[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] WHPX: Use proper synchronization primitives while processing
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH] WHPX: Use proper synchronization primitives while processing |
Date: |
Tue, 3 Mar 2020 11:17:43 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
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 <address@hidden>
> ---
> 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