]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoAvoid memory allocations in the ARC eviction thread
Mark Johnston [Fri, 21 Jan 2022 18:28:13 +0000 (13:28 -0500)]
Avoid memory allocations in the ARC eviction thread

When the eviction thread goes to shrink an ARC state, it allocates a set
of marker buffers used to hold its place in the state's sublists.

This can be problematic in low memory conditions, since
1) the allocation can be substantial, as we allocate NCPU markers;
2) on at least FreeBSD, page reclamation can block in
   arc_wait_for_eviction()

In particular, in stress tests it's possible to hit a deadlock on
FreeBSD when the number of free pages is very low, wherein the system is
waiting for the page daemon to reclaim memory, the page daemon is
waiting for the ARC eviction thread to finish, and the ARC eviction
thread is blocked waiting for more memory.

Try to reduce the likelihood of such deadlocks by pre-allocating markers
for the eviction thread at ARC initialization time.  When evicting
buffers from an ARC state, check to see if the current thread is the ARC
eviction thread, and use the pre-allocated markers for that purpose
rather than dynamically allocating them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #12985
(cherry picked from commit 6e2a59181e286a397d260fa9f140b58688d60c58)

2 years agomsdosfs: Fix mounting when the device sector size is >512B
Mark Johnston [Mon, 14 Feb 2022 14:41:32 +0000 (09:41 -0500)]
msdosfs: Fix mounting when the device sector size is >512B

HugeSectors * BytesPerSec should be computed before converting
HugeSectors to a DEV_BSIZE-based count.

Fixes: ba2c98389b78 ("msdosfs: sanity check sector count from BPB")
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c7cd607a4e28233ab6679ee330c0a4836414bb0a)

2 years agosleepqueue: Annotate sleepq_max_depth as static
Mark Johnston [Mon, 14 Feb 2022 14:41:07 +0000 (09:41 -0500)]
sleepqueue: Annotate sleepq_max_depth as static

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 852ff943b9c23d40e36ebe5f82112f7bce4537c9)

2 years agolibctf: Rip out CTFv1 support
Mark Johnston [Thu, 10 Feb 2022 20:32:23 +0000 (15:32 -0500)]
libctf: Rip out CTFv1 support

CTFv1 was obsolete before libctf was imported into FreeBSD, and
ctfconvert/ctfmerge can emit only CTFv2.  Make ctf.h a bit easier to
maintain by ripping v1 support out.  No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7db423d69273644d3be2a65a48a67b9e0cfb0147)

2 years agolibctf: Use ctf_type_t instead of struct ctf_type
Mark Johnston [Wed, 9 Feb 2022 14:38:03 +0000 (09:38 -0500)]
libctf: Use ctf_type_t instead of struct ctf_type

For consistency with other CTF toolchain code.  No functional change
intended.

Fixes: 105fd928b0b5 ("libctf: Improve check for duplicate SOU definitions in ctf_add_type()")

(cherry picked from commit 2e4311906d8c8dc7a7c726345268253bca6d4acc)

2 years agoctfconvert: Rip out STABS support
Mark Johnston [Thu, 10 Feb 2022 20:36:19 +0000 (15:36 -0500)]
ctfconvert: Rip out STABS support

It is unused on FreeBSD and complicates some efforts to modify the CTF
format to permit wider type IDs, so remove it.  No functional change
intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7be9a3b45356747f9fcb6d69a722c1c95f8060bf)

2 years agotcp: Avoid conditionally defined fields in union lro_address
Mark Johnston [Thu, 10 Feb 2022 20:31:26 +0000 (15:31 -0500)]
tcp: Avoid conditionally defined fields in union lro_address

The layout of the structure ends up depending on whether the including
file includes opt_inet.h and opt_inet6.h, so different compilation units
can end up seeing different versions of the structure.  Fix this by
unconditionally defining the address fields.

As a side effect, this eliminates some duplication in the kernel's CTF
type graph.

Reviewed by: rscheff, tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b4f60fab5d3fdd2ea51c1151fa79b2c541c6b81a)

2 years agolinux: Add additional ptracestop only if the debugger is Linux
Edward Tomasz Napierala [Sat, 30 Oct 2021 08:53:55 +0000 (09:53 +0100)]
linux: Add additional ptracestop only if the debugger is Linux

In 6e66030c4c0, additional ptracestop was added in order
to implement PTRACE_EVENT_EXEC.  Make it only apply to cases
where the debugger is a Linux processes; native FreeBSD
debuggers can trace Linux processes too, but they don't
expect that additonal ptracestop.

Fixes: 6e66030c4c0
Reported By: kib
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32726

(cherry picked from commit 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3)

2 years agolinux: Make PTRACE_GETREGSET return proper buffer size
Edward Tomasz Napierala [Fri, 29 Oct 2021 14:28:56 +0000 (15:28 +0100)]
linux: Make PTRACE_GETREGSET return proper buffer size

This fixes Chrome warning:

[1022/152319.328632:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32616

(cherry picked from commit f939dccfd770df2f9070cd30aa52105b7afe1bde)

2 years agolinux: Fix ptrace panic with ERESTART
Edward Tomasz Napierala [Fri, 29 Oct 2021 13:21:21 +0000 (14:21 +0100)]
linux: Fix ptrace panic with ERESTART

Translate ERESTART into Linux "internal" errno ERESTARTSYS.
This fixes the erestartsys.gen.test from strace(1).

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32623

(cherry picked from commit 6547153e4618c3b57e5f76062de006a04ecbd64b)

2 years agolinux: Improve debug for PTRACE_GETEVENTMSG
Edward Tomasz Napierala [Sat, 23 Oct 2021 18:53:12 +0000 (19:53 +0100)]
linux: Improve debug for PTRACE_GETEVENTMSG

No functional changes.

Sponsored By: EPSRC

(cherry picked from commit 2ec26ae402fc2589cb97bb5aa713b6d0ba080c17)

2 years agolinux: implement PTRACE_EVENT_EXEC
Edward Tomasz Napierala [Sat, 23 Oct 2021 18:13:14 +0000 (19:13 +0100)]
linux: implement PTRACE_EVENT_EXEC

This fixes strace(1) from Ubuntu Focal.

Reviewed By: jhb
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32367

(cherry picked from commit 6e66030c4c05331f9b0adf87c31f2f233dd3ae1f)

2 years agolinux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN
Edward Tomasz Napierala [Sat, 23 Oct 2021 17:56:29 +0000 (18:56 +0100)]
linux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN

This fixes panic when trying to run strace(8) from Focal.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32355

(cherry picked from commit 2558bb8e9166395dce26afcfac91fc692621de7b)

2 years agolinux: Improve debug for PTRACE_GETREGSET
Edward Tomasz Napierala [Fri, 22 Oct 2021 18:58:52 +0000 (19:58 +0100)]
linux: Improve debug for PTRACE_GETREGSET

No functional changes.

Sponsored By: EPSRC

(cherry picked from commit e3a83df1195cc4f48f2908b423b5c80dd9c49a21)

2 years agolinux: Improve debugging for PTRACE_GETREGSET
Edward Tomasz Napierala [Sun, 17 Oct 2021 11:52:39 +0000 (12:52 +0100)]
linux: Improve debugging for PTRACE_GETREGSET

It's triggered by gdb(1).

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32456

(cherry picked from commit a03d4d73e4c7c73447263294df6ebd1791ab01f2)

2 years agolinux: Implement some bits of PTRACE_PEEKUSER
Edward Tomasz Napierala [Sun, 17 Oct 2021 11:20:16 +0000 (12:20 +0100)]
linux: Implement some bits of PTRACE_PEEKUSER

This makes Linux gdb from Bionic a little less broken.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32455

(cherry picked from commit f9246e14848820664539763b72b6fdef408d20e4)

2 years agolinux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics
Edward Tomasz Napierala [Sun, 17 Oct 2021 10:49:42 +0000 (11:49 +0100)]
linux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics

The tests/ptrace_syscall_info test from strace(1) complained
about this.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32368

(cherry picked from commit 75a9d95b4d0a043ac0f3f8d1efc0982156337eac)

2 years agoRemove PT_GET_SC_ARGS_ALL
Konstantin Belousov [Wed, 15 Sep 2021 13:24:09 +0000 (16:24 +0300)]
Remove PT_GET_SC_ARGS_ALL

Reimplement bdf0f24bb16d556a5b by checking for the caller' ABI in
the implementation of PT_GET_SC_ARGS, and copying out everything if
it is Linuxolator.

Also fix a minor information leak: if PT_GET_SC_ARGS_ALL is done on the
thread reused after other process, it allows to read some number of that
thread last syscall arguments. Clear td_sa.args in thread_alloc().

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D31968

(cherry picked from commit f575573ca57716395ad88b962388a55d755cf6a7)

2 years agolinux: implement PTRACE_GET_SYSCALL_INFO
Edward Tomasz Napierala [Sun, 12 Sep 2021 11:31:10 +0000 (11:31 +0000)]
linux: implement PTRACE_GET_SYSCALL_INFO

This is one of the pieces required to make modern (ie Focal)
strace(1) work.

Reviewed By: jhb (earlier version)
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D28212

(cherry picked from commit bdf0f24bb16d556a5b1e01cdfc087d08e91ac572)

2 years agolinux: make ptrace(2) return EIO when trying to peek invalid address
Edward Tomasz Napierala [Sat, 24 Apr 2021 10:37:06 +0000 (11:37 +0100)]
linux: make ptrace(2) return EIO when trying to peek invalid address

Previously we've returned the error from native ptrace(2), ENOMEM.
This confused Linux strace(2).

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29925

(cherry picked from commit 77651151f3caec7d2440404f8c0f1819757d1d5d)

2 years agolinux: refactor bsd_to_linux_regset() out of linux_ptrace.c
Edward Tomasz Napierala [Fri, 21 May 2021 06:22:25 +0000 (07:22 +0100)]
linux: refactor bsd_to_linux_regset() out of linux_ptrace.c

This will be used for Linux coredump support.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30365

(cherry picked from commit 95c19e1d65619624db4a7a21afc1685f122a05c1)

2 years agolinux(4): make arch_prctl(2) support GET_CET_STATUS, report unknown codes
Edward Tomasz Napierala [Thu, 6 May 2021 08:33:35 +0000 (09:33 +0100)]
linux(4): make arch_prctl(2) support GET_CET_STATUS, report unknown codes

This is largely a no-op, to make future debugging slightly easier.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30035

(cherry picked from commit 916f3dba4523d1b2d478538875d45df56b20bcdb)

2 years agolinux(4): fix ptrace(2) to properly handle orig_rax
Edward Tomasz Napierala [Tue, 4 May 2021 13:11:01 +0000 (14:11 +0100)]
linux(4): fix ptrace(2) to properly handle orig_rax

This fixes strace(1) erroneously reporting return values
as "Function not implemented", combined with reporting the binary
ABI as X32.

Very similar code in linux_ptrace_getregs() is left as it is - it's
probably wrong too, but I don't have a way to test it.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29927

(cherry picked from commit 023bff799098cac28732f2800c967f0248d2eb47)

2 years agopf: fix set_prio after nv conversion
Franco Fichtner [Mon, 14 Feb 2022 19:26:39 +0000 (20:26 +0100)]
pf: fix set_prio after nv conversion

Reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34266

(cherry picked from commit 0143a6bb7f634c5984b34db1834313bdb47e6ccd)

2 years agoBump __FreeBSD_version to 1300526 for LinuxKPI changes.
Bjoern A. Zeeb [Sun, 20 Feb 2022 18:10:45 +0000 (18:10 +0000)]
Bump __FreeBSD_version to 1300526 for LinuxKPI changes.

This successfully builds against drm-fbsd13-kmod-5.4.144.g20220128
so no conflicting changes on the MFC.  Given there are overlaps, bump
__FreeBSD_version so they can be detected and removed as pleases.

2 years agoLinuxKPI: 802.11 simplify beacon checks in rx path
Bjoern A. Zeeb [Thu, 17 Feb 2022 00:58:12 +0000 (00:58 +0000)]
LinuxKPI: 802.11 simplify beacon checks in rx path

In linuxkpi_ieee80211_rx() check if the frame is a beacon once upfront
and use the result for enhanced debugging and further checks.
This was done intially for rx_status->device_timestamp debugging.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c0cadd99d1e36ffe0994f8b30df2939f1d3d0fee)

2 years agoLinuxKPI: implement dma_sync_single_for_*, apply to (un)map single/sg
Bjoern A. Zeeb [Fri, 1 Oct 2021 10:51:50 +0000 (10:51 +0000)]
LinuxKPI: implement dma_sync_single_for_*, apply to (un)map single/sg

Implement dma_sync_single_for_{cpu,device} translating the Linux
DMA_ flags to BUS_DMASYNC_ combinations.  Make map_single/unmap_single*
functions call the respective sync function.   Apply the same logic to
the scatter-gather list map/unmap functions.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D32255

(cherry picked from commit 95edb10b47fc1a919cd1687aaf16be9e14456c89)

2 years agoLinuxKPI: 802.11: disable ic_headroom for the moment
Bjoern A. Zeeb [Wed, 16 Feb 2022 23:57:27 +0000 (23:57 +0000)]
LinuxKPI: 802.11: disable ic_headroom for the moment

There is a problem with some drivers, such as rtw88, asking for more
headroom than we currently can handle throughout the stack (we have
other legacy wireless driver in the tree with similar problems).
This may trigger an assertion in the TCP syncache where we are checking
for a reply to fit in MHLEN.
While for the moment we still copy data from mbufs to skbs,
we can simply disable the extra headroom request in ic_headroom and
deal with it ourselves (which we already did anyway).
Leave a link to the thread on freebsd-transport detailing more of the
problem so we can find it again and solve it here or there.

(cherry picked from commit 3d09d310d9981dde1d6e51fed6ecf9576480b9f7)

2 years agoLinuxKPI: 802.11 advertise full offload scanning based on hw_scan only
Bjoern A. Zeeb [Thu, 17 Feb 2022 00:15:56 +0000 (00:15 +0000)]
LinuxKPI: 802.11 advertise full offload scanning based on hw_scan only

We disabled hw_scan for drivers not advertising SINGLE_SCAN_ON_ALL_BANDS.
Do not depend on this hw flag to set IEEE80211_FEXT_SCAN_OFFLOAD for
net80211 as otherwise scanning will never work.
Long-term we probably want to re-think how we do/integrate hw_scan
better in net80211.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cc4e78d51351d6362b0536e326280c1e230648d5)

2 years agoLinuxKPI: 802.11 header updates and add/adjust source dependencies.
Bjoern A. Zeeb [Tue, 15 Feb 2022 23:45:15 +0000 (23:45 +0000)]
LinuxKPI: 802.11 header updates and add/adjust source dependencies.

This update is for more/newer versions of drivers:
- add and properly place more structs, enums, defines needed by drivers.
- correct types of struct fields.
- make various function arguments const.
- move REG_RULE() macro to its own file regulatory.h and
  use macros for calculations.
- add linuxkpi_ieee80211_get_channel() implementation.
- change linuxkpi_ieee80211_ifattach() to return int for error checking.

No intended functional changes for iwlwifi.

Sponsored by: The FreeBSD Foundation (partially)

(cherry picked from commit 2e183d999c6033e876602ddbbc5cb538bb41e4b3)

2 years agoLinuxKPI: skbuff updates
Bjoern A. Zeeb [Wed, 16 Feb 2022 02:10:10 +0000 (02:10 +0000)]
LinuxKPI: skbuff updates

Various updates to skbuff for new/updated drivers and some housekeeping:
- update types and struct members, add new (stub) functions
- improve freeing of frags.
- fix an issue with sleeping during alloc for dev_alloc_skb().
- Adjust a KASSERT for skb_reserve() which apparently can be called
  multiple times if no data was put into the skb yet.
- move the sysctl from linux_8022.c (which may be in a different module)
  to linux_skbuff.c so in case we turn debugging on we do not run into
  unresolved symbols.  Rename the sysctl variable to be less conflicting
  and update debugging macros along with that; also add IMPROVE().
- add DDB support to show an skbuff.
- adjust comments/whitespace.

No functional changes intended for iwlwifi.

Sponsored by: The FreeBSD Foundation (partially)

(cherry picked from commit 6baea3312d92cd7eb25f5b9e0e474132636f62d9)

2 years agoLinuxKPI: 802.11: defer workq allocation until we have a name
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:20:29 +0000 (03:20 +0000)]
LinuxKPI: 802.11: defer workq allocation until we have a name

Turned out all the workq's taskqueues were named "wlanNA" if you had
more then one card in a machine as by the time we called wiphy_name()
the device name was not set yet and we returned the fallback.

Move the alloc_ordered_workqueue() from linuxkpi_ieee80211_alloc_hw()
to linuxkpi_ieee80211_ifattach() at which time the device name has
to be set to give us a unique name.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 652e22d39562ec396d12860313677599becbc749)

2 years agoLinuxKPI: 802.11 assign an(y) early chandef
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:48:54 +0000 (03:48 +0000)]
LinuxKPI: 802.11 assign an(y) early chandef

The Realtek driver assumes an early chandef to be set.  At the time
of linuxkpi_ieee80211_ifattach() we do not really know one yet so
try to find the first one which is available and set that.
This prevents a NULL-deref panic.

(cherry picked from commit c5b96b3eaede01a5117975af6de3483dc43673a4)

2 years agoLinuxKPI: 802.11 scan update
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:00:34 +0000 (03:00 +0000)]
LinuxKPI: 802.11 scan update

Realtek's rtw88 is returning a hard-coded 1 in case they cannot
hw_scan (fw not advertising it).  In that case if we want any scan
to run we need to fall-back to sw scan.  Start dealing with this.
Long-term we probably need to keep internal state.

(cherry picked from commit d3ef7fb459ff924911e5276db0c04b13cd8074d9)

2 years agoLinuxKPI: pci.h add more defines
Bjoern A. Zeeb [Tue, 15 Feb 2022 23:51:40 +0000 (23:51 +0000)]
LinuxKPI: pci.h add more defines

Add and sort in more defines needed by newer drivers.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34293

(cherry picked from commit c4f52f71de98a575dab84f5654f73d7022d40795)

2 years agoLinuxKPI: 802.11 enahnce linuxkpi_ieee80211_iterate_interfaces()
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:56:54 +0000 (03:56 +0000)]
LinuxKPI: 802.11 enahnce linuxkpi_ieee80211_iterate_interfaces()

Add support for IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER in
linuxkpi_ieee80211_iterate_interfaces() needed by a driver.

(cherry picked from commit 61a68e50d436333396ffd2e1d6a4b5d2875f8118)

2 years agoLinuxKPI: lockdep add lockdep_assert_not_held()
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:01:32 +0000 (12:01 +0000)]
LinuxKPI: lockdep add lockdep_assert_not_held()

Add lockdep_assert_not_held() asserting LA_UNLOCKED as needed by a
driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34232

(cherry picked from commit 064c110f4b551cbf3f2ef6f567736005c2d7007a)

2 years agonet80211: enhance (disabled) debugging
Bjoern A. Zeeb [Mon, 14 Feb 2022 22:16:59 +0000 (22:16 +0000)]
net80211: enhance (disabled) debugging

Add maxchans to the disabled debugging in addchan() and copychan_prev()
to aid debugging possible errors rreturned due to reaching maxchans
limits.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 32cf376a01d42710ccbb1d6664ebd0a85c9e0064)

2 years agoLinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:58:40 +0000 (11:58 +0000)]
LinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY()

Add an implementation of kstrtoint_from_user() based on the other
implementations and an attempt at DECLARE_FLEX_ARRAY() which works
for the driver needing it.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34231

(cherry picked from commit c840d5cec2607932d077ffcfee7ccf0a6b50cdf3)

2 years agoLinuxKPI: add UUID_STRING_LEN and GUID_INIT to uuid.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:10:59 +0000 (12:10 +0000)]
LinuxKPI: add UUID_STRING_LEN and GUID_INIT to uuid.h

Add a definition for UUID_STRING_LEN to uuid.h as needed by a driver.
Also add GUID_INIT for drm-kmod [1].

Submitted by: wulf [1]
Reviewed by: hselasky (earlier), wulf
Differential Revision: https://reviews.freebsd.org/D34235

(cherry picked from commit 97009980c492f5bc44a942cee09ac1ccfe4ae00a)

2 years agoLinuxKPI: 802.11: get rid of lkpi_ic_getradiocaps warnings
Bjoern A. Zeeb [Mon, 14 Feb 2022 22:29:38 +0000 (22:29 +0000)]
LinuxKPI: 802.11: get rid of lkpi_ic_getradiocaps warnings

Users are seeing warnings about 2 channels (1 per band)
triggered by an ioctl from wpa_supplicant usually:
lkpi_ic_getradiocaps: Adding chan ... returned error 55
This was an early FAQ.

Check the current number of channels against maxchans and the return
code from net80211. In case net80211 reports that we reached the limit
do not print the warning and do not try to add further channels.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cee56e77d77909df69624cc707a571647651c853)

2 years agoLinuxKPI: add get_unaligned_le16()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:37:37 +0000 (11:37 +0000)]
LinuxKPI: add get_unaligned_le16()

Add get_unaligned_le16() to asm/unaligned.h needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34224

(cherry picked from commit 2e818fbcfc03f9416593d5fe5bc860c1829f5366)

2 years agoLinuxKPI: add sizeof_field()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:46:15 +0000 (11:46 +0000)]
LinuxKPI: add sizeof_field()

Add sizeof_field() to linux/compiler.h needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34226

(cherry picked from commit e5b95b220135bba90154c9c27803f54bf1a75548)

2 years agoLinuxKPI: add __ffs64()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:43:33 +0000 (11:43 +0000)]
LinuxKPI: add __ffs64()

Add __ffs64() to linux/bitops.h needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34225

(cherry picked from commit d17b78aa142d7c63490c7a2c3f202ef99fffad70)

2 years agoLinuxKPI: add linux/pm_qos.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:07:44 +0000 (12:07 +0000)]
LinuxKPI: add linux/pm_qos.h

Add a linux/pm_qos.h with three dummy functions and a struct as needed
by a driver and drm-kmod [1] in main with no intend to support this for
the moment.

Submitted by: wulf (drm-kmod bits) [1]
Sponsored by: The FreeBSD Foundation (drm-kmod requested updates)
Reviewed by: hselasky (earlier version), wulf
Differential Revision: https://reviews.freebsd.org/D34234

(cherry picked from commit fa6d3522b56d482e77740e325b59019e2ffc347e)

2 years agoLinuxKPI: add NETIF_F_HW_CSUM to netdev_features.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:05:13 +0000 (12:05 +0000)]
LinuxKPI: add NETIF_F_HW_CSUM to netdev_features.h

Add NETIF_F_HW_CSUM to netdev_features.h as needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34233

(cherry picked from commit 85d61bd872a0d91173d6cc8dc5bb2c927a5a4302)

2 years agoTCP syncache: enhance KASSERT output
Bjoern A. Zeeb [Tue, 8 Feb 2022 23:47:15 +0000 (23:47 +0000)]
TCP syncache: enhance KASSERT output

Improve the "syncache: mbuf too small" assertion message with various
variables (some not actually needed) but enough that it will be obvious
if (a) we use IPv4 or IPv6, (b) if UDP tunneling is on, (c) what
max_linkhdr is, and (d) what MHLEN is.

This should help diagnostics in the future.
The case was hit with wireless drivers setting a large ic_headroom
and using IPv6.

Reviewed by: gallatin, tuexen, rscheff
Differential Revision: https://reviews.freebsd.org/D34217

(cherry picked from commit 232d323ef227109acce37f5a0d62492673666ee2)

2 years agoLinuxKPI: add more errno
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:48:37 +0000 (11:48 +0000)]
LinuxKPI: add more errno

Add ENOMEDIUM, ENOSR, and ELNRNG to linux/errno.h needed by drivers.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34227

(cherry picked from commit 8f33ad3cf5361c700e2b133915685983003de67c)

2 years agoLinuxKPI: add eth_random_addr() and device_get_mac_address()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:50:27 +0000 (11:50 +0000)]
LinuxKPI: add eth_random_addr() and device_get_mac_address()

Add eth_random_addr() and a dummy of device_get_mac_address()
pending OF (FDT) support needed by drivers.

While here remove a white space in random_ether_addr().

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34228

(cherry picked from commit 3cd6d6ff527ad0a57d278e2911f59b22dbd402cf)

2 years agoLinuxKPI: add an initial ethtool.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:53:27 +0000 (11:53 +0000)]
LinuxKPI: add an initial ethtool.h

Add an initial ethtool.h for a define and a dummy struct for now
needed by drivers.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34229

(cherry picked from commit 0c37ffda799a9d44370bfe9898f220c193306842)

2 years agoLinuxKPI; add the beginning of a tracepoint.h implementation
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:13:19 +0000 (12:13 +0000)]
LinuxKPI; add the beginning of a tracepoint.h implementation

Add a beginning of a tracepoint.h implementation to ease porting drivers
making use of this Linux facility.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34236

(cherry picked from commit a4529c46d4ee330ff6d347a611d62f4792e94392)

2 years agoetc/defaults/rc.conf: set default of zfskeys_enable to NO
Robert Wing [Tue, 18 Jan 2022 23:26:30 +0000 (14:26 -0900)]
etc/defaults/rc.conf: set default of zfskeys_enable to NO

This addresses the following boot message:
    /etc/rc: WARNING: $zfskeys_enable is not set properly - see rc.conf(5).

Reported by:    Mark Millard
Sponsored by:   Modirum MDPay
Sponsored by:   Klara Inc.
Fixes: bfb7a31b6a22 ("rc: Hook zfskeys to the build")
Fixes: 33ff39796ffe ("Add zfskeys rc.d script for auto-loading encryption keys")
(cherry picked from commit 6596f19daa42d5b968030e08826542c704533b73)

2 years agolibthr: Disable stack unwinding on ARM.
John Baldwin [Thu, 10 Feb 2022 20:47:08 +0000 (12:47 -0800)]
libthr: Disable stack unwinding on ARM.

When a thread exits, _Unwind_ForcedUnwind() is used to walk up stack
frames executing pending cleanups pushed by pthread_cleanup_push().
The cleanups are popped by thread_unwind_stop() which is passed as a
callback function to _Unwind_ForcedUnwind().

LLVM's libunwind uses a different function type for the callback on
32-bit ARM relative to all other platforms.  The previous unwind.h
header (as well as the unwind.h from libcxxrt) use the non-ARM type on
all platforms, so this has likely been broken on 32-bit arm since it
switched to using LLVM's libunwind.

For now, just disable stack unwinding on 32-bit arm to unbreak the
build until a proper fix is tested.

(cherry picked from commit bbf4df1722060fb78939419476fb624114fb303d)

2 years agoInstall unwind.h into /usr/include
John Baldwin [Thu, 10 Feb 2022 17:57:49 +0000 (18:57 +0100)]
Install unwind.h into /usr/include

Install headers from LLVM's libunwind in place of the headers from
libcxxrt and allow C applications to use the library.

As part of this, remove include/unwind.h and switch libthr over to
using the installed unwind.h.

Reviewed by: dim, emaste
MFC after: 10 days
Differential Revision: https://reviews.freebsd.org/D34065

(cherry picked from commit c00d345665366a89aaba7244d6f078dc756f4c53)

2 years agoChange the return value of _Unwind_GetCFA in include/unwind.h.
John Baldwin [Thu, 27 Jan 2022 22:42:40 +0000 (14:42 -0800)]
Change the return value of _Unwind_GetCFA in include/unwind.h.

I tested the original commit as part of a series that culminates in
removing this header and installing LLVM libunwind's unwind.h in its
place so missed updating this header as was done in b84693501af6.

Pointy hat to: jhb
Reported by: kevans
Fixes: 3a502289d316 Use uintptr_t for return type of _Unwind_GetCFA.

(cherry picked from commit 522f5383547a2b3980f097a647b25f12c15411af)

2 years agoUse uintptr_t for return type of _Unwind_GetCFA.
John Baldwin [Thu, 27 Jan 2022 18:53:21 +0000 (10:53 -0800)]
Use uintptr_t for return type of _Unwind_GetCFA.

This matches the type in other unwind headers.

Reviewed by: dim, emaste
Differential Revision: https://reviews.freebsd.org/D34050

(cherry picked from commit 3a502289d316f726fec24087012fabb06313a2bf)

2 years agoUse an unsigned 64-bit integer for exception class.
John Baldwin [Thu, 27 Jan 2022 18:34:35 +0000 (10:34 -0800)]
Use an unsigned 64-bit integer for exception class.

This matches the type in other unwind headers (LLVM libunwind,
libcxxrt, glibc).

NB: include/unwind.h is not installed but is only used by libthr

Reviewed by: imp, dim, emaste
Differential Revision: https://reviews.freebsd.org/D34049

(cherry picked from commit b84693501af6521487327ec4eb7c6ae0097ac5d7)

2 years agounbound: Refresh manpages to latest version
Cy Schubert [Thu, 17 Feb 2022 16:11:33 +0000 (08:11 -0800)]
unbound: Refresh manpages to latest version

Update unbound manpages by copying the current unbound manpages in
contrib/doc/*.in to their respective manpages,

PR: 262013
Reported by: Michael Osipov <michael.osipov@siemens.com>
Fixes: numerous previous updates

(cherry picked from commit 0640e0c1965948da53e0baae9eece957919c0b43)

2 years agopf tests: Test adding counters to an existing table
Kristof Provost [Tue, 1 Feb 2022 17:27:40 +0000 (18:27 +0100)]
pf tests: Test adding counters to an existing table

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34132

(cherry picked from commit 109418996514111d887b6790c617cbc7cc3f41a5)

2 years agopf: deal with tables gaining or losing counters
Kristof Provost [Tue, 1 Feb 2022 17:25:57 +0000 (18:25 +0100)]
pf: deal with tables gaining or losing counters

When we create a table without counters, add an entry  and later
re-define the table to have counters we wound up trying to read
non-existent counters.

We now cope with this by attempting to add them if needed, removing them
when they're no longer needed and not trying to read from counters that
are not present.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34131

(cherry picked from commit b21826bf15f7ec1e206fa3cfdf40691f84fb1d8e)

2 years agoFix non-printable characters in NVMe model and serial numbers.
Kenneth D. Merry [Mon, 24 Jan 2022 21:19:25 +0000 (16:19 -0500)]
Fix non-printable characters in NVMe model and serial numbers.

The NVMe 1.4 spec simply says that Model and Serial numbers are
ASCII strings.  Unlike SCSI, it doesn't prohibit non-printable
characters or say that the strings should be padded with spaces.

Since 2014, we have had cam_strvis_sbuf(), which gives additional
options for handling non-ASCII characters.  That behavior hasn't
been available for non-sbuf consumers, so users of cam_strvis()
were left with having octal ASCII codes inserted.

So, to avoid having garbage or octal chracters in the strings, use
cam_strvis_sbuf() to create a new function, cam_strvis_flag(), and
re-implement cam_strvis() using cam_strvis_flag().

Now, for the NVMe drives, we can use cam_strvis_flag with the
CAM_STRVIS_FLAG_NONASCII_SPC flag.  This transforms non-printable
characters into spaces.

sys/cam/cam.c:
Add a new function, cam_strvis_flag(), that creates an sbuf
on the stack with the user's destination buffer, and calls
cam_strvis_sbuf() with the given flag argument.

Re-implement cam_strvis() to call cam_strvis_flag with the
CAM_STRVIS_FLAG_NONASCII_ESC argument.  This should be the
equivalent of the old cam_strvis() function, except for the
overhead of creating the sbuf and calling sbuf_putc/printf.

sys/cam/cam.h:
Declaration for cam_strvis_flag.

sys/cam/nvme/nvme_all.c:
In nvme_print_ident, use the NONASCII_SPC flag with
cam_strvis_flag().

sys/cam/nvme/nvme_da.c:
In ndaregister(), use cam_strvis_flag() with the
NONASCII_SPC flag for the disk description and serial
number we report to GEOM.

sys/cam/nvme/nvme_xpt.c:
In nvme_probe_done(), use cam_strvis_flag with the
NONASCII_SPC flag when storing the drive serial number
in the CAM EDT.

Sponsored by: Spectra Logic
Differential Revision: https://reviews.freebsd.org/D33973

(cherry picked from commit 3090d5045a1e5663f151ef3f50f3c7db8f9a9e3c)

2 years agolinux: Make compat.linux.preserve_vstatus default to 1
Edward Tomasz Napierala [Mon, 17 Jan 2022 08:44:58 +0000 (08:44 +0000)]
linux: Make compat.linux.preserve_vstatus default to 1

From a user point of view, this makes ^T work out of the box.

Reviewed By: debdrup (man page)
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33842

(cherry picked from commit b896bdb86d832d07ae397b340a56beb1a14ff980)

2 years agolinux: More man page tweaks
Edward Tomasz Napierala [Sun, 9 Jan 2022 10:03:44 +0000 (10:03 +0000)]
linux: More man page tweaks

Mention debootstrap(8) and improve the wording.

Reviewed By: debdrup, emaste, Pau Amma
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33772

(cherry picked from commit 595532a766b4bf62401f0567a607e85ed0f548fc)

2 years agolinux(4): man page tweaks
Edward Tomasz Napierala [Wed, 5 Jan 2022 08:16:38 +0000 (08:16 +0000)]
linux(4): man page tweaks

Advertise rc.conf method as the right way to enable it, mention
file system mapping... and change some wording.

Reviewed By: emaste, debdrup, Pau Amma
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D33720

(cherry picked from commit bd8077ee84bd990d88607cc13f36f3da2a4dce10)

2 years agohier(7): add some new Xrs, remove some unrelated ones
Edward Tomasz Napierala [Sat, 18 Dec 2021 11:50:07 +0000 (11:50 +0000)]
hier(7): add some new Xrs, remove some unrelated ones

Reviewed By: debdrup, imp, 0mp
Differential Revision: https://reviews.freebsd.org/D33386

(cherry picked from commit 57976b7af3b23573a5dfd0c752d6a3e52e68bde6)

2 years agointro(3): Fix formatting
Edward Tomasz Napierala [Sat, 18 Dec 2021 11:51:42 +0000 (11:51 +0000)]
intro(3): Fix formatting

This makes the left column narrower, leaving more space for the text.

Reviewed By: debdrup, 0mp
Differential Revision: https://reviews.freebsd.org/D33385

(cherry picked from commit e522571b7948fd64f2652258a73f6588f1fa43f0)

2 years agodevelopment(7): Use a more common architecture for examples
Edward Tomasz Napierala [Sun, 31 Oct 2021 13:27:29 +0000 (13:27 +0000)]
development(7): Use a more common architecture for examples

(cherry picked from commit e03813c3e1fd6aaac87eac3dd258cccb4238ed91)

2 years agolinprocfs: Fix formatting of Uid and Gid lines
Edward Tomasz Napierala [Wed, 3 Nov 2021 08:40:49 +0000 (08:40 +0000)]
linprocfs: Fix formatting of Uid and Gid lines

The separator here should be tabs, not spaces.  This fixes a warning
from chromium-browser on Bionic:

[1022/162248.137612:ERROR:process_info_linux.cc(107)] format error: unrecognized Uid format

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32612

(cherry picked from commit 91be6286e2a7ddad6dcf8d653fcd3f2c0b53072f)

2 years agoMake vmdaemon timeout configurable
Edward Tomasz Napierala [Sun, 17 Oct 2021 12:48:50 +0000 (13:48 +0100)]
Make vmdaemon timeout configurable

Make vmdaemon timeout configurable, so that one can adjust
how often it runs.

Here's a trick: set this to 1, then run 'limits -m 0 sh',
then run whatever you want with 'ktrace -it XXX', and observe
how the working set changes over time.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D22038

(cherry picked from commit 0f559a9f097b9eea318e970155fb23e37af07c4e)

2 years agoprocfs: Document as deprecated
Edward Tomasz Napierala [Sun, 17 Oct 2021 12:44:19 +0000 (13:44 +0100)]
procfs: Document as deprecated

Update the procfs(5) man page to clarify that it's deprecated.

Reviewed By: bcr, 0mp (earlier version)
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D22275

(cherry picked from commit 70774c637b87eac1d9a94bb960e6f5242dad9e43)

2 years agolinux: implement rt_sigsuspend(2) on arm64
Edward Tomasz Napierala [Fri, 23 Jul 2021 20:11:06 +0000 (20:11 +0000)]
linux: implement rt_sigsuspend(2) on arm64

... by making it architecture-independent.

Reviewed By: dchagin
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D31259

(cherry picked from commit 72f7ddb587a79dbea353e40b182ea93bb1dfea21)

2 years agoRegen after 2561da0636c.
Edward Tomasz Napierala [Wed, 21 Jul 2021 12:26:31 +0000 (12:26 +0000)]
Regen after 2561da0636c.

(cherry picked from commit 8bc3dc01005e56035be8807d2a559c1a86960519)

2 years agolinux: Fix declaration of rt_sigreturn() on arm64
Edward Tomasz Napierala [Wed, 21 Jul 2021 12:20:45 +0000 (12:20 +0000)]
linux: Fix declaration of rt_sigreturn() on arm64

On Linux, this syscall doesn't take any arguments; instead
it assumes the context was put on the stack.

Reviewed By: dchagin
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D31251

(cherry picked from commit 2561da0636c1b8504d05246258a5333b621a2433)

2 years agochroot: fix typo in usage
Edward Tomasz Napierala [Wed, 21 Jul 2021 09:16:11 +0000 (10:16 +0100)]
chroot: fix typo in usage

While here also fix typo in a variable name.

Reported By: oshogbo

(cherry picked from commit 0634390572b2390cfa8e2a3fd83359a944461f34)

2 years agosesutil: Fix status checking
Edward Tomasz Napierala [Wed, 21 Jul 2021 09:14:21 +0000 (10:14 +0100)]
sesutil: Fix status checking

Previously we would display "OK, Swapped" for swapped disks,
instead of the usual disk size.

Reviewed By: allanjude
Differential Revision: https://reviews.freebsd.org/D31219

(cherry picked from commit a1571967135255d2ea5256a4721e6f9909f291e5)

2 years agoImplement unprivileged chroot
Edward Tomasz Napierala [Tue, 20 Jul 2021 08:56:04 +0000 (08:56 +0000)]
Implement unprivileged chroot

This builds on recently introduced NO_NEW_PRIVS flag to implement
unprivileged chroot, enabled by `security.bsd.unprivileged_chroot`.
It allows non-root processes to chroot(2), provided they have the
NO_NEW_PRIVS flag set.

The chroot(8) utility gets a new flag, -n, which sets NO_NEW_PRIVS
before chrooting.

Reviewed By: kib
Sponsored By: EPSRC
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D30130

(cherry picked from commit a40cf4175c90142442d0c6515f6c83956336699b)

2 years agolibpfctl: fix pfctl_kill_states()
Kristof Provost [Mon, 31 Jan 2022 17:31:53 +0000 (18:31 +0100)]
libpfctl: fix pfctl_kill_states()

735748f30a changed the output of the states so that the creator id
endianness would be consistent. This means that we need to convert the
host endianness creatorid back to big-endian before we give it to the
kernel.

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6f47a72d8ebf444641bda192b33eb217c9013811)

2 years agolibpfctl: fix creatorid endianness
Kristof Provost [Fri, 21 Jan 2022 16:50:15 +0000 (17:50 +0100)]
libpfctl: fix creatorid endianness

We provide the hostid (which is the state creatorid) to the kernel as a
big endian number (see pfctl/pfctl.c pfctl_set_hostid()), so convert it
back to system endianness when we get it from the kernel.

This avoids a confusing mismatch between the value the user configures
and the value displayed in the state.

MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D33989

(cherry picked from commit 735748f30aad80593e2b7f5f5f175d64484c5eeb)

2 years agopfctl: improve error reporting for routehost
Kristof Provost [Wed, 5 Jan 2022 20:31:02 +0000 (21:31 +0100)]
pfctl: improve error reporting for routehost

If an invalid (i.e. overly long) interface name is specified error out
immediately, rather than in expand_rule() so we point at the incorrect
line.

PR: 260958
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D34008

(cherry picked from commit e68de6694381748b7578703b22580c0f17780b32)

2 years agovdso linker scripts: explicitly specify output arch and target
Konstantin Belousov [Thu, 3 Feb 2022 14:38:15 +0000 (16:38 +0200)]
vdso linker scripts: explicitly specify output arch and target

(cherry picked from commit fd8d4e53bc2ac424d6f08ac700800093b03a2d97)

2 years agortld: Add ${TOKEN} aliases to $TOKEN
Konstantin Belousov [Fri, 11 Feb 2022 13:46:05 +0000 (15:46 +0200)]
rtld: Add ${TOKEN} aliases to $TOKEN

(cherry picked from commit b1b517412342f336a8e6d153130b2f4110e0285b)

2 years agortld: make token substitution table-driven
Konstantin Belousov [Fri, 11 Feb 2022 13:44:36 +0000 (15:44 +0200)]
rtld: make token substitution table-driven

(cherry picked from commit 55abf23dd36b2fa1499bd6806ce4c9510f7a4ee5)

2 years agocompiler-rt: re-exec with ASLR disabled when necessary
Ed Maste [Sun, 16 Jan 2022 19:22:05 +0000 (14:22 -0500)]
compiler-rt: re-exec with ASLR disabled when necessary

Some sanitizers (at least msan) currently require ASLR to be disabled.
When we detect that ASLR is enabled, re-exec with it disabled rather
than exiting with an error.  See LLVM GitHub issue 53256 for more
detail: https://github.com/llvm/llvm-project/issues/53256

No objection: dim
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33934

(cherry picked from commit 930a7c2ac67e1e8e511aa1d0a31a16c632060ebb)

2 years agoelfctl: fix operations with multiple features on multiple files
Ed Maste [Tue, 15 Feb 2022 03:44:01 +0000 (22:44 -0500)]
elfctl: fix operations with multiple features on multiple files

Previously an invocation like

  elfctl -e +feature1,feature2 file1 file2

would set both feature flags in file 1 but only feature1 in file2 (due
to the string being modified by strsep()).

Reported by: jrm
Tested by: jrm
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34283

(cherry picked from commit 82b611ed18e6bfaeadf152ef9216230548c25a8a)

2 years agoelfctl: error if -e is specified multiple times
Ed Maste [Tue, 15 Feb 2022 03:04:29 +0000 (22:04 -0500)]
elfctl: error if -e is specified multiple times

Reported by: jrm
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f0cf9b602dc0375dfc279500e0314b7c55273bf0)

2 years agoelfctl: fix -e invalid operation error handling
Ed Maste [Tue, 15 Feb 2022 03:30:29 +0000 (22:30 -0500)]
elfctl: fix -e invalid operation error handling

Validate the operation prior to parsing the feature string, so that e.g.
-e 0x1 reports invalid operation '0' rather than invalid feature 'x11'.
Also make it an error rather than a warning, so that it is not repeated
if multiple files are specified.

(Previously an invalid operation resulted in a segfault.)

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b8185579f457569640f714b6180522619c2f18ea)

2 years agoOpenSSL: Fix the same BIO_FLAGS macro definition
John Baldwin [Thu, 17 Feb 2022 22:51:58 +0000 (14:51 -0800)]
OpenSSL: Fix the same BIO_FLAGS macro definition

Also add comment to the public header to avoid
making another conflict in future.

Reviewed by: jkim
Obtained from: OpenSSL commit 5d4975ecd88ac17d0749513a8fac9a7c7befd900
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34135

(cherry picked from commit aa7208254996a66fb0b363bb696fe65d81335d81)

2 years agoSSL_sendfile: Replace ERR_raise_data with SYSerr.
John Baldwin [Thu, 17 Feb 2022 22:51:58 +0000 (14:51 -0800)]
SSL_sendfile: Replace ERR_raise_data with SYSerr.

ERR_raise_data is only present in OpenSSL 3.0 and later.

Reviewed by: jkim
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D33363

(cherry picked from commit 27bb8830d555621d4292da8a83f3bc09176fd00d)

2 years agobhyve: set EV_CLEAR for EVFILT_VNODE mevents
Robert Wing [Sun, 12 Dec 2021 21:39:40 +0000 (12:39 -0900)]
bhyve: set EV_CLEAR for EVFILT_VNODE mevents

When an EVFILT_VNODE filter event is triggered, reset it.

This fixes the issue where a virtio-blk resize event would cause the
mevent thread to consume 100% of the cpu.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D33326

(cherry picked from commit 0b29683b32df0233a85f597836e61cc6432a3e4f)

2 years agokldxref: add R_PPC_ADDR32 handler
Alfredo Dal'Ava Junior [Thu, 17 Feb 2022 21:48:52 +0000 (18:48 -0300)]
kldxref: add R_PPC_ADDR32 handler

Implements R_PPC_ADDR32 handler for kldxref, addressing
"kldxref: unhandled relocation type 1" when running
"kldxref /boot/kernel" on powerpc 32 bits.

Reviewed by: luporl
MFC after: 2 days
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D33745

(cherry picked from commit 79f5d19890c3a703b3808af2dffe9d181a2e1696)

2 years agolinux(4): Improve comment about SA_RESTORER
Edward Tomasz Napierala [Tue, 13 Jul 2021 09:38:08 +0000 (10:38 +0100)]
linux(4): Improve comment about SA_RESTORER

No functional changes.

Sponsored By: EPSRC

(cherry picked from commit 3eaf271d3c0e4fa18b74971a71c950fd43fa4189)

2 years agolinux(4): remove unfinished vsyscall bits on arm64
Edward Tomasz Napierala [Tue, 13 Jul 2021 09:52:13 +0000 (09:52 +0000)]
linux(4): remove unfinished vsyscall bits on arm64

The vsyscall mechanism is obsolete.

Reviewed By: dchagin, emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D31091

(cherry picked from commit 84a3963d5d94be05c913d04ea0cef4ac69a8bfc7)

2 years agolinux(4): implement PR_SET_NO_NEW_PRIVS
Edward Tomasz Napierala [Sat, 3 Jul 2021 07:41:59 +0000 (08:41 +0100)]
linux(4): implement PR_SET_NO_NEW_PRIVS

This makes prctl(2) support PR_SET_NO_NEW_PRIVS, by mapping it
to the native PROC_NO_NEW_PRIVS_CTL procctl(2).

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30973

(cherry picked from commit 2f514e6f13de41aa9ad5f563ed0decc66e91f99c)

2 years agolinux: implement set_cloned_tls() on arm64
Edward Tomasz Napierala [Wed, 16 Jun 2021 09:34:06 +0000 (09:34 +0000)]
linux: implement set_cloned_tls() on arm64

This fixes random segfaults on "git commit --amend".

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30508

(cherry picked from commit a397b5508320e757274bc652b43ccb2e1a702933)

2 years agolinux: implement set_upcall on aarch64
Edward Tomasz Napierala [Tue, 15 Jun 2021 12:01:02 +0000 (12:01 +0000)]
linux: implement set_upcall on aarch64

This fixes "git diff" (git-1:2.25.1-1ubuntu3).

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30509

(cherry picked from commit e505c3066bbdb96dd28ff4634a315346490b9b33)

2 years agolinux: implement statx(2)
Philippe Michaud-Boudreault [Tue, 8 Jun 2021 08:24:10 +0000 (09:24 +0100)]
linux: implement statx(2)

PR: 252106
Reviewed By: dchagin
Differential Revision: https://reviews.freebsd.org/D30466

(cherry picked from commit 2362ad457a01d56d87e74823599578ab37bdbfb9)

2 years agoInstall the linux(4) man page also for aarch64
Edward Tomasz Napierala [Mon, 7 Jun 2021 10:50:25 +0000 (11:50 +0100)]
Install the linux(4) man page also for aarch64

Previously it was only installed on i386 and amd64.

Reviewed By: emaste, gbe (manpages)
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30546

(cherry picked from commit dd869341b1e0b58eb50fd2700b3191094d97ef5b)

2 years agoCross-reference camcontrol(8) and zonectl(8) man pages.
Edward Tomasz Napierala [Sat, 10 Apr 2021 09:13:29 +0000 (10:13 +0100)]
Cross-reference camcontrol(8) and zonectl(8) man pages.

(cherry picked from commit 28b475b01832af786f3bbd2aafec9caf121b9ca8)

2 years agolinux: export AT_HWCAP and AT_HWCAP2 on aarch64
Edward Tomasz Napierala [Tue, 1 Jun 2021 12:12:25 +0000 (13:12 +0100)]
linux: export AT_HWCAP and AT_HWCAP2 on aarch64

The flag values seem to be the same between Linux and FreeBSD.
Comparing to a Linux VM on the same hardware, we're missing
HWCAP_EVTSTRM, HWCAP_CPUID, HWCAP_DCPOP, HWCAP_USCAT, HWCAP_PACA,
and HWCAP_PACG.

Reviewed By: mhorne, emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30540

(cherry picked from commit b501b2ae52f3ccb384584dcbb5dc4a4568cc0096)

2 years agolinux: fix architecture returned for uname on aarch64
Edward Tomasz Napierala [Fri, 28 May 2021 23:01:55 +0000 (23:01 +0000)]
linux: fix architecture returned for uname on aarch64

Previously it would return "arm64", which was breaking build
for Linux kernel.  While here, reshuffle entries in the auxv
vector to match real Linux.

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30500

(cherry picked from commit aa462cab60c8957a97f612d36ac0a4dfa501bbbe)