* [PATCH 0/2] Improve reporting of simultaneous exception errors
@ 2009-11-04 10:47 Avi Kivity
2009-11-04 10:47 ` [PATCH 1/2] KVM: Allow internal errors reported to userspace to carry extra data Avi Kivity
2009-11-04 10:47 ` [PATCH 2/2] KVM: VMX: Report unexpected simultaneous exceptions as internal errors Avi Kivity
0 siblings, 2 replies; 3+ messages in thread
From: Avi Kivity @ 2009-11-04 10:47 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm, Gleb Natapov
Currently if we hit an error processing simultaneous exceptions we mumble
something in dmesg and continue. AFAIK this situation always deteriorates,
so attempt to report it to userspace to give us a chance to debug it.
Avi Kivity (2):
KVM: Allow internal errors reported to userspace to carry extra data
KVM: VMX: Report unexpected simultaneous exceptions as internal
errors
arch/x86/kvm/mmu.c | 1 +
arch/x86/kvm/vmx.c | 12 +++++++++---
include/linux/kvm.h | 5 +++++
virt/kvm/kvm_main.c | 1 +
4 files changed, 16 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] KVM: Allow internal errors reported to userspace to carry extra data
2009-11-04 10:47 [PATCH 0/2] Improve reporting of simultaneous exception errors Avi Kivity
@ 2009-11-04 10:47 ` Avi Kivity
2009-11-04 10:47 ` [PATCH 2/2] KVM: VMX: Report unexpected simultaneous exceptions as internal errors Avi Kivity
1 sibling, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2009-11-04 10:47 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm, Gleb Natapov
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>
---
arch/x86/kvm/mmu.c | 1 +
arch/x86/kvm/vmx.c | 1 +
include/linux/kvm.h | 4 ++++
virt/kvm/kvm_main.c | 1 +
4 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a902479..4c3e5b2 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)
case EMULATE_FAIL:
vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
+ vcpu->run->internal.ndata = 0;
return 0;
default:
BUG();
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b923f2a..85a7363 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3346,6 +3346,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
kvm_report_emulation_failure(vcpu, "emulation failure");
vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
+ vcpu->run->internal.ndata = 0;
ret = 0;
goto out;
}
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 6ed1a12..6d27513 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -187,6 +187,9 @@ struct kvm_run {
} dcr;
struct {
__u32 suberror;
+ /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
+ __u32 ndata;
+ __u64 data[16];
} internal;
/* Fix the size of the union. */
char padding[256];
@@ -440,6 +443,7 @@ struct kvm_ioeventfd {
#define KVM_CAP_XEN_HVM 38
#endif
#define KVM_CAP_ADJUST_CLOCK 39
+#define KVM_CAP_INTERNAL_ERROR_DATA 40
#ifdef KVM_CAP_IRQ_ROUTING
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index bd44fb4..f92ba13 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)
#ifdef CONFIG_KVM_APIC_ARCHITECTURE
case KVM_CAP_SET_BOOT_CPU_ID:
#endif
+ case KVM_CAP_INTERNAL_ERROR_DATA:
return 1;
#ifdef CONFIG_HAVE_KVM_IRQCHIP
case KVM_CAP_IRQ_ROUTING:
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] KVM: VMX: Report unexpected simultaneous exceptions as internal errors
2009-11-04 10:47 [PATCH 0/2] Improve reporting of simultaneous exception errors Avi Kivity
2009-11-04 10:47 ` [PATCH 1/2] KVM: Allow internal errors reported to userspace to carry extra data Avi Kivity
@ 2009-11-04 10:47 ` Avi Kivity
1 sibling, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2009-11-04 10:47 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm, Gleb Natapov
These happen when we trap an exception when another exception is being
delivered; we only expect these with MCEs and page faults. If something
unexpected happens, things probably went south and we're better off reporting
an internal error and freezing.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/kvm/vmx.c | 11 ++++++++---
include/linux/kvm.h | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 85a7363..8b8eaac 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2738,9 +2738,14 @@ static int handle_exception(struct kvm_vcpu *vcpu)
return handle_machine_check(vcpu);
if ((vect_info & VECTORING_INFO_VALID_MASK) &&
- !is_page_fault(intr_info))
- printk(KERN_ERR "%s: unexpected, vectoring info 0x%x "
- "intr info 0x%x\n", __func__, vect_info, intr_info);
+ !is_page_fault(intr_info)) {
+ vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
+ vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_SIMUL_EX;
+ vcpu->run->internal.ndata = 2;
+ vcpu->run->internal.data[0] = vect_info;
+ vcpu->run->internal.data[1] = intr_info;
+ return 0;
+ }
if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR)
return 1; /* already handled by vmx_vcpu_run() */
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 6d27513..089cad7 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -99,6 +99,7 @@ struct kvm_pit_config {
/* For KVM_EXIT_INTERNAL_ERROR */
#define KVM_INTERNAL_ERROR_EMULATION 1
+#define KVM_INTERNAL_ERROR_SIMUL_EX 2
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
struct kvm_run {
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-04 10:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-04 10:47 [PATCH 0/2] Improve reporting of simultaneous exception errors Avi Kivity
2009-11-04 10:47 ` [PATCH 1/2] KVM: Allow internal errors reported to userspace to carry extra data Avi Kivity
2009-11-04 10:47 ` [PATCH 2/2] KVM: VMX: Report unexpected simultaneous exceptions as internal errors Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox