]>
Commit | Line | Data |
---|---|---|
f6df304f TL |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Maxim Levitsky <mlevitsk@redhat.com> | |
83250735 | 3 | Date: Wed, 3 Aug 2022 18:50:02 +0300 |
f6df304f | 4 | Subject: [PATCH] KVM: x86: emulator: update the emulation mode after rsm |
826eb0ff FG |
5 | MIME-Version: 1.0 |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
f6df304f TL |
8 | |
9 | This ensures that RIP will be correctly written back, | |
10 | because the RSM instruction can switch the CPU mode from | |
11 | 32 bit (or less) to 64 bit. | |
12 | ||
13 | This fixes a guest crash in case the #SMI is received | |
14 | while the guest runs a code from an address > 32 bit. | |
15 | ||
16 | Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> | |
17 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> | |
826eb0ff | 18 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> |
f6df304f TL |
19 | --- |
20 | arch/x86/kvm/emulate.c | 5 +++++ | |
21 | 1 file changed, 5 insertions(+) | |
22 | ||
23 | diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c | |
12247ad0 | 24 | index 4a43261d25a2..4f7f5117ec7a 100644 |
f6df304f TL |
25 | --- a/arch/x86/kvm/emulate.c |
26 | +++ b/arch/x86/kvm/emulate.c | |
4fc427d9 | 27 | @@ -2654,6 +2654,11 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt) |
f6df304f TL |
28 | if (ret != X86EMUL_CONTINUE) |
29 | goto emulate_shutdown; | |
30 | ||
31 | + | |
83250735 | 32 | + ret = emulator_recalc_and_set_mode(ctxt); |
f6df304f TL |
33 | + if (ret != X86EMUL_CONTINUE) |
34 | + goto emulate_shutdown; | |
35 | + | |
36 | /* | |
37 | * Note, the ctxt->ops callbacks are responsible for handling side | |
38 | * effects when writing MSRs and CRs, e.g. MMU context resets, CPUID |