Skip to contentSkip to conversation

whpx: i386, arm: do partition reset on boot CPU reset

PATCH Superseded Mohamed Mediouni 2 participants 2 messages Apr 21

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 whpx: i386, arm: do partition reset on boot CPU reset

WHvResetPartition resets partition state, and is not supported on Windows 10.

On Arm, it's supposed to be used for reboots.

---
 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(-)
accel/whpx/whpx-accel-ops.c +1 -0
index b8f41544cb..ddeef79e53 100644
@@ -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;
accel/whpx/whpx-common.c +12 -0
index 6fe44d5910..daf59207c6 100644
@@ -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.
  */
include/accel/accel-cpu-ops.h +7 -0
index 9c07a903ea..32348d3470 100644
@@ -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:
include/system/cpus.h +3 -0
index 508444ccf1..5dcd7fff07 100644
@@ -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
include/system/whpx-accel-ops.h +2 -0
index 4b2a732654..c809250485 100644
@@ -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);
system/cpus.c +7 -0
index bded87feb1..6a321873f5 100644
@@ -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) {
system/runstate.c +3 -0
index 2d4e95a216..135e2decba 100644
@@ -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
target/arm/whpx/whpx-all.c +0 -2
index 4019a513aa..f345fea4fe 100644
@@ -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:
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw
Quoted 25 lines · Mohamed Mediouni

WHvResetPartition resets partition state, and is not supported on Windows 10.

On Arm, it's supposed to be used for reboots.

---
  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(-)
include/accel/accel-cpu-ops.h +0 -0
index 9c07a903ea..32348d3470 100644
@@ -42,6 +42,13 @@ struct AccelOpsClass {
      void (*kick_vcpu_thread)(CPUState *cpu);
      bool (*cpu_thread_is_idle)(CPUState *cpu);
 

include/accel/accel-cpu-ops.h struct AccelOpsClass { · line 54

Quoted 10 lines
include/accel/accel-cpu-ops.h +7 -0
+    /**
+     * vm_reset
+     *
+     * Request to reset the VM to the hardware accelerator.
+     */
+    void (*vm_reset)(void);
+
      /**
       * synchronize_post_reset:
       * synchronize_post_init:

AccelOpsClass is per vCPU, AccelClass is per accel/VM.