0019-KVM-x86-emulator-update-the-emulation-mode-after-rsm.patch 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. From 6d83f3690f8f3026df587db2264f0917ba747de9 Mon Sep 17 00:00:00 2001
  2. From: Maxim Levitsky <[email protected]>
  3. Date: Tue, 25 Oct 2022 15:47:30 +0300
  4. Subject: [PATCH] KVM: x86: emulator: update the emulation mode after rsm
  5. Update the emulation mode after RSM so that RIP will be correctly
  6. written back, because the RSM instruction can switch the CPU mode from
  7. 32 bit (or less) to 64 bit.
  8. This fixes a guest crash in case the #SMI is received while the guest
  9. runs a code from an address > 32 bit.
  10. Signed-off-by: Maxim Levitsky <[email protected]>
  11. ---
  12. arch/x86/kvm/emulate.c | 2 +-
  13. 1 file changed, 1 insertion(+), 1 deletion(-)
  14. diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
  15. index d75d33d60cb8..4365137d823b 100644
  16. --- a/arch/x86/kvm/emulate.c
  17. +++ b/arch/x86/kvm/emulate.c
  18. @@ -2313,7 +2313,7 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
  19. if (ctxt->ops->leave_smm(ctxt))
  20. ctxt->ops->triple_fault(ctxt);
  21. - return X86EMUL_CONTINUE;
  22. + return emulator_recalc_and_set_mode(ctxt);
  23. }
  24. static void
  25. --
  26. 2.38.1