All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb()
@ 2022-01-21 16:08 Daniel Henrique Barboza
  2022-01-21 18:32 ` Fabiano Rosas
  2022-01-25  9:12 ` Greg Kurz
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Henrique Barboza @ 2022-01-21 16:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Daniel Henrique Barboza, qemu-ppc, clg, david

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 <groug@kaod.org>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/809
Fixes: 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM")
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/ppc/helper_regs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c
index 8671b7bb69..7dca585ddd 100644
--- a/target/ppc/helper_regs.c
+++ b/target/ppc/helper_regs.c
@@ -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;
     }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb()
  2022-01-21 16:08 [PATCH 1/1] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb() Daniel Henrique Barboza
@ 2022-01-21 18:32 ` Fabiano Rosas
  2022-01-25  9:12 ` Greg Kurz
  1 sibling, 0 replies; 3+ messages in thread
From: Fabiano Rosas @ 2022-01-21 18:32 UTC (permalink / raw)
  To: Daniel Henrique Barboza, qemu-devel
  Cc: Daniel Henrique Barboza, qemu-ppc, Greg Kurz, david, clg

Daniel Henrique Barboza <danielhb413@gmail.com> writes:

> 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 <groug@kaod.org>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/809
> Fixes: 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM")
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb()
  2022-01-21 16:08 [PATCH 1/1] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb() Daniel Henrique Barboza
  2022-01-21 18:32 ` Fabiano Rosas
@ 2022-01-25  9:12 ` Greg Kurz
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2022-01-25  9:12 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: clg, qemu-ppc, qemu-devel, david

On Fri, 21 Jan 2022 13:08:41 -0300
Daniel Henrique Barboza <danielhb413@gmail.com> wrote:

> 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.
> 

Ohh boy... this is embarrassing :-\

> Fix the 'skip KVM' condition so the function is a no-op when
> kvm_enabled().
> 
> CC: Greg Kurz <groug@kaod.org>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/809
> Fixes: 6d38666a8931 ("ppc: Ignore the CPU_INTERRUPT_EXITTB interrupt with KVM")
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  target/ppc/helper_regs.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c
> index 8671b7bb69..7dca585ddd 100644
> --- a/target/ppc/helper_regs.c
> +++ b/target/ppc/helper_regs.c
> @@ -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;
>      }
>  



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-25  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 16:08 [PATCH 1/1] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb() Daniel Henrique Barboza
2022-01-21 18:32 ` Fabiano Rosas
2022-01-25  9:12 ` Greg Kurz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.