]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: Clean up unloved invlpg emulation
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 9 Sep 2007 11:12:54 +0000 (14:12 +0300)
committerAvi Kivity <avi@qumranet.com>
Sat, 13 Oct 2007 08:18:27 +0000 (10:18 +0200)
invlpg shouldn't fetch the "src" address, since it may not be valid,
however SVM's "solution" which neuters emulation of all group 7
instruction is horrible and breaks kvm-lite.  The simplest fix is to
put a special check in for invlpg.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm.h
drivers/kvm/svm.c
drivers/kvm/x86_emulate.c

index 7c353524af2b79dd3c9487a12b8d6a942398d390..9bf9ac6389b1690fce7668bdac01c4d6067cd744 100644 (file)
@@ -539,8 +539,6 @@ static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
 hpa_t gva_to_hpa(struct kvm_vcpu *vcpu, gva_t gva);
 struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
 
-void kvm_emulator_want_group7_invlpg(void);
-
 extern hpa_t bad_page_address;
 
 struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
index dbd4e813cbe431c11683c7597608b2c1e4ce4509..e51f6b7f8ff3a193cdd182863a4468e528c468ac 100644 (file)
@@ -376,8 +376,6 @@ static __init int svm_hardware_setup(void)
        void *iopm_va, *msrpm_va;
        int r;
 
-       kvm_emulator_want_group7_invlpg();
-
        iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER);
 
        if (!iopm_pages)
index 7439b3422ecf92181ca0fd0afedb571f9ae9d45c..342594d78d8c34244ceff1cb9eb5638b54300f9a 100644 (file)
@@ -213,19 +213,6 @@ static u16 twobyte_table[256] = {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 };
 
-/*
- * Tell the emulator that of the Group 7 instructions (sgdt, lidt, etc.) we
- * are interested only in invlpg and not in any of the rest.
- *
- * invlpg is a special instruction in that the data it references may not
- * be mapped.
- */
-void kvm_emulator_want_group7_invlpg(void)
-{
-       twobyte_table[1] &= ~SrcMem;
-}
-EXPORT_SYMBOL_GPL(kvm_emulator_want_group7_invlpg);
-
 /* Type, address-of, and value of an instruction's operand. */
 struct operand {
        enum { OP_REG, OP_MEM, OP_IMM } type;
@@ -791,6 +778,9 @@ done_prefixes:
                goto srcmem_common;
        case SrcMem:
                src.bytes = (d & ByteOp) ? 1 : op_bytes;
+               /* Don't fetch the address for invlpg: it could be unmapped. */
+               if (twobyte && b == 0x01 && modrm_reg == 7)
+                       break;
              srcmem_common:
                src.type = OP_MEM;
                src.ptr = (unsigned long *)cr2;