From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8851313A258 for ; Wed, 13 May 2026 05:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778650333; cv=none; b=T/z/udr1SIaBbyJTS2HeEI+zQsbRjKTaFmh2Jqs6m5Lt7jLh8wisZrY3KonOOqctDkaKZXcCXasfFq7WGkSkoETdszyjtx8VVacy7NqSOqaJeEGlCrdNdGx0oGGwWliNSGCJpuY5o/QNnauLaSgxWOjI40prB71tOecXE0H6XGU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778650333; c=relaxed/simple; bh=sMOtYz4Lc3qjfIRhalyd4vU23tDUWIEPoNJpwNc+1Iw=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=blMM14DhnSLtDUaep/+WHwtCyoUBTArlV26tYiZ17LxRTIUIUr3fJADdbLinUGiH2cPmjml7Efsmp7JGFXQSPofsMDsclFJi5py264kIjWZk33rmmZ+nEhq/kIAAuFXgd0zBxaju5qsyL6GtQNaQBKEsSR9Zdpp/rXDFPB4VBpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LiFZaf92; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LiFZaf92" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-36608b2f2dcso4421357a91.2 for ; Tue, 12 May 2026 22:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778650331; x=1779255131; darn=vger.kernel.org; h=references:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Odlz6dn4AMU3xpWoO+zOes01KTSuDtmQ6fjIHbN8+tI=; b=LiFZaf92/458W1Mat08Q55oHhi1XwTBte5k3AKMWvIB477/HDqVSVfW18MKIL4oYSs 3LHPzvoUkS01KsYTfzZ4svfKpcnACc/BgmO7U7GH+5YxSv+jNsYwrwbFR7vlv+LzXgcI 5k1OiqL6lVpRpmgqwErocB8U0anmQo3MlkwZmqoEM7EMcuLuX/SEjA3EVvlvYl2xf/9U +pMGbckBp1M3iOQ4TPsxOkHZnQJvjTHaaYeKlPwLf9Vp9r4lHPln4YMNt/LFDe7GiPq0 52x/sEGSzBDyh8ZwFoS46V9QEjuN52hq7Du1GA02x22ejqDCM49gCqGevrwN+JJ3z1ns 0wXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778650331; x=1779255131; h=references:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Odlz6dn4AMU3xpWoO+zOes01KTSuDtmQ6fjIHbN8+tI=; b=a8GGRNF+l6op68EkGb7ELv/wyG25ODO8Hn6OY/PUIvF07xgtttuH95Y9/Wn/qb8x9C 2vw4GXkNs+Nw1ogGAx+feIm3YUVslddbrH4y3khQZemnMyy4BWBrYQrYYgIB4RXDD7iH FfI5p/6lFAdPZsSRwsmHcylEPV26phME4nqDbfWKGrvg+dzSkJaPv9gLSmnSS6nacibe vgKVm4yo9DLC9LE5nVotnCnVCYjAlC7tQRktMZJ00ZcX1792QWJJzw7gaay5qOd8Wi9B jC1cHqqAEB4xtxfJV9SEQC7kMPTYXMG/2RW6zkpCNKmTJxyp/Ru1tTlZRo/96B4DNcI7 sWng== X-Gm-Message-State: AOJu0YxsoUVJTMKoyv5A/Hw2QEzv70p91HD+SlrNGHooTe12G5o0Y3Ak 7VQvVssO0QKQB2ZCzNoEg300e2XkYlImX/er+gJjzfUMYb1I5boCvXnWxga9yw== X-Gm-Gg: Acq92OH3Ay0X+ZFEKPB/rNLZ1glzPG4v5629FrizJNx7O5U6B6siSCYT2qpnrYnROVt RgBXAGvooQXBAP9lcKhuygRaeastK83twn21uUFMzrjEZxUoQDA6qFuR/vctm7/E+YZOUyGE/dA kb/XPYWR7WKdVMqygbxflSKuwhD5KGCDIsQxqqIHXICxC+Xh6Bb6JeDFKL/Lm+51EDsa/APHyv+ X5NUS4isMdPoyr8JtI9E7st2e174em1yOQpUbOkbancd60rnRjoNr0kxf2mg+HMGKfTpixEducf oK/815i4T1fWP04SxRB4yluty6K+54KJqxJPppXe1Ez/OBEie9TJcsJzkGtOew3v/13ANV9IE5z uPNVlNNiD7NW+NQRZvHfENGuQGSAkLbQejg+75+XSfhDsGQqqSSZI1D9N+7vREVzHD413Iko6zo 50A3UYtrDIw5k7BYByOqyKAQ== X-Received: by 2002:a17:90b:2702:b0:366:4782:139a with SMTP id 98e67ed59e1d1-368f79930c2mr1396471a91.17.1778650330660; Tue, 12 May 2026 22:32:10 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-368ede49dfcsm1614075a91.7.2026.05.12.22.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 22:32:09 -0700 (PDT) From: Ritesh Harjani (IBM) To: Sayali Patil , linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com Cc: linux-kernel@vger.kernel.org, Mahesh Salgaonkar , sshegde@linux.ibm.com, chleroy@kernel.org Subject: Re: [PATCH 1/3] powerpc/time: remove preempt_disable/enable from arch_irq_work_raise() In-Reply-To: Date: Wed, 13 May 2026 10:00:49 +0530 Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Sayali Patil writes: > 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] > NIP [c000000000029e40] arch_irq_work_raise+0x10/0x70 > LR [c00000000003ffc8] machine_check_queue_event+0xa8/0x150 [14626.841925] MSR: 8000000000001003 CR: 88222248 XER: 00000005 [14626.841939] CFAR: c00000000003ffc4 DAR: c00000006be21300 DSISR: 40000000 IRQMASK: 0 Let's also add the above MSR state along with the call stack showing MSR[EE] was 0 when this triggered. This also shows the DAR as 0xc.... while MSR[IR|DR] = 0. > 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 0fe1ac48bef0 ("powerpc/perf_event: Fix > oops due to perf_event_do_pending call") to avoid races while raising > irq work from exception context. > > Later, commit 471ba0e686cb ("irq_work: Do not raise an IPI when > queueing work on the local CPU") added preemption protection in > irq_work_queue() path, while commit 20b876918c06 ("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. > > Remove it to avoid accessing preempt_count from real mode context. > > Fixes: cc15ff327569 ("powerpc/mce: Avoid using irq_work_queue() in realmode") Agree with the Fixes tag. This patch actually moved mce to use arch_irq_work_raise(). It was ok until the CONFIG_PREEMPTION was disabled on powerpc since macros like preempt_enable|disable() were mostly a no-op. However, after lazy preemption got enabled, access to preempt_count while in real mode can cause the issue you described. One more thing which we should add to the commit msg is: The arch_irq_work_raise() function executes in NMI context when called from MCE handler, hence we won't be preempted or scheduled out since we are in NMI context with MSR[EE]=0, hence it is safe to remove preempt_disable|enable() call from here. And let's change the commit subject to: powerpc/time: Remove redundant preempt_disable|enable() calls from arch_irq_work_raise() BTW, thanks for adding a nice commit msg with the sequence of events. With the above changes - pease feel free to add: Reviewed-by: Ritesh Harjani (IBM) > Suggested-by: Mahesh Salgaonkar > Signed-off-by: Sayali Patil > --- > arch/powerpc/kernel/time.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c > index 4bbeb8644d3d..a99eb43f6ce9 100644 > --- a/arch/powerpc/kernel/time.c > +++ b/arch/powerpc/kernel/time.c > @@ -471,10 +471,8 @@ void arch_irq_work_raise(void) > * which could get tangled up if we're messing with the same state > * here. > */ > - preempt_disable(); > set_irq_work_pending_flag(); > set_dec(1); > - preempt_enable(); > } > > static void set_dec_or_work(u64 val) > -- > 2.52.0