Skip to contentSkip to conversation

whpx: arm: set of small fixes

PATCH Superseded Mohamed Mediouni 2 participants 9 messages Mar 11 – Mar 12

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover whpx: arm: set of small fixes

Highlight is probably getting -cpu host working on WHPX again, but otherwise pretty small set of fixes.

Mohamed Mediouni (5):
whpx: arm: fix -cpu host
whpx: arm: add EC_DATAABORT assert for
WHvRunVpExitReasonGpaIntercept/UnmappedGpa
whpx: arm: enable more enlightements
whpx: arm: remove comment bit that is no longer accurate target/arm: cpu: alter error message for host CPU type

 hw/arm/virt.c              | 2 +-
 target/arm/cpu.c           | 4 ++--
 target/arm/whpx/whpx-all.c | 9 ++++++---
 3 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw

PATCH v2 1/5 whpx: arm: fix -cpu host

"hw/arm/virt: Register valid CPU types dynamically" went under my radar, so fix this for WHPX.

---
 hw/arm/virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/virt.c +1 -1
index bced9f67f4..af3f03ced3 100644
@@ -3477,7 +3477,7 @@ static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms)
     if (target_aarch64()) {
         g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("cortex-a53")));
         g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("cortex-a57")));
-        if (kvm_enabled() || hvf_enabled()) {
+        if (kvm_enabled() || hvf_enabled() || whpx_enabled()) {
             g_ptr_array_add(vct, g_strdup(ARM_CPU_TYPE_NAME("host")));
         }
     }
Signature · 1 line
2.50.1 (Apple Git-155)
#3 lore raw

PATCH v2 2/5 whpx: arm: add EC_DATAABORT assert for WHvRunVpExitReasonGpaIntercept/UnmappedGpa

In reply to Mohamed Mediouni

If we get anything else from Hyper-V there's a problem, so enforce this.

---
 target/arm/whpx/whpx-all.c | 1 +
 1 file changed, 1 insertion(+)
target/arm/whpx/whpx-all.c +1 -0
index 513551bec1..3df60a950d 100644
@@ -439,6 +439,7 @@ int whpx_vcpu_run(CPUState *cpu)
         switch (vcpu->exit_ctx.ExitReason) {
         case WHvRunVpExitReasonGpaIntercept:
         case WHvRunVpExitReasonUnmappedGpa:
+            assert(syn_get_ec(vcpu->exit_ctx.MemoryAccess.Syndrome) == EC_DATAABORT);
             advance_pc = true;
 
             if (vcpu->exit_ctx.MemoryAccess.Syndrome & BIT(8)) {
Signature · 1 line
2.50.1 (Apple Git-155)
#4 lore raw

PATCH v2 3/5 whpx: arm: enable more enlightements

In reply to Mohamed Mediouni

Linux uses AccessVpRegs without checking availability and panics if it's not there. Expose it unconditionally.

---
 target/arm/whpx/whpx-all.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target/arm/whpx/whpx-all.c +4 -2
index 3df60a950d..9e5bc03a21 100644
@@ -832,6 +832,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
     UINT32 whpx_cap_size;
     WHV_PARTITION_PROPERTY prop;
     WHV_CAPABILITY_FEATURES features;
+    WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features;
     MachineClass *mc = MACHINE_GET_CLASS(ms);
     int pa_range = 0;
 
@@ -942,7 +943,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
     }
 
     /* Enable synthetic processor features */
-    WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features;
     memset(&synthetic_features, 0, sizeof(WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS));
     synthetic_features.BanksCount = 1;
 
@@ -953,13 +953,15 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
     synthetic_features.Bank0.AccessPartitionReferenceTsc = 1;
     synthetic_features.Bank0.AccessHypercallRegs = 1;
     synthetic_features.Bank0.AccessVpIndex = 1;
-    synthetic_features.Bank0.AccessHypercallRegs = 1;
     synthetic_features.Bank0.TbFlushHypercalls = 1;
     synthetic_features.Bank0.AccessSynicRegs = 1;
     synthetic_features.Bank0.AccessSyntheticTimerRegs = 1;
     synthetic_features.Bank0.AccessIntrCtrlRegs = 1;
     synthetic_features.Bank0.SyntheticClusterIpi = 1;
     synthetic_features.Bank0.DirectSyntheticTimers = 1;
+    synthetic_features.Bank0.FastHypercallOutput = 1;
+    synthetic_features.Bank0.AccessVpRegs = 1;
+    synthetic_features.Bank0.SyncContext = 1;
 
     /*
      * On ARM64, have enlightenments off by default
Signature · 1 line
2.50.1 (Apple Git-155)
#5 lore raw

PATCH v2 4/5 whpx: arm: remove comment bit that is no longer accurate

In reply to Mohamed Mediouni

As of Windows 11 version 26H1, SME support shipped. However the MIT-licensed headers aren't updated yet.

---
 target/arm/whpx/whpx-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/whpx/whpx-all.c +1 -1
index 9e5bc03a21..8aa24f2adc 100644
@@ -717,7 +717,7 @@ static bool whpx_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
      * Work needed for SVE support:
      * - SVE state save/restore
      * - any potentially needed VL management
-     * Also disable SME at the same time. (not currently supported by Hyper-V)
+     * Also disable SME at the same time.
      */
     SET_IDREG(&ahcf->isar, ID_AA64PFR0,
               GET_IDREG(&ahcf->isar, ID_AA64PFR0) & ~R_ID_AA64PFR0_SVE_MASK);
Signature · 1 line
2.50.1 (Apple Git-155)
#6 lore raw

PATCH v2 5/5 target/arm: cpu: alter error message for host CPU type

In reply to Mohamed Mediouni
---
 target/arm/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/cpu.c +2 -2
index 7e3e84b4bb..e73d7eb4fc 100644
@@ -1629,8 +1629,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
      * this is the first point where we can report it.
      */
     if (cpu->host_cpu_probe_failed) {
-        if (!kvm_enabled() && !hvf_enabled()) {
-            error_setg(errp, "The 'host' CPU type can only be used with KVM or HVF");
+        if (!kvm_enabled() && !hvf_enabled() && !whpx_enabled()) {
+            error_setg(errp, "The 'host' CPU type can only be used with KVM, HVF or WHPX");
         } else {
             error_setg(errp, "Failed to retrieve host CPU features");
         }
Signature · 1 line
2.50.1 (Apple Git-155)
#7 lore raw

Re: [PATCH v2 5/5] target/arm: cpu: alter error message for host CPU type

Quoted 10 lines · Mohamed Mediouni
---
  target/arm/cpu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/cpu.c +0 -0
index 7e3e84b4bb..e73d7eb4fc 100644

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1633

Quoted 7 lines
target/arm/cpu.c +2 -2
@@ -1629,8 +1629,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
       * this is the first point where we can report it.
       */
      if (cpu->host_cpu_probe_failed) {
-        if (!kvm_enabled() && !hvf_enabled()) {
-            error_setg(errp, "The 'host' CPU type can only be used with KVM or HVF");
+        if (!kvm_enabled() && !hvf_enabled() && !whpx_enabled()) {
+            error_setg(errp, "The 'host' CPU type can only be used with KVM, HVF or WHPX");

Squash with patch #1?

Quoted 3 lines
target/arm/cpu.c +0 -0
          } else {
              error_setg(errp, "Failed to retrieve host CPU features");
          }
#8 lore raw

Re: [PATCH v2 5/5] target/arm: cpu: alter error message for host CPU type

Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Mohamed Mediouni
---
  target/arm/cpu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 19 lines

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1633

Quoted 12 lines
target/arm/cpu.c +2 -2
index 7e3e84b4bb..e73d7eb4fc 100644
@@ -1629,8 +1629,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
       * this is the first point where we can report it.
       */
      if (cpu->host_cpu_probe_failed) {
-        if (!kvm_enabled() && !hvf_enabled()) {
-            error_setg(errp, "The 'host' CPU type can only be used with KVM or HVF");
+        if (!kvm_enabled() && !hvf_enabled() && !whpx_enabled()) {
+            error_setg(errp, "The 'host' CPU type can only be used with KVM, HVF or WHPX");

Squash with patch #1?

Quoted 3 lines
target/arm/cpu.c +0 -0
          } else {
              error_setg(errp, "Failed to retrieve host CPU features");
          }

At any rate,