EC2: Set hw.dmar.enable="1"
Large EC2 "bare metal" instances route interrupts to APIC IDs > 255,
and unlike the "virtualized" instances, don't support extended APIC
destination IDs (since that's a hypervisor feature, and bare metal
instances have no hypervisor).
Enable the IOMMU for interrupt remapping; this unbreaks booting on
m8i.metal-96xl and variants thereof (e.g. c8in).
MFC after: 1 day
Sponsored by: Amazon
Tested on: c5n.9xlarge, c6a.24xlarge, c8in.96xlarge, c5.metal,
c6in.metal, c6a.metal, c7a.metal-48xl, c7i.metal-24xl,
c7i.metal-48xl, c8a.metal-24xl, c8a.metal-48xl,
c8i.metal-48xl, c8i.metal-96xl, c8in.metal-48xl,
c8in.metal-96xl, m5.metal, m8azn.metal-24xl
evdev: Map the HP mic mute and programmable keys on HP only
AT scan codes 0xE0 0x01 and 0x68 are vendor keys: systemd's hwdb gives
them other meanings on Dell, Alienware, Lenovo, Samsung and others,
some of which send no release code. The shared AT table made Insert
toggle mic mute on an IdeaPad 5 and left KEY_PROG1 held after the Dell
G-Mode key.
Map them only where SMBIOS names an HP business laptop, as hwdb does:
0xE0 0x01 to KEY_MICMUTE on ZBook, EliteBook, ProBook, Elite Dragonfly
and EliteBoard, 0x68 to KEY_PROG1 on the Elite Dragonfly G2 and the
ZBook Ultra G1a.
Reported by: llm-postcr
Reviewed by: imp, wulf
Approved by: wulf
Fixes: d34baf1b5ca0 ("evdev: Map the HP mic mute and programmable keys")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/130
netinet6: check the length of the destination address
in6_validate_ifra() requires ifra_addr to be a struct sockaddr_in6,
but it accepts an AF_INET6 ifra_dstaddr with any sin6_len, and
in6_notify_ifa() stores that address in ia_dstaddr as given.
Reject an AF_INET6 destination address whose sin6_len is not
sizeof(struct sockaddr_in6) with EINVAL, as in_aifaddr() does for
IPv4. ifconfig(8), the netlink address handler and the kernel's own
callers already pass the right length.
Add tests/sys/netinet6/in6_control, whose cases run in a VNET jail:
- aifaddr_dstaddr: SIOCAIFADDR_IN6 stores a valid destination
address, and getifaddrs(3) reports it;
- aifaddr_dstaddr_badlen: SIOCAIFADDR_IN6 rejects a destination
address with sin6_len 255.
aifaddr_dstaddr_badlen fails without the fix.
Reviewed by: glebius, markj
[3 lines not shown]
nfscommon: Fix a couple of slot handling cases
If a server shrinks the slot table for a NFSv4.1/4.2 session
(the FreeBSD server does not do this), it might have failed
to reset the slot's sequence# to 0, do to not handling the
case where the slot# equals the foreslot limit.
Also, a typo would fail when the slot# is greater than 31,
due to the type of the 1 being shifted.
This patch fixes both of these.
Reported by: Chuck Lever <cel at kernel.org>
MFC after: 2 weeks
powerpc: fix an off-by-one when widening 32-bit syscall arguments
cpu_fetch_syscall_args() widens the arguments a 32-bit syscall passes on
the stack. The loop started at narg instead of narg - 1 and wrote
td_sa.args[narg], one past the end of the eight entry array, which is
td_sigblock_ptr in struct thread. NARGREG is 8, so a plain syscall never
enters the loop, but syscall(2) and __syscall(2) lower the register count
to 7 and 6, and an eight argument syscall made that way, like
freebsd32_sendfile with its two slot off_t, corrupted the pointer.
A 32-bit program calling sendfile through syscall(2) changed its own
td_sigblock_ptr (watched with DTrace on cpu_fetch_syscall_args); it
leaves it alone now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61884
cpu_switch(): Move 'sw1wait' inside the function block
This code block is unrelated to the resumectx() procedure it was after,
and is referenced only by cpu_switch(), so move it between
ENTRY(cpu_switch) and END(cpu_switch). This, in particular, puts it
inside a .cfi_startproc/.cfi_endproc block, giving clearer debugging
information should a problem arise there.
Keep it at the end so that jumping to it is initially predicted not
taken.
Reviewed by: kib
Fixes: 73dd84a7a54d ("amd64: clean up cpu_switch.S")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61713
libsysdecode: Avoid non-portable \> word end boundary in mktables
Whilst we bootstrap our own sed when building on non-FreeBSD, it uses
the system regex(3) implementation, and so inherits its extensions, not
our own. Our implementation and glibc's both include this extension to
POSIX, but macOS's does not, and so even with our bootstrap sed we
cannot use the \> extension when built and run on macOS.
Unfortunately, there is no alternative form we can use; whilst macOS
implements [[:>:]] as an extension that provides this same feature, and
so do we, the regex(3) implementation in glibc does not, and the only
alternative glibc offers is \b, which neither us nor macOS implement.
We could make the form used conditional on the OS, but that starts to
get messy once other Linux libcs enter the picture, which in theory we
somewhat support.
Rewrite both uses to avoid the need for \>. For gen_table, use a pattern
to match the identifier that is precisely the (non-extended) C99
[25 lines not shown]
bsnmp: drop messages with an unsupported SNMP version
snmp_pdu_decode_header() returned SNMP_CODE_BADENC for an unknown
version. snmp_input_start() treats BADENC as a bad value in a SET and
carries on, so its version check, which runs only for SNMP_CODE_OK, was
skipped. The message then reached snmp_pdu_auth_access(), which with
snmp_vacm loaded switched on pdu->version and called abort() for
SNMP_Verr. A single unauthenticated packet could stop bsnmpd.
Return SNMP_CODE_BADVERS instead, as bsnmplib(3) documents, so the
message is counted in snmpInBadVersions and dropped. Remove the
mapping in snmp_pdu_decode() that tried to do this but was never
reached, and have snmp_pdu_auth_access() deny an unknown version
rather than abort.
Reported by: Hila Cohen, Apiiro (hillalee on github)
Reviewed by: harti
MFC after: 3 days
tcp: improve consistency
Use an inline function tcp_adapt_iss_check() to perform the check
consistently instead of replicating the code multiple times. These
checks already became inconsistent.
A fix for PR 298560 requires more calls to tcp_adapt_iss_check().
Reviewed by: Peter Lei
Fixes: fa2ad70a4511 ("tcp: make ghost ACK handling more conformant")
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61685
(cherry picked from commit e3483dbc91b59b5b2c73a4bc792fbb834c3dc111)
tcp: improve sender side SWS avoidance
When checking for a full sized segment, take all TCP options that will
be included into account. This fixes a bug which can trigger the
"sent too much" KASSERT related to limited transmit.
Reported by: olivier
Reviewed by: rscheff, Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61605
(cherry picked from commit d174085f9f895ed444bd95120da3eff481a58f1a)
tcp bbr: improve handling of retransmissions in LAST-ACK
When performing a timer based retransmission, clear the
BBR_RWND_COLLAPSED flag. If it sticks, t_rxtshift is never incremented
resulting in unlimited retransmissions in the LAST-ACK state.
Reported by: Illia Vynohradov
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61586
(cherry picked from commit 3c6fd437b1824caeddb5f0d4570d43cf0c999c14)
tcp bbr: improve persits timeout computation
t_srtt and t_rttvar use different lengths of fractions, therefore use
the appropriate shift value.
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61600
(cherry picked from commit 751882926dc0bb1f7a4834c4b5e8d951cee61c7c)
tcp bbr: improve retransmit timout calculation
The retransmission timeout should the srtt + 4 * rttvar.
The srtt is using 5 bits of fractions and rttvar is using 4 bits of
fractions, some specific shifting is required.
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61581
(cherry picked from commit 2f98793a13fe3e69cf6b698fa469550b4ba0fea1)
tcp bbr: improve invalidating rtt
Invalidate the rtt based on t_rxtshift instead of resetting t_srtt to 0,
because using the latter also affects the retransmission timeout.
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61585
(cherry picked from commit 8018d75601dfe804a8d70f4f08bdb0e4e3a8c5c9)
tcp: make ghost ACK handling more conformant
The latest version of draft-ietf-tcpm-tcp-ghost-acks changed
a condition. This should make no substantial difference, but makei
it compliant to the latest version of the specification.
Reviewed by: rscheff, Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D58411
(cherry picked from commit fa2ad70a4511e7b379e81de82c9e51b2e0994295)
amd64/arm64 pmap: Mark pmap_enter()'s large page case unlikely
PMAP_ENTER_LARGEPAGE is only used to map non-transparent large page
shared memory objects. Tell the compiler that this case is unlikely.
This hint stops pmap_enter_largepage() from being inlined into
pmap_enter(), which shortens pmap_enter()'s more common execution path
on both amd64 and arm64.
MFC after: 1 week
cd9660 tests: Require the cd9660 kernel module
When cd9660(4) is not loaded and cannot be loaded, mount(8) fails
with ENODEV instead of the expected EINVAL, and cd9660_rrip_pr296853
fails rather than skips.
Reviewed by: jfree
Approved by: jfree
Fixes: 1a4c2eedad5b ("cd9660: Fix dereferencing invalid RR outlen ptr")
Sponsored by: Netflix
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/132
bhyve: add command to list config options
For a software built on top of bhyve(8) and/or managing bhyve(8),
it is very convenient to know what specific features the given binary supports.
Currently, bhyve(8) provides some of this information, and it could be
retrieved by parsing `bhyve -h`, `bhyve -s help`, `bhyve -l help`.
Sometimes it is not enough, for example, the recently added
"oemstrings" feature cannot be fully probed using these commands.
Over time, some workarounds were suggested. Specifically:
- Mapping features to __FreeBSD_version. I see at least two issues with
that:
* __FreeBSD_version does not directly map to bhyve(8) features,
so this is simply not accurate.
* bhyve(8) might be updated separately from the system, which
is not so uncommon, especially for development purposes.
Then such a probing will be inaccurate.
[34 lines not shown]
linux: Move the machine-dependent ioctl bits into per-arch headers
Move both out of <compat/linux/linux_ioctl.h> and into
<machine/../linux/linux_ioctl.h> and <machine/../linux/linux_termbits.h>,
following the lead of linux_emul_md.h. Every architecture linuxulator
currently supports uses the asm-generic values, so the new per-arch
headers either spell out the generic encoding or just include the common
termbits set, and nothing changes for them. This is all in preparation
for powerpc64 linuxulator.
While here, move the termio structures from linux_ioctl.c up to
linux_ioctl.h, next to the constants that size them.
No functional change intended.
Differential Revision: https://reviews.freebsd.org/D61330
linux: Add a LINUX_TODO() macro
Unimplemented corners of the Linuxulator are easier to find when they
announce themselves instead of silently returning. LINUX_TODO() prints
a rate-limited message naming the function and what the stub is still
missing, built on the existing LINUX_RATELIMIT_MSG_OPT1().
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D61329
lindebugfs: Remove unneeded header
linux_ioctl.h is not needed in order to build, so remove it. A future
change will split linux_ioctl.h into arch-specific headers, and 32-bit
arm does not have a compat linux so would fail the build, and adding a
header just to appease lindebugfs would be superfluous, given that it's
not needed.
sys/arm64: TTL fixes
Set TTL bits in TLBI_RANGE_FIELDS() regardless of FEAT_TTL; these bits are
defined by FEAT_TLBIRANGE.
Set TTL in per-page invalidate path (pmap_s1_invalidate_loop()).
Reported by: alc
Reviewed by: alc
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D61390
Merge commit 5472aa0c1321 from llvm git (by Piotr Kubaj):
[PowerPC] Use the 16-byte stack and vector alignment on FreeBSD (#232336)
FreeBSD uses the ELFv2 ABI on both byte orders, so it has the same
16-byte stack alignment as Linux. The explicit vector alignment is a
backend workaround that does not depend on the OS. There is no
reason for the layouts to differ.
llvm 21 still keeps the data layout in two places, so the check is
changed in both the PowerPC backend and clang. They have to match, or
clang errors out with a data layout mismatch.
Reviewed by: dim
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D61678
(cherry picked from commit d1470ac7f365a1846b8cc565b76592c7a79a22e3)
powerpc: move get_pcpu() to machine/pcpu.h
Every other arch defines get_pcpu() in machine/pcpu.h, powerpc has it in
machine/cpufunc.h, which is entirely under _KERNEL. lsof includes
sys/systm.h without _KERNEL first on purpose, so on powerpc cpufunc.h
turns into an empty header and pcpup later expands to a call of an
undeclared get_pcpu(). Since sys/mount.h started pulling in sys/proc.h
this breaks the lsof build on powerpc64 and powerpc64le.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61305
(cherry picked from commit 4b3364a4bceb61c5870f50b75bf56272ca850944)
powerpc: save and restore VRSAVE with the vector state
VRSAVE was never saved or restored, although user code can write it
and the mcontext carries it, so every process saw the value the
previous process on that CPU had left there.
Two processes pinned to the same CPU and writing different values to
VRSAVE each read back the other's; each reads back its own now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61544
(cherry picked from commit 26b47fd4b63c4e67a952f9a4f0ceb89bcb6a24ac)
Merge commit 5472aa0c1321 from llvm git (by Piotr Kubaj):
[PowerPC] Use the 16-byte stack and vector alignment on FreeBSD (#232336)
FreeBSD uses the ELFv2 ABI on both byte orders, so it has the same
16-byte stack alignment as Linux. The explicit vector alignment is a
backend workaround that does not depend on the OS. There is no
reason for the layouts to differ.
llvm 21 still keeps the data layout in two places, so the check is
changed in both the PowerPC backend and clang. They have to match, or
clang errors out with a data layout mismatch.
Reviewed by: dim
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D61678
(cherry picked from commit d1470ac7f365a1846b8cc565b76592c7a79a22e3)