Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caprevoke: merge through 2023-07-07 #1740

Merged
merged 1,026 commits into from
Jul 8, 2023

Conversation

brooksdavis
Copy link
Member

PR for CI

emaste and others added 30 commits June 21, 2023 10:35
Cirrus-CI was red because `make makeman` failed with a spurious "filemon
is not loaded" error.  For now just make it a warning.
Keep the old constants for backwards compatibility.

MFC after:	1 week
- In _in_pcbinshash_wild(), we should avoid returning v6 sockets unless
  no other matches are available.  This preserves pre-existing
  semantics.
- Fix an inverted test: when inserting a non-jailed PCB, we want to
  search for the first non-jailed PCB in the hash chain.
- Test the right PCB when searching for a non-jailed PCB.

While here, add a required locking assertion.

Fixes:	7b92493 ("inpcb: Avoid inp_cred dereferences in SMR-protected lookup")
Prompted by a compiler warning introduced by
e582d4a ("arm64: nexus code tidy-up").

Reviewed by:	mhorne, andrew
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39749
Reviewed by:	mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39750
It appears that PAC registers are configured to trap upon access, but
since the kernel starts in EL1 on this platform it has no ability to
inspect or modify this configuration.  Simply disable PAC on this
platform for now, since the kernel otherwise hangs during boot.

PR:		270472
Reviewed by:	andrew, emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D39748
Summary:
After llvm/llvm-project@b4257d3bf58c ("[tsan]
Replace mem intrinsics with calls to interceptors") intrinsic calls to
memcpy, memmove or memset will directly call sanitizer interceptors,
e.g. __tsan_memcpy, __tsan_memmove or __tsan_memset.

Building GENERIC-KCSAN with clang >= 16 would thus result in link errors
similar to:

  ld: error: undefined symbol: __tsan_memcpy
  >>> referenced by cam_compat.c:150 (/usr/src/sys/cam/cam_compat.c:150)
  >>>               cam_compat.o:(cam_compat_handle_0x17)
  >>> referenced by cam_compat.c:151 (/usr/src/sys/cam/cam_compat.c:151)
  >>>               cam_compat.o:(cam_compat_handle_0x17)
  >>> referenced by cam_compat.c:152 (/usr/src/sys/cam/cam_compat.c:152)
  >>>               cam_compat.o:(cam_compat_handle_0x17)
  >>> referenced 1692 more times

Similar to subr_msan.c, add aliases from the existing kcsan_* versions
of these functions to __tsan_* names.

Reviewed by:	markj
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D39772
Exporting UPDATE_DEPDFILE=NO from makeman didn't work,
back to setting it in local.meta.sys.env.mk
Import ISC-licensed driver parts of mediatek/mt76
assumed to be based on Linux wireless-testing at
a02411a5b98612c12be99349836d99f07db12a77 (tag: wt-2022-11-23).

Complement the driver and LinuxKPI with our own (dummy)
implementations of missing parts (util.h and soc/mediatek/)
as well as changes to make compile on FreeBSD with changes
covered by #ifdef (__FreeBSD__) conditions.
Further select updates were applied since the initial import
in order to keep compiling along with other LinuxKPI based
drivers.

For the moment we only target the mt7915 and mt7921 PCI parts.
More may follow in the future.

Firmware is provided by port net/wifi-firmware-mt76-kmod.

Given the lack of full license texts on non-local files this is
imported under the draft policy for handling SPDX files (D29226). [1]

Approved by:	core (emaste, 2022-04-08) [1]
MFC after:	2 months
Add framework to build if_mt7915 and if_mt7921 with LinuxKPI
as well as initial man pages for the two mt76 chipset drivers.

MFC after:	2 months
Add the "mt79" to the regex for wireless drivers in devd.conf so
that they get handled as expected.

MFC after:	2 months
In order to match these drivers, and in expectiation of ath12k
happening add ath[0-9]+k to the regex pattern for wlan devices.

MFC after:	2 months
Add files needed by ath1?k drivers to linuxkpi/linuxkpi_wlan.
This contain (skeleton) implementations of what is needed to
compile but specifically mhi/qmi/qrtr will need more work for
ath11k.

MFC after:	2 months
Import common ISC-licensed athk parts assumed to be
based on Linux kvalo/ath.git master at
6bae9de622d3ef4805aba40e763eb4b0975c4f6d.

The only modification should be for FreeBSD module
handling in main.c.

Add the module build framework unconnected to the
build for now.

These files will be shared by ath1?k drivers.

MFC after:	2 months
Import ISC-licensed ath10k driver assumed to be
based on Linux kvalo/ath.git master at
6bae9de622d3ef4805aba40e763eb4b0975c4f6d.

Import support to redirect fwlogs to kernel messages
from https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/389075

Complement the driver to make compile on FreeBSD
using LinuxKPI with changes covered by #ifdef (__FreeBSD__).
Further select updates were applied since the initial import
in order to keep compiling along with other LinuxKPI based
drivers.

Any other native driver using BUS_PROBE_DEFAULT will attach
ignoring this one by default given bsd_probe_return is set
to a lower priority.

Add the module build framework.

We only support PCI parts.

The firmware is provided by port net/wifi-firmware-ath10k-kmod.

Given the lack of full license texts on most files this is
imported under the draft policy for handling SPDX files (D29226). [1]

Approved by:	core (emaste, 2022-04-08) [1]
MFC after:	2 months
Add initial man page for ath10k.4.

MFC after:	2 months
PR:	271038
Reported by:	[email protected]
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
When building on various hosts it can be handy to create pseudo
options like MK_host_egacy - building on a host that needs libegacy.

Such options should be ignored by showconfig

Reviewed by: emaste
deduplicate this as it might be needed for other drivers (e.g. Apple SPI-HID)

Sponsored by:	https://www.patreon.com/valpackett
Reviewed by:	chuck, imp
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D32879
These feature are required for an upcoming Apple MacBook topcase
(HID over SPI) driver:

A delay after toggling CS is required to avoid anomalies like an extra
junk byte in front of the message. Keeping CS asserted is required to
be able to read a status report after writing a command. (The device
won't return the status if CS was deasserted.)

Sleep is not allowed in the interrupt context where the Apple input
driver runs its transactions. Use a flag to tell the SPI driver to
avoid mtx_sleep.

Reviewed by:	manu (ok to SPI part of larger patch)
MFC afret:	1 month
Differential revision:	https://reviews.freebsd.org/D29534
Also adds fixups and cleanups:

- apply the child's mode/speed
- implement suspend/resume support
- use RF_SHAREABLE interrupts
- use bus_delayed_attach_children since the transfer can use interrupts
- add support for newly added spibus features (cs_delay and flags)

Operation tested on Broadwell (Wildcat Point) MacBookPro12,1.
Attachment also tested on Kaby Lake (Sunrise Point) Pixelbook.

Reviewed by:	wulf
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D29249
hid_input is equal to 0. It is leftover from NetBSD code.

Reviewed by:	hselasky, wulf
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D28149
When mapping the arm64 KASAN shadow map we use Ln_TABLE_MASK to align
physical addresses, however these should already be aligned either
by rounding to a greater alignment, or the VM subsystem is giving us
a correctly aligned page.

Remove these extra alignment masks.

Reviewed by:	kevans
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39752
There is padding between some fields. Mark those I have found so they
can be reused later if needed.

Sponsored by:	Arm Ltd
To allow for attachments that don't use memory mapped registers add
a flag they can set when the base driver shouldn't map them.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39227
Add a n attachment to the pci_host_generic driver for the Arm DEN0115
PCI Configuration Space Access Firmware Interface [1]. This can be used
when PCI controllers need to implement quirks in the PCI root bus.
To handle this the firmware implements a SMCCC interface the driver can
use to read and write the configuration register.

This has been tested on a Raspberry Pi 4 booting with EDK2.

[1] https://developer.arm.com/documentation/den0115/latest

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39228
Use a single uint64_t to hole the mpidr register as we can break the
KBI on 14. Keep the macro so code can still be MFCd to 13.

Sponsored by:	Arm Ltd
The bus tag and handle fields are already stored in the resource. Use
this with the bus_read/bus_write helper macros.

Sponsored by:	Arm Ltd
Use the xref from OF_xref_from_node for the smmu xref. We already have
a valid xref ID, there is no need to convert this to a memory address.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39181
bsdjhb and others added 28 commits June 23, 2023 09:33
These are all due to the empty object used with nla_p_donemsg.
This fixes the build on i386 and other architectures which didn't
have a definition of PHYS_TO_DMAP_PAGE but which do have a stub
for PHYS_TO_DMAP.

Also, one can't use #if PMAP_HAS_DMAP, PMAP_HAS_DMAP is a runtime-only
macro as it maps to a variable (not a constant) on powerpc.

Use uintmax_t casts to print PAs while here to pacify the build on
32-bit platforms as well as i386 which has 64-bit PAs.
This was a lost race due to PIOD_WRITE_CHERI_CAP landing before the
introduction of PHYS_TO_DMAP_PAGE.
The first argument needs to be a void * now rather than an integer.

cheribuild doesn't notice this for amd64 since it disables OFED even
for non-cheri platforms.
Always use a capability with full page bounds when zeroing a subpage region.
Currently Makefile.libcompat queries a few MK_FOO variables to determine
what is being built. However, it is plausible (and indeed, downstream
in CheriBSD, this is the case) that these may vary between the native
and the compat architecture. In order to correctly determine their
values for the compat architecture, we need to defer their evaluation
until we are in the compat sub-make where src.opts.mk will give us the
right value for the compat MACHINE_ARCH.

Reviewed by:	brooks, jhb, imp
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D40570

(cherry picked from commit 10afc5e)
Whilst the kernel can support any number of COMPAT_FOO, world can only
build a single libfoo. Upstream this isn't such an issue, since the only
option is lib32 anyway, but downstreams, such as CheriBSD, may wish to
support multiple at the same time. Thus, adjust the top-level Makefiles
to turn _LIBCOMPAT into a _LIBCOMPATS list that gets iterated over, and
adjust bsd.compat.mk to support this use-case.

For the normal NEED_COMPAT/WANT_COMPAT case, LIBCOMPATFOO remain set and
refer to the requested compat's, preserving the current interface. For
the top-level Makefiles those variables are no longer set (since there
is no longer "the" compat) and only the per-compat ones are available.

Reviewed by:	brooks, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D40571

(cherry picked from commit 91d7edd)
Makefile.libcompat now supports building multiple sets of compat
libraries so this is no longer needed. It is, however, rather academic
for now given CHERI-MIPS was removed (the only CHERI architecture whose
base architecture has LIB32 support in FreeBSD), at least until upstream
gains LIB32 for arm64.aarch64.
get_arm64_tls pokes at the PCB for TPIDR_EL0 so needs the relevant
definitions. Currently we have a downstream diff to sys/systm.h that
pulls in machine/pcb.h, but that was only needed for CHERI-MIPS and so
should go away, which exposes this missing include.
Upstream doesn't pull it in here; this diff dates back to CHERI-MIPS,
which stored DDC in the PCB and thus __USER_CAP needed its definition.
However, neither Morello nor CHERI-RISC-V get it from the PCB and so do
not need this include (nor is it a generic thing that's needed), so we
should not have this as a downstream diff any more.

This fixes building lib32 libprocstat on amd64. Currently it dies
building zfs_defs.c, since it transitively includes machine/fpu.h via
sys/systm.h and, because it hackily defines _KERNEL, gets kernel
prototypes for things like fpu_save_area_free which reference struct
savefpu, but x86/fpu.h will give the i386 definition, which is a union
not a struct, giving a tag mismatch error. This issue once again
highlights how awful this approach is, and how fragile the whole thing
is when you start modifying system headers. We should probaby invest
efforts in fixing this mess upstream given the continued friction seen
around libprocstat/zfs downstream.
The situation for cleandir is a bit of a mess. The top-level build runs
cleandir normally and re-runs it per-libcompat under LIBCOMPATWMAKE.
This includes all programs, not just libraries, and so we end up in
nonsense situations. As a result, bsd.compat.mk is stubbed out for
cleandir, which in turn means it won't define libcompats, yet the top
level has defined _LIBCOMPATS, and so we end up trying to index it and
error out. Thus, skip this code in that instance, since cleandir isn't
referencing any of these targets. Note that, prior to multi-libcompat
support, we'd just reference the undefined libcompat and it would expand
to the empty string (which isn't an error in the contexts it was done,
other than the one removed in 86ddc08), but now we have to be more
careful.

This should all be reworked upstream so cleandir doesn't do stupid
things and these hacks can go (including reverting the .warn that
otherwise gets hit in bsd.compat.mk back to an .error).

Fixes:	cb783c2 ("Generalise libcompat to be a list rather than a single option")
Fixes:	#1729
Fixes:	c5c2d3d ("c18n: Insert trampolines for PLT function calls")
These add a bit to the build time, but we want to check that we're not
regressing the lib32 build as has happened in the past. We may wish to
flip the default in cheribuild (or remove the option entirely) at some
point in the future once we don't need to support versions where the
build is broken.
It's plausible these could mean something else in the Arm architecture
outside of the Morello architecture fork, so we shouldn't go defining
(and using) them unless we know we're targeting Morello.
Because Morello awkwardly puts the encoding mode in SPSR rather than
CELR, we need to explicitly copy it over to the child's trapframe
otherwise we'll lose the state and end up back in A64. In practice, this
currently doesn't matter, since the success path doesn't have any
mode-dependent instructions and terminates in a ret, which will get the
right mode from c30, and the error path (which does have mode-dependent
instructions behind a direct branch to cerror) can never be reached in
the child, only the parent. However, this is still wrong, and will
matter in the Morello benchmark ABI, where fork will return with an
integer ret x30 and thus stay in A64.
Currently we just use "Child exited abnormally" for when the child
process doesn't exit cleanly, which is unhelpful when debugging, so
print the signal number instead if it was due to a signal.

Note that tests which deliberately provoke signals still exit cleanly,
since the child's test harness will catch the signal, save various parts
of the given siginfo_t and exit. This code is only for more catastrophic
situations (e.g. signal delivery itself is broken or the child received
a fatal signal before even setting up the handler).
This lets you easily run multiple cheribsdtest variants in sequence,
filtering out the verbose logging for each test, printing just the
summary lines at the end, as a useful tool for local testing. It is only
intended for humans and should not be extended for use in automated
environments; those should be using cheribuild or another similar tool
to do things properly.
@brooksdavis brooksdavis merged commit f430a5b into caprevoke Jul 8, 2023
14 checks passed
@brooksdavis brooksdavis deleted the caprevoke-merge-through-20230707 branch July 8, 2023 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.