* [PATCH v2 00/10] whpx: i386: Some more changes
@ 2026-04-15 13:29 Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 01/10] whpx: i386: set apicbase value only on success Mohamed Mediouni
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
This applies on top of the "whpx: i386: bug fixes, feature probing and CPUID" series.
"target: i386: HLT type that ignores EFLAGS.IF" is probably the most worthwhile patch
here, and that not-quite-an-HLT might be what's needed to reduce CPU idle on KVM on
recent Windows versions too..
v1 -> v2:
Oops, my v1 had a bug in HV_X64_MSR_GUEST_IDLE emulation, We should not inject interrupts
after it ignoring EFLAGS.IF. That matters just for the wake from HLT.
Trapping one more CPUID for x2APIC system topology, and some more x2APIC awareness. For the
kernel-irqchip=off case, keep the hypervisor aware of the initial APIC ID we're hoosing anyways.
Based-on: <20260413205208.50643-1-mohamed@unpredictable.fr>
Mohamed Mediouni (10):
whpx: i386: set apicbase value only on success
whpx: i386: unknown MSR configurability
whpx: i386: enable GuestIdleReg enlightenment
whpx: i386: tighten APIC base validity check
whpx: i386: ignore vpassist when kernel-irqchip=off
target: i386: HLT type that ignores EFLAGS.IF
whpx: i386: add HV_X64_MSR_GUEST_IDLE when !kernel-irqchip
whpx: i386: one more CPUID
whpx: i386: some x2APIC awareness
whpx: i386: set WHvX64RegisterInitialApicId
accel/whpx/whpx-common.c | 38 +++++++++++++++++
include/system/whpx-internal.h | 1 +
target/i386/cpu.c | 10 +++--
target/i386/cpu.h | 2 +
target/i386/whpx/whpx-all.c | 77 +++++++++++++++++++++++++++++++---
target/i386/whpx/whpx-apic.c | 12 +++++-
6 files changed, 129 insertions(+), 11 deletions(-)
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 01/10] whpx: i386: set apicbase value only on success
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 02/10] whpx: i386: unknown MSR configurability Mohamed Mediouni
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 86d2dc1df8..56a789c5fd 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2001,8 +2001,9 @@ int whpx_vcpu_run(CPUState *cpu)
int msr_ret = cpu_set_apic_base(X86_CPU(cpu)->apic_state, val);
if (msr_ret < 0) {
x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0);
+ } else {
+ whpx_set_reg(cpu, WHvX64RegisterApicBase, reg);
}
- whpx_set_reg(cpu, WHvX64RegisterApicBase, reg);
}
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 02/10] whpx: i386: unknown MSR configurability
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 01/10] whpx: i386: set apicbase value only on success Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 03/10] whpx: i386: enable GuestIdleReg enlightenment Mohamed Mediouni
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Add an option to inject back a GPF for unknown MSRs.
Keep it on by default for now as Linux expects accesses to some
AMD-specific MSRs to always succeed when on an AMD host.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
accel/whpx/whpx-common.c | 38 ++++++++++++++++++++++++++++++++++
include/system/whpx-internal.h | 1 +
target/i386/whpx/whpx-all.c | 4 ++++
3 files changed, 43 insertions(+)
diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 59be996aef..706871f138 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -505,6 +505,38 @@ static void whpx_set_hyperv(Object *obj, Visitor *v,
}
}
+static void whpx_set_unknown_msr(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->ignore_unknown_msr = true;
+ break;
+
+ case ON_OFF_AUTO_OFF:
+ whpx->ignore_unknown_msr = false;
+ break;
+
+ case ON_OFF_AUTO_AUTO:
+ whpx->ignore_unknown_msr = true;
+ 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);
@@ -538,6 +570,11 @@ static void whpx_accel_class_init(ObjectClass *oc, const void *data)
NULL, NULL);
object_class_property_set_description(oc, "hyperv",
"Configure Hyper-V enlightenments");
+ object_class_property_add(oc, "ignore-unknown-msr", "OnOffAuto",
+ NULL, whpx_set_unknown_msr,
+ NULL, NULL);
+ object_class_property_set_description(oc, "ignore-unknown-msr",
+ "Configure unknown MSR behavior");
}
static void whpx_accel_instance_init(Object *obj)
@@ -552,6 +589,7 @@ static void whpx_accel_instance_init(Object *obj)
whpx->hyperv_enlightenments_required = false;
/* Value determined at whpx_accel_init */
whpx->hyperv_enlightenments_enabled = false;
+ whpx->ignore_unknown_msr = true;
}
static const TypeInfo whpx_accel_type = {
diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h
index cf782cf5f8..86639627b3 100644
--- a/include/system/whpx-internal.h
+++ b/include/system/whpx-internal.h
@@ -47,6 +47,7 @@ struct whpx_state {
bool hyperv_enlightenments_required;
bool hyperv_enlightenments_enabled;
+ bool ignore_unknown_msr;
};
extern struct whpx_state whpx_global;
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 56a789c5fd..b248afb5e7 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2048,6 +2048,10 @@ int whpx_vcpu_run(CPUState *cpu)
vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite);
}
+ if (!is_known_msr && !whpx->ignore_unknown_msr) {
+ x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0);
+ }
+
hr = whp_dispatch.WHvSetVirtualProcessorRegisters(
whpx->partition,
cpu->cpu_index,
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 03/10] whpx: i386: enable GuestIdleReg enlightenment
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 01/10] whpx: i386: set apicbase value only on success Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 02/10] whpx: i386: unknown MSR configurability Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 04/10] whpx: i386: tighten APIC base validity check Mohamed Mediouni
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
This corresponds to HV_X64_MSR_GUEST_IDLE (0x400000f0).
This enlightenment is only available by the HV when using the Hyper-V LAPIC.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b248afb5e7..73066581d4 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2686,6 +2686,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
synthetic_features.Bank0.AccessIntrCtrlRegs = 1;
synthetic_features.Bank0.SyntheticClusterIpi = 1;
synthetic_features.Bank0.DirectSyntheticTimers = 1;
+ synthetic_features.Bank0.AccessGuestIdleReg = 1;
/*
* These technically work without the Hyper-V LAPIC
* but behave oddly for multi-core VMs.
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 04/10] whpx: i386: tighten APIC base validity check
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (2 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 03/10] whpx: i386: enable GuestIdleReg enlightenment Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 05/10] whpx: i386: ignore vpassist when kernel-irqchip=off Mohamed Mediouni
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, 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 73066581d4..6c39168b06 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -1993,6 +1993,9 @@ int whpx_vcpu_run(CPUState *cpu)
if (vcpu->exit_ctx.MsrAccess.MsrNumber == MSR_IA32_APICBASE) {
is_known_msr = 1;
+ if (val & MSR_IA32_APICBASE_RESERVED) {
+ x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0);
+ }
if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) {
/* Read path unreachable on Hyper-V */
abort();
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 05/10] whpx: i386: ignore vpassist when kernel-irqchip=off
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (3 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 04/10] whpx: i386: tighten APIC base validity check Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 06/10] target: i386: HLT type that ignores EFLAGS.IF Mohamed Mediouni
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Linux tries to set vpassist even when none of the enlightenments
using it are available.
So ignore the page it sets.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 6c39168b06..2e6679f40b 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -51,6 +51,7 @@
#define HYPERV_APIC_BUS_FREQUENCY (200000000ULL)
/* for kernel-irqchip=off */
#define HV_X64_MSR_APIC_FREQUENCY 0x40000023
+#define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073
static bool is_modern_os = true;
@@ -2033,6 +2034,18 @@ int whpx_vcpu_run(CPUState *cpu)
}
}
}
+
+ /*
+ * Linux tries to use it anyway even when not exposed.
+ * Ignore the write as the VP assist page is not used.
+ */
+ if (vcpu->exit_ctx.MsrAccess.MsrNumber == HV_X64_MSR_VP_ASSIST_PAGE
+ && vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite
+ && !whpx_irqchip_in_kernel()
+ && whpx->hyperv_enlightenments_enabled) {
+ is_known_msr = 1;
+ }
+
/*
* For all unsupported MSR access we:
* ignore writes
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 06/10] target: i386: HLT type that ignores EFLAGS.IF
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (4 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 05/10] whpx: i386: ignore vpassist when kernel-irqchip=off Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 07/10] whpx: i386: add HV_X64_MSR_GUEST_IDLE when !kernel-irqchip Mohamed Mediouni
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
The TLFS says:
> A partition which possesses the AccessGuestIdleMsr privilege may trigger
> entry into the virtual processor idle sleep state through a read to the
> hypervisor-defined MSR HV_X64_MSR_GUEST_IDLE. The virtual processor will
> be woken when an interrupt arrives, regardless of whether the interrupt
> is enabled on the virtual processor or not.
Meanwhile, Windows 24H2+ calls this MSR anyway without the privilege being set.
Add the infrastructure to support it on the generic QEMU side.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/cpu.c | 10 ++++++----
target/i386/cpu.h | 2 ++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0000093fa3..b18e40666e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -10482,13 +10482,15 @@ int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request)
(((env->hflags2 & HF2_VINTR_MASK) &&
(env->hflags2 & HF2_HIF_MASK)) ||
(!(env->hflags2 & HF2_VINTR_MASK) &&
- (env->eflags & IF_MASK &&
- !(env->hflags & HF_INHIBIT_IRQ_MASK))))) {
+ ((env->eflags & IF_MASK &&
+ !(env->hflags & HF_INHIBIT_IRQ_MASK))
+ || env->hflags2 & HF2_HYPERV_HLT_MASK)))) {
return CPU_INTERRUPT_HARD;
} else if (env->hflags2 & HF2_VGIF_MASK) {
if((interrupt_request & CPU_INTERRUPT_VIRQ) &&
- (env->eflags & IF_MASK) &&
- !(env->hflags & HF_INHIBIT_IRQ_MASK)) {
+ ((env->eflags & IF_MASK &&
+ !(env->hflags & HF_INHIBIT_IRQ_MASK))
+ || env->hflags2 & HF2_HYPERV_HLT_MASK)) {
return CPU_INTERRUPT_VIRQ;
}
}
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0b539155c4..67f508dc10 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -225,6 +225,7 @@ typedef enum X86Seg {
#define HF2_NPT_SHIFT 6 /* Nested Paging enabled */
#define HF2_IGNNE_SHIFT 7 /* Ignore CR0.NE=0 */
#define HF2_VGIF_SHIFT 8 /* Can take VIRQ*/
+#define HF2_HYPERV_HLT_SHIFT 9 /* Hyper-V HV_X64_MSR_GUEST_IDLE */
#define HF2_GIF_MASK (1 << HF2_GIF_SHIFT)
#define HF2_HIF_MASK (1 << HF2_HIF_SHIFT)
@@ -235,6 +236,7 @@ typedef enum X86Seg {
#define HF2_NPT_MASK (1 << HF2_NPT_SHIFT)
#define HF2_IGNNE_MASK (1 << HF2_IGNNE_SHIFT)
#define HF2_VGIF_MASK (1 << HF2_VGIF_SHIFT)
+#define HF2_HYPERV_HLT_MASK (1 << HF2_HYPERV_HLT_SHIFT)
#define CR0_PE_SHIFT 0
#define CR0_MP_SHIFT 1
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 07/10] whpx: i386: add HV_X64_MSR_GUEST_IDLE when !kernel-irqchip
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (5 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 06/10] target: i386: HLT type that ignores EFLAGS.IF Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 08/10] whpx: i386: one more CPUID Mohamed Mediouni
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Add support for an oddball HV_X64_MSR_GUEST_IDLE not-quite-an-HLT
that wakes the vCPU even if EFLAGS.IF is set.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 46 ++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 2e6679f40b..0b89fe093f 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -52,6 +52,7 @@
/* for kernel-irqchip=off */
#define HV_X64_MSR_APIC_FREQUENCY 0x40000023
#define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073
+#define HV_X64_MSR_GUEST_IDLE 0x400000f0
static bool is_modern_os = true;
@@ -1543,13 +1544,16 @@ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid)
}
}
-static int whpx_handle_halt(CPUState *cpu)
+static int whpx_handle_halt_generic(CPUState *cpu)
{
+ X86CPU *x86_cpu = X86_CPU(cpu);
+ CPUX86State *env = &x86_cpu->env;
+
int ret = 0;
bql_lock();
if (!(cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD) &&
- (cpu_env(cpu)->eflags & IF_MASK)) &&
+ ((cpu_env(cpu)->eflags & IF_MASK) || env->hflags2 & HF2_HYPERV_HLT_MASK)) &&
!cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) {
cpu->exception_index = EXCP_HLT;
cpu->halted = true;
@@ -1560,6 +1564,27 @@ static int whpx_handle_halt(CPUState *cpu)
return ret;
}
+static int whpx_handle_halt(CPUState *cpu)
+{
+ int ret = 0;
+
+ ret = whpx_handle_halt_generic(cpu);
+
+ return ret;
+}
+
+static int whpx_handle_hyperv_guestidle(CPUState *cpu)
+{
+ X86CPU *x86_cpu = X86_CPU(cpu);
+ CPUX86State *env = &x86_cpu->env;
+ int ret = 0;
+
+ env->hflags2 |= HF2_HYPERV_HLT_MASK;
+ ret = whpx_handle_halt_generic(cpu);
+
+ return ret;
+}
+
static void whpx_vcpu_kick_out_of_hlt(CPUState *cpu)
{
WHV_REGISTER_VALUE reg;
@@ -1763,9 +1788,10 @@ static void whpx_vcpu_process_async_events(CPUState *cpu)
}
if ((cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD) &&
- (env->eflags & IF_MASK)) ||
+ ((env->eflags & IF_MASK) || env->hflags2 & HF2_HYPERV_HLT_MASK)) ||
cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) {
cpu->halted = false;
+ env->hflags2 &= ~HF2_HYPERV_HLT_MASK;
}
if (cpu_test_interrupt(cpu, CPU_INTERRUPT_SIPI)) {
@@ -2035,6 +2061,20 @@ int whpx_vcpu_run(CPUState *cpu)
}
}
+ /*
+ * Windows and Linux both use this MSR.
+ * Windows 11 25H2 uses it even when not advertised.
+ */
+ if (vcpu->exit_ctx.MsrAccess.MsrNumber == HV_X64_MSR_GUEST_IDLE
+ && !vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite
+ && !whpx_irqchip_in_kernel()
+ && whpx->hyperv_enlightenments_enabled) {
+ is_known_msr = 1;
+ whpx_bump_rip(cpu, &vcpu->exit_ctx);
+ ret = whpx_handle_hyperv_guestidle(cpu);
+ break;
+ }
+
/*
* Linux tries to use it anyway even when not exposed.
* Ignore the write as the VP assist page is not used.
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 08/10] whpx: i386: one more CPUID
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (6 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 07/10] whpx: i386: add HV_X64_MSR_GUEST_IDLE when !kernel-irqchip Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 09/10] whpx: i386: some x2APIC awareness Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 10/10] whpx: i386: set WHvX64RegisterInitialApicId Mohamed Mediouni
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Trap cpuid_0xb as it has x2APIC topology information.
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 0b89fe093f..9442c240b8 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2527,7 +2527,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
WHV_PROCESSOR_FEATURES_BANKS processor_features;
WHV_PROCESSOR_PERFMON_FEATURES perfmon_features;
- UINT32 cpuidExitList[] = {0x0, 0x1, 0x6, 0x7, 0x14, 0x24, 0x29, 0x1E,
+ UINT32 cpuidExitList[] = {0x0, 0x1, 0x6, 0x7, 0xb, 0x14, 0x24, 0x29, 0x1E,
0x40000000, 0x40000001, 0x40000010, 0x80000000, 0x80000001,
0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008,
0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001};
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 09/10] whpx: i386: some x2APIC awareness
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (7 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 08/10] whpx: i386: one more CPUID Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 10/10] whpx: i386: set WHvX64RegisterInitialApicId Mohamed Mediouni
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-apic.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c
index 65629ca45f..cc272f82a5 100644
--- a/target/i386/whpx/whpx-apic.c
+++ b/target/i386/whpx/whpx-apic.c
@@ -33,7 +33,11 @@ static void whpx_put_apic_state(APICCommonState *s,
int i;
memset(kapic, 0, sizeof(*kapic));
- kapic->fields[0x2].data = s->id << 24;
+ if (s->apicbase & MSR_IA32_APICBASE_EXTD) {
+ kapic->fields[0x2].data = s->initial_apic_id;
+ } else {
+ kapic->fields[0x2].data = s->id << 24;
+ }
kapic->fields[0x3].data = s->version | ((APIC_LVT_NB - 1) << 16);
kapic->fields[0x8].data = s->tpr;
kapic->fields[0xd].data = s->log_dest << 24;
@@ -61,7 +65,11 @@ static void whpx_get_apic_state(APICCommonState *s,
{
int i, v;
- s->id = kapic->fields[0x2].data >> 24;
+ if (s->apicbase & MSR_IA32_APICBASE_EXTD) {
+ assert(kapic->fields[0x2].data == s->initial_apic_id);
+ } else {
+ s->id = kapic->fields[0x2].data >> 24;
+ }
s->tpr = kapic->fields[0x8].data;
s->arb_id = kapic->fields[0x9].data;
s->log_dest = kapic->fields[0xd].data >> 24;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 10/10] whpx: i386: set WHvX64RegisterInitialApicId
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
` (8 preceding siblings ...)
2026-04-15 13:29 ` [PATCH v2 09/10] whpx: i386: some x2APIC awareness Mohamed Mediouni
@ 2026-04-15 13:29 ` Mohamed Mediouni
9 siblings, 0 replies; 11+ messages in thread
From: Mohamed Mediouni @ 2026-04-15 13:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mohamed Mediouni, Zhao Liu, Paolo Bonzini, Pedro Barbuda
Keep Hyper-V aware of the initial APIC ID chosen.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
target/i386/whpx/whpx-all.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 9442c240b8..62fb9b5fc1 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2398,6 +2398,11 @@ int whpx_init_vcpu(CPUState *cpu)
goto error;
}
+ if (!whpx_irqchip_in_kernel()) {
+ WHV_REGISTER_VALUE apic_id = {.Reg64 = x86_cpu->apic_state->initial_apic_id};
+ whpx_set_reg(cpu, WHvX64RegisterInitialApicId, apic_id);
+ }
+
/*
* vcpu's TSC frequency is either specified by user, or use the value
* provided by Hyper-V if the former is not present. In the latter case, we
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-04-15 13:31 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 13:29 [PATCH v2 00/10] whpx: i386: Some more changes Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 01/10] whpx: i386: set apicbase value only on success Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 02/10] whpx: i386: unknown MSR configurability Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 03/10] whpx: i386: enable GuestIdleReg enlightenment Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 04/10] whpx: i386: tighten APIC base validity check Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 05/10] whpx: i386: ignore vpassist when kernel-irqchip=off Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 06/10] target: i386: HLT type that ignores EFLAGS.IF Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 07/10] whpx: i386: add HV_X64_MSR_GUEST_IDLE when !kernel-irqchip Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 08/10] whpx: i386: one more CPUID Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 09/10] whpx: i386: some x2APIC awareness Mohamed Mediouni
2026-04-15 13:29 ` [PATCH v2 10/10] whpx: i386: set WHvX64RegisterInitialApicId Mohamed Mediouni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.