[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/38] accel/hvf: Use accel-specific per-vcpu @dirty field
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 22/38] accel/hvf: Use accel-specific per-vcpu @dirty field |
Date: |
Fri, 26 Apr 2024 21:41:42 +0200 |
HVF has a specific use of the CPUState::vcpu_dirty field
(CPUState::vcpu_dirty is not used by common code).
To make this field accel-specific, add and use a new
@dirty variable in the AccelCPUState structure.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240424174506.326-4-philmd@linaro.org>
---
include/hw/core/cpu.h | 3 +--
include/sysemu/hvf_int.h | 1 +
accel/hvf/hvf-accel-ops.c | 10 +++++-----
target/arm/hvf/hvf.c | 4 ++--
target/i386/hvf/hvf.c | 4 ++--
target/i386/hvf/x86hvf.c | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 7f037b158e..cead8f01a6 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -525,6 +525,7 @@ struct CPUState {
uint32_t kvm_fetch_index;
uint64_t dirty_pages;
int kvm_vcpu_stats_fd;
+ bool vcpu_dirty;
/* Use by accel-block: CPU is executing an ioctl() */
QemuLockCnt in_ioctl_lock;
@@ -546,8 +547,6 @@ struct CPUState {
int32_t exception_index;
AccelCPUState *accel;
- /* shared by kvm and hvf */
- bool vcpu_dirty;
/* Used to keep track of an outstanding cpu throttle thread for migration
* autoconverge
diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h
index 718beddcdd..4a327fd526 100644
--- a/include/sysemu/hvf_int.h
+++ b/include/sysemu/hvf_int.h
@@ -55,6 +55,7 @@ struct AccelCPUState {
bool vtimer_masked;
sigset_t unblock_ipi_mask;
bool guest_debug_enabled;
+ bool dirty;
};
void assert_hvf_ok(hv_return_t ret);
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index d94d41ab6d..40d4187d9d 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -204,15 +204,15 @@ static void hvf_set_phys_mem(MemoryRegionSection
*section, bool add)
static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
- if (!cpu->vcpu_dirty) {
+ if (!cpu->accel->dirty) {
hvf_get_registers(cpu);
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
}
}
static void hvf_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->vcpu_dirty) {
+ if (!cpu->accel->dirty) {
run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -221,7 +221,7 @@ static void do_hvf_cpu_synchronize_set_dirty(CPUState *cpu,
run_on_cpu_data arg)
{
/* QEMU state is the reference, push it to HVF now and on next entry */
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
}
static void hvf_cpu_synchronize_post_reset(CPUState *cpu)
@@ -402,7 +402,7 @@ static int hvf_init_vcpu(CPUState *cpu)
#else
r = hv_vcpu_create((hv_vcpuid_t *)&cpu->accel->fd, HV_VCPU_DEFAULT);
#endif
- cpu->vcpu_dirty = 1;
+ cpu->accel->dirty = true;
assert_hvf_ok(r);
cpu->accel->guest_debug_enabled = false;
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 65a5601804..db628c1cba 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -806,9 +806,9 @@ int hvf_put_registers(CPUState *cpu)
static void flush_cpu_state(CPUState *cpu)
{
- if (cpu->vcpu_dirty) {
+ if (cpu->accel->dirty) {
hvf_put_registers(cpu);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
}
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 1ed8ed5154..e493452acb 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -419,9 +419,9 @@ int hvf_vcpu_exec(CPUState *cpu)
}
do {
- if (cpu->vcpu_dirty) {
+ if (cpu->accel->dirty) {
hvf_put_registers(cpu);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
if (hvf_inject_interrupts(cpu)) {
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index be2c46246e..1569f860eb 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -427,7 +427,7 @@ int hvf_process_events(CPUState *cs)
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
- if (!cs->vcpu_dirty) {
+ if (!cs->accel->dirty) {
/* light weight sync for CPU_INTERRUPT_HARD and IF_MASK */
env->eflags = rreg(cs->accel->fd, HV_X86_RFLAGS);
}
--
2.41.0
- [PULL 13/38] target/sparc: Replace abi_ulong by uint32_t for TARGET_ABI32, (continued)
- [PULL 13/38] target/sparc: Replace abi_ulong by uint32_t for TARGET_ABI32, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 14/38] target/i386: Include missing 'exec/exec-all.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 15/38] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 16/38] accel/tcg: Include missing 'hw/core/cpu.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 18/38] accel/tcg: Rename load-extract/store-insert headers using .h.inc suffix, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 17/38] accel/tcg: Include missing headers in 'tb-jmp-cache.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 19/38] accel/tcg: Rename helper-head.h -> helper-head.h.inc, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 12/38] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 20/38] accel/whpx: Use accel-specific per-vcpu @dirty field, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 21/38] accel/nvmm: Use accel-specific per-vcpu @dirty field, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 22/38] accel/hvf: Use accel-specific per-vcpu @dirty field,
Philippe Mathieu-Daudé <=
- [PULL 23/38] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 24/38] exec/cpu-all: Remove unused 'qemu/thread.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 25/38] exec/cpu-all: Remove unused tswapls() definitions, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 26/38] exec: Declare target_words_bigendian() in 'exec/tswap.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 27/38] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 28/38] exec/user: Do not include 'cpu.h' in 'abitypes.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 29/38] exec: Declare abi_ptr type in its own 'abi_ptr.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 30/38] exec: Declare MMUAccessType type in 'mmu-access-type.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 31/38] exec: Declare CPUBreakpoint/CPUWatchpoint type in 'breakpoint.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 32/38] exec: Restrict TCG specific declarations of 'cputlb.h', Philippe Mathieu-Daudé, 2024/04/26