diff options
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 506bd2b4b8bb..542f6315444d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4987,7 +4987,7 @@ int handle_ud(struct kvm_vcpu *vcpu) | |||
4987 | emul_type = 0; | 4987 | emul_type = 0; |
4988 | } | 4988 | } |
4989 | 4989 | ||
4990 | er = emulate_instruction(vcpu, emul_type); | 4990 | er = kvm_emulate_instruction(vcpu, emul_type); |
4991 | if (er == EMULATE_USER_EXIT) | 4991 | if (er == EMULATE_USER_EXIT) |
4992 | return 0; | 4992 | return 0; |
4993 | if (er != EMULATE_DONE) | 4993 | if (er != EMULATE_DONE) |
@@ -5870,7 +5870,10 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2, | |||
5870 | gpa_t gpa = cr2; | 5870 | gpa_t gpa = cr2; |
5871 | kvm_pfn_t pfn; | 5871 | kvm_pfn_t pfn; |
5872 | 5872 | ||
5873 | if (emulation_type & EMULTYPE_NO_REEXECUTE) | 5873 | if (!(emulation_type & EMULTYPE_ALLOW_RETRY)) |
5874 | return false; | ||
5875 | |||
5876 | if (WARN_ON_ONCE(is_guest_mode(vcpu))) | ||
5874 | return false; | 5877 | return false; |
5875 | 5878 | ||
5876 | if (!vcpu->arch.mmu.direct_map) { | 5879 | if (!vcpu->arch.mmu.direct_map) { |
@@ -5958,7 +5961,10 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt, | |||
5958 | */ | 5961 | */ |
5959 | vcpu->arch.last_retry_eip = vcpu->arch.last_retry_addr = 0; | 5962 | vcpu->arch.last_retry_eip = vcpu->arch.last_retry_addr = 0; |
5960 | 5963 | ||
5961 | if (!(emulation_type & EMULTYPE_RETRY)) | 5964 | if (!(emulation_type & EMULTYPE_ALLOW_RETRY)) |
5965 | return false; | ||
5966 | |||
5967 | if (WARN_ON_ONCE(is_guest_mode(vcpu))) | ||
5962 | return false; | 5968 | return false; |
5963 | 5969 | ||
5964 | if (x86_page_table_writing_insn(ctxt)) | 5970 | if (x86_page_table_writing_insn(ctxt)) |
@@ -6276,7 +6282,19 @@ restart: | |||
6276 | 6282 | ||
6277 | return r; | 6283 | return r; |
6278 | } | 6284 | } |
6279 | EXPORT_SYMBOL_GPL(x86_emulate_instruction); | 6285 | |
6286 | int kvm_emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type) | ||
6287 | { | ||
6288 | return x86_emulate_instruction(vcpu, 0, emulation_type, NULL, 0); | ||
6289 | } | ||
6290 | EXPORT_SYMBOL_GPL(kvm_emulate_instruction); | ||
6291 | |||
6292 | int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu, | ||
6293 | void *insn, int insn_len) | ||
6294 | { | ||
6295 | return x86_emulate_instruction(vcpu, 0, 0, insn, insn_len); | ||
6296 | } | ||
6297 | EXPORT_SYMBOL_GPL(kvm_emulate_instruction_from_buffer); | ||
6280 | 6298 | ||
6281 | static int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, | 6299 | static int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, |
6282 | unsigned short port) | 6300 | unsigned short port) |
@@ -7734,7 +7752,7 @@ static inline int complete_emulated_io(struct kvm_vcpu *vcpu) | |||
7734 | { | 7752 | { |
7735 | int r; | 7753 | int r; |
7736 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); | 7754 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); |
7737 | r = emulate_instruction(vcpu, EMULTYPE_NO_DECODE); | 7755 | r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE); |
7738 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); | 7756 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); |
7739 | if (r != EMULATE_DONE) | 7757 | if (r != EMULATE_DONE) |
7740 | return 0; | 7758 | return 0; |