aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-11-04 04:54:59 -0500
committerAvi Kivity <avi@redhat.com>2009-12-03 02:32:24 -0500
commita9c7399d6cda0a092b347f8ee49bbe44f6e1fe66 (patch)
treea00b781aa1521efc387ae9b59875862cb37c1d3f
parentc54d2aba27f0c505d61700d656c5943e96982e60 (diff)
KVM: Allow internal errors reported to userspace to carry extra data
Usually userspace will freeze the guest so we can inspect it, but some internal state is not available. Add extra data to internal error reporting so we can expose it to the debugger. Extra data is specific to the suberror. Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/mmu.c1
-rw-r--r--arch/x86/kvm/vmx.c1
-rw-r--r--include/linux/kvm.h4
-rw-r--r--virt/kvm/kvm_main.c1
4 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a9024797b21f..4c3e5b2314cb 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2800,6 +2800,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
2800 case EMULATE_FAIL: 2800 case EMULATE_FAIL:
2801 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 2801 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
2802 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; 2802 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
2803 vcpu->run->internal.ndata = 0;
2803 return 0; 2804 return 0;
2804 default: 2805 default:
2805 BUG(); 2806 BUG();
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c9cc9596e1a6..c0e66dd58a47 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3352,6 +3352,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
3352 kvm_report_emulation_failure(vcpu, "emulation failure"); 3352 kvm_report_emulation_failure(vcpu, "emulation failure");
3353 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 3353 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
3354 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; 3354 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
3355 vcpu->run->internal.ndata = 0;
3355 ret = 0; 3356 ret = 0;
3356 goto out; 3357 goto out;
3357 } 3358 }
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index ca62b8e056f9..172639e94392 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -251,6 +251,9 @@ struct kvm_run {
251 } dcr; 251 } dcr;
252 struct { 252 struct {
253 __u32 suberror; 253 __u32 suberror;
254 /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
255 __u32 ndata;
256 __u64 data[16];
254 } internal; 257 } internal;
255 /* Fix the size of the union. */ 258 /* Fix the size of the union. */
256 char padding[256]; 259 char padding[256];
@@ -484,6 +487,7 @@ struct kvm_ioeventfd {
484#define KVM_CAP_XEN_HVM 38 487#define KVM_CAP_XEN_HVM 38
485#endif 488#endif
486#define KVM_CAP_ADJUST_CLOCK 39 489#define KVM_CAP_ADJUST_CLOCK 39
490#define KVM_CAP_INTERNAL_ERROR_DATA 40
487 491
488#ifdef KVM_CAP_IRQ_ROUTING 492#ifdef KVM_CAP_IRQ_ROUTING
489 493
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index bd44fb48ac43..f92ba138007a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1653,6 +1653,7 @@ static long kvm_dev_ioctl_check_extension_generic(long arg)
1653#ifdef CONFIG_KVM_APIC_ARCHITECTURE 1653#ifdef CONFIG_KVM_APIC_ARCHITECTURE
1654 case KVM_CAP_SET_BOOT_CPU_ID: 1654 case KVM_CAP_SET_BOOT_CPU_ID:
1655#endif 1655#endif
1656 case KVM_CAP_INTERNAL_ERROR_DATA:
1656 return 1; 1657 return 1;
1657#ifdef CONFIG_HAVE_KVM_IRQCHIP 1658#ifdef CONFIG_HAVE_KVM_IRQCHIP
1658 case KVM_CAP_IRQ_ROUTING: 1659 case KVM_CAP_IRQ_ROUTING: