Skip to contentSkip to conversation

kvm: Print MSR information if KVM_SET_MSRS failed

PATCH In review Eduardo Habkost 2 participants 3 messages Mar 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: Print MSR information if KVM_SET_MSRS failed

When a KVM_SET_MSRS ioctl() fails, it is difficult to find out which MSR caused the problem. Print an error message for debugging, before we trigger the (ret == cpu->kvm_msr_buf->nmsrs) assert.

---
 target/i386/kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)
target/i386/kvm.c +6 -0
index 887a81268f..3a874e4717 100644
@@ -1807,6 +1807,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         return ret;
     }
 
+    if (ret < cpu->kvm_msr_buf->nmsrs) {
+        struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret];
+        error_report("error: failed to set MSR 0x%" PRIx32 " to 0x%" PRIx64,
+                     (uint32_t)e->index, (uint64_t)e->data);
+    }
+
     assert(ret == cpu->kvm_msr_buf->nmsrs);
     return 0;
 }
Signature · 1 line
2.11.0.259.g40922b1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · * Eduardo Habkost ([email protected]) wrote:

When a KVM_SET_MSRS ioctl() fails, it is difficult to find out which MSR caused the problem. Print an error message for debugging, before we trigger the (ret == cpu->kvm_msr_buf->nmsrs) assert.

---
 target/i386/kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)
target/i386/kvm.c +0 -0
index 887a81268f..3a874e4717 100644

target/i386/kvm.c static int kvm_put_msrs(X86CPU *cpu, int level) · line 1815

Quoted 9 lines
target/i386/kvm.c +6 -0
@@ -1807,6 +1807,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         return ret;
     }
 
+    if (ret < cpu->kvm_msr_buf->nmsrs) {
+        struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret];
+        error_report("error: failed to set MSR 0x%" PRIx32 " to 0x%" PRIx64,
+                     (uint32_t)e->index, (uint64_t)e->data);
+    }
+

Yes, I'd thought about doing the same; had you considered adding it on the get as well?

Dave

Quoted 6 lines
target/i386/kvm.c +0 -0
     assert(ret == cpu->kvm_msr_buf->nmsrs);
     return 0;
 }
Signature · 1 line
2.11.0.259.g40922b1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 19 lines · Dr. David Alan Gilbert
Quoted 18 lines · * Eduardo Habkost ([email protected]) wrote:

When a KVM_SET_MSRS ioctl() fails, it is difficult to find out which MSR caused the problem. Print an error message for debugging, before we trigger the (ret == cpu->kvm_msr_buf->nmsrs) assert.

---
 target/i386/kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)
target/i386/kvm.c +0 -0
index 887a81268f..3a874e4717 100644
@@ -1807,6 +1807,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         return ret;
     }
 
Quoted 8 lines

target/i386/kvm.c static int kvm_put_msrs(X86CPU *cpu, int level) · line 1815

Quoted 6 lines
target/i386/kvm.c +6 -0
+    if (ret < cpu->kvm_msr_buf->nmsrs) {
+        struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret];
+        error_report("error: failed to set MSR 0x%" PRIx32 " to 0x%" PRIx64,
+                     (uint32_t)e->index, (uint64_t)e->data);
+    }
+

Yes, I'd thought about doing the same;

Actually, I forgot to add:

as it was your idea. :)

Quoted 2 lines

had you considered adding it on the get
as well?

I don't remember hitting the kvm_get_msrs() assert(), so I didn't consider doing it.

But it looks useful, I will submit a separate patch.

Quoted 2 lines

Thanks!

Quoted 11 lines

Dave

Quoted 6 lines
target/i386/kvm.c +0 -0
     assert(ret == cpu->kvm_msr_buf->nmsrs);
     return 0;
 }
Signature · 1 line
2.11.0.259.g40922b1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Signature · 1 line
Eduardo