Have 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.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
accel/whpx/whpx-common.c | 44 ++++++++++++++++++++++++++++++++++
include/system/whpx-internal.h | 4 ++++
target/i386/whpx/whpx-all.c | 20 +++++++++-------
3 files changed, 59 insertions(+), 9 deletions(-)
diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 4863fc8663..dae9ff0800 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -25,6 +25,7 @@
#include "qapi/qapi-visit-common.h"
#include "migration/blocker.h"
#include "accel/accel-cpu-target.h"
+#include "qemu/target-info.h"
#include <winerror.h>
#include "system/whpx-internal.h"
@@ -470,6 +471,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 +534,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 +548,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 = {
diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h
index 7a1c9871f1..8482901f71 100644
--- a/include/system/whpx-internal.h
+++ b/include/system/whpx-internal.h
@@ -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;
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index bc82995b33..b095c96962 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -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 */
--
2.50.1 (Apple Git-155)
On 7/3/26 16:41, Mohamed Mediouni wrote:
> Have 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.
>
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> ---
> accel/whpx/whpx-common.c | 44 ++++++++++++++++++++++++++++++++++
> include/system/whpx-internal.h | 4 ++++
> target/i386/whpx/whpx-all.c | 20 +++++++++-------
> 3 files changed, 59 insertions(+), 9 deletions(-)
>
> diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
> index 4863fc8663..dae9ff0800 100644
> --- a/accel/whpx/whpx-common.c
> +++ b/accel/whpx/whpx-common.c
> @@ -25,6 +25,7 @@
> #include "qapi/qapi-visit-common.h"
> #include "migration/blocker.h"
> #include "accel/accel-cpu-target.h"
> +#include "qemu/target-info.h"
I suppose you meant "qapi/qapi-types-common.h"?
> #include <winerror.h>
>
> #include "system/whpx-internal.h"
> @@ -470,6 +471,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 +534,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 +548,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;
> }
> On 7. Mar 2026, at 16:53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 7/3/26 16:41, Mohamed Mediouni wrote:
>> Have 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.
>> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
>> ---
>> accel/whpx/whpx-common.c | 44 ++++++++++++++++++++++++++++++++++
>> include/system/whpx-internal.h | 4 ++++
>> target/i386/whpx/whpx-all.c | 20 +++++++++-------
>> 3 files changed, 59 insertions(+), 9 deletions(-)
>> diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
>> index 4863fc8663..dae9ff0800 100644
>> --- a/accel/whpx/whpx-common.c
>> +++ b/accel/whpx/whpx-common.c
>> @@ -25,6 +25,7 @@
>> #include "qapi/qapi-visit-common.h"
>> #include "migration/blocker.h"
>> #include "accel/accel-cpu-target.h"
>> +#include "qemu/target-info.h"
>
> I suppose you meant "qapi/qapi-types-common.h”?
Skipping including the line at all :)
Context: in an earlier iteration added an arch check added here with using the target_aarch64() function*,
but changed it for this rev.
* at the end, decided to use a bifurcated hyperv_enlightenments_allowed/hyperv_enlightenments_required
design like for kernel-irqchip, with enlightenments off by default on arm64 but on by default for x86, because
arm64 virt is cleaner architecturally by enough that enlightenments don’t really matter there.
>
>> #include <winerror.h>
>> #include "system/whpx-internal.h"
>> @@ -470,6 +471,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 +534,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 +548,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;
>> }
>
© 2016 - 2026 Red Hat, Inc.