2022-07-27 14:45:07 +03:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maxim Levitsky <mlevitsk@redhat.com>
|
2022-08-08 16:08:52 +03:00
|
|
|
Date: Wed, 3 Aug 2022 18:50:02 +0300
|
2022-07-27 14:45:07 +03:00
|
|
|
Subject: [PATCH] KVM: x86: emulator: update the emulation mode after rsm
|
|
|
|
|
|
|
|
This ensures that RIP will be correctly written back,
|
|
|
|
because the RSM instruction can switch the CPU mode from
|
|
|
|
32 bit (or less) to 64 bit.
|
|
|
|
|
|
|
|
This fixes a guest crash in case the #SMI is received
|
|
|
|
while the guest runs a code from an address > 32 bit.
|
|
|
|
|
|
|
|
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
|
|
|
---
|
|
|
|
arch/x86/kvm/emulate.c | 5 +++++
|
|
|
|
1 file changed, 5 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
|
2024-02-08 20:49:26 +03:00
|
|
|
index 98b25a7af8ce8..0616ee9cd9778 100644
|
2022-07-27 14:45:07 +03:00
|
|
|
--- a/arch/x86/kvm/emulate.c
|
|
|
|
+++ b/arch/x86/kvm/emulate.c
|
2022-10-13 11:28:51 +03:00
|
|
|
@@ -2638,6 +2638,11 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
|
2022-07-27 14:45:07 +03:00
|
|
|
if (ret != X86EMUL_CONTINUE)
|
|
|
|
goto emulate_shutdown;
|
|
|
|
|
|
|
|
+
|
2022-08-08 16:08:52 +03:00
|
|
|
+ ret = emulator_recalc_and_set_mode(ctxt);
|
2022-07-27 14:45:07 +03:00
|
|
|
+ if (ret != X86EMUL_CONTINUE)
|
|
|
|
+ goto emulate_shutdown;
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Note, the ctxt->ops callbacks are responsible for handling side
|
|
|
|
* effects when writing MSRs and CRs, e.g. MMU context resets, CPUID
|