* [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze
@ 2026-03-07 18:18 Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 1/9] target/i386/hvf/hvf.c: fix compilation Mohamed Mediouni
` (8 more replies)
0 siblings, 9 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
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(-)
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v6 1/9] target/i386/hvf/hvf.c: fix compilation
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK Mohamed Mediouni
` (7 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda, Pierrick Bouvier
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
../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.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/hvf/hvf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index a70f8461b0..c0d028b147 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -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]);
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 1/9] target/i386/hvf/hvf.c: fix compilation Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-09 8:20 ` Paolo Bonzini
2026-03-07 18:18 ` [PATCH v6 3/9] hvf: arm: unbreak the x86 build Mohamed Mediouni
` (6 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
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 <mohamed@unpredictable.fr>
---
meson.build | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 7b4e5bc72b..78bde0611b 100644
--- a/meson.build
+++ b/meson.build
@@ -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',
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 3/9] hvf: arm: unbreak the x86 build
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 1/9] target/i386/hvf/hvf.c: fix compilation Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-08 15:32 ` Philippe Mathieu-Daudé
2026-03-07 18:18 ` [PATCH v6 4/9] whpx: i386: do not enable nested virt when kernel-irqchip=off Mohamed Mediouni
` (5 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
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 <mohamed@unpredictable.fr
---
target/arm/hvf_arm.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h
index 6b1c3b9792..8029d48caf 100644
--- a/target/arm/hvf_arm.h
+++ b/target/arm/hvf_arm.h
@@ -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)
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 4/9] whpx: i386: do not enable nested virt when kernel-irqchip=off
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
` (2 preceding siblings ...)
2026-03-07 18:18 ` [PATCH v6 3/9] hvf: arm: unbreak the x86 build Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 5/9] target/i386: emulate: LA57 fix Mohamed Mediouni
` (4 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
This 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
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index c172e86886..9c60295d55 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -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(
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 5/9] target/i386: emulate: LA57 fix
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
` (3 preceding siblings ...)
2026-03-07 18:18 ` [PATCH v6 4/9] whpx: i386: do not enable nested virt when kernel-irqchip=off Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 6/9] whpx: i386: enable some more enlightenments Mohamed Mediouni
` (3 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
Seen 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.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/emulate/x86_mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/emulate/x86_mmu.c b/target/i386/emulate/x86_mmu.c
index 8261ca1635..4e39bae025 100644
--- a/target/i386/emulate/x86_mmu.c
+++ b/target/i386/emulate/x86_mmu.c
@@ -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)
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 6/9] whpx: i386: enable some more enlightenments
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
` (4 preceding siblings ...)
2026-03-07 18:18 ` [PATCH v6 5/9] target/i386: emulate: LA57 fix Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 7/9] whpx: make Hyper-V enlightenments configurable Mohamed Mediouni
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 9c60295d55..bc82995b33 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -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;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 7/9] whpx: make Hyper-V enlightenments configurable
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
` (5 preceding siblings ...)
2026-03-07 18:18 ` [PATCH v6 6/9] whpx: i386: enable some more enlightenments Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 8/9] whpx: arm64: enable enlightenments if asked for Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 9/9] whpx: i386: remove SIPI trapping Mohamed Mediouni
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
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 | 43 ++++++++++++++++++++++++++++++++++
include/system/whpx-internal.h | 4 ++++
target/i386/whpx/whpx-all.c | 20 +++++++++-------
3 files changed, 58 insertions(+), 9 deletions(-)
diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 4863fc8663..b813a5d9d2 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -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 = {
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)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 8/9] whpx: arm64: enable enlightenments if asked for
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
` (6 preceding siblings ...)
2026-03-07 18:18 ` [PATCH v6 7/9] whpx: make Hyper-V enlightenments configurable Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 9/9] whpx: i386: remove SIPI trapping Mohamed Mediouni
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/arm/whpx/whpx-all.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c
index c5b108166a..513551bec1 100644
--- a/target/arm/whpx/whpx-all.c
+++ b/target/arm/whpx/whpx-all.c
@@ -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);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v6 9/9] whpx: i386: remove SIPI trapping
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
` (7 preceding siblings ...)
2026-03-07 18:18 ` [PATCH v6 8/9] whpx: arm64: enable enlightenments if asked for Mohamed Mediouni
@ 2026-03-07 18:18 ` Mohamed Mediouni
8 siblings, 0 replies; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-07 18:18 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Mohamed Mediouni,
Paolo Bonzini, Philippe Mathieu-Daudé, Michael S. Tsirkin,
qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
The 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.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 97 -------------------------------------
1 file changed, 97 deletions(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b095c96962..4d5d3dbd24 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -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,
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v6 3/9] hvf: arm: unbreak the x86 build
2026-03-07 18:18 ` [PATCH v6 3/9] hvf: arm: unbreak the x86 build Mohamed Mediouni
@ 2026-03-08 15:32 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-08 15:32 UTC (permalink / raw)
To: Mohamed Mediouni, qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell, Paolo Bonzini,
Michael S. Tsirkin, qemu-arm, Phil Dennis-Jordan, Pedro Barbuda
On 7/3/26 19:18, Mohamed Mediouni wrote:
> 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 <mohamed@unpredictable.fr
> ---
> target/arm/hvf_arm.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
2026-03-07 18:18 ` [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK Mohamed Mediouni
@ 2026-03-09 8:20 ` Paolo Bonzini
2026-03-09 8:38 ` Mohamed Mediouni
0 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2026-03-09 8:20 UTC (permalink / raw)
To: Mohamed Mediouni, qemu-devel
Cc: Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell,
Philippe Mathieu-Daudé, Michael S. Tsirkin, qemu-arm,
Phil Dennis-Jordan, Pedro Barbuda
On 3/7/26 19:18, Mohamed Mediouni wrote:
> 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 <mohamed@unpredictable.fr>
> ---
> meson.build | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/meson.build b/meson.build
> index 7b4e5bc72b..78bde0611b 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
2026-03-09 8:20 ` Paolo Bonzini
@ 2026-03-09 8:38 ` Mohamed Mediouni
2026-03-09 11:16 ` Paolo Bonzini
0 siblings, 1 reply; 14+ messages in thread
From: Mohamed Mediouni @ 2026-03-09 8:38 UTC (permalink / raw)
To: Paolo Bonzini
Cc: qemu-devel, "Daniel P. Berrangé", Wei Liu,
Roman Bolshakov, Marc-André Lureau, Zhao Liu, Peter Maydell,
Philippe Mathieu-Daudé, Michael S. Tsirkin, qemu-arm,
Phil Dennis-Jordan, Pedro Barbuda
> On 9. Mar 2026, at 09:20, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 3/7/26 19:18, Mohamed Mediouni wrote:
>> 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 <mohamed@unpredictable.fr>
>> ---
>> meson.build | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/meson.build b/meson.build
>> index 7b4e5bc72b..78bde0611b 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -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?
Hello,
Yes, it’s enabled by default at least by the CI.
> 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
> I'm applying the other patches, but for this one I don't think this is
> the right fix.
>
>
> Paolo
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
2026-03-09 8:38 ` Mohamed Mediouni
@ 2026-03-09 11:16 ` Paolo Bonzini
0 siblings, 0 replies; 14+ messages in thread
From: Paolo Bonzini @ 2026-03-09 11:16 UTC (permalink / raw)
To: Mohamed Mediouni
Cc: qemu-devel, Daniel P. Berrangé, Wei Liu, Roman Bolshakov,
Marc-André Lureau, Zhao Liu, Peter Maydell,
Philippe Mathieu-Daudé, Michael S. Tsirkin, qemu-arm,
Phil Dennis-Jordan, Pedro Barbuda
On Mon, Mar 9, 2026 at 9:38 AM Mohamed Mediouni
<mohamed@unpredictable.fr> wrote:
> 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?
Yes, if that works it's better. For 11.1 we can look into adding
-Werror to all cc.has_function() calls.
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-03-09 11:17 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-07 18:18 [PATCH v6 0/9] hvf, whpx: i386: x86-centric fixes before softfreeze Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 1/9] target/i386/hvf/hvf.c: fix compilation Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK Mohamed Mediouni
2026-03-09 8:20 ` Paolo Bonzini
2026-03-09 8:38 ` Mohamed Mediouni
2026-03-09 11:16 ` Paolo Bonzini
2026-03-07 18:18 ` [PATCH v6 3/9] hvf: arm: unbreak the x86 build Mohamed Mediouni
2026-03-08 15:32 ` Philippe Mathieu-Daudé
2026-03-07 18:18 ` [PATCH v6 4/9] whpx: i386: do not enable nested virt when kernel-irqchip=off Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 5/9] target/i386: emulate: LA57 fix Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 6/9] whpx: i386: enable some more enlightenments Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 7/9] whpx: make Hyper-V enlightenments configurable Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 8/9] whpx: arm64: enable enlightenments if asked for Mohamed Mediouni
2026-03-07 18:18 ` [PATCH v6 9/9] whpx: i386: remove SIPI trapping Mohamed Mediouni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox