From patchwork Fri Mar 27 14:34:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 14738 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2REaTdg010071 for ; Fri, 27 Mar 2009 14:36:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758942AbZC0OfJ (ORCPT ); Fri, 27 Mar 2009 10:35:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759322AbZC0OfI (ORCPT ); Fri, 27 Mar 2009 10:35:08 -0400 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:2808 "EHLO TX2EHSOBE008.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758479AbZC0OfG (ORCPT ); Fri, 27 Mar 2009 10:35:06 -0400 Received: from mail34-tx2-R.bigfish.com (10.9.14.241) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 8.1.340.0; Fri, 27 Mar 2009 14:35:04 +0000 Received: from mail34-tx2 (localhost.localdomain [127.0.0.1]) by mail34-tx2-R.bigfish.com (Postfix) with ESMTP id 697F6158032B; Fri, 27 Mar 2009 14:35:04 +0000 (UTC) X-BigFish: VPS3(zzzz1202hzzz32i43j64h) X-Spam-TCS-SCL: 3:0 X-FB-SS: 5, Received: by mail34-tx2 (MessageSwitch) id 1238164502646877_14520; Fri, 27 Mar 2009 14:35:02 +0000 (UCT) Received: from svlb1extmailp02.amd.com (unknown [139.95.251.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail34-tx2.bigfish.com (Postfix) with ESMTP id 734041958053; Fri, 27 Mar 2009 14:35:02 +0000 (UTC) Received: from svlb1twp01.amd.com ([139.95.250.34]) by svlb1extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n2REYtlg028099; Fri, 27 Mar 2009 07:34:58 -0700 X-WSS-ID: 0KH65TT-03-6NJ-01 Received: from SSVLEXBH1.amd.com (ssvlexbh1.amd.com [139.95.53.182]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2C57088494B; Fri, 27 Mar 2009 07:34:40 -0700 (PDT) Received: from SSVLEXMB1.amd.com ([139.95.53.181]) by SSVLEXBH1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 07:34:46 -0700 Received: from SF36EXMB1.amd.com ([172.19.4.24]) by SSVLEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 07:34:45 -0700 Received: from seurexmb1.amd.com ([165.204.82.130]) by SF36EXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 15:34:40 +0100 Received: from lemmy.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 15:34:39 +0100 Received: by lemmy.amd.com (Postfix, from userid 41430) id 3581E24614; Fri, 27 Mar 2009 15:34:39 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, Joerg Roedel Subject: [PATCH 2/2] kvm/qemu: set gbpages cpuid bit if kvm supports it Date: Fri, 27 Mar 2009 15:34:39 +0100 Message-ID: <1238164479-16207-3-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.6.4 In-Reply-To: <1238164479-16207-1-git-send-email-joerg.roedel@amd.com> References: <1238164479-16207-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 27 Mar 2009 14:34:39.0707 (UTC) FILETIME=[291BCAB0:01C9AEE9] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Joerg Roedel --- libkvm/libkvm.c | 9 +++++++++ libkvm/libkvm.h | 1 + qemu/qemu-kvm.c | 6 ++++++ qemu/qemu-kvm.h | 3 +++ qemu/target-i386/helper.c | 4 ++++ qemu/vl.c | 7 +++++++ 6 files changed, 30 insertions(+), 0 deletions(-) diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index 0610e3f..a699fe9 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -1065,6 +1065,15 @@ int kvm_has_sync_mmu(kvm_context_t kvm) return r; } +int kvm_has_gbpages(kvm_context_t kvm) +{ + int r = 0; +#ifdef KVM_CAP_1GB_PAGES + r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_1GB_PAGES); +#endif + return r; +} + int kvm_inject_nmi(kvm_context_t kvm, int vcpu) { #ifdef KVM_CAP_USER_NMI diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index d3e431a..efbc23e 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -558,6 +558,7 @@ int kvm_dirty_pages_log_reset(kvm_context_t kvm); int kvm_irqchip_in_kernel(kvm_context_t kvm); int kvm_has_sync_mmu(kvm_context_t kvm); +int kvm_has_gbpages(kvm_context_t kvm); #ifdef KVM_CAP_IRQCHIP /*! diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c index 4164368..0a5c6c8 100644 --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -33,6 +33,7 @@ int kvm_irqchip = 1; int kvm_pit = 1; int kvm_pit_reinject = 1; int kvm_nested = 0; +int kvm_gb_pages = 0; kvm_context_t kvm_context; pthread_mutex_t qemu_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -1395,6 +1396,11 @@ int qemu_kvm_has_sync_mmu(void) return kvm_has_sync_mmu(kvm_context); } +int qemu_kvm_has_gbpages() +{ + return kvm_has_gbpages(kvm_context); +} + void qemu_kvm_cpu_stop(CPUState *env) { if (kvm_enabled()) diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h index ca59af8..6f2d99f 100644 --- a/qemu/qemu-kvm.h +++ b/qemu/qemu-kvm.h @@ -151,6 +151,7 @@ extern int kvm_irqchip; extern int kvm_pit; extern int kvm_pit_reinject; extern int kvm_nested; +extern int kvm_gb_pages; extern kvm_context_t kvm_context; struct ioperm_data { @@ -161,6 +162,7 @@ struct ioperm_data { }; int qemu_kvm_has_sync_mmu(void); +int qemu_kvm_has_gbpages(void); void qemu_kvm_cpu_stop(CPUState *env); #define kvm_enabled() (kvm_allowed) @@ -172,6 +174,7 @@ void kvm_load_tsc(CPUState *env); #else #define kvm_enabled() (0) #define kvm_nested 0 +#define kvm_gb_pages 0 #define qemu_kvm_irqchip_in_kernel() (0) #define qemu_kvm_pit_in_kernel() (0) #define kvm_has_sync_mmu() (0) diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c index be7b021..78a5db5 100644 --- a/qemu/target-i386/helper.c +++ b/qemu/target-i386/helper.c @@ -1585,6 +1585,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx &= ~4UL; /* 3dnow */ *edx &= ~0xc0000000; +#ifdef USE_KVM + if (qemu_kvm_has_gbpages() && kvm_gb_pages) + *edx |= CPUID_EXT2_PDPE1GB; +#endif } break; case 0x80000002: diff --git a/qemu/vl.c b/qemu/vl.c index f820d3a..651ef02 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -4189,6 +4189,7 @@ static void help(int exitcode) "-no-kvm-pit disable KVM kernel mode PIT\n" "-no-kvm-pit-reinjection disable KVM kernel mode PIT interrupt reinjection\n" "-enable-nesting enable support for running a VM inside the VM (AMD only)\n" + "-enable-gb-pages enable GB pages in the guest (if host supports it)\n" #if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__) "-pcidevice host=bus:dev.func[,dma=none][,name=string]\n" " expose a PCI device to the guest OS.\n" @@ -4339,6 +4340,7 @@ enum { QEMU_OPTION_no_kqemu, QEMU_OPTION_enable_kvm, QEMU_OPTION_enable_nesting, + QEMU_OPTION_enable_gb_pages, QEMU_OPTION_no_kvm, QEMU_OPTION_no_kvm_irqchip, QEMU_OPTION_no_kvm_pit, @@ -4488,6 +4490,7 @@ static const QEMUOption qemu_options[] = { { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit }, { "no-kvm-pit-reinjection", 0, QEMU_OPTION_no_kvm_pit_reinjection }, { "enable-nesting", 0, QEMU_OPTION_enable_nesting }, + { "enable-gb-pages", 0, QEMU_OPTION_enable_gb_pages }, #if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__) { "pcidevice", HAS_ARG, QEMU_OPTION_pcidevice }, #endif @@ -5456,6 +5459,10 @@ int main(int argc, char **argv, char **envp) kvm_nested = 1; break; } + case QEMU_OPTION_enable_gb_pages: { + kvm_gb_pages = 1; + break; + } #if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__) case QEMU_OPTION_pcidevice: if (assigned_devices_index >= MAX_DEV_ASSIGN_CMDLINE) {