WSL2-Linux-Kernel/arch/powerpc/kernel
Mahesh Salgaonkar e2afb26615 powerpc: Avoid nmi_enter/nmi_exit in real mode interrupt.
commit 0db880fc865ffb522141ced4bfa66c12ab1fbb70 upstream.

nmi_enter()/nmi_exit() touches per cpu variables which can lead to kernel
crash when invoked during real mode interrupt handling (e.g. early HMI/MCE
interrupt handler) if percpu allocation comes from vmalloc area.

Early HMI/MCE handlers are called through DEFINE_INTERRUPT_HANDLER_NMI()
wrapper which invokes nmi_enter/nmi_exit calls. We don't see any issue when
percpu allocation is from the embedded first chunk. However with
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK enabled there are chances where percpu
allocation can come from the vmalloc area.

With kernel command line "percpu_alloc=page" we can force percpu allocation
to come from vmalloc area and can see kernel crash in machine_check_early:

[    1.215714] NIP [c000000000e49eb4] rcu_nmi_enter+0x24/0x110
[    1.215717] LR [c0000000000461a0] machine_check_early+0xf0/0x2c0
[    1.215719] --- interrupt: 200
[    1.215720] [c000000fffd73180] [0000000000000000] 0x0 (unreliable)
[    1.215722] [c000000fffd731b0] [0000000000000000] 0x0
[    1.215724] [c000000fffd73210] [c000000000008364] machine_check_early_common+0x134/0x1f8

Fix this by avoiding use of nmi_enter()/nmi_exit() in real mode if percpu
first chunk is not embedded.

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Tested-by: Shirisha Ganta <shirisha@linux.ibm.com>
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240410043006.81577-1-mahesh@linux.ibm.com
[ Conflicts in arch/powerpc/include/asm/interrupt.h
  because interrupt_nmi_enter_prepare() and interrupt_nmi_exit_prepare()
  has been refactored. ]
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-19 05:45:51 +02:00
..
ptrace powerpc: Don't try to copy PPR for task with NULL pt_regs 2023-04-05 11:25:00 +02:00
syscalls syscalls: fix compat_sys_io_pgetevents_time64 usage 2024-07-05 09:14:50 +02:00
trace powerpc/ftrace: Fix stack teardown in ftrace_no_trace 2023-12-20 15:17:43 +01:00
vdso32 powerpc updates for 5.13 2021-04-30 12:22:28 -07:00
vdso64 powerpc/vdso: Don't use r30 to avoid breaking Go lang 2021-07-29 23:13:12 +10:00
.gitignore
Makefile powerpc/64s: Disable stack variable initialisation for prom_init 2022-08-17 14:23:05 +02:00
align.c powerpc: Rename probe_kernel_read_inst() 2021-04-21 22:52:33 +10:00
asm-offsets.c Merge branch 'fixes' into next 2021-09-03 22:54:12 +10:00
audit.c
btext.c powerpc/btext: add missing of_node_put 2022-01-27 11:04:57 +01:00
cacheinfo.c powerpc/smp: Use existing L2 cache_map cpumask to find L3 cache siblings 2021-08-04 10:53:39 +10:00
cacheinfo.h
compat_audit.c
cpu_setup_6xx.S
cpu_setup_44x.S
cpu_setup_fsl_booke.S
cpu_setup_pa6t.S
cpu_setup_power.c
cpu_setup_ppc970.S
cputable.c
crash_dump.c powerpc: Don't use 'struct ppc_inst' to reference instruction location 2021-06-17 00:09:00 +10:00
dawr.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
dbell.c
dma-iommu.c powerpc/iommu: Incorrect DDW Table is referenced for SR-IOV device 2023-05-24 17:36:55 +01:00
dma-mask.c
dma-swiotlb.c
dt_cpu_ftrs.c
early_32.c
eeh.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
eeh_cache.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
eeh_driver.c powerpc/eeh: Set channel state after notifying the drivers 2024-03-01 13:21:53 +01:00
eeh_event.c
eeh_pe.c powerpc/eeh: avoid possible crash when edev->pdev changes 2024-07-27 10:46:13 +02:00
eeh_sysfs.c
entry_32.S powerpc/47x: Fix 47x syscall return crash 2023-10-25 11:58:59 +02:00
entry_64.S powerpc/rtas: Keep MSR[RI] set when calling RTAS 2022-06-09 10:22:42 +02:00
epapr_hcalls.S
epapr_paravirt.c powerpc: Don't use 'struct ppc_inst' to reference instruction location 2021-06-17 00:09:00 +10:00
exceptions-64e.S powerpc: flexible GPR range save/restore macros 2022-07-12 16:35:02 +02:00
exceptions-64s.S powerpc: flexible GPR range save/restore macros 2022-07-12 16:35:02 +02:00
fadump.c cma: factor out minimum alignment requirement 2024-07-05 09:14:13 +02:00
firmware.c powerpc: fix unbalanced node refcount in check_kvm_guest() 2021-11-18 19:16:51 +01:00
fpu.S powerpc: Don't clobber f0/vs0 during fp|altivec register save 2023-12-08 08:48:01 +01:00
fsl_booke_entry_mapping.S powerpc/booke: Avoid link stack corruption in several places 2021-08-25 13:35:47 +10:00
head_8xx.S powerpc/8xx: Fix pinned TLBs with CONFIG_STRICT_KERNEL_RWX 2021-11-25 09:48:44 +01:00
head_32.h powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly 2023-10-25 11:58:59 +02:00
head_40x.S powerpc/40x: Map 32Mbytes of memory at startup 2022-01-27 11:05:01 +01:00
head_44x.S powerpc/booke: Avoid link stack corruption in several places 2021-08-25 13:35:47 +10:00
head_64.S powerpc/toc: Future proof kernel toc 2024-01-25 14:52:32 -08:00
head_book3s_32.S powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly 2023-10-25 11:58:59 +02:00
head_booke.h powerpc: flexible GPR range save/restore macros 2022-07-12 16:35:02 +02:00
head_fsl_booke.S powerpc/85xx: Fix math emulation exception 2023-11-08 17:26:45 +01:00
hw_breakpoint.c powerpc/watchpoints: Annotate atomic context in more places 2023-10-06 13:18:18 +02:00
hw_breakpoint_constraints.c powerpc/watchpoint: Disable pagefaults when getting user instruction 2023-10-06 13:18:18 +02:00
idle.c powerpc/mm: Switch obsolete dssall to .long 2022-06-14 18:36:27 +02:00
idle_6xx.S powerpc/mm: Switch obsolete dssall to .long 2022-06-14 18:36:27 +02:00
idle_book3e.S
idle_book3s.S powerpc/idle: Don't corrupt back chain when going idle 2021-10-20 21:37:58 +11:00
idle_e500.S
ima_arch.c
interrupt.c powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly 2023-10-25 11:58:59 +02:00
interrupt_64.S powerpc/64: Set task pt_regs->link to the LR value on scv entry 2024-02-23 08:55:08 +01:00
io-workarounds.c powerpc: Fix reverse map real-mode address lookup with huge vmalloc 2021-05-28 22:54:27 +10:00
io.c
iomap.c
iommu.c powerpc/iommu: Fix notifiers being shared by PCI and VIO buses 2023-09-19 12:22:42 +02:00
irq.c powerpc/64: warn if local irqs are enabled in NMI or hardirq context 2021-10-07 19:54:55 +11:00
isa-bridge.c mm/vmalloc: remove unmap_kernel_range 2021-04-30 11:20:40 -07:00
jump_label.c powerpc: Don't use 'struct ppc_inst' to reference instruction location 2021-06-17 00:09:00 +10:00
kdebugfs.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
kgdb.c powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
kprobes-ftrace.c powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
kprobes.c powerpc/kprobes: Fix null pointer reference in arch_prepare_kprobe() 2022-10-26 12:35:23 +02:00
kvm.c gup: Turn fault_in_pages_{readable,writeable} into fault_in_{readable,writeable} 2022-05-01 17:22:28 +02:00
kvm_emul.S
l2cr_6xx.S powerpc/mm: Switch obsolete dssall to .long 2022-06-14 18:36:27 +02:00
legacy_serial.c powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds 2021-05-12 11:07:39 +10:00
mce.c powerpc/mce: Fix access error in mce handler 2021-09-13 22:34:12 +10:00
mce_power.c powerpc/powernv: Fix machine check reporting of async store errors 2021-06-21 21:13:19 +10:00
misc.S powerpc: Avoid link stack corruption in misc asm functions 2021-08-25 13:35:47 +10:00
misc_32.S powerpc: Avoid link stack corruption in misc asm functions 2021-08-25 13:35:47 +10:00
misc_64.S powerpc: Avoid link stack corruption in misc asm functions 2021-08-25 13:35:47 +10:00
module.c powerpc/modules: Don't WARN on first module allocation attempt 2022-01-27 11:04:08 +01:00
module_32.c powerpc/modules: Use PPC_RAW_xx() macros 2021-06-16 00:16:48 +10:00
module_64.c powerpc/module_64: Fix livepatching for RO modules 2021-12-22 09:32:49 +01:00
msi.c
note.S
nvram_64.c
of_platform.c
optprobes.c powerpc/kprobes: Fix Oops by passing ppc_inst as a pointer to emulate_step() on ppc32 2021-06-25 14:46:51 +10:00
optprobes_head.S powerpc: flexible GPR range save/restore macros 2022-07-12 16:35:02 +02:00
paca.c Revert "powerpc/rtas: Implement reentrant rtas call" 2022-10-15 07:59:02 +02:00
pci-common.c powerpc/pci: Fix get_phb_number() locking 2022-08-25 11:40:23 +02:00
pci-hotplug.c
pci_32.c
pci_64.c mm/vmalloc: remove unmap_kernel_range 2021-04-30 11:20:40 -07:00
pci_dn.c powerpc/pci_dn: Add missing of_node_put() 2022-10-26 12:35:22 +02:00
pci_of_scan.c
pmc.c
ppc32.h
ppc_save_regs.S powerpc: update ppc_save_regs to save current r1 in pt_regs 2023-07-23 13:47:13 +02:00
proc_powerpc.c
process.c powerpc: Enable execve syscall exit tracepoint 2022-06-29 09:03:30 +02:00
prom.c powerpc/64: Init jump labels before parse_early_param() 2022-08-25 11:40:45 +02:00
prom_init.c powerpc/prom_init: Fix improper check of prom_getprop() 2022-01-27 11:04:06 +01:00
prom_init_check.sh powerpc/prom_init: Fix kernel config grep 2022-07-07 17:53:24 +02:00
prom_parse.c
reloc_32.S powerpc: Avoid link stack corruption in misc asm functions 2021-08-25 13:35:47 +10:00
reloc_64.S powerpc/64: Add UADDR64 relocation support 2022-05-09 09:14:44 +02:00
rtas-proc.c
rtas-rtc.c powerpc/rtas-rtc: remove unused constant 2021-06-25 14:47:20 +10:00
rtas.c powerpc/rtas: ensure 4KB alignment for rtas_data_buf 2024-03-01 13:21:53 +01:00
rtas_flash.c powerpc/rtas_flash: allow user copy to flash block cache objects 2023-08-26 14:23:31 +02:00
rtas_pci.c
rtasd.c powerpc: Replace deprecated CPU-hotplug functions. 2021-08-10 23:14:56 +10:00
secure_boot.c
security.c powerpc/security: Fix Speculation_Store_Bypass reporting on Power10 2023-07-23 13:47:47 +02:00
secvar-ops.c
secvar-sysfs.c powerpc/secvar: fix refcount leak in format_show() 2022-04-13 20:59:08 +02:00
setup-common.c powerpc/mm: Fix boot crash with FLATMEM 2023-11-08 17:26:48 +01:00
setup.h
setup_32.c powerpc: Don't use 'struct ppc_inst' to reference instruction location 2021-06-17 00:09:00 +10:00
setup_64.c powerpc: Avoid nmi_enter/nmi_exit in real mode interrupt. 2024-08-19 05:45:51 +02:00
signal.c entry: rseq: Call rseq_handle_notify_resume() in tracehook_notify_resume() 2021-09-22 10:24:01 -04:00
signal.h powerpc/signal32: Fix sigset_t copy 2021-11-25 09:48:44 +01:00
signal_32.c powerpc/signal32: Force inlining of __unsafe_save_user_regs() and save_tm_user_regs_unsafe() 2023-07-23 13:47:12 +02:00
signal_64.c gup: Turn fault_in_pages_{readable,writeable} into fault_in_{readable,writeable} 2022-05-01 17:22:28 +02:00
smp-tbsync.c
smp.c powerpc/fadump: Fix inaccurate CPU state info in vmcore generated with panic 2022-01-27 11:05:02 +01:00
stacktrace.c powerpc/stacktrace: Include linux/delay.h 2021-08-03 22:33:37 +10:00
suspend.c
swsusp.c
swsusp_32.S powerpc/mm: Switch obsolete dssall to .long 2022-06-14 18:36:27 +02:00
swsusp_64.c
swsusp_asm64.S powerpc/mm: Switch obsolete dssall to .long 2022-06-14 18:36:27 +02:00
swsusp_booke.S
sys_ppc32.c powerpc: Fix fallocate and fadvise64_64 compat parameter combination 2022-10-26 12:35:22 +02:00
syscalls.c powerpc: Fix fallocate and fadvise64_64 compat parameter combination 2022-10-26 12:35:22 +02:00
sysfs.c powerpc/smp: Fix OOPS in topology_init() 2021-08-07 08:53:59 +10:00
systbl.S powerpc: align syscall table for ppc32 2022-09-08 12:28:03 +02:00
systbl_chk.sh
tau_6xx.c powerpc/tau: Add 'static' storage qualifier to 'tau_work' definition 2021-08-20 17:00:53 +10:00
time.c powerpc/kcsan: Exclude udelay to prevent recursive instrumentation 2023-03-17 08:49:01 +01:00
tm.S powerpc/tm: Fix more userspace r13 corruption 2022-07-12 16:35:02 +02:00
traps.c powerpc: Fix build error due to is_valid_bugaddr() 2024-02-23 08:54:36 +01:00
ucall.S
udbg.c isystem: ship and use stdarg.h 2021-08-19 09:02:55 +09:00
udbg_16550.c powerpc/microwatt: Use standard 16550 UART for console 2021-06-21 21:16:31 +10:00
uprobes.c powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
vdso.c
vdso32_wrapper.S
vdso64_wrapper.S
vecemu.c
vector.S powerpc: Don't clobber f0/vs0 during fp|altivec register save 2023-12-08 08:48:01 +01:00
vmlinux.lds.S powerpc/toc: Future proof kernel toc 2024-01-25 14:52:32 -08:00
watchdog.c powerpc/watchdog: Fix missed watchdog reset due to memory ordering race 2022-01-27 11:04:57 +01:00