mmu:remove the usage of the private field by the rmap.
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/1 mmu:remove the usage of the private field by the rmap.
in order to be able to allocate the memory to kvm from userspace we have to remove
the private usage made by the rmap.
this patch add array to each memory slot sorted by gfn that hold rmap to each page.
to make the finding of gfn from spte address, we are adding another page to each kvm_mmu_page, that hold
to each spte - spt offset the gfn of it.
thanks
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 64F9B87B6B770947A9F8391472E032160CBECFB7-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/[email protected]
I think you forgot to include the patch?
Regards,
Anthony Liguori
Quoted 22 lines · Izik Eidus
in order to be able to allocate the memory to kvm from userspace we have to remove
the private usage made by the rmap.this patch add array to each memory slot sorted by gfn that hold rmap to each page.
to make the finding of gfn from spte address, we are adding another page to eachkvm_mmu_page, that hold
to each spte - spt offset the gfn of it.thanks
------------------------------------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
------------------------------------------------------------------------
Quoted 5 lines
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Anthony Liguori
I think you forgot to include the patch?
Regards,
Anthony Liguori
yes i forgot :)
here it is...
commit 3ed7059496e6e7d802dfb46e604d0af4abc2b040
Author: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/[email protected]> Date: Mon Sep 24 13:35:12 2007 +0200
Remove the usage of the private field by the rmap.
this patch add to each memory slot an array sorted by gfn that hold to each page its reverse mapping,
drivers/kvm/kvm.h +5 -1
@@ -126,6 +126,8 @@ struct kvm_mmu_page {union kvm_mmu_page_role role;u64 *spt; +/* hold the gfn of each spte inside spt */ +gfn_t *gfns;unsigned long slot_bitmap;/* One bit set per slot which has memory * in this shadow page. */
@@ -157,7 +159,7 @@ struct kvm_mmu {u64 *pae_root; }; -#define KVM_NR_MEM_OBJS 20 +#define KVM_NR_MEM_OBJS 40struct kvm_mmu_memory_cache {int nobjs;
@@ -399,6 +401,7 @@ struct kvm_memory_slot {unsigned long npages;unsigned long flags;struct page **phys_mem; +unsigned long *rmap;unsigned long *dirty_bitmap; };
@@ -550,6 +553,7 @@ struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);extern hpa_t bad_page_address; +gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn);struct page *gfn_to_page (struct kvm *kvm,gfn_t gfn);struct kvm_memory_slot *gfn_to_memslot (struct kvm *kvm,gfn_t gfn);void mark_page_dirty (struct kvm *kvm,gfn_t gfn);
drivers/kvm/kvm_main.c +9 -2
@@ -329,6 +329,8 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,__free_page (free->phys_mem[i]);vfree (free->phys_mem); } +if (!dont || free->rmap != dont->rmap) +vfree (free->rmap);if (!dont || free->dirty_bitmap != dont->dirty_bitmap)vfree (free->dirty_bitmap);
@@ -742,13 +744,18 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,if (!new.phys_mem) goto out_unlock; + new.rmap =vmalloc (npages *sizeof (struct page *)); + +if (!new.rmap) + goto out_unlock; +memset (new.phys_mem,0 , npages *sizeof (struct page *)); +memset (new.rmap,0 , npages *sizeof (*new.rmap));for (i =0 ; i < npages; ++i) { new.phys_mem[i] =alloc_page (GFP_HIGHUSER | __GFP_ZERO);if (!new.phys_mem[i]) goto out_unlock; -set_page_private (new.phys_mem[i],0 ); } }
@@ -932,7 +939,7 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)return r; } -static gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) +gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) {int i;struct kvm_mem_alias *alias;
drivers/kvm/mmu.c +75 -52
269 lines not on this page · raw message
drivers/kvm/paging_tmpl.h +2 -1
@@ -289,7 +289,8 @@ unshadowed:set_shadow_pte (shadow_pte, spte);page_header_update_slot (vcpu->kvm, shadow_pte, gaddr);if (!was_rmapped) -rmap_add (vcpu, shadow_pte); +rmap_add (vcpu, shadow_pte, (gaddr &PT64_BASE_ADDR_MASK ) + >>PAGE_SHIFT ); } static void FNAME(set_pte)(struct kvm_vcpu *vcpu, pt_element_t gpte,
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 46F8B7B2.9020104-atKUWr5tajBWk0Htik3J/[email protected]
Quoted 10 lines · Izik Eidus
Quoted 7 lines · Anthony Liguori
I think you forgot to include the patch?
Regards,
Anthony Liguori
yes i forgot :)
here it is...
Patch doesn't apply. Can you rebase to latest kvm.git?
Also, fix whitespace issues reported by 'git apply'.
Please repost with 'git format-patch' instead of 'git show'.
Signature · 7 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): 46FB8C39.2060505-atKUWr5tajBWk0Htik3J/[email protected]
Quoted 17 lines · Avi Kivity
Quoted 4 lines · Izik Eidus
Quoted 2 lines · Anthony Liguori
I think you forgot to include the patch?
Quoted 9 lines
Quoted 6 lines
Regards,
Anthony Liguori
yes i forgot :)
here it is...
Quoted 7 lines
Patch doesn't apply. Can you rebase to latest kvm.git?
Also, fix whitespace issues reported by 'git apply'.
Please repost with 'git format-patch' instead of 'git show'.
avi, is it ok now?
Quoted 1 line
From
974f43b6b550a7b895d8374f43e9ea454d8636e3Mon Sep 17 00:00:00 2001
From: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/[email protected]>
Date: Thu, 27 Sep 2007 14:11:22 +0200
Subject: [PATCH] Remove the usage of the private field by the rmap. this patch add to each memory slot an array sorted by gfn that hold to each page its reverse mapping.
--- drivers/kvm/kvm.h | 6 ++- drivers/kvm/kvm_main.c | 11 +++- drivers/kvm/mmu.c | 122 ++++++++++++++++++++++++++------------------- drivers/kvm/paging_tmpl.h | 3 +- 4 files changed, 86 insertions(+), 56 deletions(-)
drivers/kvm/kvm.h +5 -1
@@ -126,6 +126,8 @@ struct kvm_mmu_page {union kvm_mmu_page_role role;u64 *spt; +/* hold the gfn of each spte inside spt */ +gfn_t *gfns;unsigned long slot_bitmap;/* One bit set per slot which has memory * in this shadow page. */
@@ -159,7 +161,7 @@ struct kvm_mmu {u64 *pae_root; }; -#define KVM_NR_MEM_OBJS 20 +#define KVM_NR_MEM_OBJS 40struct kvm_mmu_memory_cache {int nobjs;
@@ -402,6 +404,7 @@ struct kvm_memory_slot {unsigned long npages;unsigned long flags;struct page **phys_mem; +unsigned long *rmap;unsigned long *dirty_bitmap; };
@@ -554,6 +557,7 @@ struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);extern hpa_t bad_page_address; +gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn);struct page *gfn_to_page (struct kvm *kvm,gfn_t gfn);struct kvm_memory_slot *gfn_to_memslot (struct kvm *kvm,gfn_t gfn);void mark_page_dirty (struct kvm *kvm,gfn_t gfn);
drivers/kvm/kvm_main.c +9 -2
@@ -329,6 +329,8 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,__free_page (free->phys_mem[i]);vfree (free->phys_mem); } +if (!dont || free->rmap != dont->rmap) +vfree (free->rmap);if (!dont || free->dirty_bitmap != dont->dirty_bitmap)vfree (free->dirty_bitmap);
@@ -739,13 +741,18 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,if (!new.phys_mem) goto out_unlock; + new.rmap =vmalloc (npages *sizeof (struct page *)); + +if (!new.rmap) + goto out_unlock; +memset (new.phys_mem,0 , npages *sizeof (struct page *)); +memset (new.rmap,0 , npages *sizeof (*new.rmap));for (i =0 ; i < npages; ++i) { new.phys_mem[i] =alloc_page (GFP_HIGHUSER | __GFP_ZERO);if (!new.phys_mem[i]) goto out_unlock; -set_page_private (new.phys_mem[i],0 ); } }
@@ -929,7 +936,7 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)return r; } -static gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) +gfn_t unalias_gfn (struct kvm *kvm,gfn_t gfn) {int i;struct kvm_mem_alias *alias;
drivers/kvm/mmu.c +70 -52
264 lines not on this page · raw message
drivers/kvm/paging_tmpl.h +2 -1
@@ -295,7 +295,8 @@ unshadowed:set_shadow_pte (shadow_pte, spte);page_header_update_slot (vcpu->kvm, shadow_pte, gaddr);if (!was_rmapped) -rmap_add (vcpu, shadow_pte); +rmap_add (vcpu, shadow_pte, (gaddr &PT64_BASE_ADDR_MASK ) + >>PAGE_SHIFT );if (!ptwrite || !*ptwrite) vcpu->last_pte_updated = shadow_pte; }
Signature · 1 line
1.5.2.4
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 46FBA07F.8030402-atKUWr5tajBWk0Htik3J/[email protected]
Quoted 17 lines · Izik Eidus
Quoted 16 lines · Avi Kivity
Quoted 12 lines · Izik Eidus
Quoted 7 lines · Anthony Liguori
I think you forgot to include the patch?
Regards,
Anthony Liguori
yes i forgot :)
here it is...
Quoted 9 lines
Quoted 7 lines
Patch doesn't apply. Can you rebase to latest kvm.git?
Also, fix whitespace issues reported by 'git apply'.
Please repost with 'git format-patch' instead of 'git show'.
avi, is it ok now?
Sure; applied.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/