* [PATCH] target/i386/mshv: add SynIC MSR init routine
@ 2026-11-25 14:49 Magnus Kulke
2026-11-27 22:52 ` Wei Liu
0 siblings, 1 reply; 2+ messages in thread
From: Magnus Kulke @ 2026-11-25 14:49 UTC (permalink / raw)
To: qemu-devel
Cc: Magnus Kulke, Magnus Kulke, Wei Liu, Zhao Liu, Paolo Bonzini,
Doru Blânzeanu, Wei Liu
Windows guests on Microsoft Hypervisor expect to be initialized with a
specific set of values in its SynIC MSRs, otherwise the paravirtualized
timers will not work and boot will stall.
Reference:
https://github.com/microsoft/openvmm/blob/8d4e0313/vmm_core/virt/src/x86/vp.rs
L1801-L1813
Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
---
include/system/mshv.h | 3 +++
include/system/mshv_int.h | 1 +
target/i386/cpu.c | 4 ++++
target/i386/mshv/mshv-cpu.c | 5 +++++
target/i386/mshv/synic.c | 14 ++++++++++++++
5 files changed, 27 insertions(+)
diff --git a/include/system/mshv.h b/include/system/mshv.h
index 864f2aa34d..1c80916619 100644
--- a/include/system/mshv.h
+++ b/include/system/mshv.h
@@ -79,4 +79,7 @@ void mshv_init_irq_routing(MshvState *s);
/* cpuid */
uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg);
+/* cpu */
+void mshv_arch_reset_vcpu(CPUState *cpu);
+
#endif
diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h
index 01da21affe..e3e46304f9 100644
--- a/include/system/mshv_int.h
+++ b/include/system/mshv_int.h
@@ -172,5 +172,6 @@ int mshv_set_siefp(int cpu_fd, const uint8_t *page);
bool mshv_synic_enabled(const CPUState *cpu);
int mshv_get_synthetic_timers(int cpu_fd, uint8_t *state);
int mshv_set_synthetic_timers(int cpu_fd, const uint8_t *state);
+void mshv_init_synic(CPUState *cpu);
#endif
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index eab0d5a4d4..7d587a846c 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -9569,6 +9569,10 @@ static void x86_cpu_reset_hold(Object *obj, ResetType type)
kvm_arch_reset_vcpu(cpu);
}
+ if (mshv_enabled()) {
+ mshv_arch_reset_vcpu(cs);
+ }
+
x86_cpu_set_sgxlepubkeyhash(env);
env->amd_tsc_scale_msr = MSR_AMD64_TSC_RATIO_DEFAULT;
diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
index c145bbc447..be6530d641 100644
--- a/target/i386/mshv/mshv-cpu.c
+++ b/target/i386/mshv/mshv-cpu.c
@@ -2467,6 +2467,11 @@ static int set_unimplemented_msr_action(int vm_fd)
return 0;
}
+void mshv_arch_reset_vcpu(CPUState *cpu)
+{
+ mshv_init_synic(cpu);
+}
+
int mshv_arch_post_init_vm(int vm_fd)
{
int ret;
diff --git a/target/i386/mshv/synic.c b/target/i386/mshv/synic.c
index 4c629adc3a..7bd6727376 100644
--- a/target/i386/mshv/synic.c
+++ b/target/i386/mshv/synic.c
@@ -204,3 +204,17 @@ int mshv_set_siefp(int cpu_fd, const uint8_t *page)
return 0;
}
+
+void mshv_init_synic(CPUState *cpu)
+{
+ X86CPU *x86_cpu = X86_CPU(cpu);
+ CPUX86State *env = &x86_cpu->env;
+ size_t i;
+
+ env->msr_hv_synic_control = 1;
+ env->msr_hv_synic_evt_page = 0;
+ env->msr_hv_synic_msg_page = 0;
+ for (i = 0; i < HV_SINT_COUNT; i++) {
+ env->msr_hv_synic_sint[i] = 0x10000;
+ }
+}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] target/i386/mshv: add SynIC MSR init routine
2026-11-25 14:49 [PATCH] target/i386/mshv: add SynIC MSR init routine Magnus Kulke
@ 2026-11-27 22:52 ` Wei Liu
0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2026-11-27 22:52 UTC (permalink / raw)
To: Magnus Kulke
Cc: qemu-devel, Magnus Kulke, Wei Liu, Zhao Liu, Paolo Bonzini,
Doru Blânzeanu, Wei Liu
On Wed, Nov 25, 2026 at 03:49:11PM +0100, Magnus Kulke wrote:
> Windows guests on Microsoft Hypervisor expect to be initialized with a
> specific set of values in its SynIC MSRs, otherwise the paravirtualized
> timers will not work and boot will stall.
>
> Reference:
>
> https://github.com/microsoft/openvmm/blob/8d4e0313/vmm_core/virt/src/x86/vp.rs
>
> L1801-L1813
>
> Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
Acked-by: Wei Liu <wei.liu@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 22:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 14:49 [PATCH] target/i386/mshv: add SynIC MSR init routine Magnus Kulke
2026-11-27 22:52 ` Wei Liu
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.