[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 12/19] hvf: Simplify post reset/init/loadvm hooks
From: |
Alexander Graf |
Subject: |
[PATCH v7 12/19] hvf: Simplify post reset/init/loadvm hooks |
Date: |
Sun, 16 May 2021 21:58:48 +0200 |
The hooks we have that call us after reset, init and loadvm really all
just want to say "The reference of all register state is in the QEMU
vcpu struct, please push it".
We already have a working pushing mechanism though called cpu->vcpu_dirty,
so we can just reuse that for all of the above, syncing state properly the
next time we actually execute a vCPU.
This fixes PSCI resets on ARM, as they modify CPU state even after the
post init call has completed, but before we execute the vCPU again.
To also make the scheme work for x86, we have to make sure we don't
move stale eflags into our env when the vcpu state is dirty.
Signed-off-by: Alexander Graf <agraf@csgraf.de>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
accel/hvf/hvf-accel-ops.c | 27 +++++++--------------------
target/i386/hvf/x86hvf.c | 5 ++++-
2 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index ded918c443..d1691be989 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -205,39 +205,26 @@ static void hvf_cpu_synchronize_state(CPUState *cpu)
}
}
-static void do_hvf_cpu_synchronize_post_reset(CPUState *cpu,
- run_on_cpu_data arg)
+static void do_hvf_cpu_synchronize_set_dirty(CPUState *cpu,
+ run_on_cpu_data arg)
{
- hvf_put_registers(cpu);
- cpu->vcpu_dirty = false;
+ /* QEMU state is the reference, push it to HVF now and on next entry */
+ cpu->vcpu_dirty = true;
}
static void hvf_cpu_synchronize_post_reset(CPUState *cpu)
{
- run_on_cpu(cpu, do_hvf_cpu_synchronize_post_reset, RUN_ON_CPU_NULL);
-}
-
-static void do_hvf_cpu_synchronize_post_init(CPUState *cpu,
- run_on_cpu_data arg)
-{
- hvf_put_registers(cpu);
- cpu->vcpu_dirty = false;
+ run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL);
}
static void hvf_cpu_synchronize_post_init(CPUState *cpu)
{
- run_on_cpu(cpu, do_hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL);
-}
-
-static void do_hvf_cpu_synchronize_pre_loadvm(CPUState *cpu,
- run_on_cpu_data arg)
-{
- cpu->vcpu_dirty = true;
+ run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL);
}
static void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu)
{
- run_on_cpu(cpu, do_hvf_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
+ run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL);
}
static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on)
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 28cfee4f60..2ced2c2478 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -433,7 +433,10 @@ int hvf_process_events(CPUState *cpu_state)
X86CPU *cpu = X86_CPU(cpu_state);
CPUX86State *env = &cpu->env;
- env->eflags = rreg(cpu_state->hvf->fd, HV_X86_RFLAGS);
+ if (!cpu_state->vcpu_dirty) {
+ /* light weight sync for CPU_INTERRUPT_HARD and IF_MASK */
+ env->eflags = rreg(cpu_state->hvf->fd, HV_X86_RFLAGS);
+ }
if (cpu_state->interrupt_request & CPU_INTERRUPT_INIT) {
cpu_synchronize_state(cpu_state);
--
2.30.1 (Apple Git-130)
- [PATCH v7 01/19] hvf: Move assert_hvf_ok() into common directory, (continued)
- [PATCH v7 01/19] hvf: Move assert_hvf_ok() into common directory, Alexander Graf, 2021/05/16
- [PATCH v7 02/19] hvf: Move vcpu thread functions into common directory, Alexander Graf, 2021/05/16
- [PATCH v7 06/19] hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t, Alexander Graf, 2021/05/16
- [PATCH v7 07/19] hvf: Split out common code on vcpu init and destroy, Alexander Graf, 2021/05/16
- [PATCH v7 05/19] hvf: Make hvf_set_phys_mem() static, Alexander Graf, 2021/05/16
- [PATCH v7 04/19] hvf: Move hvf internal definitions into common header, Alexander Graf, 2021/05/16
- [PATCH v7 08/19] hvf: Use cpu_synchronize_state(), Alexander Graf, 2021/05/16
- [PATCH v7 09/19] hvf: Make synchronize functions static, Alexander Graf, 2021/05/16
- [PATCH v7 03/19] hvf: Move cpu functions into common directory, Alexander Graf, 2021/05/16
- [PATCH v7 10/19] hvf: Remove hvf-accel-ops.h, Alexander Graf, 2021/05/16
- [PATCH v7 12/19] hvf: Simplify post reset/init/loadvm hooks,
Alexander Graf <=
- [PATCH v7 11/19] hvf: Introduce hvf vcpu struct, Alexander Graf, 2021/05/16
- [PATCH v7 14/19] arm/hvf: Add a WFI handler, Alexander Graf, 2021/05/16
- [PATCH v7 19/19] hvf: arm: Handle Windows 10 SMC call, Alexander Graf, 2021/05/16
- [PATCH v7 13/19] hvf: Add Apple Silicon support, Alexander Graf, 2021/05/16
- [PATCH v7 17/19] arm: Add Hypervisor.framework build target, Alexander Graf, 2021/05/16
- [PATCH v7 18/19] arm: Enable Windows 10 trusted SMCCC boot call, Alexander Graf, 2021/05/16
- [PATCH v7 15/19] hvf: arm: Implement -cpu host, Alexander Graf, 2021/05/16
- [PATCH v7 16/19] hvf: arm: Implement PSCI handling, Alexander Graf, 2021/05/16
- Re: [PATCH v7 00/19] hvf: Implement Apple Silicon Support, no-reply, 2021/05/16