linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] KVM: MMU: simple cleanups
@ 2013-02-05  7:26 Xiao Guangrong
  2013-02-05  7:26 ` [PATCH v3 1/3] KVM: MMU: cleanup mapping-level Xiao Guangrong
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Xiao Guangrong @ 2013-02-05  7:26 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Gleb Natapov, LKML, KVM

There are the simple cleanups for MMU, no function / logic changed.

Marcelo, Gleb, please apply them after applying
"[PATCH v3] KVM: MMU: lazily drop large spte"

Changelog:
no change, just split them from the previous patchset for good review.

Thanks!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/3] KVM: MMU: cleanup mapping-level
  2013-02-05  7:26 [PATCH v3 0/3] KVM: MMU: simple cleanups Xiao Guangrong
@ 2013-02-05  7:26 ` Xiao Guangrong
  2013-02-05  7:27 ` [PATCH v3 2/3] KVM: MMU: remove pt_access in mmu_set_spte Xiao Guangrong
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Xiao Guangrong @ 2013-02-05  7:26 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Marcelo Tosatti, Gleb Natapov, LKML, KVM

Use min() to cleanup mapping_level

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/mmu.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ff2fc80..fe877da 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -832,8 +832,7 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
 	if (host_level == PT_PAGE_TABLE_LEVEL)
 		return host_level;

-	max_level = kvm_x86_ops->get_lpage_level() < host_level ?
-		kvm_x86_ops->get_lpage_level() : host_level;
+	max_level = min(kvm_x86_ops->get_lpage_level(), host_level);

 	for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level)
 		if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/3] KVM: MMU: remove pt_access in mmu_set_spte
  2013-02-05  7:26 [PATCH v3 0/3] KVM: MMU: simple cleanups Xiao Guangrong
  2013-02-05  7:26 ` [PATCH v3 1/3] KVM: MMU: cleanup mapping-level Xiao Guangrong
@ 2013-02-05  7:27 ` Xiao Guangrong
  2013-02-05  7:28 ` [PATCH v3 3/3] KVM: MMU: cleanup __direct_map Xiao Guangrong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Xiao Guangrong @ 2013-02-05  7:27 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Marcelo Tosatti, Gleb Natapov, LKML, KVM

It is only used in debug code, so drop it

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/mmu.c         |   17 +++++++----------
 arch/x86/kvm/paging_tmpl.h |    9 ++++-----
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index fe877da..2112c1b 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2403,16 +2403,15 @@ done:
 }

 static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
-			 unsigned pt_access, unsigned pte_access,
-			 int write_fault, int *emulate, int level, gfn_t gfn,
-			 pfn_t pfn, bool speculative, bool host_writable)
+			 unsigned pte_access, int write_fault, int *emulate,
+			 int level, gfn_t gfn, pfn_t pfn, bool speculative,
+			 bool host_writable)
 {
 	int was_rmapped = 0;
 	int rmap_count;

-	pgprintk("%s: spte %llx access %x write_fault %d gfn %llx\n",
-		 __func__, *sptep, pt_access,
-		 write_fault, gfn);
+	pgprintk("%s: spte %llx write_fault %d gfn %llx\n", __func__,
+		 *sptep, write_fault, gfn);

 	if (is_rmap_spte(*sptep)) {
 		/*
@@ -2528,7 +2527,7 @@ static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu,
 		return -1;

 	for (i = 0; i < ret; i++, gfn++, start++)
-		mmu_set_spte(vcpu, start, ACC_ALL, access, 0, NULL,
+		mmu_set_spte(vcpu, start, access, 0, NULL,
 			     sp->role.level, gfn, page_to_pfn(pages[i]),
 			     true, true);

@@ -2589,9 +2588,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,

 	for_each_shadow_entry(vcpu, (u64)gfn << PAGE_SHIFT, iterator) {
 		if (iterator.level == level) {
-			unsigned pte_access = ACC_ALL;
-
-			mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, pte_access,
+			mmu_set_spte(vcpu, iterator.sptep, ACC_ALL,
 				     write, &emulate, level, gfn, pfn,
 				     prefault, map_writable);
 			direct_pte_prefetch(vcpu, iterator.sptep);
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 34c5c99..105dd5b 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -326,8 +326,8 @@ FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
 	 * we call mmu_set_spte() with host_writable = true because
 	 * pte_prefetch_gfn_to_pfn always gets a writable pfn.
 	 */
-	mmu_set_spte(vcpu, spte, sp->role.access, pte_access, 0,
-		     NULL, PT_PAGE_TABLE_LEVEL, gfn, pfn, true, true);
+	mmu_set_spte(vcpu, spte, pte_access, 0, NULL, PT_PAGE_TABLE_LEVEL,
+		     gfn, pfn, true, true);

 	return true;
 }
@@ -470,9 +470,8 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
 	}

 	clear_sp_write_flooding_count(it.sptep);
-	mmu_set_spte(vcpu, it.sptep, access, gw->pte_access,
-		     write_fault, &emulate, it.level,
-		     gw->gfn, pfn, prefault, map_writable);
+	mmu_set_spte(vcpu, it.sptep, gw->pte_access, write_fault, &emulate,
+		     it.level, gw->gfn, pfn, prefault, map_writable);
 	FNAME(pte_prefetch)(vcpu, gw, it.sptep);

 	return emulate;
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 3/3] KVM: MMU: cleanup __direct_map
  2013-02-05  7:26 [PATCH v3 0/3] KVM: MMU: simple cleanups Xiao Guangrong
  2013-02-05  7:26 ` [PATCH v3 1/3] KVM: MMU: cleanup mapping-level Xiao Guangrong
  2013-02-05  7:27 ` [PATCH v3 2/3] KVM: MMU: remove pt_access in mmu_set_spte Xiao Guangrong
@ 2013-02-05  7:28 ` Xiao Guangrong
  2013-02-05 11:47 ` [PATCH v3 0/3] KVM: MMU: simple cleanups Gleb Natapov
  2013-02-08 21:05 ` Marcelo Tosatti
  4 siblings, 0 replies; 6+ messages in thread
From: Xiao Guangrong @ 2013-02-05  7:28 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Marcelo Tosatti, Gleb Natapov, LKML, KVM

Use link_shadow_page to link the sp to the spte in __direct_map

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 arch/x86/kvm/mmu.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 2112c1b..8041454 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1961,9 +1961,9 @@ static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp)
 {
 	u64 spte;

-	spte = __pa(sp->spt)
-		| PT_PRESENT_MASK | PT_ACCESSED_MASK
-		| PT_WRITABLE_MASK | PT_USER_MASK;
+	spte = __pa(sp->spt) | PT_PRESENT_MASK | PT_WRITABLE_MASK |
+	       shadow_user_mask | shadow_x_mask | shadow_accessed_mask;
+
 	mmu_spte_set(sptep, spte);
 }

@@ -2607,11 +2607,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
 					      iterator.level - 1,
 					      1, ACC_ALL, iterator.sptep);

-			mmu_spte_set(iterator.sptep,
-				     __pa(sp->spt)
-				     | PT_PRESENT_MASK | PT_WRITABLE_MASK
-				     | shadow_user_mask | shadow_x_mask
-				     | shadow_accessed_mask);
+			link_shadow_page(iterator.sptep, sp);
 		}
 	}
 	return emulate;
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/3] KVM: MMU: simple cleanups
  2013-02-05  7:26 [PATCH v3 0/3] KVM: MMU: simple cleanups Xiao Guangrong
                   ` (2 preceding siblings ...)
  2013-02-05  7:28 ` [PATCH v3 3/3] KVM: MMU: cleanup __direct_map Xiao Guangrong
@ 2013-02-05 11:47 ` Gleb Natapov
  2013-02-08 21:05 ` Marcelo Tosatti
  4 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2013-02-05 11:47 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Marcelo Tosatti, LKML, KVM

On Tue, Feb 05, 2013 at 03:26:21PM +0800, Xiao Guangrong wrote:
> There are the simple cleanups for MMU, no function / logic changed.
> 
> Marcelo, Gleb, please apply them after applying
> "[PATCH v3] KVM: MMU: lazily drop large spte"
> 
> Changelog:
> no change, just split them from the previous patchset for good review.
> 
> Thanks!
Reviewed-by: Gleb Natapov <gleb@redhat.com>

--
			Gleb.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/3] KVM: MMU: simple cleanups
  2013-02-05  7:26 [PATCH v3 0/3] KVM: MMU: simple cleanups Xiao Guangrong
                   ` (3 preceding siblings ...)
  2013-02-05 11:47 ` [PATCH v3 0/3] KVM: MMU: simple cleanups Gleb Natapov
@ 2013-02-08 21:05 ` Marcelo Tosatti
  4 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2013-02-08 21:05 UTC (permalink / raw)
  To: Xiao Guangrong; +Cc: Gleb Natapov, LKML, KVM

On Tue, Feb 05, 2013 at 03:26:21PM +0800, Xiao Guangrong wrote:
> There are the simple cleanups for MMU, no function / logic changed.
> 
> Marcelo, Gleb, please apply them after applying
> "[PATCH v3] KVM: MMU: lazily drop large spte"
> 
> Changelog:
> no change, just split them from the previous patchset for good review.
> 
> Thanks!

Applied, thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-08 21:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-05  7:26 [PATCH v3 0/3] KVM: MMU: simple cleanups Xiao Guangrong
2013-02-05  7:26 ` [PATCH v3 1/3] KVM: MMU: cleanup mapping-level Xiao Guangrong
2013-02-05  7:27 ` [PATCH v3 2/3] KVM: MMU: remove pt_access in mmu_set_spte Xiao Guangrong
2013-02-05  7:28 ` [PATCH v3 3/3] KVM: MMU: cleanup __direct_map Xiao Guangrong
2013-02-05 11:47 ` [PATCH v3 0/3] KVM: MMU: simple cleanups Gleb Natapov
2013-02-08 21:05 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).