From patchwork Tue Dec 14 12:12:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 409671 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBECCcKS019670 for ; Tue, 14 Dec 2010 12:12:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758429Ab0LNMMg (ORCPT ); Tue, 14 Dec 2010 07:12:36 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:56909 "EHLO mx4-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758337Ab0LNMMf (ORCPT ); Tue, 14 Dec 2010 07:12:35 -0500 Received: from mail03.corp.redhat.com (zmail07.collab.prod.int.phx2.redhat.com [10.5.5.47]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBECCZab029708; Tue, 14 Dec 2010 07:12:35 -0500 Date: Tue, 14 Dec 2010 07:12:35 -0500 (EST) From: Ulrich Obergfell To: kvm@vger.kernel.org Cc: glommer@redhat.com, zamsden@redhat.com, avi@redhat.com, mtosatti@redhat.com Message-ID: <968327341.680991292328755403.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> In-Reply-To: <1843567008.679501292327213657.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Subject: [RFC 2/4] KVM in-kernel PM Timer implementation (experimental code part 2) MIME-Version: 1.0 X-Originating-IP: [10.5.5.71] X-Mailer: Zimbra 5.0.21_GA_3150.RHEL4_64 (ZimbraWebClient - FF3.0 (Linux)/5.0.21_GA_3150.RHEL4_64) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 14 Dec 2010 12:12:38 +0000 (UTC) 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 #include @@ -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)