]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
KVM: VMX: Fix host GDT.LIMIT corruption
authorAvi Kivity <avi@redhat.com>
Mon, 26 Jul 2010 15:32:38 +0000 (18:32 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 2 Aug 2010 05:10:18 +0000 (08:10 +0300)
vmx does not restore GDT.LIMIT to the host value, instead it sets it to 64KB.
This means host userspace can learn a few bits of host memory.

Fix by reloading GDTR when we load other host state.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/vmx.c

index 2fdcc9819f36bc5faab15853a984af16587c0de5..27a0222c29460d79e6e65992ac00fc2845f8f25b 100644 (file)
@@ -185,6 +185,7 @@ static void kvm_cpu_vmxoff(void);
 static DEFINE_PER_CPU(struct vmcs *, vmxarea);
 static DEFINE_PER_CPU(struct vmcs *, current_vmcs);
 static DEFINE_PER_CPU(struct list_head, vcpus_on_cpu);
+static DEFINE_PER_CPU(struct desc_ptr, host_gdt);
 
 static unsigned long *vmx_io_bitmap_a;
 static unsigned long *vmx_io_bitmap_b;
@@ -871,6 +872,7 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
 #endif
        if (current_thread_info()->status & TS_USEDFPU)
                clts();
+       load_gdt(&__get_cpu_var(host_gdt));
 }
 
 static void vmx_load_host_state(struct vcpu_vmx *vmx)
@@ -1379,6 +1381,8 @@ static int hardware_enable(void *garbage)
                ept_sync_global();
        }
 
+       store_gdt(&__get_cpu_var(host_gdt));
+
        return 0;
 }