x86/GENERIC: Enable PCI_RESOURCE.
Has been needed for motherboards that are already several years old
by now, which require the OS to allocate PCI memory regions for some
devices like iwm(4); let's get some experience with having it on by
default.
PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
make: in meta mode allow more general filtering
When a pre-built tree is cloned or relocated it is necessary to
filter all paths in .meta files that refer to the original location
to refer to the new.
For example (SB names the parent directory of src):
.if ${SB} != ${SB_ORIGIN:U${SB}}
.MAKE.META.FILTER += S,${SB_ORIGIN},${SB},
.endif
for commands; this is applied prior to any filters from
.MAKE.META.CMP_FILTER
but it is also applied to paths in the filemon syscall records
so we do not lose the benefit of them.
Reviewed by: rillig
atomic_store(9): Fix byte indexing on hash-locked architectures.
Fixes the easy part of:
PR kern/60393: hash-locked atomic_store_* is all kinds of busted
The hard part will require redoing these to just hash-lock the whole
store.
Pass the actual mutex to mutex_spin_retry()
Avoid a situation where leftover splraise SR-mask cookie stays in a0.
Make UP kernel that double-acquires a spin mutex die with
"locking against myself" rather misleading garbage-pointer crash.
Part of fix for PR lib/58282
Redo the logic for erasing lines when we have the capability, it was
broken and caused blanks to be written when clearing the screen instead
which caused thrashing and large outputs.
Back out changes to quickch() which were actually just work arounds
for broken hashes and were the cause of an infinite hang seen in
the previous commit of these changes.
wg-userspace(8): Ignore recvfrom errors.
On IPv6 networks, issuing sendto(2) when we've lost IPv6 connectivity
may eventually lead to the next recvfrom(2) failing with EHOSTDOWN.
Example ktrace:
8072 16529 rump_server 1782951176.090085182 CALL sendto(0xa,0x70fb4fa1b50c,0x60,0,0x70fb4f236b00,0x1c)
8072 16529 rump_server 1782951176.090085664 MISC msghdr: [name=0x70fb4f236b00, namelen=28, iov=0xffffc5126bfa8f50, iovlen=1, control=0x0, controllen=0, flags=0]
8072 16529 rump_server 1782951176.090086919 MISC mbsoname: [2601:...]
8072 16529 rump_server 1782951176.090093493 GIO fd 10 wrote 96 bytes
8072 16529 rump_server 1782951176.090094033 RET sendto 96/0x60
...
8072 23248 rump_server 1782951180.090105990 CALL recvfrom(0xa,0x70fb4efe203c,0x233a,0,0x70fb3f7cff50,0x70fb3f7cff4c)
8072 23248 rump_server 1782951180.090106339 MISC msghdr: [name=0x0, namelen=0, iov=0xffffc5126c63ff20, iovlen=1, control=0x0, controllen=0, flags=0]
8072 23248 rump_server 1782951180.090107309 RET recvfrom -1 errno 64 Host is down
In this case, wg_user_rcvthread mistakenly ignored the failing result
and blithely shoved the ssize_t -1 error indicator into
iov[1].iov_len and passed it on to rumpkern_recv_peer:
[34 lines not shown]
wg-userspace(8): Drop <4-byte UDP packets immediately.
Same as the kernel already does. Add an assertion into
wg_receive_packets about this and a couple comments cross-referencing
wg_overudp_cb and wg_receive_packets.
And, while here, as a precaution in case the
inpcb_register_overudp_cb mechanism ever breaks down or gets
refactored, make wg_receive_packets drop <4-byte packets too -- this
path should be hit only when handling handshake packets, so adding
another predicted-not-taken branch here should cost essentially
nothing.
PR bin/60392: assertion "mbuflen >= sizeof(struct wg_msg)" failed
rescue/ldd: Add a couple new symbols for recent rtld changes.
Should fix:
# link rescue/rescue
...
/tmp/build/2026.07.01.20.39.44-i386/tools/lib/gcc/i486--netbsdelf/14.3.0/../../../../i486--netbsdelf/bin/ld: /tmp/build/2026.07.01.20.39.44-i386/obj/usr.bin/ldd/elf32/libldd_elf32.a(load.o): in function `_rtld_load_object':
load.c:(.text+0x23b): undefined reference to `_rtld_objgen'
/tmp/build/2026.07.01.20.39.44-i386/tools/lib/gcc/i486--netbsdelf/14.3.0/../../../../i486--netbsdelf/bin/ld: load.c:(.text+0x256): undefined reference to `_rtld_objrelocpending'
PR lib/59751: dlclose is not MT-safe depending on the libraries
unloaded
ld.elf_so(1): Bump _rtld_objgen when changing, not reading, objlist.
Prompted by:
PR lib/59751: dlclose is not MT-safe depending on the libraries
unloaded
ld.elf_so(1): Resolve several races in dlopen/dlclose.
This is difficult because, although rtld generally has a single
exclusive lock, i.e., generally runs single-threaded itself, it can't
hold this lock while calling constructors/destructors (init/fini or
ifunc) -- if it did, then, for example, lazy symbol binding that
happens during the constructor/destructor would deadlock against
itself.
And whenever rtld drops the lock to call constructors/destructors,
any objects it is working on, during dlopen or dlclose, might have
been concurrently closed and invalidated by the time it gets the lock
again.
The key point is that anywhere we pass a sigset_t *mask parameter
during dlopen or dlclose, we might release the rtld lock to sleep and
then reacquire the lock. And anywhere we might release and reacquire
the lock, any objects we hold may be invalidated -- unless we hold some
reference to prevent invalidation. And any object we find in the list
[129 lines not shown]
sdmmc: remove unused cmd fields
c_dmaseg and c_dmaoff are only written using memset(&cmd, 0) when
constructing a command, so they always assume a constant value and can be
removed.
/bin/sh fix trap/jobid builtins when run from grandchild
The trap and jobid builtins are designed to allow
T=$(trap)
(etc) to see (output) the traps (or jobs for jobid) of parent shell (the one
running the assignment) to be seen from inside a subshell (here the command
substitution, which it usually would be).
But all that should be reported are the traps (jobs) of the parent of
that subshell, not recursively up the chain.
That is
( T=$(trap) )
should usually be equivalent to T='' as inside a subshell environment
all non-ignored traps are defined to be reset to their defaults
[33 lines not shown]
sh tests: builtins: add more content
Many of the t_builtins sh tests were just placeholders for things to come.
They've been that way for years...
This adds some actual content to some of them - still very primitive in
most cases, but better than was there before. There are still too many
empty tests (test the builtin exists, but that's it).
Also, add a test for the trap builtin - that wasn't there before as traps
are tested in other of the sh tests ... this new one is therefor not testing
that traps work (or not in any way that's meaningful), rather it is testing
that the various ways the trap command can be used all work.
Currently two of the sub-tests will fail, the new trap test, and the
(was previously empty) jobid test (testing a NetBSD extension builtin).
Adding those failing tests was the inspiration for all of this. The bug
they expose is exotic, and never likely to be encountered, or do any harm
[7 lines not shown]
sh tests: arithmetic: fix test for support of pre ++/-- ops
The C prefix and postfix unary ++ and -- operators are optional
in POSIX sh (supported in NetBSD's sh). To allow these tests to be
used to test other shells, the tests generally attempt to verify that
optional features are supported, before testing them.
The prefix ++ and -- tests, to see if there was support in ${TEST_SH}
were not guaranteed to work, as ++X might be preincrement X, or it
might just be + + X (ie: applying the unary + operator twice).
Fix that by testing whether ++X and + + X give the same result, if
they do, then prefix ++ is not supported (also if ++X generates an error)
Just the same for the prefix -- operator.
The postfix operator tests are OK, X-- is either X-- or an error.
NFCI for tests of the NetBSD sh. (This change has been in my local
set of sh tests for a long time now.)
Avoid stupid macro name clash: m68k/include/reg.h defines R0 and R1
as the register offsets for returning values from functions in the.
These clash with local buffers R0 and R1 here.
Rename them to cookie_R0 and cookie_R1 to make all m68k ports build again.
unbound: Install a default configuration.
This way, setting unbound=YES is enough to get a working local
recursive resolver listening on 127.0.0.1:53 and [::1]:53.
PR misc/60339: unbound=YES in rc.conf should be enough to get a
recursive resolver
Additionally, this includes the workaround for:
PR bin/60325: unbound emits warning: so-sndbuf 4194304 was not
granted
x86/efi: Bypass kASAN memcpy when copying the efi runtime.
Fixes crash at boot with `options KASAN' enabled on EFI systems.
We could try to find some way to exclude the EFI runtime mappings
from kASAN, e.g. by hacking kasan_md_unsupported. But there's a lot
of detailed exclusions to pass through to that (every entry in the
EFI memory map), and this is the only memcpy in the whole kernel that
all those details are likely to be applicable.
PR kern/60391: kernel panic in efi_init() with "options KASAN"
Introduce EFIKA_OFW_WORKAROUNDS - patch OFW trampoline for EFIKA.
Long story short, is that SmartFirmware (EFIKA's OpenFirmware) misbehaves
on every OF call from the kernel by zeroing SDR1 and messing with BATs.
In the olden days, these problems were worked around with FIRMWORKSBUGS
option. However, that option does not work currently on EFIKA. Presumaly,
something has changed between 2012 and now, which causes FIRMWORKSBUGS
to hang on SmartFirmware very early (before NetBSD copyright banner is
printed).
So we get this kludge, which only does the bare minimum to let OFW
call succeed, and the kernel continue after the call.
citrus/HZ: Be more careful about encoding buffer.
1. Use unsigned char for chlen, since it's never negative and only
needs to be big enough for the ch array.
2. Expand the ch array by space for two escape sequences, each of
which is two characters.
I don't think it is currently possible with the i18n data we ship
for it to emit two escape sequences in a row -- there is a code
path to do this, but I don't think it can be reached without
setting escape sequences for variable 1 and extending this in some
way. Nevertheless, let's err on the side of safety.
3. Sprinkle assertions everywhere.
PR 59019: various iconv issues
iconv(3): Fix printing bytes on test failure.
Don't sign-extend to a 32-bit quantity causing the left to be padded
with f's; just print the 8-bit quantity.
PR 59019: various iconv issues