Re: CVS commit: src/sys/dev/pci

2021-01-23 Thread Taylor R Campbell
> Date: Sat, 23 Jan 2021 22:59:22 - (UTC)
> From: chris...@astron.com (Christos Zoulas)
> 
> In article <23974.1611441...@splode.eterna.com.au>,
> matthew green   wrote:
> >this seems dangerous to me.  we don't define it on
> >some platforms because we can't, so having it faked
> >out here seems like someone later will be confused
> >and the wrong thing will happen.
> >
> >i would rather have something like
> >
> >virtio_write8(...)
> >{
> >#ifdef __HAVE_BUS_SPACE_8
> > just use the real thing
> >#else
> > use the dual-_4 version that is ok _for this device_
> >#endif
> >}
> >
> >and then use this wrapper in the rest of the code.
> 
> This implementation is internal to virtio_pci and is guaranteed to work
> by the spec, how will someone else us it?

Conversely, how do you know whether this hacked-up implementation
which tears the write into two will actually work?  Maybe it works for
virtio but there are likely other devices out there for which it will
fail or have weird side effects if the architecture doesn't have
native 8-byte bus I/O.


Re: CVS commit: src/share/man/man5

2021-01-15 Thread Taylor R Campbell
> Date: Sat, 16 Jan 2021 14:46:46 +1100
> from: matthew green 
> 
> > Log Message:
> > Tweak wording for consistency: `if empty or not set', not `if unset'.
> 
> is this correct?
> 
> rc complains if unset or not set (ie, if "$foo" is zero length):
> 
> /etc/rc.d/upsdriver: WARNING: $upsdriver is not set properly - see rc.conf(5).

The allowed settings are:

entropy=check
entropy=wait
entropy=""

Note that `entropy' is not an `rcvar' the way upsdriver is (if your
/etc/rc.d/upsdriver is pkgsrc/sysutils/ups-nut/files/upsdriver.sh).
Compare, e.g., `domainname' or `hostname' in rc.conf(5).


Re: CVS commit: src

2020-11-12 Thread Taylor R Campbell
> Date: Thu, 12 Nov 2020 11:21:43 -0800
> From: Jason Thorpe 
> 
> > On Nov 12, 2020, at 9:40 AM, nia  wrote:
> > 
> > For the record I'm just trying to fix things so that running
> > third-party software on NetBSD sucks less. If fewer third-party
> > libraries were exposed by the base system this wouldn't be
> > necessary.
> 
> Why do we even have sqlite in the base system in the first place?

apropos(1); a handful of other things also use it (heimdal, postfix).

I suggested that we leave the bells & whistles out of base sqlite3,
maybe even stop installing the .so symlink, and teach pkgsrc to just
use pkgsrc sqlite3 (with all bells & whistles included) rather than
base sqlite3 -- after all, sqlite3 is meant to be embedded and has
lots of optional bells & whistles that apropos(1) has no need of, so
it is silly to impose those costs on apropos(1) or make sqlite3 part
of the NetBSD API.

But there's a snag with heimdal.

Heimdal exposes the sqlite3 library to clients via libgssapi.so which
links against libkrb5.so which brings in libsqlite3.so.  So we get nice
situations like this:

% ldd /pkg/2020Q2/bin/svn | grep sqlite   
-lsqlite3.0 => /pkg/2020Q2/lib/libsqlite3.so.0
-lsqlite3.1 => /usr/lib/libsqlite3.so.1

This is also why the change to base sqlite3 affected, e.g., su(1).

I have no idea what heimdal does with sqlite3, but it puts us in a
pretty pickle: we can't reliably use pkgsrc sqlite3 on existing NetBSD
installs for packages that use gssapi, and we can't rely on sqlite3 in
existing NetBSD installs for packages that need newer/threaded/jsonned
sqlite3 as we often encounter.


Re: CVS commit: src

2020-11-10 Thread Taylor R Campbell
> Module Name:src
> Committed By:   nia
> Date:   Sun Nov  8 21:56:48 UTC 2020
> 
> Modified Files:
> src/external/bsd/kyua-cli: Makefile.inc
> src/external/ibm-public/postfix: Makefile.inc
> src/external/public-domain/sqlite: Makefile.inc
> src/external/public-domain/sqlite/bin: Makefile
> src/external/public-domain/sqlite/lib: Makefile sqlite3.pc.in
> src/usr.sbin/makemandb: Makefile
> 
> Log Message:
> sqlite: do not build without multithreading support
> 
> at least a few pkgsrc packages avoid base sqlite because it fails
> this check, and it's probably a surprising performance penalty for
> unsuspecting users

Why do we even expose NetBSD's libsqlite3.so to pkgsrc?  Why not just
have pkgsrc always use pkgsrc sqlite3, and change base to go back to
the smaller non-threaded sqlite3 with only the options the things in
base actually need?

Also: What is the performance penalty?  The sqlite3 documentation
(https://www.sqlite.org/faq.html#q6) suggests that _enabling_
SQLITE_THREADSAFE has a performance penalty, not the other way around.

It seems to me we've had a lot of problems over the years trying to
use base sqlite3 for everything in pkgsrc.  It's not clear to me that
any of the recent changes are helpful for the three things in base
that need sqlite3, and it's also not clear that they will help with
running newer pkgsrc on older NetBSD.


Re: CVS commit: src

2020-09-22 Thread Taylor R Campbell
> Date: Wed, 23 Sep 2020 01:46:14 +0200
> From: Tobias Nygren 
> 
> > Modified Files:
> > src/include: unistd.h
> > src/lib/libc/gen: Makefile.inc
> > Removed Files:
> > src/lib/libc/gen: getentropy.3 getentropy.c
> > 
> > Log Message:
> > remove getentropy bits
> 
> I know it is -current but undiscussed ABI breakage in libc still does
> make me raise an eyebrow. A heads-up including a summary of the reason
> for the change would have been nice.

This change does not break any ABI because getentropy.c was not
included in the build.  All that is being removed here is the man page
and the unused source code.


Re: CVS commit: src

2020-09-10 Thread Taylor R Campbell
> Module Name:src
> Committed By:   maxv
> Date:   Sat Sep  5 07:22:26 UTC 2020
> 
> nvmm: update copyright headers
> 
> [...]
> -.\" Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
> +.\" Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
>  .\" All rights reserved.
>  .\"
> -.\" This code is derived from software contributed to The NetBSD Foundation
> -.\" by Maxime Villard.
> +.\" This code is part of the NVMM hypervisor.

Please restore the NetBSD Foundation copyright notice.

You can add your own copyright notice in addition to it, for copyright
covering subsequent changes to the file, or on new files.  But you
already committed this code to the tree years ago, and it's gone out
in a NetBSD release with the NetBSD Foundation copyright notice.

If you want TNF to reassign the copyright back to you, please contact
board to discuss it rather than just quietly changing the existing
copyright notice on the file in the tree.


Re: CVS commit: src

2020-08-15 Thread Taylor R Campbell
> Date: Sat, 15 Aug 2020 10:23:02 +
> From: nia 
> 
> Obviously, I disagree with core's decision, but let's try to be
> productive about this.
> 
> I'm happy to have getrandom in NetBSD, it's a good thing. But not with
> this behaviour.
> 
> 1) Adopting getrandom for compatibility does not make sense.
> 
>NetBSD's behaviour for getrandom(x, y, 0) is incompatible with Linux
>and FreeBSD _at least_ - they will unblock after the kernel receives
>an arbitrary amount of "random-ish" data. NetBSD will block forever
>until the sysadmin intervenes (by writing to /dev/random or attaching
>a forensically analyzed HWRNG, or rebooting with a seed file).

- The behaviour is compatible in the sense that the getrandom calls
  that _can_ lead to blocking are the same: a getrandom call that may
  block on NetBSD may also block on Linux/FreeBSD/ a getrandom
  call that is guaranteed never to block on Linux/FreeBSD/ is
  guaranteed never to block on NetBSD.

- The behaviour is compatible in the sense that if getrandom blocks,
  then it unblocks when the operating system has decided there is
  adequate entropy.

- The behaviour is incompatible only in the sense that NetBSD's idea
  of `adequate entropy' is stronger than FreeBSD's or Linux's, so
  blocking is _more likely_ on NetBSD than on FreeBSD or Linux.

The difference manifests in a user-visible way primarily only on
systems where users are actually in danger of not having adequate
entropy -- in other words, on systems where the signal of an alarm
might actually amtter.  I would like to put effort toward addressing
that by making it easier to provide adequate entropy rather than by
papering over the alarm.

>NetBSD's behaviour for GRND_RANDOM is incompatible with FreeBSD,
>which treats it the same as getrandom(x, y, 0).

Why do you say this is incompatible?  getrandom(...,GRND_RANDOM) just
makes fewer promises than getrandom(...,0) as a portable API -- it
_may_ block more often and it _may_ return short.  In practice, on
NetBSD it only blocks when getrandom(...,0) would block too.

If FreeBSD makes _more_ promises, fine, but the GRND_RANDOM flag a
silly API that exists only for Linux source compatibility that very
few reasonable applications use.  So I don't see why it's important to
put any attention on it or make any stronger promises about it than
portable applications can rely on -- that's why, e.g., the man page I
wrote specifically calls it out as silly, not recommended, for Linux
source compatibility only, and with no usage examples.

> 2) The main problem raised with getentropy is that Solaris has a buggy
>implementation that projects such as Python were seeking to avoid
>(because it blocked a lot, and they preferred something that
>wouldn't).

The main problem raised with getentropy is that between four different
operating systems (OpenBSD, Linux, FreeBSD, Solaris) there seemed to
be three different behaviours around blocking (block never, block at
boot, block often).  That's not good for a portable API, particularly
one which was originally defined never to block, period.

I'm not saying I disagree with adopting getentropy.  I'm just saying
that _as a portable API_ its semantics is murkier than getrandom's,
despite the additional complexity of flags in getrandom.

Indeed, I made an argument, based on a survey of how entropy pool
initialization and unblocking works across different operating
systems, for adopting getentropy(p,n) == getrandom(p,n,GRND_INSECURE)
as you're suggesting:

https://mail-index.netbsd.org/tech-userlevel/2020/05/09/msg012390.html

But there are reasonable counterarguments too, as gson raised:

https://mail-index.netbsd.org/tech-userlevel/2020/05/10/msg012397.html

So my somewhat elaborate argument isn't strong enough for me to want
to push for it one way or another.  Sure would be nice if every
computer just had a reliable HWRNG!  But alas.

> 4) The original argument that we need the getrandom(x, y, 0) behaviour
>to please Rust does not make sense, since Rust's randomness library
>now uses never-blocking APIs on both OpenBSD and NetBSD. Same for
>OpenSSL.

The Rust API specifically describes getrandom(p,n,0) semantics:

https://docs.rs/rand/0.7.3/rand/rngs/struct.OsRng.html

  `It is possible that when used during early boot the first call to
   OsRng will block until the system's RNG is initialised. It is also
   possible (though highly unlikely) for OsRng to fail on some
   platforms, most likely due to system mis-configuration.

  `After the first successful call, it is highly unlikely that
   failures or significant delays will occur (although performance
   should be expected to be much slower than a user-space PRNG).'

Obviously we can patch OpenSSL in base however we like, but at least
one OpenSSL developer reported being uncomfortable with having
getrandom(p,n,GNRD_INSECURE) semantics for getentropy if used
upstream:


Re: CVS commit: src/sys/kern

2020-08-02 Thread Taylor R Campbell
> Date: Sun, 2 Aug 2020 17:35:06 +0200
> From: Kamil Rytarowski 
> 
> On 02.08.2020 16:44, Taylor R Campbell wrote:
> >> Date: Sun, 2 Aug 2020 16:04:15 +0200
> >> From: Kamil Rytarowski 
> >>
> >> On 02.08.2020 15:57, Taylor R Campbell wrote:
> >>> But it sounds like the original motivation is that it triggered
> >>> -Wvla...which frankly strikes me as a compiler bug since there's
> >>> obviously no actual VLA created in sizeof; as far as I can tell
> >>> there's no semantic difference between sizeof(device_t[n]) and
> >>> sizeof(device_t) * n.
> >>
> >> This is not true:
> > 
> > Which part of what I said are you claiming is not true, and what are
> > you illustrating with the example program below?
> 
> Calling it a compiler bug.
> 
> Clang behaves the same way.
> 
> $ clang -Wvla test.c
> test.c:6:37: warning: variable length array used [-Wvla]
> printf("sizeof = %zu\n", sizeof(int[argc]));
>^
> 1 warning generated.
> 
> Creating VLA is not needed for using it as an intermediate. In practice
> in most/all cases it is optimized and actual VLA is not allocated.

This is not a matter of optimization in practice.  It's absolutely not
an `intermediate' at all -- there is no VLA created, period, any more
than sizeof(malloc(1)) causes any actual call to malloc or sizeof(*p)
causes any dereference of a pointer.

This makes -Wvla less useful as a tool, because apparently it flags
code that unquestionably does not have any bad effects of VLAs.  This
happens because -Wvla is dumb -- it just looks for the syntax, not for
the semantics of creating VLAs.  That's why I call it a bug -- it
raises a false positive that makes it less useful.


Re: CVS commit: src/sys/kern

2020-08-02 Thread Taylor R Campbell
> Date: Sun, 2 Aug 2020 16:04:15 +0200
> From: Kamil Rytarowski 
> 
> On 02.08.2020 15:57, Taylor R Campbell wrote:
> > But it sounds like the original motivation is that it triggered
> > -Wvla...which frankly strikes me as a compiler bug since there's
> > obviously no actual VLA created in sizeof; as far as I can tell
> > there's no semantic difference between sizeof(device_t[n]) and
> > sizeof(device_t) * n.
> 
> This is not true:

Which part of what I said are you claiming is not true, and what are
you illustrating with the example program below?

It seems to illustrate that sizeof(int[argc]) does exactly what one
would expect it to do -- return the size of an argc-length array of
ints, just like sizeof(int) * argc does.



> #include 
> 
> int
> main(int argc, char **argv)
> {
> printf("sizeof = %zu\n", sizeof(int[argc]));
> return 0;
> }
> 
> $ ./a.out
> 
> sizeof = 4
> $ ./a.out 12 3
> sizeof = 12
> $ ./a.out 12 3 45 6
> sizeof = 20


Re: CVS commit: src/sys/kern

2020-08-02 Thread Taylor R Campbell
> Date: Sun, 2 Aug 2020 10:47:21 +0200
> From: Jarom�r Dole ek 
> 
> Readability first and foremost in this case.
> 
> I was exploring if I can disable VLAs for the kernel altogether, this
> can't be done for now. Nevertheless, this change looked like it would
> be useful to make anyway.

Why does it improve readability?  Surely if we want the size of an
array of device_t of length n it's more to the point to say
sizeof(device_t[n]) directly than to talk about multiplying
sizeof(device_t) by n.  If that were the only question I think the
change makes readability worse, personally!

But it sounds like the original motivation is that it triggered
-Wvla...which frankly strikes me as a compiler bug since there's
obviously no actual VLA created in sizeof; as far as I can tell
there's no semantic difference between sizeof(device_t[n]) and
sizeof(device_t) * n.

What else does -Wvla choke on in src/sys?


Re: CVS commit: src/sys/arch/x86

2020-08-01 Thread Taylor R Campbell
> Module Name:src
> Committed By:   jdolecek
> Date:   Sat Aug  1 12:36:36 UTC 2020
> 
> Modified Files:
> src/sys/arch/x86/pci: pci_intr_machdep.c
> src/sys/arch/x86/x86: mainbus.c
> 
> Log Message:
> reorder includes to pull __HAVE_PCI_MSI_MSIX properly via
> 

If  requires a file to be included
("opt_pci.h"?) in order for its definition of __HAVE_PCI_MSI_MSIX to
work, why doesn't  include that file
directly?

Or, if I didn't follow exactly what's going on here, why is it
necessary to reorder the includes?

I think we should generally treat it as a bug if including two header
files in different orders gives different outcomes, and fix it by
fixing the header files rather than by adjusting the ordering of
includes in every file where they're used.


Re: CVS commit: src/sys/kern

2020-08-01 Thread Taylor R Campbell
> Module Name:src
> Committed By:   jdolecek
> Date:   Sat Aug  1 11:18:26 UTC 2020
> 
> Modified Files:
> src/sys/kern: subr_autoconf.c
> 
> Log Message:
> avoid VLA for the sizeof() calculations

Why?


Re: CVS commit: src/share/misc

2020-08-01 Thread Taylor R Campbell
> Module Name:src
> Committed By:   lukem
> Date:   Sat Aug  1 02:45:36 UTC 2020
> 
> Modified Files:
> src/share/misc: style
> 
> Log Message:
> style: prefer braces for single statement control statements
> 
> Prefer to use { braces } around single statements after
> control statements, instead of discouraging them.
> 
> Per discussion on tech-userlevel & tech-kern, where the significant
> majority of developers who responded (including current and former
> core members) prefer this new style.

Hmm...that's not the conclusion I got from the thread.  What you proposed
(https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html),
and got consensus on, was:

- discourage braces around single statements
+ permit braces around single statements

What you committed was:

- discourage braces around single statements
+ prefer braces around single statements and add braces to all examples

At least two core members (me and kre) preferred the change you
originally proposed over the change you committed.

Personally I feel that braces around short statements hurt legibility
by adding unnecessary visual clutter, and make it more cumbersome to
have consistent patterns like

if (foo() == -1)
goto fail0;
if ((x = bar()) == -1)
goto fail1;
if (baz() == -1)
goto fail2;

which makes it more tempting to get clever with shortcuts for error
branches or with reversing the sense of the branch, and we have too
many bugs with clever shortcuts in error branches already.

We don't have a `goto fail' problem in NetBSD -- if we did, our
toolchain would detect it with -Werror=misleading-indentation, as I
just confirmed experimentally.  (Same goes for macros that expand to
multiple statements, with -Werror=multistatement-macros.)

Can you please restore this to the change you originally suggested,
along the lines of the attached patch?
Index: share/misc/style
===
RCS file: /cvsroot/src/share/misc/style,v
retrieving revision 1.56
diff -p -p -u -r1.56 style
--- share/misc/style1 Aug 2020 02:45:35 -   1.56
+++ share/misc/style1 Aug 2020 22:54:53 -
@@ -241,9 +241,8 @@ main(int argc, char *argv[])
errno = 0;
num = strtol(optarg, , 10);
if (num <= 0 || *ep != '\0' || (errno == ERANGE &&
-   (num == LONG_MAX || num == LONG_MIN)) ) {
+   (num == LONG_MAX || num == LONG_MIN)) )
errx(1, "illegal number -- %s", optarg);
-   }
break;
case '?':
default:
@@ -256,16 +255,16 @@ main(int argc, char *argv[])
 
/*
 * Space after keywords (while, for, return, switch).
-* Braces are preferred for control statements
-* with only a single statement.
+*
+* Braces around single-line bodies are optional; use discretion.
 *
 * Forever loops are done with for's, not while's.
 */
-   for (p = buf; *p != '\0'; ++p) {
+   for (p = buf; *p != '\0'; ++p)
continue;   /* Explicit no-op */
-   }
for (;;) {
-   stmt;
+   stmt1;
+   stmt2;
}
 
/*
@@ -317,9 +316,8 @@ main(int argc, char *argv[])
}
 
/* No spaces after function names. */
-   if ((result = function(a1, a2, a3, a4)) == NULL) {
+   if ((result = function(a1, a2, a3, a4)) == NULL)
exit(1);
-   }
 
/*
 * Unary operators don't require spaces, binary operators do.
@@ -397,12 +395,10 @@ function(int a1, int a2, float fl, int a
 *
 * Use err/warn(3), don't roll your own!
 */
-   if ((four = malloc(sizeof(*four))) == NULL) {
+   if ((four = malloc(sizeof(*four))) == NULL)
err(1, NULL);
-   }
-   if ((six = (int *)overflow()) == NULL) {
+   if ((six = (int *)overflow()) == NULL)
errx(1, "Number overflowed.");
-   }
 
/* No parentheses are needed around the return value. */
return eight;
@@ -426,9 +422,8 @@ dirinfo(const char *p, struct stat *sb, 
_DIAGASSERT(p != NULL);
_DIAGASSERT(filedesc != -1);
 
-   if (stat(p, sb) < 0) {
+   if (stat(p, sb) < 0)
err(1, "Unable to stat %s", p);
-   }
 
/*
 * To printf quantities that might be larger than "long", include


Re: CVS commit: src/sys/arch/xen/xen

2020-06-24 Thread Taylor R Campbell
> Module Name:src
> Committed By:   jdolecek
> Date:   Fri Apr 10 18:03:06 UTC 2020
> 
> Modified Files:
> src/sys/arch/xen/xen: if_xennet_xenbus.c
> 
> Log Message:
> convert to bus_dma(9), remove now not necessary XENPVHVM redefines
> [...]
> +   KASSERT(req->rxreq_gntref = GRANT_INVALID_REF);

I don't think this does quite what you meant it to do!

I can fix it by adding the missing `=', but it may cause the kassert
to fire because I don't see anywhere in xennet_rx_free_req that sets
it to GRANT_INVALID_REF and I don't know the surrounding logic well
enough to be confident that just changing it there is correct.


Re: CVS commit: src/sys/dev/usb

2020-05-27 Thread Taylor R Campbell
> Date: Wed, 27 May 2020 05:28:41 -0700 (PDT)
> From: Paul Goyette 
> 
> Do you also need to decrement the number of busses when one is
> detached?

Not really, because we just need to know whether usb_once_init has
been run.

Now, should we use something other than RUN_ONCE, which can both set
up and tear down?  Sure, that might be better in principle, but there
probably aren't that many systems that have hotpluggable USB in which
you might unplug _all_ of the USBs and where you really want to save
the cost of a couple kernel threads.  So not likely worth much effort.


Re: CVS commit: src/tests/lib/libc/sys

2020-05-14 Thread Taylor R Campbell
> Date: Thu, 14 May 2020 23:36:28 +0200
> From: Kamil Rytarowski 
> 
> If a signal would not reach the child process (as it is ignored or
> masked+SA_IGNOREd) and it is not a crash signal, it is dropped. As I
> checked, it's the design in UNIX to overlook SIGCHLD signals in UNIX.
> Race free signals could be maybe possible, but with some design rethinking.

I don't understand -- are you saying that if I mask SIGCHLD, e.g. with
sigprocmask(SIG_BLOCK), then because sigprop[SIGCHLD] has SA_IGNORE
set, any SIGCHLD signals will be discarded while I have it masked?

This can't be right, so either I misunderstood what you're saying, or
something else is afoot with the test that is making it flaky, or
there's a bug in the kernel.


Re: CVS commit: src/sys/uvm

2020-05-10 Thread Taylor R Campbell
> Date: Sun, 10 May 2020 23:53:00 +0100
> From: Alexander Nasonov 
> 
> Taylor R Campbell wrote:
> > Log Message:
> > Implement swap encryption.
> > 
> > Enabled by sysctl -w vm.swap_encrypt=1.
> 
> If secmodel_securelevel(9) is still a thing, locking down this sysctl
> at high securelevel may improve our security. Prior to this change,
> swap devices were readable (even if enrypted with cgd).  With this
> sysctl set to 1, all new swap devices will be encrypted, the only
> thing to worry about is if it's set back to 0 on a compromised host.

This sounds entirely reasonable.  Would you like to draft an
implementation of that?

Presumably it would require writing a sysctl callback function for
vm.swap_encrypt, and would somehow involve kauth, but I'm not sure
offhand what needs to happen beyond that.  Perhaps vm.user_va0_disable
can be a source of inspiration.


Re: CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs

2020-05-07 Thread Taylor R Campbell
> Module Name:src
> Committed By:   hannken
> Date:   Thu May  7 09:12:03 UTC 2020
> 
> Modified Files:
> src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vnops.c
> 
> Log Message:
> Revert Rev. 1.63 and add a comment why we have to zil_commit() here:
> 
> Operation zfs_znode.c::zfs_zget_cleaner() depends on this
> zil_commit() as a barrier to guarantee the znode cannot
> get freed before its log entries are resolved.

We must be doing something wrong.

The only times we should ever call zil_commit are when someone called
fsync or the file system is mounted sync=always.  Calling zil_commit
whenever we delete a file absolutely wrecks performance and shouldn't
be needed for on-disk correctness in normal zfs semantics unless I
terribly misunderstand something, so we must be doing something wrong
with the in-memory state if we seem to need this.

Do you have a test case that can trigger the problem?


Re: CVS commit: src

2020-05-04 Thread Taylor R Campbell
> Module Name:src
> Committed By:   maxv
> Date:   Sat May  2 11:37:17 UTC 2020
> 
> Log Message:
> Modify the hotpatch mechanism, in order to make it much less ROP-friendly.
> 
> Currently x86_patch_window_open is a big problem, because it is a perfect
> function to inject/modify executable code with ROP.
> 
>  - Remove x86_patch_window_open(), along with its x86_patch_window_close()
>counterpart.

This broke existing kernel modules by removing a symbol; seems like a
kernel version bump is in order.

> It looks like fbt is going to collapse soon anyway.

What does this mean?


Re: CVS commit: src/sys/modules/examples/fopsmapper

2020-04-01 Thread Taylor R Campbell
> Date: Wed, 1 Apr 2020 07:42:53 -0700
> From: Jason Thorpe 
> 
> If PAGE_SIZE is ostensibly a vsize_t / size_t, why not define it as (1U << 
> PAGE_SHIFT)?

Without running the following program, can you tell me what it will
print?

It might work to define PAGE_SIZE to be ((size_t)1 << PAGE_SHIFT) but
the consequences are not immediately clear to me (and might be tricky
on, e.g., i386pae).


#include 
#include 
#include 

#define PAGE_SIZE_S (1 << 12)
#define PAGE_SIZE_U (1u << 12)

uint64_taddr = 0x7fff01234567;

int
main(void)
{

printf("%"PRIx64"\n", addr & ~(PAGE_SIZE_S - 1));
printf("%"PRIx64"\n", addr & ~(PAGE_SIZE_U - 1));

fflush(stdout);
return ferror(stdout);
}


Re: CVS commit: src/external/gpl3

2020-03-26 Thread Taylor R Campbell
> Date: Thu, 26 Mar 2020 14:57:40 +0100
> From: Kamil Rytarowski 
> 
> Maybe we could specify TMPDIR somewhere in /etc and point to /tmp?
> 
> The build of tools could be fixed independently.

It is wrong for gcc to abuse /var/tmp for files that aren't
meaningfully persistent, just like it would be wrong to abuse /usr/bin
for configuration files that the operator is expected to edit.  If
upstream inexplicably insisted on abusing /usr/bin for a configuration
file because it was once on a larger partition than /etc, we would
patch gcc to fix that bug too.

If gcc doesn't respect TMPDIR, that's a separate bug that should be
fixed as well.

We don't need to set TMPDIR=/tmp anywhere because that's already what
correct programs use by default (for example, via _PATH_TMP).


Re: CVS commit: src/external/gpl3

2020-03-25 Thread Taylor R Campbell
> Date: Thu, 26 Mar 2020 01:26:05 +0100
> From: Kamil Rytarowski 
> 
> Upstream (GCC) is strongly against this change (even under __NetBSD__
> ifdef) as /var/tmp is typically larger than /tmp:
> 
> > I'd strongly recommend against this as-is.
> >
> > The whole reason we prefer /var/tmp is because it's often dramatically
> larger
> > than a ram-backed /tmp.
> 
> -- by Jeff Law.
> 
> Do we insist on this patch? Can we remove it from local sources?

We should keep the change.  There is no semantic justification for
putting build-time temporary files in the directory for temporary
files that are meant to persist across reboot.  These temporary files
_cannot_ be used if interrupted -- let alone by a reboot.

Going back to /var/tmp would be ridiculous, and a huge performance hit
on systems with tmpfs-backed /tmp, for zero real benefit.  Abusing
/var/tmp has been stupid for over a decade and I'm glad we finally
fixed it.

Users who actually run out of /tmp space -- which is something that
happens noisily, not silently slowing everything down for no apparent
reason, and something that I've never heard of happening on machines
that do builds -- can easily either (a) add more, or (b) set TMPDIR
explicitly.


Re: CVS commit: src/sys/rump

2020-03-09 Thread Taylor R Campbell
> Module Name:src
> Committed By:   kamil
> Date:   Mon Mar  9 00:03:00 UTC 2020
> 
> Modified Files:
> src/sys/rump: Makefile.rump
> 
> Log Message:
> Build RUMP with -fno-delete-null-pointer-checks on all compilers

I asked you to hold off on making this change, ten hours before you
proceeded to make it:

https://mail-index.NetBSD.org/tech-kern/2020/03/08/msg026125.html

It remains unclear whether the change is actually necessary.

Please back this out until the discussion has reached a conclusion,
and please don't unilaterally move ahead to make changes that are
still under active discussion -- especially when someone in the
discussion you initiated has specifically asked you to wait.

If there is a dispute that has deadlocked in public discussion and
requires a resolution, then you can present a case to core and ask for
a ruling.  But right now the discussion is not deadlocked and nobody
has asked for core to step in to resolve any dispute in order to make
progress.


Re: CVS commit: src/lib

2020-03-03 Thread Taylor R Campbell
> Date: Tue, 03 Mar 2020 20:05:14 +1100
> from: matthew green 
> 
> thanksand can you please have this pulled up to other
> branches it's present on.

Already done:

https://releng.NetBSD.org/cgi-bin/req-9.cgi?show=756
https://releng.NetBSD.org/cgi-bin/req-8.cgi?show=1513


Re: CVS commit: src/sys/kern

2020-03-02 Thread Taylor R Campbell
> Date: Tue, 3 Mar 2020 12:41:32 +0900
> From: Rin Okuyama 
> 
> On 2020/03/03 1:00, Taylor R Campbell wrote:
> > Include kern_crashme.c in non-DEBUG kernels.
> > 
> > This is useful for simulating crashes in production to test failover.
> 
> I like this.
> 
> Could you please send pullup request to netbsd-9, or can I?

Go for it!


Re: CVS commit: src/doc

2020-02-29 Thread Taylor R Campbell
> Module Name:src
> Committed By:   kamil
> Date:   Sat Feb 29 04:27:01 UTC 2020
> 
> Modified Files:
> src/doc: CHANGES
> 
> Log Message:
> ld.elf_so(1): Implement DT_GNU_HASH

Was this discussed anywhere?  What are the advantages and drawbacks of
this over what we were doing before?  What other toolchain changes are
involved in using it?  What maintenance burden does it put on us for
compatibility?  What's the impact on systems that prioritize size over
speed?


Re: CVS commit: src/sys/arch

2019-12-23 Thread Taylor R Campbell
> Module Name:src
> Committed By:   thorpej
> Date:   Sun Dec 22 15:09:39 UTC 2019
> 
> Add intr_mask() and corresponding intr_unmask() calls that allow specific
> interrupt lines / sources to be masked as needed (rather than making a
> set of sources by IPL as with spl*()).
> 
> +   if (ci == curcpu() || !mp_online) {
> +   intr_hwunmask_xcall(ih, NULL);
> +   } else {
> +   where = xc_unicast(0, intr_hwunmask_xcall, ih, NULL, ci);
> +   xc_wait(where);
> +   }

If this conditional is necessary, we should teach xc_unicast to make
it unnecessary.


Re: CVS commit: src/sys/uvm

2019-12-23 Thread Taylor R Campbell
> Module Name:src
> Committed By:   ad
> Date:   Sat Dec 21 14:41:44 UTC 2019
> 
> - Add inlines to set/get locator values in the unused lower bits of
>   pg->phys_addr.  Begin by using it to cache the freelist index, because
>   computing it is expensive and that shows up during profiling.  Discussed
>   on tech-kern.

So I guess we won't be switching pg->phys_addr from paddr to pfn?
Speaking of which, any plans for expanding to >32-bit (or >31-bit, if
signed) pfns in the rest of uvm?

> +static inline unsigned
> +uvm_page_get_bucket(struct vm_page *pg)
> +{
> +   return (pg->phys_addr & 0x3e0) >> 5;
> +}

Can you use __BITS/__SHIFTIN/__SHIFTOUT for this instead of magic hex
masks?

#define PHYSADDR_FREELIST   __BITS(0,4)
#define PHYSADDR_BUCKET __BITS(5,9)

static inline unsigned
uvm_page_get_bucket(struct vm_page *pg)
{
return __SHIFTOUT(pg->phys_addr, PHYSADDR_BUCKET);
}

static inline unsigned
uvm_page_set_bucket(struct vm_page *pg, unsigned b)
{
pg->phys_addr &= ~PHYSADDR_BUCKET;
pg->phys_addr |= __SHIFTIN(b, PHYSADDR_BUCKET);
}


Re: CVS commit: src

2019-12-22 Thread Taylor R Campbell
> Date: Sun, 22 Dec 2019 10:24:01 +0100
> From: Maxime Villard 
> 
> You, Martin Christos and Taylor, are trying to change subject, find
> excuses, and are sending me irrelevant responses vaguely insinuating that
> I should revert my change only without addressing the additional concerns
> expressed repeatedly. I fail to see whether I should take these as official
> core answers.
> 
> If they are, please clearly say so.

Please revert your filemon deletion and leave the existing mitigation
in place for the moment pending discussion.  We can address the
additional concerns afterward.

Thanks,
-Riastradh, on behalf of core


Re: CVS commit: src

2019-12-20 Thread Taylor R Campbell
Security-team is not perfect.  We're happy to discuss a better way to
disable filemon provisionally, and/or how to better address the
existing users if we are to delete it -- after you do as core asked
you to do to resolve the interim dispute by restoring the tree.

This is a social process.  We can work together to make it better for
everyone, but you have to be willing to work with the community,
including accepting rulings by core to resolve disputes.

Constantly against the community hurts everyone, including you
because it brews resentment against the good work you do and makes
that work harder to get through.  It's especially harmful when much of
the developer community likely agrees with you on technical grounds --
you seem to be stepping on toes and lashing out for no reason.


Re: CVS commit: src

2019-12-19 Thread Taylor R Campbell
> Date: Thu, 19 Dec 2019 08:19:07 +0100
> From: Maxime Villard 
> 
> I think you meant to say "REMOVING things you don't like".

Correct, I made an editing error.  Sorry for the confusion.

> In the meantime, I have absolutely no intent to reinstate filemon. You can
> reinstate it if you want, but it should come as no surprise to you in the
> near future that filemon, after whatever "necessary" discussion or different
> forms of bureaucratic idiocy you want to throw at it, will be deleted almost
> as fast as it came back from the attic. Especially considering the emails
> sent from the other people since I proceeded.

This is not negotiable.  It is core's position that the filemon
removal should be undone for the time being, so please go ahead and
undo it.

Thanks,
-Riastradh, on behalf of core


Re: CVS commit: src

2019-12-18 Thread Taylor R Campbell
> Module Name:src
> Committed By:   maxv
> Date:   Wed Dec 18 07:37:19 UTC 2019
> 
> Log Message:
> Retire filemon, discussed on tech-kern@.

Please refrain from taking unilateral actions such as things you don't
like without reasonable discussion.

- Nobody skimming tech-kern by subject line would reasonably expect
  that a thread titled `[filemon] CVS commit: htdocs/support/security'
  is the place to find a proposal of deletion on 18h notice.

- Nothing in the thread was actually a proposal for discussion -- just
  an announcement that you have taken a unilateral decision to remove
  it.

- And since the module is gone and the pseudo-device is disabled by
  default, no unilateral emergency action is warranted, even it turns
  out under discussion that there is community consensus that filemon
  should be removed from the tree.

Please revert the filemon deletion and ensure the tree builds within
the next 24h.  If you want to see filemon deleted, you can raise the
subject _after_ you have reverted the commits.

Thanks,
-Riastradh, on behalf of core.


Re: CVS commit: src/sys/uvm

2019-12-01 Thread Taylor R Campbell
> Date: Sun, 1 Dec 2019 11:54:24 +
> From: Andrew Doran 
> 
> On Sun, Dec 01, 2019 at 08:19:09AM +, Maxime Villard wrote:
> 
> > Modified Files:
> > src/sys/uvm: uvm_fault.c
> > 
> > Log Message:
> > Use atomic_{load,store}_relaxed() on global counters.
> 
> If you would be so kind, please don't do any more of the UVM counters.  I
> have a patch to make these CPU local which will be going out for review in
> the near future.

Sounds good -- using atomic_load/store for these counters was intended
to be a stop-gap measure until someone did the work to make them
CPU-local, as discussed in the past couple weeks on tech-kern!


CVS commit: src/sys/arch/ia64/ia64

2019-11-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 16:23:46 UTC 2019

Modified Files:
src/sys/arch/ia64/ia64: pmap.c

Log Message:
Need  for atomic_inc_64.

Emptying out  had the side effect of removing an
implied #include .


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/ia64/ia64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/ia64/ia64

2019-11-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 16:23:46 UTC 2019

Modified Files:
src/sys/arch/ia64/ia64: pmap.c

Log Message:
Need  for atomic_inc_64.

Emptying out  had the side effect of removing an
implied #include .


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/ia64/ia64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ia64/ia64/pmap.c
diff -u src/sys/arch/ia64/ia64/pmap.c:1.38 src/sys/arch/ia64/ia64/pmap.c:1.39
--- src/sys/arch/ia64/ia64/pmap.c:1.38	Thu May  9 15:48:55 2019
+++ src/sys/arch/ia64/ia64/pmap.c	Sat Nov 30 16:23:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.38 2019/05/09 15:48:55 scole Exp $ */
+/* $NetBSD: pmap.c,v 1.39 2019/11/30 16:23:46 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -81,9 +81,10 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.38 2019/05/09 15:48:55 scole Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.39 2019/11/30 16:23:46 riastradh Exp $");
 
 #include 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/sys

2019-11-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 15:34:07 UTC 2019

Modified Files:
src/sys/sys: mutex.h

Log Message:
Nix vestigial references to MUTEX_GIVE and MUTEX_RECEIVE in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/sys/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/mutex.h
diff -u src/sys/sys/mutex.h:1.22 src/sys/sys/mutex.h:1.23
--- src/sys/sys/mutex.h:1.22	Sat Sep 16 23:25:35 2017
+++ src/sys/sys/mutex.h	Sat Nov 30 15:34:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.22 2017/09/16 23:25:35 christos Exp $	*/
+/*	$NetBSD: mutex.h,v 1.23 2019/11/30 15:34:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -63,13 +63,6 @@
  *		[additionally:]
  *		volatile integer	mtx_id
  *
- *	MUTEX_RECEIVE(mtx)
- *		Post a load fence after acquiring the mutex, if necessary.
- *
- *	MUTEX_GIVE(mtx)
- *		Post a load/store fence after releasing the mutex, if
- *		necessary.
- *
  * 	MUTEX_CAS(ptr, old, new)
  *		Perform an atomic "compare and swap" operation and
  *		evaluate to true or false according to the success



CVS commit: src/sys/sys

2019-11-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 15:34:07 UTC 2019

Modified Files:
src/sys/sys: mutex.h

Log Message:
Nix vestigial references to MUTEX_GIVE and MUTEX_RECEIVE in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/sys/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:47:14 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9 uvm_hotplug.9
src/usr.sbin/i2cscan: i2cscan.8
src/usr.sbin/pcictl: pcictl.8

Log Message:
Use .Sy, not .Em, for bold-faced WARNING of impending doom.

Underline and, worse, italic aren't as good at catching the eye.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/uvm_hotplug.9
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/i2cscan/i2cscan.8
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/pcictl/pcictl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:47:14 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9 uvm_hotplug.9
src/usr.sbin/i2cscan: i2cscan.8
src/usr.sbin/pcictl: pcictl.8

Log Message:
Use .Sy, not .Em, for bold-faced WARNING of impending doom.

Underline and, worse, italic aren't as good at catching the eye.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/uvm_hotplug.9
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/i2cscan/i2cscan.8
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/pcictl/pcictl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/atomic_loadstore.9
diff -u src/share/man/man9/atomic_loadstore.9:1.2 src/share/man/man9/atomic_loadstore.9:1.3
--- src/share/man/man9/atomic_loadstore.9:1.2	Sat Nov 30 02:38:44 2019
+++ src/share/man/man9/atomic_loadstore.9	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_loadstore.9,v 1.2 2019/11/30 02:38:44 riastradh Exp $
+.\"	$NetBSD: atomic_loadstore.9,v 1.3 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation
 .\" All rights reserved.
@@ -655,7 +655,7 @@ and
 functions like a acquire operation on
 .Fa obj .
 .Pp
-.Em WARNING :
+.Sy WARNING :
 The combination of
 .Fn atomic_load_relaxed
 and

Index: src/share/man/man9/uvm_hotplug.9
diff -u src/share/man/man9/uvm_hotplug.9:1.4 src/share/man/man9/uvm_hotplug.9:1.5
--- src/share/man/man9/uvm_hotplug.9:1.4	Sat Dec 24 08:05:47 2016
+++ src/share/man/man9/uvm_hotplug.9	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: uvm_hotplug.9,v 1.4 2016/12/24 08:05:47 wiz Exp $
+.\"	$NetBSD: uvm_hotplug.9,v 1.5 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright (c) 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -95,7 +95,7 @@ They must
 never be used after
 .Xr uvm_init 9 .
 .Pp
-.Em WARNING :
+.Sy WARNING :
 This is an experimental feature and should not be used in production
 environments.
 Furthermore, attempting to "hotplug" without

Index: src/usr.sbin/i2cscan/i2cscan.8
diff -u src/usr.sbin/i2cscan/i2cscan.8:1.6 src/usr.sbin/i2cscan/i2cscan.8:1.7
--- src/usr.sbin/i2cscan/i2cscan.8:1.6	Thu Nov 26 23:29:05 2015
+++ src/usr.sbin/i2cscan/i2cscan.8	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: i2cscan.8,v 1.6 2015/11/26 23:29:05 wiz Exp $
+.\"	$NetBSD: i2cscan.8,v 1.7 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright (c) 2011, 2013 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -61,7 +61,7 @@ Available options:
 scan using 1 byte reads instead of quick writes.
 .El
 .Pp
-.Em WARNING !
+.Sy WARNING :
 Using this utility can access some devices in such a
 manner as to leave them in an unstable or unusable state.
 It can also lock up the entire

Index: src/usr.sbin/pcictl/pcictl.8
diff -u src/usr.sbin/pcictl/pcictl.8:1.19 src/usr.sbin/pcictl/pcictl.8:1.20
--- src/usr.sbin/pcictl/pcictl.8:1.19	Tue Sep 27 16:44:04 2016
+++ src/usr.sbin/pcictl/pcictl.8	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pcictl.8,v 1.19 2016/09/27 16:44:04 mrg Exp $
+.\"	$NetBSD: pcictl.8,v 1.20 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright 2001 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -96,7 +96,7 @@ If the bus is not specified, it defaults
 PCI bus specified on the command line.
 If the function is not specified, it defaults to 0.
 .Pp
-.Em WARNING :
+.Sy WARNING :
 .Nm
 .Cm read
 is a dangerous command that can damage hardware and panic the operating
@@ -118,7 +118,7 @@ If the bus is not specified, it defaults
 PCI bus specified on the command line.
 If the function is not specified, it defaults to 0.
 .Pp
-.Em WARNING :
+.Sy WARNING :
 .Nm
 .Cm write
 is a dangerous command that can damage hardware and panic the operating



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:38:44 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
Document relation to atomic_ops(3) and membar_ops(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man9/atomic_loadstore.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/atomic_loadstore.9
diff -u src/share/man/man9/atomic_loadstore.9:1.1 src/share/man/man9/atomic_loadstore.9:1.2
--- src/share/man/man9/atomic_loadstore.9:1.1	Fri Nov 29 22:17:23 2019
+++ src/share/man/man9/atomic_loadstore.9	Sat Nov 30 02:38:44 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_loadstore.9,v 1.1 2019/11/29 22:17:23 riastradh Exp $
+.\"	$NetBSD: atomic_loadstore.9,v 1.2 2019/11/30 02:38:44 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation
 .\" All rights reserved.
@@ -621,6 +621,60 @@ They do not require
 to be at most the largest size of available atomic loads and stores on
 the host architecture.
 .El
+.Sh MEMORY BARRIERS AND ATOMIC READ/MODIFY/WRITE
+The atomic read/modify/write operations in
+.Xr atomic_ops 3
+have relaxed ordering by default, but can be combined with the memory
+barriers in
+.Xr membar_ops 3
+for the same effect as an acquire operation and a release operation for
+the purposes of pairing with
+.Fn atomic_store_release
+and
+.Fn atomic_load_acquire
+or
+.Fn atomic_load_consume :
+If
+.Fn atomic_r/m/w
+is an atomic read/modify/write operation in
+.Xr atomic_ops 3 ,
+then
+.Bd -literal
+	membar_exit();
+	atomic_r/m/w(obj, ...);
+.Ed
+.Pp
+functions like a release operation on
+.Fa obj ,
+and
+.Bd -literal
+	atomic_r/m/w(obj, ...);
+	membar_enter();
+.Ed
+.Pp
+functions like a acquire operation on
+.Fa obj .
+.Pp
+.Em WARNING :
+The combination of
+.Fn atomic_load_relaxed
+and
+.Xr membar_enter 3
+.Em does not
+make an acquire operation; only read/modify/write atomics may be
+combined with
+.Xr membar_enter 3
+this way.
+.Pp
+On architectures where
+.Dv __HAVE_ATOMIC_AS_MEMBAR
+is defined, all the
+.Xr atomic_ops 3
+imply release and acquire operations, so the
+.Xr membar_enter 3
+and
+.Xr membar_exit 3
+are redundant.
 .Sh EXAMPLES
 Maintaining lossy counters.
 These may lose some counts, because the read/modify/write cycle as a



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:38:44 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
Document relation to atomic_ops(3) and membar_ops(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man9/atomic_loadstore.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:22:23 UTC 2019

Modified Files:
src/share/man/man9: xcall.9

Log Message:
Document xc_barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/xcall.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:22:23 UTC 2019

Modified Files:
src/share/man/man9: xcall.9

Log Message:
Document xc_barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/xcall.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/xcall.9
diff -u src/share/man/man9/xcall.9:1.15 src/share/man/man9/xcall.9:1.16
--- src/share/man/man9/xcall.9:1.15	Sun Oct  6 17:21:28 2019
+++ src/share/man/man9/xcall.9	Sat Nov 30 02:22:23 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: xcall.9,v 1.15 2019/10/06 17:21:28 uwe Exp $
+.\" $NetBSD: xcall.9,v 1.16 2019/11/30 02:22:23 riastradh Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,14 +27,15 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 1, 2018
+.Dd November 29, 2019
 .Dt XCALL 9
 .Os
 .Sh NAME
 .Nm xcall ,
 .Nm xc_broadcast ,
 .Nm xc_unicast ,
-.Nm xc_wait
+.Nm xc_wait ,
+.Nm xc_barrier
 .Nd cross-call interface
 .Sh SYNOPSIS
 .In sys/xcall.h
@@ -45,6 +46,8 @@
 .Fn xc_unicast "u_int flags" "xcfunc_t func" "void *arg1" "void *arg2" "struct cpu_info *ci"
 .Ft void
 .Fn xc_wait "uint64_t where"
+.Ft void
+.Fn xc_barrier "u_int flags"
 .Sh DESCRIPTION
 The machine-independent
 .Nm
@@ -143,6 +146,29 @@ or
 for the corresponding cross-call to complete.
 .Fn xc_wait
 should be called from a thread context.
+.It Fn xc_barrier "flags"
+Issue a broadcast cross-call that does nothing, using
+.Fa flags ,
+and wait for it to complete.
+This has two effects:
+.Bl -dash -compact
+.It
+This waits for the interrupt priority level to transition to
+.Dv IPL_NONE
+at least once on all CPUs.
+.It
+This functions like a memory barrier that forces all prior operations
+in program order to globally happen before all subsequent operations in
+program order, as witnessed by every CPU.
+.El
+.Pp
+.Fn xc_barrier
+is much more expensive than
+.Xr membar_ops 3 ,
+so it should be used sparingly, only to publish information
+infrequently \(em for example, during module load and unload \(em when
+the cost of a memory barrier on the consumer side would be
+prohibitive.
 .El
 .Sh CODE REFERENCES
 The
@@ -151,6 +177,7 @@ interface is implemented within the file
 .Pa sys/kern/subr_xcall.c .
 .\" .Sh EXAMPLES
 .Sh SEE ALSO
+.Xr membar_ops 3 ,
 .Xr kpreempt 9 ,
 .Xr percpu 9 ,
 .Xr softint 9



CVS commit: src/distrib/sets/lists/comp

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 00:02:15 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
Missed another spot.

Marked mb.9 obsolete but forgot to mark mb_memory.9  too.


To generate a diff of this commit:
cvs rdiff -u -r1.2294 -r1.2295 src/distrib/sets/lists/comp/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2294 src/distrib/sets/lists/comp/mi:1.2295
--- src/distrib/sets/lists/comp/mi:1.2294	Fri Nov 29 22:17:23 2019
+++ src/distrib/sets/lists/comp/mi	Sat Nov 30 00:02:15 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2294 2019/11/29 22:17:23 riastradh Exp $
+#	$NetBSD: mi,v 1.2295 2019/11/30 00:02:15 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -11394,9 +11394,9 @@
 ./usr/share/man/cat9/malloc_type_detach.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/malloc_type_setlimit.0	comp-obsolete		obsolete
 ./usr/share/man/cat9/mb.0			comp-obsolete		obsolete
-./usr/share/man/cat9/mb_memory.0		comp-sys-catman		.cat
-./usr/share/man/cat9/mb_read.0			comp-sys-catman		.cat
-./usr/share/man/cat9/mb_write.0			comp-sys-catman		.cat
+./usr/share/man/cat9/mb_memory.0		comp-obsolete		obsolete
+./usr/share/man/cat9/mb_read.0			comp-obsolete		obsolete
+./usr/share/man/cat9/mb_write.0			comp-obsolete		obsolete
 ./usr/share/man/cat9/mbuf.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/mca.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/mca_conf_read.0		comp-sys-catman		.cat
@@ -19323,9 +19323,9 @@
 ./usr/share/man/html9/malloc_type_detach.html	comp-sys-htmlman	html
 ./usr/share/man/html9/malloc_type_setlimit.html comp-obsolete	obsolete
 ./usr/share/man/html9/mb.html			comp-obsolete	obsolete
-./usr/share/man/html9/mb_memory.html		comp-sys-htmlman	html
-./usr/share/man/html9/mb_read.html		comp-sys-htmlman	html
-./usr/share/man/html9/mb_write.html		comp-sys-htmlman	html
+./usr/share/man/html9/mb_memory.html		comp-obsolete	obsolete
+./usr/share/man/html9/mb_read.html		comp-obsolete	obsolete
+./usr/share/man/html9/mb_write.html		comp-obsolete	obsolete
 ./usr/share/man/html9/mbuf.html			comp-sys-htmlman	html
 ./usr/share/man/html9/mca.html			comp-sys-htmlman	html
 ./usr/share/man/html9/mca_conf_read.html	comp-sys-htmlman	html
@@ -27405,9 +27405,9 @@
 ./usr/share/man/man9/malloc_type_detach.9	comp-sys-man		.man
 ./usr/share/man/man9/malloc_type_setlimit.9	comp-obsolete		obsolete
 ./usr/share/man/man9/mb.9			comp-obsolete		obsolete
-./usr/share/man/man9/mb_memory.9		comp-sys-man		.man
-./usr/share/man/man9/mb_read.9			comp-sys-man		.man
-./usr/share/man/man9/mb_write.9			comp-sys-man		.man
+./usr/share/man/man9/mb_memory.9		comp-obsolete		obsolete
+./usr/share/man/man9/mb_read.9			comp-obsolete		obsolete
+./usr/share/man/man9/mb_write.9			comp-obsolete		obsolete
 ./usr/share/man/man9/mbuf.9			comp-sys-man		.man
 ./usr/share/man/man9/mca.9			comp-sys-man		.man
 ./usr/share/man/man9/mca_conf_read.9		comp-sys-man		.man



CVS commit: src/distrib/sets/lists/comp

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 00:02:15 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi

Log Message:
Missed another spot.

Marked mb.9 obsolete but forgot to mark mb_memory.9  too.


To generate a diff of this commit:
cvs rdiff -u -r1.2294 -r1.2295 src/distrib/sets/lists/comp/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:55:34 UTC 2019

Modified Files:
src/sys/arch/alpha/include: mutex.h
src/sys/arch/arm/include: mutex.h
src/sys/arch/ia64/include: mutex.h
src/sys/arch/m68k/include: mutex.h
src/sys/arch/mips/include: mutex.h
src/sys/arch/or1k/include: mutex.h
src/sys/arch/powerpc/include: mutex.h
src/sys/arch/riscv/include: mutex.h
src/sys/arch/sh3/include: mutex.h
src/sys/arch/sparc/include: mutex.h
src/sys/arch/sparc64/include: mutex.h
src/sys/arch/usermode/include: mutex.h
src/sys/arch/vax/include: mutex.h
src/sys/arch/x86/include: mutex.h

Log Message:
Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/include/mutex.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/include/mutex.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/include/mutex.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/include/mutex.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/include/mutex.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/include/mutex.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/include/mutex.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sh3/include/mutex.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/mutex.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/mutex.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/vax/include/mutex.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:55:34 UTC 2019

Modified Files:
src/sys/arch/alpha/include: mutex.h
src/sys/arch/arm/include: mutex.h
src/sys/arch/ia64/include: mutex.h
src/sys/arch/m68k/include: mutex.h
src/sys/arch/mips/include: mutex.h
src/sys/arch/or1k/include: mutex.h
src/sys/arch/powerpc/include: mutex.h
src/sys/arch/riscv/include: mutex.h
src/sys/arch/sh3/include: mutex.h
src/sys/arch/sparc/include: mutex.h
src/sys/arch/sparc64/include: mutex.h
src/sys/arch/usermode/include: mutex.h
src/sys/arch/vax/include: mutex.h
src/sys/arch/x86/include: mutex.h

Log Message:
Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/include/mutex.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/include/mutex.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/include/mutex.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/include/mutex.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/include/mutex.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/include/mutex.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/include/mutex.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sh3/include/mutex.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/mutex.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/mutex.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/vax/include/mutex.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/include/mutex.h
diff -u src/sys/arch/alpha/include/mutex.h:1.5 src/sys/arch/alpha/include/mutex.h:1.6
--- src/sys/arch/alpha/include/mutex.h:1.5	Fri Nov 29 20:05:07 2019
+++ src/sys/arch/alpha/include/mutex.h	Fri Nov 29 22:55:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:05:07 riastradh Exp $	*/
+/*	$NetBSD: mutex.h,v 1.6 2019/11/29 22:55:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@@ -60,9 +60,6 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		__asm __volatile("mb" : : : "memory")
-#define	MUTEX_GIVE(mtx)			__asm __volatile("mb" : : : "memory")
-
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 
 int	_lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);

Index: src/sys/arch/arm/include/mutex.h
diff -u src/sys/arch/arm/include/mutex.h:1.20 src/sys/arch/arm/include/mutex.h:1.21
--- src/sys/arch/arm/include/mutex.h:1.20	Wed Feb 25 13:52:42 2015
+++ src/sys/arch/arm/include/mutex.h	Fri Nov 29 22:55:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.20 2015/02/25 13:52:42 joerg Exp $	*/
+/*	$NetBSD: mutex.h,v 1.21 2019/11/29 22:55:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -84,30 +84,6 @@ struct kmutex {
 #endif
 #define	__HAVE_SIMPLE_MUTEXES		1
 
-/*
- * MUTEX_{GIVE,RECEIVE}: no memory barrier is required in the UP case;
- * we're synchronizing against interrupts, not multiple processors.
- */
-#ifdef MULTIPROCESSOR
-#ifdef _ARM_ARCH_7
-#define	MUTEX_RECEIVE(mtx)		__asm __volatile("dmb" ::: "memory")
-#else
-#define	MUTEX_RECEIVE(mtx)		membar_consumer()
-#endif
-#else
-#define	MUTEX_RECEIVE(mtx)		/* nothing */
-#endif
-
-#ifdef MULTIPROCESSOR
-#ifdef _ARM_ARCH_7
-#define	MUTEX_GIVE(mtx)			__asm __volatile("dsb" ::: "memory")
-#else
-#define	MUTEX_GIVE(mtx)			membar_producer()
-#endif
-#else
-#define	MUTEX_GIVE(mtx)			/* nothing */
-#endif
-
 #define	MUTEX_CAS(p, o, n)		\
 (atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o))
 #ifdef MULTIPROCESSOR

Index: src/sys/arch/ia64/include/mutex.h
diff -u src/sys/arch/ia64/include/mutex.h:1.4 src/sys/arch/ia64/include/mutex.h:1.5
--- src/sys/arch/ia64/include/mutex.h:1.4	Mon Jul 20 04:41:37 2009
+++ src/sys/arch/ia64/include/mutex.h	Fri Nov 29 22:55:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2009/07/20 04:41:37 kiyohara Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 22:55:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -56,16 +56,6 @@ struct kmutex {
 */
 #define	__HAVE_SIMPLE_MUTEXES		1
 
-/*
- * MUTEX_RECEIVE: no memory barrier required, atomic_cas implies a load fence.
- */
-#define	MUTEX_RECEIVE(mtx)		/* nothing */
-
-/*
- * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it.
- */
-#define	MUTEX_GIVE(mtx)			/* nothing */
-
 #define	MUTEX_CAS(ptr, old, new)		\
 (atomic_cas_ulong((volatile unsigned long *)(ptr), (old), (new)) == (old))
 

Index: src/sys/arch/m68k/include/mutex.h
diff -u src/sys/arch/m68k/include/mutex.h:1.8 src/sys/arch/m68k/include/mutex.h:1.9
--- src/sys/arch/m68k/include/mutex.h:1.8	Fri 

CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:38:28 UTC 2019

Modified Files:
src/share/man/man9: Makefile

Log Message:
Missed a spot: delete mb.9 from MLINKS too.


To generate a diff of this commit:
cvs rdiff -u -r1.443 -r1.444 src/share/man/man9/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.443 src/share/man/man9/Makefile:1.444
--- src/share/man/man9/Makefile:1.443	Fri Nov 29 22:17:23 2019
+++ src/share/man/man9/Makefile	Fri Nov 29 22:38:28 2019
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.443 2019/11/29 22:17:23 riastradh Exp $
+#   $NetBSD: Makefile,v 1.444 2019/11/29 22:38:28 riastradh Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -494,7 +494,6 @@ MLINKS+=malloc.9 malloc_type_attach.9
 MLINKS+=malloc.9 malloc_type_detach.9
 MLINKS+=malloc.9 MALLOC_DEFINE.9
 MLINKS+=malloc.9 MALLOC_DECLARE.9
-MLINKS+=mb.9 mb_memory.9 mb.9 mb_read.9 mb.9 mb_write.9
 MLINKS+=mbuf.9 m_get.9 mbuf.9 m_gethdr.9 mbuf.9 m_devget.9 \
 	mbuf.9 m_copym.9 mbuf.9 m_copypacket.9 mbuf.9 m_copydata.9 \
 	mbuf.9 m_copyback.9 mbuf.9 m_cat.9 mbuf.9 m_dup.9 mbuf.9 m_prepend.9 \



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:38:28 UTC 2019

Modified Files:
src/share/man/man9: Makefile

Log Message:
Missed a spot: delete mb.9 from MLINKS too.


To generate a diff of this commit:
cvs rdiff -u -r1.443 -r1.444 src/share/man/man9/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:17:24 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
src/sys/sys: atomic.h
Added Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
New atomic load/store operations for the kernel.

Guarantee no fusing and no tearing, and can optionally impose
ordering relative to other memory operations.

Unordered:
- atomic_load_relaxed
- atomic_store_relaxed

Ordered:
- atomic_load_acquire
- atomic_load_consume
- atomic_store_release

These are intended to match C11 semantics, and can be defined in
terms of the C11 atomic API when ready.


To generate a diff of this commit:
cvs rdiff -u -r1.2293 -r1.2294 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.442 -r1.443 src/share/man/man9/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.17 -r1.18 src/sys/sys/atomic.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-11-29 Thread Taylor R Campbell
19
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic.h,v 1.17 2019/11/14 16:23:53 maxv Exp $	*/
+/*	$NetBSD: atomic.h,v 1.18 2019/11/29 22:17:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -383,4 +383,109 @@ __END_DECLS
 #define atomic_inc_64_nv	kmsan_atomic_inc_64_nv
 #endif
 
+#ifdef _KERNEL
+
+#if 1 // XXX: __STDC_VERSION__ < 201112L
+
+/* Pre-C11 definitions */
+
+#include 
+#include 
+
+#ifdef _LP64
+#define	__HAVE_ATOMIC64_LOADSTORE	1
+#define	__ATOMIC_SIZE_MAX		8
+#else
+#define	__ATOMIC_SIZE_MAX		4
+#endif
+
+/*
+ * We assume that access to an aligned pointer to a volatile object of
+ * at most __ATOMIC_SIZE_MAX bytes is guaranteed to be atomic.  This is
+ * an assumption that may be wrong, but we hope it won't be wrong
+ * before we just adopt the C11 atomic API.
+ */
+#define	__ATOMIC_PTR_CHECK(p) do	  \
+{	  \
+	CTASSERT(sizeof(*(p)) <= __ATOMIC_SIZE_MAX);			  \
+	KASSERT(((uintptr_t)(p) & ilog2(sizeof(*(p == 0);		  \
+} while (0)
+
+#define	atomic_load_relaxed(p)		  \
+({	  \
+	const volatile __typeof__(*(p)) *__al_ptr = (p);		  \
+	__ATOMIC_PTR_CHECK(__al_ptr);	  \
+	*__al_ptr;			  \
+})
+
+#define	atomic_load_consume(p)		  \
+({	  \
+	const volatile __typeof__(*(p)) *__al_ptr = (p);		  \
+	__ATOMIC_PTR_CHECK(__al_ptr);	  \
+	__typeof__(*(p)) __al_val = *__al_ptr;  \
+	membar_datadep_consumer();	  \
+	__al_val;			  \
+})
+
+/*
+ * We want {loads}-before-{loads,stores}.  It is tempting to use
+ * membar_enter, but that provides {stores}-before-{loads,stores},
+ * which may not help.  So we must use membar_sync, which does the
+ * slightly stronger {loads,stores}-before-{loads,stores}.
+ */
+#define	atomic_load_acquire(p)		  \
+({	  \
+	const volatile __typeof__(*(p)) *__al_ptr = (p);		  \
+	__ATOMIC_PTR_CHECK(__al_ptr);	  \
+	__typeof__(*(p)) __al_val = *__al_ptr;  \
+	membar_sync();			  \
+	__al_val;			  \
+})
+
+#define	atomic_store_relaxed(p,v)	  \
+({	  \
+	volatile __typeof__(*(p)) *__as_ptr = (p);			  \
+	__ATOMIC_PTR_CHECK(__as_ptr);	  \
+	*__as_ptr = (v);		  \
+})
+
+#define	atomic_store_release(p,v)	  \
+({	  \
+	volatile __typeof__(*(p)) *__as_ptr = (p);			  \
+	__typeof__(*(p)) __as_val = (v);  \
+	__ATOMIC_PTR_CHECK(__as_ptr);	  \
+	membar_exit();			  \
+	*__as_ptr = __as_val;		  \
+})
+
+#else  /* __STDC_VERSION__ >= 201112L */
+
+/* C11 definitions, not yet available */
+
+#include 
+
+#define	atomic_load_relaxed(p)		  \
+	atomic_load_explicit((p), memory_order_relaxed)
+#if 0/* memory_order_consume is not there yet */
+#define	atomic_load_consume(p)		  \
+	atomic_load_explicit((p), memory_order_consume)
+#else
+#define	atomic_load_consume(p)		  \
+({	  \
+	const __typeof__(*(p)) __al_val = atomic_load_relaxed(p);	  \
+	membar_datadep_consumer();	  \
+	__al_val;			  \
+})
+#endif
+#define	atomic_load_acquire(p)		  \
+	atomic_load_explicit((p), memory_order_acquire)
+#define	atomic_store_relaxed(p, v)	  \
+	atomic_store_explicit((p), (v), memory_order_relaxed)
+#define	atomic_store_release(p, v)	  \
+	atomic_store_explicit((p), (v), memory_order_release)
+
+#endif	/* __STDC_VERSION__ */
+
+#endif	/* _KERNEL */
+
 #endif /* ! _SYS_ATOMIC_H_ */

Added files:

Index: src/share/man/man9/atomic_loadstore.9
diff -u /dev/null src/share/man/man9/atomic_loadstore.9:1.1
--- /dev/null	Fri Nov 29 22:17:24 2019
+++ src/share/man/man9/atomic_loadstore.9	Fri Nov 29 22:17:23 2019
@@ -0,0 +1,744 @@
+.\"	$NetBSD: atomic_loadstore.9,v 1.1 2019/11/29 22:17:23 riastradh Exp $
+.\"
+.\" Copyright (c) 2019 The NetBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Taylor R. Campbell.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.

CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:31:35 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
Removed Files:
src/share/man/man9: mb.9

Log Message:
Nix obsolete mb(9) man page.


To generate a diff of this commit:
cvs rdiff -u -r1.2292 -r1.2293 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.441 -r1.442 src/share/man/man9/Makefile
cvs rdiff -u -r1.8 -r0 src/share/man/man9/mb.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2292 src/distrib/sets/lists/comp/mi:1.2293
--- src/distrib/sets/lists/comp/mi:1.2292	Mon Nov 11 22:44:56 2019
+++ src/distrib/sets/lists/comp/mi	Fri Nov 29 20:31:35 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2292 2019/11/11 22:44:56 joerg Exp $
+#	$NetBSD: mi,v 1.2293 2019/11/29 20:31:35 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -11387,7 +11387,7 @@
 ./usr/share/man/cat9/malloc_type_attach.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/malloc_type_detach.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/malloc_type_setlimit.0	comp-obsolete		obsolete
-./usr/share/man/cat9/mb.0			comp-sys-catman		.cat
+./usr/share/man/cat9/mb.0			comp-obsolete		obsolete
 ./usr/share/man/cat9/mb_memory.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/mb_read.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/mb_write.0			comp-sys-catman		.cat
@@ -19310,7 +19310,7 @@
 ./usr/share/man/html9/malloc_type_attach.html	comp-sys-htmlman	html
 ./usr/share/man/html9/malloc_type_detach.html	comp-sys-htmlman	html
 ./usr/share/man/html9/malloc_type_setlimit.html comp-obsolete	obsolete
-./usr/share/man/html9/mb.html			comp-sys-htmlman	html
+./usr/share/man/html9/mb.html			comp-obsolete	obsolete
 ./usr/share/man/html9/mb_memory.html		comp-sys-htmlman	html
 ./usr/share/man/html9/mb_read.html		comp-sys-htmlman	html
 ./usr/share/man/html9/mb_write.html		comp-sys-htmlman	html
@@ -27386,7 +27386,7 @@
 ./usr/share/man/man9/malloc_type_attach.9	comp-sys-man		.man
 ./usr/share/man/man9/malloc_type_detach.9	comp-sys-man		.man
 ./usr/share/man/man9/malloc_type_setlimit.9	comp-obsolete		obsolete
-./usr/share/man/man9/mb.9			comp-sys-man		.man
+./usr/share/man/man9/mb.9			comp-obsolete		obsolete
 ./usr/share/man/man9/mb_memory.9		comp-sys-man		.man
 ./usr/share/man/man9/mb_read.9			comp-sys-man		.man
 ./usr/share/man/man9/mb_write.9			comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.441 src/share/man/man9/Makefile:1.442
--- src/share/man/man9/Makefile:1.441	Wed Oct  2 08:21:08 2019
+++ src/share/man/man9/Makefile	Fri Nov 29 20:31:35 2019
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.441 2019/10/02 08:21:08 rin Exp $
+#   $NetBSD: Makefile,v 1.442 2019/11/29 20:31:35 riastradh Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -34,7 +34,7 @@ MAN=	accept_filter.9 accf_data.9 accf_ht
 	kprintf.9 kthread.9 linedisc.9 lock.9 locking.9 log.9 ltsleep.9 \
 	localcount.9 LWP_CACHE_CREDS.9 \
 	makeiplcookie.9 \
-	malloc.9 mb.9 mbuf.9 mca.9 memcmp.9 memcpy.9 memoryallocators.9 \
+	malloc.9 mbuf.9 mca.9 memcmp.9 memcpy.9 memoryallocators.9 \
 	memmove.9 memset.9 \
 	microseq.9 microtime.9 microuptime.9 mi_switch.9 module.9 \
 	mstohz.9 mutex.9 m_tag.9 namecache.9 \



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:31:35 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
Removed Files:
src/share/man/man9: mb.9

Log Message:
Nix obsolete mb(9) man page.


To generate a diff of this commit:
cvs rdiff -u -r1.2292 -r1.2293 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.441 -r1.442 src/share/man/man9/Makefile
cvs rdiff -u -r1.8 -r0 src/share/man/man9/mb.9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/vax/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:44 UTC 2019

Modified Files:
src/sys/arch/vax/include: lock.h

Log Message:
Nix mb_* on vax.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/vax/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/vax/include/lock.h
diff -u src/sys/arch/vax/include/lock.h:1.31 src/sys/arch/vax/include/lock.h:1.32
--- src/sys/arch/vax/include/lock.h:1.31	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/vax/include/lock.h	Fri Nov 29 20:06:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.31 2017/09/17 00:01:08 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.32 2019/11/29 20:06:44 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2000 Ludd, University of Lule}, Sweden.
@@ -160,15 +160,4 @@ do {	\
 } while (/*CONSTCOND*/0)
 #endif /* MULTIPROCESSOR */
 
-static __inline void mb_read(void);
-static __inline void
-mb_read(void)
-{
-}
-
-static __inline void mb_write(void);
-static __inline void
-mb_write(void)
-{
-}
 #endif /* _VAX_LOCK_H_ */



CVS commit: src/sys/arch/vax/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:44 UTC 2019

Modified Files:
src/sys/arch/vax/include: lock.h

Log Message:
Nix mb_* on vax.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/vax/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/powerpc/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:59 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: lock.h mutex.h

Log Message:
Nix mb_* on powerpc.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:34 UTC 2019

Modified Files:
src/sys/arch/sparc/include: lock.h
src/sys/arch/sparc64/include: mutex.h

Log Message:
Nix mb_* on sparc and sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:34 UTC 2019

Modified Files:
src/sys/arch/sparc/include: lock.h
src/sys/arch/sparc64/include: mutex.h

Log Message:
Nix mb_* on sparc and sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc/include/lock.h
diff -u src/sys/arch/sparc/include/lock.h:1.32 src/sys/arch/sparc/include/lock.h:1.33
--- src/sys/arch/sparc/include/lock.h:1.32	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/sparc/include/lock.h	Fri Nov 29 20:06:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.32 2017/09/17 00:01:08 christos Exp $ */
+/*	$NetBSD: lock.h,v 1.33 2019/11/29 20:06:34 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2006 The NetBSD Foundation, Inc.
@@ -140,46 +140,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-#if defined(__sparc_v9__)
-static __inline void
-mb_read(void)
-{
-	__asm __volatile("membar #LoadLoad" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm __volatile("" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm __volatile("membar #MemIssue" : : : "memory");
-}
-#else	/* __sparc_v9__ */
-static __inline void
-mb_read(void)
-{
-	static volatile int junk;
-	__asm volatile("st %%g0,[%0]"
-	:
-	: "r" ()
-	: "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__insn_barrier();
-}
-
-static __inline void
-mb_memory(void)
-{
-	mb_read();
-}
-#endif	/* __sparc_v9__ */
-
 #endif /* _MACHINE_LOCK_H */

Index: src/sys/arch/sparc64/include/mutex.h
diff -u src/sys/arch/sparc64/include/mutex.h:1.4 src/sys/arch/sparc64/include/mutex.h:1.5
--- src/sys/arch/sparc64/include/mutex.h:1.4	Mon Apr 28 20:23:37 2008
+++ src/sys/arch/sparc64/include/mutex.h	Fri Nov 29 20:06:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2008/04/28 20:23:37 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:06:34 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -55,7 +55,11 @@ struct kmutex {
 #define __HAVE_MUTEX_STUBS		1
 #define	__HAVE_SIMPLE_MUTEXES		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
+/*
+ * XXX Should this be LoadLoad|LoadStore, or does the assumption of a
+ * preceding atomic r/m/w operation obviate the need for that?
+ */
+#define	MUTEX_RECEIVE(mtx) __asm __volatile("membar #LoadLoad" : : : "memory")
 
 /*
  * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it.



CVS commit: src/sys/arch/powerpc/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:59 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: lock.h mutex.h

Log Message:
Nix mb_* on powerpc.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/include/lock.h
diff -u src/sys/arch/powerpc/include/lock.h:1.13 src/sys/arch/powerpc/include/lock.h:1.14
--- src/sys/arch/powerpc/include/lock.h:1.13	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/powerpc/include/lock.h	Fri Nov 29 20:05:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.13 2017/09/17 00:01:08 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.14 2019/11/29 20:05:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -120,22 +120,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__asm volatile ("isync" ::: "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm volatile ("sync" ::: "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm volatile ("sync" ::: "memory");
-}
-
 #endif /* _POWERPC_LOCK_H_ */

Index: src/sys/arch/powerpc/include/mutex.h
diff -u src/sys/arch/powerpc/include/mutex.h:1.4 src/sys/arch/powerpc/include/mutex.h:1.5
--- src/sys/arch/powerpc/include/mutex.h:1.4	Mon Apr 28 20:23:32 2008
+++ src/sys/arch/powerpc/include/mutex.h	Fri Nov 29 20:05:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2008/04/28 20:23:32 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:05:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -61,8 +61,8 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
-#define	MUTEX_GIVE(mtx)			mb_memory()
+#define	MUTEX_RECEIVE(mtx)		__asm __volatile("isync" ::: "memory")
+#define	MUTEX_GIVE(mtx)			__asm __volatile("sync" ::: "memory")
 
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 



CVS commit: src/sys/arch/arm/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:19 UTC 2019

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Nix mb_* on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/include/lock.h
diff -u src/sys/arch/arm/include/lock.h:1.33 src/sys/arch/arm/include/lock.h:1.34
--- src/sys/arch/arm/include/lock.h:1.33	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/arm/include/lock.h	Fri Nov 29 20:05:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.33 2017/09/17 00:01:07 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.34 2019/11/29 20:05:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -66,11 +66,8 @@ __cpu_simple_lock_set(__cpu_simple_lock_
 }
 
 #ifdef _KERNEL
+/* XXX Formerly included for obsolete mb_* API, maybe no longer needed.  */
 #include 
-
-#define	mb_read		drain_writebuf		/* in cpufunc.h */
-#define	mb_write	drain_writebuf		/* in cpufunc.h */
-#define	mb_memory	drain_writebuf		/* in cpufunc.h */
 #endif
 
 #ifdef _ARM_ARCH_6



CVS commit: src/sys/arch/arm/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:19 UTC 2019

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Nix mb_* on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/hppa/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:29 UTC 2019

Modified Files:
src/sys/arch/hppa/include: lock.h mutex.h

Log Message:
Nix mb_* on hppa.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hppa/include/lock.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hppa/include/lock.h
diff -u src/sys/arch/hppa/include/lock.h:1.21 src/sys/arch/hppa/include/lock.h:1.22
--- src/sys/arch/hppa/include/lock.h:1.21	Tue Apr 16 12:25:17 2019
+++ src/sys/arch/hppa/include/lock.h	Fri Nov 29 20:05:29 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: lock.h,v 1.21 2019/04/16 12:25:17 skrll Exp $	*/
+/* 	$NetBSD: lock.h,v 1.22 2019/11/29 20:05:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -141,22 +141,4 @@ __cpu_simple_lock_clear(__cpu_simple_loc
 	*__aptr = __SIMPLELOCK_RAW_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__sync();
-}
-
-static __inline void
-mb_write(void)
-{
-	__sync();
-}
-
-static __inline void
-mb_memory(void)
-{
-	__sync();
-}
-
 #endif /* _HPPA_LOCK_H_ */

Index: src/sys/arch/hppa/include/mutex.h
diff -u src/sys/arch/hppa/include/mutex.h:1.13 src/sys/arch/hppa/include/mutex.h:1.14
--- src/sys/arch/hppa/include/mutex.h:1.13	Wed Oct  4 23:04:42 2017
+++ src/sys/arch/hppa/include/mutex.h	Fri Nov 29 20:05:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.13 2017/10/04 23:04:42 christos Exp $	*/
+/*	$NetBSD: mutex.h,v 1.14 2019/11/29 20:05:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -99,9 +99,9 @@ MUTEX_OWNED(uintptr_t owner)
 static inline int
 MUTEX_SET_WAITERS(struct kmutex *mtx, uintptr_t owner)
 {
-	mb_write();
+	__sync();		/* formerly mb_read */
 	mtx->mtx_waiters = 1;
-	mb_memory();
+	__sync();		/* formerly mb_memory */
 	return mtx->mtx_owner != MUTEX_ADAPTIVE_UNOWNED;
 }
 



CVS commit: src/sys/arch/m68k/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:49 UTC 2019

Modified Files:
src/sys/arch/m68k/include: lock.h mutex.h

Log Message:
Nix mb_* on m68k.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/include/lock.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/ia64/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:38 UTC 2019

Modified Files:
src/sys/arch/ia64/include: lock.h

Log Message:
Nix mb_* on ia64.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ia64/include/lock.h
diff -u src/sys/arch/ia64/include/lock.h:1.7 src/sys/arch/ia64/include/lock.h:1.8
--- src/sys/arch/ia64/include/lock.h:1.7	Thu Jan 10 17:05:56 2019
+++ src/sys/arch/ia64/include/lock.h	Fri Nov 29 20:05:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.7 2019/01/10 17:05:56 scole Exp $	*/
+/*	$NetBSD: lock.h,v 1.8 2019/11/29 20:05:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -117,24 +117,6 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 }
 
 static __inline void
-mb_read(void)
-{
-	__asm __volatile("mf	\n" ::: "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm __volatile("mf	\n" ::: "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm __volatile("mf	\n" ::: "memory");
-}
-
-static __inline void
 ia64_pause(void)
 {
 	__asm __volatile("hint @pause" ::: "memory");



CVS commit: src/sys/arch/hppa/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:29 UTC 2019

Modified Files:
src/sys/arch/hppa/include: lock.h mutex.h

Log Message:
Nix mb_* on hppa.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hppa/include/lock.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/ia64/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:38 UTC 2019

Modified Files:
src/sys/arch/ia64/include: lock.h

Log Message:
Nix mb_* on ia64.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:08 UTC 2019

Modified Files:
src/sys/arch/sh3/include: lock.h

Log Message:
Nix mb_* on sh3.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sh3/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/include/lock.h
diff -u src/sys/arch/sh3/include/lock.h:1.17 src/sys/arch/sh3/include/lock.h:1.18
--- src/sys/arch/sh3/include/lock.h:1.17	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/sh3/include/lock.h	Fri Nov 29 20:06:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.17 2017/09/17 00:01:08 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.18 2019/11/29 20:06:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -110,22 +110,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
 #endif /* !_SH3_LOCK_H_ */



CVS commit: src/sys/arch/sh3/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:08 UTC 2019

Modified Files:
src/sys/arch/sh3/include: lock.h

Log Message:
Nix mb_* on sh3.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sh3/include/lock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/m68k/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:49 UTC 2019

Modified Files:
src/sys/arch/m68k/include: lock.h mutex.h

Log Message:
Nix mb_* on m68k.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/include/lock.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/m68k/include/lock.h
diff -u src/sys/arch/m68k/include/lock.h:1.15 src/sys/arch/m68k/include/lock.h:1.16
--- src/sys/arch/m68k/include/lock.h:1.15	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/m68k/include/lock.h	Fri Nov 29 20:05:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.15 2017/09/17 00:01:07 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.16 2019/11/29 20:05:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,22 +101,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
 #endif /* _M68K_LOCK_H_ */

Index: src/sys/arch/m68k/include/mutex.h
diff -u src/sys/arch/m68k/include/mutex.h:1.7 src/sys/arch/m68k/include/mutex.h:1.8
--- src/sys/arch/m68k/include/mutex.h:1.7	Mon Apr 28 20:23:26 2008
+++ src/sys/arch/m68k/include/mutex.h	Fri Nov 29 20:05:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.7 2008/04/28 20:23:26 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.8 2019/11/29 20:05:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -62,8 +62,8 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
-#define	MUTEX_GIVE(mtx)			mb_memory()
+#define	MUTEX_RECEIVE(mtx)		__insn_barrier()
+#define	MUTEX_GIVE(mtx)			__insn_barrier()
 
 #define	MUTEX_CAS(p, o, n)		(atomic_cas_uint((p), (o), (n)) == (o))
 



CVS commit: src/sys

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:04:54 UTC 2019

Modified Files:
src/sys/arch/alpha/include: rwlock.h
src/sys/arch/arm/include: rwlock.h
src/sys/arch/hppa/include: rwlock.h
src/sys/arch/ia64/include: rwlock.h
src/sys/arch/m68k/include: rwlock.h
src/sys/arch/mips/include: rwlock.h
src/sys/arch/or1k/include: rwlock.h
src/sys/arch/powerpc/include: rwlock.h
src/sys/arch/riscv/include: rwlock.h
src/sys/arch/sh3/include: rwlock.h
src/sys/arch/sparc/include: rwlock.h
src/sys/arch/sparc64/include: rwlock.h
src/sys/arch/usermode/include: rwlock.h
src/sys/arch/vax/include: rwlock.h
src/sys/arch/x86/include: rwlock.h
src/sys/kern: kern_rwlock.c
src/sys/sys: rwlock.h

Log Message:
Largely eliminate the MD rwlock.h header file.

This was full of definitions that have been obsolete for over a
decade.  The file still remains for __HAVE_RW_STUBS but that's all.
Used only internally in kern_rwlock.c now, not by .


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/rwlock.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/include/rwlock.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/rwlock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sh3/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/rwlock.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/rwlock.h
cvs rdiff -u -r1.55 -r1.56 src/sys/kern/kern_rwlock.c
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/rwlock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/alpha/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:08 UTC 2019

Modified Files:
src/sys/arch/alpha/include: lock.h mutex.h

Log Message:
Nix mb_* on alpha.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/include/lock.h
diff -u src/sys/arch/alpha/include/lock.h:1.29 src/sys/arch/alpha/include/lock.h:1.30
--- src/sys/arch/alpha/include/lock.h:1.29	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/alpha/include/lock.h	Fri Nov 29 20:05:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.29 2017/09/17 00:01:07 christos Exp $ */
+/* $NetBSD: lock.h,v 1.30 2019/11/29 20:05:07 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -174,23 +174,4 @@ do {	\
 #define	SPINLOCK_BACKOFF_HOOK	(void)nullop((void *)0)
 #endif /* MULTIPROCESSOR */
 
-static __inline void
-mb_read(void)
-{
-	__asm __volatile("mb" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	/* XXX wmb */
-	__asm __volatile("mb" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm __volatile("mb" : : : "memory");
-}
-
 #endif /* _ALPHA_LOCK_H_ */

Index: src/sys/arch/alpha/include/mutex.h
diff -u src/sys/arch/alpha/include/mutex.h:1.4 src/sys/arch/alpha/include/mutex.h:1.5
--- src/sys/arch/alpha/include/mutex.h:1.4	Mon Apr 28 20:23:11 2008
+++ src/sys/arch/alpha/include/mutex.h	Fri Nov 29 20:05:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2008/04/28 20:23:11 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:05:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@@ -60,8 +60,8 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
-#define	MUTEX_GIVE(mtx)			mb_memory()
+#define	MUTEX_RECEIVE(mtx)		__asm __volatile("mb" : : : "memory")
+#define	MUTEX_GIVE(mtx)			__asm __volatile("mb" : : : "memory")
 
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 



CVS commit: src/sys

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:04:54 UTC 2019

Modified Files:
src/sys/arch/alpha/include: rwlock.h
src/sys/arch/arm/include: rwlock.h
src/sys/arch/hppa/include: rwlock.h
src/sys/arch/ia64/include: rwlock.h
src/sys/arch/m68k/include: rwlock.h
src/sys/arch/mips/include: rwlock.h
src/sys/arch/or1k/include: rwlock.h
src/sys/arch/powerpc/include: rwlock.h
src/sys/arch/riscv/include: rwlock.h
src/sys/arch/sh3/include: rwlock.h
src/sys/arch/sparc/include: rwlock.h
src/sys/arch/sparc64/include: rwlock.h
src/sys/arch/usermode/include: rwlock.h
src/sys/arch/vax/include: rwlock.h
src/sys/arch/x86/include: rwlock.h
src/sys/kern: kern_rwlock.c
src/sys/sys: rwlock.h

Log Message:
Largely eliminate the MD rwlock.h header file.

This was full of definitions that have been obsolete for over a
decade.  The file still remains for __HAVE_RW_STUBS but that's all.
Used only internally in kern_rwlock.c now, not by .


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/rwlock.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/include/rwlock.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/rwlock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sh3/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/rwlock.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/rwlock.h
cvs rdiff -u -r1.55 -r1.56 src/sys/kern/kern_rwlock.c
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/rwlock.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/include/rwlock.h
diff -u src/sys/arch/alpha/include/rwlock.h:1.4 src/sys/arch/alpha/include/rwlock.h:1.5
--- src/sys/arch/alpha/include/rwlock.h:1.4	Mon Apr 28 20:23:11 2008
+++ src/sys/arch/alpha/include/rwlock.h	Fri Nov 29 20:04:52 2019
@@ -1,52 +1 @@
-/*	$NetBSD: rwlock.h,v 1.4 2008/04/28 20:23:11 martin Exp $	*/
-
-/*-
- * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe and Andrew Doran.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _ALPHA_RWLOCK_H_
-#define	_ALPHA_RWLOCK_H_
-
-struct krwlock {
-	volatile uintptr_t	rw_owner;
-};
-
-#ifdef __RWLOCK_PRIVATE
-
-#define	__HAVE_SIMPLE_RW_LOCKS		1
-
-#define	RW_RECEIVE(rw)			/* nothing */
-#define	RW_GIVE(rw)			/* nothing */
-
-#define	RW_CAS(p, o, n)			_lock_cas((p), (o), (n))
-
-int	_lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
-
-#endif	/* __RWLOCK_PRIVATE */
-
-#endif /* _ALPHA_RWLOCK_H_ */
+/*	$NetBSD: rwlock.h,v 1.5 2019/11/29 20:04:52 riastradh Exp $	*/

Index: src/sys/arch/arm/include/rwlock.h
diff -u src/sys/arch/arm/include/rwlock.h:1.9 src/sys/arch/arm/include/rwlock.h:1.10
--- src/sys/arch/arm/include/rwlock.h:1.9	Wed Feb 25 13:52:42 2015
+++ src/sys/arch/arm/include/rwlock.h	Fri Nov 29 20:04:52 2019
@@ -1,61 +1 @@
-/*	$NetBSD: rwlock.h,v 1.9 2015/02/25 13:52:42 joerg Exp $	*/
-
-/*-

CVS commit: src/sys/arch/alpha/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:08 UTC 2019

Modified Files:
src/sys/arch/alpha/include: lock.h mutex.h

Log Message:
Nix mb_* on alpha.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/mutex.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/kern

2019-11-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Nov 25 15:19:54 UTC 2019

Modified Files:
src/sys/kern: subr_cprng.c

Log Message:
Use cprng_strong, not cprng_fast, for sysctl kern.arnd.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/subr_cprng.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_cprng.c
diff -u src/sys/kern/subr_cprng.c:1.32 src/sys/kern/subr_cprng.c:1.33
--- src/sys/kern/subr_cprng.c:1.32	Sun Nov 17 12:32:31 2019
+++ src/sys/kern/subr_cprng.c	Mon Nov 25 15:19:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cprng.c,v 1.32 2019/11/17 12:32:31 nia Exp $ */
+/*	$NetBSD: subr_cprng.c,v 1.33 2019/11/25 15:19:54 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.32 2019/11/17 12:32:31 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.33 2019/11/25 15:19:54 riastradh Exp $");
 
 #include 
 #include 
@@ -539,6 +539,7 @@ cprng_strong_rndsink_callback(void *cont
 	mutex_exit(>cs_lock);
 }
 
+static ONCE_DECL(sysctl_prng_once);
 static cprng_strong_t *sysctl_prng;
 
 static int
@@ -558,10 +559,9 @@ makeprng(void)
 static int
 sysctl_kern_urnd(SYSCTLFN_ARGS)
 {
-	static ONCE_DECL(control);
 	int v, rv;
 
-	RUN_ONCE(, makeprng);
+	RUN_ONCE(_prng_once, makeprng);
 	rv = cprng_strong(sysctl_prng, , sizeof(v), 0);
 	if (rv == sizeof(v)) {
 		struct sysctlnode node = *rnode;
@@ -591,6 +591,7 @@ sysctl_kern_arnd(SYSCTLFN_ARGS)
 	int error;
 	void *v;
 	struct sysctlnode node = *rnode;
+	size_t n __diagused;
 
 	switch (*oldlenp) {
 	case 0:
@@ -599,8 +600,10 @@ sysctl_kern_arnd(SYSCTLFN_ARGS)
 		if (*oldlenp > 256) {
 			return E2BIG;
 		}
+		RUN_ONCE(_prng_once, makeprng);
 		v = kmem_alloc(*oldlenp, KM_SLEEP);
-		cprng_fast(v, *oldlenp);
+		n = cprng_strong(sysctl_prng, v, *oldlenp, 0);
+		KASSERT(n == *oldlenp);
 		node.sysctl_data = v;
 		node.sysctl_size = *oldlenp;
 		error = sysctl_lookup(SYSCTLFN_CALL());



CVS commit: src/sys/kern

2019-11-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Nov 25 15:19:54 UTC 2019

Modified Files:
src/sys/kern: subr_cprng.c

Log Message:
Use cprng_strong, not cprng_fast, for sysctl kern.arnd.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/subr_cprng.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/crypto/nist_hash_drbg

2019-09-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Sep 19 18:29:55 UTC 2019

Modified Files:
src/sys/crypto/nist_hash_drbg: nist_hash_drbg.c

Log Message:
Use an explicit run-time assertion where compile-time doesn't work.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c
diff -u src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.2 src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.3
--- src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.2	Thu Sep 19 14:34:59 2019
+++ src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c	Thu Sep 19 18:29:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nist_hash_drbg.c,v 1.2 2019/09/19 14:34:59 riastradh Exp $	*/
+/*	$NetBSD: nist_hash_drbg.c,v 1.3 2019/09/19 18:29:55 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
 
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nist_hash_drbg.c,v 1.2 2019/09/19 14:34:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nist_hash_drbg.c,v 1.3 2019/09/19 18:29:55 riastradh Exp $");
 #endif
 
 #include 
@@ -1009,10 +1009,6 @@ static const struct {
 #define	CHECK(i, name, actual, expected, n) do  \
 {	  \
 	CTASSERT(sizeof(actual) == (n));  \
-	CTASSERT(__builtin_constant_p(n) ? sizeof(actual) == (n) : 1);	  \
-	ASSERT(__builtin_constant_p(n) ? 1 : sizeof(actual) >= (n));	  \
-	CTASSERT(__builtin_constant_p(n) ? sizeof(expected) == (n) : 1);  \
-	ASSERT(__builtin_constant_p(n) ? 1 : sizeof(expected) >= (n));	  \
 	ok &= check(i, name, actual, expected, (n));			  \
 } while (0)
 
@@ -1091,7 +1087,9 @@ nist_hash_drbg_initialize(void)
 			kat[i].reseed ? 0 : kat[i].additional[0]->hv_len);
 			reseed_counter++;
 			CHECK(i, "V[1]", D->V, kat[i].V[1], SEEDLEN_BYTES);
-			CHECK(i, "rnd_val[0]", rnd_val, kat[i].rnd_val[0],
+			ASSERT(sizeof(kat[i].rnd_val[0]) - trunc <=
+			sizeof rnd_val);
+			check(i, "rnd_val[0]", rnd_val, kat[i].rnd_val[0],
 			sizeof(kat[i].rnd_val[0]) - trunc);
 			if (D->reseed_counter != reseed_counter) {
 DPRINTF("bad reseed counter: %u, expected %u",
@@ -1113,7 +,9 @@ nist_hash_drbg_initialize(void)
 			kat[i].reseed ? 0 : kat[i].additional[1]->hv_len);
 			reseed_counter++;
 			CHECK(i, "V[2]", D->V, kat[i].V[2], SEEDLEN_BYTES);
-			CHECK(i, "rnd_val[1]", rnd_val, kat[i].rnd_val[1],
+			ASSERT(sizeof(kat[i].rnd_val[1]) - trunc <=
+			sizeof rnd_val);
+			check(i, "rnd_val[1]", rnd_val, kat[i].rnd_val[1],
 			sizeof(kat[i].rnd_val[1]) - trunc);
 			if (D->reseed_counter != reseed_counter) {
 DPRINTF("bad reseed counter: %u, expected %u",



CVS commit: src/sys/crypto/nist_hash_drbg

2019-09-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Sep 19 18:29:55 UTC 2019

Modified Files:
src/sys/crypto/nist_hash_drbg: nist_hash_drbg.c

Log Message:
Use an explicit run-time assertion where compile-time doesn't work.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/crypto/nist_hash_drbg

2019-09-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Sep 19 14:35:00 UTC 2019

Modified Files:
src/sys/crypto/nist_hash_drbg: nist_hash_drbg.c

Log Message:
Use CTASSERT where possible, run-time assertion where not.

Should fix negative-length variable-length array found by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/crypto/nist_hash_drbg

2019-09-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Sep 19 14:35:00 UTC 2019

Modified Files:
src/sys/crypto/nist_hash_drbg: nist_hash_drbg.c

Log Message:
Use CTASSERT where possible, run-time assertion where not.

Should fix negative-length variable-length array found by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c
diff -u src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.1 src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.2
--- src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.1	Mon Sep  2 20:09:29 2019
+++ src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c	Thu Sep 19 14:34:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nist_hash_drbg.c,v 1.1 2019/09/02 20:09:29 riastradh Exp $	*/
+/*	$NetBSD: nist_hash_drbg.c,v 1.2 2019/09/19 14:34:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
 
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nist_hash_drbg.c,v 1.1 2019/09/02 20:09:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nist_hash_drbg.c,v 1.2 2019/09/19 14:34:59 riastradh Exp $");
 #endif
 
 #include 
@@ -1009,6 +1009,10 @@ static const struct {
 #define	CHECK(i, name, actual, expected, n) do  \
 {	  \
 	CTASSERT(sizeof(actual) == (n));  \
+	CTASSERT(__builtin_constant_p(n) ? sizeof(actual) == (n) : 1);	  \
+	ASSERT(__builtin_constant_p(n) ? 1 : sizeof(actual) >= (n));	  \
+	CTASSERT(__builtin_constant_p(n) ? sizeof(expected) == (n) : 1);  \
+	ASSERT(__builtin_constant_p(n) ? 1 : sizeof(expected) >= (n));	  \
 	ok &= check(i, name, actual, expected, (n));			  \
 } while (0)
 



CVS commit: src/share/man/man4

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep  4 04:03:25 UTC 2019

Modified Files:
src/share/man/man4: rnd.4

Log Message:
Update NIST SP800-90A reference.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/share/man/man4/rnd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/rnd.4
diff -u src/share/man/man4/rnd.4:1.26 src/share/man/man4/rnd.4:1.27
--- src/share/man/man4/rnd.4:1.26	Wed Sep  4 04:00:04 2019
+++ src/share/man/man4/rnd.4	Wed Sep  4 04:03:25 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rnd.4,v 1.26 2019/09/04 04:00:04 riastradh Exp $
+.\"	$NetBSD: rnd.4,v 1.27 2019/09/04 04:03:25 riastradh Exp $
 .\"
 .\" Copyright (c) 2014 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -489,10 +489,10 @@ Never blocks.
 .%A Elaine Barker
 .%A John Kelsey
 .%T Recommendation for Random Number Generation Using Deterministic Random Bit Generators
-.%D January 2012
+.%D June 2015
 .%I National Institute of Standards and Technology
-.%O NIST Special Publication 800-90A
-.%U http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf
+.%O NIST Special Publication 800-90A, Revision 1
+.%U https://csrc.nist.gov/publications/detail/sp/800-90a/rev-1/final
 .Re
 .Rs
 .%A Daniel J. Bernstein



CVS commit: src/share/man/man4

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep  4 04:03:25 UTC 2019

Modified Files:
src/share/man/man4: rnd.4

Log Message:
Update NIST SP800-90A reference.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/share/man/man4/rnd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/share/man/man4

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep  4 04:00:04 UTC 2019

Modified Files:
src/share/man/man4: rnd.4

Log Message:
Replace slightly wrong rant by shorter and slightly less long rant.

(If X and Y in Z/2Z are independent, then so are X and X+Y.  What was
I thinking.)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/share/man/man4/rnd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/rnd.4
diff -u src/share/man/man4/rnd.4:1.25 src/share/man/man4/rnd.4:1.26
--- src/share/man/man4/rnd.4:1.25	Wed Sep  4 03:15:20 2019
+++ src/share/man/man4/rnd.4	Wed Sep  4 04:00:04 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rnd.4,v 1.25 2019/09/04 03:15:20 riastradh Exp $
+.\"	$NetBSD: rnd.4,v 1.26 2019/09/04 04:00:04 riastradh Exp $
 .\"
 .\" Copyright (c) 2014 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -551,50 +551,27 @@ Unfortunately, no amount of software eng
 .Sh ENTROPY ACCOUNTING
 The entropy accounting described here is not grounded in any
 cryptography theory.
-It is done because it was always done, and because it gives people a
-warm fuzzy feeling about information theory.
+.Sq Entropy estimation
+doesn't mean much: the kernel hypothesizes an extremely simple-minded
+parametric model for all entropy sources which bears little relation to
+any physical processes, implicitly fits parameters from data, and
+accounts for the entropy of the fitted model.
 .Pp
-The folklore is that every
-.Fa n Ns -bit
-output of
-.Fa /dev/random
-is not merely indistinguishable from uniform random to a
-computationally bounded attacker, but information-theoretically is
-independent and has
-.Fa n
-bits of entropy even to a computationally
-.Em unbounded
-attacker -- that is, an attacker who can recover AES keys, compute
-SHA-1 preimages, etc.
-This property is not provided, nor was it ever provided in any
-implementation of
-.Fa /dev/random
-known to the author.
-.Pp
-This property would require that, after each read, the system discard
-all measurements from hardware in the entropy pool and begin anew.
-All work done to make the system unpredictable would be thrown out, and
-the system would immediately become predictable again.
-Reverting the system to being predictable every time a process reads
-from
-.Fa /dev/random
-would give attackers a tremendous advantage in predicting future
-outputs, especially if they can fool the entropy estimator, e.g. by
-sending carefully timed network packets.
-.Pp
-If you filled your entropy pool by flipping a coin 256 times, you would
-have to flip it again 256 times for the next output, and so on.
-In that case, if you really want information-theoretic guarantees, you
-might as well take
-.Fa /dev/random
-out of the picture and use your coin flips verbatim.
-.Pp
-On the other hand, every cryptographic protocol in practice, including
-HTTPS, SSH, PGP, etc., expands short secrets deterministically into
-long streams of bits, and their security relies on conjectures that a
-computationally bounded attacker cannot distinguish the long streams
-from uniform random.
-If we couldn't do that for
+Past versions of the
+.Nm
+subsystem were concerned with
+.Sq information-theoretic
+security, under the premise that the number of bits of entropy out must
+not exceed the number of bits of entropy in -- never mind that its
+.Sq entropy estimation
+is essentially meaningless without a model for the physical processes
+the system is observing.
+.Pp
+But every cryptographic protocol in practice, including HTTPS, SSH,
+PGP, etc., expands short secrets deterministically into long streams of
+bits, and their security relies on conjectures that a computationally
+bounded attacker cannot distinguish the long streams from uniform
+random.  If we couldn't do that for
 .Fa /dev/random ,
 it would be hopeless to assume we could for HTTPS, SSH, PGP, etc.
 .Pp
@@ -603,7 +580,3 @@ system engineering for random number gen
 Nobody has ever reported distinguishing SHA-256 hashes with secret
 inputs from uniform random, nor reported computing SHA-1 preimages
 faster than brute force.
-The folklore information-theoretic defence against computationally
-unbounded attackers replaces system engineering that successfully
-defends against realistic threat models by imaginary theory that
-defends only against fantasy threat models.



CVS commit: src/share/man/man4

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep  4 04:00:04 UTC 2019

Modified Files:
src/share/man/man4: rnd.4

Log Message:
Replace slightly wrong rant by shorter and slightly less long rant.

(If X and Y in Z/2Z are independent, then so are X and X+Y.  What was
I thinking.)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/share/man/man4/rnd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/share/man/man4

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep  4 03:15:20 UTC 2019

Modified Files:
src/share/man/man4: rnd.4

Log Message:
Update man page to reflect switch from CTR_DRBG to Hash_DRBG.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/share/man/man4/rnd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/rnd.4
diff -u src/share/man/man4/rnd.4:1.24 src/share/man/man4/rnd.4:1.25
--- src/share/man/man4/rnd.4:1.24	Wed Jan 18 22:38:00 2017
+++ src/share/man/man4/rnd.4	Wed Sep  4 03:15:20 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rnd.4,v 1.24 2017/01/18 22:38:00 abhinav Exp $
+.\"	$NetBSD: rnd.4,v 1.25 2019/09/04 03:15:20 riastradh Exp $
 .\"
 .\" Copyright (c) 2014 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 16, 2014
+.Dd September 3, 2019
 .Dt RND 4
 .Os
 .Sh NAME
@@ -404,9 +404,9 @@ When a user process opens
 or
 .Pa /dev/urandom
 and first reads from it, the kernel draws from the entropy pool to seed
-a cryptographic pseudorandom number generator, the NIST CTR_DRBG
-(counter-mode deterministic random bit generator) with AES-128 as the
-block cipher, and uses that to generate data.
+a cryptographic pseudorandom number generator, the NIST Hash_DRBG
+(hash-based deterministic random bit generator) with SHA-256 as the
+hash function, and uses that to generate data.
 .Pp
 To draw a seed from the entropy pool, the kernel
 .Bl -bullet -offset abcd -compact
@@ -600,8 +600,8 @@ it would be hopeless to assume we could 
 .Pp
 History is littered with examples of broken entropy sources and failed
 system engineering for random number generators.
-Nobody has ever reported distinguishing AES ciphertext from uniform
-random without side channels, nor reported computing SHA-1 preimages
+Nobody has ever reported distinguishing SHA-256 hashes with secret
+inputs from uniform random, nor reported computing SHA-1 preimages
 faster than brute force.
 The folklore information-theoretic defence against computationally
 unbounded attackers replaces system engineering that successfully



CVS commit: src/share/man/man4

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep  4 03:15:20 UTC 2019

Modified Files:
src/share/man/man4: rnd.4

Log Message:
Update man page to reflect switch from CTR_DRBG to Hash_DRBG.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/share/man/man4/rnd.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  3 15:38:52 UTC 2019

Modified Files:
src: UPDATING

Log Message:
Add UPDATING note about radeon firmware image mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/UPDATING

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  3 15:38:52 UTC 2019

Modified Files:
src: UPDATING

Log Message:
Add UPDATING note about radeon firmware image mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/UPDATING

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/UPDATING
diff -u src/UPDATING:1.301 src/UPDATING:1.302
--- src/UPDATING:1.301	Sat Jul 27 07:55:18 2019
+++ src/UPDATING	Tue Sep  3 15:38:52 2019
@@ -1,4 +1,4 @@
-$NetBSD: UPDATING,v 1.301 2019/07/27 07:55:18 martin Exp $
+$NetBSD: UPDATING,v 1.302 2019/09/03 15:38:52 riastradh Exp $
 
 This file (UPDATING) is intended to be a brief reference to recent
 changes that might cause problems in the build process, and a guide for
@@ -19,6 +19,87 @@ See also: BUILDING, build.sh, Makefile.
 Recent changes:
 ^^^
 
+20190903:
+
+	File with names that coincide with existing files' names on
+	case-insensitive file systems were inadvertently committed, for
+	radeon GPU firmware.  We cannot mark these as obsolete for
+	postinstall to fix, so if you updated src since 2019-08-26, and
+	ran build.sh distribution or ran build.sh release, you must
+	manually delete the following files in your DESTDIR (which is
+	usually $OBJDIR/destir.$ARCH), or from / if you have installed
+	them:
+
+		/libdata/firmware/radeon/bonaire_ce.bin
+		/libdata/firmware/radeon/bonaire_mc.bin
+		/libdata/firmware/radeon/bonaire_me.bin
+		/libdata/firmware/radeon/bonaire_mec.bin
+		/libdata/firmware/radeon/bonaire_pfp.bin
+		/libdata/firmware/radeon/bonaire_rlc.bin
+		/libdata/firmware/radeon/bonaire_sdma.bin
+		/libdata/firmware/radeon/bonaire_smc.bin
+		/libdata/firmware/radeon/bonaire_uvd.bin
+		/libdata/firmware/radeon/hainan_ce.bin
+		/libdata/firmware/radeon/hainan_mc.bin
+		/libdata/firmware/radeon/hainan_me.bin
+		/libdata/firmware/radeon/hainan_pfp.bin
+		/libdata/firmware/radeon/hainan_rlc.bin
+		/libdata/firmware/radeon/hainan_smc.bin
+		/libdata/firmware/radeon/hawaii_ce.bin
+		/libdata/firmware/radeon/hawaii_mc.bin
+		/libdata/firmware/radeon/hawaii_me.bin
+		/libdata/firmware/radeon/hawaii_mec.bin
+		/libdata/firmware/radeon/hawaii_pfp.bin
+		/libdata/firmware/radeon/hawaii_rlc.bin
+		/libdata/firmware/radeon/hawaii_sdma.bin
+		/libdata/firmware/radeon/hawaii_smc.bin
+		/libdata/firmware/radeon/kabini_ce.bin
+		/libdata/firmware/radeon/kabini_me.bin
+		/libdata/firmware/radeon/kabini_mec.bin
+		/libdata/firmware/radeon/kabini_pfp.bin
+		/libdata/firmware/radeon/kabini_rlc.bin
+		/libdata/firmware/radeon/kabini_sdma.bin
+		/libdata/firmware/radeon/kaveri_ce.bin
+		/libdata/firmware/radeon/kaveri_me.bin
+		/libdata/firmware/radeon/kaveri_mec.bin
+		/libdata/firmware/radeon/kaveri_mec2.bin
+		/libdata/firmware/radeon/kaveri_pfp.bin
+		/libdata/firmware/radeon/kaveri_rlc.bin
+		/libdata/firmware/radeon/kaveri_sdma.bin
+		/libdata/firmware/radeon/mullins_ce.bin
+		/libdata/firmware/radeon/mullins_me.bin
+		/libdata/firmware/radeon/mullins_mec.bin
+		/libdata/firmware/radeon/mullins_pfp.bin
+		/libdata/firmware/radeon/mullins_rlc.bin
+		/libdata/firmware/radeon/mullins_sdma.bin
+		/libdata/firmware/radeon/oland_ce.bin
+		/libdata/firmware/radeon/oland_mc.bin
+		/libdata/firmware/radeon/oland_me.bin
+		/libdata/firmware/radeon/oland_pfp.bin
+		/libdata/firmware/radeon/oland_rlc.bin
+		/libdata/firmware/radeon/oland_smc.bin
+		/libdata/firmware/radeon/pitcairn_ce.bin
+		/libdata/firmware/radeon/pitcairn_mc.bin
+		/libdata/firmware/radeon/pitcairn_me.bin
+		/libdata/firmware/radeon/pitcairn_pfp.bin
+		/libdata/firmware/radeon/pitcairn_rlc.bin
+		/libdata/firmware/radeon/pitcairn_smc.bin
+		/libdata/firmware/radeon/tahiti_ce.bin
+		/libdata/firmware/radeon/tahiti_mc.bin
+		/libdata/firmware/radeon/tahiti_me.bin
+		/libdata/firmware/radeon/tahiti_pfp.bin
+		/libdata/firmware/radeon/tahiti_rlc.bin
+		/libdata/firmware/radeon/tahiti_smc.bin
+		/libdata/firmware/radeon/verde_ce.bin
+		/libdata/firmware/radeon/verde_mc.bin
+		/libdata/firmware/radeon/verde_me.bin
+		/libdata/firmware/radeon/verde_pfp.bin
+		/libdata/firmware/radeon/verde_rlc.bin
+		/libdata/firmware/radeon/verde_smc.bin
+
+	We will re-import these radeon firmware images another way
+	later.
+
 20190727:
 	The uefi bootloader has gained tftp support and needs a clean
 	build. If you do update builds, manually clean its object



CVS commit: src

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  3 15:34:08 UTC 2019

Modified Files:
src/distrib/sets/lists/base: mi
src/sys/dev/microcode/radeon: Makefile
Removed Files:
src/sys/dev/microcode/radeon: bonaire_ce.bin bonaire_mc.bin
bonaire_me.bin bonaire_mec.bin bonaire_pfp.bin bonaire_rlc.bin
bonaire_sdma.bin bonaire_smc.bin bonaire_uvd.bin hainan_ce.bin
hainan_mc.bin hainan_me.bin hainan_pfp.bin hainan_rlc.bin
hainan_smc.bin hawaii_ce.bin hawaii_mc.bin hawaii_me.bin
hawaii_mec.bin hawaii_pfp.bin hawaii_rlc.bin hawaii_sdma.bin
hawaii_smc.bin kabini_ce.bin kabini_me.bin kabini_mec.bin
kabini_pfp.bin kabini_rlc.bin kabini_sdma.bin kaveri_ce.bin
kaveri_me.bin kaveri_mec.bin kaveri_mec2.bin kaveri_pfp.bin
kaveri_rlc.bin kaveri_sdma.bin mullins_ce.bin mullins_me.bin
mullins_mec.bin mullins_pfp.bin mullins_rlc.bin mullins_sdma.bin
oland_ce.bin oland_mc.bin oland_me.bin oland_pfp.bin oland_rlc.bin
oland_smc.bin pitcairn_ce.bin pitcairn_mc.bin pitcairn_me.bin
pitcairn_pfp.bin pitcairn_rlc.bin pitcairn_smc.bin tahiti_ce.bin
tahiti_mc.bin tahiti_me.bin tahiti_pfp.bin tahiti_rlc.bin
tahiti_smc.bin verde_ce.bin verde_mc.bin verde_me.bin verde_pfp.bin
verde_rlc.bin verde_smc.bin

Log Message:
Revert "Add more missing firmwares."

This reverts
https://mail-index.NetBSD.org/source-changes/2019/08/27/msg108499.html
which broke the tree on case-insensitive file systems.

See discussion at
https://mail-index.NetBSD.org/source-changes-d/2019/08/27/msg011590.html
for alternatives considered.

This does _not_ simply mark the new files as `obsolete' in the set
lists, because if we marked foo.bin obsolete then on a case-
insensitive file system, then it would try to delete the FOO.bin that
we still want installed.  We'll require a manual change announced in
UPDATING and on current-users.

ok msaitoh


To generate a diff of this commit:
cvs rdiff -u -r1.1213 -r1.1214 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/microcode/radeon/Makefile
cvs rdiff -u -r1.1 -r0 src/sys/dev/microcode/radeon/bonaire_ce.bin \
src/sys/dev/microcode/radeon/bonaire_mc.bin \
src/sys/dev/microcode/radeon/bonaire_me.bin \
src/sys/dev/microcode/radeon/bonaire_mec.bin \
src/sys/dev/microcode/radeon/bonaire_pfp.bin \
src/sys/dev/microcode/radeon/bonaire_rlc.bin \
src/sys/dev/microcode/radeon/bonaire_sdma.bin \
src/sys/dev/microcode/radeon/bonaire_smc.bin \
src/sys/dev/microcode/radeon/bonaire_uvd.bin \
src/sys/dev/microcode/radeon/hainan_ce.bin \
src/sys/dev/microcode/radeon/hainan_mc.bin \
src/sys/dev/microcode/radeon/hainan_me.bin \
src/sys/dev/microcode/radeon/hainan_pfp.bin \
src/sys/dev/microcode/radeon/hainan_rlc.bin \
src/sys/dev/microcode/radeon/hainan_smc.bin \
src/sys/dev/microcode/radeon/hawaii_ce.bin \
src/sys/dev/microcode/radeon/hawaii_mc.bin \
src/sys/dev/microcode/radeon/hawaii_me.bin \
src/sys/dev/microcode/radeon/hawaii_mec.bin \
src/sys/dev/microcode/radeon/hawaii_pfp.bin \
src/sys/dev/microcode/radeon/hawaii_rlc.bin \
src/sys/dev/microcode/radeon/hawaii_sdma.bin \
src/sys/dev/microcode/radeon/hawaii_smc.bin \
src/sys/dev/microcode/radeon/kabini_ce.bin \
src/sys/dev/microcode/radeon/kabini_me.bin \
src/sys/dev/microcode/radeon/kabini_mec.bin \
src/sys/dev/microcode/radeon/kabini_pfp.bin \
src/sys/dev/microcode/radeon/kabini_rlc.bin \
src/sys/dev/microcode/radeon/kabini_sdma.bin \
src/sys/dev/microcode/radeon/kaveri_ce.bin \
src/sys/dev/microcode/radeon/kaveri_me.bin \
src/sys/dev/microcode/radeon/kaveri_mec.bin \
src/sys/dev/microcode/radeon/kaveri_mec2.bin \
src/sys/dev/microcode/radeon/kaveri_pfp.bin \
src/sys/dev/microcode/radeon/kaveri_rlc.bin \
src/sys/dev/microcode/radeon/kaveri_sdma.bin \
src/sys/dev/microcode/radeon/mullins_ce.bin \
src/sys/dev/microcode/radeon/mullins_me.bin \
src/sys/dev/microcode/radeon/mullins_mec.bin \
src/sys/dev/microcode/radeon/mullins_pfp.bin \
src/sys/dev/microcode/radeon/mullins_rlc.bin \
src/sys/dev/microcode/radeon/mullins_sdma.bin \
src/sys/dev/microcode/radeon/oland_ce.bin \
src/sys/dev/microcode/radeon/oland_mc.bin \
src/sys/dev/microcode/radeon/oland_me.bin \
src/sys/dev/microcode/radeon/oland_pfp.bin \
src/sys/dev/microcode/radeon/oland_rlc.bin \
src/sys/dev/microcode/radeon/oland_smc.bin \
src/sys/dev/microcode/radeon/pitcairn_ce.bin \
src/sys/dev/microcode/radeon/pitcairn_mc.bin \
src/sys/dev/microcode/radeon/pitcairn_me.bin \
src/sys/dev/microcode/radeon/pitcairn_pfp.bin \
src/sys/dev/microcode/radeon/pitcairn_rlc.bin \
src/sys/dev/microcode/radeon/pitcairn_smc.bin \
src/sys/dev/microcode/radeon/tahiti_ce.bin \

CVS commit: src

2019-09-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Sep  3 15:34:08 UTC 2019

Modified Files:
src/distrib/sets/lists/base: mi
src/sys/dev/microcode/radeon: Makefile
Removed Files:
src/sys/dev/microcode/radeon: bonaire_ce.bin bonaire_mc.bin
bonaire_me.bin bonaire_mec.bin bonaire_pfp.bin bonaire_rlc.bin
bonaire_sdma.bin bonaire_smc.bin bonaire_uvd.bin hainan_ce.bin
hainan_mc.bin hainan_me.bin hainan_pfp.bin hainan_rlc.bin
hainan_smc.bin hawaii_ce.bin hawaii_mc.bin hawaii_me.bin
hawaii_mec.bin hawaii_pfp.bin hawaii_rlc.bin hawaii_sdma.bin
hawaii_smc.bin kabini_ce.bin kabini_me.bin kabini_mec.bin
kabini_pfp.bin kabini_rlc.bin kabini_sdma.bin kaveri_ce.bin
kaveri_me.bin kaveri_mec.bin kaveri_mec2.bin kaveri_pfp.bin
kaveri_rlc.bin kaveri_sdma.bin mullins_ce.bin mullins_me.bin
mullins_mec.bin mullins_pfp.bin mullins_rlc.bin mullins_sdma.bin
oland_ce.bin oland_mc.bin oland_me.bin oland_pfp.bin oland_rlc.bin
oland_smc.bin pitcairn_ce.bin pitcairn_mc.bin pitcairn_me.bin
pitcairn_pfp.bin pitcairn_rlc.bin pitcairn_smc.bin tahiti_ce.bin
tahiti_mc.bin tahiti_me.bin tahiti_pfp.bin tahiti_rlc.bin
tahiti_smc.bin verde_ce.bin verde_mc.bin verde_me.bin verde_pfp.bin
verde_rlc.bin verde_smc.bin

Log Message:
Revert "Add more missing firmwares."

This reverts
https://mail-index.NetBSD.org/source-changes/2019/08/27/msg108499.html
which broke the tree on case-insensitive file systems.

See discussion at
https://mail-index.NetBSD.org/source-changes-d/2019/08/27/msg011590.html
for alternatives considered.

This does _not_ simply mark the new files as `obsolete' in the set
lists, because if we marked foo.bin obsolete then on a case-
insensitive file system, then it would try to delete the FOO.bin that
we still want installed.  We'll require a manual change announced in
UPDATING and on current-users.

ok msaitoh


To generate a diff of this commit:
cvs rdiff -u -r1.1213 -r1.1214 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/microcode/radeon/Makefile
cvs rdiff -u -r1.1 -r0 src/sys/dev/microcode/radeon/bonaire_ce.bin \
src/sys/dev/microcode/radeon/bonaire_mc.bin \
src/sys/dev/microcode/radeon/bonaire_me.bin \
src/sys/dev/microcode/radeon/bonaire_mec.bin \
src/sys/dev/microcode/radeon/bonaire_pfp.bin \
src/sys/dev/microcode/radeon/bonaire_rlc.bin \
src/sys/dev/microcode/radeon/bonaire_sdma.bin \
src/sys/dev/microcode/radeon/bonaire_smc.bin \
src/sys/dev/microcode/radeon/bonaire_uvd.bin \
src/sys/dev/microcode/radeon/hainan_ce.bin \
src/sys/dev/microcode/radeon/hainan_mc.bin \
src/sys/dev/microcode/radeon/hainan_me.bin \
src/sys/dev/microcode/radeon/hainan_pfp.bin \
src/sys/dev/microcode/radeon/hainan_rlc.bin \
src/sys/dev/microcode/radeon/hainan_smc.bin \
src/sys/dev/microcode/radeon/hawaii_ce.bin \
src/sys/dev/microcode/radeon/hawaii_mc.bin \
src/sys/dev/microcode/radeon/hawaii_me.bin \
src/sys/dev/microcode/radeon/hawaii_mec.bin \
src/sys/dev/microcode/radeon/hawaii_pfp.bin \
src/sys/dev/microcode/radeon/hawaii_rlc.bin \
src/sys/dev/microcode/radeon/hawaii_sdma.bin \
src/sys/dev/microcode/radeon/hawaii_smc.bin \
src/sys/dev/microcode/radeon/kabini_ce.bin \
src/sys/dev/microcode/radeon/kabini_me.bin \
src/sys/dev/microcode/radeon/kabini_mec.bin \
src/sys/dev/microcode/radeon/kabini_pfp.bin \
src/sys/dev/microcode/radeon/kabini_rlc.bin \
src/sys/dev/microcode/radeon/kabini_sdma.bin \
src/sys/dev/microcode/radeon/kaveri_ce.bin \
src/sys/dev/microcode/radeon/kaveri_me.bin \
src/sys/dev/microcode/radeon/kaveri_mec.bin \
src/sys/dev/microcode/radeon/kaveri_mec2.bin \
src/sys/dev/microcode/radeon/kaveri_pfp.bin \
src/sys/dev/microcode/radeon/kaveri_rlc.bin \
src/sys/dev/microcode/radeon/kaveri_sdma.bin \
src/sys/dev/microcode/radeon/mullins_ce.bin \
src/sys/dev/microcode/radeon/mullins_me.bin \
src/sys/dev/microcode/radeon/mullins_mec.bin \
src/sys/dev/microcode/radeon/mullins_pfp.bin \
src/sys/dev/microcode/radeon/mullins_rlc.bin \
src/sys/dev/microcode/radeon/mullins_sdma.bin \
src/sys/dev/microcode/radeon/oland_ce.bin \
src/sys/dev/microcode/radeon/oland_mc.bin \
src/sys/dev/microcode/radeon/oland_me.bin \
src/sys/dev/microcode/radeon/oland_pfp.bin \
src/sys/dev/microcode/radeon/oland_rlc.bin \
src/sys/dev/microcode/radeon/oland_smc.bin \
src/sys/dev/microcode/radeon/pitcairn_ce.bin \
src/sys/dev/microcode/radeon/pitcairn_mc.bin \
src/sys/dev/microcode/radeon/pitcairn_me.bin \
src/sys/dev/microcode/radeon/pitcairn_pfp.bin \
src/sys/dev/microcode/radeon/pitcairn_rlc.bin \
src/sys/dev/microcode/radeon/pitcairn_smc.bin \
src/sys/dev/microcode/radeon/tahiti_ce.bin \

Re: CVS commit: src

2019-09-03 Thread Taylor R Campbell
> Date: Tue, 3 Sep 2019 04:07:16 +
> From: Taylor R Campbell 
> 
> 1. We could simply revert the commits, but that will nevertheless
>break checkout by date on case-insensitive file systems, which
>implies breaking bisection over the past week on case-insensitive
>file systems.

I'm just going to revert the one commit once I've done a distribution
build to confirm it worked; explain what happened in UPDATING and send
an announcement to current-users about deleting the files manually;
and then sort out how to reimport later.

This does mean checkout-by-date will fail on case-insensitive file
systems, but bisection will continue to work for everyone else -- I'm
not seeing a way to improve on that outcome.


Re: CVS commit: src

2019-09-03 Thread Taylor R Campbell
> Date: Tue, 03 Sep 2019 12:36:31 +0700
> From: Robert Elz 
> 
> Date:Tue, 3 Sep 2019 04:07:16 +
>     From:    Taylor R Campbell 
> 
> Message-ID:  <20190903040716.a6abe60...@jupiter.mumble.net>
> 
>   | How do we clean it up?
> 
>   | I am not seeing a good way out of this.
> 
> I do, but you are all refusing to permit it ... simply abandon support
> for case insensitive filesystems.

That's not a good way out of it.  Instead of causing bisection to fail
on one week for ordinary users on macOS, it prevents them from working
on NetBSD at all without jumping through hoops to pass a considerably
higher barrier to entry.

Yes, there are ways to overcome that barrier to entry with enough
effort.  But if that barrier to entry had been around when I started
using NetBSD, I probably wouldn't be here today.


Re: CVS commit: src

2019-09-02 Thread Taylor R Campbell
> Date: Mon, 2 Sep 2019 14:23:14 +
> From: Taylor R Campbell 
> 
> > Date: Mon, 2 Sep 2019 16:53:34 +0900
> > From: Masanobu SAITOH 
> > 
> > d) Any other options.
> 
> 1. Revert the commit for now, ASAP, to unblock people.

So, it turns out this is more complicated than I thought.

msaitoh pointed out that since the files have now been installed, it
seems appropriate to mark them as obsolete when reverting the commit.

However, if we add them to obsolete, then I expect that on a case-
insensitive file system, when build.sh distribution runs postinstall
on $DESTDIR, and it tries to delete the new (bad) files, it will have
the effect of deleting the old (good) files too because their names
differ only in case.

So we need to clean this up _without_ marking anything as obsolete
(and then add a note to UPDATING and post an announcement to
current-users explaining what happened and advising everyone to
manually delete the new (bad) files).


How do we clean it up?

1. We could simply revert the commits, but that will nevertheless
   break checkout by date on case-insensitive file systems, which
   implies breaking bisection over the past week on case-insensitive
   file systems.

2. We could move the ,v files to a subdirectory as christos suggested,
   but the Makefile changes would then refer to files that don't
   exist, which implies breaking bisection over the past week for
   everyone.

I am not seeing a good way out of this.  I'm inclined to weigh
`bisection for everyone' as more important than `bisection on
case-insensitive file systems', and to prefer (1) over (2), but maybe
there are other downsides to leaving the ,v files around and other
reasons why we should do (2) instead of (1).

Thoughts?


CVS commit: src/sys

2019-09-02 Thread Taylor R Campbell
-1,4 +1,4 @@
-/*	$NetBSD: cprng.h,v 1.14 2018/04/29 11:42:09 maxv Exp $ */
+/*	$NetBSD: cprng.h,v 1.15 2019/09/02 20:09:30 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2011-2013 The NetBSD Foundation, Inc.
@@ -38,11 +38,11 @@
 
 #include 
 
-#include 
+#include 
 #include 
 
 /*
- * NIST SP800-90 says 2^19 bytes per request for the CTR_DRBG.
+ * NIST SP800-90 says 2^19 bytes per request for the Hash_DRBG.
  */
 #define CPRNG_MAX_LEN	524288
 

Added files:

Index: src/sys/crypto/nist_hash_drbg/files.nist_hash_drbg
diff -u /dev/null src/sys/crypto/nist_hash_drbg/files.nist_hash_drbg:1.1
--- /dev/null	Mon Sep  2 20:09:30 2019
+++ src/sys/crypto/nist_hash_drbg/files.nist_hash_drbg	Mon Sep  2 20:09:29 2019
@@ -0,0 +1,3 @@
+#	$NetBSD: files.nist_hash_drbg,v 1.1 2019/09/02 20:09:29 riastradh Exp $
+
+file	crypto/nist_hash_drbg/nist_hash_drbg.c
Index: src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c
diff -u /dev/null src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c:1.1
--- /dev/null	Mon Sep  2 20:09:30 2019
+++ src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c	Mon Sep  2 20:09:29 2019
@@ -0,0 +1,1127 @@
+/*	$NetBSD: nist_hash_drbg.c,v 1.1 2019/09/02 20:09:29 riastradh Exp $	*/
+
+/*-
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file implements Hash_DRBG, a `deterministic random bit
+ * generator' (more commonly known in lay terms and in the cryptography
+ * literature as a pseudorandom bit generator or pseudorandom number
+ * generator), described in
+ *
+ *	Elaine Barker and John Kelsey, `Recommendation for Random
+ *	Number Generation Using Deterministic Random Bit Generators',
+ *	NIST SP800-90A, June 2015.
+ *
+ * This code is meant to work in userland or in kernel.  For a test
+ * program, compile with -DNIST_HASH_DRBG_MAIN to define a `main'
+ * function; for verbose debugging output, compile with
+ * -DNIST_HASH_DRBG_DEBUG, mainly useful if you need to change
+ * something and have to diagnose what's wrong with the known-answer
+ * tests.
+ */
+
+#ifdef _KERNEL
+#include 
+__KERNEL_RCSID(0, "$NetBSD: nist_hash_drbg.c,v 1.1 2019/09/02 20:09:29 riastradh Exp $");
+#endif
+
+#include 
+#include 
+#include 
+
+#ifdef _KERNEL
+#include 			/* memcpy */
+#include 	/* KASSERT */
+#define	ASSERT		KASSERT
+#else
+#include 
+#include 
+#include 
+#include 
+#define	ASSERT		assert
+#define	CTASSERT	__CTASSERT
+#endif
+
+#include "nist_hash_drbg.h"
+
+#define	secret	/* must not use in variable-time operations; should zero */
+#define	arraycount(A)	(sizeof(A)/sizeof(A[0]))
+
+CTASSERT(0 < NIST_HASH_DRBG_RESEED_INTERVAL);
+CTASSERT(NIST_HASH_DRBG_RESEED_INTERVAL <= INT_MAX);
+CTASSERT(NIST_HASH_DRBG_RESEED_INTERVAL <= ~(~0ull << 48));
+
+/* Instantiation: SHA-256 */
+#define	HASH_LENGTH	SHA256_DIGEST_LENGTH
+#define	HASH_CTX	SHA256_CTX
+#define	hash_init	SHA256_Init
+#define	hash_update	SHA256_Update
+#define	hash_final	SHA256_Final
+
+#define	SEEDLEN_BYTES	NIST_HASH_DRBG_SEEDLEN_BYTES
+
+struct hvec {
+	const void	*hv_base;
+	size_t		hv_len;
+};
+
+static void	hashgen(secret uint8_t *, size_t,
+		const secret uint8_t[SEEDLEN_BYTES]);
+static void	add8(secret uint8_t *, size_t, const secret uint8_t *, size_t);
+static void	hash_df(secret void *, size_t, const struct hvec *, size_t);
+static void	hash_df_block(secret void *, uint8_t, uint8_t[4],
+		const struct hvec *, size_t);
+
+/* 10.1.1 Hash_DRBG */
+
+int
+nist_hash_drbg_destroy(struct nist_hash_drbg *D)
+{
+
+	explicit_memset(D, 0, sizeof(*D));
+	D->reseed_counter = UINT_MAX

CVS commit: src/sys

2019-09-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Sep  2 20:09:30 UTC 2019

Modified Files:
src/sys/conf: files
src/sys/dev: rndpseudo.c
src/sys/kern: subr_cprng.c
src/sys/rump/kern/lib/libcrypto: Makefile
src/sys/rump/librump/rumpkern: Makefile.rumpkern
src/sys/sys: cprng.h
Added Files:
src/sys/crypto/nist_hash_drbg: files.nist_hash_drbg nist_hash_drbg.c
nist_hash_drbg.h
Removed Files:
src/sys/crypto/nist_ctr_drbg: files.nist_ctr_drbg
nist_ctr_aes_rijndael.h nist_ctr_drbg.c nist_ctr_drbg.h
nist_ctr_drbg_aes128.h nist_ctr_drbg_aes256.h
nist_ctr_drbg_config.h

Log Message:
Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:

- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (https://eprint.iacr.org/2018/349)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:

- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

XXX pullup-7
XXX pullup-8
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.1237 -r1.1238 src/sys/conf/files
cvs rdiff -u -r1.1 -r0 src/sys/crypto/nist_ctr_drbg/files.nist_ctr_drbg \
src/sys/crypto/nist_ctr_drbg/nist_ctr_drbg.c \
src/sys/crypto/nist_ctr_drbg/nist_ctr_drbg_config.h
cvs rdiff -u -r1.2 -r0 src/sys/crypto/nist_ctr_drbg/nist_ctr_aes_rijndael.h \
src/sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes128.h \
src/sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes256.h
cvs rdiff -u -r1.3 -r0 src/sys/crypto/nist_ctr_drbg/nist_ctr_drbg.h
cvs rdiff -u -r0 -r1.1 src/sys/crypto/nist_hash_drbg/files.nist_hash_drbg \
src/sys/crypto/nist_hash_drbg/nist_hash_drbg.c \
src/sys/crypto/nist_hash_drbg/nist_hash_drbg.h
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/rndpseudo.c
cvs rdiff -u -r1.30 -r1.31 src/sys/kern/subr_cprng.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/kern/lib/libcrypto/Makefile
cvs rdiff -u -r1.175 -r1.176 src/sys/rump/librump/rumpkern/Makefile.rumpkern
cvs rdiff -u -r1.14 -r1.15 src/sys/sys/cprng.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src

2019-09-02 Thread Taylor R Campbell
> Date: Mon, 2 Sep 2019 16:53:34 +0900
> From: Masanobu SAITOH 
> 
> d) Any other options.

1. Revert the commit for now, ASAP, to unblock people.

2. Deterministically transform the uppercase filenames into versions
   that do not collide under case folding with lowercase filenames.
   For example, FOO_bar.bin -> u_foo_bar.bin.

3. Change the Linux module firmware loading files to apply the
   transformation at run-time so we don't have to patch upstream code
   to cope with it.

4. Maybe ask upstream to change names so we can eliminate this hack in
   the future.


CVS commit: src/sys/external/bsd/drm/dist/shared-core

2019-08-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 30 03:34:37 UTC 2019

Modified Files:
src/sys/external/bsd/drm/dist/shared-core: radeon_cs.c

Log Message:
Delete dead-as-a-doornail-in-a-dead-horse branch.

If dev_priv is null here, you're hosed to begin with, so the apparent
null pointer dereference in this branch is moot; also this is the old
drm code that we should maybe just delete altogether...

Potential null pointer dereference reported by Dr Silvio Cesare of
InfoSect.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/external/bsd/drm/dist/shared-core

2019-08-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 30 03:34:37 UTC 2019

Modified Files:
src/sys/external/bsd/drm/dist/shared-core: radeon_cs.c

Log Message:
Delete dead-as-a-doornail-in-a-dead-horse branch.

If dev_priv is null here, you're hosed to begin with, so the apparent
null pointer dereference in this branch is moot; also this is the old
drm code that we should maybe just delete altogether...

Potential null pointer dereference reported by Dr Silvio Cesare of
InfoSect.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c
diff -u src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c:1.2 src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c:1.3
--- src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c:1.2	Thu Oct 17 21:15:18 2013
+++ src/sys/external/bsd/drm/dist/shared-core/radeon_cs.c	Fri Aug 30 03:34:37 2019
@@ -148,11 +148,6 @@ int radeon_cs_ioctl(struct drm_device *d
 	cs_id = 0;
 	cs->cs_id = cs_id;
 
-	if (dev_priv == NULL) {
-		DRM_ERROR("called with no initialization\n");
-		DRM_SPINUNLOCK(_priv->cs.cs_mutex);
-		return -EINVAL;
-	}
 	if (!cs->num_chunks) {
 		DRM_SPINUNLOCK(_priv->cs.cs_mutex);
 		return 0;



CVS commit: src/sys/dev/eisa

2019-08-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 30 00:36:53 UTC 2019

Modified Files:
src/sys/dev/eisa: if_fea.c

Log Message:
Delete dead null test after malloc(M_WAITOK).

Reported as a possible null pointer dereference by Dr Silvio Cesare
of InfoSect, but the branch is dead code anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/eisa/if_fea.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/eisa/if_fea.c
diff -u src/sys/dev/eisa/if_fea.c:1.47 src/sys/dev/eisa/if_fea.c:1.48
--- src/sys/dev/eisa/if_fea.c:1.47	Thu Jul 14 10:19:06 2016
+++ src/sys/dev/eisa/if_fea.c	Fri Aug 30 00:36:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_fea.c,v 1.47 2016/07/14 10:19:06 msaitoh Exp $	*/
+/*	$NetBSD: if_fea.c,v 1.48 2019/08/30 00:36:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1996 Matt Thomas 
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_fea.c,v 1.47 2016/07/14 10:19:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fea.c,v 1.48 2019/08/30 00:36:53 riastradh Exp $");
 
 #include "opt_inet.h"
 
@@ -245,10 +245,6 @@ pdq_eisa_attach(
 int irq = ffs(ed->ioconf.irq) - 1;
 
 sc = (pdq_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
-if (sc == NULL) {
-	printf("fea%d: malloc failed!\n", sc->sc_if.if_unit);
-	return -1;
-}
 pdqs_eisa[ed->unit] = sc;
 
 sc->sc_if.if_name = "fea";



CVS commit: src/sys/arch/arm/gemini

2019-08-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 30 00:33:55 UTC 2019

Modified Files:
src/sys/arch/arm/gemini: gemini_ipi.c

Log Message:
Don't dereference pointer when we're about to panic because it's null.

Reported by Dr Silvio Cesare of InfoSect.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/gemini/gemini_ipi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/gemini

2019-08-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 30 00:33:55 UTC 2019

Modified Files:
src/sys/arch/arm/gemini: gemini_ipi.c

Log Message:
Don't dereference pointer when we're about to panic because it's null.

Reported by Dr Silvio Cesare of InfoSect.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/gemini/gemini_ipi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/gemini/gemini_ipi.c
diff -u src/sys/arch/arm/gemini/gemini_ipi.c:1.6 src/sys/arch/arm/gemini/gemini_ipi.c:1.7
--- src/sys/arch/arm/gemini/gemini_ipi.c:1.6	Sat Oct 27 17:17:38 2012
+++ src/sys/arch/arm/gemini/gemini_ipi.c	Fri Aug 30 00:33:55 2019
@@ -7,7 +7,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: gemini_ipi.c,v 1.6 2012/10/27 17:17:38 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gemini_ipi.c,v 1.7 2019/08/30 00:33:55 riastradh Exp $");
 
 #include 
 #include 
@@ -169,7 +169,7 @@ ipi_intr_disestablish(void *ih)
 gemini_ipi_softc_t *sc = gemini_ipi_sc;
 
 	if (sc == NULL)
-		panic("%s: NULL gemini_ipi_sc", device_xname(sc->sc_dev));
+		panic("NULL gemini_ipi_sc");
 
 gemini_ipi_intrq_remove(sc, ih);
 }



  1   2   3   >