aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-09-09 07:12:54 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:27 -0400
commitb85b9ee9259917f248ee1507d7d1f575f4fc27dd (patch)
tree7455f36a04f4e87665a1b44dcfc1b5595eeb9289
parentc9a1185c945c8db3185ad40092963cbb39192e31 (diff)
KVM: Clean up unloved invlpg emulation
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>
-rw-r--r--drivers/kvm/kvm.h2
-rw-r--r--drivers/kvm/svm.c2
-rw-r--r--drivers/kvm/x86_emulate.c16
3 files changed, 3 insertions, 17 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 7c353524af2b..9bf9ac6389b1 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -539,8 +539,6 @@ static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
539hpa_t gva_to_hpa(struct kvm_vcpu *vcpu, gva_t gva); 539hpa_t gva_to_hpa(struct kvm_vcpu *vcpu, gva_t gva);
540struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); 540struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
541 541
542void kvm_emulator_want_group7_invlpg(void);
543
544extern hpa_t bad_page_address; 542extern hpa_t bad_page_address;
545 543
546struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); 544struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index dbd4e813cbe4..e51f6b7f8ff3 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -376,8 +376,6 @@ static __init int svm_hardware_setup(void)
376 void *iopm_va, *msrpm_va; 376 void *iopm_va, *msrpm_va;
377 int r; 377 int r;
378 378
379 kvm_emulator_want_group7_invlpg();
380
381 iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER); 379 iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER);
382 380
383 if (!iopm_pages) 381 if (!iopm_pages)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index 7439b3422ecf..342594d78d8c 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -213,19 +213,6 @@ static u16 twobyte_table[256] = {
213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
214}; 214};
215 215
216/*
217 * Tell the emulator that of the Group 7 instructions (sgdt, lidt, etc.) we
218 * are interested only in invlpg and not in any of the rest.
219 *
220 * invlpg is a special instruction in that the data it references may not
221 * be mapped.
222 */
223void kvm_emulator_want_group7_invlpg(void)
224{
225 twobyte_table[1] &= ~SrcMem;
226}
227EXPORT_SYMBOL_GPL(kvm_emulator_want_group7_invlpg);
228
229/* Type, address-of, and value of an instruction's operand. */ 216/* Type, address-of, and value of an instruction's operand. */
230struct operand { 217struct operand {
231 enum { OP_REG, OP_MEM, OP_IMM } type; 218 enum { OP_REG, OP_MEM, OP_IMM } type;
@@ -791,6 +778,9 @@ done_prefixes:
791 goto srcmem_common; 778 goto srcmem_common;
792 case SrcMem: 779 case SrcMem:
793 src.bytes = (d & ByteOp) ? 1 : op_bytes; 780 src.bytes = (d & ByteOp) ? 1 : op_bytes;
781 /* Don't fetch the address for invlpg: it could be unmapped. */
782 if (twobyte && b == 0x01 && modrm_reg == 7)
783 break;
794 srcmem_common: 784 srcmem_common:
795 src.type = OP_MEM; 785 src.type = OP_MEM;
796 src.ptr = (unsigned long *)cr2; 786 src.ptr = (unsigned long *)cr2;