linux/arch/powerpc
Sayali Patil 31467b2382 powerpc/time: Remove redundant preempt_disable|enable() calls from arch_irq_work_raise()
A kernel panic is observed when handling machine check exceptions from
real mode.

  BUG: Unable to handle kernel data access on read at 0xc00000006be21300
  Oops: Kernel access of bad area, sig: 11 [#1]
  MSR:  8000000000001003 <SF,ME,RI,LE>  CR: 88222248  XER: 00000005
  CFAR: c00000000003ffc4 DAR: c00000006be21300 DSISR: 40000000 IRQMASK: 0
  NIP [c000000000029e40] arch_irq_work_raise+0x10/0x70
  LR [c00000000003ffc8] machine_check_queue_event+0xa8/0x150
  Call Trace:
  [c0000000179d3c70] [c00000000003ff64] machine_check_queue_event+0x44/0x150
  [c0000000179d3d30] [c0000000000084e0] machine_check_early_common+0x1f0/0x2c0

The crash occurs because arch_irq_work_raise() calls preempt_disable()
from machine check exception (MCE) handlers running in real mode. In
this context, accessing the preempt_count can fault, leading to the panic.

The preempt_disable()/preempt_enable() pair in arch_irq_work_raise()
was originally added by commit 0fe1ac48be ("powerpc/perf_event: Fix
oops due to perf_event_do_pending call") to avoid races while raising
irq work from exception context.

Later, commit 471ba0e686 ("irq_work: Do not raise an IPI when
queueing work on the local CPU") added preemption protection in
irq_work_queue() path, while commit 20b876918c ("irq_work: Use per
cpu atomics instead of regular atomics") added equivalent
protection in irq_work_queue_on() before reaching arch_irq_work_raise():

  irq_work_queue() / irq_work_queue_on()
    -> preempt_disable()
      -> __irq_work_queue_local()
        -> irq_work_raise()
          -> arch_irq_work_raise()

As a result, callers other than mce_irq_work_raise() already execute
with preemption disabled, making the additional
preempt_disable()/preempt_enable() pair in arch_irq_work_raise()
redundant.

The arch_irq_work_raise() function executes in NMI context when called
from MCE handler. Hence we will not be preempted or scheduled out since
we are in NMI context with MSR[EE]=0. Therefore, it is safe to remove
the preempt_disable()/preempt_enable() calls from here.

Remove it to avoid accessing preempt_count from real mode context.

Fixes: cc15ff3275 ("powerpc/mce: Avoid using irq_work_queue() in realmode")
Suggested-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Acked-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
[Maddy: Fixed the commit title]
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260513081413.222490-1-sayalip@linux.ibm.com
2026-05-14 11:15:26 +05:30
..
boot powerpc updates for 7.1 2026-04-14 17:10:15 -07:00
configs powerpc/g5: Enable all windfarms by default 2026-05-12 11:48:01 +05:30
crypto lib/crypto: powerpc/ghash: Migrate optimized code into library 2026-03-23 16:44:29 -07:00
include powerpc/powermac: Remove pmac_low_i2c_{lock,unlock}() 2026-05-12 11:50:09 +05:30
kernel powerpc/time: Remove redundant preempt_disable|enable() calls from arch_irq_work_raise() 2026-05-14 11:15:26 +05:30
kexec powerpc/kdump: fix KASAN sanitization flag for core_$(BITS).o 2026-05-06 07:31:27 +05:30
kvm KVM: PPC: remove hugetlb.h inclusion 2026-04-05 13:53:23 -07:00
lib powerpc/vmx: avoid KASAN instrumentation in enter_vmx_ops() for kexec 2026-05-06 07:31:28 +05:30
math-emu
mm mm.git review status for linus..mm-stable 2026-04-15 12:59:16 -07:00
net bpf: Pass bpf_verifier_env to JIT 2026-04-16 07:03:40 -07:00
perf powerpc/hv-gpci: fix preempt count leak in sysfs show paths 2026-05-12 11:51:17 +05:30
platforms powerpc/powermac: Remove pmac_low_i2c_{lock,unlock}() 2026-05-12 11:50:09 +05:30
purgatory Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
sysdev powerpc updates for 7.1 2026-04-14 17:10:15 -07:00
tools powerpc64/ftrace: fix OOL stub count with clang 2026-03-07 16:02:25 +05:30
xmon powerpc/xmon: replace sizeof calculations with ARRAY_SIZE macro 2025-09-01 13:40:46 +05:30
Kbuild powerpc64/ftrace: Move ftrace sequence out of line 2024-10-31 11:00:54 +11:00
Kconfig integrity-v7.1 2026-04-17 15:42:01 -07:00
Kconfig.debug powerpc: fix dead default for GUEST_STATE_BUFFER_TEST 2026-05-12 11:50:52 +05:30
Makefile kbuild: Add missing $(objtree) prefix to powerpc crtsavres.o artifact 2025-09-01 13:41:57 +05:30
Makefile.postlink powerpc/ftrace: Add a postlink script to validate function tracer 2024-10-31 11:00:54 +11:00