Link [ NetBSD | NetBSD OpenGrok source search | PR fulltext-search | Summary of daily snapshot builds | history of daily build result | pkgsrc commit viewer ]


   
        usage: [branch:branch] [user:user] [path@revision] keyword [... [-excludekeyword [...]]] (e.g. branch:MAIN sys/arch/arm, if_wm.c@1.234 )




switch to index mode

recent branches: MAIN (6m)  netbsd-8 (5d)  netbsd-10 (5d)  netbsd-9 (11d)  thorpej-ifq (175d)  thorpej-altq-separation (177d) 

2024-05-09 20:29:15 UTC Now

2022-03-28 12:43:58 UTC MAIN commitmail json YAML

uhidev(9): Refactor error branch to use one label.

No functional change intended.

(riastradh)

2022-03-28 12:43:48 UTC MAIN commitmail json YAML

uhidev(9): Make some private functions static and fix comment.

No functional change.

(riastradh)

2022-03-28 12:43:39 UTC MAIN commitmail json YAML

uhidev(9): Make uhidev_stop work reliably.

(riastradh)

2022-03-28 12:43:30 UTC MAIN commitmail json YAML

ucycom(4): Defer uhidev_write_async to taskq.

Can't submit USB transfers while holding tty_lock, a spin lock.

(riastradh)

2022-03-28 12:43:22 UTC MAIN commitmail json YAML

uhidev(9): Move struct uhidev_softc into uhidev.c.

No longer part of any ABI for uhidev modules.

(riastradh)

2022-03-28 12:43:12 UTC MAIN commitmail json YAML

uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.

(riastradh)

2022-03-28 12:43:03 UTC MAIN commitmail json YAML

uhidev(9): New uhidev_write_async.

Like uhidev_write but issues the transfer asynchronously with a
callback.

Use it in ucycom(4).

Also, clear endpoint stalls asynchronously -- can't do them
synchronously in xfer callbacks which run at softint and therefore
can't wait in cv_wait as usbd_do_request does.

(riastradh)

2022-03-28 12:42:54 UTC MAIN commitmail json YAML

uhidev(9): Partially fix uhidev_write aborting.

In my previous change, I intended to make uhidev_stop abort any
pending write -- but I forgot to initialize sc->sc_writereportid, so
it never did anything.

This changes the API and ABI of uhidev_write so it takes the struct
uhidev pointer, rather than the struct uhidev_softc pointer; this way
uhidev_write knows what the report id of the client is, so it can
arrange to have uhidev_stop abort only this one.

XXX Except it still doesn't actually work because we do this
unlocked, ugh, so the write might complete before we abort anything.
To be fixed some more in a later change.

XXX kernel ABI change to uhidev_write signature, used by uhidev
driver modules, requires bump

(riastradh)

2022-03-28 12:42:45 UTC MAIN commitmail json YAML

uhid(4): Use d_cfdriver/devtounit/cancel to avoid open/detach races.

- Split uhidclose into separate uhidcancel and uhidclose parts.
  uhidcancel interrupts pending I/O operations (open, read, write,
  ioctl, &c.); uhidclose doesn't run until all I/O operations are
  done.

- Handle case where, owing to revoke(2), uhidcancel/uhidclose run
  concurrently with a uhidopen that hasn't yet noticed that there
  isn't actually a device.

- Handle case where, owing to revoke(2), uhidread might be cancelled
  by mere revoke, not by detach, so it has to wake up when the device
  is closing, not (just) when dying (but dying will lead to closing
  so no need to check for dying).

- Omit needless reference-counting goo.  vdevgone takes care of this
  for us by cancelling all I/O operations with uhidcancel, waiting
  for I/O operations to drain, closing the device, and waiting until
  it is closed if that is already happening concurrently.

- Name the closed/changing/open states rather than using 0/1/2.

- Omit needless sc_dying.

(riastradh)

2022-03-28 12:42:37 UTC MAIN commitmail json YAML

ucom(4): Rework open/close/attach/detach logic.

- Defer sleep after hangup until open.

  No need to make close hang; we just need to make sure some time has
  passed before we next try to open.

  This changes the wchan for the sleep.  Oh well.

- Use .d_cfdriver/devtounit/cancel to resolve races between attach,
  detach, open, close, and revoke.

- Use a separate .sc_closing flag instead of a UCOM_CLOSING state.
  ucomcancel/ucomclose owns this flag, and it may be set in any state
  (except UCOM_DEAD).  UCOM_OPENING remains owned by ucomopen, which
  might be interrupted by cancel/close.

- Rework error branches in ucomopen.  Much simpler this way.

- Nix unnecessary reference counting.

(riastradh)

2022-03-28 12:41:17 UTC MAIN commitmail json YAML

subr_devsw.c: KNF and style nits.

No functional change intended.

(riastradh)

2022-03-28 12:39:57 UTC MAIN commitmail json YAML

audio(4): Use d_cfdriver/devtounit to avoid open/detach races.

(riastradh)

2022-03-28 12:39:47 UTC MAIN commitmail json YAML

sd(4): Use d_cfdriver/devtounit to avoid open/detach races.

(riastradh)

2022-03-28 12:39:37 UTC MAIN commitmail json YAML

wd(4): Use d_cfdriver/devtounit to avoid open/detach races.

(riastradh)

2022-03-28 12:39:29 UTC MAIN commitmail json YAML

tty(9): New ttycancel function.

This causes any current and future ttyopens to fail until ttyclose.

This is necessary for revoke to work reliably for device detach like
ucom(4) removable USB devices.  A tty driver for a removable device
needs some way to interrupt a pending .d_open so it returns promptly.
But ttyclose only interrupts ttyopen if it's already sleeping; it
won't cause a concurrent .d_open call which _will call_ but _hasn't
yet called_ ttyopen to avoid sleeping.  Using ttycancel in the tty
driver's .d_cancel makes this work.

(riastradh)

2022-03-28 12:39:18 UTC MAIN commitmail json YAML

driver(9): New types dev_*_t for device driver devsw operations.

These will serve to replace the archaic and kludgey dev_type_* macros
which should've been typedefs all along.

(riastradh)

2022-03-28 12:39:10 UTC MAIN commitmail json YAML

driver(9): New devsw d_cancel op to interrupt I/O before close.

If specified, when revoking a device node or closing its last open
node, specfs will:

1. Call d_cancel, which should return promptly without blocking.
2. Wait for all concurrent d_read/write/ioctl/&c. to drain.
3. Call d_close.

Otherwise, specfs will:

1. Call d_close.
2. Wait for all concurrent d_read/write/ioctl/&c. to drain.

This fallback is problematic because often parts of d_close rely on
concurrent devsw operations to have completed already, so it is up to
each driver to have its own mechanism for waiting, and the extra step
in (2) is almost redundant.  But it is still important to ensure that
devsw operations are not active by the time a module tries to invoke
devsw_detach, because only d_open is protected against that.

The signature of d_cancel matches d_close, mostly so we don't raise
questions about `why is this different?'; the lwp argument is not
useful but we should remove it from open/cancel/close all at the same
time.

The only way d_cancel should fail, if it does at all, is with ENODEV,
meaning the driver doesn't support cancelling outstanding I/O, and
will take responsibility for that in d_close.  I would make it return
void and only have bdev_cancel and cdev_cancel possibly return ENODEV
so specfs can detect whether a driver supports it, but this would
break the pattern around devsw operation types.

Drivers are allowed to omit it from struct bdevsw, struct cdevsw --
if so, it is as if they used a function that just returns ENODEV.

XXX kernel ABI change to struct bdevsw/cdevsw requires bump

(riastradh)

2022-03-28 12:38:59 UTC MAIN commitmail json YAML

2022-03-28 12:38:34 UTC MAIN commitmail json YAML

driver(9): Make vdevgone call config_detach_commit if appropriate.

Make sure to do this before spec_node_lookup_by_dev -- that might wait
for a concurrent revoke to complete, which in turn might wait for a
concurrent open to complete, which in turn might be waiting for the
device to commit to detaching.

(riastradh)

2022-03-28 12:38:25 UTC MAIN commitmail json YAML

autoconf(9): Disentangle slightly circuitous config_detach logic.

No functional change intended.

(riastradh)

2022-03-28 12:38:15 UTC MAIN commitmail json YAML

autoconf(9): New function config_detach_commit.

When a driver's .ca_detach function has committed to detaching -- it
definitely won't back out with EBUSY, for instance -- it can call
this to wake all pending calls to device_lookup_acquire and make them
fail immediately.

This is necessary to break a deadlock if the device_lookup_acquire
calls happen inside I/O operations which the driver's .ca_detach
function waits for the completion of -- without config_detach_commit,
I/O operations would be stuck in device_lookup_acquire waiting for
.ca_detach and .ca_detach would be stuck waiting for I/O operations
to return.

Most drivers won't need to call this: for autoconf drivers used the
traditional way by devsw for userland device nodes, the .ca_detach
routine uses vdevgone, and we will arrange to make vdevgone call
config_detach_commit automagically in such drivers anyway.

XXX kernel ABI change to struct device requires bump -- later change
will make struct device opaque to ABI, but we're not there yet

(riastradh)

2022-03-28 12:38:04 UTC MAIN commitmail json YAML

specfs: Reorder struct specnode members to save padding.

Shrinks from 40 bytes to 32 bytes on LP64 systems this way.

(riastradh)

2022-03-28 12:37:56 UTC MAIN commitmail json YAML

specfs: Remove specnode from hash table in spec_node_revoke.

Previously, it was possible for spec_node_lookup_by_dev to handle a
speconde that a concurrent spec_node_destroy is about to remove from
the hash table and then free, as soon as spec_node_lookup_by_dev
releases device_lock.

Now, the ordering is:

1. Remove specnode from hash table in spec_node_revoke.  At this
  point, no _new_ vnode references are possible (other than possibly
  one acquired by vcache_vget under v_interlock), but there may be
  existing ones.

2. Mark vnode reclaimed so vcache_vget will fail.

3. The last vrele (or equivalent logic in vcache_vget) will then free
  the specnode in spec_node_destroy.

This way, _if_ a thread in spec_node_lookup_by_dev finds a specnode
in the hash table under device_lock/v_interlock, _then_ it will not
be freed until the thread completes vcache_vget.

This change requires calling spec_node_revoke unconditionally for
device special nodes, not just for active ones.  Might introduce
slightly more contention on device_lock but not much because we
already have to take it in this path anyway a little later in
spec_node_destroy.

(riastradh)

2022-03-28 12:37:46 UTC MAIN commitmail json YAML

specfs: Let spec_node_lookup_by_dev wait for reclaim to finish.

vdevgone relies on this to ensure that if there is a concurrent
revoke in progress, it will wait for that revoke to finish -- that
way, it can guarantee all I/O operations have completed and the
device is closed.

(riastradh)

2022-03-28 12:37:35 UTC MAIN commitmail json YAML

specfs: Assert opencnt is nonzero before decrementing.

(riastradh)

2022-03-28 12:37:27 UTC MAIN commitmail json YAML

specfs: Take an I/O reference across bdev/cdev_open.

- Revoke is used to invalidate all prior access control checks when
  device permissions are changing, so it must wait for .d_open to exit
  so any new access must go through new access control checks.

- Revoke is used by vdevgone in xyz_detach to wait until all use of
  the driver's data structures have completed before xyz_detach frees
  them.

So we need to make sure spec_close waits for .d_open too.

(riastradh)

2022-03-28 12:37:18 UTC MAIN commitmail json YAML

specfs: Wait for last close in spec_node_revoke.

Otherwise, revoke -- and vdevgone, in the detach path of removable
devices -- may complete while I/O operations are still running
concurrently.

(riastradh)

2022-03-28 12:37:09 UTC MAIN commitmail json YAML

specfs: Prevent new opens while close is waiting to drain.

Otherwise, bdev/cdev_close could have cancelled all _existing_ opens,
and waited for them to complete (and freed resources used by them) --
but a new one could start, and hang (e.g., a tty), at the same time
spec_close tries to drain all pending I/O operations, one of which
(the new open) is now hanging indefinitely.

Preventing the new open from even starting until bdev/cdev_close is
finished and all I/O operations have drained avoids this deadlock.

(riastradh)

2022-03-28 12:37:01 UTC MAIN commitmail json YAML

specfs: Take an I/O reference in spec_node_setmountedfs.

This is not quite correct.  We _should_ require the caller to hold a
vnode lock around spec_node_getmountedfs, and an exclusive vnode lock
around spec_node_setmountedfs, so that it is only necessary to check
whether revoke has already happened, not hold an I/O reference.

Unfortunately, various callers in various file systems don't follow
this sensible rule.  So let's at least make sure the vnode can't be
revoked in spec_node_setmountedfs, while we're in bdev_ioctl, and
leave a comment explaining what the sorry state of affairs is and how
to fix it later.

(riastradh)

2022-03-28 12:36:51 UTC MAIN commitmail json YAML

specfs: Drain all I/O operations after last .d_close call.

New kind of I/O reference on specdevs, sd_iocnt.  This could be done
with psref instead; I chose a reference count instead for now because
we already have to take a per-object lock anyway, v_interlock, for
vdead_check, so another atomic is not likely to hurt much more.  We
can always change the mechanism inside spec_io_enter/exit/drain later
on.

Make sure every access to vp->v_rdev or vp->v_specnode and every call
to a devsw operation is protected either:

- by the vnode lock (with vdead_check if we unlocked/relocked),
- by positive sd_opencnt,
- by spec_io_enter/exit, or
- by sd_opencnt management in open/close.

(riastradh)

2022-03-28 12:36:42 UTC MAIN commitmail json YAML

specfs: Resolve a race between close and a failing reopen.

(riastradh)

2022-03-28 12:36:34 UTC MAIN commitmail json YAML

specfs: Document sn_opencnt, sd_opencnt, sd_refcnt.

(riastradh)

2022-03-28 12:36:27 UTC MAIN commitmail json YAML

specfs: Paranoia: Assert opencnt is zero on reclaim.

(riastradh)

2022-03-28 12:36:18 UTC MAIN commitmail json YAML

specfs: Omit needless vdead_check in spec_fdiscard.

The vnode lock is held, so the vnode cannot be revoked without also
changing v_op so subsequent uses under the vnode lock will go to
deadfs's VOP_FDISCARD instead (which is genfs_eopnotsupp).

(riastradh)

2022-03-28 12:36:09 UTC MAIN commitmail json YAML

specfs: Add a comment and assertion to spec_close about refcnts.

(riastradh)

2022-03-28 12:36:01 UTC MAIN commitmail json YAML

specfs: If sd_opencnt is zero, sn_opencnt had better be zero.

(riastradh)

2022-03-28 12:35:52 UTC MAIN commitmail json YAML

specfs: Factor KASSERT out of switch in spec_open.

No functional change.

(riastradh)

2022-03-28 12:35:44 UTC MAIN commitmail json YAML

specfs: sn_gone cannot be set while we hold the vnode lock.

Revoke runs with the vnode lock too, which is exclusive.  Add an
assertion to this effect in spec_node_revoke to make it clear.

(riastradh)

2022-03-28 12:35:35 UTC MAIN commitmail json YAML

specfs: Reorganize D_DISK tail of spec_open and explain what's up.

No functional change intended.

(riastradh)

2022-03-28 12:35:26 UTC MAIN commitmail json YAML

specfs: Factor VOP_UNLOCK/vn_lock out of switch for clarity.

No functional change.

(riastradh)

2022-03-28 12:35:17 UTC MAIN commitmail json YAML

specfs: Factor common device_lock out of switch for clarity.

No functional change.

(riastradh)

2022-03-28 12:35:08 UTC MAIN commitmail json YAML

specfs: Delete bogus comment about .d_open/.d_close at same time.

Annoying as it is that .d_open and .d_close can run at the same time,
it is also necessary for tty semantics, where open can block
indefinitely, and it is the responsibility of close (called via
revoke) necessary to interrupt it.

(riastradh)

2022-03-28 12:34:59 UTC MAIN commitmail json YAML

specfs: Split spec_open switch into three sections.

The sections are now:

1. Acquire open reference.

1a (intermezzo). Set VV_ISTTY.

2. Drop the vnode lock to call .d_open and autoload modules if
  necessary.

3. Handle concurrent revoke if it happenend, or release open reference
  if .d_open failed.

No functional change.  Sprinkle comments about problems.

(riastradh)

2022-03-28 12:34:51 UTC MAIN commitmail json YAML

specfs: Factor common kauth check out of switch in spec_open.

No functional change.

(riastradh)

2022-03-28 12:34:42 UTC MAIN commitmail json YAML

specfs: Assert v_type is VBLK or VCHR in spec_open.

Nothing else makes sense.  Prune dead branches (and replace default
case by panic).

(riastradh)

2022-03-28 12:34:34 UTC MAIN commitmail json YAML

specfs: Call bdev_open without the vnode lock.

There is no need for it to serialize opens, because they are already
serialized by sd_opencnt which for block devices is always either 0
or 1.

There's not obviously any other reason why the vnode lock should be
held across bdev_open, other than that it might be nice to avoid
dropping it if not necessary.  For character devices we always have
to drop the vnode lock because open might hang indefinitely, when
opening a tty, which is not allowed while holding the vnode lock.

(riastradh)

2022-03-28 12:34:26 UTC MAIN commitmail json YAML

specfs: Note lock order for vnode lock, device_lock, v_interlock.

(riastradh)

2022-03-28 12:34:17 UTC MAIN commitmail json YAML

driver(9): Eliminate D_MCLOSE.

D_MCLOSE was introduced a few years ago by mistake for audio(4),
which should have used -- and now does use -- fd_clone to create
per-open state.  The semantics was originally to call close once
every time the device node is closed, not only for the last close.
Nothing uses it any more, and it complicates reasoning about the
system, so let's simplify it away.

(riastradh)

2022-03-28 12:34:08 UTC MAIN commitmail json YAML

driver(9): New function dev_minor_unit.

(riastradh)

2022-03-28 12:33:59 UTC MAIN commitmail json YAML

disk(9): New function disklabel_dev_unit.

Maps a dev_t like wd3e to an autoconf instance number like 3, with no
partition.  Same as DISKUNIT macro, but is a symbol whose pointer can
be taken.  Meant for use with struct bdevsw, cdevsw::d_devtounit.

(riastradh)

2022-03-28 12:33:50 UTC MAIN commitmail json YAML

driver(9): New devsw members d_cfdriver, d_devtounit.

If set, then bdev_open/cdev_open will use d_devtounit to map the
dev_t to an autoconf instance (e.g., /dev/wd0a -> wd0) and hold a
reference with device_lookup_acquire across the call to d_open.

This guarantees that the autoconf instance cannot be detached while
the devsw's d_open function is trying to open it (and also that the
autoconf instance has finished *_attach before anyone can open it).

Of course, if the underlying hardware has gone away, there will be
I/O errors, but this avoids software synchronization bugs between
open and detach for drivers that opt into it.  It's up to the driver
and bus to figure out how to deal with I/O errors from operations on
hardware that has gone away while the software hasn't finished
notifying everything that it's gone yet.

XXX kernel ABI change to struct bdevsw/cdevsw requires bump

(riastradh)

2022-03-28 12:33:41 UTC MAIN commitmail json YAML

autoconf(9): New localcount-based device instance references.

device_lookup_acquire looks up an autoconf device instance, if found,
and acquires a reference the caller must release with device_release.
If attach or detach is still in progress, device_lookup_acquire waits
until it completes.  While references are held, the device's softc
will not be freed or reused until the last reference is released.

The reference is meant to be held while opening a device in the short
term, and then to be passed off to a longer-term reference that can
be broken explicitly by detach -- usually a device special vnode,
which is broken by vdevgone in the driver's *_detach function.

Sleeping while holding a reference is allowed, e.g. waiting to open a
tty.  A driver must arrange that its *_detach function will interrupt
any threads sleeping while holding references and cause them to back
out so that detach can complete promptly.

Subsequent changes to subr_devsw.c will make bdev_open and cdev_open
automatically take a reference to an autoconf instance for drivers
that opt into this, so there will be no logic changes needed in most
drivers other than to connect the autoconf cfdriver to the
bdevsw/cdevsw I/O operation tables.  The effect will be that *_detach
may run while d_open is in progress, but no new d_open can begin
until *_detach has backed out from or committed to detaching.

XXX kernel ABI change to struct device requires bump -- later change
will make struct device opaque to ABI, but we're not there yet

(riastradh)

2022-03-28 12:33:32 UTC MAIN commitmail json YAML

driver(9): Fix synchronization of devsw_attach/lookup/detach.

(`dev' means either `bdev' or `cdev' for brevity here, e.g. in
`devsw_lookup' (bdevsw_lookup, cdevsw_lookup), `dev_open' (bdev_open,
cdev_open), `maxdevsws', &c., except for `devsw_attach' and
`devsw_detach' which are taken literally.)

- Use atomic_store_release and atomic_load_consume for devsw and
  tables and their entries, which are read unlocked and thus require
  memory barriers to ensure ordering between initialization in
  devsw_attach and use in dev_lookup.

- Use pserialize(9) and localcount(9) to synchronize dev_open and
  devsw_detach.

  => Driver must ensure d_open fails and all open instances have been
    closed by the time it calls devsw_detach.

  => Bonus: dev_open is no longer globally serialized through
    device_lock.

- Use atomic_store_release and atomic_load_acquire for max_devsws,
  which is used in conditionals in the new devsw_lookup_acquire.

  => It is safe to use atomic_load_relaxed in devsw_lookup because
    the caller must guarantee the entry is stable, so any increase
    of max_devsws must have already happened.

  => devsw_lookup and devsw_lookup_acquire assume that max_devsws
    never goes down.  If you change this you must find some way to
    adapt the users, preferably without adding much overhead so that
    devsw operations are cheap.

This change introduces an auxiliary table devswref mapping device
majors to localcounts of opens in progress.  The auxiliary table only
occupies one pointer's worth of memory in a monolithic kernel, and is
allocated on the fly for dynamically loaded modules.  We could ask
the module itself to reserve storage for it, but I don't see much
value in that, and it would require some changes to the ABI and to
config(8).

- Omit needless boolean indirection.

(riastradh)

2022-03-28 12:33:22 UTC MAIN commitmail json YAML

driver(9): devsw_detach never fails.  Make it return void.

Prune a whole lotta dead branches as a result of this.  (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back.  To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump

(riastradh)

2022-03-28 11:21:40 UTC MAIN commitmail json YAML

2022-03-28 11:16:59 UTC MAIN commitmail json YAML

Check INITED state by default for all ioctls but VNDIOCSET. Avoids crashes
with disk_ioctls on default unit, which is not INITED.
Fixes PR 56700.

(mlelstv)

2022-03-28 11:09:24 UTC MAIN commitmail json YAML

Fix sanity check for zero sized buffer.

(mlelstv)

2022-03-28 10:38:00 UTC MAIN commitmail json YAML

Media size is in bytes (off_t), not sectors.

(mlelstv)

2022-03-27 20:18:05 UTC MAIN commitmail json YAML

Make mmap() with "len == 0" an error if not MAP_ANON.  We should return
an error for MAP_ANON too but unfortunately our /libexec/ld.elf_so
sometimes creates an empty anon mapping for the bss of a shared library.

At least FreeBSD and Solaris return this error too and according to POSIX
"If len is zero, mmap() shall fail and no mapping shall be established".

Fixes PR pkg/56338 Installing qt5-qtdeclarative leaves a dangling reference

The dangling reference here originates from vn_mmap() taking a vnode
reference for this empty mapping that will never be released.

(hannken)

2022-03-27 18:39:01 UTC MAIN commitmail json YAML

2022-03-27 17:10:56 UTC MAIN commitmail json YAML

2022-03-27 16:36:12 UTC MAIN commitmail json YAML

Describe the hardlink restrictions.

(christos)

2022-03-27 16:28:35 UTC MAIN commitmail json YAML

Implement restrictions for adding hard links to files

(christos)

2022-03-27 16:26:26 UTC MAIN commitmail json YAML

add a kauth vnode check for adding links

(christos)

2022-03-27 16:24:59 UTC MAIN commitmail json YAML

2022-03-27 16:23:08 UTC MAIN commitmail json YAML

2022-03-27 16:16:39 UTC MAIN commitmail json YAML

Widen kauth_action_t so we can add KAUTH_VNODE_ADD_LINK; welcome to 9.99.96.

(christos)

2022-03-27 00:32:15 UTC MAIN commitmail json YAML

popen.3: revert s/null-/nul-/ change, this is subject to debate

(gutteridge)

2022-03-26 19:38:00 UTC MAIN commitmail json YAML

mips/cavium: Simplify membars around interrupt establishment.

Previously I used xc_barrier to ensure the initialization of the
struct octeon_intrhand was witnessed on all CPUs before publishing
it, in order to avoid needing any barrier on the usage side to be
issued by the interrupt handler.

But there's no need to avoid atomic_load_consume at time of
interrupt: on MIPS it's the same as atomic_load_relaxed anyway, so
there's no additional memory barrier cost here.

(riastradh)

2022-03-26 19:35:57 UTC MAIN commitmail json YAML

igpio(4): Use device_xname, not struct device members.

(riastradh)

2022-03-26 19:35:35 UTC MAIN commitmail json YAML

igpio(4): Nix trailing whitespace.

(setq show-trailing-whitespace t), M-x delete-trailing-whitespace

(riastradh)

2022-03-26 17:15:18 UTC MAIN commitmail json YAML

2022-03-26 17:11:20 UTC MAIN commitmail json YAML

2022-03-26 17:09:53 UTC MAIN commitmail json YAML

2022-03-26 16:22:50 UTC MAIN commitmail json YAML

Add sparc* to the list of architectures that need an explicit address
with PT_CONTINUE in this test.

(martin)

2022-03-26 16:03:02 UTC MAIN commitmail json YAML

__makenew: use calloc to get zeroed memory for window contents.

PR lib/56767.

(uwe)

2022-03-26 15:39:58 UTC MAIN commitmail json YAML

Mention 'make -r' with .POSIX

(sjg)

2022-03-26 14:34:07 UTC MAIN commitmail json YAML

2022-03-26 14:17:47 UTC MAIN commitmail json YAML

2022-03-26 14:02:40 UTC MAIN commitmail json YAML

make: prefer 'long long' over 'long' on 32-bit C99 platforms

When sorting the words of an expression numerically using the modifier
':On' (added on 2021-07-30), use 64-bit numbers even on 32-bit
platforms.  A typical use case is comparing file sizes.

When tracing the execution of jobs, fix an integer overflow after 2038.
32-bit platforms that use a pre-C99 compiler still have this problem.

No change to the test suite since most tests simply skip any potential
differences between 32-bit platforms and 64-bit platforms (see
varmod-order-numeric.mk) or already account for both variants (see
varmod-localtime.mk).

(rillig)

2022-03-26 13:41:16 UTC MAIN commitmail json YAML

When reading CIS tuples from a BAR, do not blindly copy 2k of data (or
to the end of the BAR space), but instead follow the tuples and stop
reading once we reach the end of the list.
I have a card

bwi0 at cardbus0 function 0: Broadcom Wireless
bwi0: BBP id 0x4306, BBP rev 0x2, BBP pkg 0

where the BAR claims 8k space but seems to only implement 6k (but that
is impossible to report as the spec only allows 2^n sizes) and the CIS
starts at a bit over 4k (so the old code tried reading beyound the 6k
limit and caused pci bus errors).

An alternative would be to avoid reporting bus errors during this access,
but since we are only interested in the CIS chain anyway (and that ends
way earlier) this is a simpler solution.

(martin)

2022-03-26 13:32:32 UTC MAIN commitmail json YAML

2022-03-26 12:44:57 UTC MAIN commitmail json YAML

2022-03-26 06:49:27 UTC MAIN commitmail json YAML

Add terminology comments.

(isaki)

2022-03-26 06:43:36 UTC MAIN commitmail json YAML

2022-03-26 06:41:12 UTC MAIN commitmail json YAML

Remove a dead code in audio_track_record().

(isaki)

2022-03-26 06:36:06 UTC MAIN commitmail json YAML

Clarify the assertion in audio_rmixer_process().
By previous commit (r1.116), the assersion no longer fires even without
this modification.  But the condition was a bit inaccurate.
There is no need to check the data length must be aligned to blocks here
(though it also should be aligned now).  What we should check here is that
the tail must be aligned.

(isaki)

2022-03-26 06:27:32 UTC MAIN commitmail json YAML

Fix conditions that audio_read() calls audio_track_record().
audio_track_record() must be called when usrbuf has at least one free block.

I hope that this will fix the panic reported in PR kern/56644.
When an user process specifies the hardware format as its recording format
(i.e., there is no track conversions), if the user process read(2) a small
amount of data and the rmixer_process then runs, depending on the conditions,
the panic may happen.  I have never reproduced it because it's difficult to
do intentionally.

Thanks Y.Sugahara and riastradh@ for help and comments.

(isaki)

2022-03-25 23:16:04 UTC MAIN commitmail json YAML

dwhdmi: properly initialize connector atomic helper funcs (PR port-evbarm/56766)

(tnn)

2022-03-25 23:03:47 UTC MAIN commitmail json YAML

tests/make: test .undef for exported global variables

(rillig)

2022-03-25 22:38:39 UTC MAIN commitmail json YAML

tests/make: suppress -DCLEANUP output in test deptgt-phony

(rillig)

2022-03-25 21:24:20 UTC MAIN commitmail json YAML

evbarm: Enable USERCONF option

(jmcneill)

2022-03-25 21:23:51 UTC MAIN commitmail json YAML

2022-03-25 21:23:00 UTC MAIN commitmail json YAML

efiboot: Add support for 'userconf' command.

Add support for the 'userconf' command at the boot prompt and in boot.cfg,
and for FDT based booting, pass the commands as a string list property
named "netbsd,userconf" on the /chosen node.

(jmcneill)

2022-03-25 21:16:04 UTC MAIN commitmail json YAML

Include posix.mk when .POSIX: first encountered

Since .POSIX: is required to be the first non-comment line
in a Makefile, including ${MAKE_POSIX_MK} or whatever _PATH_POSIX_MK is
set to at this point is equivalent to an extension of sys.mk

This is a minimal change that can allow a better approximation of
POSIX compliance

Reviewed by: rillig

(sjg)

2022-03-25 19:34:04 UTC MAIN commitmail json YAML

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'.  Fix this by
copying the upstream code.

No binary change.

(rillig)

2022-03-25 19:25:23 UTC MAIN commitmail json YAML

localtime.c: reduce unnecessary diff to upstream

No binary change.

(rillig)

2022-03-25 19:00:16 UTC MAIN commitmail json YAML

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.

(rillig)

2022-03-25 18:35:50 UTC MAIN commitmail json YAML

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.

(rillig)

2022-03-25 12:24:44 UTC MAIN commitmail json YAML

pcdisplay_getwschar: on error return error code, not -1.

This value ends up being returned from vga_ioctl to sys_ioctl which
expects an errno and spams kernel log otherwise.

Ditto for pcdisplay_putwschar.

(uwe)

2022-03-25 08:57:51 UTC MAIN commitmail json YAML

Prevent memory corruption from wg_send_handshake_msg_init() on
LP64 machines with "MSIZE == 256", sparc64 for example.

wg_send_handshake_msg_init() tries to put 148 bytes into a buffer
of 144 bytes and overwrites 4 bytes following the mbuf.  Check
for "sizeof() > MHLEN" and use a cluster in this case.

With help from Taylor R Campbell <riastradh@>

(hannken)

2022-03-25 08:57:15 UTC MAIN commitmail json YAML

It is impossible for VOP_LOCK() to return ENOENT with LK_RETRY flag.
Remove the second call to VOP_LOCK().

Enable assertion "vrefcnt(vp) > 0" and assert all possible errors
for all LK_RETRY/LK_NOWAIT combinations.

(hannken)

2022-03-25 08:56:36 UTC MAIN commitmail json YAML

As VV_LOCKSWORK is gone remove LOCKSWORK from VNODE_FLAGBITS string.
Also convert illegal octal number 18 to 20.

(hannken)

2022-03-24 16:33:58 UTC MAIN commitmail json YAML

igpio(4): fix date

(wiz)

2022-03-24 16:33:05 UTC MAIN commitmail json YAML

add more igpio man pages (cat4, html4)

(wiz)

2022-03-24 16:15:05 UTC MAIN commitmail json YAML

put back the 2022a changes and fix the misplaced brace.

(christos)

2022-03-24 14:04:28 UTC MAIN commitmail json YAML

Add man page for Intel GPIO igpio.4

(manu)

2022-03-24 14:00:19 UTC MAIN commitmail json YAML

Add documentatiion for Intel GPIO driver igpio(4)

(manu)

2022-03-24 12:59:56 UTC MAIN commitmail json YAML

vfs(9): Add missing vnode lock around VOP_CLOSE in vfs_mountroot.

Maybe vnode_if.c should be taught to KASSERT the vnode lock now that
locks always work.

(riastradh)

2022-03-24 12:58:56 UTC MAIN commitmail json YAML

entropy(9): Call entropy_softintr while bound to CPU.

It looks like We tripped on the new assertion in entropy_account_cpu
when there was pending entropy on cpu0 running lwp0 when xc_broadcast
ran -- since xc_broadcast calls the function directly rather than
calling it through softint_schedule, it's not called via the softint
lwp which would satisfy the assertion.

(riastradh)

2022-03-24 12:12:00 UTC MAIN commitmail json YAML

2022-03-24 10:13:01 UTC MAIN commitmail json YAML

zlib: Fix a bug that can crash deflate on some input when using Z_FIXED.

https://github.com/madler/zlib/commit/5c44459c3b28a9bd3283aaceab7c615f8020c531

This bug was reported by Danilo Ramos of Eideticom, Inc. It has
lain in wait 13 years before being found! The bug was introduced
in zlib 1.2.2.2, with the addition of the Z_FIXED option. That
option forces the use of fixed Huffman codes. For rare inputs with
a large number of distant matches, the pending buffer into which
the compressed data is written can overwrite the distance symbol
table which it overlays. That results in corrupted output due to
invalid distances, and can result in out-of-bound accesses,
crashing the application.

The fix here combines the distance buffer and literal/length
buffers into a single symbol buffer. Now three bytes of pending
buffer space are opened up for each literal or length/distance
pair consumed, instead of the previous two bytes. This assures
that the pending buffer cannot overwrite the symbol table, since
the maximum fixed code compressed length/distance is 31 bits, and
since there are four bytes of pending space for every three bytes
of symbol space.

(wiz)

2022-03-24 08:54:17 UTC MAIN commitmail json YAML

ixl(4): Added Intel V710 for 5000BaseT support

(yamaguchi)

2022-03-24 08:48:19 UTC MAIN commitmail json YAML

2022-03-24 08:46:49 UTC MAIN commitmail json YAML

Added Intel V710 for 5000BaseT

(yamaguchi)

2022-03-24 08:44:04 UTC MAIN commitmail json YAML

Change description about Intel X710 10GBaseT device

(yamaguchi)

2022-03-24 08:08:05 UTC MAIN commitmail json YAML

s/interupt/interrupt/ in comments.
also add missing RCS ID in bcm53xx_reg.h and fix one more typo in there.

(andvar)

2022-03-24 08:02:21 UTC MAIN commitmail json YAML

vioif(4): adopt ether_set_ifflags_cb

(yamaguchi)

2022-03-24 07:57:11 UTC MAIN commitmail json YAML

vioif(4): register MAC address to a device

(yamaguchi)

2022-03-24 07:51:14 UTC MAIN commitmail json YAML

vioif(4): fix missing error handling

(yamaguchi)

2022-03-24 07:47:50 UTC MAIN commitmail json YAML

vioif(4): do not schedule packet processing while stopping the device

(yamaguchi)

2022-03-24 02:24:25 UTC MAIN commitmail json YAML

2022-03-24 01:55:15 UTC MAIN commitmail json YAML

popen.3: minor spelling, grammar, style, and xref tweaks

(gutteridge)

2022-03-24 01:52:48 UTC MAIN commitmail json YAML

fork.2: add _exit(2) xref and spell "ID" consistently

(gutteridge)

2022-03-23 23:24:21 UTC MAIN commitmail json YAML

mips/cavium: Fix membars around establishing interrupt handlers.

(riastradh)

2022-03-23 23:23:25 UTC MAIN commitmail json YAML

viornd(4): Process host entropy in softint context.

Samples added to the entropy pool in hard interrupt context are only
buffered, never processed directly, and if they fill the buffer, the
sample is dropped -- this serves to encourage taking timing samples
in hard interrupt context because it's cheap, and we have no idea how
many samples we really need for full entropy so it's safer to err on
the side of `as many as we can get'.

But for viornd(4), we assume the host has full entropy so we only
need a single 32-byte sample, and we want to avoid dropping it so we
get full entropy ASAP.  Entering the sample in a soft interrupt
rather than hard interrupt achieves this.

(riastradh)

2022-03-23 23:20:52 UTC MAIN commitmail json YAML

entropy(9): Include <sys/lwp.h> and <sys/proc.h> explicitly.

Now that we use curlwp, struct lwp::l_pflag, and LP_BOUND, let's not
rely on side-loads from other .h files.

(riastradh)

2022-03-23 23:18:18 UTC MAIN commitmail json YAML

entropy(9): Bind to CPU temporarily to avoid race with lwp migration.

More fallout from the IPL_VM->IPL_SOFTSERIAL change.

In entropy_enter, there is a window when the lwp can be migrated to
another CPU:

ec = entropy_cpu_get();
...
pending = ec->ec_pending + ...;
...
entropy_cpu_put();

/* lwp migration possible here */

if (pending)
entropy_account_cpu(ec);

If this happens, we may trip over any of several problems in
entropy_account_cpu because it assumes ec is the current CPU's state
in order to decide whether we have anything to contribute from the
local pool to the global pool.

No need to do this in entropy_softintr because softints are bound to
the CPU anyway.

(riastradh)

2022-03-23 17:35:41 UTC MAIN commitmail json YAML

allow com at dino to actually attach

(macallan)

2022-03-23 14:02:05 UTC MAIN commitmail json YAML

revert changes from 2022a for now until I figure out what's wrong.

(christos)

2022-03-23 13:06:06 UTC MAIN commitmail json YAML

2022-03-23 11:08:28 UTC MAIN commitmail json YAML

fix few typos in comments, mainly s/paramenters/parameters/.

(andvar)

2022-03-22 23:37:10 UTC MAIN commitmail json YAML

make: clean up comments and code for setting debug flags

No binary change.

(rillig)

2022-03-22 21:45:13 UTC MAIN commitmail json YAML

2022-03-22 18:32:51 UTC MAIN commitmail json YAML

2022-03-22 17:49:31 UTC MAIN commitmail json YAML

2022-03-22 17:48:39 UTC MAIN commitmail json YAML

welcome to tzcode-2022a

  Changes to code

    Fix bug when mktime gets confused by truncated TZif files with
    unspecified local time.  (Problem reported by Almaz Mingaleev.)

    Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
    (Problem reported by Christos Zoulas.)

    When reading a version 2 or later TZif file, the TZif reader now
    validates the version 1 header and data block only enough to skip
    over them, as recommended by RFC 8536 section 4.  Also, the TZif
    reader no longer mistakenly attempts to parse a version 1 TZIf
    file header as a TZ string.

    zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
    when local time and UT cannot be determined for a timestamp.

(christos)

2022-03-21 22:20:32 UTC MAIN commitmail json YAML

autoconf(9): Enter more timing samples into entropy pool.

Previously, we sampled the time of each _failed_ config_search.  I'm
not sure why -- there was no explanation in the comment or the commit
message introducing this in rev. 1.230.2.1 on tls-earlyentropy.

With this change, we sample the time of _every_ search including the
successful ones -- and also measure the time to attach which often
includes things like probing device registers, triggering device
reset and waiting for it to post, &c.

(riastradh)

2022-03-21 09:20:04 UTC MAIN commitmail json YAML

hdaudio: Obsolete HDAUDIO_ENABLE_DISPLAYPORT and HDAUDIO_ENABLE_HDMI

Enable display port and HDMI devices by default rather than making this
a compile time option.

(jmcneill)

2022-03-21 09:12:10 UTC MAIN commitmail json YAML

hdaudio: pci: PCIe config space fixes and Intel PCH snoop support

The HD audio specification does not cover PCI config space, and this
driver was unconditionally writing to a vendor specific register. Reduce
scope of config space accesses based on PCI IDs.

With this cleaned up, add support for Intel PCH devices which require
some additional vendor specific configuration to bypass no snoop mode.

(jmcneill)

2022-03-21 00:25:04 UTC MAIN commitmail json YAML

entropy(9): Make rnd_lock_sources work while cold.

x86 uses entropy_extract verrrrrry early.  Fixes mistake in previous
that did not manifest in my testing on aarch64, which does not use it
so early.

(riastradh)

2022-03-20 20:37:59 UTC MAIN commitmail json YAML

s/Multilik/Multilink/

(andvar)

2022-03-20 20:19:35 UTC MAIN commitmail json YAML

s/circut/circuit/ and s/circiut/circuit/ in comments and acronyms file.

(andvar)

2022-03-20 19:26:27 UTC MAIN commitmail json YAML

2022-03-20 18:56:29 UTC MAIN commitmail json YAML

fix typos in debug/panic messages: isued->issued, initialiased->initialised.

(andvar)

2022-03-20 18:22:20 UTC MAIN commitmail json YAML

Updated to tzdata2022agtz which is a 2022a fork with backzone zones
moved back into the main data repo (restoring old data)

(kre)

2022-03-20 18:20:19 UTC MAIN commitmail json YAML

2022-03-20 18:19:58 UTC MAIN commitmail json YAML

entropy(9): Improve entropy warning messages and documentation.

- For the main warning message, use less jargon, say `security', and
  cite the entropy(7) man page for further reading.  Document this in
  rnd(4) and entropy(7).

- For the debug-only warning message, say `entropy' only once and omit
  it from the rnd(4) man page -- it's not very important unless you're
  debugging the kernel in which case you probably know what you're
  doing enough to not need the text explained in the man page.

(riastradh)

2022-03-20 18:04:52 UTC MAIN commitmail json YAML

Note tzdata 2022a (using tzdata2022agtz upstream fork)

(kre)

2022-03-20 14:30:57 UTC MAIN commitmail json YAML

entropy(9): Fix premature optimization deadlock in entropy_request.

- For synchronous queries from /dev/random, which are waiting for
  entropy to be ready, wait for concurrent access -- e.g., concurrent
  rnd_detach_source -- to finish, and make sure to request entropy
  from all sources (unless we're interrupted by a signal).

- When invoked through softint context (e.g., cprng_fast_intr ->
  cprng_strong -> entropy_extract), don't wait, because we're
  forbidden from waiting anyway.

- For entropy_bootrequest, wait but don't bother failing on signal
  because this only happens in kthread context, not in userland
  process context, so there can't be signals.

Nix rnd_trylock_sources; use the same entropy_extract flags
(ENTROPY_WAIT, ENTROPY_SIG) for rnd_lock_sources.

(riastradh)

2022-03-20 14:05:41 UTC MAIN commitmail json YAML

Revert "entropy(9): Nix rnd_trylock_sources."

Not a premature optimization after all -- this is necessary because
entropy_request can run in softint context, where the cv_wait_sig in
rnd_lock_sources is forbidden.  Need to do this another way.

(riastradh)

2022-03-20 13:44:18 UTC MAIN commitmail json YAML

entropy(9): Nix rnd_trylock_sources.

This was a premature optimization that turned out to be bogus.  It's
not harmful to request more than we need from drivers, so let's not
go out of our way to avoid that.

(riastradh)

2022-03-20 13:18:30 UTC MAIN commitmail json YAML

ualea(4): Enter the data under the softc lock.

This avoids a race with a concurrent ualea_get updating sc_needed,
which could lead to hang when requesting more entropy.

ualea(4) now survives

sysctl -w kern.entropy.depletion=1
cat </dev/random >/dev/null &
cat </dev/random >/dev/null &

without hanging for longer (even if yanked and reinserted in the
middle, although the detach path is not relevant to the bug this
change fixes).

(riastradh)

2022-03-20 13:18:12 UTC MAIN commitmail json YAML

entropy(9): Fix another new race in entropy_account_cpu.

The consolidation xcall can preempt entropy_enter, between when it
unlocks the per-CPU state and when it calls entropy_account_cpu, with
the effect of setting ec->ec_pending=0.

Previously this was impossible because we called entropy_account_cpu
with the per-CPU state still locked, but that doesn't work now that
the global entropy lock is an adaptive lock which might sleep which
is forbidden while the per-CPU state is locked.

(riastradh)

2022-03-20 13:17:44 UTC MAIN commitmail json YAML

entropy(9): Shuffle some assertions around.

Tripped over (diff || E->pending == ENTROPY_CAPACITY*NBBY), not sure
why yet, printing values will help.

No functional change intended.

(riastradh)

2022-03-20 13:17:32 UTC MAIN commitmail json YAML

entropy(9): Lock the per-CPU state in entropy_account_cpu.

This was previously called with the per-CPU state locked, which
worked fine as long as the global entropy lock was a spin lock so
acquiring it would never sleep.  Now it's an adaptive lock, so it's
not safe to take with the per-CPU state lock -- but we still need to
prevent reentrant access to the per-CPU entropy pool by interrupt
handlers while we're extracting from it.  So now the logic for
entering a sample is:

- lock per-CPU state
- entpool_enter
- unlock per-CPU state
- if anything pending on this CPU and it's time to consolidate:
  - lock global entropy state
  - lock per-CPU state
  - transfer
  - unlock per-CPU state
  - unlock global entropy state

(riastradh)

2022-03-20 13:17:09 UTC MAIN commitmail json YAML

entropy(9): Factor out logic to lock and unlock per-CPU state.

No functional change intended.

(riastradh)

2022-03-20 13:13:10 UTC MAIN commitmail json YAML

ualea(4): Simplify xfer error branches.

- Avoid going into a loop in case the transfer fails repeatedly --
  just give up immediately if it fails.

- Assert result size is reasonable; no need to assume usbdi(9) is
  malicious.  If it can return ux_actlen > ux_length, that's a bug in
  usbdi(9) that we should fix.

(riastradh)

2022-03-20 00:41:01 UTC MAIN commitmail json YAML

ualea(4): Fix detach and error paths.

- Set sc_needed before aborting the pipe to prevent the xfer callback
  from rescheduling itself.

- Make sure all paths out of the xfer callback clear sc_inflight.

While here, use device_printf instead of aprint_* after attach.

Now my system survives repeated insertion and yanking of ualea(4)
during:

sysctl -w kern.entropy.depletion=1
cat </dev/random >/dev/null

(riastradh)

2022-03-20 00:40:52 UTC MAIN commitmail json YAML

usbdi(9): Make sure aborting a pipe waits for all callbacks.

There may be a callback in flight from an xfer that has already been
taken off the queue by the time usbd_ar_pipe gets to it.  We must
guarantee that even that callback has completed before returning
control to the caller.

(riastradh)

2022-03-20 00:19:11 UTC MAIN commitmail json YAML

entropy(9): Avoid reentrance to per-CPU state from sleeping on lock.

Changing the global entropy lock from IPL_VM to IPL_SOFTSERIAL meant
it went from being a spin lock, which blocks preemption, to being an
adaptive lock, which might sleep -- and allow other threads to run
concurrently with the softint, even if those threads have softints
blocked with splsoftserial.

This manifested as KASSERT(!ec->ec_locked) triggering in
entropy_consolidate_xc -- presumably entropy_softintr slept on the
global entropy lock while holding the per-CPU state locked with
ec->ec_locked, and then entropy_consolidate_xc ran.

Instead, to protect access to the per-CPU state without taking a
global lock, defer entropy_account_cpu until after ec->ec_locked is
cleared.  This way, we never sleep while holding ec->ec_locked, nor
do we incur any contention on shared memory when entering entropy
unless we're about to distribute it.  To verify this, sprinkle in
assertions that curlwp->l_ncsw hasn't changed by the time we release
ec->ec_locked.

(riastradh)

2022-03-19 20:50:32 UTC MAIN commitmail json YAML

usb: Insert assertion to diagnose ud_cdesc/ud_ifaces inconsistency.

Syzbot found a way to see ud_cdesc=NULL but ud_ifaces!=NULL:

https://syzkaller.appspot.com/bug?id=e6d4449a128e73a9a88100a5cc833e5cae9fecae

Maybe it's a race with two threads somehow doing usbd_free_device at
the same time when only one should, but let's rule this case out
early on to make it easier to prove it has to be a race.

(riastradh)

2022-03-19 20:44:07 UTC MAIN commitmail json YAML

umidi(4): Parse descriptors a little more robustly.

Reported-by: syzbot+fd58d1d4dd12f8931486@syzkaller.appspotmail.com

(riastradh)

2022-03-19 16:20:45 UTC MAIN commitmail json YAML

viornd(4): Revert IPL change for lock.

This lock is taken in hard interrupt context, so it needs to remain
at IPL_VM.

(riastradh)

2022-03-19 14:48:31 UTC MAIN commitmail json YAML

lint: be more specific in comment about <ctype.h> check

No binary change.

(rillig)

2022-03-19 14:35:13 UTC MAIN commitmail json YAML

Makefile: fix location of postinstall program for MAKEVERBOSE > 2

If MAKEVERBOSE > 2, each shell command from a make target is echoed.
This resulted in two additional words ending up in the variable
_POSTINSTALL.  Noticed by Brad Harder.

Before:
$ make -v _POSTINSTALL MAKEVERBOSE=3
echo .../usr.sbin/postinstall .../usr.sbin/postinstall/postinstall ...

After:
$ make -v _POSTINSTALL MAKEVERBOSE=3
.../usr.sbin/postinstall/postinstall ...

(rillig)

2022-03-19 14:35:08 UTC MAIN commitmail json YAML

rnd(9): Delete legacy rnd_initial_entropy symbol.

Use entropy_epoch() instead.

XXX kernel ABI change deleting symbol requires bump

(riastradh)

2022-03-19 14:34:48 UTC MAIN commitmail json YAML

kern: Delete kernel_ticks from kernel ABI.

Use getticks() instead.

(riastradh)

2022-03-19 13:53:33 UTC MAIN commitmail json YAML

2022-03-19 13:52:45 UTC MAIN commitmail json YAML

Remove now unused genfs_nolock(), genfs_nounlock() and genfs_noislocked().

(hannken)

2022-03-19 13:52:11 UTC MAIN commitmail json YAML

2022-03-19 13:51:35 UTC MAIN commitmail json YAML

2022-03-19 13:51:01 UTC MAIN commitmail json YAML

2022-03-19 13:50:28 UTC MAIN commitmail json YAML

Lock vnode across VOP_OPEN.

(hannken)

2022-03-19 13:50:02 UTC MAIN commitmail json YAML

Lock vnode across VOP_OPEN.

(hannken)

2022-03-19 13:49:21 UTC MAIN commitmail json YAML

Lock vnode across VOP_OPEN/VOP_IOCTL/VOP_CLOSE.

(hannken)

2022-03-19 13:48:42 UTC MAIN commitmail json YAML

Switch MFS device node to real vnode locking, VV_LOCKSWORK now.

(hannken)

2022-03-19 13:48:04 UTC MAIN commitmail json YAML

As FSTRANS is part of VOP_*LOCK() since June 4, 2017 the vdead_check()
from union_lock() is no longer needed.

Adapt union_lock() to the recent addition of upgrade or downgrade.

VV_LOCKSWORK now.

(hannken)

2022-03-19 11:55:03 UTC MAIN commitmail json YAML

rnd(9): Omit needless locks in various HWRNG drivers.

Now that the rnd(9) API guarantees serial callbacks, we can simplify
everything a bit more.

(Some drivers like hifn(4) and sun8icrypto(4) still use locks to
coordinate with other parts of the driver to submit requests to and
process responses from the device.)

(riastradh)

2022-03-19 11:54:53 UTC MAIN commitmail json YAML

rnd(9): Document the serial use of rndsource callbacks.

This simplifies the rndsource API -- no need to lock, unless you're
also coordinating with other driver logic like concurrent
opencrypto(4) requests that share device requests.

(riastradh)

2022-03-19 11:37:17 UTC MAIN commitmail json YAML

tegra124_car(4): Attach rndsource synchronously.

It looks like the original motivation for deferring to
config_interrupts was to wait until softint_establish worked.  But
this no longer needs to use softints to deliver the entropy, so
that's moot.

Doing this synchronously gives us a better chance for more entropy
earlier.

(riastradh)

2022-03-19 11:37:06 UTC MAIN commitmail json YAML

2022-03-19 11:36:53 UTC MAIN commitmail json YAML

tegra124_car(4): No need for rnd lock -- delete it.

This only ever reads from a single device register, so no need to
serialize access.

XXX This should really have a hardware-specific health test, but I
can't find any documentation on the underlying physical entropy
source.

(riastradh)

2022-03-19 11:36:43 UTC MAIN commitmail json YAML

meson_rng(4): No need for lock -- delete it.

We only ever read a single register at a time; no exclusive access or
serialization needed.

XXX This driver should have some kind of hardware-specific health
test -- is there documentation anywhere for what this RNG actually
is?

(riastradh)

2022-03-19 10:05:52 UTC MAIN commitmail json YAML

usbdi(9): Fix usbd_get_no_alts.

This incorrectly rejected the configuration as invalid if any
descriptor is not large enough to be interface descriptors.

Instead, it should reject the configuration only if any descriptor is
not large enough to be a _descriptor_, or if any interface-type
descriptor is not large enough to be an interface descriptor, but
skip over descriptors of other types even if they're smaller than
interface descriptors.

Candidate fix for PR kern/56762.

(riastradh)

2022-03-19 09:55:30 UTC MAIN commitmail json YAML

2022-03-19 09:54:25 UTC MAIN commitmail json YAML

Alight code re-organisation so it better matches the VPRINTF headings
it is under. NFCI.

(skrll)

2022-03-19 09:53:19 UTC MAIN commitmail json YAML

Slight code re-organisation. NFCI.

(skrll)

2022-03-18 23:37:14 UTC MAIN commitmail json YAML

clockrnd(9): Use atomic_load_relaxed for struct clockrnd::needed.

This may be set concurrently by clockrnd_get, so let's match the
atomic_store_relaxed and avoid the appearance of data races.

(riastradh)

2022-03-18 23:37:06 UTC MAIN commitmail json YAML

entropy(9): Establish the softint a little earlier.

Just need to wait until softint_establish and high-priority xcalls
will work, no later than that.  Doing this earlier gives us slightly
more of a chance to ensure cprng_fast and ssp get entropy from
hardware RNG devices that rely on interrupts.

(riastradh)

2022-03-18 23:36:57 UTC MAIN commitmail json YAML

sun8icrypto(4): Do self-test and first RNG draw synchronously.

If the self-test fails, disable everything else at boot -- don't just
leave it to the operator to notice and do something.

This way we get entropy earlier at boot, before threads start and
before the first things in the kernel that draw from it (cprng fast
init, ssp init).

(riastradh)

2022-03-18 23:36:42 UTC MAIN commitmail json YAML

sun8icrypto(4): Attach rndsource as RND_TYPE_RNG.

Previously this was attached as RND_TYPE_UNKNOWN, at a time when the
kernel assumed _any_ RNG-type rndsource produced independent uniform
random bits and subjected it to automatic tests that would fail with
high probability for many other distributions.  But sun8icrypto(4) is
very nonuniform (probably yields consecutive samples of a ring
oscillator, which are very much not independent).

Now the kernel no longer makes this assumption, so it is valid to
label this as what it is -- a hardware RNG.  We should ideally still
have better information from the vendor about what's going on under
the hood before enabling nonzero entropy for it.  But at least we can
label its type accurately.

(riastradh)

2022-03-18 23:35:48 UTC MAIN commitmail json YAML

sun8icrypto(4): Split out interrupt and thread locks.

No need to block interrupts while we're going through all the data
structures -- only need to block interrupts for the handoff from
interrupt handler to lower-priority logic.

(riastradh)

2022-03-18 23:35:37 UTC MAIN commitmail json YAML

getrandom(2): Fix return value checks in automatic tests.

The syscall only guarantees up to 256 bytes in a single go -- if
interrupted, it might return short, but if the caller requested at
least 256 bytes it will definitely return 256 bytes.

(riastradh)

2022-03-18 23:35:28 UTC MAIN commitmail json YAML

entropy(9): Count dropped or truncated interrupt samples.

(riastradh)

2022-03-18 23:35:19 UTC MAIN commitmail json YAML

entropy(9): Reduce global entropy lock from IPL_VM to IPL_SOFTSERIAL.

This is no longer ever taken in hard interrupt context, so there's no
longer any need to block interrupts while doing crypto operations on
the global entropy pool.

(riastradh)

2022-03-18 23:35:07 UTC MAIN commitmail json YAML

entropy(9): Request entropy after the softint is enabled.

Otherwise, there is a window during which interrupts are running, but
the softint is not, so if many interrupts queue (low-entropy) samples
early at boot, they might get dropped on the floor.  This could
happen, for instance, with a PCI RNG like ubsec(4) or hifn(4) which
requests entropy and processes it in its own hard interrupt handler.

(riastradh)

2022-03-18 23:34:56 UTC MAIN commitmail json YAML

entropy(9): Use the early-entropy path only while cold.

This way, we never take the global entropy lock from interrupt
handlers (no interrupts while cold), so the global entropy lock need
not block interrupts.

There's an annoying ordering issue here: softint_establish doesn't
work until after CPUs have been detected, which happens inside
configure(), which is also what enables interrupts.  So we have no
opportunity to softint_establish the entropy softint _before_
interrupts are enabled.

To work around this, we have to put a conditional into the interrupt
path, and go out of our way to process any queued samples after
establishing the softint.  If we just made softint_establish work
early, like percpu_create does now, this problem would go away and we
could delete a bit of logic here.

Candidate fix for PR kern/56730.

(riastradh)

2022-03-18 23:34:44 UTC MAIN commitmail json YAML

entropy(9): Create per-CPU state earlier.

This will make it possible to use it from interrupts as soon as they
start, which means the global entropy pool lock won't have to block
interrupts.

(riastradh)

2022-03-18 23:33:41 UTC MAIN commitmail json YAML

drm: In ww_mutex_unlock, do lockdebug check first.

This way we get a full lockdebug dump when LOCKDEBUG is enabled,
instead of just the panic message (which includes the lock address
you could pass to `show lock' in ddb, but let's get the dump by
default even if you don't enter ddb).

Also in the KASSERT print the mutex.

(riastradh)