whpx: arm: set of small fixes for QEMU 11.0
v3 cover whpx: arm: set of small fixes for QEMU 11.0
Localised fixes for QEMU 11.0:
- fixes for -cpu host, including an ID_AA64MMFR2_EL1/ID_AA64MMFR3_EL1 mixup
- add EC_DATAABORT assert for WHvRunVpExitReasonGpaIntercept/UnmappedGpa
This one doesn't functionally change anything today, but is good to have and is a single-line change.
- fix Hyper-V enlightenments
AccessVpRegs turns out to be necessary too. Linux doesn't check for its presence and panics in an Hyper-V arm64 configuration without it exposed.
Fixing a mistake in not following the QEMU code style and having had AccessHypercallRegs included twice at the same time. Also add some more privileges because it looks like guests don't check for presence of each one systematically...
- SME support shipped in Hyper-V now
So remove a code comment. Another one-liner.
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
Osama Abdelkader (1):
whpx: arm: fix ID_AA64MMFR3_EL1 host feature register index
hw/arm/virt.c | 2 +- target/arm/cpu.c | 4 ++-- target/arm/whpx/whpx-all.c | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 1/6 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
@@ -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)
Re: [PATCH v3 1/6] whpx: arm: fix -cpu host
Am 14.03.26 um 23:15 schrieb Mohamed Mediouni:
Quoted 13 lines
"hw/arm/virt: Register valid CPU types dynamically" went under my radar, so fix this for WHPX.
Signed-off-by Mohamed Mediouni <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/virt.c +0
-0
hw/arm/virt.c static GPtrArray *virt_get_valid_cpu_types(const MachineState *ms) · line 3483
Quoted 8 lines
hw/arm/virt.c +1
-1@@ -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" ))); } }
PATCH v3 2/6 whpx: arm: add EC_DATAABORT assert for WHvRunVpExitReasonGpaIntercept/UnmappedGpa
In reply to Mohamed MediouniIf 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
@@ -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)
PATCH v3 3/6 whpx: arm: enable more enlightements
In reply to Mohamed MediouniLinux 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
@@ -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)
Re: [PATCH v3 3/6] whpx: arm: enable more enlightements
Quoted 2 lines · Mohamed Mediouni
Linux uses AccessVpRegs without checking availability and panics if it's not there. Expose it unconditionally.
The commit message subject says we're enabling enlightenments...
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 956
Quoted 5 lines
target/arm/whpx/whpx-all.c +0
-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 ;
...but the code change seems to be removing one as well as adding the three new ones. Intentional?
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 967
Quoted 12 lines
target/arm/whpx/whpx-all.c +3
-0synthetic_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
I've taken this series into target-arm.next for the moment -- I can either drop this patch or else fix it up depending on what the right thing is.
PS: for commit messages, could you wrap the body text at the usual 70-ish columns, please?
thanks
-- PMM
Re: [PATCH v3 3/6] whpx: arm: enable more enlightements
Quoted 9 lines · Peter Maydell
Quoted 2 lines · Mohamed Mediouni
Linux uses AccessVpRegs without checking availability and panics if it's not there. Expose it unconditionally.
The commit message subject says we're enabling enlightenments...
Quoted 8 lines
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 956
Quoted 5 lines
target/arm/whpx/whpx-all.c +0
-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 ;...but the code change seems to be removing one as well as adding the three new ones. Intentional?
Hello,
The AccessHypercallRegs bit was set twice - with the first one being two lines earlier - removed a spurious one of the two.
Quoted 14 lines
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 967
Quoted 13 lines
target/arm/whpx/whpx-all.c +3
-0synthetic_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
Quoted 6 lines
I've taken this series into target-arm.next for the moment -- I can either drop this patch or else fix it up depending on what the right thing is.
PS: for commit messages, could you wrap the body text at the usual 70-ish columns, please?
Will add some tooling to catch those earlier instead of trying to manually wrap… (and inevitably failing some of the time…)
Quoted 3 lines
thanks
-- PMM
Re: [PATCH v3 3/6] whpx: arm: enable more enlightements
Quoted 18 lines · Mohamed Mediouni
Quoted 10 lines · Peter Maydell
Quoted 2 lines · Mohamed Mediouni
Linux uses AccessVpRegs without checking availability and panics if it's not there. Expose it unconditionally.
The commit message subject says we're enabling enlightenments...
Quoted 8 lines
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 956
Quoted 5 lines
target/arm/whpx/whpx-all.c +0
-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 ;...but the code change seems to be removing one as well as adding the three new ones. Intentional?
Quoted 4 lines
Hello,
The AccessHypercallRegs bit was set twice - with the first one being two lines earlier - removed a spurious one of the two.
Ah, right. How about this for a commit message ?
whpx: arm: enable more enlightenments
Unconditionally enable some more enlightenments for whpx. In particular, linux uses AccessVpRegs without checking availability and panics if it's not there, so it's important to expose it.
We also had a duplicate line where we set AccessHypercallRegs = 1 twice; remove the duplicate.
If you have more rationale/info about the other two we're enabling, that would also be nice to include.
thanks
-- PMM
Re: [PATCH v3 3/6] whpx: arm: enable more enlightements
Quoted 40 lines · Peter Maydell
Quoted 18 lines · Mohamed Mediouni
Quoted 10 lines · Peter Maydell
Quoted 2 lines · Mohamed Mediouni
Linux uses AccessVpRegs without checking availability and panics if it's not there. Expose it unconditionally.
The commit message subject says we're enabling enlightenments...
Quoted 8 lines
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 956
Quoted 5 lines
target/arm/whpx/whpx-all.c +0
-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 ;...but the code change seems to be removing one as well as adding the three new ones. Intentional?
Quoted 4 lines
Hello,
The AccessHypercallRegs bit was set twice - with the first one being two lines earlier - removed a spurious one of the two.
Ah, right. How about this for a commit message ?
whpx: arm: enable more enlightenments
Unconditionally enable some more enlightenments for whpx. In particular, linux uses AccessVpRegs without checking availability and panics if it's not there, so it's important to expose it.
We also had a duplicate line where we set AccessHypercallRegs = 1 twice; remove the duplicate.
Quoted 5 lines
If you have more rationale/info about the other two we're enabling, that would also be nice to include.
thanks
-- PMM
Hello,
``` whpx: arm: enable more enlightenments Enable some more enlightenments for whpx for -accel whpx,hyperv=on. In particular, Linux uses AccessVpRegs without checking availability when Hyper-V enlightenments are exposed and panics if it's not there. We also had a duplicate line where we set AccessHypercallRegs = 1 twice; remove the duplicate. Microsoft’s VMM exposes SyncContext on arm64 and FastHypercallOutput regardless of architecture unconditionally, so add those two to match that configuration. ```
On arm64, Hyper-V enlightenments with QEMU whpx aren’t on by default and are a more research-y configuration - as the case when it was needed to have a properly-behaved VM on Snapdragon X laptops has been worked around in Hyper-V.
Snapdragon X has broken CNTVOFF_EL2 with an interrupt flood when HCR_EL2.E2H = 1 + CNTVOFF_EL2 != 0 and Hyper-V synthetic timers were used on arm64 to sidestep that. Nowadays, Hyper-V has a workaround so that the virtual timer can be used instead of needing to resort to using those.
Thanks,
-Mohamed
Re: [PATCH v3 3/6] whpx: arm: enable more enlightements
Quoted 44 lines · Mohamed Mediouni
Quoted 37 lines · Peter Maydell
Quoted 18 lines · Mohamed Mediouni
Quoted 10 lines · Peter Maydell
Quoted 2 lines · Mohamed Mediouni
Linux uses AccessVpRegs without checking availability and panics if it's not there. Expose it unconditionally.
The commit message subject says we're enabling enlightenments...
Quoted 8 lines
target/arm/whpx/whpx-all.c int whpx_accel_init(AccelState *as, MachineState *ms) · line 956
Quoted 5 lines
target/arm/whpx/whpx-all.c +0
-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 ;...but the code change seems to be removing one as well as adding the three new ones. Intentional?
Quoted 4 lines
Hello,
The AccessHypercallRegs bit was set twice - with the first one being two lines earlier - removed a spurious one of the two.
Ah, right. How about this for a commit message ?
whpx: arm: enable more enlightenments
Unconditionally enable some more enlightenments for whpx. In particular, linux uses AccessVpRegs without checking availability and panics if it's not there, so it's important to expose it.
Quoted 6 lines
We also had a duplicate line where we set AccessHypercallRegs = 1 twice; remove the duplicate.
If you have more rationale/info about the other two we're enabling, that would also be nice to include.
Quoted 15 lines
``` whpx: arm: enable more enlightenments Enable some more enlightenments for whpx for -accel whpx,hyperv=on. In particular, Linux uses AccessVpRegs without checking availability when Hyper-V enlightenments are exposed and panics if it's not there. We also had a duplicate line where we set AccessHypercallRegs = 1 twice; remove the duplicate. Microsoft’s VMM exposes SyncContext on arm64 and FastHypercallOutput regardless of architecture unconditionally, so add those two to match that configuration. ```
Thanks -- I've updated the commit message for this patch in target-arm.next to that.
-- PMM
PATCH v3 4/6 whpx: arm: remove comment bit that is no longer accurate
In reply to Mohamed MediouniAs 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
@@ -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)
PATCH v3 5/6 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
@@ -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)
PATCH v3 6/6 whpx: arm: fix ID_AA64MMFR3_EL1 host feature register index
In reply to Mohamed MediouniFrom: Osama Abdelkader <[email protected]>
IdAa64Mmfr3El1 was stored in idregs[ID_AA64MMFR2_EL1_IDX], overwriting MMFR2 and leaving MMFR3 never set. Use ID_AA64MMFR3_EL1_IDX so the host MMFR3 value is stored in the correct slot.
--- target/arm/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/whpx/whpx-all.c +1 -1
@@ -684,7 +684,7 @@ static bool whpx_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) { WHvArm64RegisterIdAa64Mmfr0El1, &ahcf->isar.idregs[ID_AA64MMFR0_EL1_IDX] }, { WHvArm64RegisterIdAa64Mmfr1El1, &ahcf->isar.idregs[ID_AA64MMFR1_EL1_IDX] }, { WHvArm64RegisterIdAa64Mmfr2El1, &ahcf->isar.idregs[ID_AA64MMFR2_EL1_IDX] }, - { WHvArm64RegisterIdAa64Mmfr3El1, &ahcf->isar.idregs[ID_AA64MMFR2_EL1_IDX] } + { WHvArm64RegisterIdAa64Mmfr3El1, &ahcf->isar.idregs[ID_AA64MMFR3_EL1_IDX] } };int i;
Signature · 1 line
2.50.1 (Apple Git-155)
Re: [PATCH v3 6/6] whpx: arm: fix ID_AA64MMFR3_EL1 host feature register index
Quoted 6 lines · Mohamed Mediouni
From: Osama Abdelkader <[email protected]>
IdAa64Mmfr3El1 was stored in idregs[ID_AA64MMFR2_EL1_IDX], overwriting MMFR2 and leaving MMFR3 never set. Use
ID_AA64MMFR3_EL1_IDXso the host MMFR3 value is stored in the correct slot.
Quoted 5 lines
Signed-off-by Osama Abdelkader <[email protected]>Reviewed-by Mohamed Mediouni <[email protected]>--- target/arm/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH v3 6/6] whpx: arm: fix ID_AA64MMFR3_EL1 host feature register index
In reply to Mohamed MediouniQuoted 25 lines · Mohamed Mediouni
From: Osama Abdelkader <[email protected]>
IdAa64Mmfr3El1 was stored in idregs[ID_AA64MMFR2_EL1_IDX], overwriting MMFR2 and leaving MMFR3 never set. Use
ID_AA64MMFR3_EL1_IDXso the host MMFR3 value is stored in the correct slot.Signed-off-by Osama Abdelkader <[email protected]>Reviewed-by Mohamed Mediouni <[email protected]>--- target/arm/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/arm/whpx/whpx-all.c +1
-1@@ -684,7 +684,7 @@ static bool whpx_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) { WHvArm64RegisterIdAa64Mmfr0El1, &ahcf->isar.idregs[ID_AA64MMFR0_EL1_IDX] }, { WHvArm64RegisterIdAa64Mmfr1El1, &ahcf->isar.idregs[ID_AA64MMFR1_EL1_IDX] }, { WHvArm64RegisterIdAa64Mmfr2El1, &ahcf->isar.idregs[ID_AA64MMFR2_EL1_IDX] }, - { WHvArm64RegisterIdAa64Mmfr3El1, &ahcf->isar.idregs[ID_AA64MMFR2_EL1_IDX] } + { WHvArm64RegisterIdAa64Mmfr3El1, &ahcf->isar.idregs[ID_AA64MMFR3_EL1_IDX] } };int i;
Peter Maydell
AppliedQuoted 13 lines · Mohamed Mediouni
Localised fixes for QEMU 11.0:
- fixes for -cpu host, including an ID_AA64MMFR2_EL1/ID_AA64MMFR3_EL1 mixup
- addEC_DATAABORTassert for WHvRunVpExitReasonGpaIntercept/UnmappedGpaThis one doesn't functionally change anything today, but is good to have and is a single-line change.
- fix Hyper-V enlightenments
AccessVpRegs turns out to be necessary too. Linux doesn't check for its presence and panics in an Hyper-V arm64 configuration without it exposed.
Quoted 7 lines
Fixing a mistake in not following the QEMU code style and having had AccessHypercallRegs included twice at the same time. Also add some more privileges because it looks like guests don't check for presence of each one systematically...
- SME support shipped in Hyper-V now
So remove a code comment. Another one-liner.
Applied to target-arm.next with commit message adjustments as discussed, thanks.
-- PMM