svn commit: r328393 - head/sbin/fsck_ffs

2018-01-25 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Thu Jan 25 08:36:19 2018
New Revision: 328393
URL: https://svnweb.freebsd.org/changeset/base/328393

Log:
  Fix architectures where pointer and u_int have different sizes
  
  Reviewed by:  imp
  Differential Revision:https://reviews.freebsd.org/D14049

Modified:
  head/sbin/fsck_ffs/fsutil.c

Modified: head/sbin/fsck_ffs/fsutil.c
==
--- head/sbin/fsck_ffs/fsutil.c Thu Jan 25 07:27:03 2018(r328392)
+++ head/sbin/fsck_ffs/fsutil.c Thu Jan 25 08:36:19 2018(r328393)
@@ -368,8 +368,8 @@ flush(int fd, struct bufarea *bp)
switch (bp->b_type) {
case BT_SUPERBLK:
if (bp != &sblk)
-   pfatal("BUFFER 0x%x DOES NOT MATCH SBLK 0x%x\n",
-   (u_int)bp, (u_int)&sblk);
+   pfatal("BUFFER %p DOES NOT MATCH SBLK %p\n",
+   bp, &sblk);
blwrite(fd, bp->b_un.b_buf, bp->b_bno, bp->b_size);
for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize,
   j++) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328394 - head/sys/net

2018-01-25 Thread Wojciech Macek
Author: wma
Date: Thu Jan 25 12:13:41 2018
New Revision: 328394
URL: https://svnweb.freebsd.org/changeset/base/328394

Log:
  BPF: Switch to 32 bit compatible mode only when thread is 32 bit
  
  Sometimes 32 bit and 64 bit ioctls are represented by the same number.
  It causes unnecessary switch to 32 bit commpatible mode.
  
  This patch prevents switching when we are dealing with 64 bit executable.
  It fixes issue mentioned here
  
  Authored by:   Patryk Duda 
  Submitted by:  Wojciech Macek 
  Reviewed by:   andrew, wma
  Obtained from: Semihalf
  Sponsored by:  IBM, QCM Technologies
  Differential revision: https://reviews.freebsd.org/D14023

Modified:
  head/sys/net/bpf.c

Modified: head/sys/net/bpf.c
==
--- head/sys/net/bpf.c  Thu Jan 25 08:36:19 2018(r328393)
+++ head/sys/net/bpf.c  Thu Jan 25 12:13:41 2018(r328394)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1321,9 +1322,11 @@ bpfioctl(struct cdev *dev, u_long cmd, caddr_t addr, i
case BIOCGDLTLIST32:
case BIOCGRTIMEOUT32:
case BIOCSRTIMEOUT32:
-   BPFD_LOCK(d);
-   d->bd_compat32 = 1;
-   BPFD_UNLOCK(d);
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
+   BPFD_LOCK(d);
+   d->bd_compat32 = 1;
+   BPFD_UNLOCK(d);
+   }
}
 #endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328218 - in head/sys: amd64/amd64 arm/xscale/ixp425 arm64/arm64 cam cam/ctl compat/ndis dev/aacraid dev/advansys dev/ath dev/beri/virtio dev/bnxt dev/bwn dev/ciss dev/cxgbe/crypto dev

2018-01-25 Thread Bruce Evans

On Wed, 24 Jan 2018, Conrad Meyer wrote:


On Wed, Jan 24, 2018 at 10:05 AM, Warner Losh  wrote:
...

Let's start with his point about u_long vs size_t causing problems:

void*malloc(unsigned long size, struct malloc_type *type, int flags)
vs
void*mallocarray(size_t nmemb, size_t size, struct malloc_type *type,

Since size_t is long long on i386, for example,


It is?  Since when?  __size_t is uint32_t on !__LP64__.


I already correctly gave this detail and many more.  size_t is indeed
the same as u_long on __LP64__.  This tends to prevent the compiler
from noticing that the types are are logically different, but I notice.
(clang's error messages for other errors indicate that it knows that
a type typedefed as u_long is logically different from u_long, but it
would be unreasonable for it to warn about mixing them.)

size_t is not the same as u_long on __LP32__, but it has the same
representation.  Since it has higher rank, compilers can reasonably
complain about mixing them, like at least gcc does for printing size_t
with %lu format.  This helps prevent writing code that will break
(perhaps without the problem being detected at compile time) on arches
where size_t and u_long don't have the same respresentation.

I gave many more details about why the type mismatch doesn't break anything
on any supported arches and what it might break on future arches.


this can result in
undetected overflows. Such inattention to detail makes me extremely uneasy
about the rest of the code.


A similar snarky comment can be made here about inattention to detail
when making criticisms.  If __LP64__ is true, long long is the same
size as long anyway.


I gave full attention to detail.


(malloc() should also use size_t.)


That would be just churn.

The newer UMA doesn't even use u_long.  It uses plain int for sizes and
counts in all its documented APIs.  These are just "int size" and even
"int align" for uma_zcreate() and "int nitems" for uma_zone_set_max().
UMA is fundamentally array-like, with zones consisting of an array of
fairly small items.  Since it is a kernel API, it doesn't have to be
consistent with the C design error of using (unsigned) size_t for sizes
and even non-sizes (counts) in malloc() and calloc().  All allocations
are known to be tiny relative to INT32_MAX, at least for individual
elements.  (It is almost reasonable to have a single full zone of size
much larger than INT32_MAX on arches with a 64-bit address space.  But
UMA depends on callers not asking for this, else it it has many overflows.
Large item sizes are unlikely to occur, and insane nitems for 
uma_zone_set_max() is almost self-limiting:

- uma_zone_set_max(zone, -1) calculates a negative page count, then
  overflows to large-unsigned on assignment.  The result is not much
  different from starting with a large positive nitimes
- uma_zone_set_max(zone, large) overflows to a smaller page and item
  count than requested.  The nitems limit is mostly advisory (for
  future allocations), so this might not do anything worse than preventing
  future allocations.


It's an important function, but it's so poorly implement we should try
again. It is not safe nor wise to use it blindly, which was bde's larger
point.


Citation needed?


Blind use is always unwise.  Non-blind use involves looking at the caller
to see if it needs to be more careful.  This is only easy for callers that
already have bounds checking.


#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 8 / 2))
static inline bool
WOULD_OVERFLOW(size_t nmemb, size_t size)
{

return ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
nmemb > 0 && __SIZE_T_MAX / nmemb < size);
}

So if I pass in 1GB and 10, this will tell me it won't overflow because of
size_t can handle 10GB, but u_long can't.


This whole argument hinges upon incorrect assumption that size_t is
larger than u_long.


That wasn't my argument.  I said that the correctness of the code depends
on the assumption that size_t has the same representation as u_long and
more, and implicitly that it is too hard to show correctness even if you
assume this and shows inattention to detail if you don't show correctness.

Why not just write code that doesn't make assumptions?  Well, this is not
so easy with everything typedefed.  It is easier with u_long only.  Even
u_long is MD.

I forget if I pointed out the problem with converting the args before
checking them.  This is more serious than I relaized before.  It gives
the same security hole as blind truncation of the product: suppose that
the args struct *uap has nmemb in an typedefed type that you shouldn't
know.  Bad code does:

int *p;

p = mallocarrary(uap->nmemb, sizeof(*p), ..., M_WAITOK);
if (uap->nmemb > 1)
p[uap->nmemb] = 1;

If size_t is uint32_t and typeof(uap->nmemb) is uint64_t, then uap->nmemb
can be 0x10001 and the bad mallocarray() API truncates this to 1 before
checking for overflow; then th

svn commit: r328395 - head/share/man/man8

2018-01-25 Thread Ed Maste
Author: emaste
Date: Thu Jan 25 13:51:20 2018
New Revision: 328395
URL: https://svnweb.freebsd.org/changeset/base/328395

Log:
  Install uefi.8 also on arm64
  
  Our standard boot method for arm64 is via UEFI, so install the man page
  that describes the boot process.
  
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/man/man8/Makefile

Modified: head/share/man/man8/Makefile
==
--- head/share/man/man8/MakefileThu Jan 25 12:13:41 2018
(r328394)
+++ head/share/man/man8/MakefileThu Jan 25 13:51:20 2018
(r328395)
@@ -34,7 +34,7 @@ MLINKS+=yp.8 NIS.8 \
yp.8 YP.8
 .endif
 
-.if ${MACHINE_CPUARCH} == "amd64"
+.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64"
 _uefi.8= uefi.8
 
 MLINKS+=uefi.8 efi.8
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328396 - head/share/man/man8

2018-01-25 Thread Ed Maste
Author: emaste
Date: Thu Jan 25 14:36:47 2018
New Revision: 328396
URL: https://svnweb.freebsd.org/changeset/base/328396

Log:
  uefi.8: describe architecture-specific default path
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/man/man8/uefi.8

Modified: head/share/man/man8/uefi.8
==
--- head/share/man/man8/uefi.8  Thu Jan 25 13:51:20 2018(r328395)
+++ head/share/man/man8/uefi.8  Thu Jan 25 14:36:47 2018(r328396)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 24, 2018
+.Dd January 25, 2018
 .Dt UEFI 8
 .Os
 .Sh NAME
@@ -65,16 +65,20 @@ boot process proceeds as follows:
 firmware runs at power up and searches for an OS loader in the EFI system
 partition.
 The path to the loader may be set by an EFI environment variable.
-If not set, the default is
-.Pa /EFI/BOOT/BOOTX64.EFI .
+If not set, an architecture-specific default is used.
+.Bl -column -offset indent "Architecture" "Default Path"
+.It Sy Architecture Ta Sy Default Path
+.It amd64 Ta Pa /EFI/BOOT/BOOTX64.EFI
+.It arm64 Ta Pa /EFI/BOOT/BOOTAA64.EFI
+.El
+.Pp
 The default
 .Nm
 boot configuration for
 .Fx
 installs
 .Pa boot1.efi
-as
-.Pa /EFI/BOOT/BOOTX64.EFI .
+in the default path.
 .It
 .Pa boot1.efi
 reads boot configuration from
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328340 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs

2018-01-25 Thread Bruce Evans

On Wed, 24 Jan 2018, Pedro F. Giffuni wrote:


Log:
 Revert r327781,  r328093, r328056:
 ufs|ext2fs: Revert uses of mallocarray(9).

 These aren't really useful: drop them.
 Variable unsigning will be brought again later.


Variable "unsigning" (that is, adding unsign extension bugs) is even more
negatively useful than mallocarray(), so should not be brought back.

Unsigning variables used _only_ for array sizes and element counts doesn't
cause any new problems (and fixes warnings about converting from signed to
unsigned when calling malloc*()), but it is a lot of work to check that
they aren't used for other things where their signedness matters (perhaps
differences or loops that count down to -1 instead of 0).

Unsigned variables also break checking for overflow in expressions by
compiling with -ftrapv.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328340 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs

2018-01-25 Thread Pedro Giffuni



On 25/01/2018 09:42, Bruce Evans wrote:

On Wed, 24 Jan 2018, Pedro F. Giffuni wrote:


Log:
 Revert r327781,  r328093, r328056:
 ufs|ext2fs: Revert uses of mallocarray(9).

 These aren't really useful: drop them.
 Variable unsigning will be brought again later.


Variable "unsigning" (that is, adding unsign extension bugs) is even more
negatively useful than mallocarray(), so should not be brought back.


Any specific case? I already brought those back in r328346.

Unsigning variables used _only_ for array sizes and element counts 
doesn't
cause any new problems (and fixes warnings about converting from 
signed to

unsigned when calling malloc*()), but it is a lot of work to check that
they aren't used for other things where their signedness matters (perhaps
differences or loops that count down to -1 instead of 0).

I did check and had mckusick crosscheck before, but as you say it is 
usually a lot of work and my have missed something.


Pedro.

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328398 - head/cddl/lib/libdtrace

2018-01-25 Thread Mark Johnston
Author: markj
Date: Thu Jan 25 15:31:56 2018
New Revision: 328398
URL: https://svnweb.freebsd.org/changeset/base/328398

Log:
  Remove uneeded parentheses.
  
  MFC after:1 week

Modified:
  head/cddl/lib/libdtrace/tcp.d

Modified: head/cddl/lib/libdtrace/tcp.d
==
--- head/cddl/lib/libdtrace/tcp.d   Thu Jan 25 15:28:43 2018
(r328397)
+++ head/cddl/lib/libdtrace/tcp.d   Thu Jan 25 15:31:56 2018
(r328398)
@@ -260,7 +260,7 @@ translator tcpinfoh_t < struct tcphdr *p > {
tcp_ack =   p == NULL ? -1 : p->th_ack;
tcp_offset =p == NULL ? -1 : (p->th_off >> 2);
tcp_flags = p == NULL ? 0  : p->th_flags;
-   tcp_window =p == NULL ? 0  : (p->th_win);
+   tcp_window =p == NULL ? 0  : p->th_win;
tcp_checksum =  p == NULL ? 0  : ntohs(p->th_sum);
tcp_urgent =p == NULL ? 0  : p->th_urp;
tcp_hdr =   (struct tcphdr *)p;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328399 - head/sys/netinet

2018-01-25 Thread Mark Johnston
Author: markj
Date: Thu Jan 25 15:35:34 2018
New Revision: 328399
URL: https://svnweb.freebsd.org/changeset/base/328399

Log:
  Use tcpinfoh_t for TCP headers in the tcp:::debug-{drop,input} probes.
  
  The header passed to these probes has some fields converted to host
  order by tcp_fields_to_host(), so the tcpinfo_t translator doesn't do
  what we want.
  
  Submitted by: Hannes Mehnert
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D12647

Modified:
  head/sys/netinet/in_kdtrace.c

Modified: head/sys/netinet/in_kdtrace.c
==
--- head/sys/netinet/in_kdtrace.c   Thu Jan 25 15:31:56 2018
(r328398)
+++ head/sys/netinet/in_kdtrace.c   Thu Jan 25 15:35:34 2018
(r328399)
@@ -109,7 +109,7 @@ SDT_PROBE_DEFINE1_XLATE(tcp, , , siftr,
 
 SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__input,
 "struct tcpcb *", "tcpsinfo_t *" ,
-"struct tcphdr *", "tcpinfo_t *",
+"struct tcphdr *", "tcpinfoh_t *",
 "uint8_t *", "ipinfo_t *");
 
 SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__output,
@@ -123,7 +123,7 @@ SDT_PROBE_DEFINE2_XLATE(tcp, , , debug__user,
 
 SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__drop,
 "struct tcpcb *", "tcpsinfo_t *" ,
-"struct tcphdr *", "tcpinfo_t *",
+"struct tcphdr *", "tcpinfoh_t *",
 "struct mbuf *", "ipinfo_t *");
 
 SDT_PROBE_DEFINE6_XLATE(tcp, , , state__change,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328400 - head/share/man/man9

2018-01-25 Thread Warner Losh
Author: imp
Date: Thu Jan 25 15:42:21 2018
New Revision: 328400
URL: https://svnweb.freebsd.org/changeset/base/328400

Log:
  Add info about c99 designationed initializers.
  
  Differential Revision: https://reviews.freebsd.org/D13975

Modified:
  head/share/man/man9/style.9

Modified: head/share/man/man9/style.9
==
--- head/share/man/man9/style.9 Thu Jan 25 15:35:34 2018(r328399)
+++ head/share/man/man9/style.9 Thu Jan 25 15:42:21 2018(r328400)
@@ -324,6 +324,10 @@ Userspace code should include
 while kernel code should include
 .In sys/types.h .
 .Pp
+Likewise, the project is moving to using the
+.St -isoC-99
+designated initializers when it makes sense to do so.
+.Pp
 Enumeration values are all uppercase.
 .Bd -literal
 enum enumtype { ONE, TWO } et;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328401 - head/share/man/man9

2018-01-25 Thread Warner Losh
Author: imp
Date: Thu Jan 25 15:55:58 2018
New Revision: 328401
URL: https://svnweb.freebsd.org/changeset/base/328401

Log:
  Bump .Dd date for c99 change

Modified:
  head/share/man/man9/style.9

Modified: head/share/man/man9/style.9
==
--- head/share/man/man9/style.9 Thu Jan 25 15:42:21 2018(r328400)
+++ head/share/man/man9/style.9 Thu Jan 25 15:55:58 2018(r328401)
@@ -26,7 +26,7 @@
 .\"From: @(#)style 1.14 (Berkeley) 4/28/95
 .\" $FreeBSD$
 .\"
-.Dd January 18, 2018
+.Dd January 25, 2018
 .Dt STYLE 9
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328346 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs

2018-01-25 Thread Bruce Evans

On Wed, 24 Jan 2018, Pedro F. Giffuni wrote:


Log:
 ext2fs|ufs:Unsign some values related to allocation.

 When allocating memory through malloc(9), we always expect the amount of
 memory requested to be unsigned as a negative value would either stand for
 an error or an overflow.
 Unsign some values, found when considering the use of mallocarray(9), to
 avoid unnecessary casting. Also consider that indexes should be of
 at least the same size/type as the upper limit they pretend to index.


This might not break much, but it adds many more type errors and bogus
(implicit) casts than it fixes.  It actually changes the brokenness of the
first variable touched:


Modified: head/sys/fs/ext2fs/ext2_lookup.c
==
--- head/sys/fs/ext2fs/ext2_lookup.cWed Jan 24 17:52:06 2018
(r328345)
+++ head/sys/fs/ext2fs/ext2_lookup.cWed Jan 24 17:58:48 2018
(r328346)
@@ -145,9 +145,9 @@ ext2_readdir(struct vop_readdir_args *ap)
off_t offset, startoffset;
size_t readcnt, skipcnt;
ssize_t startresid;
-   int ncookies;
int DIRBLKSIZ = VTOI(ap->a_vp)->i_e2fs->e2fs_bsize;
int error;
+   u_int ncookies;


The first bug is only a style bug (unsorting the u_int after the ints even
when its variable was accidentally already before the ints.



if (uio->uio_offset < 0)
return (EINVAL);


That is the only change in this file.  No comment on other changes.

ncookies is mostly used in contexts other than for multiplying by it before
calling malloc(), and its type is now inconsistent with most other places.

The other places are:

X   ncookies = uio->uio_resid;

This has a more serious type error and consequent overflow bugs.  uio_resid
used to have type int, and cookies had to have type int to match that, else
there overflow occurs before the bounds checks.  Now uio_resid has type
ssize_t, which is excessively large on 64-bit arches (64 bits then), so the
assignment overflowed when ncookies had type int and uio_resid > INT_MAX.
Now it overflows differently when uio_resid > UINT_MAX, and unsign extension
causes overflow when uio_resid < 0.  There might be a sanity check on
uio_resid at higher levels, but I can only find a check related to EOF in
vfs_read_dirent().

Next, we do some bounds checking which seems to be correct modulo previous
overflows, and show the care needed for unsigned variables (i_size is unsigned
and must be compared with uio_offset which is signed).

Next, we assign ncookies, to ap_ncookies which still has the correct type
(plain signed int).  If ncookies were actually large enough to need a u_int,
or worse a 64-bit ssize_t, then this would overflow.

Later, we KASSERT() that ncookies > 0.  This might cause a compiler warning
"unsigned comparison with 0" now that ncookies is unsigned.  We count down
ncookies, but the loop termination condition is complicated and we don't
get any benefits from the possible micro-optimization of using ncookies as
a loop counter that counts down to 0.

To fix the problem that mallocarray() wanted a size_t arg, ncookies could
be cast to size_t, but that would be silly.  The prototype does the same
cast automatically even for cases with sign mismatches.  Now malloc()
wants a type of size_t (after further breakage to change malloc()s arg
type).  Many conversions are still involved, and casting would at most limit
compiler warnings:  the code is now:

X   malloc(ncookies * sizeof(*cookies), ...)

First, ncookies and sizeof(...) are promoted to a common type.  When ncookies
was int, usually it was promoted to size_t and sizeof(...) was not promoted.
But on exotic arches with size_t smaller than int, sizeof(...) is promoted to
int and ncookies is not promoted.

Next, the type of the result of the multiplication is the common type.

Finally, the prototype used to convert to u_long, but now converts to size_t.
When the common type is size_t, then the conversion is now null.  When the
common type was int, the conversion was promotion to u_long, but it is now
demotion to size_t.

All this only obviously works in practice because all the variables and
the product are small, so they are smaller than all of INT_MAX, SIZE_MAX
and ULONG_MAX on all supported and unsupported arches.  However, it is
hard to write bounds checks that obviously handle all cases, except
by using simple small bounds on the variables.

It is now obvious that the bounds checking is broken for general use.
There is no obvious limit on the malloc() except the file size.
However, I think cookies are only used by nfs, so this is not a
user-serving bug.  nfs just has to limit its cookie size.  It seems to
use a limit of something like NFS_SRVMAXIO (128K).  This also makes
the overflow from the ssize_t type error unreachable.  Note that it

So all of this actually works very unobviously in practice.  The sizes
are only small because nfs is the only (?) caller 

Re: svn commit: r328388 - head/share/man/man8

2018-01-25 Thread Rodney W. Grimes
[ Charset UTF-8 unsupported, converting... ]
> Author: lwhsu (ports committer)
> Date: Thu Jan 25 05:15:44 2018
> New Revision: 328388
> URL: https://svnweb.freebsd.org/changeset/base/328388
> 
> Log:
>   Fix manual page install on non-amd64
>   
>   Reviewed by:emaste, imp
>   Differential Revision:  https://reviews.freebsd.org/D14038

Um, small technical nit, *efi is not amd64 only.  There is
a 32 bit efi spec that can apply to i386, and there is also
arm using efi.

Let me quote the wiki(sic):
Processor compatibility

As of version 2.5, processor bindings exist for Itanium, x86,
x86-64, ARM (AArch32) and ARM64 (AArch64).[14] Only little-endian
processors can be supported.[15] Unofficial UEFI support is under
development for POWERPC64 by implementing TianoCore on top of
OPAL,[16] the OpenPOWER abstraction layer, running in little-endian
mode.[17] Similar projects exist for MIPS[18] and RISC-V.[19].
As of UEFI 2.7, RISC-V processor bindings have been officially
established for 32, 64 and 128-bit modes.[20]


I had already pointed out on the commit list that Ed's r328378 was
in error in that it mangled the NIS/yp links with the *efi links
within minutes of the commit happening, kinda confused why this
had to go to a differential to fix what was a rather trivial
man link error.



> Modified:
>   head/share/man/man8/Makefile
> 
> Modified: head/share/man/man8/Makefile
> ==
> --- head/share/man/man8/Makefile  Thu Jan 25 02:52:44 2018
> (r328387)
> +++ head/share/man/man8/Makefile  Thu Jan 25 05:15:44 2018
> (r328388)
> @@ -29,14 +29,15 @@ MLINKS= \
>  .if ${MK_NIS} != "no"
>  MAN+=yp.8
>  
> -MLINKS+=uefi.8 efi.8 \
> - yp.8 NIS.8 \
> +MLINKS+=yp.8 NIS.8 \
>   yp.8 nis.8 \
>   yp.8 YP.8
>  .endif
>  
>  .if ${MACHINE_CPUARCH} == "amd64"
>  _uefi.8= uefi.8
> +
> +MLINKS+=uefi.8 efi.8
>  .endif
>  
>  .include 
> 
> 

-- 
Rod Grimes rgri...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328402 - head/sys/dev/usb/controller

2018-01-25 Thread Ruslan Bukin
Author: br
Date: Thu Jan 25 16:58:23 2018
New Revision: 328402
URL: https://svnweb.freebsd.org/changeset/base/328402

Log:
  Add basic driver for Qualcomm USB 2.0 EHCI controller.
  This driver relies on system initialization in u-boot.
  
  Tested on DragonBoard 410c.
  
  Sponsored by: DARPA, AFRL

Added:
  head/sys/dev/usb/controller/ehci_msm.c   (contents, props changed)

Added: head/sys/dev/usb/controller/ehci_msm.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/usb/controller/ehci_msm.c  Thu Jan 25 16:58:23 2018
(r328402)
@@ -0,0 +1,231 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Ruslan Bukin 
+ * All rights reserved.
+ *
+ * This software was developed by BAE Systems, the University of Cambridge
+ * Computer Laboratory, and Memorial University under DARPA/AFRL contract
+ * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing
+ * (TC) research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "opt_bus.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+struct ehci_msm_softc {
+   ehci_softc_tbase;
+   struct resource *res[3];
+};
+
+static struct resource_spec ehci_msm_spec[] = {
+   { SYS_RES_MEMORY,   0,  RF_ACTIVE },
+   { SYS_RES_MEMORY,   1,  RF_ACTIVE },
+   { SYS_RES_IRQ,  0,  RF_ACTIVE },
+   { -1, 0 }
+};
+
+#defineEHCI_HC_DEVSTR  "Qualcomm USB 2.0 controller"
+
+static device_attach_t ehci_msm_attach;
+static device_detach_t ehci_msm_detach;
+
+static int
+ehci_msm_probe(device_t dev)
+{
+
+   if (!ofw_bus_is_compatible(dev, "qcom,ci-hdrc"))
+   return (ENXIO);
+
+   device_set_desc(dev, EHCI_HC_DEVSTR);
+
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+ehci_msm_attach(device_t dev)
+{
+   struct ehci_msm_softc *esc;
+   bus_space_handle_t bsh;
+   ehci_softc_t *sc;
+   int err;
+
+   esc = device_get_softc(dev);
+   sc = &esc->base;
+   sc->sc_bus.parent = dev;
+   sc->sc_bus.devices = sc->sc_devices;
+   sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
+   sc->sc_bus.dma_bits = 32;
+
+   if (bus_alloc_resources(dev, ehci_msm_spec, esc->res)) {
+   device_printf(dev, "could not allocate resources\n");
+   return (ENXIO);
+   }
+
+   sc->sc_io_tag = rman_get_bustag(esc->res[0]);
+
+   /* Get all DMA memory */
+   if (usb_bus_mem_alloc_all(&sc->sc_bus,
+   USB_GET_DMA_TAG(dev), &ehci_iterate_hw_softc)) {
+   return (ENOMEM);
+   }
+
+   /* EHCI registers */
+   sc->sc_io_tag = rman_get_bustag(esc->res[0]);
+   bsh = rman_get_bushandle(esc->res[0]);
+   sc->sc_io_size = rman_get_size(esc->res[0]);
+
+   if (bus_space_subregion(sc->sc_io_tag, bsh, 0x100,
+   sc->sc_io_size, &sc->sc_io_hdl) != 0)
+   panic("%s: unable to subregion USB host registers",
+   device_get_name(dev));
+
+   sc->sc_bus.bdev = device_add_child(dev, "usbus", -1);
+   if (!sc->sc_bus.bdev) {
+   device_printf(dev, "Could not add USB device\n");
+   goto error;
+   }
+   device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
+   device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR);
+
+   sprintf(sc->sc_vendor, "Qualcomm");
+
+   err = bus_setup_intr(dev, esc->res[2

svn commit: r328403 - head/sys/dev/sdhci

2018-01-25 Thread Ruslan Bukin
Author: br
Date: Thu Jan 25 17:00:35 2018
New Revision: 328403
URL: https://svnweb.freebsd.org/changeset/base/328403

Log:
  Add support for SDHCI controller found in Qualcomm Snapdragon 410e.
  
  Tested on DragonBoard 410c.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/sdhci/sdhci_fdt.c

Modified: head/sys/dev/sdhci/sdhci_fdt.c
==
--- head/sys/dev/sdhci/sdhci_fdt.c  Thu Jan 25 16:58:23 2018
(r328402)
+++ head/sys/dev/sdhci/sdhci_fdt.c  Thu Jan 25 17:00:35 2018
(r328403)
@@ -63,10 +63,12 @@ __FBSDID("$FreeBSD$");
 #defineSDHCI_FDT_ARMADA38X 1
 #defineSDHCI_FDT_GENERIC   2
 #defineSDHCI_FDT_XLNX_ZY7  3
+#defineSDHCI_FDT_QUALCOMM  4
 
 static struct ofw_compat_data compat_data[] = {
{ "marvell,armada-380-sdhci",   SDHCI_FDT_ARMADA38X },
{ "sdhci_generic",  SDHCI_FDT_GENERIC },
+   { "qcom,sdhci-msm-v4",  SDHCI_FDT_QUALCOMM },
{ "xlnx,zy7_sdhci", SDHCI_FDT_XLNX_ZY7 },
{ NULL, 0 }
 };
@@ -200,6 +202,10 @@ sdhci_fdt_probe(device_t dev)
break;
case SDHCI_FDT_GENERIC:
device_set_desc(dev, "generic fdt SDHCI controller");
+   break;
+   case SDHCI_FDT_QUALCOMM:
+   sc->quirks = SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE;
+   device_set_desc(dev, "Qualcomm FDT SDHCI controller");
break;
case SDHCI_FDT_XLNX_ZY7:
sc->quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328402 - head/sys/dev/usb/controller

2018-01-25 Thread Emmanuel Vadot

 Hi Ruslan,

On Thu, 25 Jan 2018 16:58:23 + (UTC)
Ruslan Bukin  wrote:

> Author: br
> Date: Thu Jan 25 16:58:23 2018
> New Revision: 328402
> URL: https://svnweb.freebsd.org/changeset/base/328402
> 
> Log:
>   Add basic driver for Qualcomm USB 2.0 EHCI controller.
>   This driver relies on system initialization in u-boot.
>   
>   Tested on DragonBoard 410c.
>   
>   Sponsored by:   DARPA, AFRL
> 
> Added:
>   head/sys/dev/usb/controller/ehci_msm.c   (contents, props changed)
> 

 The code looks like the generic-ehci, would it be better to subclass
generic-ehci to fdt and add qualcomm quirks if necessary ?

 Cheers,

-- 
Emmanuel Vadot  
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328404 - in head/sys: arm/mv/armada38x arm/xilinx conf

2018-01-25 Thread Ruslan Bukin
Author: br
Date: Thu Jan 25 17:16:29 2018
New Revision: 328404
URL: https://svnweb.freebsd.org/changeset/base/328404

Log:
  o Move sdhci_fdt to the generic files list.
  o Include Qualcomm EHCI and UART drivers to the build.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm/mv/armada38x/files.armada38x
  head/sys/arm/xilinx/files.zynq7
  head/sys/conf/files

Modified: head/sys/arm/mv/armada38x/files.armada38x
==
--- head/sys/arm/mv/armada38x/files.armada38x   Thu Jan 25 17:00:35 2018
(r328403)
+++ head/sys/arm/mv/armada38x/files.armada38x   Thu Jan 25 17:16:29 2018
(r328404)
@@ -9,4 +9,3 @@ arm/mv/armada38x/armada38x_mp.c optional smp
 arm/mv/armada38x/pmsu.cstandard
 arm/mv/armada38x/armada38x_rtc.c   optional mv_rtc fdt
 arm/mv/armada38x/armada38x_pl310.c optional pl310
-dev/sdhci/sdhci_fdt.c  optional sdhci

Modified: head/sys/arm/xilinx/files.zynq7
==
--- head/sys/arm/xilinx/files.zynq7 Thu Jan 25 17:00:35 2018
(r328403)
+++ head/sys/arm/xilinx/files.zynq7 Thu Jan 25 17:16:29 2018
(r328404)
@@ -12,7 +12,6 @@ arm/xilinx/zy7_devcfg.c   standard
 arm/xilinx/zy7_mp.coptional smp
 
 dev/cadence/if_cgem.c  optional cgem
-dev/sdhci/sdhci_fdt.c  optional sdhci
 arm/xilinx/zy7_ehci.c  optional ehci
 arm/xilinx/uart_dev_cdnc.c optional uart
 arm/xilinx/zy7_gpio.c  optional gpio

Modified: head/sys/conf/files
==
--- head/sys/conf/files Thu Jan 25 17:00:35 2018(r328403)
+++ head/sys/conf/files Thu Jan 25 17:16:29 2018(r328404)
@@ -3013,6 +3013,7 @@ dev/scc/scc_dev_quicc.c   optional scc quicc
 dev/scc/scc_dev_sab82532.c optional scc
 dev/scc/scc_dev_z8530.coptional scc
 dev/sdhci/sdhci.c  optional sdhci
+dev/sdhci/sdhci_fdt.c  optional sdhci fdt
 dev/sdhci/sdhci_fdt_gpio.c optional sdhci fdt gpio
 dev/sdhci/sdhci_if.m   optional sdhci
 dev/sdhci/sdhci_acpi.c optional sdhci acpi
@@ -3182,6 +3183,7 @@ dev/uart/uart_bus_puc.c   optional uart puc
 dev/uart/uart_bus_scc.coptional uart scc
 dev/uart/uart_core.c   optional uart
 dev/uart/uart_dbg.coptional uart gdb
+dev/uart/uart_dev_msm.coptional uart uart_msm fdt
 dev/uart/uart_dev_mvebu.c  optional uart uart_mvebu
 dev/uart/uart_dev_ns8250.c optional uart uart_ns8250 | uart uart_snps
 dev/uart/uart_dev_pl011.c  optional uart pl011
@@ -3205,6 +3207,7 @@ dev/usb/controller/musb_otg_atmelarm.coptional musb a
 dev/usb/controller/dwc_otg.c   optional dwcotg
 dev/usb/controller/dwc_otg_fdt.c   optional dwcotg fdt
 dev/usb/controller/ehci.c  optional ehci
+dev/usb/controller/ehci_msm.c  optional ehci_msm fdt
 dev/usb/controller/ehci_pci.c  optional ehci pci
 dev/usb/controller/ohci.c  optional ohci
 dev/usb/controller/ohci_pci.c  optional ohci pci
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328402 - head/sys/dev/usb/controller

2018-01-25 Thread Ruslan Bukin
On Thu, Jan 25, 2018 at 06:12:04PM +0100, Emmanuel Vadot wrote:
> > Log:
> >   Add basic driver for Qualcomm USB 2.0 EHCI controller.
> >   This driver relies on system initialization in u-boot.
> >   
> >   Tested on DragonBoard 410c.
> >   
> >   Sponsored by: DARPA, AFRL
> > 
> > Added:
> >   head/sys/dev/usb/controller/ehci_msm.c   (contents, props changed)
> > 
> 
>  The code looks like the generic-ehci, would it be better to subclass
> generic-ehci to fdt and add qualcomm quirks if necessary ?
> 

Hi Emmanuel

This driver is incomplete currently and requires initialization in u-boot.

Both system clocks and EHCI subsystem, also Qualcomm power management device 
requires full initialization.
My goal will be to extend this driver and proceed full initialization required 
for Qualcomm EHCI.

The u-boot option CONFIG_DM_DEVICE_REMOVE=n must be added in order to keep 
devices initialized before jumping to FreeBSD. We will need to get rid of these 
by adding some code to this driver I guess.

Thanks.

Ruslan
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328388 - head/share/man/man8

2018-01-25 Thread Warner Losh
On Thu, Jan 25, 2018 at 9:51 AM, Rodney W. Grimes <
free...@pdx.rh.cn85.dnsmgr.net> wrote:

> [ Charset UTF-8 unsupported, converting... ]
> > Author: lwhsu (ports committer)
> > Date: Thu Jan 25 05:15:44 2018
> > New Revision: 328388
> > URL: https://svnweb.freebsd.org/changeset/base/328388
> >
> > Log:
> >   Fix manual page install on non-amd64
> >
> >   Reviewed by:emaste, imp
> >   Differential Revision:  https://reviews.freebsd.org/D14038
>
> Um, small technical nit, *efi is not amd64 only.  There is
> a 32 bit efi spec that can apply to i386, and there is also
> arm using efi.
>

We don't support either of those yet (though, we're super close on arm,
we're not at all close on i386). Let's not confuse users until we're ready
to let people use them.

Warner
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328405 - head/sys/arm/freescale/imx

2018-01-25 Thread Ian Lepore
Author: ian
Date: Thu Jan 25 17:53:33 2018
New Revision: 328405
URL: https://svnweb.freebsd.org/changeset/base/328405

Log:
  Minor cleanups... Move DRIVER_MODULE() and other boilerplate stuff to the
  bottom of the file, where it is in most imx5/6 drivers.  Switch from an RD2
  macro using bus_space_read_2() to an inline function using bus_read_2();
  likewise for WR2.  Use RESOURCE_SPEC_END to end the resource_spec list.
  
  Net effect should be no functional changes.

Modified:
  head/sys/arm/freescale/imx/imx_wdog.c

Modified: head/sys/arm/freescale/imx/imx_wdog.c
==
--- head/sys/arm/freescale/imx/imx_wdog.c   Thu Jan 25 17:16:29 2018
(r328404)
+++ head/sys/arm/freescale/imx/imx_wdog.c   Thu Jan 25 17:53:33 2018
(r328405)
@@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$");
 struct imx_wdog_softc {
struct mtx  sc_mtx;
device_tsc_dev;
-   bus_space_tag_t sc_bst;
-   bus_space_handle_t  sc_bsh;
struct resource *sc_res[2];
uint32_tsc_timeout;
 };
@@ -63,9 +61,12 @@ struct imx_wdog_softc {
 static struct resource_spec imx_wdog_spec[] = {
{ SYS_RES_MEMORY,   0,  RF_ACTIVE },
{ SYS_RES_IRQ,  0,  RF_ACTIVE },
-   { -1, 0 }
+   RESOURCE_SPEC_END
 };
 
+#defineMEMRES  0
+#defineIRQRES  1
+
 static struct ofw_compat_data compat_data[] = {
{"fsl,imx6sx-wdt", 1},
{"fsl,imx6sl-wdt", 1},
@@ -80,28 +81,19 @@ static struct ofw_compat_data compat_data[] = {
{NULL, 0}
 };
 
-static voidimx_watchdog(void *, u_int, int *);
-static int imx_wdog_probe(device_t);
-static int imx_wdog_attach(device_t);
+static inline uint16_t
+RD2(struct imx_wdog_softc *sc, bus_size_t offs)
+{
 
-static device_method_t imx_wdog_methods[] = {
-   DEVMETHOD(device_probe, imx_wdog_probe),
-   DEVMETHOD(device_attach,imx_wdog_attach),
-   DEVMETHOD_END
-};
+   return bus_read_2(sc->sc_res[MEMRES], offs);
+}
 
-static driver_t imx_wdog_driver = {
-   "imx_wdog",
-   imx_wdog_methods,
-   sizeof(struct imx_wdog_softc),
-};
-static devclass_t imx_wdog_devclass;
-DRIVER_MODULE(imx_wdog, simplebus, imx_wdog_driver, imx_wdog_devclass, 0, 0);
+static inline void
+WR2(struct imx_wdog_softc *sc, bus_size_t offs, uint16_t val)
+{
 
-#defineRD2(_sc, _r)
\
-   bus_space_read_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r))
-#defineWR2(_sc, _r, _v)
\
-   bus_space_write_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r), (_v))
+   return bus_write_2(sc->sc_res[MEMRES], offs, val);
+}
 
 static void
 imx_watchdog(void *arg, u_int cmd, int *error)
@@ -165,12 +157,24 @@ imx_wdog_attach(device_t dev)
 
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "imx_wdt", MTX_DEF);
 
-   sc->sc_dev = dev;
-   sc->sc_bst = rman_get_bustag(sc->sc_res[0]);
-   sc->sc_bsh = rman_get_bushandle(sc->sc_res[0]);
-
/* TODO: handle interrupt */
 
EVENTHANDLER_REGISTER(watchdog_list, imx_watchdog, sc, 0);
return (0);
 }
+
+static device_method_t imx_wdog_methods[] = {
+   DEVMETHOD(device_probe, imx_wdog_probe),
+   DEVMETHOD(device_attach,imx_wdog_attach),
+   DEVMETHOD_END
+};
+
+static driver_t imx_wdog_driver = {
+   "imx_wdog",
+   imx_wdog_methods,
+   sizeof(struct imx_wdog_softc),
+};
+
+static devclass_t imx_wdog_devclass;
+
+DRIVER_MODULE(imx_wdog, simplebus, imx_wdog_driver, imx_wdog_devclass, 0, 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328406 - head/sys/fs/ext2fs

2018-01-25 Thread Pedro F. Giffuni
Author: pfg
Date: Thu Jan 25 18:01:46 2018
New Revision: 328406
URL: https://svnweb.freebsd.org/changeset/base/328406

Log:
  Minor style issue introduced in r328346.
  
  Pointed by:   bde

Modified:
  head/sys/fs/ext2fs/ext2_lookup.c

Modified: head/sys/fs/ext2fs/ext2_lookup.c
==
--- head/sys/fs/ext2fs/ext2_lookup.cThu Jan 25 17:53:33 2018
(r328405)
+++ head/sys/fs/ext2fs/ext2_lookup.cThu Jan 25 18:01:46 2018
(r328406)
@@ -145,9 +145,9 @@ ext2_readdir(struct vop_readdir_args *ap)
off_t offset, startoffset;
size_t readcnt, skipcnt;
ssize_t startresid;
+   u_int ncookies;
int DIRBLKSIZ = VTOI(ap->a_vp)->i_e2fs->e2fs_bsize;
int error;
-   u_int ncookies;
 
if (uio->uio_offset < 0)
return (EINVAL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328388 - head/share/man/man8

2018-01-25 Thread Rodney W. Grimes
[ Charset UTF-8 unsupported, converting... ]
> On Thu, Jan 25, 2018 at 9:51 AM, Rodney W. Grimes <
> free...@pdx.rh.cn85.dnsmgr.net> wrote:
> 
> > [ Charset UTF-8 unsupported, converting... ]
> > > Author: lwhsu (ports committer)
> > > Date: Thu Jan 25 05:15:44 2018
> > > New Revision: 328388
> > > URL: https://svnweb.freebsd.org/changeset/base/328388
> > >
> > > Log:
> > >   Fix manual page install on non-amd64
> > >
> > >   Reviewed by:emaste, imp
> > >   Differential Revision:  https://reviews.freebsd.org/D14038
> >
> > Um, small technical nit, *efi is not amd64 only.  There is
> > a 32 bit efi spec that can apply to i386, and there is also
> > arm using efi.
> >
> 
> We don't support either of those yet (though, we're super close on arm,
> we're not at all close on i386). Let's not confuse users until we're ready
> to let people use them.

I wrote this before the correction to add the man pages to arm,
which we do support and was a majority of the concern.


-- 
Rod Grimes rgri...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328407 - head/sys/arm/freescale/imx

2018-01-25 Thread Ian Lepore
Author: ian
Date: Thu Jan 25 18:08:56 2018
New Revision: 328407
URL: https://svnweb.freebsd.org/changeset/base/328407

Log:
  Fix return style in RD2.  Remove bogus return value from a void function
  in WR2 (I have no idea why that didn't result in a compile error).

Modified:
  head/sys/arm/freescale/imx/imx_wdog.c

Modified: head/sys/arm/freescale/imx/imx_wdog.c
==
--- head/sys/arm/freescale/imx/imx_wdog.c   Thu Jan 25 18:01:46 2018
(r328406)
+++ head/sys/arm/freescale/imx/imx_wdog.c   Thu Jan 25 18:08:56 2018
(r328407)
@@ -85,14 +85,14 @@ static inline uint16_t
 RD2(struct imx_wdog_softc *sc, bus_size_t offs)
 {
 
-   return bus_read_2(sc->sc_res[MEMRES], offs);
+   return (bus_read_2(sc->sc_res[MEMRES], offs));
 }
 
 static inline void
 WR2(struct imx_wdog_softc *sc, bus_size_t offs, uint16_t val)
 {
 
-   return bus_write_2(sc->sc_res[MEMRES], offs, val);
+   bus_write_2(sc->sc_res[MEMRES], offs, val);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328408 - head/sys/powerpc/powerpc

2018-01-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Jan 25 18:09:26 2018
New Revision: 328408
URL: https://svnweb.freebsd.org/changeset/base/328408

Log:
  Treat DSE exceptions like DSI exceptions when generating signinfo.
  Both can generate SIGSEGV, but DSEs would have put the wrong address
  into the siginfo structure when the signal was delivered.
  
  MFC after:1 week

Modified:
  head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Thu Jan 25 18:08:56 2018
(r328407)
+++ head/sys/powerpc/powerpc/exec_machdep.c Thu Jan 25 18:09:26 2018
(r328408)
@@ -154,7 +154,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask
 * Fill siginfo structure.
 */
ksi->ksi_info.si_signo = ksi->ksi_signo;
-   ksi->ksi_info.si_addr = (void *)((tf->exc == EXC_DSI) ? 
+   ksi->ksi_info.si_addr =
+   (void *)((tf->exc == EXC_DSI || tf->exc == EXC_DSE) ? 
tf->dar : tf->srr0);
 
#ifdef COMPAT_FREEBSD32
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328409 - head/sys/powerpc/powerpc

2018-01-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Jan 25 18:10:33 2018
New Revision: 328409
URL: https://svnweb.freebsd.org/changeset/base/328409

Log:
  Avoid all SLB operations in trap handling if the process is not using a
  software-managed SLB.

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Thu Jan 25 18:09:26 2018
(r328408)
+++ head/sys/powerpc/powerpc/trap.c Thu Jan 25 18:10:33 2018
(r328409)
@@ -629,8 +629,9 @@ syscall(struct trapframe *frame)
 * Speculatively restore last user SLB segment, which we know is
 * invalid already, since we are likely to do copyin()/copyout().
 */
-   __asm __volatile ("slbmte %0, %1; isync" ::
-"r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
+   if (td->td_pcb->pcb_cpu.aim.usr_vsid != 0)
+   __asm __volatile ("slbmte %0, %1; isync" ::
+   "r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
 #endif
 
error = syscallenter(td);
@@ -690,6 +691,9 @@ handle_user_slb_spill(pmap_t pm, vm_offset_t addr)
struct slb *user_entry;
uint64_t esid;
int i;
+
+   if (pm->pm_slb == NULL)
+   return (-1);
 
esid = (uintptr_t)addr >> ADDR_SR_SHFT;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328346 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs

2018-01-25 Thread Pedro Giffuni



On 01/25/18 11:28, Bruce Evans wrote:

On Wed, 24 Jan 2018, Pedro F. Giffuni wrote:


Log:
 ext2fs|ufs:Unsign some values related to allocation.

 When allocating memory through malloc(9), we always expect the 
amount of
 memory requested to be unsigned as a negative value would either 
stand for

 an error or an overflow.
 Unsign some values, found when considering the use of 
mallocarray(9), to

 avoid unnecessary casting. Also consider that indexes should be of
 at least the same size/type as the upper limit they pretend to index.


This might not break much, but it adds many more type errors and bogus
(implicit) casts than it fixes.  It actually changes the brokenness of 
the

first variable touched:


Modified: head/sys/fs/ext2fs/ext2_lookup.c
== 

--- head/sys/fs/ext2fs/ext2_lookup.c    Wed Jan 24 17:52:06 2018    
(r328345)
+++ head/sys/fs/ext2fs/ext2_lookup.c    Wed Jan 24 17:58:48 2018    
(r328346)

@@ -145,9 +145,9 @@ ext2_readdir(struct vop_readdir_args *ap)
off_t offset, startoffset;
size_t readcnt, skipcnt;
ssize_t startresid;
-    int ncookies;
int DIRBLKSIZ = VTOI(ap->a_vp)->i_e2fs->e2fs_bsize;
int error;
+    u_int ncookies;


The first bug is only a style bug (unsorting the u_int after the ints 
even

when its variable was accidentally already before the ints.


Yup, my error.



if (uio->uio_offset < 0)
    return (EINVAL);


That is the only change in this file.  No comment on other changes.

ncookies is mostly used in contexts other than for multiplying by it 
before
calling malloc(), and its type is now inconsistent with most other 
places.


The other places are:

X ncookies = uio->uio_resid;

This has a more serious type error and consequent overflow bugs. 
uio_resid
used to have type int, and cookies had to have type int to match that, 
else

there overflow occurs before the bounds checks.  Now uio_resid has type
ssize_t, which is excessively large on 64-bit arches (64 bits then), 
so the

assignment overflowed when ncookies had type int and uio_resid > INT_MAX.
Now it overflows differently when uio_resid > UINT_MAX, and unsign 
extension

causes overflow when uio_resid < 0.  There might be a sanity check on
uio_resid at higher levels, but I can only find a check related to EOF in
vfs_read_dirent().

I will argue that none of the code in this function is prepared for the 
eventually of

uio->uio_resid < 0

In that case we would have a rather spectacular failure in malloc.
Unsigning ncookies is a theoretical, although likely impractical, 
improvement here.


It is not clear to me that using int or u_int makes a difference given 
it is a local variable

and in this scope the signedness of the variable is basically irrelevant.

From a logical point of view .. we can't really have a negative number 
of cookies.


Next, we do some bounds checking which seems to be correct modulo 
previous
overflows, and show the care needed for unsigned variables (i_size is 
unsigned

and must be compared with uio_offset which is signed).

Next, we assign ncookies, to ap_ncookies which still has the correct type
(plain signed int).  If ncookies were actually large enough to need a 
u_int,

or worse a 64-bit ssize_t, then this would overflow.

Later, we KASSERT() that ncookies > 0.  This might cause a compiler 
warning
"unsigned comparison with 0" now that ncookies is unsigned.  We count 
down

ncookies, but the loop termination condition is complicated and we don't
get any benefits from the possible micro-optimization of using 
ncookies as

a loop counter that counts down to 0.

To fix the problem that mallocarray() wanted a size_t arg, ncookies could
be cast to size_t, but that would be silly.  The prototype does the same
cast automatically even for cases with sign mismatches.  Now malloc()
wants a type of size_t (after further breakage to change malloc()s arg
type).  Many conversions are still involved, and casting would at most 
limit

compiler warnings:  the code is now:

X malloc(ncookies * sizeof(*cookies), ...)

First, ncookies and sizeof(...) are promoted to a common type. When 
ncookies
was int, usually it was promoted to size_t and sizeof(...) was not 
promoted.
But on exotic arches with size_t smaller than int, sizeof(...) is 
promoted to

int and ncookies is not promoted.

Next, the type of the result of the multiplication is the common type.

Finally, the prototype used to convert to u_long, but now converts to 
size_t.

When the common type is size_t, then the conversion is now null. When the
common type was int, the conversion was promotion to u_long, but it is 
now

demotion to size_t.

All this only obviously works in practice because all the variables and
the product are small, so they are smaller than all of INT_MAX, SIZE_MAX
and ULONG_MAX on all supported and unsupported arches.  However, it is
hard to write bounds checks that obviously handle all cases, except
by using 

Re: svn commit: r328388 - head/share/man/man8

2018-01-25 Thread Andrew Turner

> On 25 Jan 2018, at 17:43, Warner Losh  wrote:
> 
> 
> 
> On Thu, Jan 25, 2018 at 9:51 AM, Rodney W. Grimes 
> mailto:free...@pdx.rh.cn85.dnsmgr.net>> 
> wrote:
> [ Charset UTF-8 unsupported, converting... ]
> > Author: lwhsu (ports committer)
> > Date: Thu Jan 25 05:15:44 2018
> > New Revision: 328388
> > URL: https://svnweb.freebsd.org/changeset/base/328388 
> > 
> >
> > Log:
> >   Fix manual page install on non-amd64
> >
> >   Reviewed by:emaste, imp
> >   Differential Revision:  https://reviews.freebsd.org/D14038 
> > 
> 
> Um, small technical nit, *efi is not amd64 only.  There is
> a 32 bit efi spec that can apply to i386, and there is also
> arm using efi.
> 
> We don't support either of those yet (though, we're super close on arm, we're 
> not at all close on i386). Let's not confuse users until we're ready to let 
> people use them.

We’ve had working arm support for over 2 years. The issue seems to be because 
we normally try to use it with U-Boot. Using the EDK2 base UEFI under qemu 
works.

Andrew
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328346 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs

2018-01-25 Thread Bruce Evans

On Thu, 25 Jan 2018, Pedro Giffuni wrote:

This is almost unreadable due to hard-coded UTF-8 (mostly for tabs corrupted
to spaces) even in previously-literally quoted C code.


On 01/25/18 11:28, Bruce Evans wrote:

On Wed, 24 Jan 2018, Pedro F. Giffuni wrote:


[... Most unreadable lines deleted]


X ncookies = uio->uio_resid;

This has a more serious type error and consequent overflow bugs. uio_resid
used to have type int, and cookies had to have type int to match that, else
there overflow occurs before the bounds checks.?? Now uio_resid has type
ssize_t, which is excessively large on 64-bit arches (64 bits then), so the
assignment overflowed when ncookies had type int and uio_resid > INT_MAX.
Now it overflows differently when uio_resid > UINT_MAX, and unsign 
extension

causes overflow when uio_resid < 0.?? There might be a sanity check on
uio_resid at higher levels, but I can only find a check related to EOF in
vfs_read_dirent().

I will argue that none of the code in this function is prepared for the 
eventually of

uio->uio_resid < 0


All of it except the cookies code has to be prepared for that, and seems
to handle it OK, since this userland can set uio_resid.  The other code
is not broken by either the ssize_t expansion or the unsigned bugs, since
it mostly doesn't truncate uio_resid by assigning it to a variable of the
wrong type (it uses uio->uio_resid in-place, except for copying its initial
value to startresid, and startresid is not missing the ssize_t expansion).
It mostly does comparisons of the form (uio->uio_resid > 0), where it is
0 in uio_resid means EOF, negative is treated as EOF, and strictly positive
means more to do.

There is a clear up-front check that uio_offset >= 0 (return EINVAL if
uio_offset < 0).  This is not needed for the trusted nfs caller, but is
needed for syscalls and is done for both.


In that case we would have a rather spectacular failure in malloc.
Unsigning ncookies is a theoretical, although likely impractical, improvement 
here.


No, it increases the bug slightly.  E.g., if uio_resid is -1, ncookies
was -1 / (offsetof(...) + 4) + 1 = 0 + 1 after rounding.  This might even
work (1 cookie at a time, just like if the caller asked for that).  Now
ncookies is -1U / (offsetof(...) + 4) + 1 = a large value.  However, if
uio_resid was slightly more negative than -2 * (offsetof(...) + 4), then
ncookies was -1 and in the multiplication this overflows to -1U = a large
value and the result is much the same as for earlier overflow on assignment
to u_int ncookies.

This code only works because (if?) nfs is the only caller and nfs never
passes insane values.

It is not clear to me that using int or u_int makes a difference given it is 
a local variable

and in this scope the signedness of the variable is basically irrelevant.


It is clear to me that overflow bugs occur with both if untrusted callers are
allowed.

From a logical point of view .. we can't really have a negative number of 
cookies.


Malicious and buggy callers do illogical things to get through holes in
your logic.

It is also illogical to have a zero number of cookies, but ncookies can
be 0 in various ways.  First, ncookies is 0 in the EOF case (and cookies
are requested).  We depend on 0 not being an invalid size for malloc()
so that we malloc() nothing and later do more nothings in the main loop.
This is a standard use for 0.  If you don't like negative numbers, then
you also shouldn't like 0.  Both exist to make some calculations easier.
Later, ncookies is abused as a residual count, so it becomes 0 at the end.
This is another standard use for 0.

Bruce___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328410 - head/usr.sbin/bsdinstall/partedit

2018-01-25 Thread Ed Maste
Author: emaste
Date: Thu Jan 25 19:57:21 2018
New Revision: 328410
URL: https://svnweb.freebsd.org/changeset/base/328410

Log:
  bsdinstall: enable SUJ by default (revert r327890)
  
  fsck should be fixed as of r328092.
  
  PR:   225110
  Tested by:dumbbell, Arshan Khanifar 

Modified:
  head/usr.sbin/bsdinstall/partedit/gpart_ops.c

Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Thu Jan 25 18:10:33 
2018(r328409)
+++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c   Thu Jan 25 19:57:21 
2018(r328410)
@@ -91,7 +91,8 @@ newfs_command(const char *fstype, char *command, int u
{"SU", "Softupdates",
"Enable softupdates (default)", 1 },
{"SUJ", "Softupdates journaling",
-   "Enable file system journaling", 0 },
+   "Enable file system journaling (default - "
+   "turn off for SSDs)", 1 },
{"TRIM", "Enable SSD TRIM support",
"Enable TRIM support, useful on solid-state drives",
0 },
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328346 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs

2018-01-25 Thread Pedro Giffuni


On 25/01/2018 14:24, Bruce Evans wrote:

On Thu, 25 Jan 2018, Pedro Giffuni wrote:

This is almost unreadable due to hard-coded UTF-8 (mostly for tabs 
corrupted

to spaces) even in previously-literally quoted C code.


Mailer agents ... they all suck :(

On 01/25/18 11:28, Bruce Evans wrote:

On Wed, 24 Jan 2018, Pedro F. Giffuni wrote:


[... Most unreadable lines deleted]


X ncookies = uio->uio_resid;

This has a more serious type error and consequent overflow bugs. 
uio_resid
used to have type int, and cookies had to have type int to match 
that, else

there overflow occurs before the bounds checks.  Now uio_resid has type
ssize_t, which is excessively large on 64-bit arches (64 bits then), 
so the
assignment overflowed when ncookies had type int and uio_resid > 
INT_MAX.
Now it overflows differently when uio_resid > UINT_MAX, and unsign 
extension

causes overflow when uio_resid < 0.  There might be a sanity check on
uio_resid at higher levels, but I can only find a check related to 
EOF in

vfs_read_dirent().

I will argue that none of the code in this function is prepared for 
the eventually of

uio->uio_resid < 0


All of it except the cookies code has to be prepared for that, and seems
to handle it OK, since this userland can set uio_resid.  The other code
is not broken by either the ssize_t expansion or the unsigned bugs, since
it mostly doesn't truncate uio_resid by assigning it to a variable of the
wrong type (it uses uio->uio_resid in-place, except for copying its 
initial
value to startresid, and startresid is not missing the ssize_t 
expansion).

It mostly does comparisons of the form (uio->uio_resid > 0), where it is
0 in uio_resid means EOF, negative is treated as EOF, and strictly 
positive

means more to do.

There is a clear up-front check that uio_offset >= 0 (return EINVAL if
uio_offset < 0).  This is not needed for the trusted nfs caller, but is
needed for syscalls and is done for both.


In that case we would have a rather spectacular failure in malloc.
Unsigning ncookies is a theoretical, although likely impractical, 
improvement here.


No, it increases the bug slightly.  E.g., if uio_resid is -1, ncookies
was -1 / (offsetof(...) + 4) + 1 = 0 + 1 after rounding.  This might even
work (1 cookie at a time, just like if the caller asked for that).  Now
ncookies is -1U / (offsetof(...) + 4) + 1 = a large value. However, if
uio_resid was slightly more negative than -2 * (offsetof(...) + 4), then
ncookies was -1 and in the multiplication this overflows to -1U = a large
value and the result is much the same as for earlier overflow on 
assignment

to u_int ncookies.

This code only works because (if?) nfs is the only caller and nfs never
passes insane values.



I am starting to think that we should simply match uio_resid and set it 
to ssize_t.

Returning the value to int is certainly not the solution.

It is not clear to me that using int or u_int makes a difference 
given it is a local variable
and in this scope the signedness of the variable is basically 
irrelevant.


It is clear to me that overflow bugs occur with both if untrusted 
callers are

allowed.

From a logical point of view .. we can't really have a negative 
number of cookies.


Malicious and buggy callers do illogical things to get through holes in
your logic.

It is also illogical to have a zero number of cookies, but ncookies can
be 0 in various ways.  First, ncookies is 0 in the EOF case (and cookies
are requested).  We depend on 0 not being an invalid size for malloc()
so that we malloc() nothing and later do more nothings in the main loop.
This is a standard use for 0.  If you don't like negative numbers, then
you also shouldn't like 0.  Both exist to make some calculations easier.
Later, ncookies is abused as a residual count, so it becomes 0 at the 
end.

This is another standard use for 0.

Bruce


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328388 - head/share/man/man8

2018-01-25 Thread Warner Losh
On Thu, Jan 25, 2018 at 12:16 PM, Andrew Turner 
wrote:

>
> On 25 Jan 2018, at 17:43, Warner Losh  wrote:
>
>
>
> On Thu, Jan 25, 2018 at 9:51 AM, Rodney W. Grimes <
> free...@pdx.rh.cn85.dnsmgr.net> wrote:
>
>> [ Charset UTF-8 unsupported, converting... ]
>> > Author: lwhsu (ports committer)
>> > Date: Thu Jan 25 05:15:44 2018
>> > New Revision: 328388
>> > URL: https://svnweb.freebsd.org/changeset/base/328388
>> >
>> > Log:
>> >   Fix manual page install on non-amd64
>> >
>> >   Reviewed by:emaste, imp
>> >   Differential Revision:  https://reviews.freebsd.org/D14038
>>
>> Um, small technical nit, *efi is not amd64 only.  There is
>> a 32 bit efi spec that can apply to i386, and there is also
>> arm using efi.
>>
>
> We don't support either of those yet (though, we're super close on arm,
> we're not at all close on i386). Let's not confuse users until we're ready
> to let people use them.
>
>
> We’ve had working arm support for over 2 years. The issue seems to be
> because we normally try to use it with U-Boot. Using the EDK2 base UEFI
> under qemu works.
>

Right. armv6/v7 support is kinda there, but most of the 'kinda' comes from
external factors, not our code base. Those have mostly been fixed, I think
the latest round of u-boot updates will be sufficient that we can recommend
using it...

Warner
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328411 - in head/stand/efi: include loader

2018-01-25 Thread Ed Maste
Author: emaste
Date: Thu Jan 25 20:09:51 2018
New Revision: 328411
URL: https://svnweb.freebsd.org/changeset/base/328411

Log:
  loader.efi: add missing EFI GUIDs
  
  These were found during bring-up on a new arm64 platform and in an
  amd64 VM.
  
  Submitted by: Arshan Khanifar 
  Reviewed by:  imp
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D14036

Modified:
  head/stand/efi/include/efiapi.h
  head/stand/efi/loader/main.c

Modified: head/stand/efi/include/efiapi.h
==
--- head/stand/efi/include/efiapi.h Thu Jan 25 19:57:21 2018
(r328410)
+++ head/stand/efi/include/efiapi.h Thu Jan 25 20:09:51 2018
(r328411)
@@ -840,6 +840,9 @@ typedef struct {
 #define SMBIOS_TABLE_GUID \
 { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 
0x4d} }
 
+#define SMBIOS3_TABLE_GUID \
+   { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 
0xe3, 0x94} }
+
 #define SAL_SYSTEM_TABLE_GUID  \
 { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 
0x4d} }
 
@@ -851,6 +854,15 @@ typedef struct {
 
 #define HOB_LIST_TABLE_GUID \
 { 0x7739f24c, 0x93d7, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 
0x4d} }
+
+#define LZMA_DECOMPRESSION_GUID \
+   { 0xee4e5898, 0x3914, 0x4259, {0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x3, 
0xcf} }
+
+#define ARM_MP_CORE_INFO_TABLE_GUID \
+   { 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 
0xe8, 0x34} }
+
+#define ESRT_TABLE_GUID \
+   { 0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 
0x21, 0x80} }
 
 #define MEMORY_TYPE_INFORMATION_TABLE_GUID \
 { 0x4c19049f, 0x4137, 0x4dd3, {0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 
0xfa} }

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cThu Jan 25 19:57:21 2018
(r328410)
+++ head/stand/efi/loader/main.cThu Jan 25 20:09:51 2018
(r328411)
@@ -65,8 +65,12 @@ EFI_GUID imgid = LOADED_IMAGE_PROTOCOL;
 EFI_GUID mps = MPS_TABLE_GUID;
 EFI_GUID netid = EFI_SIMPLE_NETWORK_PROTOCOL;
 EFI_GUID smbios = SMBIOS_TABLE_GUID;
+EFI_GUID smbios3 = SMBIOS3_TABLE_GUID;
 EFI_GUID dxe = DXE_SERVICES_TABLE_GUID;
 EFI_GUID hoblist = HOB_LIST_TABLE_GUID;
+EFI_GUID lzmadecomp = LZMA_DECOMPRESSION_GUID;
+EFI_GUID mpcore = ARM_MP_CORE_INFO_TABLE_GUID;
+EFI_GUID esrt = ESRT_TABLE_GUID;
 EFI_GUID memtype = MEMORY_TYPE_INFORMATION_TABLE_GUID;
 EFI_GUID debugimg = DEBUG_IMAGE_INFO_TABLE_GUID;
 EFI_GUID fdtdtb = FDT_TABLE_GUID;
@@ -655,10 +659,18 @@ command_configuration(int argc, char *argv[])
else if (!memcmp(guid, &smbios, sizeof(EFI_GUID)))
printf("SMBIOS Table %p",
ST->ConfigurationTable[i].VendorTable);
+   else if (!memcmp(guid, &smbios3, sizeof(EFI_GUID)))
+   printf("SMBIOS3 Table");
else if (!memcmp(guid, &dxe, sizeof(EFI_GUID)))
printf("DXE Table");
else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID)))
printf("HOB List Table");
+   else if (!memcmp(guid, &lzmadecomp, sizeof(EFI_GUID)))
+   printf("LZMA Compression");
+   else if (!memcmp(guid, &mpcore, sizeof(EFI_GUID)))
+   printf("ARM MpCore Information Table");
+   else if (!memcmp(guid, &esrt, sizeof(EFI_GUID)))
+   printf("ESRT Table");
else if (!memcmp(guid, &memtype, sizeof(EFI_GUID)))
printf("Memory Type Information Table");
else if (!memcmp(guid, &debugimg, sizeof(EFI_GUID)))
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328412 - head/share/vt/keymaps

2018-01-25 Thread Ed Maste
Author: emaste
Date: Thu Jan 25 21:13:42 2018
New Revision: 328412
URL: https://svnweb.freebsd.org/changeset/base/328412

Log:
  vt: add Ctrl+/ key mapping
  
  This matches Xorg's handling of Ctrl+/ and may be useful as a tmux
  escape.
  
  PR:   212197
  Submitted by: martin at sugioarto.com
  Tested by:Arshan Khanifar 
  MFC after:2 weeks
  Relnotes: Yes

Modified:
  head/share/vt/keymaps/us.kbd

Modified: head/share/vt/keymaps/us.kbd
==
--- head/share/vt/keymaps/us.kbdThu Jan 25 20:09:51 2018
(r328411)
+++ head/share/vt/keymaps/us.kbdThu Jan 25 21:13:42 2018
(r328412)
@@ -56,7 +56,7 @@
   050   'm''M'cr cr 'm''M'cr cr  C
   051   ',''<'nopnop',''<'nopnop O
   052   '.''>'nopnop'.''>'nopnop O
-  053   '/''?'nopnop'/''?'nopnop O
+  053   '/''?'0x1f   nop'/''?'nopnop O
   054   rshift rshift rshift rshift rshift rshift rshift rshift  O
   055   '*''*''*''*''*''*''*''*' O
   056   lalt   lalt   lalt   lalt   lalt   lalt   lalt   laltO
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328413 - head

2018-01-25 Thread Wolfram Schneider
Author: wosch
Date: Thu Jan 25 21:36:26 2018
New Revision: 328413
URL: https://svnweb.freebsd.org/changeset/base/328413

Log:
  `make installkernel' should display a completed message if done
  
  PR:   225159
  Reviewed by:  bdrewery
  Approved by:  cem (mentor)
  Differential Revision:https://reviews.freebsd.org/D13940

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Thu Jan 25 21:13:42 2018(r328412)
+++ head/Makefile.inc1  Thu Jan 25 21:36:26 2018(r328413)
@@ -1447,20 +1447,26 @@ reinstallkernel reinstallkernel.debug: _installcheck_k
false
 .endif
@echo "--"
-   @echo ">>> Installing kernel ${INSTALLKERNEL}"
+   @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
@echo "--"
${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${CROSSENV} PATH=${TMPPATH} \
${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} 
${.TARGET:S/kernel//}
+   @echo "--"
+   @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C 
date)"
+   @echo "--"
 .endif
 .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
 .for _kernel in ${BUILDKERNELS:[2..-1]}
@echo "--"
-   @echo ">>> Installing kernel ${_kernel}"
+   @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
@echo "--"
${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
${CROSSENV} PATH=${TMPPATH} \
${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} 
${.TARGET:S/kernel//}
+   @echo "--"
+   @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
+   @echo "--"
 .endfor
 .endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328415 - in head/sys: cam/scsi conf

2018-01-25 Thread Warner Losh
Author: imp
Date: Thu Jan 25 21:38:30 2018
New Revision: 328415
URL: https://svnweb.freebsd.org/changeset/base/328415

Log:
  Track Ref / DeRef and Hold / Unhold that da is doing to track down
  leaks. We assume each source can be taken / dropped only once and
  don't recurse. These are only enabled via DA_TRACK_REFS or
  INVARIANTS. There appreas to be a reference leak under extreme load,
  and these should help us colaberatively work it out. It also documents
  better the reference / holding protocol better.
  
  Reviewed by: ken@, scottl@
  Sponsored by: Netflix
  Differential Revision: https://reviews.freebsd.org/D14040

Modified:
  head/sys/cam/scsi/scsi_da.c
  head/sys/conf/options

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Thu Jan 25 21:38:09 2018(r328414)
+++ head/sys/cam/scsi/scsi_da.c Thu Jan 25 21:38:30 2018(r328415)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #ifdef _KERNEL
+#include "opt_da.h"
 #include 
 #include 
 #include 
@@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #endif /* _KERNEL */
 
 #ifndef _KERNEL
@@ -291,6 +293,18 @@ struct disk_params {
 
 #define DA_WORK_TUR(1 << 16)
 
+typedef enum {
+   DA_REF_OPEN = 1,
+   DA_REF_OPEN_HOLD,
+   DA_REF_CLOSE_HOLD,
+   DA_REF_PROBE_HOLD,
+   DA_REF_TUR,
+   DA_REF_GEOM,
+   DA_REF_SYSCTL,
+   DA_REF_REPROBE,
+   DA_REF_MAX  /* KEEP LAST */
+} da_ref_token;
+
 struct da_softc {
struct   cam_iosched_softc *cam_iosched;
struct   bio_queue_head delete_run_queue;
@@ -335,6 +349,7 @@ struct da_softc {
uint8_t  unmap_buf[UNMAP_BUF_SIZE];
struct scsi_read_capacity_data_long rcaplong;
struct callout  mediapoll_c;
+   int ref_flags[DA_REF_MAX];
 #ifdef CAM_IO_STATS
struct sysctl_ctx_list  sysctl_stats_ctx;
struct sysctl_oid   *sysctl_stats_tree;
@@ -1469,6 +1484,143 @@ PERIPHDRIVER_DECLARE(da, dadriver);
 
 static MALLOC_DEFINE(M_SCSIDA, "scsi_da", "scsi_da buffers");
 
+/*
+ * This driver takes out references / holds in well defined pairs, never
+ * recursively. These macros / inline functions enforce those rules. They
+ * are only enabled with DA_TRACK_REFS or INVARIANTS. If DA_TRACK_REFS is
+ * defined to be 2 or larger, the tracking also includes debug printfs.
+ */
+#if defined(DA_TRACK_REFS) || defined(INVARIANTS)
+
+#ifndef DA_TRACK_REFS
+#define DA_TRACK_REFS 1
+#endif
+
+#if DA_TRACK_REFS > 1
+#define CAM_PERIPH_PRINT(p, msg, args...)  \
+printf("%s%d:" msg, (periph)->periph_name, (periph)->unit_number, ##args)
+
+static const char *da_ref_text[] = {
+   "bogus",
+   "open",
+   "open hold",
+   "close hold",
+   "reprobe hold",
+   "Test Unit Ready",
+   "Geom",
+   "sysctl",
+   "reprobe",
+   "max -- also bogus"
+};
+
+#else
+#define CAM_PERIPH_PRINT(p, msg, args...)
+#endif
+
+static inline void
+token_sanity(da_ref_token token)
+{
+   if ((unsigned)token >= DA_REF_MAX)
+   panic("Bad token value passed in %d\n", token);
+}
+
+static inline int
+da_periph_hold(struct cam_periph *periph, int priority, da_ref_token token)
+{
+   int err = cam_periph_hold(periph, priority);
+
+   token_sanity(token);
+   CAM_PERIPH_PRINT(periph, "Holding device %s (%d): %d\n",
+   da_ref_text[token], token, err);
+   if (err == 0) {
+   int cnt;
+   struct da_softc *softc = periph->softc;
+
+   cnt = atomic_fetchadd_int(&softc->ref_flags[token], 1);
+   if (cnt != 0)
+   panic("Re-holding for reason %d, cnt = %d", token, cnt);
+   }
+   return (err);
+}
+
+static inline void
+da_periph_unhold(struct cam_periph *periph, da_ref_token token)
+{
+   int cnt;
+   struct da_softc *softc = periph->softc;
+
+   token_sanity(token);
+   cam_periph_unhold(periph);
+   CAM_PERIPH_PRINT(periph, "Unholding device %s (%d)\n",
+   da_ref_text[token], token);
+   cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1);
+   if (cnt != 1)
+   panic("Unholding %d with cnt = %d", token, cnt);
+}
+
+static inline int
+da_periph_acquire(struct cam_periph *periph, da_ref_token token)
+{
+   int err = cam_periph_acquire(periph);
+
+   token_sanity(token);
+   CAM_PERIPH_PRINT(periph, "acquiring device %s (%d): %d\n",
+   da_ref_text[token], token, err);
+   if (err == CAM_REQ_CMP) {
+   int cnt;
+   struct da_softc *softc = periph->softc;
+
+   cnt = atomic_fetchadd_int(&softc->ref_flags[token], 1);
+   if (cnt != 0)
+   panic("Re-refing for reason %d, cnt = %d", token, cnt);
+   }
+   return (err);
+}
+
+static inline void
+da_periph

svn commit: r328414 - head/sys/cam

2018-01-25 Thread Warner Losh
Author: imp
Date: Thu Jan 25 21:38:09 2018
New Revision: 328414
URL: https://svnweb.freebsd.org/changeset/base/328414

Log:
  When devices are invalidated, there's some cases where ccbs for that
  device still wind up in xpt_done after the path has been
  invalidated. Since we don't always need sim or devq, add some guard
  rails to only fail if we have to use them.
  
  Sponsored by: Netflix
  Differential Revision: https://reviews.freebsd.org/D14040

Modified:
  head/sys/cam/cam_xpt.c

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Thu Jan 25 21:36:26 2018(r328413)
+++ head/sys/cam/cam_xpt.c  Thu Jan 25 21:38:09 2018(r328414)
@@ -5374,8 +5374,8 @@ xpt_path_mtx(struct cam_path *path)
 static void
 xpt_done_process(struct ccb_hdr *ccb_h)
 {
-   struct cam_sim *sim;
-   struct cam_devq *devq;
+   struct cam_sim *sim = NULL;
+   struct cam_devq *devq = NULL;
struct mtx *mtx = NULL;
 
 #if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING)
@@ -5418,9 +5418,15 @@ xpt_done_process(struct ccb_hdr *ccb_h)
mtx_unlock(&xsoftc.xpt_highpower_lock);
}
 
-   sim = ccb_h->path->bus->sim;
+   /*
+* Insulate against a race where the periph is destroyed
+* but CCBs are still not all processed.
+*/
+   if (ccb_h->path->bus)
+   sim = ccb_h->path->bus->sim;
 
if (ccb_h->status & CAM_RELEASE_SIMQ) {
+   KASSERT(sim, ("sim missing for CAM_RELEASE_SIMQ request"));
xpt_release_simq(sim, /*run_queue*/FALSE);
ccb_h->status &= ~CAM_RELEASE_SIMQ;
}
@@ -5431,9 +5437,12 @@ xpt_done_process(struct ccb_hdr *ccb_h)
ccb_h->status &= ~CAM_DEV_QFRZN;
}
 
-   devq = sim->devq;
if ((ccb_h->func_code & XPT_FC_USER_CCB) == 0) {
struct cam_ed *dev = ccb_h->path->device;
+
+   if (sim)
+   devq = sim->devq;
+   KASSERT(devq, ("sim missing for XPT_FC_USER_CCB request"));
 
mtx_lock(&devq->send_mtx);
devq->send_active--;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328416 - head/sys/modules/cam

2018-01-25 Thread Warner Losh
Author: imp
Date: Thu Jan 25 21:48:07 2018
New Revision: 328416
URL: https://svnweb.freebsd.org/changeset/base/328416

Log:
  Add new opt_da.h for stand-alone build.
  
  Sponsored by: Netflix

Modified:
  head/sys/modules/cam/Makefile

Modified: head/sys/modules/cam/Makefile
==
--- head/sys/modules/cam/Makefile   Thu Jan 25 21:38:30 2018
(r328415)
+++ head/sys/modules/cam/Makefile   Thu Jan 25 21:48:07 2018
(r328416)
@@ -11,6 +11,7 @@ SRCS= opt_cam.h
 SRCS+= opt_ada.h
 SRCS+= opt_scsi.h
 SRCS+= opt_cd.h
+SRCS+= opt_da.h
 SRCS+= opt_pt.h
 SRCS+= opt_sa.h
 SRCS+= opt_ses.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328417 - in head/sys: contrib/ipfilter/netinet fs/nfs fs/nfsclient fs/nfsserver netinet nfsclient sys

2018-01-25 Thread Conrad Meyer
Author: cem
Date: Thu Jan 25 22:25:13 2018
New Revision: 328417
URL: https://svnweb.freebsd.org/changeset/base/328417

Log:
  style: Remove remaining deprecated MALLOC/FREE macros
  
  Mechanically replace uses of MALLOC/FREE with appropriate invocations of
  malloc(9) / free(9) (a series of sed expressions).  Something like:
  
  * MALLOC(a, b, ... -> a = malloc(...
  * FREE( -> free(
  * free((caddr_t) -> free(
  
  No functional change.
  
  For now, punt on modifying contrib ipfilter code, leaving a definition of
  the macro in its KMALLOC().
  
  Reported by:  jhb
  Reviewed by:  cy, imp, markj, rmacklem
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14035

Modified:
  head/sys/contrib/ipfilter/netinet/ip_compat.h
  head/sys/fs/nfs/nfs_commonkrpc.c
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsclient/nfs_clcomsubs.c
  head/sys/fs/nfsclient/nfs_clnode.c
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/fs/nfsclient/nfs_clrpcops.c
  head/sys/fs/nfsclient/nfs_clstate.c
  head/sys/fs/nfsclient/nfs_clsubs.c
  head/sys/fs/nfsclient/nfs_clvfsops.c
  head/sys/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/nfsclient/nfsnode.h
  head/sys/fs/nfsserver/nfs_nfsdcache.c
  head/sys/fs/nfsserver/nfs_nfsdport.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c
  head/sys/fs/nfsserver/nfs_nfsdstate.c
  head/sys/netinet/ip_mroute.c
  head/sys/nfsclient/nfsnode.h
  head/sys/sys/malloc.h

Modified: head/sys/contrib/ipfilter/netinet/ip_compat.h
==
--- head/sys/contrib/ipfilter/netinet/ip_compat.h   Thu Jan 25 21:48:07 
2018(r328416)
+++ head/sys/contrib/ipfilter/netinet/ip_compat.h   Thu Jan 25 22:25:13 
2018(r328417)
@@ -530,16 +530,16 @@ MALLOC_DECLARE(M_IPFILTER);
 #   endif /* M_PFIL */
 #  endif /* IPFILTER_M_IPFILTER */
 #  if !defined(KMALLOC)
-#   define KMALLOC(a, b)   MALLOC((a), b, sizeof(*(a)), _M_IPF, M_NOWAIT)
+#   define KMALLOC(a, b)   (a) = (b)malloc(sizeof(*(a)), _M_IPF, 
M_NOWAIT)
 #  endif
 #  if !defined(KMALLOCS)
-#   define KMALLOCS(a, b, c)   MALLOC((a), b, (c), _M_IPF, M_NOWAIT)
+#   define KMALLOCS(a, b, c)   (a) = (b)malloc((c), _M_IPF, M_NOWAIT)
 #  endif
 #  if !defined(KFREE)
-#   define KFREE(x)FREE((x), _M_IPF)
+#   define KFREE(x)free((x), _M_IPF)
 #  endif
 #   if !defined(KFREES)
-#  define  KFREES(x,s) FREE((x), _M_IPF)
+#  define  KFREES(x,s) free((x), _M_IPF)
 #  endif
 #  define  UIOMOVE(a,b,c,d)uiomove((caddr_t)a,b,d)
 #  define  SLEEP(id, n)tsleep((id), PPAUSE|PCATCH, n, 0)

Modified: head/sys/fs/nfs/nfs_commonkrpc.c
==
--- head/sys/fs/nfs/nfs_commonkrpc.cThu Jan 25 21:48:07 2018
(r328416)
+++ head/sys/fs/nfs/nfs_commonkrpc.cThu Jan 25 22:25:13 2018
(r328417)
@@ -676,7 +676,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmo
 * outstanding RPCs for nfsv4 client requests.
 */
if ((nd->nd_flag & ND_NFSV4) && procnum == NFSV4PROC_COMPOUND)
-   MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq),
+   rep = malloc(sizeof(struct nfsreq),
M_NFSDREQ, M_WAITOK);
 #ifdef KDTRACE_HOOKS
if (dtrace_nfscl_nfs234_start_probe != NULL) {
@@ -798,7 +798,7 @@ tryagain:
if (usegssname == 0)
AUTH_DESTROY(auth);
if (rep != NULL)
-   FREE((caddr_t)rep, M_NFSDREQ);
+   free(rep, M_NFSDREQ);
if (set_sigset)
newnfs_restore_sigmask(td, &oldset);
return (error);
@@ -1098,7 +1098,7 @@ tryagain:
if (usegssname == 0)
AUTH_DESTROY(auth);
if (rep != NULL)
-   FREE((caddr_t)rep, M_NFSDREQ);
+   free(rep, M_NFSDREQ);
if (set_sigset)
newnfs_restore_sigmask(td, &oldset);
return (0);
@@ -1108,7 +1108,7 @@ nfsmout:
if (usegssname == 0)
AUTH_DESTROY(auth);
if (rep != NULL)
-   FREE((caddr_t)rep, M_NFSDREQ);
+   free(rep, M_NFSDREQ);
if (set_sigset)
newnfs_restore_sigmask(td, &oldset);
return (error);

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cThu Jan 25 21:48:07 2018
(r328416)
+++ head/sys/fs/nfs/nfs_commonsubs.cThu Jan 25 22:25:13 2018
(r328417)
@@ -677,11 +677,11 @@ nfsm_getfh(struct nfsrv_descript *nd, struct nfsfh **n
}
} else
len = NFSX_V2FH;
-   MALLOC(nfhp, struct nfsfh *, sizeof (struct nfsfh) + len,
+   nfhp = malloc(sizeof 

svn commit: r328418 - in head/sys/fs: nfs nfsserver

2018-01-25 Thread Conrad Meyer
Author: cem
Date: Thu Jan 25 22:38:39 2018
New Revision: 328418
URL: https://svnweb.freebsd.org/changeset/base/328418

Log:
  nfs: Remove NFSSOCKADDRALLOC, NFSSOCKADDRFREE macros
  
  They were just thin wrappers over malloc(9) w/ M_ZERO and free(9).
  
  Discussed with:   rmacklem, markj
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsserver/nfs_nfsdserv.c
  head/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cThu Jan 25 22:25:13 2018
(r328417)
+++ head/sys/fs/nfs/nfs_commonsubs.cThu Jan 25 22:38:39 2018
(r328418)
@@ -3067,7 +3067,7 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
if (nfsrv_nfsuserd) {
NFSUNLOCKNAMEID();
error = EPERM;
-   NFSSOCKADDRFREE(sad);
+   free(sad, M_SONAME);
goto out;
}
nfsrv_nfsuserd = 1;
@@ -3088,7 +3088,8 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
/* Use the port# for a UDP socket (old nfsuserd). */
rp->nr_sotype = SOCK_DGRAM;
rp->nr_soproto = IPPROTO_UDP;
-   NFSSOCKADDRALLOC(rp->nr_nam);
+   rp->nr_nam = malloc(sizeof(*rp->nr_nam), M_SONAME, M_WAITOK |
+   M_ZERO);
NFSSOCKADDRSIZE(rp->nr_nam, sizeof (struct sockaddr_in));
ad = NFSSOCKADDR(rp->nr_nam, struct sockaddr_in *);
ad->sin_family = AF_INET;
@@ -3099,7 +3100,7 @@ nfsrv_nfsuserdport(struct sockaddr *sad, u_short port,
rp->nr_vers = RPCNFSUSERD_VERS;
error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0);
if (error) {
-   NFSSOCKADDRFREE(rp->nr_nam);
+   free(rp->nr_nam, M_SONAME);
nfsrv_nfsuserd = 0;
}
 out:
@@ -3122,7 +3123,7 @@ nfsrv_nfsuserddelport(void)
nfsrv_nfsuserd = 0;
NFSUNLOCKNAMEID();
newnfs_disconnect(&nfsrv_nfsuserdsock);
-   NFSSOCKADDRFREE(nfsrv_nfsuserdsock.nr_nam);
+   free(nfsrv_nfsuserdsock.nr_nam, M_SONAME);
 }
 
 /*

Modified: head/sys/fs/nfs/nfsport.h
==
--- head/sys/fs/nfs/nfsport.h   Thu Jan 25 22:25:13 2018(r328417)
+++ head/sys/fs/nfs/nfsport.h   Thu Jan 25 22:38:39 2018(r328418)
@@ -628,18 +628,7 @@ void nfsrvd_rcv(struct socket *, void *, int);
  * mbufs any more.)
  */
 #defineNFSSOCKADDR(a, t)   ((t)(a))
-#defineNFSSOCKADDRALLOC(a) \
-do {   \
-   (a) = malloc(sizeof (struct sockaddr),  \
-   M_SONAME, M_WAITOK);\
-   NFSBZERO((a), sizeof (struct sockaddr));\
-} while (0)
 #defineNFSSOCKADDRSIZE(a, s)   ((a)->sa_len = (s))
-#defineNFSSOCKADDRFREE(a)  \
-   do {\
-   if (a)  \
-   free((a), M_SONAME);\
-   } while (0)
 
 /*
  * These should be defined as a process or thread structure, as required

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==
--- head/sys/fs/nfsserver/nfs_nfsdserv.cThu Jan 25 22:25:13 2018
(r328417)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.cThu Jan 25 22:38:39 2018
(r328418)
@@ -3477,7 +3477,8 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused
clp->lc_stateid = malloc(sizeof(struct nfsstatehead) *
nfsrv_statehashsize, M_NFSDCLIENT, M_WAITOK);
NFSINITSOCKMUTEX(&clp->lc_req.nr_mtx);
-   NFSSOCKADDRALLOC(clp->lc_req.nr_nam);
+   clp->lc_req.nr_nam = malloc(sizeof(*clp->lc_req.nr_nam), M_SONAME,
+   M_WAITOK | M_ZERO);
NFSSOCKADDRSIZE(clp->lc_req.nr_nam, sizeof (struct sockaddr_in));
clp->lc_req.nr_cred = NULL;
NFSBCOPY(verf, clp->lc_verf, NFSX_VERF);
@@ -3533,7 +3534,7 @@ nfsrvd_setclientid(struct nfsrv_descript *nd, __unused
(void) nfsm_strtom(nd, addrbuf, strlen(addrbuf));
}
if (clp) {
-   NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+   free(clp->lc_req.nr_nam, M_SONAME);
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
free(clp->lc_stateid, M_NFSDCLIENT);
free(clp, M_NFSDCLIENT);
@@ -3551,7 +3552,7 @@ out:
return (0);
 nfsmout:
if (clp) {
-   NFSSOCKADDRFREE(clp->lc_req.nr_nam);
+   free(clp->lc_req.nr_nam, M_SONAME);
NFSFREEMUTEX(&clp->lc_req.nr_mtx);
free(clp

Re: svn commit: r328313 - head/sys/netpfil/pf

2018-01-25 Thread Gleb Smirnoff
On Thu, Jan 25, 2018 at 02:46:14PM +1100, Kristof Provost wrote:
K> On 25 Jan 2018, at 12:08, Kristof Provost wrote:
K> > On 25 Jan 2018, at 11:34, Ian Lepore wrote:
K> >> On Wed, 2018-01-24 at 16:13 -0800, Gleb Smirnoff wrote:
K> >>> (r328313)
K> >>> K> @@ -1613,6 +1613,7 @@ int
K> >>> K>  pf_unlink_state(struct pf_state *s, u_int flags)
K> >>> K>  {
K> >>> K>   struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(s)];
K> >>> K> + int last;
K> >>> K>  
K> >>> K>   if ((flags & PF_ENTER_LOCKED) == 0)
K> >>> K>   PF_HASHROW_LOCK(ih);
K> >>> K> @@ -1653,7 +1654,8 @@ pf_unlink_state(struct pf_state *s, u_int
K> >>> flags)
K> >>> K>   PF_HASHROW_UNLOCK(ih);
K> >>> K>  
K> >>> K>   pf_detach_state(s);
K> >>> K> - refcount_release(&s->refs);
K> >>> K> + last = refcount_release(&s->refs);
K> >>> K> + KASSERT(last == 0, ("Incorrect state reference count"));
K> >>> K>  
K> >>> K>   return (pf_release_state(s));
K> >>> K>  }
K> >>>
K> >>> IMHO, we shouldn't emit extra code to please Coverity. We can mark 
K> >>> it
K> >>> as a false positive in the interface. It may make sense to add a
K> >>> comment
K> >>> for a human to explain why return isn't checked here.
K> >>>
K> >>
K> >> Not to mention that when KASSERT compiles to nothing, what you're 
K> >> left
K> >> with is a "defined but not used" warning for 'last'.
K> >>
K> > I’d really like to keep the KASSERT(), because this is the sort of 
K> > thing that could go wrong, and the assertion would be helpful.
K> >
K> > I suppose I could wrap last in #ifdef INVARIANTS, but that’s rather 
K> > ugly too.
K> >
K> > Asserting that the refcount is at least 1 when entering 
K> > pf_release_state() would express the same, but that’s also 
K> > problematic.
K> > Of course, errors should trigger the KASSERT() in refcount_release(), 
K> > so I think I may have convinced myself that the KASSERT() can in fact 
K> > be removed and replaced with (void)refcount_release() and a comment 
K> > explaining why this refcount_release() can never return 1.
K> >
K> So this:
K> 
K>  diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
K>  index 55ae1145835..0dbf1fe7f66 100644
K>  --- a/sys/netpfil/pf/pf.c
K>  +++ b/sys/netpfil/pf/pf.c
K>  @@ -1623,7 +1623,6 @@ int
K>   pf_unlink_state(struct pf_state *s, u_int flags)
K>   {
K>  struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(s)];
K>  -   int last;
K> 
K>  if ((flags & PF_ENTER_LOCKED) == 0)
K>  PF_HASHROW_LOCK(ih);
K>  @@ -1664,8 +1663,9 @@ pf_unlink_state(struct pf_state *s, u_int flags)
K>  PF_HASHROW_UNLOCK(ih);
K> 
K>  pf_detach_state(s);
K>  -   last = refcount_release(&s->refs);
K>  -   KASSERT(last == 0, ("Incorrect state reference count"));
K>  +   /* pf_state_insert() initialises refs to 2, so we can never 
K> release the
K>  +* last reference here, only in pf_release_state(). */
K>  +   (void)refcount_release(&s->refs);
K> 
K>  return (pf_release_state(s));
K>   }
K> 
K> I do assume that (void) will tell Coverity I’m deliberately ignoring 
K> the return value. It’s a fairly common idiom, so I’d expect it to 
K> understand.

My vote goes for this one. A slightly better then warning when
compiling w/o INVARIANTS.

-- 
Gleb Smirnoff
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328419 - head/crypto/openssl/ssl

2018-01-25 Thread Jung-uk Kim
Author: jkim
Date: Thu Jan 25 23:38:05 2018
New Revision: 328419
URL: https://svnweb.freebsd.org/changeset/base/328419

Log:
  Add declaration of SSL_get_selected_srtp_profile() for OpenSSL.
  
  Because there was an extra declaration in the vendor version, we locally
  removed the second one in r238405 with 1.0.1c.  Later, upstream fixed it in
  1.0.2d but they removed the first one.  Therefore, both were removed in our
  version unfortunately.  Now we revert to the vendor one to re-add it.
  
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D10525

Modified:
  head/crypto/openssl/ssl/srtp.h

Modified: head/crypto/openssl/ssl/srtp.h
==
--- head/crypto/openssl/ssl/srtp.h  Thu Jan 25 22:38:39 2018
(r328418)
+++ head/crypto/openssl/ssl/srtp.h  Thu Jan 25 23:38:05 2018
(r328419)
@@ -136,6 +136,7 @@ int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const ch
 int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles);
 
 STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);
+SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);
 
 # endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328420 - head/sys/dev/cxgbe/common

2018-01-25 Thread Navdeep Parhar
Author: np
Date: Fri Jan 26 00:03:14 2018
New Revision: 328420
URL: https://svnweb.freebsd.org/changeset/base/328420

Log:
  cxgbe(4): Do not display harmless warning in non-debug builds.
  
  MFC after:3 days
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==
--- head/sys/dev/cxgbe/common/t4_hw.c   Thu Jan 25 23:38:05 2018
(r328419)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Fri Jan 26 00:03:14 2018
(r328420)
@@ -3752,8 +3752,10 @@ int t4_link_l1cfg(struct adapter *adap, unsigned int m
 
rcap = aneg | speed | fc | fec;
if ((rcap | lc->supported) != lc->supported) {
+#ifdef INVARIANTS
CH_WARN(adap, "rcap 0x%08x, pcap 0x%08x\n", rcap,
lc->supported);
+#endif
rcap &= lc->supported;
}
rcap |= mdi;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328423 - head/sys/dev/cxgbe

2018-01-25 Thread Navdeep Parhar
Author: np
Date: Fri Jan 26 00:45:40 2018
New Revision: 328423
URL: https://svnweb.freebsd.org/changeset/base/328423

Log:
  cxgbe(4): Accept old names of a couple of tunables.

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Jan 26 00:35:33 2018
(r328422)
+++ head/sys/dev/cxgbe/t4_main.cFri Jan 26 00:45:40 2018
(r328423)
@@ -355,10 +355,12 @@ TUNABLE_INT("hw.cxgbe.nnmrxq_vi", &t4_nnmrxq_vi);
 #define TMR_IDX 1
 int t4_tmr_idx = TMR_IDX;
 TUNABLE_INT("hw.cxgbe.holdoff_timer_idx", &t4_tmr_idx);
+TUNABLE_INT("hw.cxgbe.holdoff_timer_idx_10G", &t4_tmr_idx);/* Old name */
 
 #define PKTC_IDX (-1)
 int t4_pktc_idx = PKTC_IDX;
 TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx", &t4_pktc_idx);
+TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_10G", &t4_pktc_idx);/* Old name */
 
 /*
  * Size (# of entries) of each tx and rx queue.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328424 - head/sys/compat/linuxkpi/common/src

2018-01-25 Thread Justin Hibbits
Author: jhibbits
Date: Fri Jan 26 00:56:09 2018
New Revision: 328424
URL: https://svnweb.freebsd.org/changeset/base/328424

Log:
  Minimal change to build linuxkpi on architectures with physical addresses 
larger
  than virtual
  
  Summary:
  Some architectures have physical/bus addresses that are much larger
  than virtual addresses.  This change just quiets a warning, as DMAP is not 
used
  on those architectures, and on 64-bit platforms uintptr_t is the same size as
  vm_paddr_t and void *.
  
  Reviewed By:  hselasky
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D14043

Modified:
  head/sys/compat/linuxkpi/common/src/linux_page.c

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cFri Jan 26 00:45:40 
2018(r328423)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cFri Jan 26 00:56:09 
2018(r328424)
@@ -69,7 +69,8 @@ linux_page_address(struct page *page)
 
if (page->object != kmem_object && page->object != kernel_object) {
return (PMAP_HAS_DMAP ?
-   ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))) : NULL);
+   ((void *)(uintptr_t)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))) :
+   NULL);
}
return ((void *)(uintptr_t)(VM_MIN_KERNEL_ADDRESS +
IDX_TO_OFF(page->pindex)));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328425 - head/sys/cam/ctl

2018-01-25 Thread Justin Hibbits
Author: jhibbits
Date: Fri Jan 26 00:58:02 2018
New Revision: 328425
URL: https://svnweb.freebsd.org/changeset/base/328425

Log:
  Minimum changes for ctl to build on architectures with non-matching physical 
and
  virtual address sizes
  
  Summary:
  Some architectures use physical addresses larger than virtual.  This is the
  minimal changeset needed to get CAM/CTL to build on these targets.  No
  functional changes.  More changes would likely be needed for this to be fully
  functional on said platforms, but they can be made when needed.
  
  Reviewed By:  mav, chuck
  Differential Revision:https://reviews.freebsd.org/D14041

Modified:
  head/sys/cam/ctl/ctl_frontend_cam_sim.c
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c
==
--- head/sys/cam/ctl/ctl_frontend_cam_sim.c Fri Jan 26 00:56:09 2018
(r328424)
+++ head/sys/cam/ctl/ctl_frontend_cam_sim.c Fri Jan 26 00:58:02 2018
(r328425)
@@ -354,7 +354,7 @@ cfcs_datamove(union ctl_io *io)
case CAM_DATA_VADDR:
cam_sglist = &cam_sg_entry;
cam_sglist[0].ds_len = ccb->csio.dxfer_len;
-   cam_sglist[0].ds_addr = (bus_addr_t)ccb->csio.data_ptr;
+   cam_sglist[0].ds_addr = 
(bus_addr_t)(uintptr_t)ccb->csio.data_ptr;
cam_sg_count = 1;
cam_sg_start = 0;
cam_sg_offset = io->scsiio.kern_rel_offset;
@@ -382,7 +382,7 @@ cfcs_datamove(union ctl_io *io)
len_to_copy = MIN(cam_sglist[i].ds_len - cam_watermark,
  ctl_sglist[j].len - ctl_watermark);
 
-   cam_ptr = (uint8_t *)cam_sglist[i].ds_addr;
+   cam_ptr = (uint8_t *)(uintptr_t)cam_sglist[i].ds_addr;
cam_ptr = cam_ptr + cam_watermark;
if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) {
/*

Modified: head/sys/cam/ctl/scsi_ctl.c
==
--- head/sys/cam/ctl/scsi_ctl.c Fri Jan 26 00:56:09 2018(r328424)
+++ head/sys/cam/ctl/scsi_ctl.c Fri Jan 26 00:58:02 2018(r328425)
@@ -728,7 +728,7 @@ ctlfedata(struct ctlfe_lun_softc *softc, union ctl_io 
cam_sglist = cmd_info->cam_sglist;
*dxfer_len = 0;
for (i = 0; i < io->scsiio.kern_sg_entries - idx; i++) {
-   cam_sglist[i].ds_addr = (bus_addr_t)ctl_sglist[i + 
idx].addr + off;
+   cam_sglist[i].ds_addr = 
(bus_addr_t)(uintptr_t)ctl_sglist[i + idx].addr + off;
if (ctl_sglist[i + idx].len - off <= bus_softc->maxio - 
*dxfer_len) {
cam_sglist[i].ds_len = ctl_sglist[idx + i].len 
- off;
*dxfer_len += cam_sglist[i].ds_len;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328426 - in head: lib/libufs sbin/clri sbin/dump sbin/fsck_ffs sbin/fsirand sbin/growfs sbin/newfs sbin/quotacheck stand/libsa sys/geom sys/geom/journal sys/geom/label sys/ufs/ffs usr....

2018-01-25 Thread Kirk McKusick
Author: mckusick
Date: Fri Jan 26 00:58:32 2018
New Revision: 328426
URL: https://svnweb.freebsd.org/changeset/base/328426

Log:
  Refactoring of reading and writing of the UFS/FFS superblock.
  Specifically reading is done if ffs_sbget() and writing is done
  in ffs_sbput(). These functions are exported to libufs via the
  sbget() and sbput() functions which then used in the various
  filesystem utilities. This work is in preparation for adding
  subperblock check hashes.
  
  No functional change intended.
  
  Reviewed by: kib

Modified:
  head/lib/libufs/Makefile
  head/lib/libufs/libufs.h
  head/lib/libufs/sblock.c
  head/lib/libufs/sbread.3
  head/sbin/clri/Makefile
  head/sbin/clri/clri.c
  head/sbin/dump/Makefile
  head/sbin/dump/dump.h
  head/sbin/dump/main.c
  head/sbin/fsck_ffs/fsck.h
  head/sbin/fsck_ffs/fsutil.c
  head/sbin/fsck_ffs/globs.c
  head/sbin/fsck_ffs/setup.c
  head/sbin/fsirand/Makefile
  head/sbin/fsirand/fsirand.c
  head/sbin/growfs/growfs.c
  head/sbin/newfs/mkfs.c
  head/sbin/quotacheck/Makefile
  head/sbin/quotacheck/quotacheck.c
  head/stand/libsa/Makefile
  head/stand/libsa/ufs.c
  head/sys/geom/geom.h
  head/sys/geom/geom_io.c
  head/sys/geom/journal/g_journal_ufs.c
  head/sys/geom/label/g_label_ufs.c
  head/sys/ufs/ffs/ffs_extern.h
  head/sys/ufs/ffs/ffs_subr.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ffs/fs.h
  head/usr.sbin/fstyp/Makefile
  head/usr.sbin/fstyp/ufs.c
  head/usr.sbin/quot/Makefile
  head/usr.sbin/quot/quot.c

Modified: head/lib/libufs/Makefile
==
--- head/lib/libufs/MakefileFri Jan 26 00:58:02 2018(r328425)
+++ head/lib/libufs/MakefileFri Jan 26 00:58:32 2018(r328426)
@@ -17,6 +17,8 @@ MLINKS+= cgread.3 cgwrite.3
 MLINKS+= cgread.3 cgwrite1.3
 MLINKS+= cgread.3 cgput.3
 MLINKS+= sbread.3 sbwrite.3
+MLINKS+= sbread.3 sbget.3
+MLINKS+= sbread.3 sbput.3
 MLINKS+= ufs_disk_close.3 ufs_disk_fillout.3
 MLINKS+= ufs_disk_close.3 ufs_disk_fillout_blank.3
 MLINKS+= ufs_disk_close.3 ufs_disk_write.3

Modified: head/lib/libufs/libufs.h
==
--- head/lib/libufs/libufs.hFri Jan 26 00:58:02 2018(r328425)
+++ head/lib/libufs/libufs.hFri Jan 26 00:58:32 2018(r328426)
@@ -99,6 +99,20 @@ __BEGIN_DECLS
  */
 
 /*
+ * ffs_subr.c
+ */
+void   ffs_clrblock(struct fs *, u_char *, ufs1_daddr_t);
+void   ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
+void   ffs_fragacct(struct fs *, int, int32_t [], int);
+intffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
+intffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
+void   ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
+intffs_sbget(void *, struct fs **, off_t, char *,
+   int (*)(void *, off_t, void **, int));
+intffs_sbput(void *, struct fs *, off_t,
+   int (*)(void *, off_t, void *, int));
+
+/*
  * block.c
  */
 ssize_t bread(struct uufsd *, ufs2_daddr_t, void *, size_t);
@@ -129,6 +143,9 @@ int putino(struct uufsd *);
  */
 int sbread(struct uufsd *);
 int sbwrite(struct uufsd *, int);
+/* low level superblock read/write functions */
+int sbget(int, struct fs **, off_t);
+int sbput(int, struct fs *, int);
 
 /*
  * type.c
@@ -137,16 +154,6 @@ int ufs_disk_close(struct uufsd *);
 int ufs_disk_fillout(struct uufsd *, const char *);
 int ufs_disk_fillout_blank(struct uufsd *, const char *);
 int ufs_disk_write(struct uufsd *);
-
-/*
- * ffs_subr.c
- */
-void   ffs_clrblock(struct fs *, u_char *, ufs1_daddr_t);
-void   ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
-void   ffs_fragacct(struct fs *, int, int32_t [], int);
-intffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
-intffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
-void   ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
 
 /*
  * crc32c.c

Modified: head/lib/libufs/sblock.c
==
--- head/lib/libufs/sblock.cFri Jan 26 00:58:02 2018(r328425)
+++ head/lib/libufs/sblock.cFri Jan 26 00:58:32 2018(r328426)
@@ -47,79 +47,48 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-static int superblocks[] = SBLOCKSEARCH;
-
 int
 sbread(struct uufsd *disk)
 {
-   uint8_t block[MAXBSIZE];
struct fs *fs;
-   int sb, superblock;
-   int i, size, blks;
-   uint8_t *space;
 
ERROR(disk, NULL);
 
-   fs = &disk->d_fs;
-   superblock = superblocks[0];
-
-   for (sb = 0; (superblock = superblocks[sb]) != -1; sb++) {
-   if (bread(disk, superblock, disk->d_sb, SBLOCKSIZE) == -1) {
+   if ((errno = sbget(disk->d_fd, &fs, -1)) != 0) {
+   switch (errno) {
+   case EIO:
ERROR(disk, "non-existent or truncated superblock");
-   return (-1);
+   break;
+   case ENOENT:
+  

svn commit: r328427 - head/bin/dd

2018-01-25 Thread Eitan Adler
Author: eadler
Date: Fri Jan 26 03:30:05 2018
New Revision: 328427
URL: https://svnweb.freebsd.org/changeset/base/328427

Log:
  dd(1): Use a local swapbytes() function.
  
  swab(3) has restrict qualifiers for src and dst.
  Avoid relying on undefined overlapping swab behavior.
  
  Obtained From: OpenBSD

Modified:
  head/bin/dd/dd.c

Modified: head/bin/dd/dd.c
==
--- head/bin/dd/dd.cFri Jan 26 00:58:32 2018(r328426)
+++ head/bin/dd/dd.cFri Jan 26 03:30:05 2018(r328427)
@@ -339,6 +339,21 @@ speed_limit(void)
 }
 
 static void
+swapbytes(void *v, size_t len)
+{
+   unsigned char *p = v;
+   unsigned char t;
+
+   while (len > 1) {
+   t = p[0];
+   p[0] = p[1];
+   p[1] = t;
+   p += 2;
+   len -= 2;
+   }
+}
+
+static void
 dd_in(void)
 {
ssize_t n;
@@ -438,7 +453,7 @@ dd_in(void)
++st.swab;
--n;
}
-   swab(in.dbp, in.dbp, (size_t)n);
+   swapbytes(in.dbp, (size_t)n);
}
 
in.dbp += in.dbrcnt;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328428 - head/share/examples/kld/cdev/module

2018-01-25 Thread Eitan Adler
Author: eadler
Date: Fri Jan 26 04:24:39 2018
New Revision: 328428
URL: https://svnweb.freebsd.org/changeset/base/328428

Log:
  example cdev: use make_dev_s
  
  Make use of make_dev_s in the example cdev. While here, fix warnings.
  
  Reviewed by:  rpokala

Modified:
  head/share/examples/kld/cdev/module/cdev.c
  head/share/examples/kld/cdev/module/cdevmod.c

Modified: head/share/examples/kld/cdev/module/cdev.c
==
--- head/share/examples/kld/cdev/module/cdev.c  Fri Jan 26 03:30:05 2018
(r328427)
+++ head/share/examples/kld/cdev/module/cdev.c  Fri Jan 26 04:24:39 2018
(r328428)
@@ -104,7 +104,7 @@ mydev_open(struct cdev *dev, int flag, int otyp, struc
 {
 struct proc *procp = td->td_proc;
 
-printf("mydev_open: dev_t=%d, flag=%x, otyp=%x, procp=%p\n",
+printf("mydev_open: dev_t=%lu, flag=%x, otyp=%x, procp=%p\n",
   dev2udev(dev), flag, otyp, procp);
 memset(&buf, '\0', 513);
 len = 0;
@@ -116,7 +116,7 @@ mydev_close(struct cdev *dev, int flag, int otyp, stru
 {
 struct proc *procp = td->td_proc;
 
-printf("mydev_close: dev_t=%d, flag=%x, otyp=%x, procp=%p\n",
+printf("mydev_close: dev_t=%lu, flag=%x, otyp=%x, procp=%p\n",
  dev2udev(dev), flag, otyp, procp);
 return (0);
 }
@@ -128,7 +128,7 @@ mydev_ioctl(struct cdev *dev, u_long cmd, caddr_t arg,
 int error = 0;
 struct proc *procp = td->td_proc;
 
-printf("mydev_ioctl: dev_t=%d, cmd=%lx, arg=%p, mode=%x procp=%p\n",
+printf("mydev_ioctl: dev_t=%lu, cmd=%lx, arg=%p, mode=%x procp=%p\n",
   dev2udev(dev), cmd, arg, mode, procp);
 
 switch(cmd) {
@@ -152,7 +152,7 @@ mydev_write(struct cdev *dev, struct uio *uio, int iof
 {
 int err = 0;
 
-printf("mydev_write: dev_t=%d, uio=%p, ioflag=%d\n",
+printf("mydev_write: dev_t=%lu, uio=%p, ioflag=%d\n",
dev2udev(dev), uio, ioflag);
 
 err = copyinstr(uio->uio_iov->iov_base, &buf, 512, &len);
@@ -172,7 +172,7 @@ mydev_read(struct cdev *dev, struct uio *uio, int iofl
 {
 int err = 0;
 
-printf("mydev_read: dev_t=%d, uio=%p, ioflag=%d\n",
+printf("mydev_read: dev_t=%lu, uio=%p, ioflag=%d\n",
dev2udev(dev), uio, ioflag);
 
 if (len <= 0) {

Modified: head/share/examples/kld/cdev/module/cdevmod.c
==
--- head/share/examples/kld/cdev/module/cdevmod.c   Fri Jan 26 03:30:05 
2018(r328427)
+++ head/share/examples/kld/cdev/module/cdevmod.c   Fri Jan 26 04:24:39 
2018(r328428)
@@ -109,6 +109,7 @@ static int
 cdev_load(module_t mod, int cmd, void *arg)
 {
 int  err = 0;
+struct make_dev_args mda;
 
 switch (cmd) {
 case MOD_LOAD:
@@ -120,8 +121,14 @@ cdev_load(module_t mod, int cmd, void *arg)
printf("Copyright (c) 1998\n");
printf("Rajesh Vaidheeswarran\n");
printf("All rights reserved\n");
-   sdev = make_dev(&my_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "cdev");
-   break;  /* Success*/
+
+   make_dev_args_init(&mda);
+   mda.mda_devsw = &my_devsw;
+   mda.mda_uid = UID_ROOT;
+   mda.mda_gid = GID_WHEEL;
+   mda.mda_mode = 0600;
+   err = make_dev_s(&mda, &sdev, "cdev");
+   break;
 
 case MOD_UNLOAD:
printf("Unloaded kld character device driver\n");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Eitan Adler
Author: eadler
Date: Fri Jan 26 04:40:41 2018
New Revision: 328430
URL: https://svnweb.freebsd.org/changeset/base/328430

Log:
  devd: minor nits
  
  - mark usage as noreturn
  - config does not need a virtual destructor

Modified:
  head/sbin/devd/devd.cc
  head/sbin/devd/devd.hh

Modified: head/sbin/devd/devd.cc
==
--- head/sbin/devd/devd.cc  Fri Jan 26 04:32:31 2018(r328429)
+++ head/sbin/devd/devd.cc  Fri Jan 26 04:40:41 2018(r328430)
@@ -161,7 +161,7 @@ static const char *configfile = CF;
 static void devdlog(int priority, const char* message, ...)
__printflike(2, 3);
 static void event_loop(void);
-static void usage(void);
+static void usage(void) __dead2;
 
 template  void
 delete_and_clear(vector &v)

Modified: head/sbin/devd/devd.hh
==
--- head/sbin/devd/devd.hh  Fri Jan 26 04:32:31 2018(r328429)
+++ head/sbin/devd/devd.hh  Fri Jan 26 04:40:41 2018(r328430)
@@ -147,7 +147,7 @@ class config
 {
 public:
config() { push_var_table(); }
-   virtual ~config() { reset(); }
+   ~config() { reset(); }
void add_attach(int, event_proc *);
void add_detach(int, event_proc *);
void add_directory(const char *);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Warner Losh
On Thu, Jan 25, 2018 at 9:40 PM, Eitan Adler  wrote:

> Author: eadler
> Date: Fri Jan 26 04:40:41 2018
> New Revision: 328430
> URL: https://svnweb.freebsd.org/changeset/base/328430
>
> Log:
>   devd: minor nits
>
>   - mark usage as noreturn
>   - config does not need a virtual destructor
>

Everything needs a virtual destructor...  Please back that part of this
out...

Warner



> Modified:
>   head/sbin/devd/devd.cc
>   head/sbin/devd/devd.hh
>
> Modified: head/sbin/devd/devd.cc
> 
> ==
> --- head/sbin/devd/devd.cc  Fri Jan 26 04:32:31 2018(r328429)
> +++ head/sbin/devd/devd.cc  Fri Jan 26 04:40:41 2018(r328430)
> @@ -161,7 +161,7 @@ static const char *configfile = CF;
>  static void devdlog(int priority, const char* message, ...)
> __printflike(2, 3);
>  static void event_loop(void);
> -static void usage(void);
> +static void usage(void) __dead2;
>
>  template  void
>  delete_and_clear(vector &v)
>
> Modified: head/sbin/devd/devd.hh
> 
> ==
> --- head/sbin/devd/devd.hh  Fri Jan 26 04:32:31 2018(r328429)
> +++ head/sbin/devd/devd.hh  Fri Jan 26 04:40:41 2018(r328430)
> @@ -147,7 +147,7 @@ class config
>  {
>  public:
> config() { push_var_table(); }
> -   virtual ~config() { reset(); }
> +   ~config() { reset(); }
> void add_attach(int, event_proc *);
> void add_detach(int, event_proc *);
> void add_directory(const char *);
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Matt Joras
On Thu, Jan 25, 2018 at 8:52 PM, Warner Losh  wrote:
>
>
> On Thu, Jan 25, 2018 at 9:40 PM, Eitan Adler  wrote:
>>
>> Author: eadler
>> Date: Fri Jan 26 04:40:41 2018
>> New Revision: 328430
>> URL: https://svnweb.freebsd.org/changeset/base/328430
>>
>> Log:
>>   devd: minor nits
>>
>>   - mark usage as noreturn
>>   - config does not need a virtual destructor
>
>
> Everything needs a virtual destructor...  Please back that part of this
> out...
>
> Warner
Needs? If there's not inheritance there's no _need_ to do it, and it's
arguably superfluous. That being said it's also an arguably
superfluous change to remove it.

Matt
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328431 - head/sbin/devd

2018-01-25 Thread Eitan Adler
Author: eadler
Date: Fri Jan 26 05:03:37 2018
New Revision: 328431
URL: https://svnweb.freebsd.org/changeset/base/328431

Log:
  devd: readd virtual
  
  - my C++ knowledge is old and rusty. re-add virtual

Modified:
  head/sbin/devd/devd.hh

Modified: head/sbin/devd/devd.hh
==
--- head/sbin/devd/devd.hh  Fri Jan 26 04:40:41 2018(r328430)
+++ head/sbin/devd/devd.hh  Fri Jan 26 05:03:37 2018(r328431)
@@ -147,7 +147,7 @@ class config
 {
 public:
config() { push_var_table(); }
-   ~config() { reset(); }
+   virtual ~config() { reset(); }
void add_attach(int, event_proc *);
void add_detach(int, event_proc *);
void add_directory(const char *);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Eitan Adler
On 25 January 2018 at 21:02, Matt Joras  wrote:
> On Thu, Jan 25, 2018 at 8:52 PM, Warner Losh  wrote:
>>
>>
>> On Thu, Jan 25, 2018 at 9:40 PM, Eitan Adler  wrote:
>>>
>>> Author: eadler
>>> Date: Fri Jan 26 04:40:41 2018
>>> New Revision: 328430
>>> URL: https://svnweb.freebsd.org/changeset/base/328430
>>>
>>> Log:
>>>   devd: minor nits
>>>
>>>   - mark usage as noreturn
>>>   - config does not need a virtual destructor
>>
>>
>> Everything needs a virtual destructor...  Please back that part of this
>> out...
>>
>> Warner
> Needs? If there's not inheritance there's no _need_ to do it, and it's
> arguably superfluous. That being said it's also an arguably
> superfluous change to remove it.

Yeah, I don't think this needs it. That said, readded in 328431. I
removed it originally since it was the only virtual function in config
and it seemed out of place. At the least, I went looking for what
inherited from it.



-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Warner Losh
On Thu, Jan 25, 2018 at 10:02 PM, Matt Joras  wrote:

> On Thu, Jan 25, 2018 at 8:52 PM, Warner Losh  wrote:
> >
> >
> > On Thu, Jan 25, 2018 at 9:40 PM, Eitan Adler  wrote:
> >>
> >> Author: eadler
> >> Date: Fri Jan 26 04:40:41 2018
> >> New Revision: 328430
> >> URL: https://svnweb.freebsd.org/changeset/base/328430
> >>
> >> Log:
> >>   devd: minor nits
> >>
> >>   - mark usage as noreturn
> >>   - config does not need a virtual destructor
> >
> >
> > Everything needs a virtual destructor...  Please back that part of this
> > out...
> >
> > Warner
> Needs? If there's not inheritance there's no _need_ to do it, and it's
> arguably superfluous. That being said it's also an arguably
> superfluous change to remove it.
>

OK. Needs might not be the proper word. It's a stylistic thing in all the
C++ code I write. It keeps me from having to go back later and add it back
when it really does need it after subclasses are derived from it. It's an
important detail that often gets overlooked. The cost is minimal. And this
isn't one of the rare cases where it's harmful to have it.

Warner
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Warner Losh
On Thu, Jan 25, 2018 at 10:04 PM, Eitan Adler  wrote:

> On 25 January 2018 at 21:02, Matt Joras  wrote:
> > On Thu, Jan 25, 2018 at 8:52 PM, Warner Losh  wrote:
> >>
> >>
> >> On Thu, Jan 25, 2018 at 9:40 PM, Eitan Adler 
> wrote:
> >>>
> >>> Author: eadler
> >>> Date: Fri Jan 26 04:40:41 2018
> >>> New Revision: 328430
> >>> URL: https://svnweb.freebsd.org/changeset/base/328430
> >>>
> >>> Log:
> >>>   devd: minor nits
> >>>
> >>>   - mark usage as noreturn
> >>>   - config does not need a virtual destructor
> >>
> >>
> >> Everything needs a virtual destructor...  Please back that part of this
> >> out...
> >>
> >> Warner
> > Needs? If there's not inheritance there's no _need_ to do it, and it's
> > arguably superfluous. That being said it's also an arguably
> > superfluous change to remove it.
>
> Yeah, I don't think this needs it. That said, readded in 328431. I
> removed it originally since it was the only virtual function in config
> and it seemed out of place. At the least, I went looking for what
> inherited from it.
>

It's a flaw in C++ that you have a choice here. All dtors should  be
virtual because you never know when you'll have new derived classes and
have to hunt down a hard-to-find bug because you didn't go back and make it
virtual. Of course, this flaw is there because of other flaws in the
language. This isn't one of the cases where having it is harmful, so
stylistically I always have them unless there's a good reason not to
because were I to create derived classes, I might forget to make it
virtual. It's an old habit, I'll admit.

Warner
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328432 - head/sys/modules/geom/geom_label

2018-01-25 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Fri Jan 26 06:21:24 2018
New Revision: 328432
URL: https://svnweb.freebsd.org/changeset/base/328432

Log:
  Fix LINT build.
  
  Approved by:  delphij

Modified:
  head/sys/modules/geom/geom_label/Makefile

Modified: head/sys/modules/geom/geom_label/Makefile
==
--- head/sys/modules/geom/geom_label/Makefile   Fri Jan 26 05:03:37 2018
(r328431)
+++ head/sys/modules/geom/geom_label/Makefile   Fri Jan 26 06:21:24 2018
(r328432)
@@ -13,6 +13,7 @@ SRCS+=g_label_ntfs.c
 SRCS+= g_label_reiserfs.c
 SRCS+= g_label_ufs.c
 SRCS+= opt_geom.h
+SRCS+= vnode_if.h
 
 opt_geom.h:
echo "#define GEOM_LABEL 1" > ${.TARGET}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328430 - head/sbin/devd

2018-01-25 Thread Ed Schouten
2018-01-26 5:52 GMT+01:00 Warner Losh :
> Everything needs a virtual destructor...  Please back that part of this
> out...

If you're concerned about inheritance, what about adding the 'final'
keyword to the class?

http://en.cppreference.com/w/cpp/language/final

Eitan:

static void usage(void) __dead2;

This should be spelled:

[[noreturn]] static void usage();

-- 
Ed Schouten 
Nuxi, 's-Hertogenbosch, the Netherlands
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"