From patchwork Fri Mar 27 14:31:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 14728 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 n2REWVk3009709 for ; Fri, 27 Mar 2009 14:32:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757452AbZC0Oca (ORCPT ); Fri, 27 Mar 2009 10:32:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756734AbZC0Oca (ORCPT ); Fri, 27 Mar 2009 10:32:30 -0400 Received: from wa4ehsobe005.messaging.microsoft.com ([216.32.181.15]:30487 "EHLO WA4EHSOBE006.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754451AbZC0OcY (ORCPT ); Fri, 27 Mar 2009 10:32:24 -0400 Received: from mail203-wa4-R.bigfish.com (10.8.14.235) by WA4EHSOBE006.bigfish.com (10.8.40.26) with Microsoft SMTP Server id 8.1.340.0; Fri, 27 Mar 2009 14:32:20 +0000 Received: from mail203-wa4 (localhost.localdomain [127.0.0.1]) by mail203-wa4-R.bigfish.com (Postfix) with ESMTP id 5638B15104CB; Fri, 27 Mar 2009 14:32:20 +0000 (UTC) X-BigFish: VPS1(zzzz1202hzzz32i61h) X-Spam-TCS-SCL: 0:0 X-FB-SS: 5, Received: by mail203-wa4 (MessageSwitch) id 1238164338498450_10679; Fri, 27 Mar 2009 14:32:18 +0000 (UCT) Received: from ausb3extmailp02.amd.com (ausb3extmailp02.amd.com [163.181.251.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail203-wa4.bigfish.com (Postfix) with ESMTP id 4A365179005C; Fri, 27 Mar 2009 14:32:18 +0000 (UTC) Received: from ausb3twp01.amd.com (ausb3twp01.amd.com [163.181.250.37]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n2REWElB018542; Fri, 27 Mar 2009 09:32:17 -0500 X-WSS-ID: 0KH65PI-01-IGX-01 Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2ADF7194462; Fri, 27 Mar 2009 09:32:06 -0500 (CDT) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 09:32:13 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 09:32:12 -0500 Received: from seurexmb1.amd.com ([165.204.82.130]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2009 15:32:01 +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:32:00 +0100 Received: by lemmy.amd.com (Postfix, from userid 41430) id F10B924639; Fri, 27 Mar 2009 15:31:59 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 7/7] kvm x86: report 1GB page support to userspace Date: Fri, 27 Mar 2009 15:31:59 +0100 Message-ID: <1238164319-16092-8-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.6.4 In-Reply-To: <1238164319-16092-1-git-send-email-joerg.roedel@amd.com> References: <1238164319-16092-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 27 Mar 2009 14:32:00.0634 (UTC) FILETIME=[CA4B2DA0:01C9AEE8] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If userspace knows that the kernel part supports 1GB pages it can enable the corresponding cpuid bit so that guests actually use GB pages. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/svm.c | 7 +++++++ arch/x86/kvm/vmx.c | 7 +++++++ arch/x86/kvm/x86.c | 6 +++++- include/linux/kvm.h | 1 + 5 files changed, 22 insertions(+), 1 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a1df2a3..6593198 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -542,6 +542,8 @@ struct kvm_x86_ops { int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); int (*get_tdp_level)(void); int (*get_mt_mask_shift)(void); + + bool (*gb_page_enable)(void); }; extern struct kvm_x86_ops *kvm_x86_ops; diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 1fcbc17..d140686 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2604,6 +2604,11 @@ static int svm_get_mt_mask_shift(void) return 0; } +static bool svm_gb_page_enable(void) +{ + return npt_enabled; +} + static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled, @@ -2661,6 +2666,8 @@ static struct kvm_x86_ops svm_x86_ops = { .set_tss_addr = svm_set_tss_addr, .get_tdp_level = get_npt_level, .get_mt_mask_shift = svm_get_mt_mask_shift, + + .gb_page_enable = svm_gb_page_enable, }; static int __init svm_init(void) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 37ae13d..e54af3f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3647,6 +3647,11 @@ static int vmx_get_mt_mask_shift(void) return VMX_EPT_MT_EPTE_SHIFT; } +static bool vmx_gb_page_enable(void) +{ + return false; +} + static struct kvm_x86_ops vmx_x86_ops = { .cpu_has_kvm_support = cpu_has_kvm_support, .disabled_by_bios = vmx_disabled_by_bios, @@ -3702,6 +3707,8 @@ static struct kvm_x86_ops vmx_x86_ops = { .set_tss_addr = vmx_set_tss_addr, .get_tdp_level = get_ept_level, .get_mt_mask_shift = vmx_get_mt_mask_shift, + + .gb_page_enable = vmx_gb_page_enable, }; static int __init vmx_init(void) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ae4918c..c94f231 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1009,7 +1009,7 @@ out: int kvm_dev_ioctl_check_extension(long ext) { - int r; + int r = 0; switch (ext) { case KVM_CAP_IRQCHIP: @@ -1027,6 +1027,10 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_ASSIGN_DEV_IRQ: r = 1; break; + case KVM_CAP_1GB_PAGES: + if (kvm_x86_ops->gb_page_enable()) + r = 1; + break; case KVM_CAP_COALESCED_MMIO: r = KVM_COALESCED_MMIO_PAGE_OFFSET; break; diff --git a/include/linux/kvm.h b/include/linux/kvm.h index ee755e2..e79eb26 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -413,6 +413,7 @@ struct kvm_trace_rec { #define KVM_CAP_DEVICE_MSIX 28 #endif #define KVM_CAP_ASSIGN_DEV_IRQ 29 +#define KVM_CAP_1GB_PAGES 30 #ifdef KVM_CAP_IRQ_ROUTING