From patchwork Tue Dec 14 12:17:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 409691 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 oBECHujc022214 for ; Tue, 14 Dec 2010 12:17:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758072Ab0LNMRy (ORCPT ); Tue, 14 Dec 2010 07:17:54 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:33819 "EHLO mx4-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757792Ab0LNMRy (ORCPT ); Tue, 14 Dec 2010 07:17:54 -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 oBECHrah030150; Tue, 14 Dec 2010 07:17:53 -0500 Date: Tue, 14 Dec 2010 07:17:53 -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: <1193640890.681341292329073856.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> In-Reply-To: <1880011835.679641292327293761.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com> Subject: [RFC 4/4] KVM in-kernel PM Timer implementation (experimental code part 4) 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:17:57 +0000 (UTC) diff -up ./qemu-kvm.c.orig4 ./qemu-kvm.c --- ./qemu-kvm.c.orig4 2010-12-10 10:50:42.857811776 +0100 +++ ./qemu-kvm.c 2010-12-10 11:45:23.783748044 +0100 @@ -54,6 +54,9 @@ int kvm_irqchip = 1; int kvm_pit = 1; int kvm_pit_reinject = 1; int kvm_nested = 0; +#ifdef KVM_CAP_PMTMR +int kvm_pmtmr = 0; +#endif KVMState *kvm_state; @@ -186,7 +189,7 @@ int kvm_init(int smp_cpus) kvm_context->no_irqchip_creation = 0; kvm_context->no_pit_creation = 0; #ifdef KVM_CAP_PMTMR - kvm_context->no_pmtmr_creation = 0; + kvm_context->no_pmtmr_creation = 1; #endif #ifdef KVM_CAP_SET_GUEST_DEBUG @@ -241,6 +244,11 @@ void kvm_disable_pit_creation(kvm_contex } #ifdef KVM_CAP_PMTMR +void kvm_enable_pmtmr_creation(kvm_context_t kvm) +{ + kvm->no_pmtmr_creation = 0; +} + void (*kvm_arch_pmtmr_handler)(kvm_context_t kvm); /* * This handler is called by @@ -1654,6 +1662,11 @@ static int kvm_create_context(void) if (!kvm_pit) { kvm_disable_pit_creation(kvm_context); } +#ifdef KVM_CAP_PMTMR + if (kvm_pmtmr) { + kvm_enable_pmtmr_creation(kvm_context); + } +#endif if (kvm_create(kvm_context, 0, NULL) < 0) { kvm_finalize(kvm_state); return -1; diff -up ./qemu-kvm.h.orig4 ./qemu-kvm.h --- ./qemu-kvm.h.orig4 2010-12-10 11:26:43.726790319 +0100 +++ ./qemu-kvm.h 2010-12-10 11:47:50.074805792 +0100 @@ -124,6 +124,18 @@ void kvm_disable_irqchip_creation(kvm_co */ void kvm_disable_pit_creation(kvm_context_t kvm); +#ifdef KVM_CAP_PMTMR +/*! + * \brief Enable the in-kernel ACPI PM Timer register creation + * + * In-kernel ACPI PM Timer register is disabled by default. + * If in-kernel is to be used, this should be called prior to kvm_create(). + * + * \param kvm Pointer to the kvm_context + */ +void kvm_enable_pmtmr_creation(kvm_context_t kvm); +#endif + /*! * \brief Create new virtual machine * @@ -706,6 +718,9 @@ extern int kvm_irqchip; extern int kvm_pit; extern int kvm_pit_reinject; extern int kvm_nested; +#ifdef KVM_CAP_PMTMR +extern int kvm_pmtmr; +#endif extern kvm_context_t kvm_context; struct ioperm_data { diff -up ./qemu-options.hx.orig4 ./qemu-options.hx --- ./qemu-options.hx.orig4 2010-12-02 15:15:20.000000000 +0100 +++ ./qemu-options.hx 2010-12-06 11:27:57.273648509 +0100 @@ -2330,6 +2330,9 @@ DEF("no-kvm-pit-reinjection", 0, QEMU_OP QEMU_ARCH_I386) DEF("enable-nesting", 0, QEMU_OPTION_enable_nesting, "-enable-nesting enable support for running a VM inside the VM (AMD only)\n", QEMU_ARCH_I386) +DEF("kvm-pmtmr", 0, QEMU_OPTION_kvm_pmtmr, + "-kvm-pmtmr enable KVM kernel mode ACPI PM Timer register emulation\n", + QEMU_ARCH_I386) DEF("nvram", HAS_ARG, QEMU_OPTION_nvram, "-nvram FILE provide ia64 nvram contents\n", QEMU_ARCH_ALL) DEF("tdf", 0, QEMU_OPTION_tdf, diff -up ./vl.c.orig4 ./vl.c --- ./vl.c.orig4 2010-12-10 10:34:55.388997058 +0100 +++ ./vl.c 2010-12-10 11:50:20.566810444 +0100 @@ -2474,6 +2474,12 @@ int main(int argc, char **argv, char **e kvm_nested = 1; break; } +#ifdef KVM_CAP_PMTMR + case QEMU_OPTION_kvm_pmtmr: { + kvm_pmtmr = 1; + break; + } +#endif #endif case QEMU_OPTION_usb: usb_enabled = 1;