diff options
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 2 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 16 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 9 |
3 files changed, 15 insertions, 12 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index cb5cad2f2d46..cd4a990e8a12 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -828,4 +828,6 @@ void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, | |||
828 | bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu); | 828 | bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu); |
829 | extern bool kvm_find_async_pf_gfn(struct kvm_vcpu *vcpu, gfn_t gfn); | 829 | extern bool kvm_find_async_pf_gfn(struct kvm_vcpu *vcpu, gfn_t gfn); |
830 | 830 | ||
831 | void kvm_complete_insn_gp(struct kvm_vcpu *vcpu, int err); | ||
832 | |||
831 | #endif /* _ASM_X86_KVM_HOST_H */ | 833 | #endif /* _ASM_X86_KVM_HOST_H */ |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 8e87bae09a7a..fd8ffde73755 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -3147,14 +3147,6 @@ vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall) | |||
3147 | hypercall[2] = 0xc1; | 3147 | hypercall[2] = 0xc1; |
3148 | } | 3148 | } |
3149 | 3149 | ||
3150 | static void complete_insn_gp(struct kvm_vcpu *vcpu, int err) | ||
3151 | { | ||
3152 | if (err) | ||
3153 | kvm_inject_gp(vcpu, 0); | ||
3154 | else | ||
3155 | skip_emulated_instruction(vcpu); | ||
3156 | } | ||
3157 | |||
3158 | static int handle_cr(struct kvm_vcpu *vcpu) | 3150 | static int handle_cr(struct kvm_vcpu *vcpu) |
3159 | { | 3151 | { |
3160 | unsigned long exit_qualification, val; | 3152 | unsigned long exit_qualification, val; |
@@ -3172,21 +3164,21 @@ static int handle_cr(struct kvm_vcpu *vcpu) | |||
3172 | switch (cr) { | 3164 | switch (cr) { |
3173 | case 0: | 3165 | case 0: |
3174 | err = kvm_set_cr0(vcpu, val); | 3166 | err = kvm_set_cr0(vcpu, val); |
3175 | complete_insn_gp(vcpu, err); | 3167 | kvm_complete_insn_gp(vcpu, err); |
3176 | return 1; | 3168 | return 1; |
3177 | case 3: | 3169 | case 3: |
3178 | err = kvm_set_cr3(vcpu, val); | 3170 | err = kvm_set_cr3(vcpu, val); |
3179 | complete_insn_gp(vcpu, err); | 3171 | kvm_complete_insn_gp(vcpu, err); |
3180 | return 1; | 3172 | return 1; |
3181 | case 4: | 3173 | case 4: |
3182 | err = kvm_set_cr4(vcpu, val); | 3174 | err = kvm_set_cr4(vcpu, val); |
3183 | complete_insn_gp(vcpu, err); | 3175 | kvm_complete_insn_gp(vcpu, err); |
3184 | return 1; | 3176 | return 1; |
3185 | case 8: { | 3177 | case 8: { |
3186 | u8 cr8_prev = kvm_get_cr8(vcpu); | 3178 | u8 cr8_prev = kvm_get_cr8(vcpu); |
3187 | u8 cr8 = kvm_register_read(vcpu, reg); | 3179 | u8 cr8 = kvm_register_read(vcpu, reg); |
3188 | err = kvm_set_cr8(vcpu, cr8); | 3180 | err = kvm_set_cr8(vcpu, cr8); |
3189 | complete_insn_gp(vcpu, err); | 3181 | kvm_complete_insn_gp(vcpu, err); |
3190 | if (irqchip_in_kernel(vcpu->kvm)) | 3182 | if (irqchip_in_kernel(vcpu->kvm)) |
3191 | return 1; | 3183 | return 1; |
3192 | if (cr8_prev <= cr8) | 3184 | if (cr8_prev <= cr8) |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2dbf68cd46e3..1d54cb7f3358 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -334,6 +334,15 @@ void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr) | |||
334 | } | 334 | } |
335 | EXPORT_SYMBOL_GPL(kvm_requeue_exception); | 335 | EXPORT_SYMBOL_GPL(kvm_requeue_exception); |
336 | 336 | ||
337 | void kvm_complete_insn_gp(struct kvm_vcpu *vcpu, int err) | ||
338 | { | ||
339 | if (err) | ||
340 | kvm_inject_gp(vcpu, 0); | ||
341 | else | ||
342 | kvm_x86_ops->skip_emulated_instruction(vcpu); | ||
343 | } | ||
344 | EXPORT_SYMBOL_GPL(kvm_complete_insn_gp); | ||
345 | |||
337 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault) | 346 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault) |
338 | { | 347 | { |
339 | ++vcpu->stat.pf_guest; | 348 | ++vcpu->stat.pf_guest; |