libc: remove pointless off_t, size_t, void* and char* casts

2016-09-19 Thread Philip Guenther

I'm pretty sure I got all of the "no effect" casts to off_t and size_t.  
I picked up the void* and char* casts with a less comprehensize search, so 
there may be some that slipped through.

This diff was checked by comparing the .o files before and after, building 
on both an LP64 arch (amd64) and an ILP32 arch (i386).  For a handful of 
files, the joining of lines meant the debug info was altered; for those, 
they still compared as unchanged when the 'before' and 'after' files were 
stripped before comparing them.

ok?

Philip

Index: db/hash/hash.c
===
RCS file: /data/src/openbsd/src/lib/libc/db/hash/hash.c,v
retrieving revision 1.28
diff -u -p -r1.28 hash.c
--- db/hash/hash.c  28 Dec 2015 22:08:18 -  1.28
+++ db/hash/hash.c  19 Sep 2016 11:48:15 -
@@ -477,7 +477,7 @@ flush_meta(HTAB *hashp)
whdrp = 
swap_header_copy(>hdr, whdrp);
 #endif
-   if ((wsize = pwrite(fp, whdrp, sizeof(HASHHDR), (off_t)0)) == -1)
+   if ((wsize = pwrite(fp, whdrp, sizeof(HASHHDR), 0)) == -1)
return (-1);
else
if (wsize != sizeof(HASHHDR)) {
Index: db/recno/rec_close.c
===
RCS file: /data/src/openbsd/src/lib/libc/db/recno/rec_close.c,v
retrieving revision 1.12
diff -u -p -r1.12 rec_close.c
--- db/recno/rec_close.c16 Jul 2015 04:27:33 -  1.12
+++ db/recno/rec_close.c19 Sep 2016 11:48:34 -
@@ -124,7 +124,7 @@ __rec_sync(const DB *dbp, u_int flags)
return (RET_ERROR);
 
/* Rewind the file descriptor. */
-   if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0)
+   if (lseek(t->bt_rfd, 0, SEEK_SET) != 0)
return (RET_ERROR);
 
/* Save the cursor. */
@@ -164,7 +164,7 @@ __rec_sync(const DB *dbp, u_int flags)
 
if (status == RET_ERROR)
return (RET_ERROR);
-   if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1)
+   if ((off = lseek(t->bt_rfd, 0, SEEK_CUR)) == -1)
return (RET_ERROR);
if (ftruncate(t->bt_rfd, off))
return (RET_ERROR);
Index: db/recno/rec_open.c
===
RCS file: /data/src/openbsd/src/lib/libc/db/recno/rec_open.c,v
retrieving revision 1.12
diff -u -p -r1.12 rec_open.c
--- db/recno/rec_open.c 16 Jul 2015 04:27:33 -  1.12
+++ db/recno/rec_open.c 19 Sep 2016 11:48:40 -
@@ -112,7 +112,7 @@ __rec_open(const char *fname, int flags,
 * and check the errno values.
 */
errno = 0;
-   if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) {
+   if (lseek(rfd, 0, SEEK_CUR) == -1 && errno == ESPIPE) {
switch (flags & O_ACCMODE) {
case O_RDONLY:
F_SET(t, R_RDONLY);
Index: gdtoa/misc.c
===
RCS file: /data/src/openbsd/src/lib/libc/gdtoa/misc.c,v
retrieving revision 1.6
diff -u -p -r1.6 misc.c
--- gdtoa/misc.c10 Sep 2015 11:11:04 -  1.6
+++ gdtoa/misc.c19 Sep 2016 12:15:53 -
@@ -102,9 +102,9 @@ Bfree
if (v) {
if (v->k > Kmax)
 #ifdef FREE
-   FREE((void*)v);
+   FREE(v);
 #else
-   free((void*)v);
+   free(v);
 #endif
else {
ACQUIRE_DTOA_LOCK(0);
Index: gen/fts.c
===
RCS file: /data/src/openbsd/src/lib/libc/gen/fts.c,v
retrieving revision 1.55
diff -u -p -r1.55 fts.c
--- gen/fts.c   28 Jun 2016 17:21:48 -  1.55
+++ gen/fts.c   19 Sep 2016 12:16:51 -
@@ -654,7 +654,7 @@ fts_build(FTS *sp, int type)
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
continue;
 
-   if (!(p = fts_alloc(sp, dp->d_name, (size_t)dp->d_namlen)))
+   if (!(p = fts_alloc(sp, dp->d_name, dp->d_namlen)))
goto mem1;
if (dp->d_namlen >= maxlen) {   /* include space for NUL */
oldaddr = sp->fts_path;
@@ -894,7 +894,7 @@ fts_sort(FTS *sp, FTSENT *head, int nite
}
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
*ap++ = p;
-   qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar);
+   qsort(sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar);
for (head = *(ap = sp->fts_array); --nitems; ++ap)
ap[0]->fts_link = ap[1];
ap[0]->fts_link = NULL;
Index: gen/getcap.c
===
RCS file: /data/src/openbsd/src/lib/libc/gen/getcap.c,v
retrieving revision 1.33
diff -u -p -r1.33 getcap.c
--- gen/getcap.c14 

Re: [PATCH] www: mention /usr/src in upgrade notes

2016-09-19 Thread Simon Ruderich
On Mon, Sep 19, 2016 at 07:25:08PM -0700, Philip Guenther wrote:
> Listing what something *doesn't* do is generally a bad plan, because
> the list has no end, so where to draw the line becomes a matter of
> opinion.  Better to list what the installer does update and say that's
> the complete list, and then perhaps "Anything else previously
> installed will need to be updated separately."

Sounds fine to me.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9


signature.asc
Description: PGP signature


Re: [PATCH] www: mention /usr/src in upgrade notes

2016-09-19 Thread Philip Guenther
On Mon, Sep 19, 2016 at 7:12 PM, Simon Ruderich  wrote:
...
> However I still would like to see a quick note telling the user
> that he should remember to update all source-based data because
> the installer won't do it for them . Maybe something like "The
> installer doesn't automatically update source files, for example
> in /usr/src".

Listing what something *doesn't* do is generally a bad plan, because
the list has no end, so where to draw the line becomes a matter of
opinion.  Better to list what the installer does update and say that's
the complete list, and then perhaps "Anything else previously
installed will need to be updated separately."


Philip Guenther



Re: [PATCH] www: mention /usr/src in upgrade notes

2016-09-19 Thread Theo de Raadt
> However I still would like to see a quick note telling the user
> that he should remember to update all source-based data because
> the installer won't do it for them . Maybe something like "The
> installer doesn't automatically update source files, for example
> in /usr/src".

Yeah, we could add a quick note.

Then when the next person suggests so, add another quick note.

And a quick note, and a quick note, and a quick note, and a quick
note, and soon the total isn't so quick.

That's what the FAQ is for.



Re: [PATCH] www: mention /usr/src in upgrade notes

2016-09-19 Thread Simon Ruderich
On Mon, Sep 19, 2016 at 03:00:40AM +0200, Theo Buehler wrote:
> On Mon, Sep 19, 2016 at 01:59:20AM +0200, Simon Ruderich wrote:
>> I'm a relatively new OpenBSD user and just updated my system from
>> 5.9 to 6.0 but forgot to update the files in /usr/src. Thus when
>> I applied the latest patches (001-006) I actually built an old
>> 5.9 kernel which failed to boot. The following patch mentions
>> /usr/src in the upgrade notes.
>
> Thanks a lot for taking the time and submitting a patch. I will need to
> think about this a little. I will probably end up adding a link to
> errata.html since that is a more glaring omission on that page.

Hello,

I saw the addition of the errata and stable links. I think that's
an improvement, thanks.

However I still would like to see a quick note telling the user
that he should remember to update all source-based data because
the installer won't do it for them . Maybe something like "The
installer doesn't automatically update source files, for example
in /usr/src".

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9


signature.asc
Description: PGP signature


netinet/ ansify

2016-09-19 Thread David Hill
Hello -

Ansify netinet/

Index: ip_ecn.c
===
RCS file: /cvs/src/sys/netinet/ip_ecn.c,v
retrieving revision 1.7
diff -u -p -r1.7 ip_ecn.c
--- ip_ecn.c19 Dec 2014 17:14:40 -  1.7
+++ ip_ecn.c20 Sep 2016 01:54:47 -
@@ -84,10 +84,7 @@
  * call it after you've done the default initialization/copy for the outer.
  */
 void
-ip_ecn_ingress(mode, outer, inner)
-   int mode;
-   u_int8_t *outer;
-   u_int8_t *inner;
+ip_ecn_ingress(int mode, u_int8_t *outer, u_int8_t *inner)
 {
if (!outer || !inner)
panic("NULL pointer passed to ip_ecn_ingress");
@@ -120,10 +117,7 @@ ip_ecn_ingress(mode, outer, inner)
  * the caller should drop the packet if the return value is 0.
  */
 int
-ip_ecn_egress(mode, outer, inner)
-   int mode;
-   u_int8_t *outer;
-   u_int8_t *inner;
+ip_ecn_egress(int mode, u_int8_t *outer, u_int8_t *inner)
 {
if (!outer || !inner)
panic("NULL pointer passed to ip_ecn_egress");
Index: ip_ether.c
===
RCS file: /cvs/src/sys/netinet/ip_ether.c,v
retrieving revision 1.80
diff -u -p -r1.80 ip_ether.c
--- ip_ether.c  2 Dec 2015 08:47:00 -   1.80
+++ ip_ether.c  20 Sep 2016 01:54:47 -
@@ -507,11 +507,8 @@ etherip_output(struct mbuf *m, struct td
 }
 
 int
-etherip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
-   int *name;
-   u_int namelen;
-   void *oldp, *newp;
-   size_t *oldlenp, newlen;
+etherip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
+void *newp, size_t newlen)
 {
/* All sysctl names at this level are terminal. */
if (namelen != 1)
Index: ip_ipcomp.c
===
RCS file: /cvs/src/sys/netinet/ip_ipcomp.c,v
retrieving revision 1.47
diff -u -p -r1.47 ip_ipcomp.c
--- ip_ipcomp.c 13 Sep 2016 19:56:55 -  1.47
+++ ip_ipcomp.c 20 Sep 2016 01:54:47 -
@@ -80,10 +80,7 @@ ipcomp_attach(void)
  * ipcomp_init() is called when an CPI is being set up.
  */
 int
-ipcomp_init(tdbp, xsp, ii)
-   struct tdb *tdbp;
-   struct xformsw *xsp;
-   struct ipsecinit *ii;
+ipcomp_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii)
 {
struct comp_algo *tcomp = NULL;
struct cryptoini cric;
@@ -120,8 +117,7 @@ ipcomp_init(tdbp, xsp, ii)
  * ipcomp_zeroize() used when IPCA is deleted
  */
 int
-ipcomp_zeroize(tdbp)
-   struct tdb *tdbp;
+ipcomp_zeroize(struct tdb *tdbp)
 {
int err;
 
@@ -134,11 +130,7 @@ ipcomp_zeroize(tdbp)
  * ipcomp_input() gets called to uncompress an input packet
  */
 int
-ipcomp_input(m, tdb, skip, protoff)
-   struct mbuf*m;
-   struct tdb *tdb;
-   int skip;
-   int protoff;
+ipcomp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff)
 {
struct comp_algo *ipcompx = (struct comp_algo *) tdb->tdb_compalgxform;
struct tdb_crypto *tc;
@@ -361,12 +353,8 @@ baddone:
  * IPComp output routine, called by ipsp_process_packet()
  */
 int
-ipcomp_output(m, tdb, mp, skip, protoff)
-   struct mbuf*m;
-   struct tdb *tdb;
-   struct mbuf   **mp;
-   int skip;
-   int protoff;
+ipcomp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip,
+int protoff)
 {
struct comp_algo *ipcompx = (struct comp_algo *) tdb->tdb_compalgxform;
int hlen;
Index: tcp_subr.c
===
RCS file: /cvs/src/sys/netinet/tcp_subr.c,v
retrieving revision 1.155
diff -u -p -r1.155 tcp_subr.c
--- tcp_subr.c  15 Sep 2016 02:00:18 -  1.155
+++ tcp_subr.c  20 Sep 2016 01:54:47 -
@@ -186,8 +186,7 @@ tcp_init(void)
  * into just an IP overlay pointer, with casting as appropriate for v6. rja
  */
 struct mbuf *
-tcp_template(tp)
-   struct tcpcb *tp;
+tcp_template(struct tcpcb *tp)
 {
struct inpcb *inp = tp->t_inpcb;
struct mbuf *m;
@@ -488,9 +487,7 @@ tcp_newtcpcb(struct inpcb *inp)
  * then send a RST to peer.
  */
 struct tcpcb *
-tcp_drop(tp, errno)
-   struct tcpcb *tp;
-   int errno;
+tcp_drop(struct tcpcb *tp, int errno)
 {
struct socket *so = tp->t_inpcb->inp_socket;
 
@@ -595,9 +592,7 @@ tcp_rscale(struct tcpcb *tp, u_long hiwa
  * (for now, won't do anything until can select for soft error).
  */
 void
-tcp_notify(inp, error)
-   struct inpcb *inp;
-   int error;
+tcp_notify(struct inpcb *inp, int error)
 {
struct tcpcb *tp = intotcpcb(inp);
struct socket *so = inp->inp_socket;
@@ -863,9 +858,7 @@ tcp_ctlinput(int cmd, struct sockaddr *s
  * Path MTU Discovery handlers.
  */
 void
-tcp6_mtudisc_callback(sin6, rdomain)
-   struct sockaddr_in6 *sin6;
-   u_int rdomain;
+tcp6_mtudisc_callback(struct sockaddr_in6 *sin6, u_int rdomain)

Re: [PATCH] switch.4 awkward sentence reorder

2016-09-19 Thread Bryan Vyhmeister
On Mon, Sep 19, 2016 at 06:24:54PM -0700, Bryan Vyhmeister wrote:
> On Tue, Sep 20, 2016 at 02:11:41AM +0100, Stuart Henderson wrote:
> > Still seems a bit awkward, how about this?
> > 
> > The
> > .Nm
> > device and the controller communicate using the
> > OpenFlow 1.3 protocol.
> 
> Even better. I am very happy with that.

And here is the patch to accomlish what you said.

Bryan


Index: switch.4
===
RCS file: /cvs/src/share/man/man4/switch.4,v
retrieving revision 1.3
diff -u -p -r1.3 switch.4
--- switch.44 Sep 2016 19:03:34 -   1.3
+++ switch.420 Sep 2016 01:28:54 -
@@ -38,11 +38,10 @@ and it works along with a controller whi
 or
 .Xr switchctl 8 through the device
 .Pa /dev/switchN .
-As the protocol between the
+The
 .Nm
-device
-and the controller,
-OpenFlow 1.3 is supported.
+device and the controller communicate using the OpenFlow
+1.3 protocol.
 .Pp
 A
 .Nm



Re: [PATCH] switch.4 awkward sentence reorder

2016-09-19 Thread Bryan Vyhmeister
On Tue, Sep 20, 2016 at 02:11:41AM +0100, Stuart Henderson wrote:
> Still seems a bit awkward, how about this?
> 
> The
> .Nm
> device and the controller communicate using the
> OpenFlow 1.3 protocol.

Even better. I am very happy with that.

Bryan



my final netinet6 bcopy->memcpy

2016-09-19 Thread David Hill
Hello -

Here are the final bcopy->memcpy conversions in netinet6 that I am
comfortable with.  There is also one (bcmp()) to (memcmp() != 0)
conversion since the memory is not overlapping.

This, with the last netinet6 diff, has dropped the number of bcopy()
calls from 62 to 29 in netinet6/

Index: icmp6.c
===
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.190
diff -u -p -r1.190 icmp6.c
--- icmp6.c 24 Aug 2016 09:38:29 -  1.190
+++ icmp6.c 20 Sep 2016 01:00:36 -
@@ -1401,7 +1401,7 @@ icmp6_redirect_input(struct mbuf *m, int
bzero(, sizeof(sin6));
sin6.sin6_family = AF_INET6;
sin6.sin6_len = sizeof(struct sockaddr_in6);
-   bcopy(, _addr, sizeof(reddst6));
+   memcpy(_addr, , sizeof(reddst6));
rt = rtalloc(sin6tosa(), 0, m->m_pkthdr.ph_rtableid);
if (rt) {
if (rt->rt_gateway == NULL ||
@@ -1509,9 +1509,9 @@ icmp6_redirect_input(struct mbuf *m, int
sdst.sin6_family = sgw.sin6_family = ssrc.sin6_family = 
AF_INET6;
sdst.sin6_len = sgw.sin6_len = ssrc.sin6_len =
sizeof(struct sockaddr_in6);
-   bcopy(, _addr, sizeof(struct in6_addr));
-   bcopy(, _addr, sizeof(struct in6_addr));
-   bcopy(, _addr, sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
rtredirect(sin6tosa(), sin6tosa(), sin6tosa(),
, m->m_pkthdr.ph_rtableid);
 
@@ -1528,7 +1528,7 @@ icmp6_redirect_input(struct mbuf *m, int
bzero(, sizeof(sdst));
sdst.sin6_family = AF_INET6;
sdst.sin6_len = sizeof(struct sockaddr_in6);
-   bcopy(, _addr, sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
pfctlinput(PRC_REDIRECT_HOST, sin6tosa());
}
 
Index: in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.192
diff -u -p -r1.192 in6.c
--- in6.c   4 Sep 2016 10:32:01 -   1.192
+++ in6.c   20 Sep 2016 01:00:36 -
@@ -1029,9 +1029,9 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
 
/* copy args to in6_aliasreq, perform ioctl(SIOCAIFADDR_IN6). */
bzero(, sizeof(ifra));
-   bcopy(iflr->iflr_name, ifra.ifra_name, sizeof(ifra.ifra_name));
+   memcpy(ifra.ifra_name, iflr->iflr_name, sizeof(ifra.ifra_name));
 
-   bcopy(>addr, _addr,
+   memcpy(_addr, >addr,
((struct sockaddr *)>addr)->sa_len);
if (hostid) {
/* fill in hostid part */
@@ -1042,7 +1042,7 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
}
 
if (((struct sockaddr *)>dstaddr)->sa_family) {   /*XXX*/
-   bcopy(>dstaddr, _dstaddr,
+   memcpy(_dstaddr, >dstaddr,
((struct sockaddr *)>dstaddr)->sa_len);
if (hostid) {
ifra.ifra_dstaddr.sin6_addr.s6_addr32[2] =
@@ -1073,14 +1073,14 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
in6_prefixlen2mask(, iflr->prefixlen);
 
sin6 = (struct sockaddr_in6 *)>addr;
-   bcopy(>sin6_addr, , sizeof(match));
+   memcpy(, >sin6_addr, sizeof(match));
match.s6_addr32[0] &= mask.s6_addr32[0];
match.s6_addr32[1] &= mask.s6_addr32[1];
match.s6_addr32[2] &= mask.s6_addr32[2];
match.s6_addr32[3] &= mask.s6_addr32[3];
 
/* if you set extra bits, that's wrong */
-   if (bcmp(, >sin6_addr, sizeof(match)))
+   if (memcmp(, >sin6_addr, sizeof(match)) != 
0)
return EINVAL;
 
cmp = 1;
@@ -1092,7 +1092,7 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
/* on deleting an address, do exact match */
in6_prefixlen2mask(, 128);
sin6 = (struct sockaddr_in6 *)>addr;
-   bcopy(>sin6_addr, , sizeof(match));
+   memcpy(, >sin6_addr, sizeof(match));
 
cmp = 1;
}
@@ -1104,7 +1104,7 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
if (!cmp)
break;
 
-   bcopy(IFA_IN6(ifa), , sizeof(candidate));
+   memcpy(, IFA_IN6(ifa), sizeof(candidate));
candidate.s6_addr32[0] &= 

Re: [PATCH] switch.4 awkward sentence reorder

2016-09-19 Thread Stuart Henderson
On 2016/09/19 18:05, Bryan Vyhmeister wrote:
> This is a patch to reorder an awkward sentence in the switch(4) man
> page. This may not be desired but it looks less awkward to me.
> 
> Bryan
> 
> 
> Index: switch.4
> ===
> RCS file: /cvs/src/share/man/man4/switch.4,v
> retrieving revision 1.3
> diff -u -p -r1.3 switch.4
> --- switch.4  4 Sep 2016 19:03:34 -   1.3
> +++ switch.4  20 Sep 2016 00:59:17 -
> @@ -38,11 +38,10 @@ and it works along with a controller whi
>  or
>  .Xr switchctl 8 through the device
>  .Pa /dev/switchN .
> -As the protocol between the
> +OpenFlow 1.3 is supported as the protocol between the
>  .Nm
>  device
> -and the controller,
> -OpenFlow 1.3 is supported.
> +and the controller.
>  .Pp
>  A
>  .Nm
> 

Still seems a bit awkward, how about this?

The
.Nm
device and the controller communicate using the
OpenFlow 1.3 protocol.



[PATCH] switch.4 awkward sentence reorder

2016-09-19 Thread Bryan Vyhmeister
This is a patch to reorder an awkward sentence in the switch(4) man
page. This may not be desired but it looks less awkward to me.

Bryan


Index: switch.4
===
RCS file: /cvs/src/share/man/man4/switch.4,v
retrieving revision 1.3
diff -u -p -r1.3 switch.4
--- switch.44 Sep 2016 19:03:34 -   1.3
+++ switch.420 Sep 2016 00:59:17 -
@@ -38,11 +38,10 @@ and it works along with a controller whi
 or
 .Xr switchctl 8 through the device
 .Pa /dev/switchN .
-As the protocol between the
+OpenFlow 1.3 is supported as the protocol between the
 .Nm
 device
-and the controller,
-OpenFlow 1.3 is supported.
+and the controller.
 .Pp
 A
 .Nm



Re: Enabling rasops24

2016-09-19 Thread Michael W. Bombardieri
On Mon, Sep 19, 2016 at 06:52:00PM -0400, sven falempin wrote:
> Tested here and it works ! @OK
> 
> The terminal is white on red for first part of boot then goes back to white
> on
> blue.
> Also some kind of flicker/bufering during the start,
> aftfer the kernel loading no update for like half a second.
> 
> But it s booting completly :
> 
> i got some
> dmesg: sysctl: KERN_MSGBUF: Cannot allocate memmory.
> probably related to my  tree i used to compile the kernel with the
> option
> rasops24
> 
> ( QEMU emulator version 2.6.0, with OVMF Bios, OpenBSD directly on phyical
> hard drive )
Any difference under QEMU 2.7.0?

> On Tue, Aug 30, 2016 at 12:49 PM, YASUOKA Masahiko 
> wrote:
> 
> > Enabling rasops24 in files.amd64 makes QEMU with UEFI start working.
> >
> > But.. the background color of the kernel message is sometimes red or
> > green where it should be blue.
> >
> > ok for files.amd64?
> > comments for the color problem?
> >
> > Index: sys/arch/amd64/conf/files.amd64
> > ===
> > RCS file: /cvs/src/sys/arch/amd64/conf/files.amd64,v
> > retrieving revision 1.85
> > diff -u -p -r1.85 files.amd64
> > --- sys/arch/amd64/conf/files.amd64 8 Jan 2016 15:54:13 -
> >  1.85
> > +++ sys/arch/amd64/conf/files.amd64 30 Aug 2016 16:38:19 -
> > @@ -109,7 +109,7 @@ filearch/amd64/amd64/ioapic.c
> >  ioapic n
> >  #
> >  # EFI Framebuffer
> >  #
> > -device efifb: wsemuldisplaydev, rasops32, rasops16, rasops8, rasops4
> > +device efifb: wsemuldisplaydev, rasops32, rasops24, rasops16, rasops8,
> > rasops4
> >  attach efifb at mainbus
> >  file arch/amd64/amd64/efifb.c  efifb needs-flag
> >
> >
> >
> 
> 
> -- 
> -
> () ascii ribbon campaign - against html e-mail
> /\



work-in-progress iwm performance fix

2016-09-19 Thread Stefan Sperling
I'd like to know if this diff helps with iwm(4) performance issues
some people have been reporting.

This is not done yet and some details don't really make sense, especially
the #if 0 hiding of what should be correct code -- yet, enabling that code
makes the problem come back.

But hopefully this is generally going in the right direction.

Thank you, Edward Wandasiewicz, for pointing out that reverting if_iwm.c
r1.85 restores performance. That was the door to this rabbit hole :-)

Index: dev/pci/if_iwm.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v
retrieving revision 1.132
diff -u -p -r1.132 if_iwm.c
--- dev/pci/if_iwm.c12 Sep 2016 10:18:26 -  1.132
+++ dev/pci/if_iwm.c20 Sep 2016 00:17:38 -
@@ -402,10 +402,8 @@ intiwm_config_umac_scan(struct iwm_soft
 intiwm_umac_scan(struct iwm_softc *);
 void   iwm_ack_rates(struct iwm_softc *, struct iwm_node *, int *, int *);
 void   iwm_mac_ctxt_cmd_common(struct iwm_softc *, struct iwm_node *,
-   struct iwm_mac_ctx_cmd *, uint32_t);
-void   iwm_mac_ctxt_cmd_fill_sta(struct iwm_softc *, struct iwm_node *,
-   struct iwm_mac_data_sta *, int);
-intiwm_mac_ctxt_cmd(struct iwm_softc *, struct iwm_node *, uint32_t);
+   struct iwm_mac_ctx_cmd *, uint32_t, int);
+intiwm_mac_ctxt_cmd(struct iwm_softc *, struct iwm_node *, uint32_t, int);
 intiwm_update_quotas(struct iwm_softc *, struct iwm_node *);
 intiwm_auth(struct iwm_softc *);
 intiwm_assoc(struct iwm_softc *);
@@ -2428,7 +2426,7 @@ iwm_htprot_task(void *arg)
int err;
 
/* This call updates HT protection based on in->in_ni.ni_htop1. */
-   err = iwm_mac_ctxt_cmd(sc, in, IWM_FW_CTXT_ACTION_MODIFY);
+   err = iwm_mac_ctxt_cmd(sc, in, IWM_FW_CTXT_ACTION_MODIFY, 1);
if (err)
printf("%s: could not change HT protection: error %d\n",
DEVNAME(sc), err);
@@ -4203,14 +4201,15 @@ void
 iwm_power_build_cmd(struct iwm_softc *sc, struct iwm_node *in,
 struct iwm_mac_power_cmd *cmd)
 {
-   struct ieee80211com *ic = >sc_ic;
struct ieee80211_node *ni = >in_ni;
-   int dtimper, dtimper_msec;
-   int keep_alive;
+   int dtim_period, dtim_msec, keep_alive;
 
cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(in->in_id,
in->in_color));
-   dtimper = ic->ic_dtim_period ?: 1;
+   if (ni->ni_dtimperiod)
+   dtim_period = ni->ni_dtimperiod;
+   else
+   dtim_period = 1;
 
/*
 * Regardless of power management state the driver must set
@@ -4218,9 +4217,8 @@ iwm_power_build_cmd(struct iwm_softc *sc
 * immediately after association. Check that keep alive period
 * is at least 3 * DTIM.
 */
-   dtimper_msec = dtimper * ni->ni_intval;
-   keep_alive
-   = MAX(3 * dtimper_msec, 1000 * IWM_POWER_KEEP_ALIVE_PERIOD_SEC);
+   dtim_msec = dtim_period * ni->ni_intval * IEEE80211_DUR_TU;
+   keep_alive = MAX(3 * dtim_msec, 1000 * IWM_POWER_KEEP_ALIVE_PERIOD_SEC);
keep_alive = roundup(keep_alive, 1000) / 1000;
cmd->keep_alive_seconds = htole16(keep_alive);
 }
@@ -4249,14 +4247,12 @@ iwm_power_mac_update_mode(struct iwm_sof
 int
 iwm_power_update_device(struct iwm_softc *sc)
 {
-   struct iwm_device_power_cmd cmd = {
-   .flags = htole16(IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK),
-   };
+   struct iwm_device_power_cmd cmd;
 
if (!(sc->sc_capaflags & IWM_UCODE_TLV_FLAGS_DEVICE_PS_CMD))
return 0;
 
-   cmd.flags |= htole16(IWM_DEVICE_POWER_FLAGS_CAM_MSK);
+   cmd.flags = htole16(IWM_DEVICE_POWER_FLAGS_CAM_MSK);
 
return iwm_send_cmd_pdu(sc,
IWM_POWER_TABLE_CMD, 0, sizeof(cmd), );
@@ -4975,7 +4971,7 @@ iwm_ack_rates(struct iwm_softc *sc, stru
 
 void
 iwm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
-struct iwm_mac_ctx_cmd *cmd, uint32_t action)
+struct iwm_mac_ctx_cmd *cmd, uint32_t action, int assoc)
 {
struct ieee80211com *ic = >sc_ic;
struct ieee80211_node *ni = ic->ic_bss;
@@ -4987,14 +4983,17 @@ iwm_mac_ctxt_cmd_common(struct iwm_softc
cmd->action = htole32(action);
 
cmd->mac_type = htole32(IWM_FW_MAC_TYPE_BSS_STA);
-   cmd->tsf_id = htole32(in->in_tsfid);
+   cmd->tsf_id = htole32(IWM_TSF_ID_A);
 
IEEE80211_ADDR_COPY(cmd->node_addr, ic->ic_myaddr);
-   if (in->in_assoc) {
+
+#if 0 /* For some reason setting our BSSID here causes Rx problems. */
+   if (assoc)
IEEE80211_ADDR_COPY(cmd->bssid_addr, ni->ni_bssid);
-   } else {
+   else
+#endif
IEEE80211_ADDR_COPY(cmd->bssid_addr, etherbroadcastaddr);
-   }
+
iwm_ack_rates(sc, in, _ack_rates, _ack_rates);
cmd->cck_rates = htole32(cck_ack_rates);
cmd->ofdm_rates = htole32(ofdm_ack_rates);
@@ -5040,47 +5039,44 @@ 

Re: Enabling rasops24

2016-09-19 Thread sven falempin
Tested here and it works ! @OK

The terminal is white on red for first part of boot then goes back to white
on
blue.
Also some kind of flicker/bufering during the start,
aftfer the kernel loading no update for like half a second.

But it s booting completly :

i got some
dmesg: sysctl: KERN_MSGBUF: Cannot allocate memmory.
probably related to my  tree i used to compile the kernel with the
option
rasops24

( QEMU emulator version 2.6.0, with OVMF Bios, OpenBSD directly on phyical
hard drive )



On Tue, Aug 30, 2016 at 12:49 PM, YASUOKA Masahiko 
wrote:

> Enabling rasops24 in files.amd64 makes QEMU with UEFI start working.
>
> But.. the background color of the kernel message is sometimes red or
> green where it should be blue.
>
> ok for files.amd64?
> comments for the color problem?
>
> Index: sys/arch/amd64/conf/files.amd64
> ===
> RCS file: /cvs/src/sys/arch/amd64/conf/files.amd64,v
> retrieving revision 1.85
> diff -u -p -r1.85 files.amd64
> --- sys/arch/amd64/conf/files.amd64 8 Jan 2016 15:54:13 -
>  1.85
> +++ sys/arch/amd64/conf/files.amd64 30 Aug 2016 16:38:19 -
> @@ -109,7 +109,7 @@ filearch/amd64/amd64/ioapic.c
>  ioapic n
>  #
>  # EFI Framebuffer
>  #
> -device efifb: wsemuldisplaydev, rasops32, rasops16, rasops8, rasops4
> +device efifb: wsemuldisplaydev, rasops32, rasops24, rasops16, rasops8,
> rasops4
>  attach efifb at mainbus
>  file arch/amd64/amd64/efifb.c  efifb needs-flag
>
>
>


-- 
-
() ascii ribbon campaign - against html e-mail
/\


Re: db_{interface,trace}.c: ansify function definitions

2016-09-19 Thread Philip Guenther
On Mon, Sep 19, 2016 at 11:02 AM, Jasper Lievisse Adriaanse
 wrote:
> OK?
>
> Index: alpha/alpha/db_trace.c
...

ok guenther@



Re: Remove duplicated includes in stdlib.h and termios.h

2016-09-19 Thread Philip Guenther
On Mon, Sep 19, 2016 at 11:50 AM, Frederic Cambus  wrote:
> Hi tech@,
>
> This diff removes duplicated includes in stdlib.h and termios.h
>
> Comments? OK?

ok guenther@



Remove duplicated includes in stdlib.h and termios.h

2016-09-19 Thread Frederic Cambus
Hi tech@,

This diff removes duplicated includes in stdlib.h and termios.h

Comments? OK?

Index: include/stdlib.h
===
RCS file: /cvs/src/include/stdlib.h,v
retrieving revision 1.66
diff -u -p -r1.66 stdlib.h
--- include/stdlib.h9 Sep 2016 18:12:37 -   1.66
+++ include/stdlib.h16 Sep 2016 22:23:11 -
@@ -85,8 +85,6 @@ typedef struct {
 extern size_t  __mb_cur_max;
 #defineMB_CUR_MAX  __mb_cur_max
 
-#include 
-
 /*
  * Some header files may define an abs macro.
  * If defined, undef it to prevent a syntax error and issue a warning.
Index: sys/sys/termios.h
===
RCS file: /cvs/src/sys/sys/termios.h,v
retrieving revision 1.12
diff -u -p -r1.12 termios.h
--- sys/sys/termios.h   17 Dec 2013 22:12:07 -  1.12
+++ sys/sys/termios.h   16 Sep 2016 22:23:12 -
@@ -247,7 +247,6 @@ struct termios {
 #define TCIOFF 3
 #define TCION  4
 
-#include 
 #include 
 
 #if __XPG_VISIBLE >= 420 || __POSIX_VISIBLE >= 200809



Re: video(1): Don't limit maximum frame size to display size

2016-09-19 Thread Gregor Best
Hi,

> [...]
> This seems to work fine with inteldrm, a 1280x800 display and
> [...]

Good to hear I didn't break anything :)

> [...]
> No idea either... if you wanted to reduce the risk of breakage, I
> guess you could limit the resolution only if -O is not passed.
> [...]

I've read up on Xv a bit and I think it's okay to just give it larger
images, so this kind of precaution doesn't seem necessary.

-- 
Gregor



db_{interface,trace}.c: ansify function definitions

2016-09-19 Thread Jasper Lievisse Adriaanse
OK?

Index: alpha/alpha/db_trace.c
===
RCS file: /cvs/src/sys/arch/alpha/alpha/db_trace.c,v
retrieving revision 1.18
diff -u -p -r1.18 db_trace.c
--- alpha/alpha/db_trace.c  19 Sep 2016 17:59:18 -  1.18
+++ alpha/alpha/db_trace.c  19 Sep 2016 18:00:58 -
@@ -171,12 +171,8 @@ disp(x)
  * symbols available.
  */
 void
-db_stack_trace_print(addr, have_addr, count, modif, pr)
-   db_expr_t   addr;
-   int have_addr;
-   db_expr_t   count;
-   char*modif;
-   int (*pr)(const char *, ...);
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...))
 {
u_long  *frame;
int i, framesize;
Index: arm/arm/db_trace.c
===
RCS file: /cvs/src/sys/arch/arm/arm/db_trace.c,v
retrieving revision 1.7
diff -u -p -r1.7 db_trace.c
--- arm/arm/db_trace.c  19 Sep 2016 17:59:18 -  1.7
+++ arm/arm/db_trace.c  19 Sep 2016 18:00:58 -
@@ -81,12 +81,8 @@ db_regs_t ddb_regs;
 #define FR_RFP (-3)
 
 void
-db_stack_trace_print(addr, have_addr, count, modif, pr)
-   db_expr_t   addr;
-   int have_addr;
-   db_expr_t   count;
-   char*modif;
-   int (*pr) (const char *, ...);
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...)))
 {
u_int32_t   *frame, *lastframe;
char c, *cp = modif;
Index: hppa/hppa/db_interface.c
===
RCS file: /cvs/src/sys/arch/hppa/hppa/db_interface.c,v
retrieving revision 1.37
diff -u -p -r1.37 db_interface.c
--- hppa/hppa/db_interface.c1 Mar 2016 21:35:13 -   1.37
+++ hppa/hppa/db_interface.c19 Sep 2016 18:00:58 -
@@ -134,10 +134,7 @@ Debugger()
 }
 
 void
-db_read_bytes(addr, size, data)
-   vaddr_t addr;
-   size_t size;
-   char *data;
+db_read_bytes(vaddr_t addr, size_t size, char *data)
 {
register char *src = (char *)addr;
 
@@ -146,10 +143,7 @@ db_read_bytes(addr, size, data)
 }
 
 void
-db_write_bytes(addr, size, data)
-   vaddr_t addr;
-   size_t size;
-   char *data;
+db_write_bytes(vaddr_t addr, size_t size, char *data)
 {
register char *dst = (char *)addr;
 
@@ -166,8 +160,7 @@ db_write_bytes(addr, size, data)
  * Print trap reason.
  */
 void
-kdbprinttrap(type, code)
-   int type, code;
+kdbprinttrap(int type, int code)
 {
type &= ~T_USER;/* just in case */
db_printf("kernel: ");
@@ -182,9 +175,7 @@ kdbprinttrap(type, code)
  *  db_ktrap - field a BPT trap
  */
 int
-db_ktrap(type, code, regs)
-   int type, code;
-   db_regs_t *regs;
+db_ktrap(int type, int code, db_regs_t *regs)
 {
extern label_t *db_recover;
int s;
@@ -226,19 +217,14 @@ db_ktrap(type, code, regs)
  *  Any address is allowed for now.
  */
 int
-db_valid_breakpoint(addr)
-   db_addr_t addr;
+db_valid_breakpoint(db_addr_t addr)
 {
return (1);
 }
 
 void
-db_stack_trace_print(addr, have_addr, count, modif, pr)
-   db_expr_t   addr;
-   int have_addr;
-   db_expr_t   count;
-   char*modif;
-   int (*pr)(const char *, ...);
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...))
 {
register_t *fp, pc, rp, *argp;
db_sym_t sym;
Index: m88k/m88k/db_trace.c
===
RCS file: /cvs/src/sys/arch/m88k/m88k/db_trace.c,v
retrieving revision 1.15
diff -u -p -r1.15 db_trace.c
--- m88k/m88k/db_trace.c9 Mar 2016 08:58:50 -   1.15
+++ m88k/m88k/db_trace.c19 Sep 2016 18:00:58 -
@@ -806,11 +806,8 @@ db_stack_trace_cmd2(db_regs_t *regs, int
  * printed.
  */
 void
-db_stack_trace_print(db_expr_t addr,
-  int have_addr,
-  db_expr_t count,
-  char *modif,
-  int (*pr)(const char *, ...))
+db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count,
+char *modif, int (*pr)(const char *, ...))
 {
enum {
Default, Stack, Frame

-- 
jasper



Re: Build libc++ and libc++abi with -nostdinc++

2016-09-19 Thread Philip Guenther
On Mon, Sep 19, 2016 at 2:40 AM, Mark Kettenis  wrote:
>> Date: Sun, 18 Sep 2016 00:12:19 +0200 (CEST)
>> From: Mark Kettenis 
>>
>> Without this, they don't build with clang++ because it tries to use
>> the installed headers.  Doesn't hurt building with eg++.
>>
>> ok?

Makes sense.  ok guenther@



few quick arcofi(4) tests needed

2016-09-19 Thread Alexandre Ratchov
I'm trying to switch the arcofi(4) driver to the "new" (as from
1998) audio interface, but I have no access to the hardware.

Anyone with a hp9000 with a working arcofi(4) device to run few
tests for me?  (to check if it works, just play a .wav file)

Thanks



Re: TCP timers & tasks

2016-09-19 Thread Alexander Bluhm
On Mon, Sep 12, 2016 at 01:54:34PM +0200, Martin Pieuchot wrote:
> I extended the G/C timeout to 1sec, because there's no reference count
> for 'struct tcpcb'.  And the only race possible is described in the
> comment below:
> 
>   /*
>* If one of the timer tasks is already running, it must
>* be spinning on the KERNEL_LOCK().  So schedule a G/C
>* in one second, when we known the task will have released
>* its reference.
>*/
> 
> Since the first thing task are doing is checking for the ``TF_DEAD''
> flag this should be enough.

So we rely on the assumption that grabbing the kernel lock will not
take longer than one second.  As reference counting would be much
more work, this seems fine for now.

> +void
> +tcp_destroytimers(struct tcpcb *tp)
> +{
> + int i;
> +
> + for (i = 0; i < TCPT_NTIMERS; i++)
> + TCP_TIMER_DESTROY(tp, i);
> +}

Why do you introduce a special tcp_destroytimers() and TCP_TIMER_DESTROY()
interface?

>  #define  TCP_TIMER_DISARM(tp, timer) 
> \
> - timeout_del(&(tp)->t_timer[(timer)])
> + timeout_del(&(tp)->t_timer[(timer)].tcpt_timeout)
>  
> +#define  TCP_TIMER_DESTROY(tp, timer)
> \
> + task_del(softnettq, &(tp)->t_timer[(timer)].tcpt_task)

Could you just move the task_del() to the TCP_TIMER_DISARM()?  Then
it would be totally opaque to the user wehter it is timeout or task.

bluhm



Re: syslogd validate client certificates

2016-09-19 Thread Alexander Bluhm
On Mon, Sep 05, 2016 at 03:25:22AM +0200, Alexander Bluhm wrote:
> Hi,
> 
> Add an option to give syslogd a server CA that is used to validate
> client certificates.  This prevent that malicious clients can send
> fake messages.
> 
> ok?

Could anyone have a look at the validation code.  I will create
nicer man page together with jmc@ afterwards.

bluhm

> 
> bluhm
> 
> Index: usr.sbin/syslogd/syslogd.8
> ===
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.8,v
> retrieving revision 1.42
> diff -u -p -r1.42 syslogd.8
> --- usr.sbin/syslogd/syslogd.812 Jul 2016 23:04:30 -  1.42
> +++ usr.sbin/syslogd/syslogd.85 Sep 2016 01:18:00 -
> @@ -44,6 +44,7 @@
>  .Op Fl C Ar CAfile
>  .Op Fl c Ar cert_file
>  .Op Fl f Ar config_file
> +.Op Fl K Ar server_CAfile
>  .Op Fl k Ar key_file
>  .Op Fl m Ar mark_interval
>  .Op Fl p Ar log_socket
> @@ -83,6 +84,11 @@ PEM encoded file containing CA certifica
>  validation;
>  the default is
>  .Pa /etc/ssl/cert.pem .
> +Validate remote server certificates and their hostnames with this
> +CA to prevent that malicious servers read messages.
> +This validation can be explicitly turned off using the
> +.Fl V
> +switch.
>  .It Fl c Ar cert_file
>  PEM encoded file containing the client certificate for TLS connections
>  to a remote host.
> @@ -102,6 +108,12 @@ the default is
>  .Pa /etc/syslog.conf .
>  .It Fl h
>  Include the hostname when forwarding messages to a remote host.
> +.It Fl K Ar server_CAfile
> +PEM encoded file containing CA certificates used for certificate
> +valitation on the local server socket.
> +By default incomming connections from any TLS server are allowed.
> +Enforce client certificates and validate them with this CA to prevent
> +that malicious clients send fake messages.
>  .It Fl k Ar key_file
>  PEM encoded file containing the client private key for TLS connections
>  to a remote host.
> @@ -170,7 +182,8 @@ accept input from the UDP port.
>  Some software wants this, but you can be subjected to a variety of
>  attacks over the network, including attackers remotely filling logs.
>  .It Fl V
> -Do not perform server certificate and hostname validation.
> +Do not perform remote server certificate and hostname validation
> +when sending messages.
>  .El
>  .Pp
>  .Nm
> Index: usr.sbin/syslogd/syslogd.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
> retrieving revision 1.212
> diff -u -p -r1.212 syslogd.c
> --- usr.sbin/syslogd/syslogd.c29 Aug 2016 20:31:56 -  1.212
> +++ usr.sbin/syslogd/syslogd.c5 Sep 2016 01:20:06 -
> @@ -225,8 +225,9 @@ structtls *server_ctx;
>  struct   tls_config *client_config, *server_config;
>  const char *CAfile = "/etc/ssl/cert.pem"; /* file containing CA certificates 
> */
>  int  NoVerify = 0;   /* do not verify TLS server x509 certificate */
> -char *ClientCertfile = NULL;
> -char *ClientKeyfile = NULL;
> +const char *ClientCertfile = NULL;
> +const char *ClientKeyfile = NULL;
> +const char *ServerCAfile = NULL;
>  int  tcpbuf_dropped = 0; /* count messages dropped from TCP or TLS */
>  
>  #define CTL_READING_CMD  1
> @@ -356,7 +357,7 @@ main(int argc, char *argv[])
>   int  ch, i;
>   int  lockpipe[2] = { -1, -1}, pair[2], nullfd, fd;
>  
> - while ((ch = getopt(argc, argv, "46a:C:c:dFf:hk:m:np:S:s:T:U:uV"))
> + while ((ch = getopt(argc, argv, "46a:C:c:dFf:hK:k:m:np:S:s:T:U:uV"))
>   != -1)
>   switch (ch) {
>   case '4':   /* disable IPv6 */
> @@ -388,6 +389,9 @@ main(int argc, char *argv[])
>   case 'h':   /* RFC 3164 hostnames */
>   IncludeHostname = 1;
>   break;
> + case 'K':   /* verify client with CA file */
> + ServerCAfile = optarg;
> + break;
>   case 'k':   /* file containing client key */
>   ClientKeyfile = optarg;
>   break;
> @@ -625,6 +629,17 @@ main(int argc, char *argv[])
>   break;
>   }
>  
> + if (ServerCAfile) {
> + if (tls_config_set_ca_file(server_config,
> + ServerCAfile) == -1) {
> + logerrortlsconf("Load server TLS CA failed",
> + server_config);
> + /* avoid reading default certs in chroot */
> + tls_config_set_ca_mem(server_config, "", 0);
> + } else
> + logdebug("Server CAfile %s\n", ServerCAfile);
> + tls_config_verify_client(server_config);
> + }
>   

Re: gmtime return value

2016-09-19 Thread Carlin Bingham
On Mon, Sep 19, 2016 at 06:48:32AM -0600, Todd C. Miller wrote:
> Committed, thanks.
> 
>  - todd
> 

Thanks. Is there any chance of this going into -stable?
This was found because it was causing test failures in Tor and tor devs
are worried that there might be some edge-cases where it can cause real
issues.


-- 
Carlin



Re: timeout_set_proc(9)

2016-09-19 Thread Mark Kettenis
> Date: Mon, 19 Sep 2016 13:47:25 +1000
> From: David Gwynne 
> 
> On Fri, Sep 16, 2016 at 04:58:39PM +0200, Mark Kettenis wrote:
> > > Date: Thu, 15 Sep 2016 16:29:45 +0200
> > > From: Martin Pieuchot 
> > > 
> > > After discussing with a few people about a new "timed task" API I came
> > > to the conclusion that mixing timeouts and tasks will result in:
> > > 
> > >   - always including a 'struct timeout' in a 'struct task', or the other
> > > the way around
> > > or
> > >   
> > >   - introducing a new data structure, hence API.
> > > 
> > > Since I'd like to keep the change as small as possible when converting
> > > existing timeout_set(9), neither option seem a good fit.  So I decided
> > > to add a new kernel thread, curiously named "softclock", that will
> > > offer his stack to the poor timeout handlers that need one. 
> > > 
> > > With this approach, converting a timeout is just a matter of doing:
> > > 
> > >   s/timeout_set/timeout_set_proc/
> > > 
> > > 
> > > Diff below includes the conversions I need for the "netlock".  I'm
> > > waiting for feedbacks and a better name to document the new function.
> > > 
> > > Comments?
> > 
> > I like how minimal this is.  Would like to see a few more people that
> > are familliar with the timeout code chime in, but it looks mostly
> > correct to me as well.  One question though:
> 
> id rather not grow the timeout (or task for that matter) apis just
> yet. theyre nice and straightforward to read and understand so far.
> 
> for this specific problem can we do a specific fix for it? the diff
> below is equiv to the timeout_set_proc change, but implements it
> by using explicit tasks that are called by the timeouts from a
> common trampoline in the network stack.

But this is much more involved tha mpi@'s change.

So unless somebody shoots a hole into his approach, I'd prefer the
timeout_set_proc() approach.

> Index: net/if.c
> ===
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.448
> diff -u -p -r1.448 if.c
> --- net/if.c  13 Sep 2016 08:15:01 -  1.448
> +++ net/if.c  19 Sep 2016 01:51:37 -
> @@ -155,6 +155,8 @@ void  if_watchdog_task(void *);
>  void if_input_process(void *);
>  void if_netisr(void *);
>  
> +void if_nettmo_add(void *);
> +
>  #ifdef DDB
>  void ifa_print_all(void);
>  #endif
> @@ -875,6 +877,21 @@ if_netisr(void *unused)
>  
>   splx(s);
>   KERNEL_UNLOCK();
> +}
> +
> +void
> +if_nettmo_add(void *t)
> +{
> + /* the task is added to systq so it inherits the KERNEL_LOCK */
> + task_add(systq, t);
> +}
> +
> +void
> +if_nettmo_set(struct timeout *tmo, struct task *task,
> +void (*fn)(void *), void *arg)
> +{
> + task_set(task, fn, arg);
> + timeout_set(tmo, if_nettmo_add, task);
>  }
>  
>  void
> Index: net/if_pflow.c
> ===
> RCS file: /cvs/src/sys/net/if_pflow.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 if_pflow.c
> --- net/if_pflow.c29 Apr 2016 08:55:03 -  1.61
> +++ net/if_pflow.c19 Sep 2016 01:51:37 -
> @@ -36,6 +36,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -547,16 +548,24 @@ pflow_init_timeouts(struct pflow_softc *
>   timeout_del(>sc_tmo6);
>   if (timeout_initialized(>sc_tmo_tmpl))
>   timeout_del(>sc_tmo_tmpl);
> - if (!timeout_initialized(>sc_tmo))
> - timeout_set(>sc_tmo, pflow_timeout, sc);
> + if (!timeout_initialized(>sc_tmo)) {
> + if_nettmo_set(>sc_tmo, >sc_task,
> + pflow_timeout, sc);
> + }
>   break;
>   case PFLOW_PROTO_10:
> - if (!timeout_initialized(>sc_tmo_tmpl))
> - timeout_set(>sc_tmo_tmpl, pflow_timeout_tmpl, sc);
> - if (!timeout_initialized(>sc_tmo))
> - timeout_set(>sc_tmo, pflow_timeout, sc);
> - if (!timeout_initialized(>sc_tmo6))
> - timeout_set(>sc_tmo6, pflow_timeout6, sc);
> + if (!timeout_initialized(>sc_tmo_tmpl)) {
> + if_nettmo_set(>sc_tmo_tmpl, >sc_task_tmpl,
> + pflow_timeout_tmpl, sc);
> + }
> + if (!timeout_initialized(>sc_tmo)) {
> + if_nettmo_set(>sc_tmo, >sc_task,
> + pflow_timeout, sc);
> + }
> + if (!timeout_initialized(>sc_tmo6)) {
> + if_nettmo_set(>sc_tmo6, >sc_task6,
> + pflow_timeout6, sc);
> + }
>  
>   timeout_add_sec(>sc_tmo_tmpl, PFLOW_TMPL_TIMEOUT);
>   break;
> Index: net/if_pflow.h
> ===
> RCS file: /cvs/src/sys/net/if_pflow.h,v

Re: timeout_set_proc(9)

2016-09-19 Thread Alexander Bluhm
On Thu, Sep 15, 2016 at 04:29:45PM +0200, Martin Pieuchot wrote:
> After discussing with a few people about a new "timed task" API I came
> to the conclusion that mixing timeouts and tasks will result in:
> 
>   - always including a 'struct timeout' in a 'struct task', or the other
> the way around
> or
>   
>   - introducing a new data structure, hence API.
> 
> Since I'd like to keep the change as small as possible when converting
> existing timeout_set(9), neither option seem a good fit.  So I decided
> to add a new kernel thread, curiously named "softclock", that will
> offer his stack to the poor timeout handlers that need one. 
> 
> With this approach, converting a timeout is just a matter of doing:
> 
>   s/timeout_set/timeout_set_proc/
> 
> 
> Diff below includes the conversions I need for the "netlock".  I'm
> waiting for feedbacks and a better name to document the new function.
> 
> Comments?

I like this API, epsecially as we can switch easily between thread
and soft interrupt to try things.

OK bluhm@

> 
> Index: net/if_pflow.c
> ===
> RCS file: /cvs/src/sys/net/if_pflow.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 if_pflow.c
> --- net/if_pflow.c29 Apr 2016 08:55:03 -  1.61
> +++ net/if_pflow.c15 Sep 2016 14:19:10 -
> @@ -548,15 +548,16 @@ pflow_init_timeouts(struct pflow_softc *
>   if (timeout_initialized(>sc_tmo_tmpl))
>   timeout_del(>sc_tmo_tmpl);
>   if (!timeout_initialized(>sc_tmo))
> - timeout_set(>sc_tmo, pflow_timeout, sc);
> + timeout_set_proc(>sc_tmo, pflow_timeout, sc);
>   break;
>   case PFLOW_PROTO_10:
>   if (!timeout_initialized(>sc_tmo_tmpl))
> - timeout_set(>sc_tmo_tmpl, pflow_timeout_tmpl, sc);
> + timeout_set_proc(>sc_tmo_tmpl, pflow_timeout_tmpl,
> + sc);
>   if (!timeout_initialized(>sc_tmo))
> - timeout_set(>sc_tmo, pflow_timeout, sc);
> + timeout_set_proc(>sc_tmo, pflow_timeout, sc);
>   if (!timeout_initialized(>sc_tmo6))
> - timeout_set(>sc_tmo6, pflow_timeout6, sc);
> + timeout_set_proc(>sc_tmo6, pflow_timeout6, sc);
>  
>   timeout_add_sec(>sc_tmo_tmpl, PFLOW_TMPL_TIMEOUT);
>   break;
> Index: net/if_pfsync.c
> ===
> RCS file: /cvs/src/sys/net/if_pfsync.c,v
> retrieving revision 1.231
> diff -u -p -r1.231 if_pfsync.c
> --- net/if_pfsync.c   15 Sep 2016 02:00:18 -  1.231
> +++ net/if_pfsync.c   15 Sep 2016 14:19:10 -
> @@ -328,9 +328,9 @@ pfsync_clone_create(struct if_clone *ifc
>   IFQ_SET_MAXLEN(>if_snd, IFQ_MAXLEN);
>   ifp->if_hdrlen = sizeof(struct pfsync_header);
>   ifp->if_mtu = ETHERMTU;
> - timeout_set(>sc_tmo, pfsync_timeout, sc);
> - timeout_set(>sc_bulk_tmo, pfsync_bulk_update, sc);
> - timeout_set(>sc_bulkfail_tmo, pfsync_bulk_fail, sc);
> + timeout_set_proc(>sc_tmo, pfsync_timeout, sc);
> + timeout_set_proc(>sc_bulk_tmo, pfsync_bulk_update, sc);
> + timeout_set_proc(>sc_bulkfail_tmo, pfsync_bulk_fail, sc);
>  
>   if_attach(ifp);
>   if_alloc_sadl(ifp);
> @@ -1723,7 +1723,7 @@ pfsync_defer(struct pf_state *st, struct
>   sc->sc_deferred++;
>   TAILQ_INSERT_TAIL(>sc_deferrals, pd, pd_entry);
>  
> - timeout_set(>pd_tmo, pfsync_defer_tmo, pd);
> + timeout_set_proc(>pd_tmo, pfsync_defer_tmo, pd);
>   timeout_add_msec(>pd_tmo, 20);
>  
>   schednetisr(NETISR_PFSYNC);
> Index: netinet/ip_carp.c
> ===
> RCS file: /cvs/src/sys/netinet/ip_carp.c,v
> retrieving revision 1.293
> diff -u -p -r1.293 ip_carp.c
> --- netinet/ip_carp.c 25 Jul 2016 16:44:04 -  1.293
> +++ netinet/ip_carp.c 15 Sep 2016 14:19:11 -
> @@ -831,9 +831,9 @@ carp_new_vhost(struct carp_softc *sc, in
>   vhe->vhid = vhid;
>   vhe->advskew = advskew;
>   vhe->state = INIT;
> - timeout_set(>ad_tmo, carp_send_ad, vhe);
> - timeout_set(>md_tmo, carp_master_down, vhe);
> - timeout_set(>md6_tmo, carp_master_down, vhe);
> + timeout_set_proc(>ad_tmo, carp_send_ad, vhe);
> + timeout_set_proc(>md_tmo, carp_master_down, vhe);
> + timeout_set_proc(>md6_tmo, carp_master_down, vhe);
>  
>   KERNEL_ASSERT_LOCKED(); /* touching carp_vhosts */
>  
> Index: netinet/tcp_timer.h
> ===
> RCS file: /cvs/src/sys/netinet/tcp_timer.h,v
> retrieving revision 1.13
> diff -u -p -r1.13 tcp_timer.h
> --- netinet/tcp_timer.h   6 Jul 2011 23:44:20 -   1.13
> +++ netinet/tcp_timer.h   15 Sep 2016 14:19:11 -
> @@ -116,7 +116,7 @@ const char *tcptimers[] =
>   * Init, arm, disarm, and test TCP 

Re: We don't need cross-unwinding support

2016-09-19 Thread Mark Kettenis
> Date: Mon, 19 Sep 2016 16:08:33 +0200 (CEST)
> From: Mark Kettenis 
> 
> > Date: Mon, 19 Sep 2016 14:08:49 +0200 (CEST)
> > From: Mark Kettenis 
> > 
> > Saves a bit code and a bit of stack space, which might be important
> > important in some unwinding scenarios.
> > 
> > ok?
> 
> Transplanted the diff into the wrong file.  Here is the correct one.

Ugh, not my day.

Index: lib/libcxxabi/Makefile
===
RCS file: /cvs/src/lib/libcxxabi/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- lib/libcxxabi/Makefile  19 Sep 2016 11:23:16 -  1.2
+++ lib/libcxxabi/Makefile  19 Sep 2016 14:07:28 -
@@ -39,6 +39,7 @@ SRCS+=abort_message.cpp\
libunwind.cpp
 
 CPPFLAGS+= -I${SHDRDIR} -I${HDRDIR} -I${UHDRDIR}
+CPPFLAGS+= -D_LIBUNWIND_IS_NATIVE_ONLY
 CXXFLAGS+= -nostdlib -nostdinc++ -funwind-tables
 .if empty(CXXFLAGS:M-std=*)
 CXXFLAGS+= -std=c++11



Re: We don't need cross-unwinding support

2016-09-19 Thread Mark Kettenis
> Date: Mon, 19 Sep 2016 14:08:49 +0200 (CEST)
> From: Mark Kettenis 
> 
> Saves a bit code and a bit of stack space, which might be important
> important in some unwinding scenarios.
> 
> ok?

Transplanted the diff into the wrong file.  Here is the correct one.

Index: Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile19 Sep 2016 11:22:39 -  1.2
+++ Makefile19 Sep 2016 12:04:52 -
@@ -40,7 +40,8 @@ SRCS+=algorithm.cpp\
valarray.cpp
 
 CPPFLAGS+= -DLIBCXXABI -I${HDRDIR} \
-   -DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR}
+   -DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR} \
+   -D_LIBUNWIND_IS_NATIVE_ONLY
 CXXFLAGS+= -nostdlib -nostdinc++
 .if empty(CXXFLAGS:M-std=*)
 CXXFLAGS+= -std=c++11



Re: gmtime return value

2016-09-19 Thread Todd C. Miller
Committed, thanks.

 - todd



We don't need cross-unwinding support

2016-09-19 Thread Mark Kettenis
Saves a bit code and a bit of stack space, which might be important
important in some unwinding scenarios.

ok?


Index: Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile19 Sep 2016 11:22:39 -  1.2
+++ Makefile19 Sep 2016 12:04:52 -
@@ -40,7 +40,8 @@ SRCS+=algorithm.cpp\
valarray.cpp
 
 CPPFLAGS+= -DLIBCXXABI -I${HDRDIR} \
-   -DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR}
+   -DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR} \
+   -D_LIBUNWIND_IS_NATIVE_ONLY
 CXXFLAGS+= -nostdlib -nostdinc++
 .if empty(CXXFLAGS:M-std=*)
 CXXFLAGS+= -std=c++11



Re: Division by zero in ehci(4)

2016-09-19 Thread Jonathan Gray
On Mon, Sep 19, 2016 at 11:47:40AM +0200, Martin Pieuchot wrote:
> On 19/09/16(Mon) 14:20, Jonathan Gray wrote:
> > On Sat, Sep 17, 2016 at 04:36:12PM +0200, Martin Pieuchot wrote:
> > > One of the non-checked value read from an untrusted descriptor is the
> > > "maximum packet size" of an endpoint.  If a device reports an incorrect
> > > value most of our HC drivers wont work and if this value is 0 ehci(4)
> > > will crash the kernel.
> > > 
> > > So here's a diff to validate the value read from the device descriptor
> > > which ends up being the value of the default endpoint.
> > > 
> > > ok?
> > 
> > This patch made vmware hang when attaching xhci uhubs.
> > 
> > usbd_new_device bus=0x801e4000 port=0 depth=0 speed=4
> > usbd_new_device: adding unit addr=1, rev=300, class=9, subclass=0, 
> > protocol=1, maxpacket=9, len=18, speed=4
> > usb2: root hub problem
> > 
> > usbd_new_device mps 9 mps0 512
> > 
> > It would appear that for superspeed devices maxpacketsize0 is a power
> > of 2?  ie 2^9 is 512.
> 
> You're correct, here's a fix.

Thanks, this patch works with the same setup.  ok jsg@

I think the

-   (mps != 8 || mps != 16 || mps != 32 || mps != 64)) {
+   (mps != 8 && mps != 16 && mps != 32 && mps != 64)) 

part of the one I sent sound go in as well?

> 
> Index: usb_subr.c
> ===
> RCS file: /cvs/src/sys/dev/usb/usb_subr.c,v
> retrieving revision 1.129
> diff -u -p -r1.129 usb_subr.c
> --- usb_subr.c18 Sep 2016 09:51:24 -  1.129
> +++ usb_subr.c19 Sep 2016 09:42:58 -
> @@ -1175,8 +1175,12 @@ usbd_new_device(struct device *parent, s
>   }
>  
>   mps = dd->bMaxPacketSize;
> - if (speed == USB_SPEED_SUPER && mps == 0xff)
> - mps = 512;
> + if (speed == USB_SPEED_SUPER) {
> + if (mps == 0xff)
> + mps = 9;
> + /* xHCI Section 4.8.2.1 */
> + mps = (1 << mps);
> + }
>  
>   if (mps != mps0) {
>   if ((speed == USB_SPEED_LOW) ||
> 



Add support for a few more arm relocations

2016-09-19 Thread Mark Kettenis
>From FreeBSD, still under GPLv2.  I've seen R_ARM_MOVW_ABS_NC in code
generated by clang.

ok?


Index: gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h,v
retrieving revision 1.6
diff -u -p -r1.6 bfd-in2.h
--- gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h 31 May 2016 17:05:03 -  
1.6
+++ gnu/usr.bin/binutils-2.17/bfd/bfd-in2.h 19 Sep 2016 09:17:38 -
@@ -2907,6 +2907,12 @@ pc-relative or some form of GOT-indirect
 /* 31-bit PC relative address.  */
   BFD_RELOC_ARM_PREL31,
 
+/* Low and High halfword relocations for MOVW and MOVT instructions.  */
+  BFD_RELOC_ARM_MOVW,
+  BFD_RELOC_ARM_MOVT,
+  BFD_RELOC_ARM_MOVW_PCREL,
+  BFD_RELOC_ARM_MOVT_PCREL,
+
 /* Relocations for setting up GOTs and PLTs for shared libraries.  */
   BFD_RELOC_ARM_JUMP_SLOT,
   BFD_RELOC_ARM_GLOB_DAT,
Index: gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c,v
retrieving revision 1.2
diff -u -p -r1.2 elf32-arm.c
--- gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c   26 Jun 2015 04:28:53 -  
1.2
+++ gnu/usr.bin/binutils-2.17/bfd/elf32-arm.c   19 Sep 2016 09:17:38 -
@@ -1366,6 +1366,10 @@ static const struct elf32_arm_reloc_map 
 {BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32},
 {BFD_RELOC_VTABLE_INHERIT,  R_ARM_GNU_VTINHERIT},
 {BFD_RELOC_VTABLE_ENTRY,R_ARM_GNU_VTENTRY},
+{BFD_RELOC_ARM_MOVW,R_ARM_MOVW_ABS_NC},
+{BFD_RELOC_ARM_MOVT,R_ARM_MOVT_ABS},
+{BFD_RELOC_ARM_MOVW_PCREL,  R_ARM_MOVW_PREL_NC},
+{BFD_RELOC_ARM_MOVT_PCREL,  R_ARM_MOVT_PREL},
   };
 
 static reloc_howto_type *
@@ -4080,6 +4084,49 @@ elf32_arm_final_link_relocate (reloc_how
 }
   return bfd_reloc_ok;
 
+case R_ARM_MOVW_ABS_NC:
+case R_ARM_MOVT_ABS:
+case R_ARM_MOVW_PREL_NC:
+case R_ARM_MOVT_PREL:
+/* Until we properly support segment-base-relative addressing then
+   we assume the segment base to be zero, as for the group relocations.
+   Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC
+   and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS.  */
+case R_ARM_MOVW_BREL_NC:
+case R_ARM_MOVW_BREL:
+case R_ARM_MOVT_BREL:
+  {
+   bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
+
+   if (globals->use_rel)
+ {
+   addend = ((insn >> 4) & 0xf000) | (insn & 0xfff);
+   signed_addend = (addend ^ 0x8000) - 0x8000;
+ }
+
+   value += signed_addend;
+
+   if (r_type == R_ARM_MOVW_PREL_NC || r_type == R_ARM_MOVT_PREL)
+ value -= (input_section->output_section->vma
+   + input_section->output_offset + rel->r_offset);
+
+   if (r_type == R_ARM_MOVW_BREL && value >= 0x1)
+  return bfd_reloc_overflow;
+
+   if (sym_flags == STT_ARM_TFUNC)
+ value |= 1;
+
+   if (r_type == R_ARM_MOVT_ABS || r_type == R_ARM_MOVT_PREL
+|| r_type == R_ARM_MOVT_BREL)
+ value >>= 16;
+
+   insn &= 0xfff0f000;
+   insn |= value & 0xfff;
+   insn |= (value & 0xf000) << 4;
+   bfd_put_32 (input_bfd, insn, hit_data);
+  }
+  return bfd_reloc_ok;
+
 default:
   return bfd_reloc_notsupported;
 }
@@ -5651,6 +5698,10 @@ elf32_arm_gc_sweep_hook (bfd *  
case R_ARM_JUMP24:
case R_ARM_PREL31:
case R_ARM_THM_CALL:
+   case R_ARM_MOVW_ABS_NC:
+   case R_ARM_MOVT_ABS:
+   case R_ARM_MOVW_PREL_NC:
+   case R_ARM_MOVT_PREL:
  /* Should the interworking branches be here also?  */
 
  if (h != NULL)
@@ -5861,6 +5912,10 @@ elf32_arm_check_relocs (bfd *abfd, struc
  case R_ARM_JUMP24:
  case R_ARM_PREL31:
  case R_ARM_THM_CALL:
+ case R_ARM_MOVW_ABS_NC:
+ case R_ARM_MOVT_ABS:
+ case R_ARM_MOVW_PREL_NC:
+ case R_ARM_MOVT_PREL:
/* Should the interworking branches be listed here?  */
if (h != NULL)
  {
Index: gnu/usr.bin/binutils-2.17/bfd/libbfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/libbfd.h,v
retrieving revision 1.5
diff -u -p -r1.5 libbfd.h
--- gnu/usr.bin/binutils-2.17/bfd/libbfd.h  31 May 2016 17:05:03 -  
1.5
+++ gnu/usr.bin/binutils-2.17/bfd/libbfd.h  19 Sep 2016 09:17:38 -
@@ -1209,6 +1209,10 @@ static const char *const bfd_reloc_code_
   "BFD_RELOC_ARM_SBREL32",
   "BFD_RELOC_ARM_TARGET2",
   "BFD_RELOC_ARM_PREL31",
+  "BFD_RELOC_ARM_MOVW",
+  "BFD_RELOC_ARM_MOVT",
+  "BFD_RELOC_ARM_MOVW_PCREL",
+  "BFD_RELOC_ARM_MOVT_PCREL",
   "BFD_RELOC_ARM_JUMP_SLOT",
   "BFD_RELOC_ARM_GLOB_DAT",
   "BFD_RELOC_ARM_GOT32",
Index: gnu/usr.bin/binutils-2.17/bfd/reloc.c

arm libcompiler_rt

2016-09-19 Thread Mark Kettenis
Diff below adds the relevant arm-specific code to the build.  It
leaves out the VFP bits.  Those don't compile with our current
toolchain (gcc/binutils) and I believe they're only necessary for the
hard-float ABI anyway.

ok?


Index: Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- Makefile5 Sep 2016 11:38:16 -   1.1
+++ Makefile19 Sep 2016 08:28:57 -
@@ -164,6 +164,53 @@ SRCS+= ${file}.c
 .  endif
 .endfor
 
+.if ${RTARCH} == "arm"
+SRCS+= aeabi_cdcmp.S \
+   aeabi_cdcmpeq_check_nan.c \
+   aeabi_cfcmp.S \
+   aeabi_cfcmpeq_check_nan.c \
+   aeabi_dcmp.S \
+   aeabi_div0.c \
+   aeabi_drsub.c \
+   aeabi_fcmp.S \
+   aeabi_frsub.c \
+   aeabi_idivmod.S \
+   aeabi_ldivmod.S \
+   aeabi_memcmp.S \
+   aeabi_memcpy.S \
+   aeabi_memmove.S \
+   aeabi_memset.S \
+   aeabi_uidivmod.S \
+   aeabi_uldivmod.S \
+   bswapdi2.S \
+   bswapsi2.S \
+   switch16.S \
+   switch32.S \
+   switch8.S \
+   switchu8.S \
+   sync_fetch_and_add_4.S \
+   sync_fetch_and_add_8.S \
+   sync_fetch_and_and_4.S \
+   sync_fetch_and_and_8.S \
+   sync_fetch_and_max_4.S \
+   sync_fetch_and_max_8.S \
+   sync_fetch_and_min_4.S \
+   sync_fetch_and_min_8.S \
+   sync_fetch_and_nand_4.S \
+   sync_fetch_and_nand_8.S \
+   sync_fetch_and_or_4.S \
+   sync_fetch_and_or_8.S \
+   sync_fetch_and_sub_4.S \
+   sync_fetch_and_sub_8.S \
+   sync_fetch_and_umax_4.S \
+   sync_fetch_and_umax_8.S \
+   sync_fetch_and_umin_4.S \
+   sync_fetch_and_umin_8.S \
+   sync_fetch_and_xor_4.S \
+   sync_fetch_and_xor_8.S \
+   sync_synchronize.S
+.endif
+
 .if ${RTARCH} == "ppc"
 SRCS+= divtc3.c \
fixtfdi.c \



Re: timeout_set_proc(9)

2016-09-19 Thread Martin Pieuchot
On 19/09/16(Mon) 13:47, David Gwynne wrote:
> [...] 
> id rather not grow the timeout (or task for that matter) apis just
> yet. theyre nice and straightforward to read and understand so far.

So better introduce a new API, right?

> for this specific problem can we do a specific fix for it? the diff
> below is equiv to the timeout_set_proc change, but implements it
> by using explicit tasks that are called by the timeouts from a
> common trampoline in the network stack.

Is it really a specific problem?  We already encounter this for the
linkstate and the watchdog. 

I'm not convinced by this approach.  I don't understand why:
  - adding a task in every data structure is worth it
  - introducing a new if_nettmo_* make things simpler

So there's something which isn't explain in this email.

And I'll bet that in the upcoming years we're going to stop using soft
interrupts.  Meaning that timeout handlers will always have a stack 
available.  If/when this happens, it will be easier to do:

s/timeout_set_proc/timeout_set/

> Index: net/if.c
> ===
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.448
> diff -u -p -r1.448 if.c
> --- net/if.c  13 Sep 2016 08:15:01 -  1.448
> +++ net/if.c  19 Sep 2016 01:51:37 -
> @@ -155,6 +155,8 @@ void  if_watchdog_task(void *);
>  void if_input_process(void *);
>  void if_netisr(void *);
>  
> +void if_nettmo_add(void *);
> +
>  #ifdef DDB
>  void ifa_print_all(void);
>  #endif
> @@ -875,6 +877,21 @@ if_netisr(void *unused)
>  
>   splx(s);
>   KERNEL_UNLOCK();
> +}
> +
> +void
> +if_nettmo_add(void *t)
> +{
> + /* the task is added to systq so it inherits the KERNEL_LOCK */
> + task_add(systq, t);
> +}
> +
> +void
> +if_nettmo_set(struct timeout *tmo, struct task *task,
> +void (*fn)(void *), void *arg)
> +{
> + task_set(task, fn, arg);
> + timeout_set(tmo, if_nettmo_add, task);
>  }
>  
>  void
> Index: net/if_pflow.c
> ===
> RCS file: /cvs/src/sys/net/if_pflow.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 if_pflow.c
> --- net/if_pflow.c29 Apr 2016 08:55:03 -  1.61
> +++ net/if_pflow.c19 Sep 2016 01:51:37 -
> @@ -36,6 +36,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -547,16 +548,24 @@ pflow_init_timeouts(struct pflow_softc *
>   timeout_del(>sc_tmo6);
>   if (timeout_initialized(>sc_tmo_tmpl))
>   timeout_del(>sc_tmo_tmpl);
> - if (!timeout_initialized(>sc_tmo))
> - timeout_set(>sc_tmo, pflow_timeout, sc);
> + if (!timeout_initialized(>sc_tmo)) {
> + if_nettmo_set(>sc_tmo, >sc_task,
> + pflow_timeout, sc);
> + }
>   break;
>   case PFLOW_PROTO_10:
> - if (!timeout_initialized(>sc_tmo_tmpl))
> - timeout_set(>sc_tmo_tmpl, pflow_timeout_tmpl, sc);
> - if (!timeout_initialized(>sc_tmo))
> - timeout_set(>sc_tmo, pflow_timeout, sc);
> - if (!timeout_initialized(>sc_tmo6))
> - timeout_set(>sc_tmo6, pflow_timeout6, sc);
> + if (!timeout_initialized(>sc_tmo_tmpl)) {
> + if_nettmo_set(>sc_tmo_tmpl, >sc_task_tmpl,
> + pflow_timeout_tmpl, sc);
> + }
> + if (!timeout_initialized(>sc_tmo)) {
> + if_nettmo_set(>sc_tmo, >sc_task,
> + pflow_timeout, sc);
> + }
> + if (!timeout_initialized(>sc_tmo6)) {
> + if_nettmo_set(>sc_tmo6, >sc_task6,
> + pflow_timeout6, sc);
> + }
>  
>   timeout_add_sec(>sc_tmo_tmpl, PFLOW_TMPL_TIMEOUT);
>   break;
> Index: net/if_pflow.h
> ===
> RCS file: /cvs/src/sys/net/if_pflow.h,v
> retrieving revision 1.14
> diff -u -p -r1.14 if_pflow.h
> --- net/if_pflow.h3 Oct 2015 10:44:23 -   1.14
> +++ net/if_pflow.h19 Sep 2016 01:51:37 -
> @@ -182,8 +182,11 @@ struct pflow_softc {
>   u_int64_tsc_gcounter;
>   u_int32_tsc_sequence;
>   struct timeout   sc_tmo;
> - struct timeout   sc_tmo6;
> + struct task  sc_task;
>   struct timeout   sc_tmo_tmpl;
> + struct task  sc_task_tmpl;
> + struct timeout   sc_tmo6;
> + struct task  sc_task6;
>   struct socket   *so;
>   struct mbuf *send_nam;
>   struct sockaddr *sc_flowsrc;
> Index: net/if_pfsync.c
> ===
> RCS file: /cvs/src/sys/net/if_pfsync.c,v
> retrieving