[PATCH 0/2] Propagate accurate MSR access failures to userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



KVM_GET/SET_MSRS ioctls do not enable userspace clients to differentiate
between ioctl execution errors (e.g. bad pointer, memory allocation
failure) and MSR access errors (e.g. bad MSR parameter, unknown MSR).

This series repurposes kvm_msrs.pad to return the error from the first
failed msr access. It enables callers to use a sequence such as:

struct kvm_msrs msrs;
... init msrs ...
r = ioctl(vcpu_fd, KVM_GET_MSRS, &msrs);
if (r < 0) {
      	check errno for ioctl execution error
} else if (r < msrs.nmsrs) {
        if r > 0
	        reading msrs.entries[0]..msrs.entries[r-1] succeeded
        reading msrs.entries[r] failed
	msrs.errno has the reason
}

The second patch changes code that handles ranges of MSRs to return -ENOENT
when it encounters an unknown MSR. Prior to this it was not possible for
userspace to differentiate between unknown MSRs and other MSR access
errors.

The patches do not change any existing API contracts or guest-visible
exceptions.

Peter Shier (2):
  kvm: x86: propagate KVM_GET/SET_MSRS failures to userspace
  kvm: x86: differentiate unrecognized MSRs from errors

 Documentation/virtual/kvm/api.txt | 12 ++++++++---
 arch/x86/include/uapi/asm/kvm.h   |  2 +-
 arch/x86/kvm/hyperv.c             | 16 +++++++--------
 arch/x86/kvm/lapic.c              |  2 +-
 arch/x86/kvm/mtrr.c               | 10 ++++++---
 arch/x86/kvm/pmu_amd.c            | 24 ++++++++++++----------
 arch/x86/kvm/pmu_intel.c          |  5 +++--
 arch/x86/kvm/vmx.c                |  4 ++--
 arch/x86/kvm/x86.c                | 34 +++++++++++++++++++------------
 9 files changed, 65 insertions(+), 44 deletions(-)

-- 
2.19.0.rc0.228.g281dcd1b4d0-goog



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux