soelim: check the stdout error flag
fflush() may return success after a failed write, when the failed write
was the last one and left the buffer empty; the stream error flag is
then the only record of the failure. Check ferror() as well.
Make the /dev/full test use the input file from the source directory,
match the expected diagnostic, and add a line larger than the stdio
buffer so that the direct write path is covered.
Reported by: llm-postcr
bhyve: fix snapshot IPC handling
Currently, bhyvectl --suspend fails with:
Socket not connected
Even on successful suspend.
This happens because of two commits that result in a regression.
The first one, f49f33ef8c53, changed the snapshot request to
use nvlist_xfer() instead of nvlist_send(). Since the suspend path
exits before the IPC handler can send a response, nvlist_xfer()
fails with ENOTCONN.
The second one, ed60e5710e74, added err = errno when nvlist_xfer()
fails. As a result, bhyvectl prints the error message listed above
and exits with ENOTCONN.
Fix that by sending the snapshot request response before shutting
[7 lines not shown]
rge: add RTL8125CP (hwrev 0x70800000) support
Add support for the Realtek RTL8125CP 2.5GbE controller (PCI ID
0x10ec:0x8125, hwrev 0x70800000), as found in the built-in Ethernet port
on the Apple t8152 Mac mini.
RTL8125CP follows the RTL8125D register layout closely, with a few
chip-specific differences:
- Runs both MAC MCU and PHY ram-code (0x0024) from its own flash rather
than host-loaded patch tables.
- Uses RGE_TXCFG_CONFIG_8125CP (0x03000780) and specific MAC/PHY OCP
initialization values (while keeping MAC OCP 0xeb58 bit 0 set for the
driver's 32-byte TX descriptors).
- Uses the RTL8126/RTL8127 RGE_INT_CFG0 bit for ASPM/CLKREQ disable and
clears the v2 interrupt status registers (0xd04/0xd14) if an early MSI
arrives before IFF_DRV_RUNNING.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D62213
rge: read local-mac-address from FDT when available
On FDT platforms where the Realtek Ethernet controller has no standalone
EEPROM (such as integrated ports on Apple Silicon Macs), firmware
provides the factory MAC address in the device tree node's
local-mac-address property.
When built with FDT, check local-mac-address on the device's OFW node
during attach and program it into the MAC if valid.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D62212
rge: allow 64-bit DMA addresses for TX and RX descriptor rings
rge(4) already programs the upper 32 bits of the TX and RX descriptor
ring base addresses (RGE_TXDESC_ADDR_HI / RGE_RXDESC_ADDR_HI via
RGE_ADDR_HI()) and already uses BUS_SPACE_MAXADDR for its parent, packet
buffer, and statistics DMA tags.
Limiting sc_dmat_tx_desc and sc_dmat_rx_desc to BUS_SPACE_MAXADDR_32BIT
breaks platforms that have no physical RAM below 4 GiB (for example
Apple Silicon, where DRAM starts above 4 GiB and bus_dmamem_alloc()
cannot allocate below 4 GiB). Use BUS_SPACE_MAXADDR for the TX and RX
descriptor ring tags as well.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D62211
Revert "Merge commit 6573dd3f1ae9 from llvm-project (by ShengYi Hung):"
This reverts commit 4f76f14763ae59f2434875f5ff00ad26d6dba23a:
[Clang][Sema] Accept weak reference after declaration (#228809)
GCC accepts a weak reference even after there is a declaration. In here,
we use Check*Decl to do the required check and merge the NewDecl to
declaration chain.
Assisted-by: Claude # Tests ReleaseNote
Fixes: #56760
It appears to cause problems with "#pragma weak foo = bar" declarations
in OpenZFS.
PR: 205934
MFC after: 1 week
bhyve: disable SIGPIPE for TCP uart backend
Currently, if a TCP uart client disconnects while the guest is writing
to the serial port, a subsequent write to the socket raises SIGPIPE and
kills the VM.
Set SO_NOSIGPIPE on the listening socket to prevent that. Accepted
connections inherit it.
Reviewed by: markj
Fixes: 1f903953fbf8 ("bhyve: Add raw tcp to uart backend")
MFC after: 3 days
MFC to: stable/15
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62215
bhyve: disable SIGPIPE for vtcons
Currently, if a virtio-console socket client closes the connection or
shuts down the read side, the next guest write to the socket
raises SIGPIPE and kills the VM.
Set SO_NOSIGPIPE on this socket to prevent that.
Reviewed by: markj
Fixes: 13ee8dde0409 ("Add virtio-console support to bhyve.")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62216
carp: Leave the multicast groups without the softc lock
carp_detach() calls carp_multicast_cleanup() with the softc mutex held.
in_leavegroup() and in6_leavegroup() take in_multi_sx and in6_multi_sx,
so removing the last CARP address of a family from an interface gives:
lock order reversal: (sleepable after non-sleepable)
1st carp_softc (carp_softc, sleep mutex) @ sys/netinet/ip_carp.c:2329
2nd in_multi_sx (in_multi_sx, sx) @ sys/netinet/in_mcast.c:1280
and the same with in6_multi_sx for IPv6.
The memberships belong to the carp_if and are protected by carp_sx,
which carp_detach() holds throughout; carp_attach() already joins the
groups without the softc lock. Leave them once the softc is unlocked
or destroyed, before the carp_if may be freed. The groups of a family
are left only when no CARP address of that family remains on the
interface, and only softcs with an address of a family send
advertisements through its multicast options, so no sender uses them
[7 lines not shown]
netipsec: Do not send a Packet Too Big below the IPv6 minimum MTU
ipsec6_check_pmtu() answers a forwarded packet that does not fit once
encapsulated with an ICMPv6 Packet Too Big for the path MTU less the
estimated IPsec overhead. When the path MTU to the tunnel endpoint is
below IPV6_MMTU plus that overhead, 1417 bytes for an ESP tunnel over
IPv6, the message asks for less than IPV6_MMTU. Senders ignore it
(RFC 8201; icmp6_mtudisc_update() here does too), keep sending packets
of up to 1280 bytes, and the check drops every one of them.
Do what RFC 2473 section 7.1 asks of a tunnel entry point instead: pass
a packet of up to IPV6_MMTU bytes on, so that the outer packet is
fragmented, and report IPV6_MMTU for larger ones. This also replaces
the silent drop of every packet when the path MTU does not even cover
the overhead. With an IPv4 outer header and net.inet.ipsec.dfbit set
to 1, ip_output() still drops such a packet, as the outer header has DF
set.
Add a test with a path MTU of 1300 between the gateways.
[6 lines not shown]
netipsec: Find the outer destination of a bundle for the PMTU check
ipsec{4,6}_check_pmtu() look up the SA of the last request of a policy
to learn the outer destination, and from it the path MTU. The lookup
fills in the empty addresses of a transport request from the packet as
it is before any transform. When the transport request follows a
tunnel request, as in "esp/tunnel/A-B/require ah/transport//require",
the transform applies it after the tunnel request, to the outer header,
and its SA is installed for A and B. The check then finds no SA with
every SA in place. At level require it sends an SADB_ACQUIRE for the
inner addresses and drops the packet. strongSwan installs this shape
for IPComp in tunnel mode,
"ipcomp/tunnel/A-B/unique esp/transport//unique", so with such a policy
no forwarded IPv6 packet got through, and no IPv4 packet that the check
covers (net.inet.ipsec.dfbit 1, or above 1 for a packet with DF set).
At level use the check sends the same SADB_ACQUIRE and, since
655407eeea5b, skips the comparison with the path MTU. A packet that is
too big once encapsulated is then dropped by ip_output() if the outer
IPv4 header has DF set, or else fragmented, and its sender never learns
[28 lines not shown]
Merge commit 6573dd3f1ae9 from llvm-project (by ShengYi Hung):
[Clang][Sema] Accept weak reference after declaration (#228809)
GCC accepts a weak reference even after there is a declaration. In here,
we use Check*Decl to do the required check and merge the NewDecl to
declaration chain.
Assisted-by: Claude # Tests ReleaseNote
Fixes: #56760
PR: 205934
MFC after: 1 week
powerpc64: do not call pmap_nofault() for kernel addresses
trap_pfault() calls pmap_nofault() with the current process's pmap for
every radix page fault, before it has worked out which map the address
belongs to. For a fault on a kernel address that walks the user page
table: pmap_pml1e_index() masks off the quadrant bits, so 0xc008... is
looked up as the user address 0x0008....
Usually nothing is mapped there and vm_fault() handles the fault as
before. But if the process happens to have a mapping at that address,
its PTE gets the reference or change bit and its page is dirtied for an
access it never made. These faults are common: the first write to a
pipe buffer after the read that faulted it in is one.
Skip the call for kernel addresses. vm_fault() handles them the same
way it does now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62038
linuxulator/powerpc: fix the argument order of clone()
PowerPC passes tls before child_tidptr. New threads got a pointer to their
TID as thread pointer.
While here make linux_set_upcall() return 0 to the child instead of
copying r1 to r0.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62272
linuxulator/powerpc: fix signal delivery
Handlers were always treated as ELFv1 function descriptors and read
directly from userland. ELFv2 handlers are plain addresses and want their
own address in r12.
Also don't overwrite the red zone, honour sigaltstack(), write the back
chain and stop copying a FreeBSD ucontext that nobody reads.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62271
linuxulator/powerpc: fix the layout of struct stat and statfs64
st_dev and st_rdev are longs on powerpc64, but l_dev_t is 32-bit.
Everything after st_gid was off by 4 bytes and glibc read st_blksize as
the file size. statfs64 has the same problem with its word-sized fields.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62270
linuxulator/powerpc: return positive errno values
sc reports an error with CR0[SO] set and a positive errno in r3. We passed
the negative one like the other architectures do, so libc took every
error for a success. A failed open() became file descriptor 2.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62269
usb: dwc3: treat a dual-role port whose default role is host as a host port
Some device trees (such as Apple Silicon Macs) describe USB-C DWC3
controllers with dr_mode = "otg" and role-switch-default-mode = "host".
Accept that combination during probe so host mode works with unmodified
device trees instead of refusing to attach.
Differential Revision: https://reviews.freebsd.org/D62185
usb: dwc3: derive 32-bit vs 64-bit DMA from DWC3_GHWPARAMS0 AWIDTH
dwc3.c previously passed a hardcoded IS_DMA_32B (1) to xhci_init(),
which pins sc_dma_bits to 32 (and hw.usb.xhci.dma32 can only force
32-bit DMA on, never off).
On platforms with no physical memory below 4GB (such as Apple Silicon,
where DRAM starts at 0x800000000 on t8103), a 32-bit busdma tag cannot
allocate coherent memory or bounce pages and xhci_init() fails.
Read the synthesized address bus width (AWIDTH, bits [31:24]) from
DWC3_GHWPARAMS0 and enable 64-bit DMA only when AWIDTH == 64 on a
64-bit host, leaving 32-bit synthesized DWC3 cores on 32-bit DMA.
xhci_init() still checks XHCI_HCS0_AC64 and hw.usb.xhci.dma32.
Differetial Revision: https://reviews.freebsd.org/D62184
powerpc: zero the FPU save area in set_fpregs() when it was not valid
set_fpregs() marks the saved FPU registers valid and fills in the FP
registers and the FPSCR, which are only half of each of VSR0-31. The
other halves are left alone, and on a thread that hasn't used the FPU
since exec they still hold whatever the previous program left there:
exec only resets pcb_flags, and enable_fpu() zeroes the save area only
when PCB_FPREGS is clear.
So a PT_SETFPREGS on such a thread, even one that just writes back what
PT_GETFPREGS returned, hands the new program VSX register contents of
the program that ran before the exec.
Zero the save area first when it wasn't valid, like enable_fpu() does.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62037
committers-ports: Add mzar and update committer information
Add mzar@ to the ports committers list with philip@,
farrokhi@, and olivier@ as mentors.
Update the Mentor and Mentee Information according
to step 5 of the Committer's Guide.
Update the calendar according to step 10 of the
Committer's Guide.
Approved by: philip, farrokhi, olivier (mentors)
Differential Revision: https://reviews.freebsd.org/D62146
ipfilter: Clear the IP header pointer if m_pullup() fails
Otherwise fin->fin_ip is left pointing into freed memory, and
ipf_pr_ipv4hdr() may end up accessing it. In particular,
ipf_pr_ipv4hdr() checks fin->fin_ip == NULL to decide whether to
short-circuit, in contrast with ipf_pr_ipv6hdr(), which bails if
fin->fin_m == NULL.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62172
Merge commit 29474e1a3a72 from llvm-project (by Minsoo Choo):
[libunwind] Support extended amd64 segment registers on FreeBSD (#237265)
Raise the amd64 DWARF register limit to 59 and add RFLAGS, all six
segment selectors, FS.base, and GS.base to the register model. Capture
the extended state and restore it when resuming, using setcontext on
FreeBSD to restore selectors and bases together. Pack the state into the
existing context buffers without changing their public sizes or the
Windows XMM offsets.
Add tests for register access, signal-frame CFI recovery, register
bounds, and resume behavior.
Assisted-by: GPT
MFC after: 1 week
Revert "Merge commit fd4113508a64 from llvm-project (by Minsoo Choo):"
This reverts commit 28ec7cb8712fde61107126c8ff174578d0ccdf79:
[libunwind] Support extended amd64 segment registers (#229176)
Raise the amd64 DWARF register limit to 59 and add RFLAGS, all six
segment selectors, FS.base, and GS.base to the register model. Capture
the extended state and restore it when resuming, using sigreturn() on
FreeBSD to restore selectors and bases together. Pack the state into the
existing context buffers without changing their public sizes or the
Windows XMM offsets.
Add tests for register access, signal-frame CFI recovery, register
bounds, and resume behavior.
Assisted-by: GPT
It was reverted upstream, after noting that it should apply specifically
[3 lines not shown]
kern/kern_exit.c: fix decision to give back to real parent in proc_reap()
p_oppid records the reaper by pid only, and nothing updates p_oppid when
the reaper changes. When p_oppid no longer matches, proc_realparent()
falls back to p_reaper. In proc_reap(), the test p_oppid !=
p_pptr->p_pid is then still true, so proc_reap() "gives back" the child
to proc_realparent(). That resolves to the new reaper, which is already
p_pptr. proc_reparent() returns early, the reaper gets a spurious
SIGCHLD, and proc_reap() returns without reaping.
Another problem with p_oppid check is that a parked zombie is leaked
permanently under the new reaper if the reaper changes before the
debugger waits, because p_oppid keeps the old reaper's pid.
In proc_reap(), base the give-back decision on the resolved parent
instead of the pid comparison.
Reported by: llm-postcr
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
contrib/lutok: update generated headers/build glue
lutok and kyua have both been updated for the new tests and the adjusted
header layout.
MFC after: 1 week
MFC with: 5e4c3200cdc7 ("contrib/lutok: update to 0.7.1")
contrib/lutok: update to 0.7.1
This is a bugfix release. Users are encouraged to take this version.
MFC after: 1 week
Merge commit 'dac7d818e3cef52d724592c6b349dbd8ad9a049a'
contrib/lutok: compile/run tests from the project
This change adds the necessary glue to build and run the tests
distributed with each release, sans the examples tests. liblutok is
an "internal" library, so the headers and library aren't distributed
with installworld, et al, and thus the examples tests--which require the
headers/library to build tests on the fly--fail when the tests are run,
due to this difference with the upstream project.
MFC after: 1 week