* [RFC 6/8]KVM: introduce kvm_mmu_zap_pagetbl
@ 2007-07-23 6:51 Shaohua Li
[not found] ` <1185173503.2645.70.camel-yAZKuqJtXNMXR+D7ky4Foa2pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Shaohua Li @ 2007-07-23 6:51 UTC (permalink / raw)
To: kvm-devel, lkml
add a routine to zap all shadow pgtble for a gfn. If kvm supports SMP,
the API should zap pgtble for all vcpus, but kvm shadow page table
really should be per-vm, instead of per-vcpu.
Signed-off-by: Shaohua Li <shaohua.li-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/kvm/kvm.h | 1 +
drivers/kvm/mmu.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
Index: linux/drivers/kvm/kvm.h
===================================================================
--- linux.orig/drivers/kvm/kvm.h 2007-07-20 14:19:15.000000000 +0800
+++ linux/drivers/kvm/kvm.h 2007-07-20 14:26:10.000000000 +0800
@@ -621,6 +621,7 @@ int kvm_mmu_unprotect_page_virt(struct k
void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
int kvm_mmu_load(struct kvm_vcpu *vcpu);
void kvm_mmu_unload(struct kvm_vcpu *vcpu);
+void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn);
int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
Index: linux/drivers/kvm/mmu.c
===================================================================
--- linux.orig/drivers/kvm/mmu.c 2007-07-20 14:25:25.000000000 +0800
+++ linux/drivers/kvm/mmu.c 2007-07-20 14:26:10.000000000 +0800
@@ -1324,6 +1324,34 @@ void kvm_mmu_zap_all(struct kvm_vcpu *vc
init_kvm_mmu(vcpu);
}
+/* FIXME: this should zap all vcpu's shadow pgtbl for gfn */
+void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn)
+{
+ struct kvm *kvm = vcpu->kvm;
+ struct kvm_rmap_desc *desc;
+ struct page *page;
+ u64 *spte;
+
+ page = gfn_to_page(kvm, gfn);
+ BUG_ON(!page);
+
+ while (page_private(page)) {
+ if (!(page_private(page) & 1))
+ spte = (u64 *)page_private(page);
+ else {
+ desc = (struct kvm_rmap_desc *)(page_private(page) & ~1ul);
+ spte = desc->shadow_ptes[0];
+ }
+ BUG_ON(!spte);
+ BUG_ON((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT
+ != page_to_pfn(page));
+ BUG_ON(!(*spte & PT_PRESENT_MASK));
+ rmap_remove(vcpu, spte);
+ *spte = 0;
+ }
+ kvm_flush_remote_tlbs(vcpu->kvm);
+}
+
void kvm_mmu_module_exit(void)
{
if (pte_chain_cache)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC 6/8]KVM: introduce kvm_mmu_zap_pagetbl
[not found] ` <1185173503.2645.70.camel-yAZKuqJtXNMXR+D7ky4Foa2pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
@ 2007-07-23 11:16 ` Avi Kivity
[not found] ` <46A48E15.3030200-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2007-07-23 11:16 UTC (permalink / raw)
To: Shaohua Li; +Cc: kvm-devel, lkml
Shaohua Li wrote:
> add a routine to zap all shadow pgtble for a gfn. If kvm supports SMP,
> the API should zap pgtble for all vcpus, but kvm shadow page table
> really should be per-vm, instead of per-vcpu.
>
>
kvm shadow page tables _are_ per-vm. Current kvm.git even makes that
more explicit where functions that remove stuff (like rmap_remove())
don't require a vcpu.
> Index: linux/drivers/kvm/kvm.h
> ===================================================================
> --- linux.orig/drivers/kvm/kvm.h 2007-07-20 14:19:15.000000000 +0800
> +++ linux/drivers/kvm/kvm.h 2007-07-20 14:26:10.000000000 +0800
> @@ -621,6 +621,7 @@ int kvm_mmu_unprotect_page_virt(struct k
> void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
> int kvm_mmu_load(struct kvm_vcpu *vcpu);
> void kvm_mmu_unload(struct kvm_vcpu *vcpu);
> +void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn);
>
> int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
>
> Index: linux/drivers/kvm/mmu.c
> ===================================================================
> --- linux.orig/drivers/kvm/mmu.c 2007-07-20 14:25:25.000000000 +0800
> +++ linux/drivers/kvm/mmu.c 2007-07-20 14:26:10.000000000 +0800
> @@ -1324,6 +1324,34 @@ void kvm_mmu_zap_all(struct kvm_vcpu *vc
> init_kvm_mmu(vcpu);
> }
>
> +/* FIXME: this should zap all vcpu's shadow pgtbl for gfn */
> +void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn)
> +{
> + struct kvm *kvm = vcpu->kvm;
> + struct kvm_rmap_desc *desc;
> + struct page *page;
> + u64 *spte;
> +
> + page = gfn_to_page(kvm, gfn);
> + BUG_ON(!page);
> +
> + while (page_private(page)) {
> + if (!(page_private(page) & 1))
> + spte = (u64 *)page_private(page);
> + else {
> + desc = (struct kvm_rmap_desc *)(page_private(page) & ~1ul);
> + spte = desc->shadow_ptes[0];
> + }
> + BUG_ON(!spte);
> + BUG_ON((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT
> + != page_to_pfn(page));
> + BUG_ON(!(*spte & PT_PRESENT_MASK));
> + rmap_remove(vcpu, spte);
> + *spte = 0;
> + }
> + kvm_flush_remote_tlbs(vcpu->kvm);
> +}
> +
Suggest kvm_mmu_unmap_page() as a name for this.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC 6/8]KVM: introduce kvm_mmu_zap_pagetbl
[not found] ` <46A48E15.3030200-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-07-24 1:47 ` Shaohua Li
0 siblings, 0 replies; 3+ messages in thread
From: Shaohua Li @ 2007-07-24 1:47 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel, lkml
On Mon, 2007-07-23 at 19:16 +0800, Avi Kivity wrote:
> Shaohua Li wrote:
> > add a routine to zap all shadow pgtble for a gfn. If kvm supports
> SMP,
> > the API should zap pgtble for all vcpus, but kvm shadow page table
> > really should be per-vm, instead of per-vcpu.
> >
> >
>
> kvm shadow page tables _are_ per-vm. Current kvm.git even makes that
> more explicit where functions that remove stuff (like rmap_remove())
> don't require a vcpu.
Ok, I didn't check the latest kvm.git.
>
> > Index: linux/drivers/kvm/kvm.h
> > ===================================================================
> > --- linux.orig/drivers/kvm/kvm.h 2007-07-20 14:19:15.000000000
> +0800
> > +++ linux/drivers/kvm/kvm.h 2007-07-20 14:26:10.000000000 +0800
> > @@ -621,6 +621,7 @@ int kvm_mmu_unprotect_page_virt(struct k
> > void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
> > int kvm_mmu_load(struct kvm_vcpu *vcpu);
> > void kvm_mmu_unload(struct kvm_vcpu *vcpu);
> > +void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn);
> >
> > int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
> >
> > Index: linux/drivers/kvm/mmu.c
> > ===================================================================
> > --- linux.orig/drivers/kvm/mmu.c 2007-07-20 14:25:25.000000000
> +0800
> > +++ linux/drivers/kvm/mmu.c 2007-07-20 14:26:10.000000000 +0800
> > @@ -1324,6 +1324,34 @@ void kvm_mmu_zap_all(struct kvm_vcpu *vc
> > init_kvm_mmu(vcpu);
> > }
> >
> > +/* FIXME: this should zap all vcpu's shadow pgtbl for gfn */
> > +void kvm_mmu_zap_pagetbl(struct kvm_vcpu *vcpu, u64 gfn)
> > +{
> > + struct kvm *kvm = vcpu->kvm;
> > + struct kvm_rmap_desc *desc;
> > + struct page *page;
> > + u64 *spte;
> > +
> > + page = gfn_to_page(kvm, gfn);
> > + BUG_ON(!page);
> > +
> > + while (page_private(page)) {
> > + if (!(page_private(page) & 1))
> > + spte = (u64 *)page_private(page);
> > + else {
> > + desc = (struct kvm_rmap_desc
> *)(page_private(page) & ~1ul);
> > + spte = desc->shadow_ptes[0];
> > + }
> > + BUG_ON(!spte);
> > + BUG_ON((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT
> > + != page_to_pfn(page));
> > + BUG_ON(!(*spte & PT_PRESENT_MASK));
> > + rmap_remove(vcpu, spte);
> > + *spte = 0;
> > + }
> > + kvm_flush_remote_tlbs(vcpu->kvm);
> > +}
> > +
>
> Suggest kvm_mmu_unmap_page() as a name for this.
ok.
Thanks,
Shaohua
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-24 1:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 6:51 [RFC 6/8]KVM: introduce kvm_mmu_zap_pagetbl Shaohua Li
[not found] ` <1185173503.2645.70.camel-yAZKuqJtXNMXR+D7ky4Foa2pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
2007-07-23 11:16 ` Avi Kivity
[not found] ` <46A48E15.3030200-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-24 1:47 ` Shaohua Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox