Commit Graph

2959 Commits

Author SHA1 Message Date
Harry Moulton 58de791536 arm64: mte: configure initial state for system registers
The fields in SCTLR_EL1 and HCR_EL2 for enabling MTE are set, and if the
ID_AA64PFR1_EL1 register shows MTE is present, the GCR_EL1 register is
also configured, and the two TFSR registers which hold pending tag check
faults are cleared.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Signed-off-by:	Harry Moulton <harry.moulton@arm.com>
Differential Revision:	https://reviews.freebsd.org/D55946
2026-04-13 15:23:05 +01:00
Harry Moulton aa555b6004 arm64: mte: add system register definitions
Add system register and bit field definitions for Memory Tagging
Extension (MTE) in ARMv8.5.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Signed-off-by:	Harry Moulton <harry.moulton@arm.com>
Co-authored-by:	Andrew Turner <andrew@FreeBSD.org>
Differential Revision:	https://reviews.freebsd.org/D55945
2026-04-13 15:23:05 +01:00
Harry Moulton 7e718b9a8e arm64: mte: cleanup cache register definitions
Cleanup the definitions in armreg.h for the CSSIDR_EL1, CLIDR_EL1 and
CSSELR_EL1 system register to prepare for additional bitfeilds for
Memory Tagging Extension (MTE).

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Signed-off-by:	Harry Moulton <harry.moulton@arm.com>
Differential Revision:	https://reviews.freebsd.org/D55944
2026-04-13 15:23:05 +01:00
Andrew Turner 5809584275 arm64: Handle changing self-referential DMAP pages
Support changing the property of a DMAP page that holds it's own page
table entry.

Because we need to perform a break-before-make sequence to change the
properties of pages a page that also holds it's own page table entry
will fault in the make part of the sequence.

Handle this by mapping the page with a temporary mapping as we already
do when demoting a superpage.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55943
2026-04-13 15:23:05 +01:00
Andrew Turner c208439cdb arm64: Add a cmap page to pmap
When modifying mappings in pmap we may need to perform a
break-before-make sequence. This creates an invalid mapping, then
recreates it with the changes.

When modifying DMAP mappings we may be changing the mapping that
contains its own page table then after breaking the old entry we are
unable to create the new entry.

To fix this create a map that can be used & won't be affected by the
break-before-make sequence.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D56306
2026-04-13 15:23:05 +01:00
Adrian Chadd 4e3fdced7f qcom_gcc: migrate the MSM8916 support to qcom_gcc
* migrate the MSM8916 (snapdragon 410) support to qcom_gcc
* add the full qcom_gcc / qcom_clk list to files.arm64, replacing
  the MSM8916 stub in sys/arm64/qualcomm .

Differential Revision:	https://reviews.freebsd.org/D49706
2026-04-10 15:12:11 -07:00
Weixie Cui e8053023e7 arm64/apple: Fix malloc size for per-CPU arrays in AIC attach
sizeof(*sc->sc_ipimasks) * mp_maxid + 1 is parsed as
(sizeof(*sc->sc_ipimasks) * mp_maxid) + 1, so the buffers were one byte
short of a full (mp_maxid + 1) element count.  Multiply by (mp_maxid + 1)
for sc_ipimasks and sc_cpuids.

Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
Reviewed-by: kevans, ngie
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2112
2026-04-07 17:50:25 -07:00
Mark Johnston c6a1c1260f pmap: Do not use PMAP_LOCK_INIT with kernel_pmap
The kernel_pmap lock is a bit special: it does not need the DUPOK flag,
and it really belongs to a different lock class.  If it belongs to the
same class as regular pmap locks, then witness may report warnings when
performing UMA allocations under a regular pmap lock, if the allocation
triggers a pmap_growkernel() call.

Replace instances of PMAP_LOCK_INIT(kernel_pmap) with inline mtx_init()
calls to silence some witness warnings for harmless behaviour I see with
some uncommitted test programs.

Reviewed by:	alc, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D56185
2026-04-01 07:15:42 -04:00
Pouria Mousavizadeh Tehrani 254b23eb1f routing: Retire ROUTE_MPATH compile option
The ROUTE_MPATH compile option was introduced to
test the new multipath implementation.
Since compiling it has no overhead and it's enabled
by default, remove it.

Reviewed by:	melifaro, markj
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D55884
2026-03-27 23:55:33 +03:30
Dag-Erling Smørgrav 092687a031 kernel: Be clearer about what ZSTDIO is for
ZSTDIO is not just for core dumps, and it is now required by ZFS, so
move it (and GZIO, which is still just for dumps) to a new “Compression
support” section in GENERIC, and add them both to MINIMAL.

MFC after:	1 week
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D55940
2026-03-21 08:21:45 +01:00
Andrew Turner 14e97448fc arm64: Have a common call to userret
Rather than each exception calling userret use a common copy. As
syscallret already calls userret we need to skip it in that case.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55250
2026-03-17 17:10:40 +00:00
Andrew Turner 80b4129bef arm64: Optimise the repeated TLBI workaround
It has been reported that the overhead of repeating all TLBI
instructions is too large [1]. The Software Developer Errata Notices
(SDEN) for the relevant Arm CPUs have been updated so a single
"tlbi vale1is, xzr" followed by "dsb ish"  is sufficient to work around
the issues.

Replace the places we repeat TLBI instructions with the new sequence.

[1] https://lore.kernel.org/linux-arm-kernel/20260218164348.2022831-1-mark.rutland@arm.com/

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55646
2026-03-05 15:13:30 +00:00
Andrew Turner 570b8b2575 arm64: Use a canonical address when TBI is enabled
When Top Byte Ignore (TBI) is enabled in a processor we need to pass
a canonical address to the vm subsystem.

Reviewed by:	alc, kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55619
2026-03-05 15:13:30 +00:00
Andrew Turner d1650d2262 arm64/vmm: Support PMU v3p9
The only new register is read-only. As the kernel just passes the
registers to the guest directly no further change should be needed.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D51764
2026-03-04 17:10:52 +00:00
Kajetan Puchalski e40e545861 arm64: Treat the PMUVer field of ID_AA64DFR0 as unsigned
The PMUVer field of ID_AA64DFR0 contains an unsigned version of the
Performance Monitors Extension, but it is currently treated as signed.
Change it to unsigned.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Signed-off-by:	Kajetan Puchalski <kajetan.puchalski@arm.com>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2062
2026-03-04 17:10:52 +00:00
Timo Völker 0272359ada arm64/pmap: fix pmap_is_valid_memattr()
The function pmap_is_valid_memattr(pmap, mode) checks whether the
given variable mode is between the two constant values
VM_MEMATTR_DEVICE and VM_MEMATTR_WRITE_THROUGH.
After the code for this function was written, the value of
VM_MEMATTR_DEVICE changed from 0 to 4. Since VM_MEMATTR_WRITE_THROUGH
is still 3, the condition is always false.
This patch changes the condition to check whether mode is equal to any
of the VM_MEMATTR* constants.

Reviewed by:		andrew, tuexen
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D55534
2026-03-02 18:59:45 +01:00
John Baldwin 6513c2845f sys: Declare 'end' as an extern char[]
While here, remove an unused declaration.

Reviewed by:	jrtc27
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D53898
2026-02-24 21:20:59 -05:00
Bjoern A. Zeeb c3ed2f3e41 qoriq / nxp: Fix spelling take II
Fix spelling of NXP, which is not NPX, in two places.

Improves:	a4e30909ec
Reported by:	Kevin Bowling (kevin.bowling kev009.com), qoriq_dw_pci.c
MFC after:	3 days
2026-02-24 23:12:46 +00:00
Bjoern A. Zeeb a4e30909ec qoriq: fix spelling in device_set_desc()
The product series is called NXP QorIQ Layerscape.  Remove the extra 'e.

MFC after:	3 days
Reviewed by:	mmel, emaste
Differential Revision: https://reviews.freebsd.org/D55388
2026-02-24 22:04:36 +00:00
Andrew Turner 3a960425df arm64: Add more HWCAP values
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55219
2026-02-18 15:56:46 +00:00
Andrew Turner f4d1a3ab02 arm64: Fix the ESR_ELx_EC_MASK definition
Sponsored by:	Arm Ltd
2026-02-18 15:15:41 +00:00
John Baldwin 4092df8820 arm64: Explicitly use movz
This appeases GNU as which doesn't map the mov alias to movz.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D55160
2026-02-17 15:46:35 -05:00
John Baldwin dc47d99c50 arm gicv3: Use private IVAR range for GICV3 IVARs
Suggested by:	andrew
Differential Revision:	https://reviews.freebsd.org/D54191
2026-02-17 15:45:48 -05:00
John Baldwin 824ce81f74 bus: Drop a couple of unused IVAR indices
This changes the in-kernel ABI, but that is permitted across major
versions and is cleaner than leaving these around forever.

Differential Revision:	https://reviews.freebsd.org/D54160
2026-02-17 15:45:38 -05:00
John Baldwin 6cf4e30252 bus: Document special ranges of IVARs
Some IVAR indices are special in that they have global meaning across
multiple buses where as other IVARs are always private to the local bus.
Try to document this a bit and add constants for the various ranges to
avoid future conflicts.

This is a no-op, but IVAR indices are now generally defined as enums
as that makes it easier to define them in terms of ranges.

Reviewed by:	imp, royger, andrew
Differential Revision:	https://reviews.freebsd.org/D54159
2026-02-17 15:45:13 -05:00
Sarah Walker 1224347817 arm64: Add MOPS implementations of copyin/copyout
Reimplement copyin() & copyout() as ifuncs.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54947
2026-02-10 15:39:56 +00:00
Sarah Walker 7d7295df9b arm64: Add MOPS implementation of pagezero()
Reimplement pagezero() as ifunc. As pagezero() is only used in pmap.c,
move ifunc to that file.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54946
2026-02-10 15:39:56 +00:00
Sarah Walker 2ccbf06c02 arm64: Add MOPS implementations of memset(), memcpy() and memmove()
Enable the use of MOPS implementations of memset, memcpy and memmove within
the kernel. Fix pre-ifunc resolution uses of these functions.

Reported by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55051
2026-02-10 15:39:56 +00:00
Sarah Walker 18af5a180b arm64: Enable MOPS usage in the kernel
Support handling kernel-side MOE exceptions.

Reported by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54943
2026-02-10 15:39:56 +00:00
Konstantin Belousov 24038d696e Revert "pcb.h: mark struct pcb to be preserved"
kgdb only uses the marked fields from dumppcb for initial frame
reconstruction.

This reverts commit 8f23665fed.
2026-02-09 20:55:57 +02:00
Andrew Turner 1c41e411b5 arm64: Have get_kernel_reg return void
It now panics when it's unable to find the register, so doesn't need
to return a status.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55106
2026-02-09 17:24:28 +00:00
Andrew Turner a8c3933840 arm64: Assume get_kernel_reg returns true
It now only returns true so this can be assumed and doesn't need to be
checked.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55105
2026-02-09 17:24:27 +00:00
Andrew Turner 3b0b6aa2cd arm64: Panic if the ID register isn't known
This will allow for callers to be simplified & not need to check the
return status.

Keep the return type for now so this can be MFCd without breaking the
KBI.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55104
2026-02-09 17:24:27 +00:00
Andrew Turner 0ea31fe851 arm64: Move creating the ID register views earlier
These are needed when enabling CPU features so should be processed
earlier in the boot.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D55103
2026-02-09 17:24:26 +00:00
Tom Jones e506af08bb aw_gpio: Add support for H616
This adds padconf files for the two gpio ranges on the H616 SOC and adds
the SOC include.

Reviewed by:	manu
Sponsored by:   The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D54915
2026-02-09 10:22:20 +00:00
Minsoo Choo 8f23665fed pcb.h: mark struct pcb to be preserved
There are programs that depend on this structure (e.g. kernel debuggers)
that breaks when the ABI changes.

Signed-off-by:	Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D55149
2026-02-09 06:17:16 +02:00
John Baldwin e9a697bf20 STACKALIGN: Reimplement in terms of __align_down
This changes STACKALIGN to be type-preserving when operating on
pointers.

Reviewed by:	brooks, kib
Effort:		CHERI upstreaming
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D54920
2026-02-06 10:30:50 -05:00
Andrew Turner c12d6cc326 arm64: Attach the vgic even if there is no ITS
If there is no ITS device so no memory resources the gicv3 driver would
exit attaching early. This caused the vgic driver to also not be
attached, even if it could.

Reported by:	novel@
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54791
2026-01-21 17:25:04 +00:00
Andrew Turner a4f0e93c51 arm64/vmm: Set and use the fine-grained traps
Set the Fine-grained trap registers to trap any features we don't
support. These are expected to be more useful when we support nested
virtualisation, so for now just the base features and GICv3 are not
trapped.

As nested virtualisation will require VHE we only set the fine-grained
trap registers when VHE is used.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54687
2026-02-03 17:14:44 +00:00
Andrew Turner 095a7871f4 arm64/vmm: Add HYP_FEAT_FGT{,2}
Add the macros and detection for Fine-grained traps (FEAT_FGT and
FEAT_FGT2).

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54686
2026-02-03 17:14:26 +00:00
Andrew Turner 4f82ce5191 arm64: Add the Fine-Grained Trap registers
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54685
2026-02-03 17:14:03 +00:00
Andy Carrel 93d3ac1daa arm64: Fix kernel panic in get_arm64_sve during core dump
The coredump logic calls get_arm64_sve twice: once to get the note size,
and once to get the data. The note size calculation depended on the
volatile `PCB_FP_SVEVALID` flag. If this flag was cleared between the
two calls (e.g., due to a context switch clearing the flag to comply
with the ABI), the second call would expect a smaller buffer size than
the first, triggering a KASSERT panic ("invalid size").

Fix this by ensuring the SVE state is saved to the PCB before we decide
whether to use SVE or VFP.

PR: 292195
Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D54532
2026-01-30 17:01:49 +00:00
Konstantin Belousov 377c053a43 cpu_switch(): unconditionally wait on the blocked mutex transient
It is nop for 4BSD.

Reviewed by:	olce
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54831
2026-01-29 20:11:56 +02:00
Konstantin Belousov bab24f22ba kern/sched_shim.c: Provide a scheduler selection machinery
Reviewed by:	olce
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54831
2026-01-29 20:11:55 +02:00
Mark Johnston 31e5decb18 arm64/vmm: Simplify vmmpmap_remove()
This function handles invalid intermediate PTP entries, but there's no
reason for this: the passed range should be mapped.  In particular, we
assert that all L3 entries encountered are mapped.  So let's simplify
the code a bit.  No functional change intended.

Reviewed by:	andrew
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54738
2026-01-26 22:03:51 +00:00
Mark Johnston 6740cccb1e arm64/iommu: Fix a resource leak in smmu_domain_alloc()
We should free the allocated ASID if smmu_init_cd() fails.

Move the allocation of "domain" to simplify the first error path.

Reported by:	Kevin Day <kevin@your.org>
Reviewed by:	br
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54676
2026-01-15 14:04:19 +00:00
Mark Johnston 6fef0c9ee6 arm64/vgic_v3: Fix an inverted test when reading GICD_I<C|S>ENABLER
On read, these registers' fields return 1 if forwarding of the
corresponding interrupt is enabled, and 0 otherwise.  The test in
read_enabler() was inverted.

Reported by:	Kevin Day <kevin@your.org>
Reviewed by:	andrew
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54678
2026-01-15 14:04:06 +00:00
Harry Moulton bdaa120b30 arm64: Fix MAIR_ATTR_MASK
Use the correct value when calculating the mask.

(commit message by andrew@)

Sponsored by:	Arm Ltd
2026-01-13 15:28:04 +00:00
Sarah Walker 449339bdba arm64: Provide ifunc HWCAP structure definitions
IFUNC structure is based on Section 9.4.1 "GNU C Library IFUNC interface"
from "System V ABI for the Arm 64-bit Architecture (AArch64)", 2025Q1.
(https://github.com/ARM-software/abi-aa/releases/download/2025Q1/sysvabi64.pdf)

Reviewed by:	andrew
Sponsored by:   Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54598
2026-01-13 15:28:04 +00:00
Sarah Walker 591c7a08bf arm64: Enable MOPS in userspace
Detect presence of FEAT_MOPS, and enable instruction set and set HWCAP2 flag
if present.

Add handler for MOE exceptions.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54558
2026-01-13 15:28:03 +00:00