* [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear
[not found] <1359556953-30673-1-git-send-email-y>
@ 2013-01-30 14:42 ` y
2013-01-30 14:42 ` [PATCH 2/6] KVM: MMU: drop unneeded checks y
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ 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>
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] 13+ messages in thread* [PATCH 2/6] KVM: MMU: drop unneeded checks.
[not found] <1359556953-30673-1-git-send-email-y>
2013-01-30 14:42 ` [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear y
@ 2013-01-30 14:42 ` y
2013-01-30 14:42 ` [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization y
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ 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>
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] 13+ messages in thread* [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization.
[not found] <1359556953-30673-1-git-send-email-y>
2013-01-30 14:42 ` [PATCH 1/6] KVM: MMU: make spte_is_locklessly_modifiable() more clear y
2013-01-30 14:42 ` [PATCH 2/6] KVM: MMU: drop unneeded checks y
@ 2013-01-30 14:42 ` y
2013-01-30 14:42 ` [PATCH 4/6] KVM: MMU: drop superfluous min() call y
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ 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>
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] 13+ messages in thread* [PATCH 4/6] KVM: MMU: drop superfluous min() call.
[not found] <1359556953-30673-1-git-send-email-y>
` (2 preceding siblings ...)
2013-01-30 14:42 ` [PATCH 3/6] KVM: MMU: set base_role.nxe during mmu initialization y
@ 2013-01-30 14:42 ` y
2013-01-30 14:42 ` [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check y
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ 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>
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] 13+ messages in thread* [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check.
[not found] <1359556953-30673-1-git-send-email-y>
` (3 preceding siblings ...)
2013-01-30 14:42 ` [PATCH 4/6] KVM: MMU: drop superfluous min() call y
@ 2013-01-30 14:42 ` y
2013-01-30 14:42 ` [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page" y
2013-01-30 14:44 ` [PATCH 0/6] small cleanups in MMU code Gleb Natapov
6 siblings, 0 replies; 13+ 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>
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] 13+ messages in thread* [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page"
[not found] <1359556953-30673-1-git-send-email-y>
` (4 preceding siblings ...)
2013-01-30 14:42 ` [PATCH 5/6] KVM: MMU: drop superfluous is_present_gpte() check y
@ 2013-01-30 14:42 ` y
2013-01-30 14:44 ` [PATCH 0/6] small cleanups in MMU code Gleb Natapov
6 siblings, 0 replies; 13+ 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] 13+ messages in thread* Re: [PATCH 0/6] small cleanups in MMU code
[not found] <1359556953-30673-1-git-send-email-y>
` (5 preceding siblings ...)
2013-01-30 14:42 ` [PATCH 6/6] Revert "KVM: MMU: split kvm_mmu_free_page" y
@ 2013-01-30 14:44 ` Gleb Natapov
6 siblings, 0 replies; 13+ messages in thread
From: Gleb Natapov @ 2013-01-30 14:44 UTC (permalink / raw)
To: kvm; +Cc: mtosatti, xiaoguangrong, yoshikawa_takuya_b1
Something went wrong with git send-email. Ignore this one please.
On Wed, Jan 30, 2013 at 04:42:27PM +0200, y@redhat.com wrote:
> From: Gleb Natapov <gleb@redhat.com>
>
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
^ permalink raw reply [flat|nested] 13+ messages in thread