Преглед на файлове

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>
Avi Kivity преди 15 години
родител
ревизия
a9c7399d6c
променени са 4 файла, в които са добавени 7 реда и са изтрити 0 реда
  1. 1 0
      arch/x86/kvm/mmu.c
  2. 1 0
      arch/x86/kvm/vmx.c
  3. 4 0
      include/linux/kvm.h
  4. 1 0
      virt/kvm/kvm_main.c

+ 1 - 0
arch/x86/kvm/mmu.c

@@ -2800,6 +2800,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
 	case EMULATE_FAIL:
 	case EMULATE_FAIL:
 		vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 		vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 		vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
 		vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
+		vcpu->run->internal.ndata = 0;
 		return 0;
 		return 0;
 	default:
 	default:
 		BUG();
 		BUG();

+ 1 - 0
arch/x86/kvm/vmx.c

@@ -3352,6 +3352,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
 			kvm_report_emulation_failure(vcpu, "emulation failure");
 			kvm_report_emulation_failure(vcpu, "emulation failure");
 			vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 			vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 			vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
 			vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
+			vcpu->run->internal.ndata = 0;
 			ret = 0;
 			ret = 0;
 			goto out;
 			goto out;
 		}
 		}

+ 4 - 0
include/linux/kvm.h

@@ -251,6 +251,9 @@ struct kvm_run {
 		} dcr;
 		} dcr;
 		struct {
 		struct {
 			__u32 suberror;
 			__u32 suberror;
+			/* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
+			__u32 ndata;
+			__u64 data[16];
 		} internal;
 		} internal;
 		/* Fix the size of the union. */
 		/* Fix the size of the union. */
 		char padding[256];
 		char padding[256];
@@ -484,6 +487,7 @@ struct kvm_ioeventfd {
 #define KVM_CAP_XEN_HVM 38
 #define KVM_CAP_XEN_HVM 38
 #endif
 #endif
 #define KVM_CAP_ADJUST_CLOCK 39
 #define KVM_CAP_ADJUST_CLOCK 39
+#define KVM_CAP_INTERNAL_ERROR_DATA 40
 
 
 #ifdef KVM_CAP_IRQ_ROUTING
 #ifdef KVM_CAP_IRQ_ROUTING
 
 

+ 1 - 0
virt/kvm/kvm_main.c

@@ -1653,6 +1653,7 @@ static long kvm_dev_ioctl_check_extension_generic(long arg)
 #ifdef CONFIG_KVM_APIC_ARCHITECTURE
 #ifdef CONFIG_KVM_APIC_ARCHITECTURE
 	case KVM_CAP_SET_BOOT_CPU_ID:
 	case KVM_CAP_SET_BOOT_CPU_ID:
 #endif
 #endif
+	case KVM_CAP_INTERNAL_ERROR_DATA:
 		return 1;
 		return 1;
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
 #ifdef CONFIG_HAVE_KVM_IRQCHIP
 	case KVM_CAP_IRQ_ROUTING:
 	case KVM_CAP_IRQ_ROUTING: