Skip to contentSkip to conversation

Update kvm.h in qemu-kvm tree

PATCH Superseded Mohammed Gamal 2 participants 4 messages Aug 28, 2009 – Sep 1, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Update kvm.h in qemu-kvm tree

Update struct kvm_run and KVM_EXIT_* constants to match the one in the kernel-space tree

---
 kvm/include/linux/kvm.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
kvm/include/linux/kvm.h +7 -0
index ff1025d..801865d 100644
@@ -135,6 +135,10 @@ struct kvm_pit_config {
 #define KVM_EXIT_S390_RESET       14
 #define KVM_EXIT_DCR              15
 #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) */
 struct kvm_run {
@@ -221,6 +225,9 @@ struct kvm_run {
 			__u32 data;
 			__u8  is_write;
 		} dcr;
+		struct {
+			__u32 suberror;
+		} internal;
 		/* Fix the size of the union. */
 		char padding[256];
 	};
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/2 Handle emulation failure in userspace

Since we return to userspace from KVM on invalid state emulation failure, let qemu handle it.

---
 qemu-kvm.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
qemu-kvm.c +8 -0
index b59e403..a1648e0 100644
@@ -1029,6 +1029,14 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
             r = kvm_s390_handle_reset(kvm, vcpu, run);
             break;
 #endif
+	case KVM_EXIT_INTERNAL_ERROR:
+	    kvm_show_regs(vcpu);
+	    fprintf(stderr, "\nKVM internal error. Suberror: %d\n",
+		    run->internal.suberror);
+	    if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION)
+		fprintf(stderr, "emulation failure, check dmesg for details\n");
+	    abort();
+	    break;
         default:
             if (kvm_arch_run(vcpu)) {
                 fprintf(stderr, "unhandled vm exit: 0x%x\n", run->exit_reason);
Signature · 1 line
1.6.0.4
#2 lore raw

Re: [PATCH 2/2] Handle emulation failure in userspace

Quoted 29 lines · Mohammed Gamal

Since we return to userspace from KVM on invalid state emulation failure, let qemu handle it.

---
 qemu-kvm.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
qemu-kvm.c +8 -0
index b59e403..a1648e0 100644
@@ -1029,6 +1029,14 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
             r = kvm_s390_handle_reset(kvm, vcpu, run);
             break;
 #endif
+	case KVM_EXIT_INTERNAL_ERROR:
+	    kvm_show_regs(vcpu);
+	    fprintf(stderr, "\nKVM internal error. Suberror: %d\n",
+		    run->internal.suberror);
+	    if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION)
+		fprintf(stderr, "emulation failure, check dmesg for details\n");
+	    abort();
+	    break;
         default:
             if (kvm_arch_run(vcpu)) {
                 fprintf(stderr, "unhandled vm exit: 0x%x\n", run->exit_reason);
Signature · 1 line
1.6.0.4

The common practice is to print msg first and then kvm_show_regs? Applied the kvm.h update, thanks.

#3 lore raw

Re: [PATCH 2/2] Handle emulation failure in userspace

Quoted 24 lines · Marcelo Tosatti
Quoted 23 lines · Mohammed Gamal

Since we return to userspace from KVM on invalid state emulation failure, let qemu handle it.

---
 qemu-kvm.c |    8 ++++++++

 1 files changed, 8 insertions(+), 0 deletions(-)
qemu-kvm.c +7 -0
index b59e403..a1648e0 100644
@@ -1029,6 +1029,14 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
              r = kvm_s390_handle_reset(kvm, vcpu, run);
              break;
  #endif
+     case KVM_EXIT_INTERNAL_ERROR:
+         kvm_show_regs(vcpu);
+         fprintf(stderr, "\nKVM internal error. Suberror: %d\n",
+                 run->internal.suberror);
+         if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION)
+             fprintf(stderr, "emulation failure, check dmesg for details\n");
+         abort();
Quoted 8 lines
Quoted 6 lines
qemu-kvm.c +1 -0
+         break;

         default:
             if (kvm_arch_run(vcpu)) {
                 fprintf(stderr, "unhandled vm exit: 0x%x\n", run->exit_reason); --
1.6.0.4

The common practice is to print msg first and then kvm_show_regs?

True. I just thought the message would be more visible this way. Will resend

Quoted 3 lines

Applied the kvm.h update, thanks.