* [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page"
[not found] <1359556953-30673-1-git-send-email-y>
@ 2013-01-30 14:42 ` y
0 siblings, 0 replies; 11+ messages in thread
From: y @ 2013-01-30 14:42 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
From: Gleb Natapov <gleb@redhat.com>
This reverts commit bd4c86eaa6ff10abc4e00d0f45d2a28b10b09df4.
There is not user for kvm_mmu_isolate_page() any more.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/mmu.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 42ba85c..0242a8a 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1461,28 +1461,14 @@ static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr)
percpu_counter_add(&kvm_total_used_mmu_pages, nr);
}
-/*
- * Remove the sp from shadow page cache, after call it,
- * we can not find this sp from the cache, and the shadow
- * page table is still valid.
- * It should be under the protection of mmu lock.
- */
-static void kvm_mmu_isolate_page(struct kvm_mmu_page *sp)
+static void kvm_mmu_free_page(struct kvm_mmu_page *sp)
{
ASSERT(is_empty_shadow_page(sp->spt));
hlist_del(&sp->hash_link);
- if (!sp->role.direct)
- free_page((unsigned long)sp->gfns);
-}
-
-/*
- * Free the shadow page table and the sp, we can do it
- * out of the protection of mmu lock.
- */
-static void kvm_mmu_free_page(struct kvm_mmu_page *sp)
-{
list_del(&sp->link);
free_page((unsigned long)sp->spt);
+ if (!sp->role.direct)
+ free_page((unsigned long)sp->gfns);
kmem_cache_free(mmu_page_header_cache, sp);
}
@@ -2126,7 +2112,6 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
do {
sp = list_first_entry(invalid_list, struct kvm_mmu_page, link);
WARN_ON(!sp->role.invalid || sp->root_count);
- kvm_mmu_isolate_page(sp);
kvm_mmu_free_page(sp);
} while (!list_empty(invalid_list));
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 0/6] small cleanups in MMU code
@ 2013-01-30 14:44 Gleb Natapov
2013-01-30 14:45 ` [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear Gleb Natapov
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:44 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
Any of those should not change functionality.
Gleb Natapov (6):
KVM: MMU: make spte_is_locklessly_modifiable() more clear
KVM: MMU: drop unneeded checks.
KVM: MMU: set base_role.nxe during mmu initialization.
KVM: MMU: drop superfluous min() call.
KVM: MMU: drop superfluous is_present_gpte() check.
Revert "KVM: MMU: split kvm_mmu_free_page"
arch/x86/kvm/mmu.c | 32 +++++++++-----------------------
arch/x86/kvm/paging_tmpl.h | 3 ---
arch/x86/kvm/x86.c | 2 --
3 files changed, 9 insertions(+), 28 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
@ 2013-01-30 14:45 ` Gleb Natapov
2013-01-30 14:45 ` [PATCH 2/6] KVM: MMU: drop unneeded checks Gleb Natapov
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:45 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
spte_is_locklessly_modifiable() checks that both SPTE_HOST_WRITEABLE and
SPTE_MMU_WRITEABLE are present on spte. Make it more explicit.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/mmu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 9f628f7..2fa82b0 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -448,7 +448,8 @@ static bool __check_direct_spte_mmio_pf(u64 spte)
static bool spte_is_locklessly_modifiable(u64 spte)
{
- return !(~spte & (SPTE_HOST_WRITEABLE | SPTE_MMU_WRITEABLE));
+ return (spte & (SPTE_HOST_WRITEABLE | SPTE_MMU_WRITEABLE)) ==
+ (SPTE_HOST_WRITEABLE | SPTE_MMU_WRITEABLE);
}
static bool spte_has_volatile_bits(u64 spte)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/6] KVM: MMU: drop unneeded checks.
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
2013-01-30 14:45 ` [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear Gleb Natapov
@ 2013-01-30 14:45 ` Gleb Natapov
2013-01-30 14:45 ` [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization Gleb Natapov
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:45 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/mmu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 2fa82b0..40737b3 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2328,9 +2328,8 @@ static int mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,
if (s->role.level != PT_PAGE_TABLE_LEVEL)
return 1;
- if (!need_unsync && !s->unsync) {
+ if (!s->unsync)
need_unsync = true;
- }
}
if (need_unsync)
kvm_unsync_pages(vcpu, gfn);
@@ -4008,7 +4007,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
!((sp->role.word ^ vcpu->arch.mmu.base_role.word)
& mask.word) && rmap_can_add(vcpu))
mmu_pte_write_new_pte(vcpu, sp, spte, &gentry);
- if (!remote_flush && need_remote_flush(entry, *spte))
+ if (need_remote_flush(entry, *spte))
remote_flush = true;
++spte;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization.
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
2013-01-30 14:45 ` [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear Gleb Natapov
2013-01-30 14:45 ` [PATCH 2/6] KVM: MMU: drop unneeded checks Gleb Natapov
@ 2013-01-30 14:45 ` Gleb Natapov
2013-01-30 14:45 ` [PATCH 4/6] KVM: MMU: drop superfluous min() call Gleb Natapov
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:45 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
Move base_role.nxe initialisation to where all other roles are initialized.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/mmu.c | 1 +
arch/x86/kvm/x86.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 40737b3..8028ac6 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3687,6 +3687,7 @@ int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
else
r = paging32_init_context(vcpu, context);
+ vcpu->arch.mmu.base_role.nxe = is_nx(vcpu);
vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu);
vcpu->arch.mmu.base_role.cr0_wp = is_write_protection(vcpu);
vcpu->arch.mmu.base_role.smep_andnot_wp
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cf512e70..373e17a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -870,8 +870,6 @@ static int set_efer(struct kvm_vcpu *vcpu, u64 efer)
kvm_x86_ops->set_efer(vcpu, efer);
- vcpu->arch.mmu.base_role.nxe = (efer & EFER_NX) && !tdp_enabled;
-
/* Update reserved bits */
if ((efer ^ old_efer) & EFER_NX)
kvm_mmu_reset_context(vcpu);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/6] KVM: MMU: drop superfluous min() call.
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
` (2 preceding siblings ...)
2013-01-30 14:45 ` [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization Gleb Natapov
@ 2013-01-30 14:45 ` Gleb Natapov
2013-01-30 14:45 ` [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check Gleb Natapov
2013-01-30 14:45 ` [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page" Gleb Natapov
5 siblings, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:45 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 8028ac6..42ba85c 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3854,7 +3854,7 @@ static u64 mmu_pte_write_fetch_gpte(struct kvm_vcpu *vcpu, gpa_t *gpa,
/* Handle a 32-bit guest writing two halves of a 64-bit gpte */
*gpa &= ~(gpa_t)7;
*bytes = 8;
- r = kvm_read_guest(vcpu->kvm, *gpa, &gentry, min(*bytes, 8));
+ r = kvm_read_guest(vcpu->kvm, *gpa, &gentry, 8);
if (r)
gentry = 0;
new = (const u8 *)&gentry;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check.
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
` (3 preceding siblings ...)
2013-01-30 14:45 ` [PATCH 4/6] KVM: MMU: drop superfluous min() call Gleb Natapov
@ 2013-01-30 14:45 ` Gleb Natapov
2013-01-30 14:45 ` [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page" Gleb Natapov
5 siblings, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:45 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
Gust page walker puts only present ptes into ptes[] array. No need to
check it again.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/paging_tmpl.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index ca69dcc..34c5c99 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -409,9 +409,6 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
unsigned direct_access, access = gw->pt_access;
int top_level, emulate = 0;
- if (!is_present_gpte(gw->ptes[gw->level - 1]))
- return 0;
-
direct_access = gw->pte_access;
top_level = vcpu->arch.mmu.root_level;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page"
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
` (4 preceding siblings ...)
2013-01-30 14:45 ` [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check Gleb Natapov
@ 2013-01-30 14:45 ` Gleb Natapov
2013-02-05 1:24 ` Marcelo Tosatti
5 siblings, 1 reply; 11+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:45 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
This reverts commit bd4c86eaa6ff10abc4e00d0f45d2a28b10b09df4.
There is not user for kvm_mmu_isolate_page() any more.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/mmu.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 42ba85c..0242a8a 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1461,28 +1461,14 @@ static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr)
percpu_counter_add(&kvm_total_used_mmu_pages, nr);
}
-/*
- * Remove the sp from shadow page cache, after call it,
- * we can not find this sp from the cache, and the shadow
- * page table is still valid.
- * It should be under the protection of mmu lock.
- */
-static void kvm_mmu_isolate_page(struct kvm_mmu_page *sp)
+static void kvm_mmu_free_page(struct kvm_mmu_page *sp)
{
ASSERT(is_empty_shadow_page(sp->spt));
hlist_del(&sp->hash_link);
- if (!sp->role.direct)
- free_page((unsigned long)sp->gfns);
-}
-
-/*
- * Free the shadow page table and the sp, we can do it
- * out of the protection of mmu lock.
- */
-static void kvm_mmu_free_page(struct kvm_mmu_page *sp)
-{
list_del(&sp->link);
free_page((unsigned long)sp->spt);
+ if (!sp->role.direct)
+ free_page((unsigned long)sp->gfns);
kmem_cache_free(mmu_page_header_cache, sp);
}
@@ -2126,7 +2112,6 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
do {
sp = list_first_entry(invalid_list, struct kvm_mmu_page, link);
WARN_ON(!sp->role.invalid || sp->root_count);
- kvm_mmu_isolate_page(sp);
kvm_mmu_free_page(sp);
} while (!list_empty(invalid_list));
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page"
2013-01-30 14:45 ` [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page" Gleb Natapov
@ 2013-02-05 1:24 ` Marcelo Tosatti
2013-02-05 1:47 ` Takuya Yoshikawa
2013-02-05 8:42 ` Gleb Natapov
0 siblings, 2 replies; 11+ messages in thread
From: Marcelo Tosatti @ 2013-02-05 1:24 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm, xiaoguangrong, yoshikawa_takuya_b1
On Wed, Jan 30, 2013 at 04:45:05PM +0200, Gleb Natapov wrote:
> This reverts commit bd4c86eaa6ff10abc4e00d0f45d2a28b10b09df4.
>
> There is not user for kvm_mmu_isolate_page() any more.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
> arch/x86/kvm/mmu.c | 21 +++------------------
Applied all except this - Takuya's using it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page"
2013-02-05 1:24 ` Marcelo Tosatti
@ 2013-02-05 1:47 ` Takuya Yoshikawa
2013-02-05 8:42 ` Gleb Natapov
1 sibling, 0 replies; 11+ messages in thread
From: Takuya Yoshikawa @ 2013-02-05 1:47 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Gleb Natapov, kvm, xiaoguangrong
On Mon, 4 Feb 2013 23:24:01 -0200
Marcelo Tosatti <mtosatti@redhat.com> wrote:
> On Wed, Jan 30, 2013 at 04:45:05PM +0200, Gleb Natapov wrote:
> > This reverts commit bd4c86eaa6ff10abc4e00d0f45d2a28b10b09df4.
> >
> > There is not user for kvm_mmu_isolate_page() any more.
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > ---
> > arch/x86/kvm/mmu.c | 21 +++------------------
>
> Applied all except this - Takuya's using it.
My patch just folds it into kvm_mmu_free_page(), so this patch
helps me a bit.
If you want to apply this, I can rebase my patch appropriately.
Thanks,
Takuya
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page"
2013-02-05 1:24 ` Marcelo Tosatti
2013-02-05 1:47 ` Takuya Yoshikawa
@ 2013-02-05 8:42 ` Gleb Natapov
1 sibling, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-02-05 8:42 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm, xiaoguangrong, yoshikawa_takuya_b1
On Mon, Feb 04, 2013 at 11:24:01PM -0200, Marcelo Tosatti wrote:
> On Wed, Jan 30, 2013 at 04:45:05PM +0200, Gleb Natapov wrote:
> > This reverts commit bd4c86eaa6ff10abc4e00d0f45d2a28b10b09df4.
> >
> > There is not user for kvm_mmu_isolate_page() any more.
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > ---
> > arch/x86/kvm/mmu.c | 21 +++------------------
>
> Applied all except this - Takuya's using it.
He actually revers this commit, but in non-obvious way. Reverting it
explicitly makes for more clear commit history.
--
Gleb.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-02-05 8:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-30 14:44 [PATCH 0/6] small cleanups in MMU code Gleb Natapov
2013-01-30 14:45 ` [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear Gleb Natapov
2013-01-30 14:45 ` [PATCH 2/6] KVM: MMU: drop unneeded checks Gleb Natapov
2013-01-30 14:45 ` [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization Gleb Natapov
2013-01-30 14:45 ` [PATCH 4/6] KVM: MMU: drop superfluous min() call Gleb Natapov
2013-01-30 14:45 ` [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check Gleb Natapov
2013-01-30 14:45 ` [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page" Gleb Natapov
2013-02-05 1:24 ` Marcelo Tosatti
2013-02-05 1:47 ` Takuya Yoshikawa
2013-02-05 8:42 ` Gleb Natapov
[not found] <1359556953-30673-1-git-send-email-y>
2013-01-30 14:42 ` y
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox