acrn-kernel/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
vdso
xen
Kbuild
acenv.h
acpi.h
alternative-macros.h
alternative.h
apple_m1_pmu.h
arch_gicv3.h
arch_timer.h
archrandom.h
arm-cci.h
arm_dsu_pmu.h
asm-bug.h
asm-extable.h
asm-offsets.h
asm-prototypes.h
asm-uaccess.h
asm_pointer_auth.h
assembler.h
atomic.h
atomic_ll_sc.h
atomic_lse.h
barrier.h
bitops.h
bitrev.h
boot.h
brk-imm.h
bug.h
cache.h
cacheflush.h
checksum.h
clocksource.h
cmpxchg.h
compat.h
compiler.h
cpu.h
cpu_ops.h
cpufeature.h
cpuidle.h
cputype.h
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
elf.h
esr.h
exception.h
exec.h
extable.h
fb.h
fixmap.h
fpsimd.h
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
futex.h
gpr-num.h
hardirq.h
hugetlb.h
hw_breakpoint.h
hwcap.h
hyp_image.h
hyperv-tlfs.h
hypervisor.h
image.h
insn-def.h
insn.h
io.h
irq.h
irq_work.h
irqflags.h
jump_label.h
kasan.h
kernel-pgtable.h
kexec.h
kfence.h
kgdb.h
kprobes.h
kvm_arm.h
kvm_asm.h
kvm_emulate.h
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
kvm_mte.h
kvm_pgtable.h
kvm_pkvm.h
kvm_ptrauth.h
kvm_ras.h
kvm_types.h
linkage.h
lse.h
memory.h
mman.h
mmu.h
mmu_context.h
mmzone.h
module.h
module.lds.h
mshyperv.h
mte-def.h
mte-kasan.h
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.h
paravirt_api_clock.h
patching.h
pci.h
percpu.h
perf_event.h
pgalloc.h
pgtable-hwdef.h
pgtable-prot.h
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
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
seccomp.h
sections.h
set_memory.h
setup.h
shmparam.h
signal.h
signal32.h
simd.h
smp.h
smp_plat.h
sparsemem.h
spectre.h
spinlock.h
spinlock_types.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
stat.h
string.h
suspend.h
sync_bitops.h
syscall.h
syscall_wrapper.h
sysreg.h arm64: Add missing Set/Way CMO encodings 2023-06-28 11:12:35 +02:00
system_misc.h
thread_info.h
timex.h
tlb.h
tlbflush.h
topology.h
trans_pgd.h
traps.h
uaccess.h
unistd.h
unistd32.h
uprobes.h
vdso.h
vectors.h
vermagic.h
virt.h
vmalloc.h
vmap_stack.h
word-at-a-time.h
xor.h