experimental code part 2 (KVM kernel) ------------------------------------- This code introduces two new ioctl commands KVM_CREATE_PMTMR and KVM_CONFIGURE_PMTMR plus the new capability KVM_CAP_PMTMR to the ioctl infrastructure of the KVM kernel. This code utilizes some helper functions introduced by code part 1. diff -up ./arch/x86/include/asm/kvm.h.orig2 ./arch/x86/include/asm/kvm.h --- ./arch/x86/include/asm/kvm.h.orig2 2010-12-05 09:35:17.000000000 +0100 +++ ./arch/x86/include/asm/kvm.h 2010-12-10 12:32:47.067686432 +0100 @@ -24,6 +24,7 @@ #define __KVM_HAVE_DEBUGREGS #define __KVM_HAVE_XSAVE #define __KVM_HAVE_XCRS +#define __KVM_HAVE_PMTMR /* Architectural interrupt line count. */ #define KVM_NR_INTERRUPTS 256 diff -up ./arch/x86/kvm/x86.c.orig2 ./arch/x86/kvm/x86.c --- ./arch/x86/kvm/x86.c.orig2 2010-12-05 09:35:17.000000000 +0100 +++ ./arch/x86/kvm/x86.c 2010-12-10 12:24:58.083739549 +0100 @@ -26,6 +26,9 @@ #include "tss.h" #include "kvm_cache_regs.h" #include "x86.h" +#ifdef KVM_CAP_PMTMR +#include "pmtmr.h" +#endif #include <linux/clocksource.h> #include <linux/interrupt.h> @@ -1965,6 +1968,9 @@ int kvm_dev_ioctl_check_extension(long e case KVM_CAP_X86_ROBUST_SINGLESTEP: case KVM_CAP_XSAVE: case KVM_CAP_ASYNC_PF: +#ifdef KVM_CAP_PMTMR + case KVM_CAP_PMTMR: +#endif r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -3274,6 +3280,7 @@ long kvm_arch_vm_ioctl(struct file *filp struct kvm_pit_state ps; struct kvm_pit_state2 ps2; struct kvm_pit_config pit_config; + struct kvm_pmtmr_config pmtmr_config; } u; switch (ioctl) { @@ -3541,6 +3548,23 @@ long kvm_arch_vm_ioctl(struct file *filp r = 0; break; } +#ifdef KVM_CAP_PMTMR + case KVM_CREATE_PMTMR: { + mutex_lock(&kvm->slots_lock); + r = kvm_create_pmtmr(kvm); + mutex_unlock(&kvm->slots_lock); + break; + } + case KVM_CONFIGURE_PMTMR: { + r = -EFAULT; + if (copy_from_user(&u.pmtmr_config, argp, + sizeof(struct kvm_pmtmr_config))) + goto out; + + r = kvm_configure_pmtmr(kvm, &u.pmtmr_config); + break; + } +#endif default: ; diff -up ./include/linux/kvm.h.orig2 ./include/linux/kvm.h --- ./include/linux/kvm.h.orig2 2010-12-05 09:35:17.000000000 +0100 +++ ./include/linux/kvm.h 2010-12-10 12:30:13.677745093 +0100 @@ -140,6 +140,12 @@ struct kvm_pit_config { __u32 pad[15]; }; +/* for KVM_CONFIGURE_PMTMR */ +struct kvm_pmtmr_config { + __u64 pm_io_base; + __s64 clock_offset; +}; + #define KVM_PIT_SPEAKER_DUMMY 1 #define KVM_EXIT_UNKNOWN 0 @@ -541,6 +547,9 @@ struct kvm_ppc_pvinfo { #define KVM_CAP_PPC_GET_PVINFO 57 #define KVM_CAP_PPC_IRQ_LEVEL 58 #define KVM_CAP_ASYNC_PF 59 +#ifdef __KVM_HAVE_PMTMR +#define KVM_CAP_PMTMR 60 +#endif #ifdef KVM_CAP_IRQ_ROUTING @@ -672,6 +681,8 @@ struct kvm_clock_data { #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) +#define KVM_CREATE_PMTMR _IO(KVMIO, 0x7d) +#define KVM_CONFIGURE_PMTMR _IOW(KVMIO, 0x7e, struct kvm_pmtmr_config) /* Available with KVM_CAP_PIT_STATE2 */ #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html