KVM in-kernel PM Timer implementation (experimental code part 2)
A message that is not in the archive (sent off-list or not yet received): 1843567008.679501292327213657.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com
RFC 2/4 KVM in-kernel PM Timer implementation (experimental code part 2)
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.
arch/x86/include/asm/kvm.h renamed from arch/x86/include/asm/kvm.h.orig2 +1 -0
@@ -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
arch/x86/kvm/x86.c renamed from arch/x86/kvm/x86.c.orig2 +24 -0
@@ -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 ecase 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 *filpstruct 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 : ;
include/linux/kvm.h renamed from include/linux/kvm.h.orig2 +11 -0
@@ -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)