whpx: i386: enable exceptions VM exit only when needed
The exceptions VM exit was enabled with an empty bitmask even when not used. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260324151323.74473-3-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Mohamed Mediouni committed
Mar 24, 2026 at 16:13 UTC
d2d6d917949d67435c29f866f26259c00597e6ad
1 file changed
+20
-3
target/i386/whpx/whpx-all.c
+20
-3
@@ -903,13 +903,31 @@ static void whpx_init_emu(void)
903
HRESULT whpx_set_exception_exit_bitmap(UINT64 exceptions)
904
{
905
struct whpx_state *whpx = &whpx_global;
906
- WHV_PARTITION_PROPERTY prop = { 0, };
906
+ WHV_PARTITION_PROPERTY prop;
907
HRESULT hr;
908
909
if (exceptions == whpx->exception_exit_bitmap) {
910
return S_OK;
911
}
912
913
+ /* Register for MSR and CPUID exits */
914
+ memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
915
+ prop.ExtendedVmExits.X64MsrExit = 1;
916
+ if (exceptions != 0) {
917
+ prop.ExtendedVmExits.ExceptionExit = 1;
918
+ }
919
+
920
+ hr = whp_dispatch.WHvSetPartitionProperty(
921
+ whpx->partition,
922
+ WHvPartitionPropertyCodeExtendedVmExits,
923
+ &prop,
924
+ sizeof(WHV_PARTITION_PROPERTY));
925
+ if (FAILED(hr)) {
926
+ error_report("WHPX: Failed to enable extended VM exits, hr=%08lx", hr);
927
+ return hr;
928
+ }
929
+
930
+ memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
931
prop.ExceptionExitBitmap = exceptions;
932
933
hr = whp_dispatch.WHvSetPartitionProperty(
@@ -2167,7 +2185,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2185
/* Register for MSR and CPUID exits */
2186
memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
2187
prop.ExtendedVmExits.X64MsrExit = 1;
2170
- prop.ExtendedVmExits.ExceptionExit = 1;
2188
2189
hr = whp_dispatch.WHvSetPartitionProperty(
2190
whpx->partition,
@@ -2175,7 +2192,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2192
&prop,
2193
sizeof(WHV_PARTITION_PROPERTY));
2194
if (FAILED(hr)) {
2178
- error_report("WHPX: Failed to enable MSR & CPUIDexit, hr=%08lx", hr);
2195
+ error_report("WHPX: Failed to enable extended VM exits, hr=%08lx", hr);
2196
ret = -EINVAL;
2197
goto error;
2198
}