* [PATCH v4 1/3] PPC32: Fix hard_irq_disable to follow tracing and lockdep state
2026-11-17 13:16 [PATCH v4 0/3] KVM: PPC: BookE: Fix boot hang on preemptible kernels Shrikanth Hegde
@ 2026-11-17 13:16 ` Shrikanth Hegde
2026-11-17 13:28 ` Ritesh Harjani
2026-11-17 13:16 ` [PATCH v4 2/3] KVM: PPC: BookE: Load FP and Altivec before enabling the interrupts Shrikanth Hegde
2026-11-17 13:16 ` [PATCH v4 3/3] KVM: PPC: Hard disable interrupts before guest entry Shrikanth Hegde
2 siblings, 1 reply; 7+ messages in thread
From: Shrikanth Hegde @ 2026-11-17 13:16 UTC (permalink / raw)
To: maddy, linuxppc-dev, chzigotzky
Cc: sshegde, mpe, npiggin, christophe.leroy, linux-kernel, msuchanek,
ritesh.list, harshpb, gautam, amachhiw, venkat88, nnmlinux,
mkchauras
On PPC32, the code for hard_irq_disable has diverged and it doesn't
do lockdep/tracing anymore, leading to use of both local_irq_disable
and hard_irq_disable on PPC32 to overcome those.
That is un-necessary, instead simply calling local_irq_disable is
enough. It disables EE bit and does lockdep tracking.
Subsequent patch uses this API in KVM code to avoid the warnings.
Wider use of it is possible, but it will be taken subsequently.
Fixes: 5d38902c4838 ("powerpc: Add irqtrace support for 32-bit powerpc")
Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
PS: Fixes tag is based on the historical analysis done by Ritesh.
I haven't got a chance to delve deep into it. Note that it is old
commit and lot of code interleave would have happened since
including local_irq_disable at some would have added proper
lockdep support.
arch/powerpc/include/asm/hw_irq.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index b7eee6385ae5..ddb850e62abd 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -464,7 +464,7 @@ static inline bool arch_irqs_disabled(void)
return arch_irqs_disabled_flags(arch_local_save_flags());
}
-#define hard_irq_disable() arch_local_irq_disable()
+#define hard_irq_disable() local_irq_disable()
static inline bool regs_irqs_disabled(struct pt_regs *regs)
{
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v4 1/3] PPC32: Fix hard_irq_disable to follow tracing and lockdep state
2026-11-17 13:16 ` [PATCH v4 1/3] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Shrikanth Hegde
@ 2026-11-17 13:28 ` Ritesh Harjani
2026-11-17 15:31 ` Shrikanth Hegde
0 siblings, 1 reply; 7+ messages in thread
From: Ritesh Harjani @ 2026-11-17 13:28 UTC (permalink / raw)
To: Shrikanth Hegde, maddy, linuxppc-dev, chzigotzky
Cc: sshegde, mpe, npiggin, christophe.leroy, linux-kernel, msuchanek,
harshpb, gautam, amachhiw, venkat88, nnmlinux, mkchauras
Shrikanth Hegde <sshegde@linux.ibm.com> writes:
> On PPC32, the code for hard_irq_disable has diverged and it doesn't
> do lockdep/tracing anymore, leading to use of both local_irq_disable
> and hard_irq_disable on PPC32 to overcome those.
>
> That is un-necessary, instead simply calling local_irq_disable is
> enough. It disables EE bit and does lockdep tracking.
>
> Subsequent patch uses this API in KVM code to avoid the warnings.
> Wider use of it is possible, but it will be taken subsequently.
>
> Fixes: 5d38902c4838 ("powerpc: Add irqtrace support for 32-bit powerpc")
> Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
> PS: Fixes tag is based on the historical analysis done by Ritesh.
> I haven't got a chance to delve deep into it. Note that it is old
> commit and lot of code interleave would have happened since
> including local_irq_disable at some would have added proper
> lockdep support.
>
Yes, not sure whether we really want this this fix to go back to that
old change?
Maybe we can add CC: stable and keep the minimum kernel version to it,
so that it gets applied >= vX.Y+ sort of. Instead of stable backports
picking this change and taking it all the way to a very a old kernel
release - which in my opinion is not worth it. Thoughts?
Do we know from when we started hitting this problem? Should this be
after we merge generic entry/exit? Or was there any previous kernel
version too, where we were hitting this?
> arch/powerpc/include/asm/hw_irq.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
BTW, thanks for taking it forward.
The change looks good to me. So, please Feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
However, note that we should still get the stable tag / fixes thing
sorted, for stable backports to do it's right thing.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v4 1/3] PPC32: Fix hard_irq_disable to follow tracing and lockdep state
2026-11-17 13:28 ` Ritesh Harjani
@ 2026-11-17 15:31 ` Shrikanth Hegde
0 siblings, 0 replies; 7+ messages in thread
From: Shrikanth Hegde @ 2026-11-17 15:31 UTC (permalink / raw)
To: Ritesh Harjani (IBM), maddy, linuxppc-dev, chzigotzky
Cc: mpe, npiggin, christophe.leroy, linux-kernel, msuchanek, harshpb,
gautam, amachhiw, venkat88, nnmlinux, mkchauras
Hi Ritesh, thanks for taking a look.
On 11/17/26 6:58 PM, Ritesh Harjani (IBM) wrote:
> Shrikanth Hegde <sshegde@linux.ibm.com> writes:
>
>> On PPC32, the code for hard_irq_disable has diverged and it doesn't
>> do lockdep/tracing anymore, leading to use of both local_irq_disable
>> and hard_irq_disable on PPC32 to overcome those.
>>
>> That is un-necessary, instead simply calling local_irq_disable is
>> enough. It disables EE bit and does lockdep tracking.
>>
>> Subsequent patch uses this API in KVM code to avoid the warnings.
>> Wider use of it is possible, but it will be taken subsequently.
>>
>> Fixes: 5d38902c4838 ("powerpc: Add irqtrace support for 32-bit powerpc")
>> Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
>> ---
>> PS: Fixes tag is based on the historical analysis done by Ritesh.
>> I haven't got a chance to delve deep into it. Note that it is old
>> commit and lot of code interleave would have happened since
>> including local_irq_disable at some would have added proper
>> lockdep support.
>>
>
> Yes, not sure whether we really want this this fix to go back to that
> old change?
>
> Maybe we can add CC: stable and keep the minimum kernel version to it,
> so that it gets applied >= vX.Y+ sort of. Instead of stable backports
> picking this change and taking it all the way to a very a old kernel
> release - which in my opinion is not worth it. Thoughts?
>
> Do we know from when we started hitting this problem? Should this be
> after we merge generic entry/exit? Or was there any previous kernel
> version too, where we were hitting this?
>
I think we could keep below one. Bulk of the KVM specific problem
would have started from there.
Fixes: 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
We do have the other callsites still, maybe they need earlier ones.
But yes, keeping very old is probably not going to be complicated backports.
@maddy, can you take care of the correct fixes tag in the changelog?
or you want to send v5?
>> arch/powerpc/include/asm/hw_irq.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>
> BTW, thanks for taking it forward.
>
> The change looks good to me. So, please Feel free to add:
> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>
> However, note that we should still get the stable tag / fixes thing
> sorted, for stable backports to do it's right thing.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] KVM: PPC: BookE: Load FP and Altivec before enabling the interrupts
2026-11-17 13:16 [PATCH v4 0/3] KVM: PPC: BookE: Fix boot hang on preemptible kernels Shrikanth Hegde
2026-11-17 13:16 ` [PATCH v4 1/3] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Shrikanth Hegde
@ 2026-11-17 13:16 ` Shrikanth Hegde
2026-11-17 13:16 ` [PATCH v4 3/3] KVM: PPC: Hard disable interrupts before guest entry Shrikanth Hegde
2 siblings, 0 replies; 7+ messages in thread
From: Shrikanth Hegde @ 2026-11-17 13:16 UTC (permalink / raw)
To: maddy, linuxppc-dev, chzigotzky
Cc: sshegde, mpe, npiggin, christophe.leroy, linux-kernel, msuchanek,
ritesh.list, harshpb, gautam, amachhiw, venkat88, nnmlinux,
mkchauras
Christian reported that booting preemptible kernel on FSL Cyrus+ board
causes boot hang.
The logs pointed that system was busy in printing below warning.
WARNING: at .enable_kernel_fp+0x30/0x78, CPU#3: qemu-system-ppc/4884
Modules linked in:
CPU: 3 UID: 1000 PID: 4884 Comm: qemu-system-ppc Not tainted 7.3.0-rc1-powerpc64-smp-preempt #1 PREEMPT
NIP [c000000000003338] .enable_kernel_fp+0x30/0x78
LR [c00000000005de84] .kvmppc_load_guest_fp+0x30/0x80
Call Trace:
[c000000085ca7700] [c00000000005de84] .kvmppc_load_guest_fp+0x30/0x80
[c000000085ca7780] [c00000000005f2a0] .kvmppc_handle_exit+0x5bc/0x5cc
[c000000085ca7830] [c00000000006204c] .kvmppc_resume_host+0xb8/0x10c
Which is...
void enable_kernel_fp(void)
{
unsigned long cpumsr;
WARN_ON(preemptible());
And...
Though irq's are hard disabled after kvmppc_prepare_to_enter, but
kvmppc_fix_ee_before_entry enables the softmask's IRQ state.
That causes the irqs_disabled to return false.
Hence leading to the warnings.
Fix it by re-ordering the code to load the FP and Altivec
before enabling the softmask IRQ state.
Suggested-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Fixes: 3efc7da61f6c ("KVM: PPC: Book3E: Increase FPU laziness")
Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Closes: https://lore.kernel.org/all/33342fbf-eb7b-bde6-2c8c-254fe8bfb993@xenosoft.de/
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Reviewed-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
arch/powerpc/kvm/booke.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 13ad4cf5fa71..aed7b476b7eb 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1404,10 +1404,9 @@ int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr)
if (s <= 0)
r = (s << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
else {
- /* interrupts now hard-disabled */
- kvmppc_fix_ee_before_entry();
kvmppc_load_guest_fp(vcpu);
kvmppc_load_guest_altivec(vcpu);
+ kvmppc_fix_ee_before_entry();
}
}
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v4 3/3] KVM: PPC: Hard disable interrupts before guest entry
2026-11-17 13:16 [PATCH v4 0/3] KVM: PPC: BookE: Fix boot hang on preemptible kernels Shrikanth Hegde
2026-11-17 13:16 ` [PATCH v4 1/3] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Shrikanth Hegde
2026-11-17 13:16 ` [PATCH v4 2/3] KVM: PPC: BookE: Load FP and Altivec before enabling the interrupts Shrikanth Hegde
@ 2026-11-17 13:16 ` Shrikanth Hegde
2026-11-17 13:41 ` Ritesh Harjani
2 siblings, 1 reply; 7+ messages in thread
From: Shrikanth Hegde @ 2026-11-17 13:16 UTC (permalink / raw)
To: maddy, linuxppc-dev, chzigotzky
Cc: sshegde, mpe, npiggin, christophe.leroy, linux-kernel, msuchanek,
ritesh.list, harshpb, gautam, amachhiw, venkat88, nnmlinux,
mkchauras
After applying preempt disable patch, i.e PATCH 2/3, Christian reported
a subsequent warning stopping his board to boot properly.
WARNING: at .kvmppc_fix_ee_before_entry+0x10/0x28, CPU#0: qemu-system-ppc/4667
CPU: 0 UID: 1000 PID: 4667 Comm: qemu-system-ppc Tainted: G W 7.3.0-rc4-2-powerpc64-smp #1 PREEMPT
Tainted: [W]=WARN
Hardware name: varisys,CYRUS5040 e5500 0x80240012 CoreNet Generic
NIP [c00000000005dc3c] .kvmppc_fix_ee_before_entry+0x10/0x28
LR [c00000000005f298] .kvmppc_handle_exit+0x5b4/0x5e8
Call Trace:
[c000000086587780] [c00000000005ee10] .kvmppc_handle_exit+0x12c/0x5e8 (unreliable)
[c000000086587830] [c000000000062068] .kvmppc_resume_host+0xb8/0x10c
It triggers below warning...
static inline void kvmppc_fix_ee_before_entry(void)
{
trace_hardirqs_on();
/*
* To avoid races, the caller must have gone directly from having
* interrupts fully-enabled to hard-disabled.
*/
WARN_ON(local_paca->irq_happened != PACA_IRQ_HARD_DIS);
This happens since kvmppc_prepare_to_enter does first local_irq_disable
followed by hard_irq_disable. This leaves a small window where interrupt
may occur and it could set the irq pending bit in PACA.
That local_irq_disable was necessary for PPC32 to track the lockdep
state etc. On PPC64 hard_irq_disable is good enough. There is no need to
do both. With now hard_irq_disable, doing local_irq_disable for PPC32,
just calling that is enough.
Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Fixes: 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Closes: https://lore.kernel.org/all/b8f82519-9ae5-c247-e020-e79c627e57df@xenosoft.de/
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Reviewed-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
arch/powerpc/kvm/booke.c | 1 -
arch/powerpc/kvm/powerpc.c | 8 --------
2 files changed, 9 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index aed7b476b7eb..2593f7ae6c09 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -722,7 +722,6 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
if (vcpu->arch.shared->msr & MSR_WE) {
local_irq_enable();
kvm_vcpu_halt(vcpu);
- local_irq_disable();
hard_irq_disable();
kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 9194cf492d1c..f4db7dea57b3 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -81,12 +81,6 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
int r;
WARN_ON(irqs_disabled());
- /*
- * local_irq_disable() first: on 32-bit, hard_irq_disable() alone is a
- * raw MSR[EE] clear that bypasses the lockdep/irq-tracing state, and
- * the xfer_to_guest_mode helpers assert IRQs are seen as disabled.
- */
- local_irq_disable();
hard_irq_disable();
while (true) {
@@ -101,7 +95,6 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
*/
local_irq_enable();
r = kvm_xfer_to_guest_mode_handle_work(vcpu);
- local_irq_disable();
hard_irq_disable();
if (r) {
/*
@@ -134,7 +127,6 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
local_irq_enable();
trace_kvm_check_requests(vcpu);
r = kvmppc_core_check_requests(vcpu);
- local_irq_disable();
hard_irq_disable();
if (r > 0)
continue;
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v4 3/3] KVM: PPC: Hard disable interrupts before guest entry
2026-11-17 13:16 ` [PATCH v4 3/3] KVM: PPC: Hard disable interrupts before guest entry Shrikanth Hegde
@ 2026-11-17 13:41 ` Ritesh Harjani
0 siblings, 0 replies; 7+ messages in thread
From: Ritesh Harjani @ 2026-11-17 13:41 UTC (permalink / raw)
To: Shrikanth Hegde, maddy, linuxppc-dev, chzigotzky
Cc: sshegde, mpe, npiggin, christophe.leroy, linux-kernel, msuchanek,
harshpb, gautam, amachhiw, venkat88, nnmlinux, mkchauras
Shrikanth Hegde <sshegde@linux.ibm.com> writes:
> After applying preempt disable patch, i.e PATCH 2/3, Christian reported
> a subsequent warning stopping his board to boot properly.
>
> WARNING: at .kvmppc_fix_ee_before_entry+0x10/0x28, CPU#0: qemu-system-ppc/4667
> CPU: 0 UID: 1000 PID: 4667 Comm: qemu-system-ppc Tainted: G W 7.3.0-rc4-2-powerpc64-smp #1 PREEMPT
> Tainted: [W]=WARN
> Hardware name: varisys,CYRUS5040 e5500 0x80240012 CoreNet Generic
> NIP [c00000000005dc3c] .kvmppc_fix_ee_before_entry+0x10/0x28
> LR [c00000000005f298] .kvmppc_handle_exit+0x5b4/0x5e8
> Call Trace:
> [c000000086587780] [c00000000005ee10] .kvmppc_handle_exit+0x12c/0x5e8 (unreliable)
> [c000000086587830] [c000000000062068] .kvmppc_resume_host+0xb8/0x10c
>
> It triggers below warning...
>
> static inline void kvmppc_fix_ee_before_entry(void)
> {
> trace_hardirqs_on();
>
> /*
> * To avoid races, the caller must have gone directly from having
> * interrupts fully-enabled to hard-disabled.
> */
> WARN_ON(local_paca->irq_happened != PACA_IRQ_HARD_DIS);
>
> This happens since kvmppc_prepare_to_enter does first local_irq_disable
> followed by hard_irq_disable. This leaves a small window where interrupt
> may occur and it could set the irq pending bit in PACA.
>
> That local_irq_disable was necessary for PPC32 to track the lockdep
> state etc. On PPC64 hard_irq_disable is good enough. There is no need to
> do both. With now hard_irq_disable, doing local_irq_disable for PPC32,
> just calling that is enough.
>
> Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Fixes: 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Closes: https://lore.kernel.org/all/b8f82519-9ae5-c247-e020-e79c627e57df@xenosoft.de/
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
> Reviewed-by: Narayana Murty N <nnmlinux@linux.ibm.com>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
> arch/powerpc/kvm/booke.c | 1 -
> arch/powerpc/kvm/powerpc.c | 8 --------
> 2 files changed, 9 deletions(-)
>
LGTM. Feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread