Skip to contentSkip to conversation

KVM: PPC: BookE: Fix boot hang on preemptible kernels

PATCH Superseded Shrikanth Hegde 7 participants 26 messages Sep 28 – Dec 3

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Shrikanth Hegde

author reviewer
#0 lore raw

cover KVM: PPC: BookE: Fix boot hang on preemptible kernels

Christian Zigotzky had reported that preemptible kernels don't boot on his FSL Cyrus+ board. The board freezes on running either full/lazy preemption and has been an issue for a while now.

https://lore.kernel.org/all/[email protected]/#t

After 7.0, there is only preempt=full/lazy which removed the preempt=none/voluntary workaround used to mask the issue. There was challenge is getting the console logs which made the fixes difficult since one couldn't know where the issue is.

Thanks to Michal for helping in getting the logs. That pointed at few places where the issue could be. This series is an attempt at fixing those.

Christian, KVM team,
Please *test* the patches.

Shrikanth Hegde (2):
KVM: PPC: BookE: Disable preemption before loading guest FP and
Altivec
KVM: PPC: Replay pending interrupts before entering the guest

 arch/powerpc/kvm/booke.c   |  9 ++++++++-
 arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
Signature · 1 line
2.52.0
author reviewer
#1 lore raw

PATCH 1/2 KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

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 disabling the preemption using the preempt disable. Note, it is calling noresched variant of preempt enable, since hard irq are disabled. It is likely not a good idea to call schedule.

Fixes 3efc7da61f6c ("KVM: PPC: Book3E: Increase FPU laziness")
---
 arch/powerpc/kvm/booke.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/powerpc/kvm/booke.c +8 -1
index 13ad4cf5fa71..5b9118eefe1d 100644
@@ -1404,10 +1404,17 @@ 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() marks the software
+			 * IRQ state enabled while interrupts are still
+			 * hard-disabled. So disable preemption while loading
+			 * guest FP and Altivec.
+			 */
 			kvmppc_fix_ee_before_entry();
+			preempt_disable();
 			kvmppc_load_guest_fp(vcpu);
 			kvmppc_load_guest_altivec(vcpu);
+			preempt_enable_no_resched();
 		}
 	}
 
Signature · 1 line
2.52.0
author reviewer
#17 lore raw

PATCH 2/2 KVM: PPC: Replay pending interrupts before entering the guest

In reply to Shrikanth Hegde

After applying preempt disable patch, i.e PATCH 1/2, 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. When that happens replay that interrupt before entering the guest.

Fixes 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
---
 arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/powerpc/kvm/powerpc.c +13 -0
index 9194cf492d1c..847ff07c364b 100644
@@ -147,6 +147,19 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
 			continue;
 		}
 
+#ifdef CONFIG_PPC64
+		/*
+		 * Interrupt arrived between the soft and hard
+		 * disable. Replay it and retry guest entry.
+		 */
+		if (unlikely(local_paca->irq_happened != PACA_IRQ_HARD_DIS)) {
+			local_irq_enable();
+			local_irq_disable();
+			hard_irq_disable();
+			continue;
+		}
+#endif
+
 		guest_enter_irqoff();
 		return 1;
 	}
Signature · 1 line
2.52.0
Tested-by on the v1 series
#23 lore raw
In reply to Shrikanth Hegde
Quoted 18 lines · Shrikanth Hegde

Christian Zigotzky had reported that preemptible kernels don't boot on his FSL Cyrus+ board. The board freezes on running either full/lazy preemption and has been an issue for a while now.

https://lore.kernel.org/all/[email protected]/#t

After 7.0, there is only preempt=full/lazy which removed the preempt=none/voluntary workaround used to mask the issue. There was challenge is getting the console logs which made the fixes difficult since one couldn't know where the issue is.

Thanks to Michal for helping in getting the logs. That pointed at few places where the issue could be. This series is an attempt at fixing those.

Christian, KVM team,
Please *test* the patches.

Quoted 9 lines

Shrikanth Hegde (2):
KVM: PPC: BookE: Disable preemption before loading guest FP and
Altivec
KVM: PPC: Replay pending interrupts before entering the guest

  arch/powerpc/kvm/booke.c   |  9 ++++++++-
  arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
  2 files changed, 21 insertions(+), 1 deletion(-)

Hi,

I was able to compile the RC5 of kernel 7.3 with your patches today. :-) [1]

After that I successfully tested it with KVM PR and KVM HV on my PowerPC machines.

Many thanks for your help,

Christian

[1] https://github.com/chzigotzky/kernels/releases/tag/v7.3.0-rc5-2

Signature · 1 line
Sent with BrassMonkey 34.3.2.1 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_34.3.2.1)
#2 lore raw

Re: [PATCH 1/2] KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

In reply to Shrikanth Hegde

Hi Shrikanth,
Thanks for the fixes. I had one question on patch 1.

Quoted 51 lines · Shrikanth Hegde

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 disabling the preemption using the preempt disable. Note, it is calling noresched variant of preempt enable, since hard irq are disabled. It is likely not a good idea to call schedule.

Fixes 3efc7da61f6c ("KVM: PPC: Book3E: Increase FPU laziness")
---
  arch/powerpc/kvm/booke.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
arch/powerpc/kvm/booke.c +1 -1
index 13ad4cf5fa71..5b9118eefe1d 100644
@@ -1404,10 +1404,17 @@ 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 */
+			/*

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) · line 1417

Quoted 10 lines
arch/powerpc/kvm/booke.c +7 -0
+			 * kvmppc_fix_ee_before_entry() marks the software
+			 * IRQ state enabled while interrupts are still
+			 * hard-disabled. So disable preemption while loading
+			 * guest FP and Altivec.
+			 */
  			kvmppc_fix_ee_before_entry();
+			preempt_disable();
  			kvmppc_load_guest_fp(vcpu);
  			kvmppc_load_guest_altivec(vcpu);
+			preempt_enable_no_resched();

Would it be simpler to move kvmppc_fix_ee_before_entry() after the FP/Altivec loads instead?

The normal kvmppc_vcpu_run() entry path already loads the guest FP/Altivec state while interrupts are still disabled and calls kvmppc_fix_ee_before_entry() immediately before entering the guest.

So could this path follow the same ordering:

kvmppc_load_guest_fp(vcpu);
kvmppc_load_guest_altivec(vcpu);
kvmppc_fix_ee_before_entry();

That would avoid making the software IRQ state enabled before loading the guest FP/Altivec state, and also avoid the additional preempt_disable()/preempt_enable_no_resched() pair.

Thanks,
Narayana Murty.

Quoted 3 lines
arch/powerpc/kvm/booke.c +0 -0
  		}
  	}
 
#18 lore raw

Re: [PATCH 2/2] KVM: PPC: Replay pending interrupts before entering the guest

In reply to Shrikanth Hegde

Hi Shrikanth,

Quoted 52 lines · Shrikanth Hegde

After applying preempt disable patch, i.e PATCH 1/2, 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. When that happens replay that interrupt before entering the guest.

Fixes 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
---
  arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
arch/powerpc/kvm/powerpc.c +6 -0
index 9194cf492d1c..847ff07c364b 100644
@@ -147,6 +147,19 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
  			continue;
  		}
 
+#ifdef CONFIG_PPC64
+		/*
+		 * Interrupt arrived between the soft and hard
+		 * disable. Replay it and retry guest entry.
+		 */
+		if (unlikely(local_paca->irq_happened != PACA_IRQ_HARD_DIS)) {

arch/powerpc/kvm/powerpc.c int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) · line 165

Quoted 10 lines
arch/powerpc/kvm/powerpc.c +7 -0
+			local_irq_enable();
+			local_irq_disable();
+			hard_irq_disable();
+			continue;
+		}
+#endif
+
  		guest_enter_irqoff();
  		return 1;
  	}

It look good to me.

Thanks,
Narayana

author reviewer
#3 lore raw

Re: [PATCH 1/2] KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

In reply to Narayana Murty N

Hi Narayana.

Quoted 2 lines · Narayana Murty N

Hi Shrikanth,
Thanks for the fixes. I had one question on patch 1.

See response below.

Quoted 34 lines
Quoted 11 lines
arch/powerpc/kvm/booke.c +1 -1
index 13ad4cf5fa71..5b9118eefe1d 100644
@@ -1404,10 +1404,17 @@ 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 */
+            /*

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) · line 1417

Quoted 10 lines
arch/powerpc/kvm/booke.c +7 -0
+             * kvmppc_fix_ee_before_entry() marks the software
+             * IRQ state enabled while interrupts are still
+             * hard-disabled. So disable preemption while loading
+             * guest FP and Altivec.
+             */
               kvmppc_fix_ee_before_entry();
+            preempt_disable();
               kvmppc_load_guest_fp(vcpu);
               kvmppc_load_guest_altivec(vcpu);
+            preempt_enable_no_resched();

Would it be simpler to move kvmppc_fix_ee_before_entry() after the FP/Altivec loads instead?

The normal kvmppc_vcpu_run() entry path already loads the guest FP/Altivec state while interrupts are still disabled and calls kvmppc_fix_ee_before_entry() immediately before entering the guest.

So could this path follow the same ordering:

kvmppc_load_guest_fp(vcpu);
kvmppc_load_guest_altivec(vcpu);
kvmppc_fix_ee_before_entry();

Quoted 9 lines

That would avoid making the software IRQ state enabled before loading the guest FP/Altivec state, and also avoid the additional preempt_disable()/preempt_enable_no_resched() pair.

Thanks,
Narayana Murty.

Quoted 2 lines
arch/powerpc/kvm/booke.c +0 -0
           }
       }

I thought I had put that for discussion after ---, but looks like I forgot.

I don't mind the above too. but I didn't have a way to test it. So kept it as is based on what Christian said works for him.

If you have a way to test the patches, please let me know. We can try that too.

author reviewer
#19 lore raw

Re: [PATCH 2/2] KVM: PPC: Replay pending interrupts before entering the guest

In reply to Narayana Murty N

Hi Narayana,

Quoted 17 lines
Quoted 17 lines
arch/powerpc/kvm/powerpc.c +10 -0
index 9194cf492d1c..847ff07c364b 100644
@@ -147,6 +147,19 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
               continue;
           }
+#ifdef CONFIG_PPC64
+        /*
+         * Interrupt arrived between the soft and hard
+         * disable. Replay it and retry guest entry.
+         */
+        if (unlikely(local_paca->irq_happened != PACA_IRQ_HARD_DIS)) {
+            local_irq_enable();
+            local_irq_disable();
+            hard_irq_disable();
+            continue;
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) · line 165

Quoted 6 lines
arch/powerpc/kvm/powerpc.c +3 -0
+        }
+#endif
+
           guest_enter_irqoff();
           return 1;
       }

It look good to me.

Thanks.

Quoted 4 lines

Thanks,
Narayana

Do you want me to consider the above as rwb tag? If yes, I prefer to see explicit tag.

#24 lore raw
In reply to Christian Zigotzky
Quoted 35 lines · Christian Zigotzky
Quoted 19 lines · Shrikanth Hegde

Christian Zigotzky had reported that preemptible kernels don't boot on his FSL Cyrus+ board. The board freezes on running either full/lazy preemption and has been an issue for a while now.

https://lore.kernel.org/all/[email protected]/#t

After 7.0, there is only preempt=full/lazy which removed the preempt=none/voluntary workaround used to mask the issue. There was challenge is getting the console logs which made the fixes difficult since one couldn't know where the issue is.

Thanks to Michal for helping in getting the logs. That pointed at few places where the issue could be. This series is an attempt at fixing those.

Christian, KVM team,
Please *test* the patches.

Quoted 9 lines

Shrikanth Hegde (2):
   KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec
   KVM: PPC: Replay pending interrupts before entering the guest

  arch/powerpc/kvm/booke.c   |  9 ++++++++-
  arch/powerpc/kvm/powerpc.c | 13 +++++++++++++

  2 files changed, 21 insertions(+), 1 deletion(-)

Hi,

I was able to compile the RC5 of kernel 7.3 with your patches today. :-) [1]

After that I successfully tested it with KVM PR and KVM HV on my PowerPC machines.

Quoted 10 lines

Many thanks for your help,

Christian

[1] https://github.com/chzigotzky/kernels/releases/tag/v7.3.0-rc5-2

Hi,

is it possible to add these patches to the kernel 7.4?

Thanks,
Christian

Signature · 1 line
Sent with BrassMonkey 35.0.2 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_35.0.2)
#4 lore raw

Re: [PATCH 1/2] KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

In reply to Shrikanth Hegde
Quoted 42 lines · Shrikanth Hegde

Hi Narayana.

Quoted 2 lines · Narayana Murty N

Hi Shrikanth,
Thanks for the fixes. I had one question on patch 1.

See response below.

Quoted 34 lines
Quoted 11 lines
arch/powerpc/kvm/booke.c +1 -1
index 13ad4cf5fa71..5b9118eefe1d 100644
@@ -1404,10 +1404,17 @@ 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 */
+            /*

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) · line 1417

Quoted 10 lines
arch/powerpc/kvm/booke.c +7 -0
+             * kvmppc_fix_ee_before_entry() marks the software
+             * IRQ state enabled while interrupts are still
+             * hard-disabled. So disable preemption while loading
+             * guest FP and Altivec.
+             */
               kvmppc_fix_ee_before_entry();
+            preempt_disable();
               kvmppc_load_guest_fp(vcpu);
               kvmppc_load_guest_altivec(vcpu);
+            preempt_enable_no_resched();

Would it be simpler to move kvmppc_fix_ee_before_entry() after the FP/Altivec loads instead?

The normal kvmppc_vcpu_run() entry path already loads the guest FP/Altivec state while interrupts are still disabled and calls kvmppc_fix_ee_before_entry() immediately before entering the guest.

So could this path follow the same ordering:

kvmppc_load_guest_fp(vcpu);
kvmppc_load_guest_altivec(vcpu);
kvmppc_fix_ee_before_entry();

Thanks Narayana, that actually make more sense to me.

Quoted 6 lines
Quoted 6 lines

That would avoid making the software IRQ state enabled before loading the guest FP/Altivec state, and also avoid the additional preempt_disable()/preempt_enable_no_resched() pair.

Thanks,
Narayana Murty.

Quoted 7 lines
Quoted 3 lines

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) · line 1419

Quoted 2 lines
arch/powerpc/kvm/booke.c +0 -0
           }
       }

I thought I had put that for discussion after ---, but looks like I forgot.

I don't mind the above too. but I didn't have a way to test it.

Actually I agree with Narayan's reasoning here.

Sorry for being so late to the game. As you know we have been occupied with other things internally.

Quoted 3 lines

So kept it as is based on what Christian said works for him. If you have a way to test the patches, please let me know. We can try that too.

Let's ask Christian directly :)
@Christian - Once we have v2, would you kindly help us test that please?

We think the other approach which Narayana suggested might be a better fix for this and it can avoid preempt_enable/disable() dance. However, looks like we may not have the board where we can reproduce this.

-ritesh

#21 lore raw

Re: [PATCH 2/2] KVM: PPC: Replay pending interrupts before entering the guest

In reply to Shrikanth Hegde

Hi Shrikanth,

Quoted 49 lines · Shrikanth Hegde

After applying preempt disable patch, i.e PATCH 1/2, 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. When that happens replay that interrupt before entering the guest.

Fixes 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
---
 arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/powerpc/kvm/powerpc.c +3 -0
index 9194cf492d1c..847ff07c364b 100644
@@ -147,6 +147,19 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
 			continue;
 		}
 
+#ifdef CONFIG_PPC64
+		/*
+		 * Interrupt arrived between the soft and hard

arch/powerpc/kvm/powerpc.c int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) · line 162

Quoted 10 lines
arch/powerpc/kvm/powerpc.c +10 -0
+		 * disable. Replay it and retry guest entry.
+		 */
+		if (unlikely(local_paca->irq_happened != PACA_IRQ_HARD_DIS)) {
+			local_irq_enable();
+			local_irq_disable();
+			hard_irq_disable();
+			continue;
+		}
+#endif
+

I looked at the commit which causes this regression, I see there are few more call sites which can hit the same WARN in kvmppc_fix_ee_before_entry().

So what I was thinking was - while we are at it - do you think we could use the following helper instead of {local|hard}_irq_{disable|enable}() pair and ...

/*
* Hard disable interrupts before entering the guest.
*
* On 64-bit don't use local_irq_disable() here. It only soft-masks, so
* an interrupt can still come in before we hard disable. That interrupt
* gets marked pending in irq_happened and kvmppc_fix_ee_before_entry()
* then throws it away. hard_irq_disable() clears MSR[EE] first and does
* the irq tracing itself, so there's no such window.
*
* On 32-bit there is no soft mask and hard_irq_disable() doesn't do the
* irq tracing, so use local_irq_disable().
*/
static inline void kvmppc_irq_disable_for_entry(void)
{

#ifdef CONFIG_PPC64
        hard_irq_disable();
#else
        local_irq_disable();

#endif
}

... and then update the other call sites too which the following commit added - which can cause the WARN.

Fixes 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")

Thoughts?

-ritesh

Quoted 5 lines
arch/powerpc/kvm/powerpc.c +0 -0
 		guest_enter_irqoff();
 		return 1;
 	}
Signature · 1 line
2.52.0
#5 lore raw

Re: [PATCH 1/2] KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

In reply to Ritesh Harjani (IBM)
Quoted 68 lines · Ritesh Harjani (IBM)
Quoted 40 lines · Shrikanth Hegde

Hi Narayana.

Quoted 2 lines · Narayana Murty N

Hi Shrikanth,
Thanks for the fixes. I had one question on patch 1.

See response below.

Quoted 33 lines
Quoted 10 lines
arch/powerpc/kvm/booke.c +1 -1
index 13ad4cf5fa71..5b9118eefe1d 100644
@@ -1404,10 +1404,17 @@ 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 */
+            /*

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) · line 1417

Quoted 10 lines
arch/powerpc/kvm/booke.c +7 -0
+             * kvmppc_fix_ee_before_entry() marks the software
+             * IRQ state enabled while interrupts are still
+             * hard-disabled. So disable preemption while loading
+             * guest FP and Altivec.
+             */
               kvmppc_fix_ee_before_entry();
+            preempt_disable();
               kvmppc_load_guest_fp(vcpu);
               kvmppc_load_guest_altivec(vcpu);
+            preempt_enable_no_resched();

Would it be simpler to move kvmppc_fix_ee_before_entry() after the FP/Altivec loads instead?

The normal kvmppc_vcpu_run() entry path already loads the guest FP/Altivec state while interrupts are still disabled and calls kvmppc_fix_ee_before_entry() immediately before entering the guest.

So could this path follow the same ordering:

kvmppc_load_guest_fp(vcpu);
kvmppc_load_guest_altivec(vcpu);
kvmppc_fix_ee_before_entry();

Thanks Narayana, that actually make more sense to me.

Quoted 11 lines
Quoted 8 lines

That would avoid making the software IRQ state enabled before loading the guest FP/Altivec state, and also avoid the additional preempt_disable()/preempt_enable_no_resched() pair.

Thanks,
Narayana Murty.

Quoted 2 lines
arch/powerpc/kvm/booke.c +0 -0
           }
       }

I thought I had put that for discussion after ---, but looks like I forgot.

I don't mind the above too. but I didn't have a way to test it.

Actually I agree with Narayan's reasoning here.

Sorry for being so late to the game. As you know we have been occupied with other things internally.

Quoted 3 lines

So kept it as is based on what Christian said works for him. If you have a way to test the patches, please let me know. We can try that too.

Let's ask Christian directly :)
@Christian - Once we have v2, would you kindly help us test that please?

Quoted 7 lines

We think the other approach which Narayana suggested might be a better fix for this and it can avoid preempt_enable/disable() dance. However, looks like we may not have the board where we can reproduce this.

-ritesh

Yes, I can help with testing.

- Christian

Signature · 1 line
Sent with BrassMonkey 35.0.2 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_35.0.2)
#16 lore raw

PATCH 1/1 powerpc/pasemi: Defer Nemo IRQ initialization

In reply to Ritesh Harjani (IBM)
Quoted 11 lines · Ritesh Harjani (IBM)

Let's ask Christian directly :)
@Christian - Once we have v2, would you kindly help us test that please?

We think the other approach which Narayana suggested might be a better fix for this and it can avoid preempt_enable/disable() dance. However, looks like we may not have the board where we can reproduce this.

-ritesh

Hi all,

Is it possible to add the following patch to the kernel?

It is more important for us because the Nemo board can't boot without this patch.

Thanks,
Christian

Signature · 1 line
Sent with BrassMonkey 35.0.2 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_35.0.2)
author reviewer
#6 lore raw

Re: [PATCH 1/2] KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

In reply to Christian Zigotzky

Hi.

Quoted 74 lines · Christian Zigotzky
Quoted 73 lines · Ritesh Harjani (IBM)
Quoted 40 lines · Shrikanth Hegde

Hi Narayana.

Quoted 2 lines · Narayana Murty N

Hi Shrikanth,
Thanks for the fixes. I had one question on patch 1.

See response below.

Quoted 33 lines
Quoted 10 lines
arch/powerpc/kvm/booke.c +1 -1
index 13ad4cf5fa71..5b9118eefe1d 100644
@@ -1404,10 +1404,17 @@ 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 */
+            /*

arch/powerpc/kvm/booke.c int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr) · line 1417

Quoted 10 lines
arch/powerpc/kvm/booke.c +7 -0
+             * kvmppc_fix_ee_before_entry() marks the software
+             * IRQ state enabled while interrupts are still
+             * hard-disabled. So disable preemption while loading
+             * guest FP and Altivec.
+             */
                kvmppc_fix_ee_before_entry();
+            preempt_disable();
                kvmppc_load_guest_fp(vcpu);
                kvmppc_load_guest_altivec(vcpu);
+            preempt_enable_no_resched();

Would it be simpler to move kvmppc_fix_ee_before_entry() after the FP/Altivec loads instead?

The normal kvmppc_vcpu_run() entry path already loads the guest FP/Altivec state while interrupts are still disabled and calls kvmppc_fix_ee_before_entry() immediately before entering the guest.

So could this path follow the same ordering:

kvmppc_load_guest_fp(vcpu);
kvmppc_load_guest_altivec(vcpu);
kvmppc_fix_ee_before_entry();

Thanks Narayana, that actually make more sense to me.

Quoted 11 lines
Quoted 8 lines

That would avoid making the software IRQ state enabled before loading the guest FP/Altivec state, and also avoid the additional preempt_disable()/preempt_enable_no_resched() pair.

Thanks,
Narayana Murty.

Quoted 2 lines
arch/powerpc/kvm/booke.c +0 -0
            }
        }

I thought I had put that for discussion after ---, but looks like I forgot.

I don't mind the above too.  but I didn't have a way to test it.

Actually I agree with Narayan's reasoning here.

Sorry for being so late to the game. As you know we have been occupied with other things internally.

Quoted 3 lines

So kept it as is based on what Christian said works for him. If you have a way to test the patches, please let me know. We can try that too.

Let's ask Christian directly :)
@Christian - Once we have v2, would you kindly help us test that please?

We think the other approach which Narayana suggested might be a better fix for this and it can avoid preempt_enable/disable() dance. However, looks like we may not have the board where we can reproduce this.

Quoted 5 lines
Quoted 2 lines

-ritesh

Yes, I can help with testing.

Thanks Christian.

Quoted 2 lines

- Christian

Hi Ritesh, Narayana,

I am afraid I won't be able to work on this at-least for couple of weeks from now.

If v2 can be worked upon by our kvm team meanwhile, it would be helpful. It is always good to fix long standing bugs sooner.

Where applicable, feel free to carry the tags.

#22 lore raw

Re: [PATCH 2/2] KVM: PPC: Replay pending interrupts before entering the guest

In reply to Ritesh Harjani (IBM)
Quoted 91 lines · Ritesh Harjani

Hi Shrikanth,

Quoted 49 lines · Shrikanth Hegde

After applying preempt disable patch, i.e PATCH 1/2, 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. When that happens replay that interrupt before entering the guest.

Fixes 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")
---
 arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/powerpc/kvm/powerpc.c +3 -0
index 9194cf492d1c..847ff07c364b 100644
@@ -147,6 +147,19 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
 			continue;
 		}
 
+#ifdef CONFIG_PPC64
+		/*
+		 * Interrupt arrived between the soft and hard

arch/powerpc/kvm/powerpc.c int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) · line 162

Quoted 10 lines
arch/powerpc/kvm/powerpc.c +10 -0
+		 * disable. Replay it and retry guest entry.
+		 */
+		if (unlikely(local_paca->irq_happened != PACA_IRQ_HARD_DIS)) {
+			local_irq_enable();
+			local_irq_disable();
+			hard_irq_disable();
+			continue;
+		}
+#endif
+

I looked at the commit which causes this regression, I see there are few more call sites which can hit the same WARN in kvmppc_fix_ee_before_entry().

So what I was thinking was - while we are at it - do you think we could use the following helper instead of {local|hard}_irq_{disable|enable}() pair and ...

/*
* Hard disable interrupts before entering the guest.
*
* On 64-bit don't use local_irq_disable() here. It only soft-masks, so
* an interrupt can still come in before we hard disable. That interrupt
* gets marked pending in irq_happened and kvmppc_fix_ee_before_entry()
* then throws it away. hard_irq_disable() clears MSR[EE] first and does
* the irq tracing itself, so there's no such window.
*
* On 32-bit there is no soft mask and hard_irq_disable() doesn't do the
* irq tracing, so use local_irq_disable().
*/
static inline void kvmppc_irq_disable_for_entry(void)
{

#ifdef CONFIG_PPC64
        hard_irq_disable();
#else
        local_irq_disable();
Quoted 9 lines

#endif
}

... and then update the other call sites too which the following commit added - which can cause the WARN.

Fixes 12013e3d4695 ("KVM: powerpc: Use generic xfer to guest work function")

Thoughts?

Yeah, i also feel this is better to have.
Personally i don't want this ifdef all around the code, It's better to have it in one place.
There's one more case like this here[1].

[1]https://lore.kernel.org/all/a14571be1897955f43d9994f0e093de3ada6ecde.1793447880.git.ritesh.list@gmail.com/

Regards,
Mukesh

Quoted 7 lines

-ritesh

Quoted 5 lines
arch/powerpc/kvm/powerpc.c +0 -0
 		guest_enter_irqoff();
 		return 1;
 	}
Signature · 1 line
2.52.0
#7 lore raw

Re: [PATCH 1/2] KVM: PPC: BookE: Disable preemption before loading guest FP and Altivec

In reply to Shrikanth Hegde

On 02 November 2026 at 2:07 pm, Shrikanth Hegde <[email protected]> wrote:

Hi.

On 11/1/26 1:58 PM, Christian Zigotzky wrote:

Yes, I can help with testing.

- - -

Thanks Christian.

- - -

Hi all,

Ever since we enabled PREEMPT on our Nemo boards [1], we have been experiencing occasional problems with the kernel stack.

Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: srcu_gp_start_if_needed+0x534/0x538

Rebooting in 180 seconds..

We are using the following patches: [2] [3]

We have disabled PREEMPT with a patch [4] again, and since then our Nemo boards have been running perfectly once more.

As the problem with the kernel stack only occurs sporadically, bisection is impossible.

I hope you can fix the kernel stack issue.

Thanks,
Christian

[1] https://en.wikipedia.org/wiki/AmigaOne_X1000

[2] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/preempt_v1.patch

[3] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/kvm_powerpc.patch

[4] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/Kconfig.preempt.patch

[5] Kernel config: https://raw.githubusercontent.com/chzigotzky/kernels/31c064092e3aab0875c47d44838443c9515b2970/configs/x1000_defconfig

#8 lore raw

[PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

Hi all,

Ever since we enabled PREEMPT on our Nemo boards [1], we have been experiencing occasional problems with the kernel stack.

Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: srcu_gp_start_if_needed+0x534/0x538

Rebooting in 180 seconds..

We are using the following patches: [2] [3]

We have disabled PREEMPT with a patch [4] again, and since then our Nemo boards have been running perfectly once more.

As the problem with the kernel stack only occurs sporadically, bisection is impossible.

I hope you can fix the kernel stack issue.

Thanks,
Christian

[1] https://en.wikipedia.org/wiki/AmigaOne_X1000

[2] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/preempt_v1.patch

[3] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/kvm_powerpc.patch

[4] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/Kconfig.preempt.patch

[5] Kernel config: https://raw.githubusercontent.com/chzigotzky/kernels/31c064092e3aab0875c47d44838443c9515b2970/configs/x1000_defconfig

Signature · 1 line
Sent with BrassMonkey 35.0.2 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_35.0.2)
author reviewer
#9 lore raw

Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

Hi Christian.

Quoted 7 lines · Christian Zigotzky

Hi all,

Ever since we enabled PREEMPT on our Nemo boards [1], we have been experiencing occasional problems with the kernel stack.

Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: srcu_gp_start_if_needed+0x534/0x538

Rebooting in 180 seconds..

We had one known issue which michal had brought up. Do you have tracing enabled or running a bpf/bcc program?

This is the fix already in upstream. Do you have this patch?
https://lore.kernel.org/all/[email protected]/#t

Quoted 21 lines

We are using the following patches: [2] [3]

We have disabled PREEMPT with a patch [4] again, and since then our Nemo boards have been running perfectly once more.

As the problem with the kernel stack only occurs sporadically, bisection is impossible.

I hope you can fix the kernel stack issue.

Thanks,
Christian

[1] https://en.wikipedia.org/wiki/AmigaOne_X1000

[2] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/preempt_v1.patch

[3] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/kvm_powerpc.patch

[4] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/Kconfig.preempt.patch

[5] Kernel config: https://raw.githubusercontent.com/chzigotzky/kernels/31c064092e3aab0875c47d44838443c9515b2970/configs/x1000_defconfig

author reviewer
#25 lore raw
In reply to Shrikanth Hegde

Hi.

Quoted 18 lines · Shrikanth Hegde

Christian Zigotzky had reported that preemptible kernels don't boot on his FSL Cyrus+ board. The board freezes on running either full/lazy preemption and has been an issue for a while now.

https://lore.kernel.org/all/[email protected]/#t

After 7.0, there is only preempt=full/lazy which removed the preempt=none/voluntary workaround used to mask the issue. There was challenge is getting the console logs which made the fixes difficult since one couldn't know where the issue is.

Thanks to Michal for helping in getting the logs. That pointed at few places where the issue could be. This series is an attempt at fixing those.

Christian, KVM team,
Please *test* the patches.

Quoted 9 lines

Shrikanth Hegde (2):
KVM: PPC: BookE: Disable preemption before loading guest FP and
Altivec
KVM: PPC: Replay pending interrupts before entering the guest

  arch/powerpc/kvm/booke.c   |  9 ++++++++-
  arch/powerpc/kvm/powerpc.c | 13 +++++++++++++
  2 files changed, 21 insertions(+), 1 deletion(-)

All the suggested changes makes sense. I will plan to send out version soon. Hopefully mid next week.

1. Re-order in below way.

	kvmppc_load_guest_fp(vcpu);
	kvmppc_load_guest_altivec(vcpu);
	kvmppc_fix_ee_before_entry();

2. Define a common helper. I am thinking to name it as ppc_hard_irq_disable(). Since suggestion was also to be used in the entry code.
Other names i could think of are local_hard_irq_disable, arch_hard_irq_disable, local_irq_disable_hard.

#10 lore raw

Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

In reply to Shrikanth Hegde
Quoted 11 lines · Shrikanth Hegde

Hi Christian.

Quoted 7 lines · Christian Zigotzky

Hi all,

Ever since we enabled PREEMPT on our Nemo boards [1], we have been experiencing occasional problems with the kernel stack.

Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: srcu_gp_start_if_needed+0x534/0x538

Rebooting in 180 seconds..

Quoted 28 lines

We had one known issue which michal had brought up. Do you have tracing enabled or running a bpf/bcc program?

This is the fix already in upstream. Do you have this patch?
https://lore.kernel.org/all/[email protected]/#t

Quoted 21 lines

We are using the following patches: [2] [3]

We have disabled PREEMPT with a patch [4] again, and since then our Nemo boards have been running perfectly once more.

As the problem with the kernel stack only occurs sporadically, bisection is impossible.

I hope you can fix the kernel stack issue.

Thanks,
Christian

[1] https://en.wikipedia.org/wiki/AmigaOne_X1000

[2] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/preempt_v1.patch

[3] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/kvm_powerpc.patch

[4] https://raw.githubusercontent.com/chzigotzky/kernels/refs/heads/main/patches/X1000/Kconfig.preempt.patch

[5] Kernel config: https://raw.githubusercontent.com/chzigotzky/kernels/31c064092e3aab0875c47d44838443c9515b2970/configs/x1000_defconfig

Hi,

We still have stack issues if we using preempt kernels. The patch above doesn't solve this issue. I created a patch for disabling preempt for Nemo boards.

arch/powerpc/platforms/pasemi/Kconfig    2026-11-24 13:17:52.878712432 +0100 renamed from arch/powerpc/platforms/pasemi/Kconfig    2026-11-22 23:57:40.000000000 +0100 +0 -0
diff -rupN a/arch/powerpc/platforms/pasemi/Kconfig b/arch/powerpc/platforms/pasemi/Kconfig
@@ -19,6 +19,7 @@ config PPC_PASEMI_NEMO

     bool "Nemo motherboard Support"
     depends on PPC_PASEMI
     select PPC_I8259
+    select ARCH_NO_PREEMPT
     help
       This option enables support for the 'Nemo' motherboard used in A-Eons's Amigaone X1000. This consists of some

---

It is very difficult to figure out what the issue is because it occurs sporadically.

Cheers,
Christian

#12 lore raw

Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

On 06 November 2026 at 07:09 am, Shrikanth Hegde wrote:

Hi Christian.

We had one known issue which michal had brought up. Do you have tracing enabled or running a bpf/bcc program?

- - -

Yes, we have BPF and Tracing activated in the kernel config.

Nemo kernel config: https://github.com/chzigotzky/kernels/blob/main/configs/x1000_defconfig

Edit: I have deactivated tracing

author reviewer
#13 lore raw

Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

Quoted 9 lines · Christian Zigotzky

On 06 November 2026 at 07:09 am, Shrikanth Hegde wrote:

Hi Christian.

We had one known issue which michal had brought up. Do you have tracing enabled or running a bpf/bcc program?

- - -

Quoted 7 lines

Yes, we have BPF and Tracing activated in the kernel config.

Nemo kernel config: https://github.com/chzigotzky/kernels/blob/main/configs/x1000_defconfig

Edit: I have deactivated tracing

If possible, please share the logs. Lets see if it gives any clues. Is it while system is idle or running some workload?

#14 lore raw

Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

Quoted 14 lines · Shrikanth Hegde
Quoted 11 lines · Christian Zigotzky

On 06 November 2026 at 07:09 am, Shrikanth Hegde wrote:

Hi Christian.

We had one known issue which michal had brought up. Do you have tracing enabled or running a bpf/bcc program?

- - -

Yes, we have BPF and Tracing activated in the kernel config.

Quoted 8 lines
Quoted 5 lines

Nemo kernel config: https://github.com/chzigotzky/kernels/blob/main/configs/x1000_defconfig

Edit: I have deactivated tracing

If possible, please share the logs. Lets see if it gives any clues. Is it while system is idle or running some workload?

It occurs sporadically during workloads. Disabling tracing did not solve the issue.

Log: https://github.com/user-attachments/files/35445406/Nemo_kernel_preempt_with_stack_issue.log

Link to the bug report: https://github.com/chzigotzky/kernels/issues/22

-- Christian

Signature · 1 line
Sent with BrassMonkey 35.0.2 (https://github.com/chzigotzky/Web-Browsers-and-Suites-for-Linux-PPC/releases/tag/BrassMonkey_35.0.2)
#15 lore raw

Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

Hello everyone.

Quoted 6 lines · Christian Zigotzky

It occurs sporadically during workloads. Disabling tracing did not solve the issue.

Log: https://github.com/user-attachments/files/35445406/Nemo_kernel_preempt_with_stack_issue.log

Link to the bug report: https://github.com/chzigotzky/kernels/issues/22

I'm also gathering data on this and finding the bug to be very stubborn. I have a Debia/sid install which I booted with a 7.3.0 kernel build and it showed up immediately. Then a few boots later disappeared. I also have Debian based Mint install which I tested and produced the error from same kernel. From this I collected logs. However, the kernel is unwilling to give any stack trace and just stops dead with a function offset. I have a serial terminal attached I can collect logs from so it may need extra debug options enabled in config. Don't know why it gives barely any info since a panic is usually considered a major show stopper. Also stopping dead like that isn't helpful when it needs advanced debugging tools to extract the info live from dead kernel memory.

Linux version 7.3.0-powerpc64-smp (testuser@build02) (powerpc-linux-gnu-gcc (Debian 9.3.0-22) 9.3.0, GNU ld (GNU Binutils for Debian) 2.44) # SMP PREEMPT

I have found it can panic on boot, panic in use like editing inside a browser, or panic on shutdown.

In my case it has happened in: srcu_gp_start_if_needed+0x510/0x514

Some ASM near crash site:

c00000000014a508 <srcu_gp_start_if_needed>:
c00000000014a508:    3c 4c 02 0e     addis   r2,r12,526 c00000000014a50c:    38 42 95 f8     addi    r2,r2,-27144 c00000000014a510:    7c 08 02 a6     mflr    r0 c00000000014a514:    4b ef 78 f5     bl      c000000000041e08 <_mcount>

...

c00000000014a6e8:    e9 21 00 48     ld   r9,72(r1)
c00000000014a6ec:    e9 4a 08 70     ld      r10,2160(r10)
c00000000014a6f0:    7d 29 52 79     xor.    r9,r9,r10
c00000000014a6f4:    39 40 00 00     li      r10,0
c00000000014a6f8:    40 82 03 18     bne     c00000000014aa10 <srcu_gp_start_if_needed+0x508>

...

c00000000014aa04:    60 00 00 00     nop
c00000000014aa08:    40 92 ff 24     bne     cr4,c00000000014a92c <srcu_gp_start_if_needed+0x424> c00000000014aa0c:    4b ff ff 50     b       c00000000014a95c <srcu_gp_start_if_needed+0x454> c00000000014aa10:    fa e1 00 58     std     r23,88(r1)
c00000000014aa14:    49 77 50 11     bl      c0000000018bfa24 <__stack_chk_fail+0x8> c00000000014aa18:    60 00 00 00     nop
c00000000014aa1c <call_srcu>:

That 0x510 offset should correspond to C00000000014AA18 after __stack_chk_fail call. Which would be return address. I can see the routine at c00000000014a6f8 above is branching to c00000000014aa10 when the stack canary fails.

In the source tree from function here:

https://github.com/torvalds/linux/blob/v7.3/kernel/rcu/srcutree.c#L1284

Would also help if some small code could be written that causes the srcu_gp_start_if_needed function to always fail with a stress test.

Now, I also found this article on a stack crash from same function. So this looks like an old issue. Possibly due to compiler clobbering over r13 and the paca, which I recently found out what it was, due to compiler optimising away and effectively killing the canary.

https://www.joelfernandes.org/blog/2023-04-25/ppc-stack-guards.html

Signature · 3 lines
My regards,

Damien Stewart.