0009-KVM-x86-emulator-update-the-emulation-mode-after-rsm.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Maxim Levitsky <[email protected]>
  3. Date: Wed, 3 Aug 2022 18:50:02 +0300
  4. Subject: [PATCH] KVM: x86: emulator: update the emulation mode after rsm
  5. This ensures that RIP will be correctly written back,
  6. 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
  9. while the guest runs a code from an address > 32 bit.
  10. Signed-off-by: Maxim Levitsky <[email protected]>
  11. Signed-off-by: Thomas Lamprecht <[email protected]>
  12. ---
  13. arch/x86/kvm/emulate.c | 5 +++++
  14. 1 file changed, 5 insertions(+)
  15. diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
  16. index 4a43261d25a2..4f7f5117ec7a 100644
  17. --- a/arch/x86/kvm/emulate.c
  18. +++ b/arch/x86/kvm/emulate.c
  19. @@ -2654,6 +2654,11 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
  20. if (ret != X86EMUL_CONTINUE)
  21. goto emulate_shutdown;
  22. +
  23. + ret = emulator_recalc_and_set_mode(ctxt);
  24. + if (ret != X86EMUL_CONTINUE)
  25. + goto emulate_shutdown;
  26. +
  27. /*
  28. * Note, the ctxt->ops callbacks are responsible for handling side
  29. * effects when writing MSRs and CRs, e.g. MMU context resets, CPUID