* [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX
@ 2024-04-24 17:45 Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 1/3] accel/whpx: Use accel-specific per-vcpu @dirty field Philippe Mathieu-Daudé
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-24 17:45 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Sunil Muthuswamy, Roman Bolshakov, Alexander Graf,
qemu-arm, Cameron Esfahani, Reinoud Zandijk,
Philippe =?unknown-8bit?q?Mathieu-Daud=C3=A9?=
We want CPUState to only contain fields used by common code.
Start using a specific @dirty field for HVF/NVMM/WHPX
(TCG then KVM will follow).
Philippe Mathieu-Daudé (3):
accel/whpx: Use accel-specific per-vcpu @dirty field
accel/nvmm: Use accel-specific per-vcpu @dirty field
accel/hvf: Use accel-specific per-vcpu @dirty field
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 +-
target/i386/nvmm/nvmm-all.c | 21 +++++++++++----------
target/i386/whpx/whpx-all.c | 23 ++++++++++++-----------
8 files changed, 35 insertions(+), 33 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] accel/whpx: Use accel-specific per-vcpu @dirty field
2024-04-24 17:45 [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Philippe Mathieu-Daudé
@ 2024-04-24 17:45 ` Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 2/3] accel/nvmm: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-24 17:45 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Sunil Muthuswamy, Roman Bolshakov, Alexander Graf,
qemu-arm, Cameron Esfahani, Reinoud Zandijk,
Philippe Mathieu-Daudé
WHPX 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>
---
target/i386/whpx/whpx-all.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 31eec7048c..b08e644517 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -237,6 +237,7 @@ struct AccelCPUState {
uint64_t tpr;
uint64_t apic_base;
bool interruption_pending;
+ bool dirty;
/* Must be the last field as it may have a tail */
WHV_RUN_VP_EXIT_CONTEXT exit_ctx;
@@ -839,7 +840,7 @@ static HRESULT CALLBACK whpx_emu_setreg_callback(
* The emulator just successfully wrote the register state. We clear the
* dirty state so we avoid the double write on resume of the VP.
*/
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
return hr;
}
@@ -1394,7 +1395,7 @@ static int whpx_last_vcpu_stopping(CPUState *cpu)
/* Returns the address of the next instruction that is about to be executed. */
static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid)
{
- if (cpu->vcpu_dirty) {
+ if (cpu->accel->dirty) {
/* The CPU registers have been modified by other parts of QEMU. */
return cpu_env(cpu)->eip;
} else if (exit_context_valid) {
@@ -1713,9 +1714,9 @@ static int whpx_vcpu_run(CPUState *cpu)
}
do {
- if (cpu->vcpu_dirty) {
+ if (cpu->accel->dirty) {
whpx_set_registers(cpu, WHPX_SET_RUNTIME_STATE);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
if (exclusive_step_mode == WHPX_STEP_NONE) {
@@ -2063,9 +2064,9 @@ static int whpx_vcpu_run(CPUState *cpu)
static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
- if (!cpu->vcpu_dirty) {
+ if (!cpu->accel->dirty) {
whpx_get_registers(cpu);
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
}
}
@@ -2073,20 +2074,20 @@ static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu,
run_on_cpu_data arg)
{
whpx_set_registers(cpu, WHPX_SET_RESET_STATE);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
static void do_whpx_cpu_synchronize_post_init(CPUState *cpu,
run_on_cpu_data arg)
{
whpx_set_registers(cpu, WHPX_SET_FULL_STATE);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu,
run_on_cpu_data arg)
{
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
}
/*
@@ -2095,7 +2096,7 @@ static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu,
void whpx_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->vcpu_dirty) {
+ if (!cpu->accel->dirty) {
run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -2235,7 +2236,7 @@ int whpx_init_vcpu(CPUState *cpu)
}
vcpu->interruptable = true;
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
cpu->accel = vcpu;
max_vcpu_index = max(max_vcpu_index, cpu->cpu_index);
qemu_add_vm_change_state_handler(whpx_cpu_update_state, env);
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] accel/nvmm: Use accel-specific per-vcpu @dirty field
2024-04-24 17:45 [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 1/3] accel/whpx: Use accel-specific per-vcpu @dirty field Philippe Mathieu-Daudé
@ 2024-04-24 17:45 ` Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 3/3] accel/hvf: " Philippe Mathieu-Daudé
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-24 17:45 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Sunil Muthuswamy, Roman Bolshakov, Alexander Graf,
qemu-arm, Cameron Esfahani, Reinoud Zandijk,
Philippe Mathieu-Daudé
NVMM 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>
---
target/i386/nvmm/nvmm-all.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index 49a3a3b916..f9cced53b3 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -30,6 +30,7 @@ struct AccelCPUState {
struct nvmm_vcpu vcpu;
uint8_t tpr;
bool stop;
+ bool dirty;
/* Window-exiting for INTs/NMIs. */
bool int_window_exit;
@@ -507,7 +508,7 @@ nvmm_io_callback(struct nvmm_io *io)
}
/* Needed, otherwise infinite loop. */
- current_cpu->vcpu_dirty = false;
+ current_cpu->accel->dirty = false;
}
static void
@@ -516,7 +517,7 @@ nvmm_mem_callback(struct nvmm_mem *mem)
cpu_physical_memory_rw(mem->gpa, mem->data, mem->size, mem->write);
/* Needed, otherwise infinite loop. */
- current_cpu->vcpu_dirty = false;
+ current_cpu->accel->dirty = false;
}
static struct nvmm_assist_callbacks nvmm_callbacks = {
@@ -726,9 +727,9 @@ nvmm_vcpu_loop(CPUState *cpu)
* Inner VCPU loop.
*/
do {
- if (cpu->vcpu_dirty) {
+ if (cpu->accel->dirty) {
nvmm_set_registers(cpu);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
if (qcpu->stop) {
@@ -826,32 +827,32 @@ static void
do_nvmm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
nvmm_get_registers(cpu);
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
}
static void
do_nvmm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg)
{
nvmm_set_registers(cpu);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
static void
do_nvmm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
{
nvmm_set_registers(cpu);
- cpu->vcpu_dirty = false;
+ cpu->accel->dirty = false;
}
static void
do_nvmm_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg)
{
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
}
void nvmm_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->vcpu_dirty) {
+ if (!cpu->accel->dirty) {
run_on_cpu(cpu, do_nvmm_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -981,7 +982,7 @@ nvmm_init_vcpu(CPUState *cpu)
}
}
- cpu->vcpu_dirty = true;
+ cpu->accel->dirty = true;
cpu->accel = qcpu;
return 0;
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] accel/hvf: Use accel-specific per-vcpu @dirty field
2024-04-24 17:45 [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 1/3] accel/whpx: Use accel-specific per-vcpu @dirty field Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 2/3] accel/nvmm: " Philippe Mathieu-Daudé
@ 2024-04-24 17:45 ` Philippe Mathieu-Daudé
2024-04-24 22:13 ` [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Richard Henderson
2024-04-26 15:03 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-24 17:45 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Sunil Muthuswamy, Roman Bolshakov, Alexander Graf,
qemu-arm, Cameron Esfahani, Reinoud Zandijk,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Yanan Wang
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>
---
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 6f5a16e0fc..46b99a7ea5 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -505,6 +505,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;
@@ -526,8 +527,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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX
2024-04-24 17:45 [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2024-04-24 17:45 ` [PATCH 3/3] accel/hvf: " Philippe Mathieu-Daudé
@ 2024-04-24 22:13 ` Richard Henderson
2024-04-26 15:03 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2024-04-24 22:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Peter Maydell, Sunil Muthuswamy, Roman Bolshakov, Alexander Graf,
qemu-arm, Cameron Esfahani, Reinoud Zandijk
On 4/24/24 10:45, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (3):
> accel/whpx: Use accel-specific per-vcpu @dirty field
> accel/nvmm: Use accel-specific per-vcpu @dirty field
> accel/hvf: Use accel-specific per-vcpu @dirty field
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX
2024-04-24 17:45 [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2024-04-24 22:13 ` [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Richard Henderson
@ 2024-04-26 15:03 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-26 15:03 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Sunil Muthuswamy, Roman Bolshakov, Alexander Graf,
qemu-arm, Cameron Esfahani, Reinoud Zandijk
On 24/4/24 19:45, Philippe Mathieu-Daudé wrote:
> We want CPUState to only contain fields used by common code.
> Start using a specific @dirty field for HVF/NVMM/WHPX
> (TCG then KVM will follow).
>
> Philippe Mathieu-Daudé (3):
> accel/whpx: Use accel-specific per-vcpu @dirty field
> accel/nvmm: Use accel-specific per-vcpu @dirty field
> accel/hvf: Use accel-specific per-vcpu @dirty field
Thanks, queued.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-26 15:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 17:45 [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 1/3] accel/whpx: Use accel-specific per-vcpu @dirty field Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 2/3] accel/nvmm: " Philippe Mathieu-Daudé
2024-04-24 17:45 ` [PATCH 3/3] accel/hvf: " Philippe Mathieu-Daudé
2024-04-24 22:13 ` [PATCH 0/3] accel: Add new @dirty field on HVF/NVMM/WHPX Richard Henderson
2024-04-26 15:03 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).