hvf, whpx: i386: x86-centric fixes before softfreeze
v6 cover hvf, whpx: i386: x86-centric fixes before softfreeze
v6:
- && __aarch64 -> && defined(__aarch64__)
- remove unneeded "#include "qemu/target-info.h"
v5:
- Also include HVF buildability fixes...
v4:
- Removed two patches that I didn't intend to be merged at this point yet...
v3:
- Added HVF build fix from Pierrick Bouvier (oops... forgot to have it copied over from the test machine earlier...)
- Also added a fix for "whpx: make enlightenments configurable" highlighted with an error from GCC. Clang did not catch this...
Mohamed Mediouni (8):
meson.build: older macOS targeting compatibility with macOS 15.4 SDK
hvf: arm: unbreak the x86 build
whpx: i386: do not enable nested virt when kernel-irqchip=off target/i386: emulate: LA57 fix
whpx: i386: enable some more enlightenments
whpx: make Hyper-V enlightenments configurable
whpx: arm64: enable enlightenments if asked for
whpx: i386: remove SIPI trapping
Pierrick Bouvier (1):
target/i386/hvf/hvf.c: fix compilation
accel/whpx/whpx-common.c | 43 ++++++++++++ include/system/whpx-internal.h | 4 ++ meson.build | 7 +- target/arm/hvf_arm.h | 2 +- target/arm/whpx/whpx-all.c | 37 ++++++++++ target/i386/emulate/x86_mmu.c | 2 +- target/i386/hvf/hvf.c | 14 ++-- target/i386/whpx/whpx-all.c | 122 ++++----------------------------- 8 files changed, 114 insertions(+), 117 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 1/9 target/i386/hvf/hvf.c: fix compilation
From: Pierrick Bouvier <[email protected]>
../target/i386/hvf/hvf.c:476:31: error: use of undeclared identifier 'cpu'
476 | X86CPU *x86_cpu = X86_CPU(cpu);
| ^../target/i386/hvf/hvf.c:479:24: error: use of undeclared identifier 'cpu'
479 | env->cr[0] = rvmcs(cpu->accel->fd, VMCS_GUEST_CR0);
| ^../target/i386/hvf/hvf.c:480:24: error: use of undeclared identifier 'cpu'
480 | env->cr[3] = rvmcs(cpu->accel->fd, VMCS_GUEST_CR3);
| ^../target/i386/hvf/hvf.c:481:23: error: use of undeclared identifier 'cpu'
481 | env->cr[2] = rreg(cpu->accel->fd, HV_X86_CR2);
| ^../target/i386/hvf/hvf.c:486:31: error: use of undeclared identifier 'cpu'
486 | X86CPU *x86_cpu = X86_CPU(cpu);
| ^../target/i386/hvf/hvf.c:489:11: error: use of undeclared identifier 'cpu'
489 | wvmcs(cpu->accel->fd, VMCS_GUEST_CR0, env->cr[0]);
| ^../target/i386/hvf/hvf.c:490:11: error: use of undeclared identifier 'cpu'
490 | wvmcs(cpu->accel->fd, VMCS_GUEST_CR3, env->cr[3]);
| ^
7 errors generated.
--- target/i386/hvf/hvf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
target/i386/hvf/hvf.c +7 -7
@@ -472,21 +472,21 @@ static void hvf_cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,static void hvf_load_crs (CPUState *cs) { -X86CPU *x86_cpu =X86_CPU (cpu); +X86CPU *x86_cpu =X86_CPU (cs);CPUX86State *env = &x86_cpu->env; - env->cr[0 ] =rvmcs (cpu->accel->fd,VMCS_GUEST_CR0 ); - env->cr[3 ] =rvmcs (cpu->accel->fd,VMCS_GUEST_CR3 ); - env->cr[2 ] =rreg (cpu->accel->fd,HV_X86_CR2 ); + env->cr[0 ] =rvmcs (cs->accel->fd,VMCS_GUEST_CR0 ); + env->cr[3 ] =rvmcs (cs->accel->fd,VMCS_GUEST_CR3 ); + env->cr[2 ] =rreg (cs->accel->fd,HV_X86_CR2 ); }static void hvf_save_crs (CPUState *cs) { -X86CPU *x86_cpu =X86_CPU (cpu); +X86CPU *x86_cpu =X86_CPU (cs);CPUX86State *env = &x86_cpu->env; -wvmcs (cpu->accel->fd,VMCS_GUEST_CR0 , env->cr[0 ]); -wvmcs (cpu->accel->fd,VMCS_GUEST_CR3 , env->cr[3 ]); +wvmcs (cs->accel->fd,VMCS_GUEST_CR0 , env->cr[0 ]); +wvmcs (cs->accel->fd,VMCS_GUEST_CR3 , env->cr[3 ]);wreg (cs->accel->fd,HV_X86_CR2 , env->cr[2 ]); }
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 2/9 meson.build: older macOS targeting compatibility with macOS 15.4 SDK
In reply to Mohamed MediouniUsing strchrnul eagerly results in a failure to compile when using the newest SDKs, with:
error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
Working around that by not using strchrnul when targeting macOS.
This didn't show up on the CI because it used the macOS 15.1 SDK instead of a macOS 15.4 SDK or later.
--- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
meson.build +6 -1
@@ -2646,7 +2646,12 @@ config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice) config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util)) -config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix)) + +# strchrnul was introduced in macOS 15.4. +# Keep this condition for compatibility of new macOS SDKs with older releases. +if host_os != 'darwin' + config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix)) +endif config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>')) if rbd.found() config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS',
Signature · 1 line
2.50.1 (Apple Git-155)
Re: [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
Quoted 18 lines · Mohamed Mediouni
Using strchrnul eagerly results in a failure to compile when using the newest SDKs, with:
error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
Working around that by not using strchrnul when targeting macOS.
This didn't show up on the CI because it used the macOS 15.1 SDK instead of a macOS 15.4 SDK or later.
Signed-off-by Mohamed Mediouni <[email protected]>--- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)meson.build +0
-0
meson.build config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) · line 2654
Quoted 10 lines
meson.build +6
-1@@ -2646,7 +2646,12 @@ config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice) config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util)) -config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix)) + +# strchrnul was introduced in macOS 15.4. +# Keep this condition for compatibility of new macOS SDKs with older releases. +if host_os != 'darwin' + config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix)) +endif
Is -Wunguarded-availability-new enabled by default? If it is enough to shut up the compiler maybe you can add a -mmacosx-version-min= flag, but workarounds on each function are not acceptable.
I'm applying the other patches, but for this one I don't think this is the right fix.
Paolo
Re: [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
Quoted 27 lines · Paolo Bonzini
Quoted 22 lines · Mohamed Mediouni
Using strchrnul eagerly results in a failure to compile when using the newest SDKs, with:
error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
Working around that by not using strchrnul when targeting macOS.
This didn't show up on the CI because it used the macOS 15.1 SDK instead of a macOS 15.4 SDK or later.
Signed-off-by Mohamed Mediouni <[email protected]>--- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)meson.build +0
-1@@ -2646,7 +2646,12 @@ config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice) config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util)) -config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix))
Quoted 8 lines
meson.build config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) · line 2654
Quoted 6 lines
meson.build +6
-0+ +# strchrnul was introduced in macOS 15.4. +# Keep this condition for compatibility of new macOS SDKs with older releases. +if host_os != 'darwin' + config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix)) +endifIs -Wunguarded-availability-new enabled by default?
Hello,
Yes, it’s enabled by default at least by the CI.
Quoted 3 lines
If it is enough to shut up the compiler maybe you can add a -mmacosx-version-min= flag, but workarounds on each function are not acceptable.
-mmacosx-version-min=15.4 or later would be overriding the macOS minimum version set by the user or corresponding to the host machine QEMU is built on.
Another way would be to have the has_function have -Werror which should be enough to deal with this case properly. Does that sound better?
For meson not sure whether it actually picks up the definition from the header or tries to use a dummy
definition though from looking at https://github.com/mesonbuild/meson/blob/6e67be7492d6982d2baf153387f9adbdb480d099/mesonbuild/compilers/mixins/clike.py#L738
If it picks the definition from the header, having Werror there ought to be enough. Otherwise, won’t be caught...
Thank you,
-Mohamed
Quoted 6 lines
I'm applying the other patches, but for this one I don't think this is the right fix.
Paolo
Re: [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
Quoted 2 lines · Mohamed Mediouni
Another way would be to have the
has_functionhave -Werror which should be enough to deal with this case properly. Does that sound better?
Yes, if that works it's better. For 11.1 we can look into adding -Werror to all cc.has_function() calls.
Quoted 3 lines
For meson not sure whether it actually picks up the definition from the header or tries to use a dummy
definition though from looking at https://github.com/mesonbuild/meson/blob/6e67be7492d6982d2baf153387f9adbdb480d099/mesonbuild/compilers/mixins/clike.py#L738
If it picks the definition from the header, having Werror there ought to be enough. Otherwise, won’t be caught...
If you have a "#include <>" in the prefix it will pick the declaration:
if '#include' in prefix:
head, main = self._have_prototype_templ()
else:
head, main = self._no_prototype_templ()
which is also something that we can add to 11.1.
Paolo
PATCH v6 3/9 hvf: arm: unbreak the x86 build
In reply to Mohamed MediouniWe don't really have any great choices here, so use the __aarch64__ define to unbreak the x86 build.
Once the CI moves away from macOS 15.1 SDK to... 15.2 even we can get rid of these SME stubs horrible hacks.
--- target/arm/hvf_arm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/hvf_arm.h +1 -1
@@ -27,7 +27,7 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu);* headers are not available until we raise our minimum macOS version. */ #ifdef __MAC_OS_X_VERSION_MAX_ALLOWED -#if (__MAC_OS_X_VERSION_MAX_ALLOWED >=150200 ) +#if (__MAC_OS_X_VERSION_MAX_ALLOWED >=150200 ) && defined(__aarch64__)#include "system/hvf_int.h" static inline bool hvf_arm_sme2_supported (void )
Signature · 1 line
2.50.1 (Apple Git-155)
Re: [PATCH v6 3/9] hvf: arm: unbreak the x86 build
Quoted 8 lines · Mohamed Mediouni
We don't really have any great choices here, so use the
__aarch64__define to unbreak the x86 build.Once the CI moves away from macOS 15.1 SDK to... 15.2 even we can get rid of these SME stubs horrible hacks.
Signed-off-by Mohamed Mediouni <[email protected]--- target/arm/hvf_arm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v6 4/9 whpx: i386: do not enable nested virt when kernel-irqchip=off
In reply to Mohamed MediouniThis combination is not allowed as of build 26300.7939 and results in:
qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005 qemu-system-x86_64.exe: failed to initialize whpx: Invalid argument
--- target/i386/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/whpx/whpx-all.c +1 -1
@@ -2160,7 +2160,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } -if (processor_features.Bank1.NestedVirtSupport) { +if (whpx_irqchip_in_kernel () && processor_features.Bank1.NestedVirtSupport) {memset (&prop,0 ,sizeof (WHV_PARTITION_PROPERTY )); prop.NestedVirtualization =1 ; hr = whp_dispatch.WHvSetPartitionProperty(
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 5/9 target/i386: emulate: LA57 fix
In reply to Mohamed MediouniSeen on a Sapphire Rapids box with LA57.
The top level of the pte array is taken for CR3, so there was one entry too little for 5-level paging.
--- target/i386/emulate/x86_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/emulate/x86_mmu.c +1 -1
@@ -56,7 +56,7 @@ static bool is_user(CPUState *cpu)struct gpt_translation {target_ulong gva;uint64_t gpa; -uint64_t pte[5 ]; +uint64_t pte[6 ]; };static int gpt_top_level (CPUState *cpu,bool pae)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 6/9 whpx: i386: enable some more enlightenments
In reply to Mohamed Mediouni--- target/i386/whpx/whpx-all.c | 3 +++ 1 file changed, 3 insertions(+)
target/i386/whpx/whpx-all.c +3 -0
@@ -2214,9 +2214,12 @@ int whpx_accel_init(AccelState *as, MachineState *ms) synthetic_features.Bank0.HypervisorPresent =1 ; synthetic_features.Bank0.Hv1 =1 ; + synthetic_features.Bank0.AccessVpRunTimeReg =1 ; synthetic_features.Bank0.AccessPartitionReferenceCounter =1 ; synthetic_features.Bank0.AccessPartitionReferenceTsc =1 ; + synthetic_features.Bank0.AccessHypercallRegs =1 ; synthetic_features.Bank0.AccessFrequencyRegs =1 ; + synthetic_features.Bank0.EnableExtendedGvaRangesForFlushVirtualAddressList =1 ; synthetic_features.Bank0.AccessVpIndex =1 ; synthetic_features.Bank0.AccessHypercallRegs =1 ; synthetic_features.Bank0.TbFlushHypercalls =1 ;
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 7/9 whpx: make Hyper-V enlightenments configurable
In reply to Mohamed MediouniHave them be a machine option instead of a CPU one, to have something available, even if not ideal...
The existing Hyper-V enlightenments configuration mechanism is part of per-CPU configuration, which happens too late for this.
--- accel/whpx/whpx-common.c | 43 ++++++++++++++++++++++++++++++++++ include/system/whpx-internal.h | 4 ++++ target/i386/whpx/whpx-all.c | 20 +++++++++------- 3 files changed, 58 insertions(+), 9 deletions(-)
accel/whpx/whpx-common.c +43 -0
@@ -470,6 +470,41 @@ static void whpx_set_kernel_irqchip(Object *obj, Visitor *v, } } +static void whpx_set_hyperv (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +struct whpx_state *whpx = &whpx_global; +OnOffAuto mode; + +if (!visit_type_OnOffAuto (v, name, &mode, errp)) { +return ; + } + +switch (mode) { +case ON_OFF_AUTO_ON : + whpx->hyperv_enlightenments_allowed = true; + whpx->hyperv_enlightenments_required = true; +break ; + +case ON_OFF_AUTO_OFF : + whpx->hyperv_enlightenments_allowed = false; + whpx->hyperv_enlightenments_required = false; +break ; + +case ON_OFF_AUTO_AUTO : + whpx->hyperv_enlightenments_allowed = true; + whpx->hyperv_enlightenments_required = false; +break ; +default : +/* +* The value was checked in visit_type_OnOffAuto() above. If +* we get here, then something is wrong in QEMU. +*/ +abort (); + } +} +static void whpx_cpu_accel_class_init (ObjectClass *oc,const void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc);
@@ -498,6 +533,11 @@ static void whpx_accel_class_init(ObjectClass *oc, const void *data) NULL, NULL);object_class_property_set_description (oc,"kernel-irqchip" ,"Configure WHPX in-kernel irqchip" ); +object_class_property_add (oc,"hyperv" ,"OnOffAuto" , +NULL , whpx_set_hyperv, +NULL ,NULL ); +object_class_property_set_description (oc,"hyperv" , +"Configure Hyper-V enlightenments" ); }static void whpx_accel_instance_init (Object *obj)
@@ -507,6 +547,9 @@ static void whpx_accel_instance_init(Object *obj)memset (whpx,0 ,sizeof (struct whpx_state ));/* Turn on kernel-irqchip, by default */ whpx->kernel_irqchip_allowed = true; + + whpx->hyperv_enlightenments_allowed = true; + whpx->hyperv_enlightenments_required = false; }static const TypeInfo whpx_accel_type = {
include/system/whpx-internal.h +4 -0
@@ -42,6 +42,10 @@ struct whpx_state {bool kernel_irqchip_allowed;bool kernel_irqchip_required; + +bool hyperv_enlightenments_allowed; +bool hyperv_enlightenments_required; + };extern struct whpx_state whpx_global;
target/i386/whpx/whpx-all.c +11 -9
@@ -2232,15 +2232,17 @@ int whpx_accel_init(AccelState *as, MachineState *ms) synthetic_features.Bank0.DirectSyntheticTimers =1 ; } - hr = whp_dispatch.WHvSetPartitionProperty ( - whpx->partition, - WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks, - &synthetic_features, -sizeof (WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS )); -if (FAILED (hr)) { -error_report ("WHPX: Failed to set synthetic features, hr=%08lx" , hr); - ret = -EINVAL ; - goto error; +if (whpx->hyperv_enlightenments_allowed) { + hr = whp_dispatch.WHvSetPartitionProperty ( + whpx->partition, + WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks, + &synthetic_features, +sizeof (WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS )); +if (FAILED (hr)) { +error_report ("WHPX: Failed to set synthetic features, hr=%08lx" , hr); + ret = -EINVAL ; + goto error; + } }/* Register for MSR and CPUID exits */
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 8/9 whpx: arm64: enable enlightenments if asked for
In reply to Mohamed Mediouni--- target/arm/whpx/whpx-all.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
target/arm/whpx/whpx-all.c +37 -0
@@ -940,6 +940,43 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } +/* 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 ; + + synthetic_features.Bank0.HypervisorPresent =1 ; + synthetic_features.Bank0.Hv1 =1 ; + synthetic_features.Bank0.AccessVpRunTimeReg =1 ; + synthetic_features.Bank0.AccessPartitionReferenceCounter =1 ; + 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 ; + +/* +* On ARM64, have enlightenments off by default +* as they're not needed for performance. +*/ +if (whpx->hyperv_enlightenments_required) { + hr = whp_dispatch.WHvSetPartitionProperty ( + whpx->partition, + WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks, + &synthetic_features, +sizeof (WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS )); +if (FAILED (hr)) { +error_report ("WHPX: Failed to set synthetic features, hr=%08lx" , hr); + ret = -EINVAL ; + goto error; + } + } + hr = whp_dispatch.WHvSetupPartition (whpx->partition);if (FAILED (hr)) {error_report ("WHPX: Failed to setup partition, hr=%08lx" , hr);
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v6 9/9 whpx: i386: remove SIPI trapping
In reply to Mohamed MediouniThe implementation in Hyper-V works fine and the code currently present doesn't handle x2APIC correctly anyway, so remove it and use the implementation in Hyper-V.
--- target/i386/whpx/whpx-all.c | 97 ------------------------------------- 1 file changed, 97 deletions(-)
target/i386/whpx/whpx-all.c +0 -97
@@ -1692,100 +1692,6 @@ int whpx_vcpu_run(CPUState *cpu) ret =whpx_handle_halt (cpu);break ; -case WHvRunVpExitReasonX64ApicInitSipiTrap: { -WHV_INTERRUPT_CONTROL ipi = {0 }; -uint64_t icr = vcpu->exit_ctx.ApicInitSipi.ApicIcr; -uint32_t delivery_mode = - (icr &APIC_ICR_DELIV_MOD ) >>APIC_ICR_DELIV_MOD_SHIFT ; -int dest_shorthand = - (icr &APIC_ICR_DEST_SHORT ) >>APIC_ICR_DEST_SHORT_SHIFT ; -bool broadcast = false; -bool include_self = false; -uint32_t i; - -/* We only registered for INIT and SIPI exits. */ -if ((delivery_mode !=APIC_DM_INIT ) && - (delivery_mode !=APIC_DM_SIPI )) { -error_report ( -"WHPX: Unexpected APIC exit that is not a INIT or SIPI" ); -break ; - } - -if (delivery_mode ==APIC_DM_INIT ) { - ipi.Type = WHvX64InterruptTypeInit; - }else { - ipi.Type = WHvX64InterruptTypeSipi; - } - - ipi.DestinationMode = - ((icr &APIC_ICR_DEST_MOD ) >>APIC_ICR_DEST_MOD_SHIFT ) ? - WHvX64InterruptDestinationModeLogical : - WHvX64InterruptDestinationModePhysical; - - ipi.TriggerMode = - ((icr &APIC_ICR_TRIGGER_MOD ) >>APIC_ICR_TRIGGER_MOD_SHIFT ) ? - WHvX64InterruptTriggerModeLevel : - WHvX64InterruptTriggerModeEdge; - - ipi.Vector = icr &APIC_VECTOR_MASK ; -switch (dest_shorthand) { -/* no shorthand. Bits 56-63 contain the destination. */ -case 0 : - ipi.Destination = (icr >>56 ) &APIC_VECTOR_MASK ; - hr = whp_dispatch.WHvRequestInterrupt (whpx->partition, - &ipi,sizeof (ipi)); -if (FAILED (hr)) { -error_report ("WHPX: Failed to request interrupt hr=%08lx" , - hr); - } - -break ; - -/* self */ -case 1 : - include_self = true; -break ; - -/* broadcast, including self */ -case 2 : - broadcast = true; - include_self = true; -break ; - -/* broadcast, excluding self */ -case 3 : - broadcast = true; -break ; - } - -if (!broadcast && !include_self) { -break ; - } - -for (i =0 ; i <= max_vcpu_index; i++) { -if (i == cpu->cpu_index && !include_self) { -continue ; - } - -/* -* Assuming that APIC Ids are identity mapped since -* WHvX64RegisterApicId & WHvX64RegisterInitialApicId registers -* are not handled yet and the hypervisor doesn't allow the -* guest to modify the APIC ID. -*/ - ipi.Destination = i; - hr = whp_dispatch.WHvRequestInterrupt (whpx->partition, - &ipi,sizeof (ipi)); -if (FAILED (hr)) { -error_report ( -"WHPX: Failed to request SIPI for %d, hr=%08lx" , - i, hr); - } - } - -break ; - } -case WHvRunVpExitReasonCanceled:if (exclusive_step_mode !=WHPX_STEP_NONE ) {/*
@@ -2249,9 +2155,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)memset (&prop,0 ,sizeof (WHV_PARTITION_PROPERTY )); prop.ExtendedVmExits.X64MsrExit =1 ; prop.ExtendedVmExits.ExceptionExit =1 ; -if (whpx_irqchip_in_kernel ()) { - prop.ExtendedVmExits.X64ApicInitSipiExitTrap =1 ; - } hr = whp_dispatch.WHvSetPartitionProperty( whpx->partition,
Signature · 1 line
2.50.1 (Apple Git-155)