libvmmapi: Compare mapping lengths in vm_mmap_memseg()
vm_mmap_memseg() returns success without mapping anything when a
mapping with the same segment, offset, protection and flags already
starts at the requested address, but it does not compare the length.
A longer request then reports success for pages it did not map, and a
shorter one for a mapping that vm_munmap_memseg() cannot remove with
the same range. No caller in the tree makes such a request.
Fail with EEXIST when the length differs, as for the other attributes,
and document that behavior. Read the existing mapping into its own
structure rather than over the arguments.
Reviewed by: markj
Approved by: markj
Fixes: 9b1aa8d622e8 (Restructure memory allocation in bhyve to support "devmem".)
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61530
bhyve: Preserve string I/O registers on faults before progress
When a string I/O instruction faults on its first transfer, the emulator
injects the exception but still writes the masked index and count back
to the guest. With a 32-bit address size in 64-bit mode this clears
the upper halves of RSI or RDI and of RCX, although no transfer
completed and the processor reports such a fault with the registers
unchanged.
Return before updating the registers whenever no transfer completed,
whether an error, a guest fault or an injected exception stopped the
first one. Exception injection has already restarted the instruction.
A repeated instruction with a zero count is handled as before.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61499
bhyve: Preserve upper RAX bits for byte and word input
Scalar IN merges the input into a 32-bit EAX temporary and writes that
value to RAX. This clears bits 63:32 for byte and word inputs, which
must preserve the bits outside AL or AX.
Use vie_update_register() to update the accumulator at the operand
width. This preserves the remaining bits for byte and word inputs and
retains zero-extension for dword inputs.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61498
bcm2835_fbd: Use the pixel order to choose the 32 bpp palette
Recent Raspberry Pi firmware acts on the pixel order requested through
the mailbox, which older firmware ignored. The order that ends up in
the framebuffer is the requested one combined with framebuffer_swap in
config.txt: when they are the same the red component is in bits 0-7 of
a 32 bpp pixel, when they differ it is in bits 16-23. framebuffer_swap
defaults to on and the firmware reports it as bcm2708_fb.fbswap=1 in
the bootargs.
U-Boot always requests RGB, so with the default config.txt the pixels
have red in bits 0-7. The driver however always configured vt(4) with
red in bits 16-23 for 32 bpp, so red and blue were swapped on the
console.
The firmware does not report the resulting order, only the requested
one, so read the pixel order with GET_PIXEL_ORDER and combine it with
fbswap. If the pixel order cannot be read the previous behavior is
kept. The 24 bpp case is unchanged.
[6 lines not shown]
arm64: Reject user-mode faults on kernel addresses
On a CPU without FEAT_E0PD, a user-mode store to a mapped kernel
address takes a permission fault, which data_abort() passes to
pmap_fault() with the process's pmap. pmap_pte() then finds the user
mapping whose address has the same low-order bits. If that mapping is
writable, pmap_fault() marks it dirty, although nothing wrote it, and
returns KERN_SUCCESS. The store is retried and faults again, so the
thread spins instead of receiving SIGSEGV. Access flag faults, which
loads also take, have the same flaw when a kernel mapping lacks
ATTR_AF.
Like amd64's trap_pfault(), send SIGSEGV for a user-mode fault in the
kernel address space without calling pmap_fault() or vm_fault_trap().
Also, in pmap_fault(), assert that a kernel address comes with the
kernel pmap and a user address with a user pmap.
Found by: Claude Code (Opus 5.5)
[3 lines not shown]
contrib/lutok: upgrade to 0.7.0
This is a large cleanup release which has a number of changes that
should be largely transparent to end-users of lutok.
Please see NEWS for more details, as well as the vendor import commit.
MFC after: 1 week
Merge commit 'a1e3c85b0684e1a1896fbf811a894a45e658ec83'
lutok: import lutok-0.7.0
This change adds lutok lutok-0.7.0 from [upstream][1].
The lutok-0.7.0 artifact was been verified by [SHA256 checksum][3].
This is a major cleanup release. A lot of credit goes to mchoo@ for all of the
hard work submitted in #13 🎉.
The API should not change in a noticeable way to consumers, e.g., a number of
"transparent" changes like const poisoning was done with methods, etc.
Iterative builds will require rebuilding lutok from scratch--which should
happen naturally, given how header dependencies [should] be treated with make.
More information about the release (from a high level) can be found in
the [release notes][4].
Updated via [`update_lutok.sh`][4] like: `update_lutok.sh 0.7.0 lutok-0.7.0`.
[4 lines not shown]
rtwn: move rtwn_get_qmap + write register to rtwn_set_qmap
Upcoming chipset support changes the definition of the register.
So instead of having the abstraction be "return the qmap to write
to the register", change it to "set the qmap however the chipset
wants it to be."
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D61928
Tested on: RTL8821AU (adrian)
syslogd: Create one forwarding socket per address pair
For each address a forwarding destination resolves to,
make_forw_socket_array() creates a socket bound to the address of each
listening socket and connects it to the destination. The same
<laddr, raddr> pair can come up more than once for one rule: the
resolver may return an address twice, e.g. when a host name appears on
several /etc/hosts lines for one IP, and several listening sockets may
be bound to one address. connect() then fails with EADDRINUSE.
maybe_dup_forw_socket() only searches the rules parsed earlier, so the
casper process exits and syslogd dies with "Failed to xfer
configuration nvlist" on every start and reload.
Skip address pairs the rule already has a socket for. A second socket
would add nothing, and with -A it would send each message twice.
Reported by: Marcos Mendoza
Reviewed by: markj
Fixes: ae4f708f0b38 ("syslogd: Ensure that forwarded...")
[4 lines not shown]
tzcode: Avoid integer truncation resulting in wrong weekday
From a report[1] on the tz mailing list:
In timesub() the weekday is stored in (int) tm_wday before reduction
modulo seven (DAYSPERWEEK). Previously this could overflow a 32-bit
int, resulting in an incorrect weekday calculation.
Calculate two additional intermediate terms modulo seven to avoid an
intermediate value that does not fit in 32 bits.
We're committing this patch now so we can have something in place for
FreeBSD 15.2. If a different change is committed upstream we will
replace this.
[1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/
Approved by: re (cperciva)
PR: 300977
[6 lines not shown]
tcp: count only the SACK blocks that fit in tcp_maxseg()
tcp_addoptions() sends only the SACK blocks that fit in TCP_MAXOLEN.
tcp_maxseg() counted every pending block and clamped the total, so
without timestamps and with five or more blocks pending it came out 4
bytes below the segment tcp_output() sends. Limited transmit after an
RTO then sent one full segment and failed the "sent too much" KASSERT.
Approved by: re (cperciva)
PR: 282605
Approved by: adrian (mentor)
Signed-off-by: Nick Price <nprice at FreeBSD.org>
Reviewed by: tuexen, glebius, adrian
Differential Revision: https://reviews.freebsd.org/D60460
(cherry picked from commit d3b02115d4b373c719d9a716da38d94511de3f07)
(cherry picked from commit aacae7b35a22a56e187a0a41db231d63ca9cefb6)
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().
Approved by: re (cperciva)
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)
(cherry picked from commit 73929d1dc3b4116ca12cc3fe08fa3a9b66bf3318)
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.
Approved by: re (cperciva)
Reviewed by: rscheff, Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D58411
(cherry picked from commit fa2ad70a4511e7b379e81de82c9e51b2e0994295)
(cherry picked from commit a170546cb8d13a67ee3062114228d3df4744bbee)
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.
Approved by: re (cperciva)
Reported by: olivier
Reviewed by: rscheff, Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61605
(cherry picked from commit d174085f9f895ed444bd95120da3eff481a58f1a)
(cherry picked from commit 13357c1ee34f9f8655375714c60da8bf4881493a)
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.
Approved by: re (cperciva)
Reported by: Illia Vynohradov
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61586
(cherry picked from commit 3c6fd437b1824caeddb5f0d4570d43cf0c999c14)
(cherry picked from commit cbd17b66e64e9bdf025200c4993b8aeae6a0ebe9)
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.
Approved by: re (cperciva)
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61581
(cherry picked from commit 2f98793a13fe3e69cf6b698fa469550b4ba0fea1)
(cherry picked from commit ccf8e3762c3948446263ae3ef0dd98391ef9f97e)
tzcode: Avoid integer truncation resulting in wrong weekday
From a report[1] on the tz mailing list:
In timesub() the weekday is stored in (int) tm_wday before reduction
modulo seven (DAYSPERWEEK). Previously this could overflow a 32-bit
int, resulting in an incorrect weekday calculation.
Calculate two additional intermediate terms modulo seven to avoid an
intermediate value that does not fit in 32 bits.
We're committing this patch now so we can have something in place for
FreeBSD 15.2. If a different change is committed upstream we will
replace this.
[1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/
PR: 300977
Requested by: re (cperciva)
[4 lines not shown]
acpica: Fix SRAT memory region insertion sort
The SRAT table can list memory regions in any order, but we need them
sorted. There is an insertion sort to accomplish this when building
the mem_info array, but instead of inserting the new region before
the *first* higher-base-address region, it was inserting the new
region before the *last* higher-base-address region; i.e. if the array
already held "1 3 4" then inserting "2" would produce "1 3 2 4".
Break out of the insertion-location-finding loop when we find the right
spot to insert the new memory region into the list, rather than looking
further.
Approved by: re (cperciva)
Reviewed by: jhb
Fixes: dd540b46236b ("Add a parser for the ACPI SRAT table...")
MFC after: 1 day
Sponsored by: Amazon
Tested on: c5n.9xlarge, c6a.24xlarge, c6a.metal, c7a.metal-48xl
[7 lines not shown]
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).
Approved by: re (cperciva)
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
[2 lines not shown]
procctl: Zero the output structure for the compat32 syscall
Otherwise the freebsd32 implementation of PROC_REAP_STATUS leaks
uninitialized kernel stack memory.
Approved by: re (cperciva)
Reviewed by: kib
Reported by: Dennys Kaluzny Pereira <dennyskaluzny at gmail.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61510
(cherry picked from commit 5a834ad15f1f09d43a6840c74da194db6f890aa2)
(cherry picked from commit 42e71f0bafc23c0707752381d0b25649d12ae8c4)
imgact_elf: Pass program headers to the sv_protect hook
We handle program headers beyond the first page of the file, but
arm64_exec_protect() wasn't updated to handle this. Pass the program
header array directly to the sv_protect hook.
Also fix a pre-existing bug: imgp->et_dyn_addr isn't the right base
address to use for the SV_INTERP case.
Approved by: re (cperciva)
Reported by: alc
Reviewed by: alc, kib
Fixes: 804daf166406 ("imgact_elf: read program headers if not contained in the first page")
Fixes: 670af174e27b ("arm64: Enable BTI in the kernel ELF loader")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61999
(cherry picked from commit 884e1a00151d181e5dd1ba9d83c1adcffd25e5e8)
sysrc: Restore alignment with rc(8) boot process
Fix 1 issue identified in post-commit review of d0a1676:
POSTCR-d0a167652278ed81d259a1b77620b0c1cb9f72c8-1:
set -f around source_rc_confs stops glob expansion of rc_conf_files,
so sysrc no longer sees files that rc(8) sources
Partially "revert" d0a167652278 with respect to RC_CONFS, `-f file`,
rc_conf_files handling, and source_rc_confs invocation.
Add an ATF test to ensure we maintain rc(8) alignment.
Reported by: llm-postcr
Fixes: d0a167652278 ("sysrc: Support special characters in file names")
tzcode: Avoid integer truncation resulting in wrong weekday
From a report[1] on the tz mailing list:
In timesub() the weekday is stored in (int) tm_wday before reduction
modulo seven (DAYSPERWEEK). Previously this could overflow a 32-bit
int, resulting in an incorrect weekday calculation.
Calculate two additional intermediate terms modulo seven to avoid an
intermediate value that does not fit in 32 bits.
We're committing this patch now so we can have something in place for
FreeBSD 15.2. If a different change is committed upstream we will
replace this.
[1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/
PR: 300977
Requested by: re (cperciva)
[2 lines not shown]
nfsclrdma: Add build glue for nfsclrdma sources
Commit 80bee4d836 added the sources for client side NFS
over RDMA.
This patch adds the code to build these sources as a
module called nfsclrdma.ko or in the kernel when
kernel options NFSCL and OFED are specified.
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D61926
Fixes: 80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")