Skip to contentSkip to conversation

target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb()

PATCH In review Daniel Henrique Barboza 3 participants 3 messages Jan 21, 2022 – Jan 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb()

cpu_interrupt_exittb() was introduced by commit 044897ef4a22 ("target/ppc: Fix system lockups caused by interrupt_request state corruption") as a way to wrap cpu_interrupt() helper in BQL.

After that, commit 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM") added a condition to skip this interrupt if we're running with KVM.

Problem is that the change made by the above commit, testing for !kvm_enabled() at the start of cpu_interrupt_exittb():

static inline void cpu_interrupt_exittb(CPUState *cs)

{
    if (!kvm_enabled()) {
        return;
    }
    (... do cpu_interrupt(cs, CPU_INTERRUPT_EXITTB) ...)

is doing the opposite of what it intended to do. This will return immediately if not kvm_enabled(), i.e. it's a emulated CPU, and if kvm_enabled() it will proceed to fire CPU_INTERRUPT_EXITTB.

Fix the 'skip KVM' condition so the function is a no-op when kvm_enabled().

CC: Greg Kurz <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/809

Fixes 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM")
---
 target/ppc/helper_regs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
target/ppc/helper_regs.c +5 -1
index 8671b7bb69..7dca585ddd 100644
@@ -201,7 +201,11 @@ void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc,
 
 void cpu_interrupt_exittb(CPUState *cs)
 {
-    if (!kvm_enabled()) {
+    /*
+     * We don't need to worry about translation blocks
+     * when running with KVM.
+     */
+    if (kvm_enabled()) {
         return;
     }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Daniel Henrique Barboza

cpu_interrupt_exittb() was introduced by commit 044897ef4a22 ("target/ppc: Fix system lockups caused by interrupt_request state corruption") as a way to wrap cpu_interrupt() helper in BQL.

After that, commit 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM") added a condition to skip this interrupt if we're running with KVM.

Problem is that the change made by the above commit, testing for !kvm_enabled() at the start of cpu_interrupt_exittb():

static inline void cpu_interrupt_exittb(CPUState *cs)

{
    if (!kvm_enabled()) {
        return;
    }
    (... do cpu_interrupt(cs, CPU_INTERRUPT_EXITTB) ...)

is doing the opposite of what it intended to do. This will return immediately if not kvm_enabled(), i.e. it's a emulated CPU, and if kvm_enabled() it will proceed to fire CPU_INTERRUPT_EXITTB.

Quoted 7 lines

Fix the 'skip KVM' condition so the function is a no-op when kvm_enabled().

CC: Greg Kurz <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/809

Fixes 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM")
Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel Henrique Barboza
Quoted 18 lines · On Fri, 21 Jan 2022 13:08:41 -0300 Daniel Henrique Barboza…

cpu_interrupt_exittb() was introduced by commit 044897ef4a22 ("target/ppc: Fix system lockups caused by interrupt_request state corruption") as a way to wrap cpu_interrupt() helper in BQL.

After that, commit 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM") added a condition to skip this interrupt if we're running with KVM.

Problem is that the change made by the above commit, testing for !kvm_enabled() at the start of cpu_interrupt_exittb():

static inline void cpu_interrupt_exittb(CPUState *cs)

{
    if (!kvm_enabled()) {
        return;
    }
    (... do cpu_interrupt(cs, CPU_INTERRUPT_EXITTB) ...)
Quoted 4 lines

is doing the opposite of what it intended to do. This will return immediately if not kvm_enabled(), i.e. it's a emulated CPU, and if kvm_enabled() it will proceed to fire CPU_INTERRUPT_EXITTB.

Ohh boy... this is embarrassing :-\

Quoted 8 lines

Fix the 'skip KVM' condition so the function is a no-op when kvm_enabled().

CC: Greg Kurz <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/809

Fixes 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM")

---

Quoted 20 lines
 target/ppc/helper_regs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
target/ppc/helper_regs.c +5 -1
index 8671b7bb69..7dca585ddd 100644
@@ -201,7 +201,11 @@ void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc,
 
 void cpu_interrupt_exittb(CPUState *cs)
 {
-    if (!kvm_enabled()) {
+    /*
+     * We don't need to worry about translation blocks
+     * when running with KVM.
+     */
+    if (kvm_enabled()) {
         return;
     }