[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Give the map_dom_mem_cache a better name, and fix a bug in



ChangeSet 1.1688, 2005/06/07 09:59:04+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Give the map_dom_mem_cache a better name, and fix a bug in
        unmap_domain_mem_with_cache() [it shouldn't actually unmap the page!].
        The bug was spotted by George Dunlap.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 arch/x86/mm.c                        |   10 +++++-----
 arch/x86/shadow.c                    |   22 +++++++++++-----------
 include/asm-x86/shadow.h             |   12 ++++++------
 include/asm-x86/x86_32/domain_page.h |   19 ++++++++++++-------
 include/asm-x86/x86_64/domain_page.h |    6 +++---
 5 files changed, 37 insertions(+), 32 deletions(-)


diff -Nru a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c 2005-06-07 05:02:50 -04:00
+++ b/xen/arch/x86/mm.c 2005-06-07 05:02:50 -04:00
@@ -1940,7 +1940,7 @@
     struct vcpu *v = current;
     struct domain *d = v->domain;
     u32 type_info;
-    struct map_dom_mem_cache mapcache, sh_mapcache;
+    struct domain_mmap_cache mapcache, sh_mapcache;
 
     LOCK_BIGLOCK(d);
 
@@ -1956,8 +1956,8 @@
             (void)get_user(done, pdone);
     }
 
-    init_map_domain_mem_cache(&mapcache);
-    init_map_domain_mem_cache(&sh_mapcache);
+    domain_mmap_cache_init(&mapcache);
+    domain_mmap_cache_init(&sh_mapcache);
 
     if ( !set_foreigndom(cpu, foreigndom) )
     {
@@ -2169,8 +2169,8 @@
     }
 
  out:
-    destroy_map_domain_mem_cache(&mapcache);
-    destroy_map_domain_mem_cache(&sh_mapcache);
+    domain_mmap_cache_destroy(&mapcache);
+    domain_mmap_cache_destroy(&sh_mapcache);
 
     process_deferred_ops(cpu);
 
diff -Nru a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c
--- a/xen/arch/x86/shadow.c     2005-06-07 05:02:51 -04:00
+++ b/xen/arch/x86/shadow.c     2005-06-07 05:02:51 -04:00
@@ -763,8 +763,8 @@
 
 int
 set_p2m_entry(struct domain *d, unsigned long pfn, unsigned long mfn,
-              struct map_dom_mem_cache *l2cache,
-              struct map_dom_mem_cache *l1cache)
+              struct domain_mmap_cache *l2cache,
+              struct domain_mmap_cache *l1cache)
 {
     unsigned long phystab = pagetable_get_paddr(d->arch.phys_table);
     l2_pgentry_t *l2, l2e;
@@ -808,14 +808,14 @@
     struct pfn_info *page, *l2page;
     l2_pgentry_t *l2;
     unsigned long mfn, pfn;
-    struct map_dom_mem_cache l1cache, l2cache;
+    struct domain_mmap_cache l1cache, l2cache;
 
     l2page = alloc_domheap_page(NULL);
     if ( l2page == NULL )
         return 0;
 
-    init_map_domain_mem_cache(&l1cache);
-    init_map_domain_mem_cache(&l2cache);
+    domain_mmap_cache_init(&l1cache);
+    domain_mmap_cache_init(&l2cache);
 
     d->arch.phys_table = mk_pagetable(page_to_phys(l2page));
     l2 = map_domain_mem_with_cache(page_to_phys(l2page), &l2cache);
@@ -851,8 +851,8 @@
         list_ent = page->list.next;
     }
 
-    destroy_map_domain_mem_cache(&l2cache);
-    destroy_map_domain_mem_cache(&l1cache);
+    domain_mmap_cache_destroy(&l2cache);
+    domain_mmap_cache_destroy(&l1cache);
 
     return 1;
 }
@@ -2682,7 +2682,7 @@
 void shadow_l1_normal_pt_update(
     struct domain *d,
     unsigned long pa, l1_pgentry_t gpte,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     unsigned long sl1mfn;    
     l1_pgentry_t *spl1e, spte;
@@ -2707,7 +2707,7 @@
 void shadow_l2_normal_pt_update(
     struct domain *d,
     unsigned long pa, l2_pgentry_t gpde,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     unsigned long sl2mfn;
     l2_pgentry_t *spl2e;
@@ -2732,7 +2732,7 @@
 void shadow_l3_normal_pt_update(
     struct domain *d,
     unsigned long pa, l3_pgentry_t gpde,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     BUG(); // not yet implemented
 }
@@ -2742,7 +2742,7 @@
 void shadow_l4_normal_pt_update(
     struct domain *d,
     unsigned long pa, l4_pgentry_t gpde,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     BUG(); // not yet implemented
 }
diff -Nru a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h
--- a/xen/include/asm-x86/shadow.h      2005-06-07 05:02:50 -04:00
+++ b/xen/include/asm-x86/shadow.h      2005-06-07 05:02:50 -04:00
@@ -121,25 +121,25 @@
 extern int __shadow_out_of_sync(struct vcpu *v, unsigned long va);
 extern int set_p2m_entry(
     struct domain *d, unsigned long pfn, unsigned long mfn,
-    struct map_dom_mem_cache *l2cache,
-    struct map_dom_mem_cache *l1cache);
+    struct domain_mmap_cache *l2cache,
+    struct domain_mmap_cache *l1cache);
 extern void remove_shadow(struct domain *d, unsigned long gpfn, u32 stype);
 
 extern void shadow_l1_normal_pt_update(struct domain *d,
                                        unsigned long pa, l1_pgentry_t l1e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 extern void shadow_l2_normal_pt_update(struct domain *d,
                                        unsigned long pa, l2_pgentry_t l2e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 #if CONFIG_PAGING_LEVELS >= 3
 extern void shadow_l3_normal_pt_update(struct domain *d,
                                        unsigned long pa, l3_pgentry_t l3e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 #endif
 #if CONFIG_PAGING_LEVELS >= 4
 extern void shadow_l4_normal_pt_update(struct domain *d,
                                        unsigned long pa, l4_pgentry_t l4e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 #endif
 extern int shadow_do_update_va_mapping(unsigned long va,
                                        l1_pgentry_t val,
diff -Nru a/xen/include/asm-x86/x86_32/domain_page.h 
b/xen/include/asm-x86/x86_32/domain_page.h
--- a/xen/include/asm-x86/x86_32/domain_page.h  2005-06-07 05:02:50 -04:00
+++ b/xen/include/asm-x86/x86_32/domain_page.h  2005-06-07 05:02:50 -04:00
@@ -27,31 +27,36 @@
  */
 extern void unmap_domain_mem(void *va);
 
-struct map_dom_mem_cache {
+#define DMCACHE_ENTRY_VALID 1UL
+#define DMCACHE_ENTRY_HELD  2UL
+
+struct domain_mmap_cache {
     unsigned long pa;
     void *va;
 };
 
 static inline void
-init_map_domain_mem_cache(struct map_dom_mem_cache *cache)
+domain_mmap_cache_init(struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
     cache->pa = 0;
 }
 
 static inline void *
-map_domain_mem_with_cache(unsigned long pa, struct map_dom_mem_cache *cache)
+map_domain_mem_with_cache(unsigned long pa, struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
+    BUG_ON(cache->pa & DMCACHE_ENTRY_HELD);
 
     if ( likely(cache->pa) )
     {
+        cache->pa |= DMCACHE_ENTRY_HELD;
         if ( likely((pa & PAGE_MASK) == (cache->pa & PAGE_MASK)) )
             goto done;
         unmap_domain_mem(cache->va);
     }
 
-    cache->pa = (pa & PAGE_MASK) | 1;
+    cache->pa = (pa & PAGE_MASK) | DMCACHE_ENTRY_HELD | DMCACHE_ENTRY_VALID;
     cache->va = map_domain_mem(cache->pa);
 
  done:
@@ -60,14 +65,14 @@
 }
 
 static inline void
-unmap_domain_mem_with_cache(void *va, struct map_dom_mem_cache *cache)
+unmap_domain_mem_with_cache(void *va, struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
-    unmap_domain_mem(va);
+    cache->pa &= ~DMCACHE_ENTRY_HELD;
 }
 
 static inline void
-destroy_map_domain_mem_cache(struct map_dom_mem_cache *cache)
+domain_mmap_cache_destroy(struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
     if ( likely(cache->pa) )
diff -Nru a/xen/include/asm-x86/x86_64/domain_page.h 
b/xen/include/asm-x86/x86_64/domain_page.h
--- a/xen/include/asm-x86/x86_64/domain_page.h  2005-06-07 05:02:50 -04:00
+++ b/xen/include/asm-x86/x86_64/domain_page.h  2005-06-07 05:02:50 -04:00
@@ -10,12 +10,12 @@
 #define map_domain_mem(_pa)   phys_to_virt(_pa)
 #define unmap_domain_mem(_va) ((void)(_va))
 
-struct map_dom_mem_cache { 
+struct domain_mmap_cache { 
 };
 
-#define init_map_domain_mem_cache(_c)      ((void)(_c))
+#define domain_mmap_cache_init(_c)         ((void)(_c))
 #define map_domain_mem_with_cache(_p,_c)   (map_domain_mem(_p))
 #define unmap_domain_mem_with_cache(_v,_c) ((void)(_v))
-#define destroy_map_domain_mem_cache(_c)   ((void)(_c))
+#define domain_mmap_cache_destroy(_c)      ((void)(_c))
 
 #endif /* __ASM_DOMAIN_PAGE_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.