@samitouri / QOSamiQemu / commits / 40f1b4d61c

whpx: i386: don't restore segment registers after MMIO handling

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260324151323.74473-6-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Mar 24, 2026 at 16:13 UTC 40f1b4d61c315f4d9a4fd8ff3fe4bc2eb60f4713
1 file changed +12 -10
target/i386/whpx/whpx-all.c
+12 -10
@@ -416,19 +416,21 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel level)
416 assert(whpx_register_names[idx] == WHvX64RegisterRflags);
417 lflags_to_rflags(env);
418 vcxt.values[idx++].Reg64 = env->eflags;
419 -
420 - /* Translate 6+4 segment registers. HV and QEMU order matches */
419 assert(idx == WHvX64RegisterEs);
422 - for (i = 0; i < 6; i += 1, idx += 1) {
423 - vcxt.values[idx].Segment = whpx_seg_q2h(&env->segs[i], v86, r86);
424 - }
420
426 - assert(idx == WHvX64RegisterLdtr);
427 - /*
428 - * Skip those registers for synchronisation after MMIO accesses
429 - * as they're not going to be modified in that case.
430 - */
421 if (level > WHPX_LEVEL_FAST_RUNTIME_STATE) {
422 +
423 + /* Translate 6+4 segment registers. HV and QEMU order matches */
424 + for (i = 0; i < 6; i += 1, idx += 1) {
425 + vcxt.values[idx].Segment = whpx_seg_q2h(&env->segs[i], v86, r86);
426 + }
427 +
428 + assert(idx == WHvX64RegisterLdtr);
429 + /*
430 + * Skip those registers for synchronisation after MMIO accesses
431 + * as they're not going to be modified in that case.
432 + */
433 +
434 vcxt.values[idx++].Segment = whpx_seg_q2h(&env->ldt, 0, 0);
435
436 assert(idx == WHvX64RegisterTr);