From patchwork Sat May 30 10:59:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 6512811 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C8FA29F1CC for ; Sat, 30 May 2015 11:01:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 017FF20851 for ; Sat, 30 May 2015 11:01:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B11320850 for ; Sat, 30 May 2015 11:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757811AbbE3K7w (ORCPT ); Sat, 30 May 2015 06:59:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:44040 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757762AbbE3K7m (ORCPT ); Sat, 30 May 2015 06:59:42 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 30 May 2015 03:59:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,522,1427785200"; d="scan'208";a="717943221" Received: from slu40-mobl2.ccr.corp.intel.com (HELO homedesktop.ccr.corp.intel.com) ([10.254.212.183]) by fmsmga001.fm.intel.com with ESMTP; 30 May 2015 03:59:35 -0700 From: Xiao Guangrong To: pbonzini@redhat.com Cc: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiao Guangrong Subject: [PATCH 03/15] KVM: MTRR: remove mtrr_state.have_fixed Date: Sat, 30 May 2015 18:59:14 +0800 Message-Id: <1432983566-15773-4-git-send-email-guangrong.xiao@linux.intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1432983566-15773-1-git-send-email-guangrong.xiao@linux.intel.com> References: <1432983566-15773-1-git-send-email-guangrong.xiao@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP vMTRR does not depend on any host MTRR feature and fixed MTRRs have always been implemented, so drop this field Signed-off-by: Xiao Guangrong --- arch/x86/include/asm/kvm_host.h | 9 ++++++++- arch/x86/kvm/mtrr.c | 7 +++---- arch/x86/kvm/x86.c | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 2353392..65de1b3 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -344,6 +344,13 @@ enum { KVM_DEBUGREG_RELOAD = 4, }; +struct kvm_mtrr { + struct mtrr_var_range var_ranges[MTRR_MAX_VAR_RANGES]; + mtrr_type fixed_ranges[KVM_NR_FIXED_MTRR_REGION]; + unsigned char enabled; + mtrr_type def_type; +}; + struct kvm_vcpu_arch { /* * rip and regs accesses must go through @@ -472,7 +479,7 @@ struct kvm_vcpu_arch { unsigned nmi_pending; /* NMI queued after currently running handler */ bool nmi_injected; /* Trying to inject an NMI this entry */ - struct mtrr_state_type mtrr_state; + struct kvm_mtrr mtrr_state; u64 pat; unsigned switch_db_regs; diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index 32664ec..562341b 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -104,7 +104,7 @@ EXPORT_SYMBOL_GPL(kvm_mtrr_valid); static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) { - struct mtrr_state_type *mtrr_state = &vcpu->arch.mtrr_state; + struct kvm_mtrr *mtrr_state = &vcpu->arch.mtrr_state; unsigned char mtrr_enabled = mtrr_state->enabled; gfn_t start, end, mask; int index; @@ -248,7 +248,7 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata) * The function is based on mtrr_type_lookup() in * arch/x86/kernel/cpu/mtrr/generic.c */ -static int get_mtrr_type(struct mtrr_state_type *mtrr_state, +static int get_mtrr_type(struct kvm_mtrr *mtrr_state, u64 start, u64 end) { u64 base, mask; @@ -263,8 +263,7 @@ static int get_mtrr_type(struct mtrr_state_type *mtrr_state, end--; /* Look in fixed ranges. Just return the type as per start */ - if (mtrr_state->have_fixed && (mtrr_state->enabled & 0x1) && - (start < 0x100000)) { + if ((mtrr_state->enabled & 0x1) && (start < 0x100000)) { int idx; if (start < 0x80000) { diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 92db294..64c2891 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6985,7 +6985,6 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { int r; - vcpu->arch.mtrr_state.have_fixed = 1; r = vcpu_load(vcpu); if (r) return r;