Skip to content

Commit

Permalink
kvm: Print MSR information if KVM_{GET,SET}_MSRS failed
Browse files Browse the repository at this point in the history
When a KVM_{GET,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.

Suggested-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Eduardo Habkost <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
ehabkost authored and bonzini committed Mar 14, 2017
1 parent 79ca7a1 commit c70b11d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions target/i386/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,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;
}
Expand Down Expand Up @@ -2189,6 +2195,12 @@ static int kvm_get_msrs(X86CPU *cpu)
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 get MSR 0x%" PRIx32,
(uint32_t)e->index);
}

assert(ret == cpu->kvm_msr_buf->nmsrs);
/*
* MTRR masks: Each mask consists of 5 parts
Expand Down

0 comments on commit c70b11d

Please sign in to comment.