TMP461 sensor: Fix temperature reading in extended range mode
In extended range mode, the temperature's integral part is stored as an
unsigned byte offset by 64, not as a signed byte. Stop treating it as
a signed value in this case, in particular sign extending it. Doing so
would cause temperatures above 128°C (and in particular nearing the
maximum operating point of 150°C) to be treated as negative ones, as the
sign extension happened after substracting the offset. In the original
commit introducing the driver, sign extension was done before, in which
case the problem manifested as soon as 64°C. It may have been noticed
while introducing support for ADT7461, but was not completely fixed at
that time.
While here, fix typos in two comments.
Reported by: llm-postcr
Reviewed by: manu
Fixes: f89f6f9581bd ("TMP461: Add thermal sensor driver")
Fixes: 6665c7a62839 ("TMP461: Add support for ADT7461 sensor")
[3 lines not shown]
TMP461 sensor: Fix UB when reading the temperature
Left shifting a potentially negative number is undefined behavior
according to the C standard (still in C23, although that's probably
a mistake for this one).
Shift left the just-read data first, as it is of an unsigned type
(uint8_t), and then sign-extend the result with the new sign_extend32().
Reviewed by: manu
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61763
tests/sys/kern/procdesc: test the reaper's own PD_NOWAITPID child
Check that the reaper can waitpid(2) for its PD_NOWAITPID child after
closing the last process descriptor, untraced, detached, or with the
tracing reaper exiting.
Based on reproducers provided by Laam Alif <laamalif at proton.me>.
PR: 301072
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61975
procdesc_close(): grant waitpid(2) when the reaper is already the parent
When the process is already a child of its reaper, proc_reparent()
returns early and does not re-enable waitpid(2), so after the last
process descriptor was closed nobody could reap the zombie. If the
reaper was also tracing the process, it was additionally linked onto
the reaper's own orphan list, and after PT_DETACH it stayed there
untraced, again without a waitpid(2) reference.
PR: 301072
Reviewed by: kib, markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61975
libc/powerpc64: save v20-v31 in setjmp
setjmp and its variants save the non-volatile GPRs and FPRs, but not the
non-volatile vector registers v20-v31, so after a longjmp they hold
whatever the code that jumped left in them. Julia runs into this when it
switches tasks with sigsetjmp/siglongjmp: the compiler keeps vector values
in v20-v31 and they come back from another task.
jmp_buf has had room for them all along. Add setjmp entry points that save
them and pick those with ifuncs when the CPU has Altivec, so the same libc
still works on CPUs without it, like the e5500. They note in the buffer
where the registers went, and longjmp loads them back only if the note is
there.
rtld can't use ifuncs, so it builds its own sigsetjmp that checks hwcap
when it's called. It needs the registers saved too: when it restarts a
symbol lookup to upgrade its lock, it longjmps out of functions that use
v31, and a lazily bound call came back with v31 zeroed.
[3 lines not shown]
bhyve: e82545: allow access to the last receive address register
The model exposes 16 receive address register pairs, but both accessors
asserted that the index was below 15. Use E82545_RAR_MAX as the last
valid index for the register ranges and accessors. Size the address
array from the same limit and use its length when clearing valid bits.
Signed-off-by: Wanpeng Qian <wanpengqian at gmail.com>
MFC after: 2 weeks
Sponsored by: keelos.dev
Differential Revision: https://reviews.freebsd.org/D60219
Co-authored-by: Kevin Bowling <kbowling at FreeBSD.org>
linux(4): compare xattr namespace names with strcmp()
xattr_to_extattr() compared each namespace over the length of the
caller's prefix and would read past the end of any shorter name
the values are already null-terminated so we can just use strcmp()
here
Reviewed by: rmoeller
Differential Revision: https://reviews.freebsd.org/D60954
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