android_kernel_xiaomi_sm8450/arch
Pierre Gondois 030b1c4217 arm64: efi: Make efi_rt_lock a raw_spinlock
[ Upstream commit 0e68b5517d3767562889f1d83fdb828c26adb24f ]

Running a rt-kernel base on 6.2.0-rc3-rt1 on an Ampere Altra outputs
the following:
  BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
  in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 9, name: kworker/u320:0
  preempt_count: 2, expected: 0
  RCU nest depth: 0, expected: 0
  3 locks held by kworker/u320:0/9:
  #0: ffff3fff8c27d128 ((wq_completion)efi_rts_wq){+.+.}-{0:0}, at: process_one_work (./include/linux/atomic/atomic-long.h:41)
  #1: ffff80000861bdd0 ((work_completion)(&efi_rts_work.work)){+.+.}-{0:0}, at: process_one_work (./include/linux/atomic/atomic-long.h:41)
  #2: ffffdf7e1ed3e460 (efi_rt_lock){+.+.}-{3:3}, at: efi_call_rts (drivers/firmware/efi/runtime-wrappers.c:101)
  Preemption disabled at:
  efi_virtmap_load (./arch/arm64/include/asm/mmu_context.h:248)
  CPU: 0 PID: 9 Comm: kworker/u320:0 Tainted: G        W          6.2.0-rc3-rt1
  Hardware name: WIWYNN Mt.Jade Server System B81.03001.0005/Mt.Jade Motherboard, BIOS 1.08.20220218 (SCP: 1.08.20220218) 2022/02/18
  Workqueue: efi_rts_wq efi_call_rts
  Call trace:
  dump_backtrace (arch/arm64/kernel/stacktrace.c:158)
  show_stack (arch/arm64/kernel/stacktrace.c:165)
  dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4))
  dump_stack (lib/dump_stack.c:114)
  __might_resched (kernel/sched/core.c:10134)
  rt_spin_lock (kernel/locking/rtmutex.c:1769 (discriminator 4))
  efi_call_rts (drivers/firmware/efi/runtime-wrappers.c:101)
  [...]

This seems to come from commit ff7a167961d1 ("arm64: efi: Execute
runtime services from a dedicated stack") which adds a spinlock. This
spinlock is taken through:
efi_call_rts()
\-efi_call_virt()
  \-efi_call_virt_pointer()
    \-arch_efi_call_virt_setup()

Make 'efi_rt_lock' a raw_spinlock to avoid being preempted.

[ardb: The EFI runtime services are called with a different set of
       translation tables, and are permitted to use the SIMD registers.
       The context switch code preserves/restores neither, and so EFI
       calls must be made with preemption disabled, rather than only
       disabling migration.]

Fixes: ff7a167961d1 ("arm64: efi: Execute runtime services from a dedicated stack")
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Cc: <stable@vger.kernel.org> # v6.1+
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-17 08:45:08 +01:00
..
alpha alpha: fix FEN fault handling 2023-03-11 16:40:04 +01:00
arc arch: setup PF_IO_WORKER threads like PF_KTHREAD 2023-01-04 11:39:22 +01:00
arm ARM: dts: spear320-hmi: correct STMPE GPIO compatible 2023-03-11 16:40:13 +01:00
arm64 arm64: efi: Make efi_rt_lock a raw_spinlock 2023-03-17 08:45:08 +01:00
c6x c6x: add support for TIF_NOTIFY_SIGNAL 2023-01-04 11:39:21 +01:00
csky csky: Fix function name in csky_alignment() and die() 2023-02-01 08:23:20 +01:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-01 08:23:19 +01:00
hexagon hexagon: Fix function name in die() 2023-02-01 08:23:19 +01:00
ia64 ia64: make IA64_MCA_RECOVERY bool instead of tristate 2023-02-01 08:23:20 +01:00
m68k m68k: Check syscall_trace_enter() return code 2023-03-11 16:39:50 +01:00
microblaze exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
mips mips: fix syscall_get_nr 2023-03-11 16:40:04 +01:00
nds32 exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
nios2 exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
openrisc exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
parisc parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case 2023-02-15 17:22:19 +01:00
powerpc powerpc: Remove linker flag from KBUILD_AFLAGS 2023-03-11 16:39:46 +01:00
riscv riscv: jump_label: Fixup unaligned arch_static_branch function 2023-03-11 16:40:06 +01:00
s390 KVM: s390: disable migration mode when dirty tracking is disabled 2023-03-11 16:39:58 +01:00
sh exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
sparc sparc: allow PM configs for sparc32 COMPILE_TEST 2023-03-11 16:39:40 +01:00
um um: vector: Fix memory leak in vector_config 2023-03-11 16:40:09 +01:00
x86 x86/CPU/AMD: Disable XSAVES on AMD family 0x17 2023-03-17 08:45:06 +01:00
xtensa exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
.gitignore
Kconfig arch/cc: Introduce a function to check for confidential computing features 2021-11-18 14:04:32 +01:00