OrangePi_CM5/arch/arm64/include/asm
Peter Collingbourne 50829b8901 BACKPORT: arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS)
This change introduces a prctl that allows the user program to control
which PAC keys are enabled in a particular task. The main reason
why this is useful is to enable a userspace ABI that uses PAC to
sign and authenticate function pointers and other pointers exposed
outside of the function, while still allowing binaries conforming
to the ABI to interoperate with legacy binaries that do not sign or
authenticate pointers.

The idea is that a dynamic loader or early startup code would issue
this prctl very early after establishing that a process may load legacy
binaries, but before executing any PAC instructions.

This change adds a small amount of overhead to kernel entry and exit
due to additional required instruction sequences.

On a DragonBoard 845c (Cortex-A75) with the powersave governor, the
overhead of similar instruction sequences was measured as 4.9ns when
simulating the common case where IA is left enabled, or 43.7ns when
simulating the uncommon case where IA is disabled. These numbers can
be seen as the worst case scenario, since in more realistic scenarios
a better performing governor would be used and a newer chip would be
used that would support PAC unlike Cortex-A75 and would be expected
to be faster than Cortex-A75.

On an Apple M1 under a hypervisor, the overhead of the entry/exit
instruction sequences introduced by this patch was measured as 0.3ns
in the case where IA is left enabled, and 33.0ns in the case where
IA is disabled.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Link: https://linux-review.googlesource.com/id/Ibc41a5e6a76b275efbaa126b31119dc197b927a5
Link: https://lore.kernel.org/r/d6609065f8f40397a4124654eb68c9f490b4d477.1616123271.git.pcc@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 192536783
(cherry picked from commit 201698626fbca1cf1a3b686ba14cf2a056500716)
Change-Id: Ic0a21c92a22575f9ec3599fb67bd2931a50b9f04
[quic_eberman@quicinc.com: Resolved merge conflict in
 arch/arm64/kernel/process.c]
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Peter Collingbourne <pcc@google.com>
2021-07-14 20:52:05 -07:00
..
vdso vdso/treewide: Add vdso_data pointer argument to __arch_get_hw_counter() 2020-08-06 10:57:30 +02:00
xen xen/arm: do not setup the runstate info page if kpti is enabled 2020-10-04 18:41:33 -05:00
Kbuild local64.h: make <asm/local64.h> mandatory 2021-01-12 20:18:16 +01:00
acenv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
acpi.h arm64/acpi: disallow AML memory opregions to access kernel memory 2020-07-14 18:02:03 +01:00
alternative-macros.h ANDROID: arm64: only permit certain alternatives in the FIPS140 module 2021-06-11 07:49:57 +00:00
alternative.h arm64: alternatives: Move length validation in alternative_{insn, endif} 2021-04-21 13:00:55 +02:00
arch_gicv3.h irqchip/gic-v3: Support pseudo-NMIs when SCR_EL3.FIQ == 0 2020-09-13 17:52:04 +01:00
arch_timer.h arm64: arch_timer: Allow an workaround descriptor to disable compat vdso 2020-07-08 21:57:51 +01:00
archrandom.h arm64: random: Remove no longer needed prototypes 2020-10-07 14:17:20 +01:00
arm-cci.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
arm_dsu_pmu.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
asm-bug.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
asm-offsets.h
…
asm-prototypes.h
…
asm-uaccess.h UPSTREAM: arm64: uaccess: split user/kernel routines 2021-04-23 17:52:37 +02:00
asm_pointer_auth.h arm64: simplify ptrauth initialization 2020-04-28 11:23:21 +01:00
assembler.h BACKPORT: arm64: fpsimd: run kernel mode NEON with softirqs disabled 2021-05-13 07:53:33 +00:00
atomic.h arm64: make atomic helpers __always_inline 2021-01-27 11:55:00 +01:00
atomic_ll_sc.h arm64: Move the LSE gas support detection to Kconfig 2020-01-15 12:50:48 +00:00
atomic_lse.h arm64: lse: fix LSE atomics with LLVM's integrated assembler 2020-01-16 17:25:10 +00:00
barrier.h FROMLIST: arm64: Add support for trace synchronization barrier 2021-03-01 12:52:14 -08:00
bitops.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
bitrev.h
…
boot.h arm64: get rid of TEXT_OFFSET 2020-09-07 15:00:52 +01:00
brk-imm.h arm64: kprobes: Use BRK instead of single-step when executing instructions out-of-line 2020-11-03 14:03:38 +00:00
bug.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
cache.h FROMGIT: arm64: kasan: simplify and inline MTE functions 2021-02-16 15:33:32 +01:00
cacheflush.h arm64: use asm-generic/cacheflush.h 2020-06-08 11:05:57 -07:00
checksum.h arm64: csum: Fix handling of bad packets 2020-07-30 17:01:38 +01:00
clocksource.h arm64: Introduce asm/vdso/clocksource.h 2020-03-21 15:23:55 +01:00
cmpxchg.h arm64: fix unreachable code issue with cmpxchg 2019-09-17 12:11:50 +01:00
compat.h compat: lift compat_s64 and compat_u64 to <asm-generic/compat.h> 2020-09-17 13:00:46 -04:00
compiler.h arm64: use a common .arch preamble for inline assembly 2020-08-28 11:15:15 +01:00
cpu.h FROMLIST: arm64: cpuinfo: Split AArch32 registers out into a separate struct 2021-02-05 09:20:52 +00:00
cpu_ops.h arm64: fix some spelling mistakes in the comments by codespell 2020-09-07 14:18:50 +01:00
cpucaps.h ANDROID: GKI: arm64: reserve space in cpu_hwcaps and cpu_hwcap_keys arrays 2021-04-23 18:42:37 -07:00
cpufeature.h FROMGIT: KVM: arm64: Drop the CPU_FTR_REG_HYP_COPY infrastructure 2021-03-31 08:23:28 +00:00
cpuidle.h
…
cputype.h arm64: Add MIDR value for KRYO2XX gold/silver CPU cores 2020-11-13 09:47:08 +00:00
current.h
…
daifflags.h arm64: entry: always set GIC_PRIO_PSR_I_SET during entry 2021-05-19 10:13:07 +02:00
dcc.h
…
debug-monitors.h arm64: kprobes: Use BRK instead of single-step when executing instructions out-of-line 2020-11-03 14:03:38 +00:00
device.h arm64: Remove dev->archdata.iommu pointer 2020-06-30 11:59:49 +02:00
dmi.h
…
efi.h efi/libstub: arm32: Base FDT and initrd placement on image address 2020-09-16 18:53:42 +03:00
el2_setup.h FROMLIST: arm64: kvm: Enable access to TRBE support for host 2021-03-01 12:52:14 -08:00
elf.h Split the old READ_IMPLIES_EXEC workaround from executable PT_GNU_STACK 2020-06-05 13:45:21 -07:00
esr.h UPSTREAM: arm64: mte: add in-kernel MTE helpers 2021-01-19 21:47:29 -08:00
exception.h BACKPORT: arm64: expose FAR_EL1 tag bits in siginfo 2021-01-22 10:09:05 -08:00
exec.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
extable.h arm64: Improve diagnostics when trapping BRK with FAULT_BRK_IMM 2020-09-18 16:35:54 +01:00
fb.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
fixmap.h arm64/fixmap: make notes of fixed_addresses more precisely 2020-08-08 19:25:04 +01:00
fpsimd.h FROMGIT: arm64: sve: Provide a conditional update accessor for ZCR_ELx 2021-03-19 08:20:11 +00:00
fpsimdmacros.h BACKPORT: FROMGIT: KVM: arm64: Rework SVE host-save/guest-restore 2021-03-19 08:20:43 +00:00
ftrace.h arm64: implement ftrace with regs 2019-11-06 14:17:35 +00:00
futex.h BACKPORT: arm64: uaccess: rename privileged uaccess routines 2021-04-23 17:52:37 +02:00
hardirq.h FROMGIT: arm64: Remove custom IRQ stat accounting 2020-10-01 11:07:44 -07:00
hugetlb.h arm64/hugetlb: Reserve CMA areas for gigantic pages on 16K and 64K configs 2020-07-15 13:38:03 +01:00
hw_breakpoint.h arm64: remove pointless __KERNEL__ guards 2019-08-05 11:06:33 +01:00
hwcap.h Merge branch 'for-next/mte' into for-next/core 2020-10-02 12:16:11 +01:00
hyp_image.h FROMLIST: KVM: arm64: Allow using kvm_nvhe_sym() in hyp code 2021-03-17 18:48:49 +00:00
hypervisor.h
…
image.h
…
insn.h UPSTREAM: arm64: alternatives: Split up alternative.h 2021-01-29 08:41:02 +00:00
io.h ANDROID: tracing: Add register read and write tracing support 2021-01-11 16:43:50 +00:00
irq.h
…
irq_work.h FROMGIT: arm64: Kill __smp_cross_call and co 2020-10-01 11:07:44 -07:00
irqflags.h arm64: Implement arch_irqs_disabled() 2020-08-26 12:41:55 +02:00
jump_label.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
kasan.h FROMGIT: arm64: kasan: simplify and inline MTE functions 2021-02-16 15:33:32 +01:00
kernel-pgtable.h arm64: get rid of TEXT_OFFSET 2020-09-07 15:00:52 +01:00
kexec.h Revert "arm64: kexec: make dtb_mem always enabled" 2020-01-10 16:00:50 +00:00
kfence.h FROMGIT: kfence: use pt_regs to generate stack trace on faults 2021-02-05 09:20:53 -08:00
kgdb.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
kprobes.h arm64: kprobes: Use BRK instead of single-step when executing instructions out-of-line 2020-11-03 14:03:38 +00:00
kvm_arm.h KVM: arm64: Disable guest access to trace filter controls 2021-04-16 11:43:19 +02:00
kvm_asm.h FROMLIST: KVM: arm64: Protect the .hyp sections from the host 2021-03-17 18:48:52 +00:00
kvm_emulate.h Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
kvm_host.h BACKPORT: arm64: KVM: Enable access to TRBE support for host 2021-06-23 22:47:56 +00:00
kvm_hyp.h FROMGIT: KVM: arm64: Drop the CPU_FTR_REG_HYP_COPY infrastructure 2021-03-31 08:23:28 +00:00
kvm_mmu.h FROMLIST: KVM: arm64: Refactor __load_guest_stage2() 2021-03-17 18:48:50 +00:00
kvm_pgtable.h ANDROID: KVM: arm64: Sync with upstream host stage 2 series 2021-03-31 08:23:11 +00:00
kvm_ptrauth.h KVM: arm64: Update context references from host to hyp 2020-09-15 18:39:02 +01:00
kvm_ras.h
…
kvm_types.h KVM: arm64: Use common KVM implementation of MMU memory caches 2020-07-09 13:29:43 -04:00
linkage.h arm64: Don't insert a BTI instruction at inner labels 2020-06-24 14:24:29 +01:00
lse.h ANDROID: arm64: disable LSE when building the FIPS140 module 2021-07-13 21:37:35 +00:00
memory.h FROMGIT: kasan, arm64: tests supports for HW_TAGS async mode 2021-04-27 10:40:13 +02:00
mman.h arm64: mte: Validate the PROT_MTE request via arch_validate_flags() 2020-09-04 12:46:07 +01:00
mmu.h UPSTREAM: KVM: arm64: Move BP hardening helpers into spectre.h 2021-01-28 17:57:07 +00:00
mmu_context.h This is the 5.10.24 stable release 2021-03-19 09:42:56 +01:00
mmzone.h
…
module.h ANDROID: arm64: module: add RELA metadata for FIPS140 use 2021-05-07 07:12:43 -07:00
module.lds.h ANDROID: crypto: fips140 - perform load time integrity check 2021-06-11 07:49:58 +00:00
mte-def.h FROMGIT: arm64: kasan: simplify and inline MTE functions 2021-02-16 15:33:32 +01:00
mte-kasan.h FROMGIT: kasan: speed up mte_set_mem_tag_range 2021-06-01 17:29:32 +00:00
mte.h BACKPORT: arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) 2021-07-14 20:52:05 -07:00
neon-intrinsics.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
neon.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
numa.h arm64/mm: return cpu_all_mask when node is NUMA_NO_NODE 2020-09-21 22:05:01 +01:00
page-def.h arm64/mm: Unify CONT_PTE_SHIFT 2020-09-11 16:33:43 +01:00
page.h BACKPORT: FROMGIT: arm64: mte: handle tags zeroing at page allocation time 2021-06-17 14:39:37 -07:00
paravirt.h arm64: Retrieve stolen time as paravirtualized guest 2019-10-21 19:20:31 +01:00
pci.h arm64: Enable PCI write-combine resources under sysfs 2020-09-18 14:05:13 +01:00
percpu.h UPSTREAM: KVM: arm64: Support per_cpu_ptr in nVHE hyp code 2021-01-28 17:57:13 +00:00
perf_event.h arm64: perf: Add support caps under sysfs 2020-09-28 14:53:45 +01:00
pgalloc.h asm-generic: pgalloc: provide generic pgd_free() 2020-08-07 11:33:26 -07:00
pgtable-hwdef.h UPSTREAM: kasan: arm64: set TCR_EL1.TBID1 when enabled 2021-01-19 21:47:26 -08:00
pgtable-prot.h FROMLIST: KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB Stage-2 flag 2021-03-17 18:48:52 +00:00
pgtable-types.h arm64: add support for folded p4d page tables 2020-06-04 19:06:21 -07:00
pgtable.h arm64: mte: Map hotplugged memory as Normal Tagged 2021-03-17 17:06:28 +01:00
pointer_auth.h BACKPORT: arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) 2021-07-14 20:52:05 -07:00
preempt.h sched/rt, arm64: Use CONFIG_PREEMPTION 2019-12-08 14:37:32 +01:00
probes.h arm64/fpsimd: add <asm/insn.h> to <asm/kprobes.h> to fix fpsimd build 2020-11-23 10:59:00 +00:00
proc-fns.h arm64: mm: convert cpu_do_switch_mm() to C 2020-02-27 14:30:50 +00:00
processor.h BACKPORT: arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) 2021-07-14 20:52:05 -07:00
ptdump.h arm64: mm: convert mm/dump.c to use walk_page_range() 2020-02-04 03:05:25 +00:00
ptrace.h UPSTREAM: arm64: head.S: always initialize PSTATE 2021-01-28 17:57:11 +00:00
pvclock-abi.h KVM: arm64: Implement PV_TIME_FEATURES call 2019-10-21 19:20:27 +01:00
rwonce.h UPSTREAM: arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y 2021-01-29 08:41:03 +00:00
scs.h Revert "FROMLIST: arm64: implement Shadow Call Stack" 2020-06-09 12:45:25 +01:00
sdei.h
…
seccomp.h UPSTREAM: arm64: Enable seccomp architecture tracking 2020-12-21 18:47:22 +00:00
sections.h FROMLIST: KVM: arm64: Introduce a BSS section for use at Hyp 2021-03-17 18:48:48 +00:00
setup.h FROMGIT: arm64: Extract early FDT mapping from kaslr_early_init() 2021-02-12 15:27:46 +00:00
shmparam.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
signal.h BACKPORT: arm64: expose FAR_EL1 tag bits in siginfo 2021-01-22 10:09:05 -08:00
signal32.h arm64: remove pointless __KERNEL__ guards 2019-08-05 11:06:33 +01:00
simd.h ANDROID: arm64: simd: omit capability check in may_use_simd() 2021-06-11 07:49:58 +00:00
smp.h ANDROID: ipi: Add function to return nr_ipi and ipi_desc 2021-02-01 16:46:43 +00:00
smp_plat.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
sparsemem.h FROMLIST: arm64: reduce section size for sparsemem 2021-01-12 21:55:15 +00:00
spectre.h UPSTREAM: arm64: Make the Meltdown mitigation state available 2021-01-28 17:57:10 +00:00
spinlock.h arm64/spinlock: fix a -Wunused-function warning 2020-02-10 11:29:24 +00:00
spinlock_types.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
stack_pointer.h
…
stackprotector.h FROMGIT: arm64: Defer enabling pointer authentication on boot core 2021-02-12 15:27:47 +00:00
stacktrace.h arm64: stacktrace: Make stack walk callback consistent with generic code 2020-09-18 14:24:16 +01:00
stage2_pgtable.h KVM: arm64: Remove unused page-table code 2020-09-11 15:51:15 +01:00
stat.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
string.h BACKPORT: kasan, arm64: expand CONFIG_KASAN checks 2021-01-19 21:47:30 -08:00
suspend.h Revert "FROMLIST: arm64: preserve x18 when CPU is suspended" 2020-06-09 12:53:28 +01:00
sync_bitops.h
…
syscall.h arm64: compat: Ensure upper 32 bits of x0 are zero on syscall return 2020-07-16 11:41:31 +01:00
syscall_wrapper.h arm64: simplify syscall wrapper ifdeffery 2019-10-14 10:55:00 +01:00
sysreg.h BACKPORT: arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS) 2021-07-14 20:52:05 -07:00
system_misc.h BACKPORT: arm64: expose FAR_EL1 tag bits in siginfo 2021-01-22 10:09:05 -08:00
thread_info.h Revert "ANDROID: arm64: Add support for asymmetric AArch32 EL0 configurations" 2021-02-05 09:20:51 +00:00
timex.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
tlb.h arm64: tlb: Set the TTL field in flush_tlb_range 2020-07-07 11:23:47 +01:00
tlbflush.h arm64: use a common .arch preamble for inline assembly 2020-08-28 11:15:15 +01:00
topology.h cpufreq,arm,arm64: restructure definitions of arch_set_freq_scale() 2020-10-08 17:17:27 +02:00
traps.h BACKPORT: arm64: expose FAR_EL1 tag bits in siginfo 2021-01-22 10:09:05 -08:00
uaccess.h FROMGIT: arm64: mte: Enable TCO in functions that can read beyond buffer limits 2021-04-26 18:40:43 +02:00
unistd.h mm/madvise: introduce process_madvise() syscall: an external memory hinting API 2020-10-18 09:27:10 -07:00
unistd32.h Revert "Revert "mm: remove compat_process_vm_{readv,writev}"" 2020-11-02 09:27:42 +01:00
uprobes.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
vdso.h arm64/vdso: Add time namespace page 2020-07-24 13:15:20 +01:00
vermagic.h arch: split MODULE_ARCH_VERMAGIC definitions out to <asm/vermagic.h> 2020-04-23 10:50:26 +09:00
virt.h FROMGIT: arm64: Provide an 'upgrade to VHE' stub hypercall 2021-02-12 15:27:45 +00:00
vmalloc.h mm/vmalloc: Add empty <asm/vmalloc.h> headers and use them from <linux/vmalloc.h> 2019-12-10 10:12:55 +01:00
vmap_stack.h mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
word-at-a-time.h FROMGIT: arm64: mte: Enable TCO in functions that can read beyond buffer limits 2021-04-26 18:40:43 +02:00
xor.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00