KVM: Expose MSRs to userspace (v2)
PATCH 1/1 KVM: Expose MSRs to userspace (v2)
Changes from v1:
- get msrs and set msrs are now symmetric: both accept a list of msrs. it is now possible to retrieve a single msr.
- a new KVM_GET_MSR_INDEX_LIST allows discovering which msrs are supported by kvm (previously this was integrated into KVM_GET_MSRS)
- error handling is simpler and correcter
- the implementation is collapsed into a single msr_io() function
- avoid pointers in ioctl structs, instead use zero length arrays
Andrew, this patch replaces kvm-exposer-msrs-to-userspace.patch.
--
Expose the model-specific registers to userspace. Primarily useful for save/resume.
drivers/kvm/kvm.h +1 -5
@@ -106,11 +106,7 @@ struct vmcs {char data[0 ]; }; -struct vmx_msr_entry { -u32 index; -u32 reserved; -u64 data; -}; +#define vmx_msr_entry kvm_msr_entrystruct kvm_vcpu ;
drivers/kvm/kvm_main.c +188 -35
283 lines not on this page · raw message
include/linux/kvm.h +23 -0
@@ -141,6 +141,26 @@ struct kvm_sregs {__u64 interrupt_bitmap[KVM_IRQ_BITMAP_SIZE (__u64)]; }; +struct kvm_msr_entry { +__u32 index; +__u32 reserved; +__u64 data; +}; + +/* for KVM_GET_MSRS and KVM_SET_MSRS */ +struct kvm_msrs { +__u32 vcpu; +__u32 nmsrs;/* number of msrs in entries */ + +struct kvm_msr_entry entries[0 ]; +}; + +/* for KVM_GET_MSR_INDEX_LIST */ +struct kvm_msr_list { +__u32 nmsrs;/* number of msrs in entries */ +__u32 indices[0 ]; +}; +/* for KVM_TRANSLATE */ struct kvm_translation {/* in */
@@ -200,5 +220,8 @@ struct kvm_dirty_log {#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 10, struct kvm_memory_region) #define KVM_CREATE_VCPU _IOW(KVMIO, 11, int /* vcpu_slot */)#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 12, struct kvm_dirty_log) +#define KVM_GET_MSRS _IOWR(KVMIO, 13, struct kvm_msrs) +#define KVM_SET_MSRS _IOWR(KVMIO, 14, struct kvm_msrs) +#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 15, struct kvm_msr_list)#endif
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV