linux/arch/arm64/include/asm
Will Deacon 9766921494 arm64: sme: Use STR P to clear FFR context field in streaming SVE mode
[ Upstream commit 893b24181b ]

The FFR is a predicate register which can vary between 16 and 256 bits
in size depending upon the configured vector length. When saving the
SVE state in streaming SVE mode, the FFR register is inaccessible and
so commit 9f58486657 ("arm64/sve: Make access to FFR optional") simply
clears the FFR field of the in-memory context structure. Unfortunately,
it achieves this using an unconditional 8-byte store and so if the SME
vector length is anything other than 64 bytes in size we will either
fail to clear the entire field or, worse, we will corrupt memory
immediately following the structure. This has led to intermittent kfence
splats in CI [1] and can trigger kmalloc Redzone corruption messages
when running the 'fp-stress' kselftest:

 | =============================================================================
 | BUG kmalloc-1k (Not tainted): kmalloc Redzone overwritten
 | -----------------------------------------------------------------------------
 |
 | 0xffff000809bf1e22-0xffff000809bf1e27 @offset=7714. First byte 0x0 instead of 0xcc
 | Allocated in do_sme_acc+0x9c/0x220 age=2613 cpu=1 pid=531
 |  __kmalloc+0x8c/0xcc
 |  do_sme_acc+0x9c/0x220
 |  ...

Replace the 8-byte store with a store of a predicate register which has
been zero-initialised with PFALSE, ensuring that the entire field is
cleared in memory.

[1] https://lore.kernel.org/r/CA+G9fYtU7HsV0R0dp4XEH5xXHSJFw8KyDf5VQrLLfMxWfxQkag@mail.gmail.com

Cc: Mark Brown <broonie@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Fixes: 9f58486657 ("arm64/sve: Make access to FFR optional")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Link: https://lore.kernel.org/r/20230628155605.22296-1-will@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-19 16:21:45 +02:00
..
stacktrace arm64: stacktrace: track hyp stacks in unwinder's address space 2022-09-09 12:30:08 +01:00
vdso arm64: vdso: use SYS_CNTVCTSS_EL0 for gettimeofday 2022-09-09 12:27:25 +01:00
xen arm/xen: Introduce xen_setup_dma_ops() 2022-06-06 08:54:33 +02:00
acenv.h
acpi.h
alternative-macros.h arm64: alternatives: Use vdso/bits.h instead of linux/bits.h 2022-10-05 10:44:44 +01:00
alternative.h
apple_m1_pmu.h
arch_gicv3.h irqchip/gic-v3: Refactor ISB + EOIR at ack time 2022-05-15 16:38:25 +01:00
arch_timer.h
archrandom.h random: handle archrandom with multiple longs 2022-07-25 13:26:14 +02:00
arm_dsu_pmu.h
arm-cci.h
asm_pointer_auth.h arm64/sysreg: Add _EL1 into ID_AA64ISAR2_EL1 definition names 2022-07-05 11:45:46 +01:00
asm-bug.h bug: Use normal relative pointers in 'struct bug_entry' 2022-05-19 23:46:10 +02:00
asm-extable.h arm64: extable: cleanup redundant extable type EX_TYPE_FIXUP 2022-06-28 12:11:47 +01:00
asm-offsets.h
asm-prototypes.h
asm-uaccess.h arm64: extable: make uaaccess helper use extable type EX_TYPE_UACCESS_ERR_ZERO 2022-06-28 12:11:47 +01:00
assembler.h Merge branch 'for-next/alternatives' into for-next/core 2022-09-30 09:18:22 +01:00
atomic_ll_sc.h arm64: cmpxchg_double*: hazard against entire exchange variable 2023-01-18 11:58:11 +01:00
atomic_lse.h arm64: cmpxchg_double*: hazard against entire exchange variable 2023-01-18 11:58:11 +01:00
atomic.h
barrier.h arm64: kcsan: Support detecting more missing memory barriers 2022-06-23 18:34:59 +01:00
bitops.h
bitrev.h
boot.h
brk-imm.h arm64: Add CFI error handling 2022-09-26 10:13:14 -07:00
bug.h
cache.h arm64: cache: Remove unused CTR_CACHE_MINLINE_MASK 2022-09-09 10:59:02 +01:00
cacheflush.h arm64: mm: Remove assembly DMA cache maintenance wrappers 2022-07-05 13:06:31 +01:00
checksum.h
clocksource.h
cmpxchg.h
compat.h asm-generic: compat: Cleanup duplicate definitions 2022-04-26 13:35:54 -07:00
compiler.h cfi: Use __builtin_function_start 2022-04-13 12:16:00 -07:00
cpu_ops.h arm64: cpuidle: remove generic cpuidle support 2022-06-23 14:19:33 +01:00
cpu.h arm64/sme: Expose SMIDR through sysfs 2022-06-23 18:22:44 +01:00
cpufeature.h Merge branch 'for-next/alternatives' into for-next/core 2022-09-30 09:18:22 +01:00
cpuidle.h arm64: cpuidle: remove generic cpuidle support 2022-06-23 14:19:33 +01:00
cputype.h arm64: Fix bit-shifting UB in the MIDR_CPU_MODEL() macro 2022-11-09 09:51:39 +00:00
current.h
daifflags.h
dcc.h
debug-monitors.h arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step 2023-05-11 23:03:16 +09:00
device.h
dmi.h
efi.h arm64: efi: Make efi_rt_lock a raw_spinlock 2023-03-11 13:55:43 +01:00
el2_setup.h arm64/sysreg: Add _EL1 into ID_AA64DFR0_EL1 definition names 2022-09-16 12:38:57 +01:00
elf.h
esr.h S390: 2022-05-26 14:20:14 -07:00
exception.h Merge branch 'for-next/misc' into for-next/core 2022-09-30 09:18:26 +01:00
exec.h
extable.h
fb.h
fixmap.h arm64: entry: simplify trampoline data page 2022-06-24 13:08:30 +01:00
fpsimd.h arm64/sme: Don't flush SVE register state when allocating SME storage 2022-08-23 11:29:11 +01:00
fpsimdmacros.h arm64: sme: Use STR P to clear FFR context field in streaming SVE mode 2023-07-19 16:21:45 +02:00
ftrace.h treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00
futex.h
gpr-num.h
hardirq.h
hugetlb.h mm: hugetlb: kill set_huge_swap_pte_at() 2022-07-03 18:08:50 -07:00
hw_breakpoint.h arm64/sysreg: Add _EL1 into ID_AA64DFR0_EL1 definition names 2022-09-16 12:38:57 +01:00
hwcap.h arm64/sysreg: Add hwcap for SVE EBF16 2022-09-06 18:53:52 +01:00
hyp_image.h
hyperv-tlfs.h
hypervisor.h
image.h
insn-def.h
insn.h arm64: Add LDR (literal) instruction 2022-07-11 21:04:58 +02:00
io.h asm-generic: updates for 6.0 2022-08-05 10:07:23 -07:00
irq_work.h
irq.h
irqflags.h
jump_label.h
kasan.h
Kbuild arm64/sysreg: Enable automatic generation of system register definitions 2022-05-04 15:30:28 +01:00
kernel-pgtable.h arm64: mm: Reserve enough pages for the initial ID map 2022-09-01 12:02:39 +01:00
kexec.h kexec: drop weak attribute from functions 2022-07-15 12:21:16 -04:00
kfence.h
kgdb.h
kprobes.h
kvm_arm.h Merge branch kvm-arm64/aarch32-idreg-trap into kvmarm-master/next 2022-05-04 09:42:45 +01:00
kvm_asm.h KVM: arm64: Prepare non-protected nVHE hypervisor stacktrace 2022-07-26 10:49:27 +01:00
kvm_emulate.h KVM: arm64: Fix S1PTW handling on RO memslots 2023-01-18 11:58:10 +01:00
kvm_host.h KVM: arm64: Avoid lock inversion when setting the VM register width 2023-05-11 23:03:03 +09:00
kvm_hyp.h
kvm_mmu.h arm64: alternatives: have callbacks take a cap 2022-09-16 17:15:03 +01:00
kvm_mte.h
kvm_pgtable.h KVM: arm64: Work out supported block level at compile time 2022-10-09 02:33:49 +01:00
kvm_pkvm.h
kvm_ptrauth.h
kvm_ras.h KVM: arm64: Treat ESR_EL2 as a 64-bit register 2022-04-29 19:26:27 +01:00
kvm_types.h
linkage.h arm64: Add types to indirect called assembly functions 2022-09-26 10:13:13 -07:00
lse.h arm64: alternatives: add alternative_has_feature_*() 2022-09-16 17:15:03 +01:00
memory.h - The usual batches of cleanups from Baoquan He, Muchun Song, Miaohe 2022-08-05 16:32:45 -07:00
mman.h arm64/mm: enable ARCH_HAS_VM_GET_PAGE_PROT 2022-04-28 23:16:13 -07:00
mmu_context.h treewide: Drop function_nocfi 2022-09-26 10:13:14 -07:00
mmu.h
mmzone.h
module.h Merge branches 'for-next/doc', 'for-next/sve', 'for-next/sysreg', 'for-next/gettimeofday', 'for-next/stacktrace', 'for-next/atomics', 'for-next/el1-exceptions', 'for-next/a510-erratum-2658417', 'for-next/defconfig', 'for-next/tpidr2_el0' and 'for-next/ftrace', remote-tracking branch 'arm64/for-next/perf' into for-next/core 2022-09-30 09:17:57 +01:00
module.lds.h
mshyperv.h
mte-def.h
mte-kasan.h printk: stop including cache.h from printk.h 2022-05-13 07:20:07 -07:00
mte.h arm64: mte: Fix/clarify the PG_mte_tagged semantics 2023-03-11 13:55:44 +01:00
neon-intrinsics.h
neon.h
numa.h
page-def.h
page.h
paravirt_api_clock.h
paravirt.h
patching.h
pci.h asm-generic: Add new pci.h and use it 2022-07-22 17:34:57 -05:00
percpu.h printk: stop including cache.h from printk.h 2022-05-13 07:20:07 -07:00
perf_event.h
pgalloc.h
pgtable-hwdef.h arm64/mm: use GENMASK_ULL for TTBR_BADDR_MASK_52 2022-07-19 19:29:04 +01:00
pgtable-prot.h arm64/mm: move protection_map[] inside the platform 2022-07-17 17:14:37 -07:00
pgtable-types.h
pgtable.h arm64: mte: Fix/clarify the PG_mte_tagged semantics 2023-03-11 13:55:44 +01:00
pointer_auth.h
preempt.h
probes.h
proc-fns.h
processor.h arm64: make is_ttbrX_addr() noinstr-safe 2022-12-31 13:32:56 +01:00
ptdump.h
ptrace.h
pvclock-abi.h
rwonce.h
scs.h arm64: Always load shadow stack pointer directly from the task struct 2023-05-11 23:02:59 +09:00
sdei.h arm64: stacktrace: move SDEI stack helpers to stacktrace code 2022-09-09 12:30:07 +01:00
seccomp.h
sections.h
set_memory.h
setup.h arm64: fix rodata=full 2022-08-23 11:02:02 +01:00
shmparam.h
signal.h
signal32.h
simd.h
smp_plat.h
smp.h
sparsemem.h
spectre.h Merge branch 'for-next/spectre-bhb' into for-next/core 2022-03-14 19:08:31 +00:00
spinlock_types.h
spinlock.h
stack_pointer.h
stackprotector.h
stacktrace.h arm64: efi: Account for the EFI runtime stack in stack unwinder 2023-02-01 08:34:35 +01:00
stage2_pgtable.h KVM: arm64: Limit stage2_apply_range() batch size to largest block 2022-10-09 02:33:49 +01:00
stat.h
string.h
suspend.h
sync_bitops.h
syscall_wrapper.h arm64/syscall: Include asm/ptrace.h in syscall_wrapper header. 2022-11-09 09:52:25 +00:00
syscall.h
sysreg.h arm64: Add missing Set/Way CMO encodings 2023-06-28 11:12:35 +02:00
system_misc.h arm64: die(): pass 'err' as long 2022-09-16 12:17:03 +01:00
thread_info.h arm64/sme: Implement SVCR context switching 2022-04-22 18:50:58 +01:00
timex.h
tlb.h
tlbflush.h
topology.h
trans_pgd.h
traps.h arm64: Treat ESR_ELx as a 64-bit register 2022-04-29 19:26:27 +01:00
uaccess.h arm64: uaccess: simplify uaccess_mask_ptr() 2022-09-23 14:39:20 +01:00
unistd.h fs: stat: compat: Add __ARCH_WANT_COMPAT_STAT 2022-04-26 13:35:45 -07:00
unistd32.h
uprobes.h
vdso.h arm64: alternative: patch alternatives in the vDSO 2022-09-09 12:27:25 +01:00
vectors.h arm64: fix clang warning about TRAMP_VALIAS 2022-03-18 13:48:28 +00:00
vermagic.h
virt.h arm64: Save state of HCR_EL2.E2H before switch to EL1 2022-07-01 15:22:51 +01:00
vmalloc.h kasan, vmalloc, arm64: mark vmalloc mappings as pgprot_tagged 2022-03-24 19:06:47 -07:00
vmap_stack.h kasan, arm64: reset pointer tags of vmapped stacks 2022-03-24 19:06:47 -07:00
word-at-a-time.h
xor.h