提交 3f5d18a9 编写于 作者: A Avi Kivity

KVM: Return to userspace on emulation failure

Instead of mindlessly retrying to execute the instruction, report the
failure to userspace.
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 988a2cae
...@@ -2673,8 +2673,9 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code) ...@@ -2673,8 +2673,9 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
++vcpu->stat.mmio_exits; ++vcpu->stat.mmio_exits;
return 0; return 0;
case EMULATE_FAIL: case EMULATE_FAIL:
kvm_report_emulation_failure(vcpu, "pagetable"); vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
return 1; vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
return 0;
default: default:
BUG(); BUG();
} }
......
...@@ -95,6 +95,10 @@ struct kvm_pit_config { ...@@ -95,6 +95,10 @@ struct kvm_pit_config {
#define KVM_EXIT_S390_RESET 14 #define KVM_EXIT_S390_RESET 14
#define KVM_EXIT_DCR 15 #define KVM_EXIT_DCR 15
#define KVM_EXIT_NMI 16 #define KVM_EXIT_NMI 16
#define KVM_EXIT_INTERNAL_ERROR 17
/* For KVM_EXIT_INTERNAL_ERROR */
#define KVM_INTERNAL_ERROR_EMULATION 1
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
struct kvm_run { struct kvm_run {
...@@ -181,6 +185,9 @@ struct kvm_run { ...@@ -181,6 +185,9 @@ struct kvm_run {
__u32 data; __u32 data;
__u8 is_write; __u8 is_write;
} dcr; } dcr;
struct {
__u32 suberror;
} internal;
/* Fix the size of the union. */ /* Fix the size of the union. */
char padding[256]; char padding[256];
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册