WHvResetPartition resets partition state, and is not supported on Windows 10.
On Arm, it's supposed to be used for reboots.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
accel/whpx/whpx-accel-ops.c | 1 +
accel/whpx/whpx-common.c | 12 ++++++++++++
include/accel/accel-cpu-ops.h | 7 +++++++
include/system/cpus.h | 3 +++
include/system/whpx-accel-ops.h | 2 ++
system/cpus.c | 7 +++++++
system/runstate.c | 3 +++
target/arm/whpx/whpx-all.c | 2 --
8 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/accel/whpx/whpx-accel-ops.c b/accel/whpx/whpx-accel-ops.c
index b8f41544cb..ddeef79e53 100644
--- a/accel/whpx/whpx-accel-ops.c
+++ b/accel/whpx/whpx-accel-ops.c
@@ -98,6 +98,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->handle_interrupt = generic_handle_interrupt;
ops->supports_guest_debug = whpx_supports_guest_debug;
+ ops->vm_reset = whpx_partition_reset;
ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset;
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
ops->synchronize_state = whpx_cpu_synchronize_state;
diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 6fe44d5910..daf59207c6 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -205,6 +205,18 @@ static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu,
cpu->vcpu_dirty = true;
}
+/*
+ * Partition support
+ */
+
+void whpx_partition_reset(void)
+{
+ struct whpx_state *whpx = &whpx_global;
+ if (whp_dispatch.WHvResetPartition) {
+ whp_dispatch.WHvResetPartition(whpx->partition);
+ }
+}
+
/*
* CPU support.
*/
diff --git a/include/accel/accel-cpu-ops.h b/include/accel/accel-cpu-ops.h
index 9c07a903ea..32348d3470 100644
--- a/include/accel/accel-cpu-ops.h
+++ b/include/accel/accel-cpu-ops.h
@@ -42,6 +42,13 @@ struct AccelOpsClass {
void (*kick_vcpu_thread)(CPUState *cpu);
bool (*cpu_thread_is_idle)(CPUState *cpu);
+ /**
+ * vm_reset
+ *
+ * Request to reset the VM to the hardware accelerator.
+ */
+ void (*vm_reset)(void);
+
/**
* synchronize_post_reset:
* synchronize_post_init:
diff --git a/include/system/cpus.h b/include/system/cpus.h
index 508444ccf1..5dcd7fff07 100644
--- a/include/system/cpus.h
+++ b/include/system/cpus.h
@@ -40,4 +40,7 @@ void cpu_synchronize_all_post_reset(void);
void cpu_synchronize_all_post_init(void);
void cpu_synchronize_all_pre_loadvm(void);
+/* VM wide reset */
+void accel_vm_reset(void);
+
#endif
diff --git a/include/system/whpx-accel-ops.h b/include/system/whpx-accel-ops.h
index 4b2a732654..c809250485 100644
--- a/include/system/whpx-accel-ops.h
+++ b/include/system/whpx-accel-ops.h
@@ -12,6 +12,8 @@
#include "system/cpus.h"
+void whpx_partition_reset(void);
+
int whpx_init_vcpu(CPUState *cpu);
int whpx_vcpu_exec(CPUState *cpu);
void whpx_destroy_vcpu(CPUState *cpu);
diff --git a/system/cpus.c b/system/cpus.c
index bded87feb1..6a321873f5 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -203,6 +203,13 @@ bool cpus_are_resettable(void)
return true;
}
+void accel_vm_reset(void)
+{
+ if (cpus_accel->vm_reset) {
+ cpus_accel->vm_reset();
+ }
+}
+
void cpu_exec_reset_hold(CPUState *cpu)
{
if (cpus_accel->cpu_reset_hold) {
diff --git a/system/runstate.c b/system/runstate.c
index 2d4e95a216..135e2decba 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -564,6 +564,9 @@ void qemu_system_reset(ShutdownCause reason)
qapi_event_send_reset(shutdown_caused_by_guest(reason), reason);
}
+ /* Tell the accelerator that the VM is being reset. */
+ accel_vm_reset();
+
/*
* Some boards use the machine reset callback to point CPUs to the firmware
* entry point. Assume that this is not the case for boards that support
diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c
index 4019a513aa..f345fea4fe 100644
--- a/target/arm/whpx/whpx-all.c
+++ b/target/arm/whpx/whpx-all.c
@@ -472,8 +472,6 @@ int whpx_vcpu_run(CPUState *cpu)
if (arm_cpu->power_state != PSCI_OFF) {
whpx_psci_cpu_off(arm_cpu);
}
- /* Partition-wide reset, to reset state for reboots to succeed. */
- whp_dispatch.WHvResetPartition(whpx->partition);
bql_unlock();
break;
case WHvRunVpExitReasonNone:
--
2.50.1 (Apple Git-155)