@samitouri / QOSamiQemu / commits / 3b599ae592

target/i386/mshv: toggle fpu/xsave migration

MSHV exposes overlapping legacy FP/SSE state through two paths: explicit Hyper-V FPU/XMM + registers and VP XSAVE state. There can be subtle inconsistencies across migrations when XSAVE is written after FPU state. Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com> Link: https://lore.kernel.org/r/20260710101534.664604-12-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Magnus Kulke committed Jul 10, 2026 at 12:15 UTC 3b599ae592db07e666cc2a7f1f449b4d792fbc95
1 file changed +5 -4
target/i386/mshv/mshv-cpu.c
+5 -4
@@ -950,7 +950,7 @@ int mshv_arch_load_vcpu_state(CPUState *cpu)
950 return ret;
951 }
952
953 - ret = get_fpu(cpu);
953 + ret = get_xsave_state(cpu);
954 if (ret < 0) {
955 return ret;
956 }
@@ -960,7 +960,7 @@ int mshv_arch_load_vcpu_state(CPUState *cpu)
960 return ret;
961 }
962
963 - ret = get_xsave_state(cpu);
963 + ret = get_fpu(cpu);
964 if (ret < 0) {
965 return ret;
966 }
@@ -1506,7 +1506,7 @@ int mshv_arch_store_vcpu_state(const CPUState *cpu)
1506 return ret;
1507 }
1508
1509 - ret = set_fpu(cpu);
1509 + ret = set_xsave_state(cpu);
1510 if (ret < 0) {
1511 return ret;
1512 }
@@ -1516,7 +1516,8 @@ int mshv_arch_store_vcpu_state(const CPUState *cpu)
1516 return ret;
1517 }
1518
1519 - ret = set_xsave_state(cpu);
1519 + /* INVARIANT: legacy FPU state must be restored after XSAVE */
1520 + ret = set_fpu(cpu);
1521 if (ret < 0) {
1522 return ret;
1523 }