]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agopowerpcspe: fix PCI enumeration on ppce500
Alfredo Dal'Ava Junior [Mon, 21 Mar 2022 10:57:07 +0000 (07:57 -0300)]
powerpcspe: fix PCI enumeration on ppce500

This fixes PCI devices not being found on QEMU ppce500. This
generic board used to have its first PCI slot at 0x11, like the
mpc8544dsi and some real HW. After commit [1], it was changed to
0x1 and our driver wasn't prepared for that.

[1] https://gitlab.com/qemu-project/qemu/-/commit/3bb7e02a9725a24e5bf915b35f914f82f5b07a1f

Reviewed by: jhibbits, bdragon
MFC after: 2 days
Sponsored by: Institudo de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D34621

(cherry picked from commit 27f56d337be39a3f493febb585f3484c4cb6c3b6)

2 years agosnd_hda.4: correct typos
Ed Maste [Fri, 18 Mar 2022 00:11:26 +0000 (20:11 -0400)]
snd_hda.4: correct typos

MFC after: 1 week

(cherry picked from commit 24cf089ab4882f482d5355c1bcdeaa6787a551bf)

2 years agoAllow kern.ipc.maxsockets to be set to current value without error
Allan Jude [Thu, 4 Nov 2021 12:55:33 +0000 (12:55 +0000)]
Allow kern.ipc.maxsockets to be set to current value without error

Normally setting kern.ipc.maxsockets returns EINVAL if the new value
is not greater than the previous value. This can cause spurious
error messages when sysctl.conf is processed multiple times, or when
automation systems try to ensure the sysctl is set to the correct
value. If the value is unchanged, then just do nothing.

PR: 243532
Reviewed by: markj
Sponsored by: Modirum MDPay
Sponsored by: Klara Inc.

(cherry picked from commit c441592a0e1591591665cd037a8a5e9b54675f99)

2 years agoclock_gettime: Fix CLOCK_THREAD_CPUTIME_ID race
firk [Tue, 15 Mar 2022 22:22:21 +0000 (18:22 -0400)]
clock_gettime: Fix CLOCK_THREAD_CPUTIME_ID race

Use a spinlock section instead of a critical section to synchronize with
statclock().  Otherwise the CLOCK_THREAD_CPUTIME_ID clock can appear to
go backwards.

PR: 262273
Reviewed by: markj

(cherry picked from commit 28d08dc7d051a4e058cc0004cf4dd884f87037a2)

2 years agohdac: Handle interrupts racing with device suspend
Mark Johnston [Wed, 16 Mar 2022 16:09:17 +0000 (12:09 -0400)]
hdac: Handle interrupts racing with device suspend

- Avoid looping forever if a concurrent reset causes a read of the
  interrupt status register to return all ones.
- Lock the softc before reading the interrupt status, so as to avoid a
  similar infinite loop in hdac_one_intr().

This fixes suspend-to-S3 on some laptops.

PR: 261207
Reviewed by: mav, imp
Tested by: uqs
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 077564cfdb7285ff7d256424715e563cbac36f8b)

2 years agohda: add patch for Framework laptop headphone jack
Ed Maste [Thu, 17 Mar 2022 19:47:55 +0000 (15:47 -0400)]
hda: add patch for Framework laptop headphone jack

For Framework laptops built after Oct 2021 (like mine) that have a Tempo
Semiconductor 92HD95B codec rather than Realtek ALC295 (see
https://frame.work/ca/en/blog/solving-for-silicon-shortages).

As we do for many other laptops, put the headphone jack and speakers in
the same association by default so that the generic sound device
automatically switches between them.  Also specify the jack colour and
location.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34596

(cherry picked from commit 06731139ca5222a6790163ed427758769696e5ab)

2 years agosound: add patch for Lenovo Legion 5 AMD
Philippe Michaud-Boudreault [Wed, 19 May 2021 14:38:34 +0000 (10:38 -0400)]
sound: add patch for Lenovo Legion 5 AMD

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30333

(cherry picked from commit 45f0e5710509c510955c56a1b3e7d0e392407b0d)

2 years agosnd_hda: restore pin patch for headphones on Lenovo X1 7th Gen
Ed Maste [Fri, 14 Jan 2022 19:40:47 +0000 (14:40 -0500)]
snd_hda: restore pin patch for headphones on Lenovo X1 7th Gen

Fixes: ef790cc7407e ("hdaa: update pin patch configurations")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33900

(cherry picked from commit 301b2b02dfcfddbb5da34dcc20136de1ab2f36af)

2 years agosnd_hda(4): Fix sound on headset jack for ThinkPad T51.
Xin LI [Mon, 12 Jul 2021 05:43:56 +0000 (22:43 -0700)]
snd_hda(4): Fix sound on headset jack for ThinkPad T51.

sys/dev/sound/pci/hda/hdaa_patches.c:
 match_pin_patches: Use HDA_DEV_MATCH instead of regular ==

sys/dev/sound/pci/hda/pin_patch_realtek.h:
 Add quirk for Lenovo laptops when ALC298 is used.

(cherry picked from commit c43bf3f59161ac697a1c3a0a3f9326d4d15216c9)

2 years agohdaa: update pin patch configurations
K Staring [Sat, 3 Jul 2021 06:15:49 +0000 (00:15 -0600)]
hdaa: update pin patch configurations

A number of structural changes:
  - Use decimal nid numbers instead of hex
  - updated the branch to incoorporate the suggestions made in the
    ALC280 pull request github thread
  - Convert magic pin values into strings.
  - Also update hdaa_patches to use clearer enums..
  - made pin patch type enum clearer, add macro for 'string' type
    patches
  - Added pin_patch structures to separate data from logic.
  - Integrated Realtek patches into new structure.

These incorporate fixes for ALC255, ALC256, ALC260, ALC262, ALC268,
ALC269, ALC280, ALC282, ALC283, ALC286, ALC290, ALC293, ALC296, ALC2880

And have definitions for a number of Dell and HP laptops.

Much of this data has been mined fromt he tables in the Linux driver.

imp squashed these into one commit because the changes from the github
pull requests no longer cleanly apply individually and made light style
changes after feedback from jhb.

Pull Request: https://github.com/freebsd/freebsd-src/pull/139
Pull Request: https://github.com/freebsd/freebsd-src/pull/140
Pull Request: https://github.com/freebsd/freebsd-src/pull/141
Pull Request: https://github.com/freebsd/freebsd-src/pull/142
Pull Request: https://github.com/freebsd/freebsd-src/pull/143
Pull Request: https://github.com/freebsd/freebsd-src/pull/144
Pull Request: https://github.com/freebsd/freebsd-src/pull/145
Pull Request: https://github.com/freebsd/freebsd-src/pull/146
Pull Request: https://github.com/freebsd/freebsd-src/pull/147
Pull Request: https://github.com/freebsd/freebsd-src/pull/148
Pull Request: https://github.com/freebsd/freebsd-src/pull/149
Pull Request: https://github.com/freebsd/freebsd-src/pull/150
Differential Revision: https://reviews.freebsd.org/D30619

(cherry picked from commit ef790cc7407e827db9563d08a52a71ab36436986)
(cherry picked from commit 29b4fa787621cbfb070323ecf2ea2da4d372bd94)
(cherry picked from commit a10c85e0f90c8739863f670d490b35d38a37648f)
(cherry picked from commit 86d69de88d1c7e8c7ed906590652008fc6f44d05)

2 years agonetinet tests: only log critical errors from scapy
Kristof Provost [Thu, 17 Mar 2022 22:32:23 +0000 (23:32 +0100)]
netinet tests: only log critical errors from scapy

See also a26e895f3d.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d234b011a8f1cf90acbda2e3cd166459736c7ed2)

2 years agopf tests: Test retrieving nested nat-anchors
Kristof Provost [Thu, 17 Mar 2022 17:33:50 +0000 (18:33 +0100)]
pf tests: Test retrieving nested nat-anchors

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3c3a19d1f42af049e798b193d4fd2a872c7c8fec)

2 years agopfctl: fix retrieving nested nat-anchors
Kristof Provost [Thu, 17 Mar 2022 17:31:37 +0000 (18:31 +0100)]
pfctl: fix retrieving nested nat-anchors

When retrieving nat rules in anchors we need to set the path just like
we do for regular rules.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit a632d9e3601272c0157dce6633fc9a23ad6ae45b)

2 years agopf tests: Test setting and retrieving nested anchors
Kristof Provost [Thu, 17 Mar 2022 18:49:09 +0000 (19:49 +0100)]
pf tests: Test setting and retrieving nested anchors

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d58d2e403db48acac7c8459652e9cb19546ab15b)

2 years agopfctl: fix retrieving nested anchors
Matteo Riondato [Thu, 17 Mar 2022 18:48:28 +0000 (19:48 +0100)]
pfctl: fix retrieving nested anchors

PR: 262622
MFC after: 1 week
Reviewed by: kp

(cherry picked from commit cd8438e5a3a425ea44b261758e17fe62ebb45fce)

2 years agoipmi: Make all sysctls also tunables.
Alexander Motin [Thu, 17 Mar 2022 17:32:46 +0000 (13:32 -0400)]
ipmi: Make all sysctls also tunables.

MFC after: 1 week

(cherry picked from commit 016d18229c6bd81891f47086bf4eec366a7c3cea)

2 years agoMerge libcxxrt commit f2e55091e2e878386c9f7974d4922bbdc4faed84
Dimitry Andric [Sun, 20 Mar 2022 21:21:28 +0000 (22:21 +0100)]
Merge libcxxrt commit f2e55091e2e878386c9f7974d4922bbdc4faed84

  Fix unlock in two-word version and add missing comment.

  Fixes #15
  Fixes #16

This should fix the hangs in __cxa_guard_acquire() reported on i386 (and
possibly other 32-bit platforms).

Obtained from: https://github.com/libcxxrt/libcxxrt/commit/f2e5509
Fixes: 56aaed388b0a
MFC after: 2 weeks

(cherry picked from commit 7819a911ff5132b34996c8b09b2a024cd10fd4fb)

2 years agoReapply libcxxrt atomics cleanup commit, preparing for upstream fix
Dimitry Andric [Sun, 20 Mar 2022 21:19:27 +0000 (22:19 +0100)]
Reapply libcxxrt atomics cleanup commit, preparing for upstream fix

This reapplies upstream commit fd484be, as there is a follow-up fix for
the possible hangs in __cxa_guard_acquire() on i386:

  Atomics cleanup (#11)

  We need to test exception specifiers but they're gone in C++17 so
  compile the tests with an older version of the standard.

  Rewrite the guard logic to be more idiomatic C++ and more
  comprehensible and make sure that atomics are used where necessary.

Obtained from: https://github.com/libcxxrt/libcxxrt/commit/fd484be
Fixes: 56aaed388b0a
MFC after: 2 weeks

(cherry picked from commit bfffb66e7f3cf9766e45a23080200c18535c2b85)

2 years agoRevert upstream libcxxrt commit which can cause hangs on i386
Dimitry Andric [Sat, 19 Mar 2022 19:46:28 +0000 (20:46 +0100)]
Revert upstream libcxxrt commit which can cause hangs on i386

This reverts upstream commit fd484be:

  Atomics cleanup (#11)

  We need to test exception specifiers but they're gone in C++17 so
  compile the tests with an older version of the standard.

  Rewrite the guard logic to be more idiomatic C++ and more
  comprehensible and make sure that atomics are used where necessary.

It looks like there are some corner cases in the i386 and/or 32-bit
atomics handling, which can make __cxa_guard_acquire() hang in certain
situations.

Reported by: antoine
Obtained from: https://github.com/libcxxrt/libcxxrt/commit/fd484be
Fixes: 56aaed388b0a
MFC after: 2 weeks

(cherry picked from commit 2548237983c47c61601b883bb9d6c9a803ef8ce4)

2 years agoMerge libcxxrt master fd484be8d1e94a1fcf6bc5c67e5c07b65ada19b6
Dimitry Andric [Wed, 9 Mar 2022 19:45:01 +0000 (20:45 +0100)]
Merge libcxxrt master fd484be8d1e94a1fcf6bc5c67e5c07b65ada19b6

Interesting fixes:
47661d0 Match libc++abi/libsupc++ when demangling array types
e44a05c Fix unitialized variable in __cxa_demangle_gnu3 after #6 (#8)
5088b05 Remove some code duplication.
fd484be Atomics cleanup (#11)

MFC after: 2 weeks

(cherry picked from commit 56aaed388b0a177b9defb4e6ecb8a716abb3cf33)

2 years agoFix llvm build after 1b3bef43e3cb, due to API change
Dimitry Andric [Sat, 19 Mar 2022 23:12:58 +0000 (00:12 +0100)]
Fix llvm build after 1b3bef43e3cb, due to API change

After merging llvm commit b9ca73e1a8fd for PR 262608, it would fail to
compile with:

/usr/src/contrib/llvm-project/llvm/lib/IR/Operator.cpp:197:22: error: no member named 'isZero' in 'llvm::APInt'
   if (!IndexedSize.isZero()) {
        ~~~~~~~~~~~ ^

Upstream refactored their APInt class, and isZero() was one of the newer
methods which did not yet exist in llvm 13.0.0. Fix this by using the
older but equivalent isNullValue() method instead.

Fixes: 1b3bef43e3cb
MFC after: 3 days

(cherry picked from commit 8e72f458c6d389870730ae0e95d28a0d8609a018)

2 years agoApply llvm fix for assertion compiling certain versions of Wine
Dimitry Andric [Sat, 19 Mar 2022 19:59:04 +0000 (20:59 +0100)]
Apply llvm fix for assertion compiling certain versions of Wine

Merge commit b9ca73e1a8fd from llvm git (by Stephen Tozer):

  [DebugInfo] Correctly handle arrays with 0-width elements in GEP salvaging

  Fixes an issue where GEP salvaging did not properly account for GEP
  instructions which stepped over array elements of width 0 (effectively a
  no-op). This unnecessarily produced long expressions by appending
  `... + (x * 0)` and potentially extended the number of SSA values used
  in the dbg.value. This also erroneously triggered an assert in the
  salvage function that the element width would be strictly positive.
  These issues are resolved by simply ignoring these useless operands.

  Reviewed By: aprantl

  Differential Revision: https://reviews.llvm.org/D111809

PR: 262608
Reported by: Damjan Jovanovic <damjan.jov@gmail.com>
MFC after: 3 days

(cherry picked from commit 1b3bef43e3cb7fb0ab49b813839915514c1134cc)

2 years agomount: make libxo support more locale-aware
Piotr Pawel Stefaniak [Sun, 26 Sep 2021 20:50:28 +0000 (22:50 +0200)]
mount: make libxo support more locale-aware

"special", "node", and "mounter" are not guaranteed to be encoded with
UTF-8. Use the appropriate modifier.

(cherry picked from commit 260f26f035af2095a1b55c04439f479c49e4056c)

2 years agomount: add libxo(3) support
Cameron Katri [Thu, 23 Sep 2021 20:51:30 +0000 (22:51 +0200)]
mount: add libxo(3) support

Adds --libxo to mount(8).

(cherry picked from commit e725ee7eb672a8501600552283d3d08a2f7b6847)

2 years agocap_fileargs: silence warnings of unused variable
Mariusz Zaborski [Sun, 20 Mar 2022 10:17:31 +0000 (11:17 +0100)]
cap_fileargs: silence warnings of unused variable

We still want to fetch the variable just to verify that the interface
is right.

(cherry picked from commit 1e9ce60a6d758ddf5392e96e886fd815694dd66b)

2 years agovt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized
Roger Pau Monné [Thu, 24 Feb 2022 15:53:30 +0000 (16:53 +0100)]
vt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized

There's too many broken hardware out there that wrongly has the
ACPI_FADT_NO_VGA bit set. Ignore it unless running as a virtualized
guest, as then the expectation would be that the hypervisor does
provide correct ACPI tables.

Reviewed by: emaste, 0mp, eugen
Sponsored by: Citrix Systems R&D
PR: 230172

(cherry picked from commit 0518832011caba1e9dcee054d7884797ed8a74c2)

2 years agox86/xen: fix CPUID signature
Roger Pau Monné [Wed, 16 Mar 2022 09:20:51 +0000 (10:20 +0100)]
x86/xen: fix CPUID signature

Reviewed by: cem
Sponsored by: Citrix Systems R&D

(cherry picked from commit 396a8479b0ac310801e998bb1c3dcc6ba4839454)

2 years agoRemove "/dev/" from geom name in `gpart add` command.
Alexander Motin [Wed, 16 Mar 2022 04:09:09 +0000 (00:09 -0400)]
Remove "/dev/" from geom name in `gpart add` command.

PR: 232462
MFC after: 1 week

(cherry picked from commit ed5d6089113cac259202a28f2e1f89727c4d6ea3)

2 years agoAdd Tempo Semiconductor 92HD95B HDA codec ID
Ed Maste [Wed, 16 Mar 2022 15:39:27 +0000 (11:39 -0400)]
Add Tempo Semiconductor 92HD95B HDA codec ID

This codec is found in recent versions of the Framework laptop.  Tempo
Semiconductor acquired these products from IDT's Audio Business Unit.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e997f3370082f8c5e304d16c441b096b80afc7b4)

2 years agonullfs.5: Add an example fstab(5) entry
Mateusz Piotrowski [Tue, 15 Mar 2022 16:20:15 +0000 (17:20 +0100)]
nullfs.5: Add an example fstab(5) entry

Some other file system manual pages like msdosfs(5) feature similar
examples as well.

MFC after: 1 week

(cherry picked from commit 7d62b5df83000e3c5d14f0dfe8be22a2978534f4)

2 years agohier: Document /usr/freebsd-dist
Mateusz Piotrowski [Mon, 14 Mar 2022 17:19:53 +0000 (18:19 +0100)]
hier: Document /usr/freebsd-dist

/usr/freebsd-dist is used used by various programs as the location for
FreeBSD distribution files. In-tree programs following this convention
are bsdinstall(8) and release(7).

Reviewed by: Pau Amma <pauamma@gundo.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34552

(cherry picked from commit 11a6c85d7f2e3cf9cb553b1f5951a83f57520dbc)

2 years agouefi.8: Fix style
Mateusz Piotrowski [Fri, 18 Mar 2022 10:53:10 +0000 (11:53 +0100)]
uefi.8: Fix style

MFC after: 3 days

(cherry picked from commit 20f0dabb71444eed658d75cbe2c381810cac0754)

2 years agorc.subr.8: Format notes consistently
Mateusz Piotrowski [Fri, 18 Mar 2022 14:06:48 +0000 (15:06 +0100)]
rc.subr.8: Format notes consistently

MFC after: 3 days

(cherry picked from commit fa1dab788d2427827b423d72d931f2f201c3838a)

2 years agogptboot.8: Fix a typo and fix lint warnings
Mateusz Piotrowski [Fri, 18 Mar 2022 09:07:18 +0000 (10:07 +0100)]
gptboot.8: Fix a typo and fix lint warnings

MFC after: 3 days

(cherry picked from commit e405ae30971f390670394814a97c164cd67ad363)

2 years agomount: improve error message for invalid filesystem names
Piotr Pawel Stefaniak [Sat, 14 Aug 2021 20:06:08 +0000 (22:06 +0200)]
mount: improve error message for invalid filesystem names

For an invalid filesystem name used like this:
mount -t asdfs /dev/ada1p5 /usr/obj

emit an error message like this:
mount: /dev/ada1p5: Invalid fstype: Invalid argument

instead of:
mount: /dev/ada1p5: Operation not supported by device

Differential Revision: https://reviews.freebsd.org/D31540

(cherry picked from commit 6e8272f317b899438165108a72fa04a4995611bd)

2 years agops: fix `ps -aa`
Math Ieu [Fri, 24 Sep 2021 06:58:40 +0000 (08:58 +0200)]
ps: fix `ps -aa`

Passing the -a flag multiple times made ps show no processes.

Differential Revision: https://reviews.freebsd.org/D27215

(cherry picked from commit bf27a2253f6ba6ee3086046b837b2fe40e22c72c)

2 years agotcp_wrappers: remove duplicate errno declarations
Piotr Pawel Stefaniak [Sun, 13 Feb 2022 18:19:25 +0000 (19:19 +0100)]
tcp_wrappers: remove duplicate errno declarations

(cherry picked from commit 9b6a8ee28d612c43c232fce3493ae0efef613ddb)

2 years agotcp_wrappers: include <unistd.h>
Piotr Pawel Stefaniak [Sun, 13 Feb 2022 18:14:55 +0000 (19:14 +0100)]
tcp_wrappers: include <unistd.h>

This is for getdomainname(3).

(cherry picked from commit 7d636a4d3ebd070acefb05c53c896cd75a9ea745)

2 years agondiscvt: remove set but not used variable
Piotr Pawel Stefaniak [Thu, 17 Mar 2022 22:05:45 +0000 (23:05 +0100)]
ndiscvt: remove set but not used variable

This is a direct commit since ndiscvt has been removed from main.

2 years agoprocstat: remove set but not used variable
Piotr Pawel Stefaniak [Thu, 17 Mar 2022 21:53:00 +0000 (22:53 +0100)]
procstat: remove set but not used variable

In an earlier version of D26310, strcmp was strncmp.

(cherry picked from commit 8b1f5965d9a55a93517c4366f3e1f22166c1aff6)

2 years agobacklight: Remove set but not used variable
Piotr Pawel Stefaniak [Thu, 17 Mar 2022 21:37:15 +0000 (22:37 +0100)]
backlight: Remove set but not used variable

(cherry picked from commit fde687c239e55da067ebd94cfa36e3a8b3a57167)

2 years agoUpdate deprecation notice in snd_maestro, snd_ds1
Ed Maste [Fri, 18 Mar 2022 21:01:12 +0000 (17:01 -0400)]
Update deprecation notice in snd_maestro, snd_ds1

These drivers are broken and have been scheduled for removal since 2012.
They will finally be removed before FreeBSD 14.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1d7f6de5cfc2f752ced8361124566da11f9bc78a)

2 years agortsx: Call rtsx_init() on resume.
hlh-restart [Sat, 19 Mar 2022 16:37:24 +0000 (12:37 -0400)]
rtsx: Call rtsx_init() on resume.

MFC after: 3 days

(cherry picked from commit 1b1bab0078a7bbeb575942c4706a2abcd71d6022)

2 years agoUpdate leap-seconds to leap-seconds.3676924800
Xin LI [Mon, 14 Mar 2022 06:37:56 +0000 (23:37 -0700)]
Update leap-seconds to leap-seconds.3676924800

Obtained from: ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.3676924800
(cherry picked from commit 1d333074349abb736ffdca9e6baf6c71aef4553b)

2 years agocontrib/tzdata: import tzdata 2022a
Philip Paeps [Mon, 21 Mar 2022 15:26:58 +0000 (23:26 +0800)]
contrib/tzdata: import tzdata 2022a

Merge commit '971fa603f2bdf16273135a00ff16c5585520c53f'

Changes: https://github.com/eggert/tz/blob/2022a/NEWS

With this merge, we return to our previous long-standing practice of
distributing the IANA Time Zone Database unmodified.

Releases of tzdb since 2021b have merged some time zones where clocks
have agreed since 1970.  The overwhelming majority of users will not be
affected by this change.  A port of the newly created global-tz fork of
the IANA Time Zone database (misc/global-tz) is available for users who
need more granular pre-1970 time zone history.

(cherry picked from commit 8ea5af2b77f2b43c250cacb257f42c0a54d644c4)

2 years agozfskeys: Support autoloading of keys stored on ZFS
Mateusz Piotrowski [Fri, 18 Mar 2022 12:35:16 +0000 (13:35 +0100)]
zfskeys: Support autoloading of keys stored on ZFS

The zfskeys service script starts before the zfs service script, so that
dataset decryption keys are available when `zfs mount -a` is run. One of
the potential edge cases of this design is that if a key is stored on
ZFS it won't be loaded until `zfs mount -a` is issued.

In order to address that let's try to load the additional keys and mount
related ZFS datasets after the zfs script finishes its standard mounting
procedure.

PR: 262468
Reported by: Graham Perrin <grahamperrin@gmail.com>
Reviewed by: allanjude
Approved by: allanjude (src)
Fixes: 33ff39796ffe Add zfskeys rc.d script for auto-loading encryption keys
MFC after: 3 days
Sponsored by: Modirum
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34601

(cherry picked from commit 97aeda2243568b386d792514996a06daec55eece)

2 years agofusefs: Initialize a pad word in the mknod message
Mark Johnston [Thu, 17 Mar 2022 22:11:26 +0000 (18:11 -0400)]
fusefs: Initialize a pad word in the mknod message

Reported by: Jenkins (KMSAN job)
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c0b98fe16f253d6b5693adeb38cdb78cadb5f58d)

2 years agonetmap: add a tunable for the maximum number of VALE switches
Vincenzo Maffione [Sun, 6 Mar 2022 17:28:44 +0000 (17:28 +0000)]
netmap: add a tunable for the maximum number of VALE switches

The new dev.netmap.max_bridges sysctl tunable can be set in
loader.conf(5) to change the default maximum number of VALE
switches that can be created. Current defaults is 8.

MFC after: 2 weeks

(cherry picked from commit dd6ab49a9aebb5fbb85973d9a859d24daa5e2165)

2 years agoif_epair: build fix
Kristof Provost [Thu, 17 Mar 2022 02:35:13 +0000 (03:35 +0100)]
if_epair: build fix

66acf7685b failed to build on riscv (and mips). This is because the
atomic_testandset_int() (and friends) functions do not exist there.
Happily those platforms do have the long variant, so switch to that.

PR: 262571
MFC after: 3 days

(cherry picked from commit 0bf7acd6b7047537a38e2de391a461e4e8956630)

2 years agonetmap: Fix TOCTOU vulnerability in nmreq_copyin
Vincenzo Maffione [Wed, 16 Mar 2022 06:58:50 +0000 (06:58 +0000)]
netmap: Fix TOCTOU vulnerability in nmreq_copyin

The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after: 3 days

(cherry picked from commit 393729916564ed13f966e09129a24e6931898d12)

2 years agonetmap: Fix integer overflow in nmreq_copyin
Vincenzo Maffione [Wed, 16 Mar 2022 06:57:54 +0000 (06:57 +0000)]
netmap: Fix integer overflow in nmreq_copyin

An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085

(cherry picked from commit 694ea59c7021c25417e6d516362d2f59b4e2c343)

2 years agodevd: correct wifi regexp
Warner Losh [Sun, 9 Jan 2022 17:16:31 +0000 (10:16 -0700)]
devd: correct wifi regexp

Correct the wifi regexp to include iwlwifi and remove wi driver that was
has been retired.

Sponsored by: Netflix

(cherry picked from commit e0ab0ff104cb0e817d47a1a2a235f915ec1a31f4)

2 years agodevd: remove the scsi regexp
Warner Losh [Sun, 9 Jan 2022 17:13:58 +0000 (10:13 -0700)]
devd: remove the scsi regexp

We don't really use the scsi regexp for anything. The rescan was a
workaround that was fixed a long time ago and has been disabled for
ages. And the regexp was incomplete.

Sponsored by: Netflix

(cherry picked from commit 926e825ef823f49e371f61780634475a1f19c812)

2 years agotouch: don't leak descriptor if fstat(2) fails
Mariusz Zaborski [Sat, 12 Mar 2022 10:38:12 +0000 (11:38 +0100)]
touch: don't leak descriptor if fstat(2) fails

If fstat(2) fails the close(2) won't be called, which will leak the
file descriptor.

The idea was borrowed from OpenBSD, where similar patch
was applied for futimens(2).

MFC after: 1 week

(cherry picked from commit cb54c500d0e1a2c52270b15c6db6a88ca3feb86a)

2 years agovirtio_random(8): MFC: avoid deadlock at shutdown time (regression fix)
Eugene Grosbein [Wed, 16 Mar 2022 04:41:51 +0000 (11:41 +0700)]
virtio_random(8): MFC: avoid deadlock at shutdown time (regression fix)

FreeBSD 13+ running as virtual guest may load virtio_random(8) driver
by means of devd(8) unless the driver is blacklisted or disabled
via device.hints(5). Currently, the driver may prevent
the system from rebooting or shutting down correctly.

This change deactivates virtio_random at very late stage
during system shutdown sequence to avoid deadlock
that results in kernel hang.

PR: 253175
Tested by: tom
Relnotes: yes

(cherry picked from commit adbf7727b3a2aad3c2faa6e543ee7fa7a6c9a3d5)

2 years agox86: Correctly report unexpected cache level
Zhenlei Huang [Wed, 16 Mar 2022 20:28:58 +0000 (16:28 -0400)]
x86: Correctly report unexpected cache level

Reviewed by: rpokala, emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34577

(cherry picked from commit ba46c6c4b7fa76d9283294cb6d9ebadbd95f67ca)

2 years agoWITHOUT_BOOT build option appears to include stand, failing on libsa
Toomas Soome [Thu, 17 Mar 2022 17:42:05 +0000 (19:42 +0200)]
WITHOUT_BOOT build option appears to include stand, failing on libsa

building libsa needs to use -I${LDRSRC} for some files.

PR: 260083
Submitted by: Ivan Rozhuk
Approved by: re (gjb, early MFC)

(cherry picked from commit 9633c3d87476f72375f13942b55a4c9a7a00c7d8)

2 years agoarmv8crypto: Remove leftover debug printfs
Mark Johnston [Thu, 17 Feb 2022 19:19:23 +0000 (14:19 -0500)]
armv8crypto: Remove leftover debug printfs

Fixes: 26b08c5d21b5 ("armv8crypto: Use cursors to access crypto buffer data")
Reported by: bz

(cherry picked from commit c89def05b57cb692fca14ffadec33e63670a8fe2)

2 years agoarmv8crypto: Use cursors to access crypto buffer data
Mark Johnston [Wed, 16 Feb 2022 02:50:41 +0000 (21:50 -0500)]
armv8crypto: Use cursors to access crypto buffer data

Currently armv8crypto copies the scheme used in aesni(9), where payload
data and output buffers are allocated on the fly if the crypto buffer is
not virtually contiguous.  This scheme is simple but incurs a lot of
overhead: for an encryption request with a separate output buffer we
have to
- allocate a temporary buffer to hold the payload
- copy input data into the buffer
- copy the encrypted payload to the output buffer
- zero the temporary buffer before freeing it

We have a handy crypto buffer cursor abstraction now, so reimplement the
armv8crypto routines using that instead of temporary buffers.  This
introduces some extra complexity, but gallatin@ reports a 10% throughput
improvement with a KTLS workload without additional CPU usage.  The
driver still allocates an AAD buffer for AES-GCM if necessary.

Reviewed by: jhb
Tested by: gallatin
Sponsored by: Ampere Computing LLC
Submitted by: Klara Inc.

(cherry picked from commit 26b08c5d21b5cf40c5f55f123e879dc1477be9a3)

2 years agoopencrypto: Add a routine to copy a crypto buffer cursor
Mark Johnston [Wed, 16 Feb 2022 02:45:32 +0000 (21:45 -0500)]
opencrypto: Add a routine to copy a crypto buffer cursor

This was useful in converting armv8crypto to use buffer cursors.  There
are some cases where one wants to make two passes over data, and this
provides a way to "reset" a cursor.

Reviewed by: jhb

(cherry picked from commit 09bfa5cf16a37509a136367431472f9169a173ad)

2 years agoarmv8crypto: Factor out some duplicated GCM code
Mark Johnston [Wed, 16 Feb 2022 02:45:59 +0000 (21:45 -0500)]
armv8crypto: Factor out some duplicated GCM code

This is in preparation for using buffer cursors.  No functional change
intended.

Reviewed by: jhb
Sponsored by: Ampere Computing LLC
Submitted by: Klara Inc.

(cherry picked from commit 0b3235ef743d1561c57989042b3c364a5a955f4f)

2 years agoloader: accept "yellow" as a named color
Ed Maste [Fri, 11 Mar 2022 19:27:46 +0000 (14:27 -0500)]
loader: accept "yellow" as a named color

For historical reasons console color number 3 may be either yellow (most
consoles) or brown (VGA palette).  The console escape code standard
uses "yellow", but teken color name constants appear to be based on the
VGA scheme and use TC_BROWN for color 3.  Even so, the palette table
used 50,50,0 as the RGB percentage tuple, resulting in a dim yellow for
framebuffer consoles at the time teken was introduced.

Amusingly, in 19e2ce2d8367 the comment on the palette entry was changed
from "brown" to "dark yellow" but the colour itself was changed from
a pure yellow to being somewhat brown.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e9249ef9582bec08b9afc3ae65b97f6ffffc6bdf)

2 years agoloader: support numeric and named bright colors (8-15)
Ed Maste [Wed, 9 Mar 2022 21:08:04 +0000 (16:08 -0500)]
loader: support numeric and named bright colors (8-15)

Accept "bright" or "light" prefix for named colors.

For numeric colors, update error message to specify that values 0 to 15
are allowed, and verify that values are in that range.

Reviewed by: imp, tsoome (both earlier version)
Relnotes: yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34512

(cherry picked from commit 425e57e7a2f754f7be8425bf3b00ce1469aba5b0)

2 years agoxhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".
Hans Petter Selasky [Wed, 16 Mar 2022 15:48:12 +0000 (16:48 +0100)]
xhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".

Submitted by: John F Carr <jfc@mit.edu>
Sponsored by: NVIDIA Networking

(cherry picked from commit 19837718ab51756183046e5162b8b3b7b3cb8c3d)

2 years agoLinuxKPI: Add comment describing proper use of the on_each_cpu() function.
Hans Petter Selasky [Wed, 16 Mar 2022 14:40:09 +0000 (15:40 +0100)]
LinuxKPI: Add comment describing proper use of the on_each_cpu() function.

Sponsored by: NVIDIA Networking

(cherry picked from commit c6cf874c7de3bcc092a58a932c732221b2933043)

2 years agolindebugfs: Make single_release() NULL safe.
Hans Petter Selasky [Fri, 11 Mar 2022 16:39:44 +0000 (17:39 +0100)]
lindebugfs: Make single_release() NULL safe.

Sponsored by: NVIDIA Networking

(cherry picked from commit a23e475c48da7a3751ffdc689be01d514ea2857c)

2 years agolindebugfs: The Linux file operations use negative return values in the kernel.
Hans Petter Selasky [Fri, 11 Mar 2022 16:37:46 +0000 (17:37 +0100)]
lindebugfs: The Linux file operations use negative return values in the kernel.

Fix sign.

Sponsored by: NVIDIA Networking

(cherry picked from commit 68ec2949ad3411aa8a684dfca2cae90cbe202675)

2 years agolindebugfs: Zero the linux_file structure before use.
Hans Petter Selasky [Fri, 11 Mar 2022 16:29:54 +0000 (17:29 +0100)]
lindebugfs: Zero the linux_file structure before use.

This avoids clients using garbage values on the stack and makes
debugging easier.

Sponsored by: NVIDIA Networking

(cherry picked from commit 88a29d89ebab1ed60607c3dab73143c3b59a0f83)

2 years agonewfs(8): Fix a bug in initialization of sblock.fs_maxbsize .
Wuyang Chung [Tue, 8 Mar 2022 13:52:17 +0000 (21:52 +0800)]
newfs(8): Fix a bug in initialization of sblock.fs_maxbsize .

Fixes: 1c85e6a35d93195e896b030d9a55f7ac4ccee2c3 (SVN r98542)
Pull Request: https://github.com/freebsd/freebsd-src/pull/587
Sponsored by: NVIDIA Networking

(cherry picked from commit c5f549c1e0c9aa1764e87d55f183053c1545b1fc)

2 years agousbtest: Fix issue when multiple devices are sharing same USB vendor and product ID.
Hans Petter Selasky [Sun, 13 Mar 2022 14:17:06 +0000 (15:17 +0100)]
usbtest: Fix issue when multiple devices are sharing same USB vendor and product ID.

When there are multiple devices sharing the same USB vendor and product ID,
the wrong device may be selected. Fix this by also matching the bus and
device address, ugen<X>.<Y> .

Sponsored by: NVIDIA Networking

(cherry picked from commit 16346e1401b8b369e251bc70781349fb9b813cef)

2 years agodumpon: use underlying device if encrypted swap is in use
Ed Maste [Mon, 7 Mar 2022 19:17:01 +0000 (14:17 -0500)]
dumpon: use underlying device if encrypted swap is in use

/etc/rc.d/dumpon runs before /etc/rc.d/swap.  When encrypted swap is in
use the .eli or .bde device will not exist at the time dumpon runs.

Even if this is addressed it does not make sense to dump core to
encrypted swap, as the encryption key will not be available after
reboot rendering the dump useless.  Thus, for the case that dumpdev=AUTO
and encrypted swap is in use, strip the extension and use the underlying
device.

Emit a warning if we are using the underlying device and the user has not
configured dump encryption, so that the user knows that the will not be
encrypted.

PR: 238301
Reported by: Ivan Rozhuk
Reviewed by: jilles
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34474

(cherry picked from commit 67e751f167c98d02f85eb38401e3e6388db09ac1)

2 years agoif_epair: fix race condition on multi-core systems
Michael Gmelin [Wed, 16 Mar 2022 22:08:55 +0000 (23:08 +0100)]
if_epair: fix race condition on multi-core systems

As an unwanted side effect of the performance improvements in
24f0bfbad57b9, epair interfaces stop forwarding traffic on higher
load levels when running on multi-core systems.

This happens due to a race condition in the logic that decides when to
place work in the task queue(s) responsible for processing the content
of ring buffers.

In order to fix this, a field named state is added to the epair_queue
structure. This field is used by the affected functions to signal each
other that something happened in the underlying ring buffers that might
require work to be scheduled in task queue(s), replacing the existing
logic, which relied on checking if ring buffers are empty or not.

epair_menq() does:
  - set BIT_MBUF_QUEUED
  - queue mbuf
  - if testandset BIT_QUEUE_TASK:
      enqueue task

epair_tx_start_deferred() does:
  - swap ring buffers
  - process mbufs
  - clear BIT_QUEUE_TASK
  - if testandclear BIT_MBUF_QUEUED
      enqueue task

PR: 262571
Approved by:    re (gjb, early MFC)
Reported by: Johan Hendriks <joh.hendriks@gmail.com>
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34569

(cherry picked from commit 66acf7685bcd8cf23b6c658a991637238a01859e)

2 years agoEnsure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.
Kirk McKusick [Wed, 16 Mar 2022 18:37:15 +0000 (11:37 -0700)]
Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.

PR:          262580
Approved by: re (gjb, early MFC)

(cherry picked from commit 2983ec0a87a18943564548c5c00c879c8db83edf)

2 years agoxhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".
Hans Petter Selasky [Thu, 3 Mar 2022 16:32:20 +0000 (17:32 +0100)]
xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".

Tested by: br@
Sponsored by: NVIDIA Networking

(cherry picked from commit 33cbbf268f7d0f3daff0c2aa06836d932faf56a9)

2 years agoOpenSSL: Merge OpenSSL 1.1.1n
Jung-uk Kim [Tue, 15 Mar 2022 23:35:22 +0000 (19:35 -0400)]
OpenSSL: Merge OpenSSL 1.1.1n

(cherry picked from commit 5ac766ab8ec23e780f108b7903d46e553d5e39d1)

2 years agovfs: [2/2] fix stalls in vnode reclaim by only counting attempts
Mateusz Guzik [Mon, 7 Mar 2022 10:38:17 +0000 (11:38 +0100)]
vfs: [2/2] fix stalls in vnode reclaim by only counting attempts

... and ignoring if they succeded, which matches historical behavior.

Reported by: pho

(cherry picked from commit 3a4c5dab9266fac93a5cb22c7cee3938466aedea)

2 years agovfs: [1/2] fix stalls in vnode reclaim by not requeieing from vnlru
Mateusz Guzik [Mon, 7 Mar 2022 10:33:59 +0000 (11:33 +0100)]
vfs: [1/2] fix stalls in vnode reclaim by not requeieing from vnlru

Reported by: pho

(cherry picked from commit c35ec1efdcb2978bc3b6a0098c2b412be8d33e39)

2 years agocache: hide hash stats behind DEBUG_CACHE
Mateusz Guzik [Thu, 3 Mar 2022 17:21:13 +0000 (17:21 +0000)]
cache: hide hash stats behind DEBUG_CACHE

They take a long time to dump and hinder sysctl -a when used with
DIAGNOSTIC.

(cherry picked from commit afb08a6d07174bab1a0fc2d01eb2d1b4bf481179)

2 years agoFix a bug in BN_mod_sqrt() that can cause it to loop forever.
Gordon Tetlow [Tue, 15 Mar 2022 16:48:59 +0000 (09:48 -0700)]
Fix a bug in BN_mod_sqrt() that can cause it to loop forever.

Obtained from: OpenSSL Project
Security: CVE-2022-0778
Security: FreeBSD-SA-22:03.openssl

(cherry picked from commit fdc418f15e92732a3551832bcb625ba9b47242df)

2 years agoi386: Call clock_init() after finishidentcpu()
Mark Johnston [Tue, 1 Mar 2022 14:00:05 +0000 (09:00 -0500)]
i386: Call clock_init() after finishidentcpu()

In a subsequent commit clock_init() will attempt to determine the TSC
frequency, and this requires that CPU identification is finalized.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c3d830cf7c71614d21f57c24039de219e4a90538)

2 years agofasttrap: Avoid creating WX mappings
Mark Johnston [Tue, 1 Mar 2022 16:53:42 +0000 (11:53 -0500)]
fasttrap: Avoid creating WX mappings

fasttrap instruments certain instructions by overwriting them and
copying the original instruction to some per-thread scratch space which
is executed after the probe fires.  This trampoline jumps back to the
tracepoint after executing the original instruction.

The created mapping has both write and execute permissions, and so this
mechanism doesn't work when allow_wx is disabled.  Work around the
restriction by using proc_rwmem() to write to the trampoline.

Reviewed by: vangyzen
Tested by: Amit <akamit91@hotmail.com>
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3a56cfedbc701f8026d38c0d808c614c9f0572ae)

2 years agofasttrap: Assert that fasttrap_fork() successfully unmaps scratch space
Mark Johnston [Tue, 1 Mar 2022 16:52:39 +0000 (11:52 -0500)]
fasttrap: Assert that fasttrap_fork() successfully unmaps scratch space

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 83958173eb7d3f9d402e6dc81e66d179a808dd63)

2 years agoproc: Remove assertion that P_WEXIT is not set in proc_rwmem()
Mark Johnston [Tue, 1 Mar 2022 20:08:25 +0000 (15:08 -0500)]
proc: Remove assertion that P_WEXIT is not set in proc_rwmem()

exit1() sets P_WEXIT before waiting for holding threads to finish,
rather than after, so this assertion is racy.

Fixes: 12fb39ec3e6b ("proc: Relax proc_rwmem()'s assertion on the process hold count")
Reported by: Jenkins

(cherry picked from commit 879b0604a8940f575f03bde5457bcf13e64c1ae8)

2 years agoproc: Relax proc_rwmem()'s assertion on the process hold count
Mark Johnston [Tue, 1 Mar 2022 16:48:39 +0000 (11:48 -0500)]
proc: Relax proc_rwmem()'s assertion on the process hold count

This reference ensures that the process and its associated vmspace will
not be destroyed while proc_rwmem() is executing.  If, however, the
calling thread belongs to the target process, then it is unnecessary to
hold the process.  In particular, fasttrap - a module which enables
userspace dtrace - may frequently call proc_rwmem(), and we'd prefer to
avoid the overhead of locking and bumping the hold count when possible.

Thus, make the assertion conditional on "p != curproc".  Also assert
that the process is not already exiting.  No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 12fb39ec3e6bc529feff3ba2862c6a4a30bd54eb)

2 years agolibpfct: factor out pfctl_get_rules_info()
Kristof Provost [Fri, 4 Mar 2022 16:12:01 +0000 (17:12 +0100)]
libpfct: factor out pfctl_get_rules_info()

Introduce pfctl_get_rules_info(), similar to pfctl_get_eth_rules_info()
to retrieve rules information (ticket and total number of rules).

Use the new function in pfctl.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34443

(cherry picked from commit 8c1400b0a1083c9e2bf8f3418eb3e3cfba1a8444)

2 years agolibpfctl: support flushing rules/nat/eth
Kristof Provost [Fri, 4 Mar 2022 14:50:43 +0000 (15:50 +0100)]
libpfctl: support flushing rules/nat/eth

Move the code to flush regular rules, nat rules and Ethernet rules into
libpfctl for easier re-use.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34442

(cherry picked from commit f0c334e4deca08b56b4226539c844a7018e9182d)

2 years agopfctl: support recursive printing of nat rules
Kristof Provost [Sat, 5 Mar 2022 16:55:48 +0000 (17:55 +0100)]
pfctl: support recursive printing of nat rules

PR: 252617
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34455

(cherry picked from commit a20773c810814dd130ca1f0fbf08d27fea465555)

2 years agopfctl: remove unused variable
Kristof Provost [Tue, 8 Mar 2022 11:22:50 +0000 (12:22 +0100)]
pfctl: remove unused variable

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit c4e49c3a65df1e806399962e27eb47a0f611223d)

2 years agoMake the arm64 get_pcpu a function again
Andrew Turner [Tue, 8 Mar 2022 11:38:51 +0000 (11:38 +0000)]
Make the arm64 get_pcpu a function again

We assume the pointer returned from get_pcpu will be consistent even
if the thread is moved to a new CPU. Fix this by partially reverting
63c858a04d565 to make get_pcpu a function again.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ed306634266002a05c88c3a4cd036c99d4cd139a)

2 years agoriscv: Add support for enabling SV48 mode
Mark Johnston [Tue, 1 Mar 2022 14:07:14 +0000 (09:07 -0500)]
riscv: Add support for enabling SV48 mode

This increases the size of the user map from 256GB to 128TB.  The kernel
map is left unchanged for now.

For now SV48 mode is left disabled by default, but can be enabled with a
tunable.  Note that extant hardware does not implement SV48, but QEMU
does.

- In pmap_bootstrap(), allocate a L0 page and attempt to enable SV48
  mode.  If the write to SATP doesn't take, the kernel continues to run
  in SV39 mode.
- Define VM_MAX_USER_ADDRESS to refer to the SV48 limit.  In SV39 mode,
  the region [VM_MAX_USER_ADDRESS_SV39, VM_MAX_USER_ADDRESS_SV48] is not
  mappable.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 31218f3209acf0f8f0dc54e436342c8fa604d279)

2 years agoriscv: Add support for dynamically allocating L1 page table pages
Mark Johnston [Tue, 1 Mar 2022 14:06:57 +0000 (09:06 -0500)]
riscv: Add support for dynamically allocating L1 page table pages

This is required in SV48 mode.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6ce716f7c31a0a1b5ca8224cbb627632f44e4e6c)

2 years agoriscv: Handle four-level page tables in various pmap traversal routines
Mark Johnston [Tue, 1 Mar 2022 14:06:42 +0000 (09:06 -0500)]
riscv: Handle four-level page tables in various pmap traversal routines

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1321117200de1d1796adad856f7e04a66850e992)

2 years agoriscv: Maintain the allpmaps list only in SV39 mode
Mark Johnston [Tue, 1 Mar 2022 14:06:31 +0000 (09:06 -0500)]
riscv: Maintain the allpmaps list only in SV39 mode

When four-level page tables are used, there is no need to distribute
updates to the top-level page to all pmaps.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ceed61483ca9c3c0bf44e37118ae9c8377e6b9ff)

2 years agoriscv: Add pmap helper functions required by four-level page tables
Mark Johnston [Tue, 1 Mar 2022 14:06:15 +0000 (09:06 -0500)]
riscv: Add pmap helper functions required by four-level page tables

No functional change intended.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5cf3a8216e3adad06f1ab02c9a9b201cebcd4809)

2 years agoriscv: Try to improve the comments for locore's page table setup
Mark Johnston [Tue, 1 Mar 2022 14:06:03 +0000 (09:06 -0500)]
riscv: Try to improve the comments for locore's page table setup

No functional change intended.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 43379792365130b1fa338c310f00aa6821493ead)

2 years agoriscv: Conditionally modify the ELF64 sysentvec for SV48
Mark Johnston [Tue, 1 Mar 2022 14:05:02 +0000 (09:05 -0500)]
riscv: Conditionally modify the ELF64 sysentvec for SV48

A sysinit determines whether the pmap has enabled SV48 mode and modifies
the corresponding fields which describe the user memory map.

Reviewed by: kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ecaf115434cf5b427339d27860bcbee3e9f48e39)

2 years agoriscv: Define a SV48 memory map
Mark Johnston [Tue, 1 Mar 2022 14:04:38 +0000 (09:04 -0500)]
riscv: Define a SV48 memory map

No functional change intended.

Reviewed by: kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 35d0f443cfaaa32afa43f4ffca986590fc56d827)

2 years agoriscv: Add various pmap definitions needed to support SV48 mode
Mark Johnston [Tue, 1 Mar 2022 14:04:01 +0000 (09:04 -0500)]
riscv: Add various pmap definitions needed to support SV48 mode

No functional change intended.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 59f192c507c49990b603f774bbb824fab71ee4c3)

2 years agoriscv: Use generic CSR macros for writing SATP
Mark Johnston [Tue, 1 Mar 2022 14:03:44 +0000 (09:03 -0500)]
riscv: Use generic CSR macros for writing SATP

Instead of having the one-off load_satp(), just use csr_write().  No
functional change intended.

Reviewed by: alc, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2e956c30cab6a36fee9a3d5159c3903406e3e5e7)

2 years agoriscv: Rename struct pmap's pm_l1 field to pm_top
Mark Johnston [Tue, 1 Mar 2022 14:03:30 +0000 (09:03 -0500)]
riscv: Rename struct pmap's pm_l1 field to pm_top

In SV48 mode, the top-level page will be an L0 page rather than an L1
page.  Rename the field accordingly.  No functional change intended.

Reviewed by: alc, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 82f4e0d0f06456f2d070d2e0692a8f318f4eb90b)