Extend the scope of socket lock in soo_stat()

2017-07-17 Thread Martin Pieuchot
`so_state' and `so_rcv' need to be checked atomically, so extend the
scope of the lock.

ok?

Index: kern/sys_socket.c
===
RCS file: /cvs/src/sys/kern/sys_socket.c,v
retrieving revision 1.30
diff -u -p -r1.30 sys_socket.c
--- kern/sys_socket.c   22 Feb 2017 10:20:21 -  1.30
+++ kern/sys_socket.c   18 Jul 2017 06:41:10 -
@@ -180,14 +180,13 @@ soo_stat(struct file *fp, struct stat *u
 
memset(ub, 0, sizeof (*ub));
ub->st_mode = S_IFSOCK;
-   if ((so->so_state & SS_CANTRCVMORE) == 0 ||
-   so->so_rcv.sb_cc != 0)
+   s = solock(so);
+   if ((so->so_state & SS_CANTRCVMORE) == 0 || so->so_rcv.sb_cc != 0)
ub->st_mode |= S_IRUSR | S_IRGRP | S_IROTH;
if ((so->so_state & SS_CANTSENDMORE) == 0)
ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
ub->st_uid = so->so_euid;
ub->st_gid = so->so_egid;
-   s = solock(so);
(void) ((*so->so_proto->pr_usrreq)(so, PRU_SENSE,
(struct mbuf *)ub, NULL, NULL, p));
sounlock(s);



soo_ioctl() & socket lock

2017-07-17 Thread Martin Pieuchot
Where soo_ioctl() modifies `so_state', `so_rcv' or `so_snd' it needs the
socket lock.

More fields might need the lock in the future but for the moment I'm
concentrating on fields accessed in the TCP input path.

ok?

Index: kern/sys_socket.c
===
RCS file: /cvs/src/sys/kern/sys_socket.c,v
retrieving revision 1.30
diff -u -p -r1.30 sys_socket.c
--- kern/sys_socket.c   22 Feb 2017 10:20:21 -  1.30
+++ kern/sys_socket.c   18 Jul 2017 06:26:15 -
@@ -78,13 +78,16 @@ soo_ioctl(struct file *fp, u_long cmd, c
switch (cmd) {
 
case FIONBIO:
+   s = solock(so);
if (*(int *)data)
so->so_state |= SS_NBIO;
else
so->so_state &= ~SS_NBIO;
-   return (0);
+   sounlock(s);
+   break;
 
case FIOASYNC:
+   s = solock(so);
if (*(int *)data) {
so->so_state |= SS_ASYNC;
so->so_rcv.sb_flags |= SB_ASYNC;
@@ -94,43 +97,47 @@ soo_ioctl(struct file *fp, u_long cmd, c
so->so_rcv.sb_flags &= ~SB_ASYNC;
so->so_snd.sb_flags &= ~SB_ASYNC;
}
-   return (0);
+   sounlock(s);
+   break;
 
case FIONREAD:
*(int *)data = so->so_rcv.sb_datacc;
-   return (0);
+   break;
 
case SIOCSPGRP:
so->so_pgid = *(int *)data;
so->so_siguid = p->p_ucred->cr_ruid;
so->so_sigeuid = p->p_ucred->cr_uid;
-   return (0);
+   break;
 
case SIOCGPGRP:
*(int *)data = so->so_pgid;
-   return (0);
+   break;
 
case SIOCATMARK:
*(int *)data = (so->so_state&SS_RCVATMARK) != 0;
-   return (0);
-   }
-   /*
-* Interface/routing/protocol specific ioctls:
-* interface and routing ioctls should have a
-* different entry since a socket's unnecessary
-*/
-   if (IOCGROUP(cmd) == 'i') {
-   NET_LOCK(s);
-   error = ifioctl(so, cmd, data, p);
-   NET_UNLOCK(s);
-   return (error);
+   break;
+
+   default:
+   /*
+* Interface/routing/protocol specific ioctls:
+* interface and routing ioctls should have a
+* different entry since a socket's unnecessary
+*/
+   if (IOCGROUP(cmd) == 'i') {
+   NET_LOCK(s);
+   error = ifioctl(so, cmd, data, p);
+   NET_UNLOCK(s);
+   return (error);
+   }
+   if (IOCGROUP(cmd) == 'r')
+   return (EOPNOTSUPP);
+   s = solock(so);
+   error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
+   (struct mbuf *)cmd, (struct mbuf *)data, NULL, p));
+   sounlock(s);
+   break;
}
-   if (IOCGROUP(cmd) == 'r')
-   return (EOPNOTSUPP);
-   s = solock(so);
-   error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, 
-   (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)NULL, p));
-   sounlock(s);
 
return (error);
 }



filt_soread() & socket lock

2017-07-17 Thread Martin Pieuchot
The socket checks in filt_soread() should be atomic.  As found in the
past week it is not possible to call solock() there because we're not
allowed to sleep.  However I'd like to prepare the function for future
locking in order to keep the locking diff minimal.

ok?

Index: kern/uipc_socket.c
===
RCS file: /cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.194
diff -u -p -r1.194 uipc_socket.c
--- kern/uipc_socket.c  13 Jul 2017 16:19:38 -  1.194
+++ kern/uipc_socket.c  18 Jul 2017 06:21:51 -
@@ -1965,22 +1965,27 @@ int
 filt_soread(struct knote *kn, long hint)
 {
struct socket *so = kn->kn_fp->f_data;
+   int rv;
 
kn->kn_data = so->so_rcv.sb_cc;
 #ifdef SOCKET_SPLICE
if (isspliced(so))
-   return (0);
+   rv = 0;
+   else
 #endif /* SOCKET_SPLICE */
if (so->so_state & SS_CANTRCVMORE) {
kn->kn_flags |= EV_EOF;
kn->kn_fflags = so->so_error;
-   return (1);
+   rv = 1;
+   } else if (so->so_error) {  /* temporary udp error */
+   rv = 1;
+   } else if (kn->kn_sfflags & NOTE_LOWAT) {
+   rv = (kn->kn_data >= kn->kn_sdata);
+   } else {
+   rv = (kn->kn_data >= so->so_rcv.sb_lowat);
}
-   if (so->so_error)   /* temporary udp error */
-   return (1);
-   if (kn->kn_sfflags & NOTE_LOWAT)
-   return (kn->kn_data >= kn->kn_sdata);
-   return (kn->kn_data >= so->so_rcv.sb_lowat);
+
+   return rv;
 }
 
 void



[patch] enable calling chroot(2) after calling pledge(2)

2017-07-17 Thread Matt Miller

I would like to be able to call chroot(2) in a program that uses pledge(2).

The following (untested) patch makes this possible as part of the  
"rpath" promise.


Does this seem like a reasonable idea?


--- sys/kern/kern_pledge.cThu Jun 29 00:10:07 2017
+++ sys/kern/kern_pledge.c.with_chroot  Mon Jul 17 22:32:43 2017
@@ -292,6 +292,7 @@
[SYS_execve] = PLEDGE_EXEC,

[SYS_chdir] = PLEDGE_RPATH,
+   [SYS_chroot] = PLEDGE_RPATH,
[SYS_openat] = PLEDGE_RPATH | PLEDGE_WPATH,
[SYS_fstatat] = PLEDGE_RPATH | PLEDGE_WPATH,
[SYS_faccessat] = PLEDGE_RPATH | PLEDGE_WPATH,




Re: intel.4: Typofix

2017-07-17 Thread Bryan Steele
On Tue, Jul 18, 2017 at 02:48:08AM +0200, Klemens Nanni wrote:
> Add missing verb and period.
> 
> Index: driver/xf86-video-intel/man/intel.man
> ===
> RCS file: /cvs/xenocara/driver/xf86-video-intel/man/intel.man,v
> retrieving revision 1.9
> diff -u -p -r1.9 intel.man
> --- driver/xf86-video-intel/man/intel.man 12 Apr 2015 19:42:05 -  
> 1.9
> +++ driver/xf86-video-intel/man/intel.man 18 Jul 2017 00:45:37 -
> @@ -321,8 +321,8 @@ Default: 0
>  .BI "Option \*qZaphodHeads\*q \*q" string \*q
>  .IP
>  Specify the randr output(s) to use with zaphod mode for a particular driver
> -instance.  If you this option you must use it with all instances of the
> -driver
> +instance.  If you use this option you must use it with all instances of the
> +driver.
>  .br
>  For example:
>  .B

This is an upstream Xorg manual.

https://lists.x.org/mailman/listinfo/xorg-devel



intel.4: Typofix

2017-07-17 Thread Klemens Nanni
Add missing verb and period.

Index: driver/xf86-video-intel/man/intel.man
===
RCS file: /cvs/xenocara/driver/xf86-video-intel/man/intel.man,v
retrieving revision 1.9
diff -u -p -r1.9 intel.man
--- driver/xf86-video-intel/man/intel.man   12 Apr 2015 19:42:05 -  
1.9
+++ driver/xf86-video-intel/man/intel.man   18 Jul 2017 00:45:37 -
@@ -321,8 +321,8 @@ Default: 0
 .BI "Option \*qZaphodHeads\*q \*q" string \*q
 .IP
 Specify the randr output(s) to use with zaphod mode for a particular driver
-instance.  If you this option you must use it with all instances of the
-driver
+instance.  If you use this option you must use it with all instances of the
+driver.
 .br
 For example:
 .B



Re: armv7 sunxi i2c+pmic(=shutdown -p)

2017-07-17 Thread Juan Francisco Cantero Hurtado
On Sun, Jul 09, 2017 at 08:34:29PM +0300, Artturi Alm wrote:
> Hi,
> 
> revived the diff below, i2c tested via pmic's shutdown(), for working
> "shutdown -p now" operation.
> there was only two i2c's w/"status: 'okay'" in the FDT, so not all of
> them do attach.
> 
> related part of dmesg:
> 
> com0: console
> sxitwi0 at simplebus0
> iic0 at sxitwi0
> axppmic0 at iic0 addr 0x34: AXP209, ACIN
> sxitwi1 at simplebus0
> iic1 at sxitwi1
> dwge0 at simplebus0
> 
> Comments?

With the patch, "halt -p" works on the LIME2.


-- 
Juan Francisco Cantero Hurtado http://juanfra.info



Re: armv7 _dcache_wbinv_all, or _dcache_wb_all ?

2017-07-17 Thread Artturi Alm
On Fri, Jul 14, 2017 at 03:33:32AM +0300, Artturi Alm wrote:
> On Fri, Jul 14, 2017 at 03:28:25AM +0300, Artturi Alm wrote:
> > Hi,
> > 
> > i'm having hard time choosing, between this diff, and the one that
> > renames it to for what it does, which would likely incur cleanup
> > elsewhere. current is just wrong.. but i'm open to be taught on this
> > matter anyway.
> > 
> > -Artturi
> > 
> 
> Wonders of manually recreating a quick diff by hand above.. fixed:
> 
> diff --git a/sys/arch/arm/arm/cpufunc.c b/sys/arch/arm/arm/cpufunc.c
> index c91108e7066..fd5385043fc 100644
> --- a/sys/arch/arm/arm/cpufunc.c
> +++ b/sys/arch/arm/arm/cpufunc.c
> @@ -291,8 +291,8 @@ armv7_dcache_wbinv_all()
>   for (ways = 0; ways < nways; ways++) {
>   word = wayval | setval | lvl;
>  
> - /* Clean D cache SE with Set/Index */
> - __asm volatile("mcr p15, 0, %0, c7, c10, 2"
> + /* Data cache clean and invalidate by set/way */
> + __asm volatile("mcr p15, 0, %0, c7, c14, 2\n"
>   : : "r" (word));
>   wayval += wayincr;
>   }

Guessing now, that this is just yet another case still prevalent in cvs
tree, where things are the way they are, and need no cleaning/fixing,
because it was written for !MULTIPROCESSOR + does work as is for GENERIC.

As a side note w/some relevancy to this, and more to the "sysreg.h use
in C". This is what i ended up using in some of my branches where i
don't restrict myself from anything, and i find it useful while cleaning:

diff --git a/sys/arch/arm/include/sysreg.h b/sys/arch/arm/include/sysreg.h
index c2aab7d6667..5d48912494a 100644
--- a/sys/arch/arm/include/sysreg.h
+++ b/sys/arch/arm/include/sysreg.h
@@ -269,4 +269,8 @@
  */
 #define CP15_CBAR(rr)  p15, 4, rr, c15, c0, 0 /* Configuration Base 
Address Register */
 
+#define_CP_REG_STR(...)#__VA_ARGS__
+#define_IA_MRC_RD(x)   "mrc" _CP_REG_STR(x) "\n"
+#define_IA_MCR_WR(x)   "mcr" _CP_REG_STR(x) "\n"
+
 #endif /* !MACHINE_SYSREG_H */


that does look like below in use, i think the mcr/mrc was not enough, so
went w/longer and more verbose name with some duplicity being _X_RealOP_OP,
where RealOP is enough to reveal _OP already...

u_int
cpu_id(void)
{
u_int _midr;
asm volatile(_IA_MRC_RD(CP15_MIDR(%0)) : "=r"(_midr));
return _midr;
}

void
cpu_set_tpidrprw(void *_tpidrprw)
{
asm volatile(_IA_MCR_WR(CP15_TPIDRPRW(%0)) :: "r"(_tpidrprw));
}

now im still not suggesting this anymore, just wanted to note why i hit
the naming issue of non-invalidating _wbinv_all() again.
-Artturi



Re: newsyslog: skip invalid newsyslog.conf entries

2017-07-17 Thread Todd C. Miller
On Mon, 17 Jul 2017 22:21:36 +0200, Jeremie Courreges-Anglas wrote:

> Here's a diff to skip invalid lines and return a meaningful error
> status if meet one.  A goto looked like the simplest way here because
> of the nested for(;;) loop in parse_file().
> 
> While here, mention the exit status in the manpage.

OK millert@

 - todd



Re: SIGBUS short mmap object

2017-07-17 Thread Theo de Raadt
The tests regress/sys/kern/siginfo-fault accesses an mmap(2)ed file
behind its end.  Then it expects an SIGBUS, but gets an SIGSEGV.

Sorry I disagree.  SIGSEGV is the right answer.  It was not mapped.
That is segmentation.

A SIGBUS should be delivered when the mode of access is not permitted
on a valid mapping.

I know some other operating systems have gotten extremly sloppy and
inconsistant in this regard.  And I despise what they did.  It suspect
they got so used to unaligned-access architectures they then forgot
the reason why SIGBUS was something else, and wanted to reuse it to
mean something else before siginfo became popular.  And I think this
bug came about due to i386 X.

And if you quote POSIX, I think they are WRONG.  It is irresponsible
of people to redefine the meanings of objects such that you cannot
tell what action to take to repair the problem.

Finally, the diff here only touches 2 architectures.  Which others
change semantics in some odd way when that uvm diff goes in?

Where is this coming from?  Is it just to satisfy a regress test?

Related commit message is:
Additionally, SIGBUS/BUS_ADRERR should be generated instead of 
SIGSEGV
for access to file mapped pages that exceed the end of the file.
(Thanks to kettenis@ for suggesting this test.)

I think this description refers to
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
Reference to whole pages within the mapping, but beyond the current
length of the object, shall result in a SIGBUS signal.

The attached diff fixes that for amd64 and i386 and the test passes.

ok?

bluhm

Index: arch/amd64/amd64/trap.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/amd64/trap.c,v
retrieving revision 1.55
diff -u -p -r1.55 trap.c
--- arch/amd64/amd64/trap.c 14 Jul 2017 12:20:32 -  1.55
+++ arch/amd64/amd64/trap.c 14 Jul 2017 22:54:28 -
@@ -306,6 +306,7 @@ copyfault:
struct vm_map *map;
vm_prot_t ftype;
extern struct vm_map *kernel_map;
+   int signal, sicode;
 
cr2 = rcr2();
KERNEL_LOCK();
@@ -372,12 +373,14 @@ faultcommon:
map, fa, ftype, error);
goto we_re_toast;
}
+
+   signal = SIGSEGV;
+   sicode = SEGV_MAPERR;
if (error == ENOMEM) {
printf("UVM: pid %d (%s), uid %d killed:"
" out of swap\n", p->p_p->ps_pid, 
p->p_p->ps_comm,
p->p_ucred ? (int)p->p_ucred->cr_uid : -1);
-   sv.sival_ptr = (void *)fa;
-   trapsignal(p, SIGKILL, T_PAGEFLT, SEGV_MAPERR, 
sv);
+   signal = SIGKILL;
} else {
 #ifdef TRAP_SIGDEBUG
printf("pid %d (%s): %s at rip %llx addr 
%llx\n",
@@ -385,10 +388,15 @@ faultcommon:
frame->tf_rip, rcr2());
frame_dump(frame);
 #endif
-   sv.sival_ptr = (void *)fa;
-   trapsignal(p, SIGSEGV, T_PAGEFLT,
-   error == EACCES ? SEGV_ACCERR : 
SEGV_MAPERR, sv);
}
+   if (error == EACCES)
+   sicode = SEGV_ACCERR;
+   if (error == EIO) {
+   signal = SIGBUS;
+   sicode = BUS_ADRERR;
+   }
+   sv.sival_ptr = (void *)fa;
+   trapsignal(p, signal, T_PAGEFLT, sicode, sv);
KERNEL_UNLOCK();
break;
}
Index: arch/i386/i386/trap.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/i386/i386/trap.c,v
retrieving revision 1.131
diff -u -p -r1.131 trap.c
--- arch/i386/i386/trap.c   14 Jul 2017 12:20:32 -  1.131
+++ arch/i386/i386/trap.c   14 Jul 2017 22:55:16 -
@@ -374,6 +374,7 @@ trap(struct trapframe *frame)
struct vmspace *vm;
struct vm_map *map;
int error;
+   int signal, sicode;
 
cr2 = rcr2();
KERNEL_LOCK();
@@ -431,9 +432,17 @@ trap(struct trapframe *

SIGBUS short mmap object

2017-07-17 Thread Alexander Bluhm
Hi,

The tests regress/sys/kern/siginfo-fault accesses an mmap(2)ed file
behind its end.  Then it expects an SIGBUS, but gets an SIGSEGV.

Related commit message is:
Additionally, SIGBUS/BUS_ADRERR should be generated instead of SIGSEGV
for access to file mapped pages that exceed the end of the file.
(Thanks to kettenis@ for suggesting this test.)

I think this description refers to
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
Reference to whole pages within the mapping, but beyond the current
length of the object, shall result in a SIGBUS signal.

The attached diff fixes that for amd64 and i386 and the test passes.

ok?

bluhm

Index: arch/amd64/amd64/trap.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/amd64/trap.c,v
retrieving revision 1.55
diff -u -p -r1.55 trap.c
--- arch/amd64/amd64/trap.c 14 Jul 2017 12:20:32 -  1.55
+++ arch/amd64/amd64/trap.c 14 Jul 2017 22:54:28 -
@@ -306,6 +306,7 @@ copyfault:
struct vm_map *map;
vm_prot_t ftype;
extern struct vm_map *kernel_map;
+   int signal, sicode;
 
cr2 = rcr2();
KERNEL_LOCK();
@@ -372,12 +373,14 @@ faultcommon:
map, fa, ftype, error);
goto we_re_toast;
}
+
+   signal = SIGSEGV;
+   sicode = SEGV_MAPERR;
if (error == ENOMEM) {
printf("UVM: pid %d (%s), uid %d killed:"
" out of swap\n", p->p_p->ps_pid, p->p_p->ps_comm,
p->p_ucred ? (int)p->p_ucred->cr_uid : -1);
-   sv.sival_ptr = (void *)fa;
-   trapsignal(p, SIGKILL, T_PAGEFLT, SEGV_MAPERR, sv);
+   signal = SIGKILL;
} else {
 #ifdef TRAP_SIGDEBUG
printf("pid %d (%s): %s at rip %llx addr %llx\n",
@@ -385,10 +388,15 @@ faultcommon:
frame->tf_rip, rcr2());
frame_dump(frame);
 #endif
-   sv.sival_ptr = (void *)fa;
-   trapsignal(p, SIGSEGV, T_PAGEFLT,
-   error == EACCES ? SEGV_ACCERR : SEGV_MAPERR, sv);
}
+   if (error == EACCES)
+   sicode = SEGV_ACCERR;
+   if (error == EIO) {
+   signal = SIGBUS;
+   sicode = BUS_ADRERR;
+   }
+   sv.sival_ptr = (void *)fa;
+   trapsignal(p, signal, T_PAGEFLT, sicode, sv);
KERNEL_UNLOCK();
break;
}
Index: arch/i386/i386/trap.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/i386/i386/trap.c,v
retrieving revision 1.131
diff -u -p -r1.131 trap.c
--- arch/i386/i386/trap.c   14 Jul 2017 12:20:32 -  1.131
+++ arch/i386/i386/trap.c   14 Jul 2017 22:55:16 -
@@ -374,6 +374,7 @@ trap(struct trapframe *frame)
struct vmspace *vm;
struct vm_map *map;
int error;
+   int signal, sicode;
 
cr2 = rcr2();
KERNEL_LOCK();
@@ -431,9 +432,17 @@ trap(struct trapframe *frame)
map, va, ftype, error);
goto we_re_toast;
}
+
+   signal = SIGSEGV;
+   sicode = SEGV_MAPERR;
+   if (error == EACCES)
+   sicode = SEGV_ACCERR;
+   if (error == EIO) {
+   signal = SIGBUS;
+   sicode = BUS_ADRERR;
+   }
sv.sival_int = fa;
-   trapsignal(p, SIGSEGV, vftype,
-   error == EACCES ? SEGV_ACCERR : SEGV_MAPERR, sv);
+   trapsignal(p, signal, vftype, sicode, sv);
KERNEL_UNLOCK();
break;
}
Index: uvm/uvm_fault.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/uvm/uvm_fault.c,v
retrieving revision 1.91
diff -u -p -r1.91 uvm_fault.c
--- uvm/uvm_fault.c 16 Sep 2016 01:09:53 -  1.91
+++ uvm/uvm_fault.c 14 Jul 2017 22:23:22 -
@@ -1032,7 +1032,7 @@ Case2:
}
 
if (!UVM_ET_ISNOFAULT(ufi.entry))
-   return (EACCES); /* XXX i/o error */
+   return (EIO);
 
uobjpage = PGO_DONTCARE;
promote = TRUE;



clang: emit trap padding between functions

2017-07-17 Thread Todd Mortimer
Hello tech,

The patch below teaches clang to treat padding between functions
differently than padding inside functions. Padding between functions is
completely filled with trap instructions, and padding inside functions
is padded as usual (trapsleds on X86, NOPs on everything else). This
means that the trapsleds between functions no longer start with a short
JMP, but are instead completely filled with int3 (0xCC), which makes them
slightly more ROP unfriendly.

This has been through a bulk build on amd64, and I have been running
base + kernel build with this for about a week without issue, so this
change seems to be stable. I would interested to get feedback from
someone running arm64, since this change does touch some generic code
shared across architectures, but there shouldn't be any binary changes
outside X86.

Any other feedback / bikeshedding is welcome.

ok?

Todd

Index: include/llvm/CodeGen/AsmPrinter.h
===
RCS file: /cvs/src/gnu/llvm/include/llvm/CodeGen/AsmPrinter.h,v
retrieving revision 1.1.1.4
diff -u -p -u -p -r1.1.1.4 AsmPrinter.h
--- include/llvm/CodeGen/AsmPrinter.h   14 Mar 2017 08:08:02 -  1.1.1.4
+++ include/llvm/CodeGen/AsmPrinter.h   10 Jul 2017 01:12:02 -
@@ -297,6 +297,11 @@ public:
   ///
   void EmitAlignment(unsigned NumBits, const GlobalObject *GO = nullptr) const;
 
+  /// Emit an alinment directive to the specified power of two boundary,
+  /// like EmitAlignment, but call EmitTrapToAlignment to fill with
+  /// trap instructions instead of NOPs.
+  void EmitTrapAlignment(unsigned NumBits, const GlobalObject *GO = nullptr) 
const;
+
   /// Lower the specified LLVM Constant to an MCExpr.
   virtual const MCExpr *lowerConstant(const Constant *CV);
 
@@ -354,6 +359,11 @@ public:
   virtual void EmitInstruction(const MachineInstr *) {
 llvm_unreachable("EmitInstruction not implemented");
   }
+
+  /// Emit an alignment directive to the specified power
+  /// of two boundary, but use Trap instructions for alignment
+  /// sections that should never be executed.
+  virtual void EmitTrapToAlignment(unsigned NumBits) const;
 
   /// Return the symbol for the specified constant pool entry.
   virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
RCS file: /cvs/src/gnu/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp,v
retrieving revision 1.1.1.4
diff -u -p -u -p -r1.1.1.4 AsmPrinter.cpp
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp   14 Mar 2017 08:08:14 -  
1.1.1.4
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp   10 Jul 2017 01:12:02 -
@@ -590,7 +590,7 @@ void AsmPrinter::EmitFunctionHeader() {
 
   EmitLinkage(F, CurrentFnSym);
   if (MAI->hasFunctionAlignment())
-EmitAlignment(MF->getAlignment(), F);
+EmitTrapAlignment(MF->getAlignment(), F);
 
   if (MAI->hasDotTypeDotSizeDirective())
 OutStreamer->EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
@@ -1759,6 +1759,33 @@ void AsmPrinter::EmitAlignment(unsigned 
   else
 OutStreamer->EmitValueToAlignment(1u << NumBits);
 }
+
+//===--===//
+/// EmitTrapAlignment - Emit an alignment directive to the specified power of
+/// two boundary, but call EmitTrapToAlignment to fill with Trap instructions
+/// if the Target implements EmitTrapToAlignment.
+void AsmPrinter::EmitTrapAlignment(unsigned NumBits, const GlobalObject *GV) 
const {
+  if (GV)
+NumBits = getGVAlignmentLog2(GV, GV->getParent()->getDataLayout(), 
NumBits);
+
+  if (NumBits == 0) return;   // 1-byte aligned: no need to emit alignment.
+
+  assert(NumBits <
+ static_cast(std::numeric_limits::digits) &&
+ "undefined behavior");
+  EmitTrapToAlignment(NumBits);
+}
+
+//===--===//
+/// EmitTrapToAlignment - Emit an alignment directive to the specified power
+/// of two boundary. This default implementation calls EmitCodeAlignment on
+/// the OutStreamer, but can be overridden by Target implementations.
+void AsmPrinter::EmitTrapToAlignment(unsigned NumBits) const {
+  if (NumBits == 0) return;
+  OutStreamer->EmitCodeAlignment(1u << NumBits);
+}
+
+
 
 
//===--===//
 // Constant emission.
Index: lib/Target/X86/X86AsmPrinter.h
===
RCS file: /cvs/src/gnu/llvm/lib/Target/X86/X86AsmPrinter.h,v
retrieving revision 1.1.1.3
diff -u -p -u -p -r1.1.1.3 X86AsmPrinter.h
--- lib/Target/X86/X86AsmPrinter.h  24 Jan 2017 08:33:28 -  1.1.1.3
+++ lib/Target/X86/X86AsmPrinter.h  10 Jul 2017 01:12:02 -
@@ -113,6 +113,8 @@ public:
 
   void EmitInstruction(const MachineInstr *MI) override;
 
+  void EmitTrapToAlignment(unsigned NumBits) const override;
+
   void EmitBasicBl

Re: armv7 sunxi i2c+pmic(=shutdown -p)

2017-07-17 Thread Artturi Alm
On Sun, Jul 16, 2017 at 11:13:35PM +0200, Mark Kettenis wrote:
> > Date: Sun, 9 Jul 2017 20:34:29 +0300
> > From: Artturi Alm 
> > 
> > Hi,
> > 
> > revived the diff below, i2c tested via pmic's shutdown(), for working
> > "shutdown -p now" operation.
> > there was only two i2c's w/"status: 'okay'" in the FDT, so not all of
> > them do attach.
> > 
> > related part of dmesg:
> > 
> > com0: console
> > sxitwi0 at simplebus0
> > iic0 at sxitwi0
> > axppmic0 at iic0 addr 0x34: AXP209, ACIN
> > sxitwi1 at simplebus0
> > iic1 at sxitwi1
> > dwge0 at simplebus0
> > 
> > Comments?
> > -Artturi
> 
> It's a pity that the PSCI "firmware" doesn't do an actual shutdown.
> But having i2c support is worth having in its own right.
> 

Yes, it would be plenty more ideal for us, if it did.
Yep, there's plenty more than just pmics we could have support for.

> A bit of a step backwards to add code under the old-style 4-clause BSD
> license, but I believe that is still acceptable.
> 

Yep, tbh., i haven't looked at freebsd, if they would have something
better w/regards that license currently, nor if netbsd has cleaned it,
but i doubt not.

> I don't think we'll ever support the Marvell Discovery hardware, so
> I'd just fold the gttwsi_core.c code into sxitwi.c and get rid of the
> GTTWSI_ALLWINNER hack.
> 

Will take a look at it, while it doesn't help w/the license.

> A few more comments inline below.
> 

reply to one of the comments below, for which i'd like to get some input
before going for the rest, but i will look at fixing everything in a single
new diff anyway, which might require a rainy day.
Thank you for your comments. :)

> On my (Allwinner A20) Banana Pi this seems to work, although the
> Ethernet link status LED turns back on shortly after the board powers
> down.  I guess it gets power from the link.  The power LED stays on as
> well, but that is just leakage from the serial console.  The green LED
> that is gpio controllable turns off when the board powers down.
> 

I have met these serial power leakages on most boards when using ftdi usb
uarts. will check if cubies do the same w/ethernet, atleast i don't remember
having noticed such.

> 
> > diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC
> > index af71a6c4835..d8762ba394c 100644
> > --- a/sys/arch/armv7/conf/GENERIC
> > +++ b/sys/arch/armv7/conf/GENERIC
> > @@ -99,6 +99,8 @@ ehci* at fdt? # EHCI (shim)
> >  usb*   at ehci?#flags 0x1
> >  #ohci* at sunxi?
> >  #usb*  at ohci?
> > +sxitwi*at fdt? # Two-Wire Serial Interface
> > +iic*   at sxitwi?  # I2C bus
> >  
> >  # ARM Versatile Express
> >  sysreg*at fdt?
> > @@ -148,6 +150,7 @@ mvxhci* at fdt?
> >  usb*   at mvxhci?
> >  mvahci*at fdt?
> >  
> > +axppmic*   at iic? # axp209 pmic
> >  crosec*at iic?
> >  wskbd* at crosec? mux 1
> >  pcfrtc*at iic?
> > diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK
> > index 56e64893df6..0c5f8aa4e1f 100644
> > --- a/sys/arch/armv7/conf/RAMDISK
> > +++ b/sys/arch/armv7/conf/RAMDISK
> > @@ -99,6 +99,8 @@ ehci* at fdt? # EHCI (shim)
> >  usb*   at ehci?#flags 0x1
> >  #ohci* at sunxi?
> >  #usb*  at ohci?
> > +sxitwi*at fdt? # Two-Wire Serial Interface
> > +iic*   at sxitwi?  # I2C bus
> >  
> >  # ARM Versatile Express
> >  sysreg*at fdt?
> > @@ -145,6 +147,7 @@ mvxhci* at fdt?
> >  usb*   at mvxhci?
> >  mvahci*at fdt?
> >  
> > +axppmic*   at iic? # axp209 pmic
> >  crosec*at iic?
> >  wskbd* at crosec? mux 1
> >  pcfrtc*at iic?
> > diff --git a/sys/dev/fdt/axp20x.c b/sys/dev/fdt/axp20x.c
> > new file mode 100644
> > index 000..833038f0eff
> > --- /dev/null
> > +++ b/sys/dev/fdt/axp20x.c
> > @@ -0,0 +1,160 @@
> > +/*
> > + * Copyright (c) 2014,2016 Artturi Alm
> > + *
> > + * Permission to use, copy, modify, and distribute this software for any
> > + * purpose with or without fee is hereby granted, provided that the above
> > + * copyright notice and this permission notice appear in all copies.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> > + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> > + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> > + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> > + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> > + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> > + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> > + */
> > +
> > +#include 
> > +#include 
> > +#

Re: [patch] fake pv drivers installation on xen

2017-07-17 Thread Maxim Khitrov
On Mon, Jul 17, 2017 at 3:40 PM, Mike Belopuhov  wrote:
> On Mon, Jul 17, 2017 at 14:32 -0400, Maxim Khitrov wrote:
>> On Wed, Jan 18, 2017 at 2:16 PM, Dinar Talypov  wrote:
>> > I use Xenserver 7.0 with xencenter management console.
>> > without it doesn't allow shutdown or reboot.
>> > Anyway I'll try with hostctl.
>> >
>> > Thanks.
>>
>> Were you able to get this working with hostctl? I'm running OpenBSD
>> 6.1 amd64 on XenServer 7.0. When I run any hostctl command, such as
>> `hostctl device/vif/0/mac`, I get the following error:
>>
>> hostctl: ioctl: Device not configured
>>
>> During boot, I see these messages:
>>
>> pvbus0 at mainbus0: Hyper-V 0.0, Xen 4.6
>> xen0 at pvbus0: features 0x2705, 32 grant table frames, event channel 3
>> xbf0 at xen0 backend 0 channel 8: disk
>>
>
> You need to disable viridian compatibility in your Xenserver.
>
>> Running `hostctl -t` returns "/dev/pvbus0: Hyper-V"
>>
>
> That's because Xenserver announces Hyper-V compatibility layer
> (called viridian) before Xen for whatever reason.  You need to
> do "cd /dev; ./MAKEDEV pvbus1" and then use "hostctl -f /dev/pvbus1"
> with your commands (I assume -- never tried a Xenserver myself).
>
>> Any tips on getting hostctl to work?
>
> See above.  The easiest is probably just to disable viridian :)

Disabling viridian worked, thanks! For anyone else interested in doing
this, run the following command on your XenServer host:

xe vm-param-set uuid= platform:viridian=false

After that, you can add these commands to /etc/rc.local:

ostype=$(sysctl -n kern.ostype)
osrelease=$(sysctl -n kern.osrelease)

# PV driver version
hostctl attr/PVAddons/MajorVersion 6
hostctl attr/PVAddons/MinorVersion 2
hostctl attr/PVAddons/MicroVersion 0
hostctl attr/PVAddons/BuildVersion 76888
hostctl attr/PVAddons/Installed 1

# OS version
hostctl data/os_name "$ostype $osrelease"
hostctl data/os_uname $osrelease
hostctl data/os_distro $ostype

# Update XenStore
hostctl data/updated 1

-Max



newsyslog: skip invalid newsyslog.conf entries

2017-07-17 Thread Jeremie Courreges-Anglas
On Sat, Jul 15 2017, Jeremie Courreges-Anglas  wrote:
> "Todd C. Miller"  writes:
>
>> On Sat, 15 Jul 2017 00:24:05 +0200, Jeremie Courreges-Anglas wrote:
>>
>>> Wouldn't it be better if we at least tried to properly free what was
>>> allocated in parse_file()?
>>
>> I'm not sure it is worth it since newsyslog is a short-lived process.
>> If you feel strongly about this I could take a look at doing that.
>
> Nah, let's forget about this idea, for the sake of simplicity.
>
>>> > One thing I wanted to
>>> > do was to make parse_file() return an error value when there was a
>>> > parse error so the exit code could be non-zero.
>>> 
>>> That would be better, a valid use case is checking the exit status of
>>> newsyslog -n to detect errors.
>>
>> That's what I was thinking as well.
>>
>>> Also, should we really ignore errors for everything, or only for
>>> getpwnam/getgrnam(3) errors?  The latter appears safer to me.
>>
>> Do you think a single bad line should prevent newsyslog from rotating
>> any files?  This could lead to /var/ filling up which seems more
>> dangerous than just ignoring a bogus line.
>
> The idea was to remain strict by default, but stay useful in case of
> missing user/group, as happened to Harald Dunkel (see misc@).  The diff
> to implement this is rather small.
>
> But I would also be ok with newsyslog(8) making its best efforts.
> Your call. :)

Here's a diff to skip invalid lines and return a meaningful error
status if meet one.  A goto looked like the simplest way here because
of the nested for(;;) loop in parse_file().

While here, mention the exit status in the manpage.

Objections/comments?


Index: newsyslog.8
===
RCS file: /d/cvs/src/usr.bin/newsyslog/newsyslog.8,v
retrieving revision 1.53
diff -u -p -r1.53 newsyslog.8
--- newsyslog.8 14 Nov 2015 01:22:04 -  1.53
+++ newsyslog.8 17 Jul 2017 19:19:58 -
@@ -429,6 +429,8 @@ will not send a
 .It Pa /etc/newsyslog.conf
 default configuration file
 .El
+.Sh EXIT STATUS
+.Ex -std
 .Sh SEE ALSO
 .Xr compress 1 ,
 .Xr gzip 1 ,
Index: newsyslog.c
===
RCS file: /d/cvs/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.104
diff -u -p -r1.104 newsyslog.c
--- newsyslog.c 14 Jul 2017 22:17:16 -  1.104
+++ newsyslog.c 17 Jul 2017 19:47:21 -
@@ -160,7 +160,7 @@ int movefile(char *, char *, uid_t, gid_
 intstat_suffix(char *, size_t, char *, struct stat *,
int (*)(const char *, struct stat *));
 off_t  sizefile(struct stat *);
-void   parse_file(struct entrylist *, int *);
+intparse_file(struct entrylist *, int *);
 time_t parse8601(char *);
 time_t parseDWM(char *);
 void   child_killer(int);
@@ -179,7 +179,7 @@ main(int argc, char **argv)
struct entrylist config, runlist;
struct conf_entry *p, *q, *tmp;
struct pidinfo *pidlist, *pl;
-   int status, listlen;
+   int status, listlen, ret;
char **av;

parse_args(argc, argv);
@@ -192,7 +192,7 @@ main(int argc, char **argv)
TAILQ_INIT(&config);
TAILQ_INIT(&runlist);
 
-   parse_file(&config, &listlen);
+   ret = parse_file(&config, &listlen);
if (argc == 0)
TAILQ_CONCAT(&runlist, &config, next);
else {
@@ -272,7 +272,7 @@ main(int argc, char **argv)
/* Wait for children to finish, then exit */
while (waitpid(-1, &status, 0) != -1)
;
-   exit(0);
+   return (ret);
 }
 
 void
@@ -464,7 +464,7 @@ usage(void)
  * Parse a configuration file and build a linked list of all the logs
  * to process
  */
-void
+int
 parse_file(struct entrylist *list, int *nentries)
 {
char line[BUFSIZ], *parse, *q, *errline, *group, *tmp, *ep;
@@ -472,7 +472,8 @@ parse_file(struct entrylist *list, int *
struct passwd *pwd;
struct group *grp;
struct stat sb;
-   int lineno;
+   int lineno = 0;
+   int ret = 0;
FILE *f;
long l;
 
@@ -482,7 +483,10 @@ parse_file(struct entrylist *list, int *
err(1, "can't open %s", conf);
 
*nentries = 0;
-   for (lineno = 1; fgets(line, sizeof(line), f); lineno++) {
+
+nextline:
+   while (fgets(line, sizeof(line), f) != NULL) {
+   lineno++;
tmp = sob(line);
if (*tmp == '\0' || *tmp == '#')
continue;
@@ -509,9 +513,13 @@ parse_file(struct entrylist *list, int *
*group++ = '\0';
if (*q) {
if (!(isnumberstr(q))) {
-   if ((pwd = getpwnam(q)) == NULL)
-   errx(1, "%s:%d: unknown user: 
%s",
+   if ((pwd = getpwnam(q)) == NULL) {
+   warnx("%s:%d: unknown user"
+

Re: [patch] fake pv drivers installation on xen

2017-07-17 Thread Mike Belopuhov
On Mon, Jul 17, 2017 at 14:32 -0400, Maxim Khitrov wrote:
> On Wed, Jan 18, 2017 at 2:16 PM, Dinar Talypov  wrote:
> > I use Xenserver 7.0 with xencenter management console.
> > without it doesn't allow shutdown or reboot.
> > Anyway I'll try with hostctl.
> >
> > Thanks.
> 
> Were you able to get this working with hostctl? I'm running OpenBSD
> 6.1 amd64 on XenServer 7.0. When I run any hostctl command, such as
> `hostctl device/vif/0/mac`, I get the following error:
> 
> hostctl: ioctl: Device not configured
> 
> During boot, I see these messages:
> 
> pvbus0 at mainbus0: Hyper-V 0.0, Xen 4.6
> xen0 at pvbus0: features 0x2705, 32 grant table frames, event channel 3
> xbf0 at xen0 backend 0 channel 8: disk
>

You need to disable viridian compatibility in your Xenserver.

> Running `hostctl -t` returns "/dev/pvbus0: Hyper-V"
>

That's because Xenserver announces Hyper-V compatibility layer
(called viridian) before Xen for whatever reason.  You need to
do "cd /dev; ./MAKEDEV pvbus1" and then use "hostctl -f /dev/pvbus1"
with your commands (I assume -- never tried a Xenserver myself).

> Any tips on getting hostctl to work?

See above.  The easiest is probably just to disable viridian :)

> Also, do the values persist
> across reboots or do they need to be set via rc.d?
> 

No, they're not.



Re: [patch] fake pv drivers installation on xen

2017-07-17 Thread Maxim Khitrov
On Wed, Jan 18, 2017 at 2:16 PM, Dinar Talypov  wrote:
> I use Xenserver 7.0 with xencenter management console.
> without it doesn't allow shutdown or reboot.
> Anyway I'll try with hostctl.
>
> Thanks.

Were you able to get this working with hostctl? I'm running OpenBSD
6.1 amd64 on XenServer 7.0. When I run any hostctl command, such as
`hostctl device/vif/0/mac`, I get the following error:

hostctl: ioctl: Device not configured

During boot, I see these messages:

pvbus0 at mainbus0: Hyper-V 0.0, Xen 4.6
xen0 at pvbus0: features 0x2705, 32 grant table frames, event channel 3
xbf0 at xen0 backend 0 channel 8: disk

Running `hostctl -t` returns "/dev/pvbus0: Hyper-V"

Any tips on getting hostctl to work? Also, do the values persist
across reboots or do they need to be set via rc.d?

-Max



Re: inteldrm(4) diff needs review and testing

2017-07-17 Thread Paul de Weerd
Hi Mark,

On Sun, Jul 16, 2017 at 03:19:41PM +0200, Mark Kettenis wrote:
| Can somebody test the following diff on Ivy Bridge or Haswell (Intel
| HD Graphics 2500/4000/4600/4700/5000/5100/5200)?
| 
| When I added support for the command parser, I took a bit of a
| shortcut and implemented the hash tables as a single linked list.
| This diff fixes that.
| 
| For the hash function I used a "mode (size-1)" approach that leaves
| one of the hash table entries unused.  Perhaps somebody with a CS
| background has a better idea that isn't too complicated to implement?
| 
| Paul, Stuart, there is a small chance that this will improve the
| vncviewer performance.

It doesn't (vncviewer still consumes a full CPU core), but otherwise
there are no regressions from the previous situation.

Thanks Mark!

Paul

OpenBSD 6.1-current (GENERIC.MP) #6: Mon Jul 17 09:52:56 CEST 2017
we...@pom.alm.weirdnet.nl:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 34243919872 (32657MB)
avail mem = 33200308224 (31662MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xec410 (88 entries)
bios0: vendor Dell Inc. version "A12" date 05/06/2015
bios0: Dell Inc. OptiPlex 9020
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT SLIC LPIT SSDT SSDT SSDT HPET SSDT MCFG SSDT 
ASF! DMAR
acpi0: wakeup devices UAR1(S3) PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) 
PXSX(S4) PXSX(S4) GLAN(S4) EHC1(S3) EHC2(S3) XHC_(S4) HDEF(S4) PEG0(S4) 
PEGP(S4) PEG1(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3392.85 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: TSC frequency 3392845890 Hz
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3392.15 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3392.15 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3392.15 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 0, core 3, package 0
cpu4 at mainbus0: apid 1 (application processor)
cpu4: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3392.15 MHz
cpu4: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT
cpu4: 256KB 64b/line 8-way L2 cache
cpu4: smt 1, core 0, package 0
cpu5 at mainbus0: apid 3 (application processor)
cpu5: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3392.15 MHz
cpu5: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSB

Re: rc: Use IFS when looking for carp interfaces

2017-07-17 Thread Robert Peichaer
On Mon, Jul 17, 2017 at 03:39:29PM +0200, Klemens Nanni wrote:
> The Internal Field Seperator is meant for this so use it instead of
> reading and stripping ':' again.
> 
> Feedback? Comments?
> 
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.508
> diff -u -p -r1.508 rc
> --- rc17 Jul 2017 12:02:53 -  1.508
> +++ rc17 Jul 2017 13:33:54 -
> @@ -351,8 +350,8 @@ if [[ $1 == shutdown ]]; then
>   [[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
>   fi
>  
> - ifconfig | while read _if _junk; do
> - [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
> + ifconfig | while IFS=: read _if _junk; do
> + [[ $_if == carp+([0-9]) ]] && ifconfig $_if down
>   done
>  
>   exit 0

Unnecessary micro optimization.

-- 
-=[rpe]=-



Re: Add machdep.lidaction=3 - powerdown laptop upon lid closing

2017-07-17 Thread Kevin Chadwick
What about powerup? Currently if u boot say an access point and close the
lid to save a watt. I *believe*? you have to wait for sysctl.conf to be
read before closing to avoid sleeping?


Re: rc: reorder_libs: [1/2] Drop unused _l, exit early on failure

2017-07-17 Thread Robert Peichaer
On Mon, Jul 17, 2017 at 03:00:34PM +0200, Klemens Nanni wrote:
> On Sun, Jul 16, 2017 at 09:09:44AM +, Robert Peichaer wrote:
> > The rationale to picking the library versions before remounting was
> > to keep the time window having rw /usr as small as possible.
> > If that's deemed ok, I'm too OK with switching the steps.
> Considering the fact that the now simplified version picking routine
> takes virtually no time, I'd like finish this up.
> 
> Here's the updated diff checking r/w status beforehand.
> 
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.508
> diff -u -p -r1.508 rc
> --- rc17 Jul 2017 12:02:53 -  1.508
> +++ rc17 Jul 2017 12:56:07 -
> @@ -170,12 +170,6 @@ reorder_libs() {
>  
>   echo -n 'reordering libraries:'
>  
> - # Only choose the latest version of the libraries.
> - for _liba in /usr/lib/lib{c,crypto}; do
> - _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail -1)"
> - done
> - _libas=${_libas# }
> -
>   # Remount read-write, if /usr/lib is on a read-only ffs filesystem.
>   if [[ $_mp == *' type ffs '*'read-only'* ]]; then
>   if mount -u -w $_dkdev; then
> @@ -185,6 +179,12 @@ reorder_libs() {
>   return
>   fi
>   fi
> +
> + # Only choose the latest version of the libraries.
> + for _liba in /usr/lib/lib{c,crypto}; do
> + _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail -1)"
> + done
> + _libas=${_libas# }
>  
>   for _liba in $_libas; do
>   _tmpdir=$(mktemp -dq /tmp/_librebuild.) && (
 
OK

-- 
-=[rpe]=-



Re: pledge ifstated

2017-07-17 Thread Rob Pierce
On Sun, Jul 16, 2017 at 04:47:07PM -0400, Rob Pierce wrote:
> On Thu, Jul 13, 2017 at 09:16:14PM -0400, Rob Pierce wrote:
> > On Mon, Jul 10, 2017 at 01:21:58PM -0400, Rob Pierce wrote:
> > > The following diff is loosely based on the approach that was taken for
> > > pledging mountd. Other code/approaches leveraged from various networking
> > > daemons.
> > > 
> > > This first step moves the ioctl with SIOCGIFDATA call to a privileged
> > > child so we can at least pledge "stdio rpath dns inet proc exec" without
> > > (intentionally) changing existing behaviour.
> > > 
> > > Comments and suggestions welcome.
> > > 
> > > Thanks!
> > > 
> > > Rob
> > 
> > An unnecessary call to log_info snuck in. Here is a clean diff.
> > 
> > Rob
> 
> My original diff to initially pledge ifstated with "stdio rpath dns inet proc
> exec" was incorrectly polling from fetch_ifstate which resulted in the delayed
> completion of that function. This new diff resolves the problem.
> 
> I also changed one instance of fatal to fatalx in sigchld_handler.

Running setproctitle in the parent breaks rcctl.

This diff removes the parent call to setproctitle so rcctl works again.

Rob

Index: Makefile
===
RCS file: /cvs/src/usr.sbin/ifstated/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- Makefile20 Jul 2010 02:05:15 -  1.10
+++ Makefile17 Jul 2017 16:38:23 -
@@ -8,7 +8,7 @@ CFLAGS+= -Wmissing-declarations
 CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
 YFLAGS=
 MAN= ifstated.8 ifstated.conf.5
-LDADD+=-levent
+LDADD+=-levent -lutil
 DPADD+= ${LIBEVENT}
 
 .include 
Index: ifstated.c
===
RCS file: /cvs/src/usr.sbin/ifstated/ifstated.c,v
retrieving revision 1.50
diff -u -p -r1.50 ifstated.c
--- ifstated.c  4 Jul 2017 21:09:52 -   1.50
+++ ifstated.c  17 Jul 2017 16:38:23 -
@@ -25,13 +25,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -39,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -47,7 +51,9 @@
 #include "log.h"
 
 struct  ifsd_config *conf = NULL, *newconf = NULL;
+struct  imsgbuf ibuf;
 
+pid_t   privchild_pid;
 int opts = 0;
 int opt_inhibit = 0;
 char   *configfile = "/etc/ifstated.conf";
@@ -74,6 +80,7 @@ void  do_action(struct ifsd_action *);
 void   remove_action(struct ifsd_action *, struct ifsd_state *);
 void   remove_expression(struct ifsd_expression *,
struct ifsd_state *);
+void   privchild(int);
 
 __dead void
 usage(void)
@@ -89,6 +96,7 @@ int
 main(int argc, char *argv[])
 {
struct timeval tv;
+   int socks[2];
int ch, rt_fd;
int debug = 0;
unsigned int rtfilter;
@@ -143,6 +151,21 @@ main(int argc, char *argv[])
if (!debug)
daemon(1, 0);
 
+   if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
+   fatal("%s: socketpair", __func__);
+   }
+
+   switch (privchild_pid = fork()) {
+   case -1:
+   fatal("%s: fork", __func__);
+   case 0:
+   close(socks[0]);
+   privchild(socks[1]);
+   }
+   close(socks[1]);
+
+   imsg_init(&ibuf, socks[0]);
+
event_init();
log_init(debug, LOG_DAEMON);
log_setverbose(opts & IFSD_OPT_VERBOSE);
@@ -160,6 +183,9 @@ main(int argc, char *argv[])
&rtfilter, sizeof(rtfilter)) == -1) /* not fatal */
log_warn("%s: setsockopt tablefilter", __func__);
 
+   if (pledge("stdio rpath dns inet proc exec", NULL) == -1)
+   fatal("pledge");
+
signal_set(&sigchld_ev, SIGCHLD, sigchld_handler, NULL);
signal_add(&sigchld_ev, NULL);
 
@@ -252,6 +278,16 @@ rt_msg_handler(int fd, short event, void
 void
 sigchld_handler(int fd, short event, void *arg)
 {
+   pid_t pid;
+   int status;
+
+   do {
+   pid = waitpid(privchild_pid, &status, WNOHANG);
+   if (pid > 0 && (WIFEXITED(status) || WIFSIGNALED(status)))
+   fatalx("privchild %i exited due to receipt of signal 
%i",
+   privchild_pid, WTERMSIG(status));
+   } while (pid == -1 && errno == EINTR);
+
check_external_status(&conf->initstate);
if (conf->curstate != NULL)
check_external_status(conf->curstate);
@@ -599,29 +635,60 @@ do_action(struct ifsd_action *action)
 void
 fetch_ifstate(void)
 {
+   struct imsg imsg;
struct ifaddrs *ifap, *ifa;
char *oname = NULL;
int sock = socket(AF_INET, SOCK_DGRAM, 0);
+   int done = 0, state, rv;
+   ssize_t n;
 
if (getifaddrs(&ifap) != 0)
err(1, "getifaddrs");
 
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {

Re: [PATCH] ure improvement

2017-07-17 Thread sc dying
On 2017/07/17 08:24, Martin Pieuchot wrote:
> On 15/07/17(Sat) 21:16, sc dying wrote:
>> Hi,
>>
>> This patch does:
>>
>> - Enable RX aggregation.
>
> Does it work on all chips?

I don't have all, but it works with mine that have RTL8152 (ver 4c10)
and RTL8153 (ver 5c20).

>
>> - Fix RX packet buffer alignment, using roundup() macro in sys/params.h.
>
> Why is that needed?  pktlen should already be aligned, no?

If RX_AGG is enabled, multiple packets may be received in a transaction
and the chip puts each packet on 8 bytes boundary.
For the first packet buf points at aligned buffer, but for second packet
the buf + pktlen might points at unaligned pointer as pktlen is the
actual length of packet. It should be rounded up.

>
>> - Call usbd_set_config before configuring endpoints in ure_init to fix
>>an error when re-opening pipes.  I grabbed the code from if_kue.c.
>
> Which error? Calling usbd_set_config() should be avoid as much as
> possible in driver code.

Without patch, ure on usb-3 port says this error

ure0: usb errors on rx: IOERROR

when down the interface and it up.

>
>> - Make the chip recognize given MAC address.
>
> Nice
>
>> - Remove ure_reset in ure_init, becasue its already called from ure_stop.
>
> Your diff do not apply, please check your mail setup.

I attached the patch. gmail will encode it with base64.
Sorry about that.
--- sys/dev/usb/if_ure.cWed May  3 22:20:15 2017
+++ sys/dev/usb/if_ure.cMon Jun 19 09:11:09 2017
@@ -470,8 +470,6 @@ ure_init(void *xsc)
/* Cancel pending I/O. */
ure_stop(sc);
 
-   ure_reset(sc);
-
if (ure_rx_list_init(sc) == ENOBUFS) {
printf("%s: rx list init failed\n", sc->ure_dev.dv_xname);
splx(s);
@@ -484,9 +482,18 @@ ure_init(void *xsc)
return;
}
 
+#define URE_CONFIG_NO 1
+   if (usbd_set_config_no(sc->ure_udev, URE_CONFIG_NO, 1) ||
+   usbd_device2interface_handle(sc->ure_udev, URE_IFACE_IDX,
+&sc->ure_iface))
+   printf("%s: set_config failed\n", sc->ure_dev.dv_xname);
+   usbd_delay_ms(sc->ure_udev, 10);
+
/* Set MAC address. */
+   ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG);
ure_write_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES,
sc->ure_ac.ac_enaddr, 8);
+   ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML);
 
/* Reset the packet filter. */
ure_write_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
@@ -683,10 +690,10 @@ ure_rtl8152_init(struct ure_softc *sc)
URE_GPHY_STS_MSK | URE_SPEED_DOWN_MSK | URE_SPDWN_RXDV_MSK |
URE_SPDWN_LINKCHG_MSK);
 
-   /* Disable Rx aggregation. */
+   /* Enable Rx aggregation. */
ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB,
-   ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) |
-   URE_RX_AGG_DISABLE);
+   ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) &
+   ~URE_RX_AGG_DISABLE);
 
/* Disable ALDPS. */
ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA |
@@ -835,10 +842,10 @@ ure_rtl8153_init(struct ure_softc *sc)
 
ure_init_fifo(sc);
 
-   /* Disable Rx aggregation. */
+   /* Enable Rx aggregation. */
ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB,
-   ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) |
-   URE_RX_AGG_DISABLE);
+   ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) &
+   ~URE_RX_AGG_DISABLE);
 
val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB);
if (!(sc->ure_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10)))
@@ -1289,7 +1296,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_sta
goto done;
}
 
-   buf += pktlen;
+   buf += roundup(pktlen, 8);
 
memcpy(&rxhdr, buf, sizeof(rxhdr));
total_len -= sizeof(rxhdr);
@@ -1302,7 +1309,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_sta
goto done;
}
 
-   total_len -= pktlen;
+   total_len -= roundup(pktlen, 8);
buf += sizeof(rxhdr);
 
m = m_devget(buf, pktlen, ETHER_ALIGN);


rc: Use IFS when looking for carp interfaces

2017-07-17 Thread Klemens Nanni
The Internal Field Seperator is meant for this so use it instead of
reading and stripping ':' again.

Feedback? Comments?

Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.508
diff -u -p -r1.508 rc
--- rc  17 Jul 2017 12:02:53 -  1.508
+++ rc  17 Jul 2017 13:33:54 -
@@ -351,8 +350,8 @@ if [[ $1 == shutdown ]]; then
[[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
fi
 
-   ifconfig | while read _if _junk; do
-   [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
+   ifconfig | while IFS=: read _if _junk; do
+   [[ $_if == carp+([0-9]) ]] && ifconfig $_if down
done
 
exit 0



Re: rc: reorder_libs: [1/2] Drop unused _l, exit early on failure

2017-07-17 Thread Theo Buehler
On Mon, Jul 17, 2017 at 03:00:34PM +0200, Klemens Nanni wrote:
> On Sun, Jul 16, 2017 at 09:09:44AM +, Robert Peichaer wrote:
> > The rationale to picking the library versions before remounting was
> > to keep the time window having rw /usr as small as possible.
> > If that's deemed ok, I'm too OK with switching the steps.
> Considering the fact that the now simplified version picking routine
> takes virtually no time, I'd like finish this up.
> 
> Here's the updated diff checking r/w status beforehand.

ok

> 
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.508
> diff -u -p -r1.508 rc
> --- rc17 Jul 2017 12:02:53 -  1.508
> +++ rc17 Jul 2017 12:56:07 -
> @@ -170,12 +170,6 @@ reorder_libs() {
>  
>   echo -n 'reordering libraries:'
>  
> - # Only choose the latest version of the libraries.
> - for _liba in /usr/lib/lib{c,crypto}; do
> - _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail -1)"
> - done
> - _libas=${_libas# }
> -
>   # Remount read-write, if /usr/lib is on a read-only ffs filesystem.
>   if [[ $_mp == *' type ffs '*'read-only'* ]]; then
>   if mount -u -w $_dkdev; then
> @@ -185,6 +179,12 @@ reorder_libs() {
>   return
>   fi
>   fi
> +
> + # Only choose the latest version of the libraries.
> + for _liba in /usr/lib/lib{c,crypto}; do
> + _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail -1)"
> + done
> + _libas=${_libas# }
>  
>   for _liba in $_libas; do
>   _tmpdir=$(mktemp -dq /tmp/_librebuild.) && (
> 



Re: rc: reorder_libs: [1/2] Drop unused _l, exit early on failure

2017-07-17 Thread Klemens Nanni
On Sun, Jul 16, 2017 at 09:09:44AM +, Robert Peichaer wrote:
> The rationale to picking the library versions before remounting was
> to keep the time window having rw /usr as small as possible.
> If that's deemed ok, I'm too OK with switching the steps.
Considering the fact that the now simplified version picking routine
takes virtually no time, I'd like finish this up.

Here's the updated diff checking r/w status beforehand.

Index: rc
===
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.508
diff -u -p -r1.508 rc
--- rc  17 Jul 2017 12:02:53 -  1.508
+++ rc  17 Jul 2017 12:56:07 -
@@ -170,12 +170,6 @@ reorder_libs() {
 
echo -n 'reordering libraries:'
 
-   # Only choose the latest version of the libraries.
-   for _liba in /usr/lib/lib{c,crypto}; do
-   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail -1)"
-   done
-   _libas=${_libas# }
-
# Remount read-write, if /usr/lib is on a read-only ffs filesystem.
if [[ $_mp == *' type ffs '*'read-only'* ]]; then
if mount -u -w $_dkdev; then
@@ -185,6 +179,12 @@ reorder_libs() {
return
fi
fi
+
+   # Only choose the latest version of the libraries.
+   for _liba in /usr/lib/lib{c,crypto}; do
+   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail -1)"
+   done
+   _libas=${_libas# }
 
for _liba in $_libas; do
_tmpdir=$(mktemp -dq /tmp/_librebuild.) && (



Re: [libcrypto] Don't build empty ecp_nistp* objects

2017-07-17 Thread Kinichiro Inoguchi
Absolutely.

ok inoguchi@

On Mon, Jul 17, 2017 at 06:26:30AM -0500, Brent Cook wrote:
> OPENSSL_NO_EC_NISTP_64_GCC_128 has been defined in opensslfeatures.h for a
> long time, which effectively means that ecp_nistp* are all empty files. So,
> there is no reason to build them in the first place. OK?
> 
> Index: Makefile
> ===
> RCS file: /cvs/src/lib/libcrypto/Makefile,v
> retrieving revision 1.20
> diff -u -p -u -p -r1.20 Makefile
> --- Makefile10 Jul 2017 21:30:37 -  1.20
> +++ Makefile17 Jul 2017 11:21:23 -
> @@ -126,7 +126,6 @@ SRCS+= dso_openssl.c
>  SRCS+= ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c
>  SRCS+= ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c
>  SRCS+= ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c
> -SRCS+= ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c
>  SRCS+= ecp_oct.c ec2_oct.c ec_oct.c
> 
>  # ecdh/



Re: inteldrm(4) diff needs review and testing

2017-07-17 Thread Giovanni Bechis
On Sun, Jul 16, 2017 at 03:19:41PM +0200, Mark Kettenis wrote:
> Can somebody test the following diff on Ivy Bridge or Haswell (Intel
> HD Graphics 2500/4000/4600/4700/5000/5100/5200)?
> 
> When I added support for the command parser, I took a bit of a
> shortcut and implemented the hash tables as a single linked list.
> This diff fixes that.
> 
no regression and no more dmesg spam for me.
 Thanks
  Giovanni

> For the hash function I used a "mode (size-1)" approach that leaves
> one of the hash table entries unused.  Perhaps somebody with a CS
> background has a better idea that isn't too complicated to implement?
> 
> Paul, Stuart, there is a small chance that this will improve the
> vncviewer performance.
> 
> 
> Index: dev/pci/drm/drm_linux.h
> ===
> RCS file: /cvs/src/sys/dev/pci/drm/drm_linux.h,v
> retrieving revision 1.56
> diff -u -p -r1.56 drm_linux.h
> --- dev/pci/drm/drm_linux.h   14 Jul 2017 11:18:04 -  1.56
> +++ dev/pci/drm/drm_linux.h   16 Jul 2017 12:54:51 -
> @@ -40,6 +40,7 @@
>  
>  #include 
>  #include 
> +#include 
>  
>  /* The Linux code doesn't meet our usual standards! */
>  #ifdef __clang__
> @@ -202,16 +203,42 @@ bitmap_weight(void *p, u_int n)
>   return sum;
>  }
>  
> -#define DECLARE_HASHTABLE(x, y) struct hlist_head x;
> +#define DECLARE_HASHTABLE(name, bits) struct hlist_head name[1 << (bits)]
>  
> -#define hash_init(x) INIT_HLIST_HEAD(&(x))
> -#define hash_add(x, y, z)hlist_add_head(y, &(x))
> -#define hash_del(x)  hlist_del_init(x)
> -#define hash_empty(x)hlist_empty(&(x))
> -#define hash_for_each_possible(a, b, c, d) \
> - hlist_for_each_entry(b, &(a), c)
> -#define hash_for_each_safe(a, b, c, d, e) (void)(b); \
> - hlist_for_each_entry_safe(d, c, &(a), e)
> +static inline void
> +__hash_init(struct hlist_head *table, u_int size)
> +{
> + u_int i;
> +
> + for (i = 0; i < size; i++)
> + INIT_HLIST_HEAD(&table[i]);
> +}
> +
> +static inline bool
> +__hash_empty(struct hlist_head *table, u_int size)
> +{
> + u_int i;
> +
> + for (i = 0; i < size; i++) {
> + if (!hlist_empty(&table[i]))
> + return false;
> + }
> +
> + return true;
> +}
> +
> +#define __hash(table, key)   &table[key % (nitems(table) - 1)]
> +
> +#define hash_init(table) __hash_init(table, nitems(table))
> +#define hash_add(table, node, key) \
> + hlist_add_head(node, __hash(table, key))
> +#define hash_del(node)   hlist_del_init(node)
> +#define hash_empty(table)__hash_empty(table, nitems(table))
> +#define hash_for_each_possible(table, obj, member, key) \
> + hlist_for_each_entry(obj, __hash(table, key), member)
> +#define hash_for_each_safe(table, i, tmp, obj, member)   \
> + for (i = 0; i < nitems(table); i++) \
> +hlist_for_each_entry_safe(obj, tmp, &table[i], member)
>  
>  #define ACCESS_ONCE(x)   (x)
>  
> 
OpenBSD 6.1-current (GENERIC.MP) #11: Mon Jul 17 14:35:43 CEST 2017
giova...@bigio.paclan.it:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4183527424 (3989MB)
avail mem = 4050944000 (3863MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.6 @ 0xccbff000 (42 entries)
bios0: vendor TOSHIBA version "Version 5.00" date 02/15/2017
bios0: TOSHIBA PORTEGE R30-A
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET APIC MCFG BOOT MSDM SLIC SSDT SSDT SSDT ASF! SSDT 
SSDT SSDT DMAR FPDT
acpi0: wakeup devices GLAN(S4) EHC1(S3) EHC2(S3) XHC_(S3) HDEF(S3) RP06(S4) 
PXSX(S4) PWRB(S4) LID_(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-4310M CPU @ 2.70GHz, 2694.14 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: TSC frequency 2694141120 Hz
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i5-4310M CPU @ 2.70GHz, 2693.77 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1

Re: rc: reorder_libs: [2/2] Pick archive versions more efficiently

2017-07-17 Thread Theo Buehler
On Mon, Jul 17, 2017 at 02:14:26PM +0300, Vadim Zhukov wrote:
> 2017-07-17 14:03 GMT+03:00 Klemens Nanni :
> > On Mon, Jul 17, 2017 at 11:57:02AM +0300, Vadim Zhukov wrote:
> >> > +   for _liba in /usr/lib/lib{c,crypto}; do
> >> > +   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | 
> >> > tail -1)"
> >> > done
> >> > +   _libas=${_libas# }
> >> >
> >> > # Remount read-write, if /usr/lib is on a read-only ffs 
> >> > filesystem.
> >> > if [[ $_mp == *' type ffs '*'read-only'* ]]; then
> >> >
> >>
> >> As a matter of microoptimization we could use "sort -rV | head -1"
> >> instead of "sort -V | tail -1". I'm okay with current version of this
> >> diff already, though.
> > Sorting requires to read the entire input, otherwise you'd only sort a
> > subset of the input. I don't see anything being optimized here.
> 
> head -1 returns earlier than tail -1. ;)

I had thought about suggesting this as well, but then I felt it's not
worth it: we're talking about a couple of dozen lines max anyway.

I committed the diff as it is, thanks!



Re: rc: reorder_libs: [2/2] Pick archive versions more efficiently

2017-07-17 Thread Klemens Nanni
On Mon, Jul 17, 2017 at 02:14:26PM +0300, Vadim Zhukov wrote:
> 2017-07-17 14:03 GMT+03:00 Klemens Nanni :
> > On Mon, Jul 17, 2017 at 11:57:02AM +0300, Vadim Zhukov wrote:
> >> > +   for _liba in /usr/lib/lib{c,crypto}; do
> >> > +   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | 
> >> > tail -1)"
> >> > done
> >> > +   _libas=${_libas# }
> >> >
> >> > # Remount read-write, if /usr/lib is on a read-only ffs 
> >> > filesystem.
> >> > if [[ $_mp == *' type ffs '*'read-only'* ]]; then
> >> >
> >>
> >> As a matter of microoptimization we could use "sort -rV | head -1"
> >> instead of "sort -V | tail -1". I'm okay with current version of this
> >> diff already, though.
> > Sorting requires to read the entire input, otherwise you'd only sort a
> > subset of the input. I don't see anything being optimized here.
> 
> head -1 returns earlier than tail -1. ;)
Generally speaking, yes. But here, even for thousands of lines to be
sorted this won't make a difference. For me it's just changing logic
without benefit.



[libcrypto] Don't build empty ecp_nistp* objects

2017-07-17 Thread Brent Cook
OPENSSL_NO_EC_NISTP_64_GCC_128 has been defined in opensslfeatures.h for a
long time, which effectively means that ecp_nistp* are all empty files. So,
there is no reason to build them in the first place. OK?

Index: Makefile
===
RCS file: /cvs/src/lib/libcrypto/Makefile,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 Makefile
--- Makefile10 Jul 2017 21:30:37 -  1.20
+++ Makefile17 Jul 2017 11:21:23 -
@@ -126,7 +126,6 @@ SRCS+= dso_openssl.c
 SRCS+= ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c
 SRCS+= ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c
 SRCS+= ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c
-SRCS+= ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c
 SRCS+= ecp_oct.c ec2_oct.c ec_oct.c

 # ecdh/


Re: rc: Use here document for temporary pf rule set

2017-07-17 Thread Vadim Zhukov
2017-07-17 0:15 GMT+03:00 Klemens Nanni :
> On Sun, Jul 16, 2017 at 08:15:38PM +, Robert Peichaer wrote:
>> > +   ifconfig lo0 inet6 >/dev/null 2>&1 &&
>>
>> Please leave the if-then-fi construct intact. This short form is
>> mostly used for on-line commands (with only a few exceptions).
> OK.
>
>> > +   RULES="$RULES"'
>>
>> What is the reason to use double quotes and single quotes here?
>> Why not just use double quotes like this?
> Personal preference to make clear nothing inside the rules gets
> substituted. Using double quotes only will work just fine here.
>
>> This is not equivalent to the existing code.
>>
>> > +   pass in proto { tcp, udp } from any port { sunrpc, nfsd } to 
>> > any
>> > +   pass out proto { tcp, udp } from any to any port { sunrpc, 
>> > nfsd } !received-on any'
>> > +   print -- "$RULES" | pfctl -nf -
> Of course, fixed. Thanks!
>
>> Unless one of the pf people speaks up in favour of combining it,
>> I'd like to leave the two steps separated as you noted in your
>> original email too.
> Sure.
>
> This is hopefully the final version of my diff. After all it now only
> merges consecutive assignments of RULE into single ones.
>
> Feedback?
>
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.507
> diff -u -p -r1.507 rc
> --- rc  4 Jul 2017 19:02:11 -   1.507
> +++ rc  16 Jul 2017 21:10:48 -
> @@ -402,28 +399,35 @@ wsconsctl_conf
>
>  # Set initial temporary pf rule set.
>  if [[ $pf != NO ]]; then
> -   RULES="block all"
> -   RULES="$RULES\npass on lo0"
> -   RULES="$RULES\npass in proto tcp from any to any port ssh keep state"
> -   RULES="$RULES\npass out proto { tcp, udp } from any to any port 
> domain keep state"
> -   RULES="$RULES\npass out inet proto icmp all icmp-type echoreq keep 
> state"
> -   RULES="$RULES\npass out inet proto udp from any port bootpc to any 
> port bootps"
> -   RULES="$RULES\npass in inet proto udp from any port bootps to any 
> port bootpc"
> +   RULES='
> +   block all
> +   pass on lo0
> +   pass in proto tcp from any to any port ssh keep state
> +   pass out proto { tcp, udp } from any to any port domain keep state
> +   pass out inet proto icmp all icmp-type echoreq keep state
> +   pass out inet proto udp from any port bootpc to any port bootps
> +   pass in inet proto udp from any port bootps to any port bootpc'
> +
> if ifconfig lo0 inet6 >/dev/null 2>&1; then
> -   RULES="$RULES\npass out inet6 proto icmp6 all icmp6-type 
> neighbrsol"
> -   RULES="$RULES\npass in inet6 proto icmp6 all icmp6-type 
> neighbradv"
> -   RULES="$RULES\npass out inet6 proto icmp6 all icmp6-type 
> routersol"
> -   RULES="$RULES\npass in inet6 proto icmp6 all icmp6-type 
> routeradv"
> -   RULES="$RULES\npass out inet6 proto udp from any port 
> dhcpv6-client to any port dhcpv6-server"
> -   RULES="$RULES\npass in inet6 proto udp from any port 
> dhcpv6-server to any port dhcpv6-client"
> +   RULES="$RULES
> +   pass out inet6 proto icmp6 all icmp6-type neighbrsol
> +   pass in inet6 proto icmp6 all icmp6-type neighbradv
> +   pass out inet6 proto icmp6 all icmp6-type routersol
> +   pass in inet6 proto icmp6 all icmp6-type routeradv
> +   pass out inet6 proto udp from any port dhcpv6-client to any 
> port dhcpv6-server
> +   pass in inet6 proto udp from any port dhcpv6-server to any 
> port dhcpv6-client"
> fi
> -   RULES="$RULES\npass in proto carp keep state (no-sync)"
> -   RULES="$RULES\npass out proto carp !received-on any keep state 
> (no-sync)"
> +
> +   RULES="$RULES
> +   pass in proto carp keep state (no-sync)
> +   pass out proto carp !received-on any keep state (no-sync)"
> +
> +   # Don't kill NFS.
> if [[ $(sysctl vfs.mounts.nfs 2>/dev/null) == *[1-9]* ]]; then
> -   # Don't kill NFS.
> -   RULES="set reassemble yes no-df\n$RULES"
> -   RULES="$RULES\npass in proto { tcp, udp } from any port { 
> sunrpc, nfsd } to any"
> -   RULES="$RULES\npass out proto { tcp, udp } from any to any 
> port { sunrpc, nfsd } !received-on any"
> +   RULES="set reassemble yes no-df
> +   $RULES
> +   pass in proto { tcp, udp } from any port { sunrpc, nfsd } to 
> any
> +   pass out proto { tcp, udp } from any to any port { sunrpc, 
> nfsd } !received-on any"
> fi
> print -- "$RULES" | pfctl -f -
> pfctl -e

I like this, okay zhuk@.

--
  WBR,
  Vadim Zhukov



Re: rc: reorder_libs: [2/2] Pick archive versions more efficiently

2017-07-17 Thread Vadim Zhukov
2017-07-17 14:03 GMT+03:00 Klemens Nanni :
> On Mon, Jul 17, 2017 at 11:57:02AM +0300, Vadim Zhukov wrote:
>> > +   for _liba in /usr/lib/lib{c,crypto}; do
>> > +   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | 
>> > tail -1)"
>> > done
>> > +   _libas=${_libas# }
>> >
>> > # Remount read-write, if /usr/lib is on a read-only ffs filesystem.
>> > if [[ $_mp == *' type ffs '*'read-only'* ]]; then
>> >
>>
>> As a matter of microoptimization we could use "sort -rV | head -1"
>> instead of "sort -V | tail -1". I'm okay with current version of this
>> diff already, though.
> Sorting requires to read the entire input, otherwise you'd only sort a
> subset of the input. I don't see anything being optimized here.

head -1 returns earlier than tail -1. ;)

--
  WBR,
  Vadim Zhukov



Re: rc: reorder_libs: [2/2] Pick archive versions more efficiently

2017-07-17 Thread Klemens Nanni
On Mon, Jul 17, 2017 at 11:57:02AM +0300, Vadim Zhukov wrote:
> > +   for _liba in /usr/lib/lib{c,crypto}; do
> > +   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail 
> > -1)"
> > done
> > +   _libas=${_libas# }
> >
> > # Remount read-write, if /usr/lib is on a read-only ffs filesystem.
> > if [[ $_mp == *' type ffs '*'read-only'* ]]; then
> >
> 
> As a matter of microoptimization we could use "sort -rV | head -1"
> instead of "sort -V | tail -1". I'm okay with current version of this
> diff already, though.
Sorting requires to read the entire input, otherwise you'd only sort a
subset of the input. I don't see anything being optimized here.



Re: rc: reorder_libs: [2/2] Pick archive versions more efficiently

2017-07-17 Thread Vadim Zhukov
2017-07-16 14:55 GMT+03:00 Klemens Nanni :
> On Sun, Jul 16, 2017 at 10:26:25AM +, Robert Peichaer wrote:
>> But I'd like to stay strict matching the filenames.
>>
>> + for _liba in /usr/lib/lib{c,crypto}; do
>> + _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail 
>> -1)"
>> + done
>>
>> > +   _libas=${_libas# }
> Agreed, I had a similiar approach first but then tried to reduce the
> differences to the essentials.
>
> Here's an updated diff taking this into while also dropping $_l together
> with this hunk instead of the other one.
>
> Feedback?
>
> Index: rc
> ===
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.507
> diff -u -p -r1.507 rc
> --- rc  4 Jul 2017 19:02:11 -   1.507
> +++ rc  16 Jul 2017 11:54:36 -
> @@ -158,7 +158,7 @@ make_keys() {
>
>  # Re-link libraries, placing the objects in a random order.
>  reorder_libs() {
> -   local _dkdev _l _liba _libas _mp _tmpdir _remount=false _error=false
> +   local _dkdev _liba _libas _mp _tmpdir _remount=false _error=false
>
> [[ $library_aslr == NO ]] && return
>
> @@ -171,13 +171,10 @@ reorder_libs() {
> echo -n 'reordering libraries:'
>
> # Only choose the latest version of the libraries.
> -   for _liba in /usr/lib/libc.so.*.a /usr/lib/libcrypto.so.*.a; do
> -   _liba=$(ls ${_liba%%.[0-9]*}*.a | sort -V | tail -1)
> -   for _l in $_libas; do
> -   [[ $_l == $_liba ]] && continue 2
> -   done
> -   _libas="$_libas $_liba"
> +   for _liba in /usr/lib/lib{c,crypto}; do
> +   _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -V | tail 
> -1)"
> done
> +   _libas=${_libas# }
>
> # Remount read-write, if /usr/lib is on a read-only ffs filesystem.
> if [[ $_mp == *' type ffs '*'read-only'* ]]; then
>

As a matter of microoptimization we could use "sort -rV | head -1"
instead of "sort -V | tail -1". I'm okay with current version of this
diff already, though.



Re: [PATCH] ure improvement

2017-07-17 Thread Martin Pieuchot
On 15/07/17(Sat) 21:16, sc dying wrote:
> Hi,
> 
> This patch does:
> 
> - Enable RX aggregation.

Does it work on all chips?

> - Fix RX packet buffer alignment, using roundup() macro in sys/params.h.

Why is that needed?  pktlen should already be aligned, no?

> - Call usbd_set_config before configuring endpoints in ure_init to fix
>an error when re-opening pipes.  I grabbed the code from if_kue.c.

Which error? Calling usbd_set_config() should be avoid as much as
possible in driver code.

> - Make the chip recognize given MAC address.

Nice

> - Remove ure_reset in ure_init, becasue its already called from ure_stop.

Your diff do not apply, please check your mail setup.

> --- sys/dev/usb/if_ure.c Wed May  3 22:20:15 2017
> +++ sys/dev/usb/if_ure.c Mon Jun 19 09:11:09 2017
> @@ -470,8 +470,6 @@ ure_init(void *xsc)
>   /* Cancel pending I/O. */
>   ure_stop(sc);
> 
> - ure_reset(sc);
> -
>   if (ure_rx_list_init(sc) == ENOBUFS) {
>   printf("%s: rx list init failed\n", sc->ure_dev.dv_xname);
>   splx(s);
> @@ -484,9 +482,18 @@ ure_init(void *xsc)
>   return;
>   }
> 
> +#define URE_CONFIG_NO 1
> + if (usbd_set_config_no(sc->ure_udev, URE_CONFIG_NO, 1) ||
> +usbd_device2interface_handle(sc->ure_udev, URE_IFACE_IDX,
> + &sc->ure_iface))
> + printf("%s: set_config failed\n", sc->ure_dev.dv_xname);
> + usbd_delay_ms(sc->ure_udev, 10);
> +
>   /* Set MAC address. */
> + ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG);
>   ure_write_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES,
>  sc->ure_ac.ac_enaddr, 8);
> + ure_write_1(sc, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML);
> 
>   /* Reset the packet filter. */
>   ure_write_2(sc, URE_PLA_FMC, URE_MCU_TYPE_PLA,
> @@ -683,10 +690,10 @@ ure_rtl8152_init(struct ure_softc *sc)
>  URE_GPHY_STS_MSK | URE_SPEED_DOWN_MSK | URE_SPDWN_RXDV_MSK |
>  URE_SPDWN_LINKCHG_MSK);
> 
> - /* Disable Rx aggregation. */
> + /* Enable Rx aggregation. */
>   ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB,
> -ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) |
> -URE_RX_AGG_DISABLE);
> +ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) &
> +~URE_RX_AGG_DISABLE);
> 
>   /* Disable ALDPS. */
>   ure_ocp_reg_write(sc, URE_OCP_ALDPS_CONFIG, URE_ENPDNPS | URE_LINKENA |
> @@ -835,10 +842,10 @@ ure_rtl8153_init(struct ure_softc *sc)
> 
>   ure_init_fifo(sc);
> 
> - /* Disable Rx aggregation. */
> + /* Enable Rx aggregation. */
>   ure_write_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB,
> -ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) |
> -URE_RX_AGG_DISABLE);
> +ure_read_2(sc, URE_USB_USB_CTRL, URE_MCU_TYPE_USB) &
> +~URE_RX_AGG_DISABLE);
> 
>   val = ure_read_2(sc, URE_USB_U2P3_CTRL, URE_MCU_TYPE_USB);
>   if (!(sc->ure_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10)))
> @@ -1289,7 +1296,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_sta
>   goto done;
>   }
> 
> - buf += pktlen;
> + buf += roundup(pktlen, 8);
> 
>   memcpy(&rxhdr, buf, sizeof(rxhdr));
>   total_len -= sizeof(rxhdr);
> @@ -1302,7 +1309,7 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_sta
>   goto done;
>   }
> 
> - total_len -= pktlen;
> + total_len -= roundup(pktlen, 8);
>   buf += sizeof(rxhdr);
> 
>   m = m_devget(buf, pktlen, ETHER_ALIGN);
>