@samitouri / QOSamiQemu / commits / a1a3692d15

whpx: i386: add SeparateSecurityDomain flag and make default

For workloads where isolation is less important, -accel whpx,ssd=off will provide significantly higher MMIO performance. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260422214225.2242-37-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Apr 22, 2026 at 23:42 UTC a1a3692d159df7ed657d96a9c957d85f1d859f37
3 files changed +67
accel/whpx/whpx-common.c
+1
@@ -556,6 +556,7 @@ static void whpx_accel_instance_init(Object *obj)
556 whpx->hyperv_enlightenments_enabled = false;
557 whpx->ignore_unknown_msr = true;
558 whpx->intercept_msr_gp = false;
559 + whpx->separate_security_domain = true;
560 }
561
562 static const TypeInfo whpx_accel_type = {
include/system/whpx-internal.h
+2
@@ -47,6 +47,8 @@ struct whpx_state {
47 bool hyperv_enlightenments_required;
48 bool hyperv_enlightenments_enabled;
49
50 + bool separate_security_domain;
51 +
52 bool ignore_unknown_msr;
53 bool intercept_msr_gp;
54 };
target/i386/whpx/whpx-all.c
+64
@@ -2962,6 +2962,39 @@ static void whpx_set_intercept_msr_gp(Object *obj, Visitor *v,
2962 }
2963 }
2964
2965 +static void whpx_set_ssd(Object *obj, Visitor *v,
2966 + const char *name, void *opaque,
2967 + Error **errp)
2968 +{
2969 + struct whpx_state *whpx = &whpx_global;
2970 + OnOffAuto mode;
2971 +
2972 + if (!visit_type_OnOffAuto(v, name, &mode, errp)) {
2973 + return;
2974 + }
2975 +
2976 + switch (mode) {
2977 + case ON_OFF_AUTO_ON:
2978 + whpx->separate_security_domain = true;
2979 + break;
2980 +
2981 + case ON_OFF_AUTO_OFF:
2982 + whpx->separate_security_domain = false;
2983 + break;
2984 +
2985 + case ON_OFF_AUTO_AUTO:
2986 + whpx->separate_security_domain = true;
2987 + break;
2988 + default:
2989 + /*
2990 + * The value was checked in visit_type_OnOffAuto() above. If
2991 + * we get here, then something is wrong in QEMU.
2992 + */
2993 + abort();
2994 + }
2995 +}
2996 +
2997 +
2998 void whpx_arch_accel_class_init(ObjectClass *oc)
2999 {
3000 object_class_property_add(oc, "ignore-unknown-msr", "OnOffAuto",
@@ -2974,6 +3007,11 @@ void whpx_arch_accel_class_init(ObjectClass *oc)
3007 NULL, NULL);
3008 object_class_property_set_description(oc, "intercept-msr-gp",
3009 "Intercept #GP to log erroring MSR accesses.");
3010 + object_class_property_add(oc, "ssd", "OnOffAuto",
3011 + NULL, whpx_set_ssd,
3012 + NULL, NULL);
3013 + object_class_property_set_description(oc, "ssd",
3014 + "Separate security domain");
3015 }
3016
3017 int whpx_accel_init(AccelState *as, MachineState *ms)
@@ -3169,6 +3207,32 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
3207 }
3208 }
3209
3210 + /*
3211 + * The combination of separate security domain off
3212 + * and disabling specifically these features results
3213 + * in a significant vmexit performance improvement
3214 + * by skipping speculative execution mitigations.
3215 + */
3216 + if (!whpx->separate_security_domain) {
3217 + processor_features.Bank0.IbrsSupport = 0;
3218 + processor_features.Bank0.StibpSupport = 0;
3219 + processor_features.Bank0.IbpbSupport = 0;
3220 + processor_features.Bank0.SsbdSupport = 0;
3221 + processor_features.Bank0.IbrsAllSupport = 0;
3222 + processor_features.Bank1.PsfdSupport = 0;
3223 + memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
3224 + prop.SeparateSecurityDomain = 0;
3225 + hr = whp_dispatch.WHvSetPartitionProperty(
3226 + whpx->partition,
3227 + WHvPartitionPropertyCodeSeparateSecurityDomain,
3228 + &prop,
3229 + sizeof(WHV_PARTITION_PROPERTY));
3230 + if (FAILED(hr)) {
3231 + error_report("WHPX: failed to unset separate security domain, hr=%08lx", hr);
3232 + /* Some old Windows 10 releases didn't have this, so not fatal*/
3233 + }
3234 + }
3235 +
3236 hr = whp_dispatch.WHvSetPartitionProperty(
3237 whpx->partition,
3238 WHvPartitionPropertyCodeProcessorFeaturesBanks,