Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1200393

[PATCH v2 2/9] KVM: MMU: move FNAME(is_rsvd_bits_set) to mmu.c

Path csiph.com!au2pb.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Xiao Guangrong <guangrong.xiao@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/9] KVM: MMU: move FNAME(is_rsvd_bits_set) to mmu.c
Date Wed, 05 Aug 2015 06:20:03 +0200
Message-ID <pTYll-6ZG-27@gated-at.bofh.it> (permalink)
References <pTYlk-6ZG-5@gated-at.bofh.it>
X-Original-To pbonzini@redhat.com
X-Extloop1 1
X-Ironport-Av E=Sophos;i="5.15,613,1432623600"; d="scan'208";a="742410625"
X-Mailer git-send-email 2.1.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 74
Organization linux.* mail to news gateway
X-Original-Cc gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, ru.pchel@gmail.com, Xiao Guangrong <guangrong.xiao@linux.intel.com>
X-Original-Date Wed, 5 Aug 2015 12:04:20 +0800
X-Original-Message-ID <1438747467-25425-3-git-send-email-guangrong.xiao@linux.intel.com>
X-Original-References <1438747467-25425-1-git-send-email-guangrong.xiao@linux.intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1200393

Show key headers only | View raw


FNAME(is_rsvd_bits_set) does not depend on guest mmu mode, move it
to mmu.c to stop being compiled multiple times

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
---
 arch/x86/kvm/mmu.c         |  8 ++++++++
 arch/x86/kvm/paging_tmpl.h | 13 ++-----------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index f432e9b..3f1c403 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3546,6 +3546,14 @@ static inline bool is_last_gpte(struct kvm_mmu *mmu, unsigned level, unsigned gp
 	return mmu->last_pte_bitmap & (1 << index);
 }
 
+static bool is_rsvd_bits_set(struct kvm_mmu *mmu, u64 gpte, int level)
+{
+	int bit7 = (gpte >> 7) & 1, low6 = gpte & 0x3f;
+
+	return (gpte & mmu->rsvd_bits_mask[bit7][level-1]) |
+		((mmu->bad_mt_xwr & (1ull << low6)) != 0);
+}
+
 #define PTTYPE_EPT 18 /* arbitrary */
 #define PTTYPE PTTYPE_EPT
 #include "paging_tmpl.h"
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 0f67d7e..736e6ab 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -128,14 +128,6 @@ static inline void FNAME(protect_clean_gpte)(unsigned *access, unsigned gpte)
 	*access &= mask;
 }
 
-static bool FNAME(is_rsvd_bits_set)(struct kvm_mmu *mmu, u64 gpte, int level)
-{
-	int bit7 = (gpte >> 7) & 1, low6 = gpte & 0x3f;
-
-	return (gpte & mmu->rsvd_bits_mask[bit7][level-1]) |
-		((mmu->bad_mt_xwr & (1ull << low6)) != 0);
-}
-
 static inline int FNAME(is_present_gpte)(unsigned long pte)
 {
 #if PTTYPE != PTTYPE_EPT
@@ -172,7 +164,7 @@ static bool FNAME(prefetch_invalid_gpte)(struct kvm_vcpu *vcpu,
 				  struct kvm_mmu_page *sp, u64 *spte,
 				  u64 gpte)
 {
-	if (FNAME(is_rsvd_bits_set)(&vcpu->arch.mmu, gpte, PT_PAGE_TABLE_LEVEL))
+	if (is_rsvd_bits_set(&vcpu->arch.mmu, gpte, PT_PAGE_TABLE_LEVEL))
 		goto no_present;
 
 	if (!FNAME(is_present_gpte)(gpte))
@@ -353,8 +345,7 @@ retry_walk:
 		if (unlikely(!FNAME(is_present_gpte)(pte)))
 			goto error;
 
-		if (unlikely(FNAME(is_rsvd_bits_set)(mmu, pte,
-					             walker->level))) {
+		if (unlikely(is_rsvd_bits_set(mmu, pte, walker->level))) {
 			errcode |= PFERR_RSVD_MASK | PFERR_PRESENT_MASK;
 			goto error;
 		}
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/9] KVM: MMU: fix and improve validation of mmio page fault Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 6/9] KVM: MMU: introduce the framework to check zero bits on sptes Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 5/9] KVM: MMU: split reset_rsvds_bits_mask_ept Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 4/9] KVM: MMU: split reset_rsvds_bits_mask Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 1/9] KVM: MMU: fix validation of mmio page fault Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 9/9] KVM: VMX: drop ept misconfig check Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 2/9] KVM: MMU: move FNAME(is_rsvd_bits_set) to mmu.c Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
  [PATCH v2 8/9] KVM: MMU: fully check zero bits for sptes Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-05 06:20 +0200
    Re: [PATCH v2 8/9] KVM: MMU: fully check zero bits for sptes Paolo Bonzini <pbonzini@redhat.com> - 2015-08-05 12:20 +0200
      Re: [PATCH v2 8/9] KVM: MMU: fully check zero bits for sptes Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2015-08-06 05:00 +0200

csiph-web