All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] WHPX: Use proper synchronization primitives while processing
@ 2020-02-24 19:27 Sunil Muthuswamy
  2020-03-02 20:03 ` Sunil Muthuswamy
  2020-03-03 10:17 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Sunil Muthuswamy @ 2020-02-24 19:27 UTC (permalink / raw
  To: Paolo Bonzini, Richard Henderson, Eduardo Habkost
  Cc: qemu-devel@nongnu.org, Stefan Weil, Justin Terry (SF)

WHPX wasn't using the proper synchronization primitives while
processing async events, which can cause issues with SMP.

Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
---
 target/i386/whpx-all.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
index 35601b8176..868ade5fd0 100644
--- a/target/i386/whpx-all.c
+++ b/target/i386/whpx-all.c
@@ -841,9 +841,8 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
 
     if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) &&
         !(env->hflags & HF_SMM_MASK)) {
-
+        whpx_cpu_synchronize_state(cpu);
         do_cpu_init(x86_cpu);
-        cpu->vcpu_dirty = true;
         vcpu->interruptable = true;
     }
 
@@ -859,17 +858,13 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
     }
 
     if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) {
-        if (!cpu->vcpu_dirty) {
-            whpx_get_registers(cpu);
-        }
+        whpx_cpu_synchronize_state(cpu);
         do_cpu_sipi(x86_cpu);
     }
 
     if (cpu->interrupt_request & CPU_INTERRUPT_TPR) {
         cpu->interrupt_request &= ~CPU_INTERRUPT_TPR;
-        if (!cpu->vcpu_dirty) {
-            whpx_get_registers(cpu);
-        }
+        whpx_cpu_synchronize_state(cpu);
         apic_handle_tpr_access_report(x86_cpu->apic_state, env->eip,
                                       env->tpr_access_type);
     }
@@ -1067,8 +1062,10 @@ static int whpx_vcpu_run(CPUState *cpu)
 
 static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
 {
-    whpx_get_registers(cpu);
-    cpu->vcpu_dirty = true;
+    if (!cpu->vcpu_dirty) {
+        whpx_get_registers(cpu);
+        cpu->vcpu_dirty = true;
+    }
 }
 
 static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu,
-- 
2.17.1


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

* RE: [PATCH] WHPX: Use proper synchronization primitives while processing
  2020-02-24 19:27 [PATCH] WHPX: Use proper synchronization primitives while processing Sunil Muthuswamy
@ 2020-03-02 20:03 ` Sunil Muthuswamy
  2020-03-03 10:17 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Sunil Muthuswamy @ 2020-03-02 20:03 UTC (permalink / raw
  To: Paolo Bonzini, Richard Henderson, Eduardo Habkost
  Cc: qemu-devel@nongnu.org, Stefan Weil, Justin Terry (SF)

> -----Original Message-----
> From: Sunil Muthuswamy
> Sent: Monday, February 24, 2020 11:28 AM
> To: Paolo Bonzini <pbonzini@redhat.com>; Richard Henderson <rth@twiddle.net>; Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org; Stefan Weil <sw@weilnetz.de>; Justin Terry (SF) <juterry@microsoft.com>
> Subject: [PATCH] WHPX: Use proper synchronization primitives while processing
> 
> WHPX wasn't using the proper synchronization primitives while
> processing async events, which can cause issues with SMP.
> 
> Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
> ---
>  target/i386/whpx-all.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
> index 35601b8176..868ade5fd0 100644
> --- a/target/i386/whpx-all.c
> +++ b/target/i386/whpx-all.c
> @@ -841,9 +841,8 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
> 
>      if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) &&
>          !(env->hflags & HF_SMM_MASK)) {
> -
> +        whpx_cpu_synchronize_state(cpu);
>          do_cpu_init(x86_cpu);
> -        cpu->vcpu_dirty = true;
>          vcpu->interruptable = true;
>      }
> 
> @@ -859,17 +858,13 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
>      }
> 
>      if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) {
> -        if (!cpu->vcpu_dirty) {
> -            whpx_get_registers(cpu);
> -        }
> +        whpx_cpu_synchronize_state(cpu);
>          do_cpu_sipi(x86_cpu);
>      }
> 
>      if (cpu->interrupt_request & CPU_INTERRUPT_TPR) {
>          cpu->interrupt_request &= ~CPU_INTERRUPT_TPR;
> -        if (!cpu->vcpu_dirty) {
> -            whpx_get_registers(cpu);
> -        }
> +        whpx_cpu_synchronize_state(cpu);
>          apic_handle_tpr_access_report(x86_cpu->apic_state, env->eip,
>                                        env->tpr_access_type);
>      }
> @@ -1067,8 +1062,10 @@ static int whpx_vcpu_run(CPUState *cpu)
> 
>  static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
>  {
> -    whpx_get_registers(cpu);
> -    cpu->vcpu_dirty = true;
> +    if (!cpu->vcpu_dirty) {
> +        whpx_get_registers(cpu);
> +        cpu->vcpu_dirty = true;
> +    }
>  }
> 
>  static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu,
> --
> 2.17.1

Can we please get this reviewed/queued till I figure out the GPG key thing?


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

* Re: [PATCH] WHPX: Use proper synchronization primitives while processing
  2020-02-24 19:27 [PATCH] WHPX: Use proper synchronization primitives while processing Sunil Muthuswamy
  2020-03-02 20:03 ` Sunil Muthuswamy
@ 2020-03-03 10:17 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-03-03 10:17 UTC (permalink / raw
  To: Sunil Muthuswamy, Richard Henderson, Eduardo Habkost
  Cc: Stefan Weil, qemu-devel@nongnu.org, Justin Terry (SF)

On 24/02/20 20:27, Sunil Muthuswamy wrote:
> WHPX wasn't using the proper synchronization primitives while
> processing async events, which can cause issues with SMP.
> 
> Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
> ---
>  target/i386/whpx-all.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c
> index 35601b8176..868ade5fd0 100644
> --- a/target/i386/whpx-all.c
> +++ b/target/i386/whpx-all.c
> @@ -841,9 +841,8 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
>  
>      if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) &&
>          !(env->hflags & HF_SMM_MASK)) {
> -
> +        whpx_cpu_synchronize_state(cpu);
>          do_cpu_init(x86_cpu);
> -        cpu->vcpu_dirty = true;
>          vcpu->interruptable = true;
>      }
>  
> @@ -859,17 +858,13 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
>      }
>  
>      if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) {
> -        if (!cpu->vcpu_dirty) {
> -            whpx_get_registers(cpu);
> -        }
> +        whpx_cpu_synchronize_state(cpu);
>          do_cpu_sipi(x86_cpu);
>      }
>  
>      if (cpu->interrupt_request & CPU_INTERRUPT_TPR) {
>          cpu->interrupt_request &= ~CPU_INTERRUPT_TPR;
> -        if (!cpu->vcpu_dirty) {
> -            whpx_get_registers(cpu);
> -        }
> +        whpx_cpu_synchronize_state(cpu);
>          apic_handle_tpr_access_report(x86_cpu->apic_state, env->eip,
>                                        env->tpr_access_type);
>      }
> @@ -1067,8 +1062,10 @@ static int whpx_vcpu_run(CPUState *cpu)
>  
>  static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
>  {
> -    whpx_get_registers(cpu);
> -    cpu->vcpu_dirty = true;
> +    if (!cpu->vcpu_dirty) {
> +        whpx_get_registers(cpu);
> +        cpu->vcpu_dirty = true;
> +    }
>  }
>  
>  static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu,
> 

Queued, thanks.

Paolo



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

end of thread, other threads:[~2020-03-03 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-24 19:27 [PATCH] WHPX: Use proper synchronization primitives while processing Sunil Muthuswamy
2020-03-02 20:03 ` Sunil Muthuswamy
2020-03-03 10:17 ` Paolo Bonzini

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.