IPv6: rc boot time improvements
If IPv6 is enabled we call rtsol on that interface so waiting in
rtsold is counterproductive; if one was to just use rtsold -F then
they are on their own for having the addresses usable during the
remaining startup time.
Rather than sleeping dad_count + 1 seconds we are now checking for
any tentative addresses on the interface and only then sleep
dad_count up-to 2 times. This should save us at least a dad_count
with the seconds with Optimistic DAD enabled (default) but there
are too many assumptions invovled anyway.
(RETRANS_TIMER in the kernel being 1000ms being one).
The reason why we need to sleep more than dad_count (1s default)
seems to be that first DAD for the link-local address clears and
only then solicited (or other global) addresses are handled.
Co-authored-by: Pouria Mousavizadeh Tehrani <pouria at FreeBSD.org>
[3 lines not shown]
amd64/vmm: Do not fall back to the VMCS for vmxctx registers
vmx_setreg() first calls vmxctx_setreg() and, if that fails, handles the
register as a VMCS field. This relies on vmxctx_setreg() failing only
for registers that are not kept in the vCPU context. Were it to reject
a value for one of its own registers, the error would be dropped and
the request passed on to vmcs_setreg(), which would fail it only
because the register has no VMCS field.
Check whether the register is kept in the vCPU context instead, and if
so return the result of vmxctx_setreg() directly. This lets
vmxctx_setreg() validate values and have its error returned as is. Do
the same in vmx_getreg(), so that the two functions read alike.
No functional change intended.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61954
amd64/vmm: Restore vmxctx registers through vmxctx_setreg()
vmx_vcpu_snapshot() copies the guest registers kept in the vCPU context
straight between the context and the snapshot buffer, while
VM_SET_REGISTER stores them through vmxctx_setreg(). A check added to
vmxctx_setreg() would thus not apply to values restored from a
snapshot.
Add vmxctx_snapshot_reg(), modelled on vmcs_snapshot_reg(), and use it
for every register in the vCPU context, so that both paths store values
the same way. The snapshot format does not change.
No functional change intended.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61953
amd64/vmm: Reject reserved DR6 bits supplied by userspace
On Intel hosts the guest's DR6 is kept in the vCPU context and loaded
into the host's register before guest entry. VM_SET_REGISTER and the
snapshot restore path store any value there. Loading a value with any
of bits 63:32 set raises #GP, which panics the host.
Fail with EINVAL instead.
Reviewed by: markj
Approved by: markj
Fixes: 65eefbe42218 (Save and restore guest debug registers.)
MFC after: 1 week
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61732
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
route/fib_algo: Fix nexthop reference leak on FLM_BATCH
handle_rtable_change_cb() references the new nexthop before calling
the algorithm. If the algorithm asks to batch the change by
returning FLM_BATCH, queue_rtable_change() references the same
nexthop again for the queued entry, while apply_rtable_changes()
only unreferences the old nexthop of each entry.
Reference new nhop once in handle_rtable_change_cb(), before
deciding whether the change is queued or passed to the algorithm,
and do not reference it again in fill_change_entry(). This also
leaves the queue reallocation as the only way for
queue_rtable_change() to fail.
Currently, dxr is the only algorithm returning FLM_BATCH.
Fixes: 6b8ef0d428c9 ("Add batched update support for the fib algo.")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D61577
[2 lines not shown]
rtnetlink: Use default weight for unset weights in NHA_GROUP
newnhg() copied the weights of a nhgrp as is and a group
whose members all have a zero weight, which is what
userland sends when it leaves the weight unset, made
calc_min_mpath_slots_fast() divide by zero.
Therefore replace weight of zero with RT_DEFAULT_WEIGHT.
While here, return early from calc_min_mpath_slots_fast()
if all weights are zero.
MFC after: 3 days
Fixes: 7e5bf68495cc ("netlink: add netlink support")
(cherry picked from commit 1db6e2c6c3554efe5acdcc20bc7aa889e1efe372)
routing: Fix nhop double free in rib_copy_route()
add_route_flags() consumes the nexthop reference on every
failure path, so nhop_free() in rib_copy_route() releases it for
the second time.
This is reachable when growing net.fibs while two existing fibs
hold the same pinned prefix.
MFC after: 3 days
Fixes: 40503b792f7e ("routing: populate fibs with interface...")
(cherry picked from commit efa14ab698fe5c3a1586aec006f98e3781f4af78)
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]
HBSD: Apply style(9) to helper function
We provide a `jailed()` function in libjail to make it easier to
determine whether the calling code is running within a jailed context.
However, that function didn't follow style(9) too well.
Signed-off-by: Shawn Webb <shawn.webb at hardenedbsd.org>
HBSD: Fix setting hardening.prohibit_ptrace_capsicum as a jail param
I missed fetching the jail parameter upon jail creation. This commit
does just that.
Signed-off-by: Shawn Webb <shawn.webb at hardenedbsd.org>
Radicle-issue: 187e40515749fcb384935a2eeb24f0122e05eddb
Reported-by: 0x1eef
MFC-to: 15-STABLE
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]
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]