diff options
author | Andre Przywara <andre.przywara@amd.com> | 2010-12-21 05:12:07 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:31:07 -0500 |
commit | dc25e89e07d5ef31c476117d2c76b34dbb22196c (patch) | |
tree | 9fef452c4bd0704b9d74512a9a58dc5d5b742d53 /arch/x86/include/asm | |
parent | df4f3108562dc6f6ae6648f2698df7f4c9acf52d (diff) |
KVM: SVM: copy instruction bytes from VMCB
In case of a nested page fault or an intercepted #PF newer SVM
implementations provide a copy of the faulting instruction bytes
in the VMCB.
Use these bytes to feed the instruction emulator and avoid the costly
guest instruction fetch in this case.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/include/asm')
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 9 | ||||
-rw-r--r-- | arch/x86/include/asm/svm.h | 4 |
3 files changed, 9 insertions, 6 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index bf70ecea3974..8e37deb1eb38 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -265,7 +265,7 @@ struct x86_emulate_ctxt { | |||
265 | #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 | 265 | #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | int x86_decode_insn(struct x86_emulate_ctxt *ctxt); | 268 | int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len); |
269 | #define EMULATION_FAILED -1 | 269 | #define EMULATION_FAILED -1 |
270 | #define EMULATION_OK 0 | 270 | #define EMULATION_OK 0 |
271 | #define EMULATION_RESTART 1 | 271 | #define EMULATION_RESTART 1 |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index de00b6026b76..6268f6ce6434 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -634,13 +634,13 @@ enum emulation_result { | |||
634 | #define EMULTYPE_NO_DECODE (1 << 0) | 634 | #define EMULTYPE_NO_DECODE (1 << 0) |
635 | #define EMULTYPE_TRAP_UD (1 << 1) | 635 | #define EMULTYPE_TRAP_UD (1 << 1) |
636 | #define EMULTYPE_SKIP (1 << 2) | 636 | #define EMULTYPE_SKIP (1 << 2) |
637 | int x86_emulate_instruction(struct kvm_vcpu *vcpu, | 637 | int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, |
638 | unsigned long cr2, int emulation_type); | 638 | int emulation_type, void *insn, int insn_len); |
639 | 639 | ||
640 | static inline int emulate_instruction(struct kvm_vcpu *vcpu, | 640 | static inline int emulate_instruction(struct kvm_vcpu *vcpu, |
641 | int emulation_type) | 641 | int emulation_type) |
642 | { | 642 | { |
643 | return x86_emulate_instruction(vcpu, 0, emulation_type); | 643 | return x86_emulate_instruction(vcpu, 0, emulation_type, NULL, 0); |
644 | } | 644 | } |
645 | 645 | ||
646 | void realmode_lgdt(struct kvm_vcpu *vcpu, u16 size, unsigned long address); | 646 | void realmode_lgdt(struct kvm_vcpu *vcpu, u16 size, unsigned long address); |
@@ -721,7 +721,8 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu); | |||
721 | 721 | ||
722 | int kvm_fix_hypercall(struct kvm_vcpu *vcpu); | 722 | int kvm_fix_hypercall(struct kvm_vcpu *vcpu); |
723 | 723 | ||
724 | int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); | 724 | int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, |
725 | void *insn, int insn_len); | ||
725 | void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); | 726 | void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); |
726 | 727 | ||
727 | void kvm_enable_tdp(void); | 728 | void kvm_enable_tdp(void); |
diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index f0ffb8184089..f2b83bc7d784 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h | |||
@@ -83,7 +83,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area { | |||
83 | u32 clean; | 83 | u32 clean; |
84 | u32 reserved_5; | 84 | u32 reserved_5; |
85 | u64 next_rip; | 85 | u64 next_rip; |
86 | u8 reserved_6[816]; | 86 | u8 insn_len; |
87 | u8 insn_bytes[15]; | ||
88 | u8 reserved_6[800]; | ||
87 | }; | 89 | }; |
88 | 90 | ||
89 | 91 | ||