]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.36.2/kvm-correct-ordering-of-ldt-reload-wrt-fs-gs-reload.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.2 / kvm-correct-ordering-of-ldt-reload-wrt-fs-gs-reload.patch
1 From 0a77fe4c188e25917799f2356d4aa5e6d80c39a2 Mon Sep 17 00:00:00 2001
2 From: Avi Kivity <avi@redhat.com>
3 Date: Tue, 19 Oct 2010 18:48:35 +0200
4 Subject: KVM: Correct ordering of ldt reload wrt fs/gs reload
5
6 From: Avi Kivity <avi@redhat.com>
7
8 commit 0a77fe4c188e25917799f2356d4aa5e6d80c39a2 upstream.
9
10 If fs or gs refer to the ldt, they must be reloaded after the ldt. Reorder
11 the code to that effect.
12
13 Userspace code that uses the ldt with kvm is nonexistent, so this doesn't fix
14 a user-visible bug.
15
16 Signed-off-by: Avi Kivity <avi@redhat.com>
17 Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
19
20 ---
21 arch/x86/kvm/svm.c | 2 +-
22 arch/x86/kvm/vmx.c | 4 ++--
23 2 files changed, 3 insertions(+), 3 deletions(-)
24
25 --- a/arch/x86/kvm/svm.c
26 +++ b/arch/x86/kvm/svm.c
27 @@ -3281,6 +3281,7 @@ static void svm_vcpu_run(struct kvm_vcpu
28 vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip;
29
30 load_host_msrs(vcpu);
31 + kvm_load_ldt(ldt_selector);
32 loadsegment(fs, fs_selector);
33 #ifdef CONFIG_X86_64
34 load_gs_index(gs_selector);
35 @@ -3288,7 +3289,6 @@ static void svm_vcpu_run(struct kvm_vcpu
36 #else
37 loadsegment(gs, gs_selector);
38 #endif
39 - kvm_load_ldt(ldt_selector);
40
41 reload_tss(vcpu);
42
43 --- a/arch/x86/kvm/vmx.c
44 +++ b/arch/x86/kvm/vmx.c
45 @@ -846,8 +846,6 @@ static void __vmx_load_host_state(struct
46
47 ++vmx->vcpu.stat.host_state_reload;
48 vmx->host_state.loaded = 0;
49 - if (vmx->host_state.fs_reload_needed)
50 - loadsegment(fs, vmx->host_state.fs_sel);
51 if (vmx->host_state.gs_ldt_reload_needed) {
52 kvm_load_ldt(vmx->host_state.ldt_sel);
53 #ifdef CONFIG_X86_64
54 @@ -857,6 +855,8 @@ static void __vmx_load_host_state(struct
55 loadsegment(gs, vmx->host_state.gs_sel);
56 #endif
57 }
58 + if (vmx->host_state.fs_reload_needed)
59 + loadsegment(fs, vmx->host_state.fs_sel);
60 reload_tss();
61 #ifdef CONFIG_X86_64
62 if (is_long_mode(&vmx->vcpu)) {