linux/arch/arm64/kernel
Mark Rutland 8bf0a8048b arm64: add ARM64_HAS_GIC_PRIO_RELAXED_SYNC cpucap
When Priority Mask Hint Enable (PMHE) == 0b1, the GIC may use the PMR
value to determine whether to signal an IRQ to a PE, and consequently
after a change to the PMR value, a DSB SY may be required to ensure that
interrupts are signalled to a CPU in finite time. When PMHE == 0b0,
interrupts are always signalled to the relevant PE, and all masking
occurs locally, without requiring a DSB SY.

Since commit:

  f226650494 ("arm64: Relax ICC_PMR_EL1 accesses when ICC_CTLR_EL1.PMHE is clear")

... we handle this dynamically: in most cases a static key is used to
determine whether to issue a DSB SY, but the entry code must read from
ICC_CTLR_EL1 as static keys aren't accessible from plain assembly.

It would be much nicer to use an alternative instruction sequence for
the DSB, as this would avoid the need to read from ICC_CTLR_EL1 in the
entry code, and for most other code this will result in simpler code
generation with fewer instructions and fewer branches.

This patch adds a new ARM64_HAS_GIC_PRIO_RELAXED_SYNC cpucap which is
only set when ICC_CTLR_EL1.PMHE == 0b0 (and GIC priority masking is in
use). This allows us to replace the existing users of the
`gic_pmr_sync` static key with alternative sequences which default to a
DSB SY and are relaxed to a NOP when PMHE is not in use.

The entry assembly management of the PMR is slightly restructured to use
a branch (rather than multiple NOPs) when priority masking is not in
use. This is more in keeping with other alternatives in the entry
assembly, and permits the use of a separate alternatives for the
PMHE-dependent DSB SY (and removal of the conditional branch this
currently requires). For consistency I've adjusted both the save and
restore paths.

According to bloat-o-meter, when building defconfig +
CONFIG_ARM64_PSEUDO_NMI=y this shrinks the kernel text by ~4KiB:

| add/remove: 4/2 grow/shrink: 42/310 up/down: 332/-5032 (-4700)

The resulting vmlinux is ~66KiB smaller, though the resulting Image size
is unchanged due to padding and alignment:

| [mark@lakrids:~/src/linux]% ls -al vmlinux-*
| -rwxr-xr-x 1 mark mark 137508344 Jan 17 14:11 vmlinux-after
| -rwxr-xr-x 1 mark mark 137575440 Jan 17 13:49 vmlinux-before
| [mark@lakrids:~/src/linux]% ls -al Image-*
| -rw-r--r-- 1 mark mark 38777344 Jan 17 14:11 Image-after
| -rw-r--r-- 1 mark mark 38777344 Jan 17 13:49 Image-before

Prior to this patch we did not verify the state of ICC_CTLR_EL1.PMHE on
secondary CPUs. As of this patch this is verified by the cpufeature code
when using GIC priority masking (i.e. when using pseudo-NMIs).

Note that since commit:

  7e3a57fa6c ("arm64: Document ICC_CTLR_EL3.PMHE setting requirements")

... Documentation/arm64/booting.rst specifies:

|      - ICC_CTLR_EL3.PMHE (bit 6) must be set to the same value across
|        all CPUs the kernel is executing on, and must stay constant
|        for the lifetime of the kernel.

... so that should not adversely affect any compliant systems, and as
we'll only check for the absense of PMHE when using pseudo-NMIs, this
will only fire when such mismatch will adversely affect the system.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20230130145429.903791-5-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2023-01-31 16:06:17 +00:00
..
pi arm64: unwind: add asynchronous unwind tables to kernel and modules 2022-11-09 18:06:35 +00:00
probes Merge branch 'for-next/kprobes' into for-next/core 2022-12-06 11:20:21 +00:00
vdso kbuild: upgrade the orphan section warning to an error if CONFIG_WERROR is set 2022-11-01 10:04:52 -07:00
vdso32 kbuild: upgrade the orphan section warning to an error if CONFIG_WERROR is set 2022-11-01 10:04:52 -07:00
.gitignore
acpi.c arm64: Add architecture specific ACPI FFH Opregion callbacks 2022-11-14 19:09:07 +01:00
acpi_numa.c arm64: numa: Don't check node against MAX_NUMNODES 2022-07-19 19:10:28 +01:00
acpi_parking_protocol.c treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00
alternative.c arm64: alternatives: add __init/__initconst to some functions/variables 2022-12-05 13:47:06 +00:00
armv8_deprecated.c arm64: armv8_deprecated: fix unused-function error 2022-11-25 12:16:22 +00:00
asm-offsets.c ftrace: arm64: move from REGS to ARGS 2022-11-18 13:56:41 +00:00
cacheinfo.c arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level 2022-08-23 11:10:24 +01:00
compat_alignment.c arm64: compat: Implement misalignment fixups for multiword loads 2022-09-06 09:34:53 +01:00
cpu-reset.S arm64: Add types to indirect called assembly functions 2022-09-26 10:13:13 -07:00
cpu_errata.c Revert "arm64: errata: Workaround possible Cortex-A715 [ESR|FAR]_ELx corruption" 2022-12-15 17:59:12 +00:00
cpu_ops.c
cpufeature.c arm64: add ARM64_HAS_GIC_PRIO_RELAXED_SYNC cpucap 2023-01-31 16:06:17 +00:00
cpuidle.c arm64: cpuidle: remove generic cpuidle support 2022-06-23 14:19:33 +01:00
cpuinfo.c arm64/hwcap: Add support for SVE 2.1 2022-11-09 17:54:53 +00:00
crash_core.c arm64: crash_core: Export MODULES, VMALLOC, and VMEMMAP ranges 2022-03-07 21:25:47 +00:00
crash_dump.c vmcore: convert copy_oldmem_page() to take an iov_iter 2022-04-29 14:37:59 -07:00
debug-monitors.c arm64/sysreg: Add _EL1 into ID_AA64DFR0_EL1 definition names 2022-09-16 12:38:57 +01:00
efi-header.S arm64: head: tidy up the Image header definition 2020-11-17 16:14:20 +00:00
efi-rt-wrapper.S arm64: efi: Recover from synchronous exceptions occurring in firmware 2022-12-08 18:33:34 +01:00
efi.c arm64: efi: Recover from synchronous exceptions occurring in firmware 2022-12-08 18:33:34 +01:00
elfcore.c arm64: mte: Fix/clarify the PG_mte_tagged semantics 2022-11-29 09:26:07 +00:00
entry-common.c Merge branch 'for-next/undef-traps' into for-next/core 2022-12-06 11:34:25 +00:00
entry-fpsimd.S arm64/sme: Implement ZA context switching 2022-04-22 18:51:02 +01:00
entry-ftrace.S arm64 updates for 6.2 2022-12-12 09:50:05 -08:00
entry.S arm64: add ARM64_HAS_GIC_PRIO_RELAXED_SYNC cpucap 2023-01-31 16:06:17 +00:00
fpsimd.c Merge branch 'for-next/sve-state' into for-next/core 2022-12-06 11:27:28 +00:00
ftrace.c ftrace: arm64: remove static ftrace 2022-11-25 12:11:50 +00:00
head.S arm64: implement dynamic shadow call stack for Clang 2022-11-09 18:06:35 +00:00
hibernate-asm.S arm64: kexec: install a copy of the linear-map 2021-10-01 13:31:00 +01:00
hibernate.c arm64: mte: Fix/clarify the PG_mte_tagged semantics 2022-11-29 09:26:07 +00:00
hw_breakpoint.c arm64: Treat ESR_ELx as a 64-bit register 2022-04-29 19:26:27 +01:00
hyp-stub.S arm64/sysreg: Standardise naming for ID_AA64MMFR1_EL1 fields 2022-09-09 10:59:03 +01:00
idle.c Merge branch 'for-next/entry' into for-next/core 2021-06-24 14:01:55 +01:00
idreg-override.c arm64/sysreg: Standardise naming for ID_AA64MMFR1_EL1 fields 2022-09-09 10:59:03 +01:00
image-vars.h arm64: add ARM64_HAS_GIC_PRIO_RELAXED_SYNC cpucap 2023-01-31 16:06:17 +00:00
image.h arm64: get rid of TEXT_OFFSET 2020-09-07 15:00:52 +01:00
io.c
irq.c Merge branch 'for-next/stacks' into for-next/core 2022-12-06 11:26:40 +00:00
jump_label.c jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
kaslr.c random: handle archrandom with multiple longs 2022-07-25 13:26:14 +02:00
kexec_image.c arm64: kexec_file: use more system keyrings to verify kernel image signature 2022-07-15 12:21:16 -04:00
kgdb.c arm64: Treat ESR_ELx as a 64-bit register 2022-04-29 19:26:27 +01:00
kuser32.S arm64: compat: Move kuser32.S to .rodata section 2022-06-23 16:01:42 +01:00
machine_kexec.c treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00
machine_kexec_file.c arm64/kexec: Fix missing extra range for crashkres_low. 2022-09-01 11:50:00 +01:00
Makefile EFI updates for v6.2: 2022-12-13 14:31:47 -08:00
module-plts.c arm64: module: Make plt_equals_entry() static 2022-09-29 17:47:18 +01:00
module.c Merge branch 'for-next/ftrace' into for-next/core 2022-12-06 11:07:39 +00:00
mte.c arm64: mte: Lock a page for MTE tag initialisation 2022-11-29 09:26:07 +00:00
paravirt.c arm64: paravirt: remove conduit check in has_pv_steal_clock 2022-11-09 18:11:56 +00:00
patch-scs.c arm64: implement dynamic shadow call stack for Clang 2022-11-09 18:06:35 +00:00
patching.c arm64: patch_text: Fixup last cpu should be master 2022-04-08 11:43:46 +01:00
pci.c arm64: PCI: Support root bridge preparation for Hyper-V 2021-08-23 10:59:26 +01:00
perf_callchain.c Peter Zijlstra says: 2022-01-12 16:26:58 -08:00
perf_event.c Perf events updates for v6.2: 2022-12-12 15:19:38 -08:00
perf_regs.c perf: arm64: Add SVE vector granule register to user regs 2022-09-22 15:06:02 +01:00
pointer_auth.c arm64: move preemption disablement to prctl handlers 2021-07-28 18:33:49 +01:00
process.c Random number generator updates for Linux 6.2-rc1. 2022-12-12 16:22:22 -08:00
proton-pack.c arm64: factor out EL1 SSBS emulation hook 2022-11-15 13:46:18 +00:00
psci.c treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00
ptrace.c Non-MM patches for 6.2-rc1. 2022-12-12 17:28:58 -08:00
reloc_test_core.c ARM64: reloc_test: add __init/__exit annotations to module init/exit funcs 2022-09-29 18:04:25 +01:00
reloc_test_syms.S
relocate_kernel.S arm64: kexec: load from kimage prior to clobbering 2022-05-17 14:25:35 +01:00
return_address.c arm64: Make return_address() use arch_stack_walk() 2021-12-10 14:06:04 +00:00
sdei.c arm64: implement dynamic shadow call stack for Clang 2022-11-09 18:06:35 +00:00
setup.c arm64: implement dynamic shadow call stack for Clang 2022-11-09 18:06:35 +00:00
signal.c arm64/fpsimd: Track the saved FPSIMD state type separately to TIF_SVE 2022-11-29 15:01:56 +00:00
signal32.c signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-04-22 12:14:05 +02:00
sigreturn32.S arm64: compat: Move sigreturn32.S to .rodata section 2022-07-01 12:05:45 +01:00
sleep.S arm64: mm: fix resume for 52-bit enabled builds 2022-09-10 14:46:28 +01:00
smccc-call.S arm64: smccc: Save lr before calling __arm_smccc_sve_check() 2021-07-21 11:23:25 +01:00
smp.c profile: setup_profiling_timer() is moslty not implemented 2022-07-29 18:12:36 -07:00
smp_spin_table.c treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00
stacktrace.c arm64: Prohibit instrumentation on arch_stack_walk() 2022-12-05 14:20:08 +00:00
suspend.c arm64: Enable data independent timing (DIT) in the kernel 2022-11-08 14:55:10 +00:00
sys.c
sys32.c
sys_compat.c arm64: compat: Do not treat syscall number as ESR_ELx for a bad syscall 2022-04-29 19:26:27 +01:00
syscall.c arm64/sve: Leave SVE enabled on syscall if we don't context switch 2022-11-29 15:01:56 +00:00
time.c arm64: Make profile_pc() use arch_stack_walk() 2021-12-10 14:06:04 +00:00
topology.c RISC-V Patches for the 6.1 Merge Window, Part 1 2022-10-09 13:24:01 -07:00
trace-events-emulation.h
traps.c arm64: armv8_deprecated: rework deprected instruction handling 2022-11-15 13:46:19 +00:00
vdso-wrap.S arm64: do not descend to vdso directories twice 2021-01-20 12:18:46 +00:00
vdso.c vdso/timens: Refactor copy-pasted find_timens_vvar_page() helper into one copy 2022-12-01 11:35:40 +01:00
vdso32-wrap.S arm64: do not descend to vdso directories twice 2021-01-20 12:18:46 +00:00
vmlinux.lds.S arm64: unwind: add asynchronous unwind tables to kernel and modules 2022-11-09 18:06:35 +00:00