From patchwork Mon Jul 27 14:30:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 37532 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 n6REat11001992 for ; Mon, 27 Jul 2009 14:36:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbZG0OgG (ORCPT ); Mon, 27 Jul 2009 10:36:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752286AbZG0OgF (ORCPT ); Mon, 27 Jul 2009 10:36:05 -0400 Received: from sg2ehsobe002.messaging.microsoft.com ([207.46.51.76]:11981 "EHLO SG2EHSOBE002.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752023AbZG0OgE (ORCPT ); Mon, 27 Jul 2009 10:36:04 -0400 Received: from mail24-sin-R.bigfish.com (10.210.100.248) by SG2EHSOBE002.bigfish.com (10.210.112.22) with Microsoft SMTP Server id 8.1.340.0; Mon, 27 Jul 2009 14:36:03 +0000 Received: from mail24-sin (localhost.localdomain [127.0.0.1]) by mail24-sin-R.bigfish.com (Postfix) with ESMTP id C06B8601A7; Mon, 27 Jul 2009 14:36:43 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(zzzz1202hzzz32i43j) Received: by mail24-sin (MessageSwitch) id 1248705124499261_18395; Mon, 27 Jul 2009 14:32:04 +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 mail24-sin.bigfish.com (Postfix) with ESMTP id 9C2E811B0072; Mon, 27 Jul 2009 14:32:00 +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 n6REUv8T013414; Mon, 27 Jul 2009 07:31:02 -0700 X-WSS-ID: 0KNG2ZF-03-X0E-01 Received: from SSVLEXBH2.amd.com (ssvlexbh2.amd.com [139.95.53.183]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2337288493C; Mon, 27 Jul 2009 07:30:51 -0700 (PDT) Received: from ssvlexmb2.amd.com ([139.95.53.7]) by SSVLEXBH2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Jul 2009 07:30:56 -0700 Received: from SF36EXMB1.amd.com ([172.19.4.24]) by ssvlexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Jul 2009 07:30:56 -0700 Received: from seurexmb1.amd.com ([165.204.9.130]) by SF36EXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Jul 2009 16:30:53 +0200 Received: from lemmy.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Jul 2009 16:30:50 +0200 Received: by lemmy.amd.com (Postfix, from userid 41430) id B9C16CA074; Mon, 27 Jul 2009 16:30:50 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Joerg Roedel Subject: [PATCH 7/7] kvm x86: report 1GB page support to userspace Date: Mon, 27 Jul 2009 16:30:48 +0200 Message-ID: <1248705048-22607-8-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1248705048-22607-1-git-send-email-joerg.roedel@amd.com> References: <1248705048-22607-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 27 Jul 2009 14:30:51.0036 (UTC) FILETIME=[D734DDC0:01CA0EC6] 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 | 6 ++++++ arch/x86/kvm/vmx.c | 6 ++++++ arch/x86/kvm/x86.c | 3 ++- 4 files changed, 16 insertions(+), 1 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3315efa..b17d845 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -528,6 +528,8 @@ struct kvm_x86_ops { int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); int (*get_tdp_level)(void); u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); + bool (*gb_page_enable)(void); + const struct trace_print_flags *exit_reasons_str; }; diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index b720b02..70e81f5 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2755,6 +2755,11 @@ static const struct trace_print_flags svm_exit_reasons_str[] = { { -1, NULL } }; +static bool svm_gb_page_enable(void) +{ + return true; +} + static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled, @@ -2818,6 +2823,7 @@ static struct kvm_x86_ops svm_x86_ops = { .get_mt_mask = svm_get_mt_mask, .exit_reasons_str = svm_exit_reasons_str, + .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 7931c72..bf12865 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3908,6 +3908,11 @@ static const struct trace_print_flags vmx_exit_reasons_str[] = { { -1, NULL } }; +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, @@ -3969,6 +3974,7 @@ static struct kvm_x86_ops vmx_x86_ops = { .get_mt_mask = vmx_get_mt_mask, .exit_reasons_str = vmx_exit_reasons_str, + .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 2539e9a..bbdc34d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1444,6 +1444,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, u32 index, int *nent, int maxnent) { unsigned f_nx = is_efer_nx() ? F(NX) : 0; + unsigned f_gbpages = kvm_x86_ops->gb_page_enable() ? F(GBPAGES) : 0; #ifdef CONFIG_X86_64 unsigned f_lm = F(LM); #else @@ -1468,7 +1469,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, F(MTRR) | F(PGE) | F(MCA) | F(CMOV) | F(PAT) | F(PSE36) | 0 /* Reserved */ | f_nx | 0 /* Reserved */ | F(MMXEXT) | F(MMX) | - F(FXSR) | F(FXSR_OPT) | 0 /* GBPAGES */ | 0 /* RDTSCP */ | + F(FXSR) | F(FXSR_OPT) | f_gbpages | 0 /* RDTSCP */ | 0 /* Reserved */ | f_lm | F(3DNOWEXT) | F(3DNOW); /* cpuid 1.ecx */ const u32 kvm_supported_word4_x86_features =