Commit e2840efd97 for qemu.org

commit e2840efd973c8280ccaefb5713dde54f8ee36d5f
Author: Magnus Kulke <magnuskulke@linux.microsoft.com>
Date:   Fri Apr 17 12:56:16 2026 +0200

    target/i386/mshv: reconstruct hflags after load

    hflags is a cached bitmap derived from standard and special regs. We
    want to reconstruct this state after regs and sregs have been read from
    the hypervisor, similar to how it's one in other accelerators.

    Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
    Link: https://lore.kernel.org/r/20260417105618.3621-33-magnuskulke@linux.microsoft.com
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
index bbf874f641..8bd63bd962 100644
--- a/target/i386/mshv/mshv-cpu.c
+++ b/target/i386/mshv/mshv-cpu.c
@@ -765,6 +765,16 @@ static int set_vcpu_events(const CPUState *cpu)
     return 0;
 }

+static int update_hflags(CPUState *cpu)
+{
+    X86CPU *x86cpu = X86_CPU(cpu);
+    CPUX86State *env = &x86cpu->env;
+
+    x86_update_hflags(env);
+
+    return 0;
+}
+
 int mshv_arch_load_vcpu_state(CPUState *cpu)
 {
     int ret;
@@ -779,6 +789,9 @@ int mshv_arch_load_vcpu_state(CPUState *cpu)
         return ret;
     }

+    /* INVARIANT: hflags are derived from regs+sregs, need to get both first */
+    update_hflags(cpu);
+
     ret = get_xc_reg(cpu);
     if (ret < 0) {
         return ret;