All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Do not set page's count_info directly
@ 2009-03-05  9:11 Jiang, Yunhong
  2009-03-05 12:32 ` Gianluca Guida
  0 siblings, 1 reply; 13+ messages in thread
From: Jiang, Yunhong @ 2009-03-05  9:11 UTC (permalink / raw)
  To: Keir Fraser, Tim Deegan, xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

Page offline patch add several flag to page_info->count_info. However, currently some code will try to set count_info after alloc_domheap_pages without using "&" or "|" operation, this may cause the new flags lost, since there are no protection. This patch try to make sure all write to count_info will only impact specific field.

Also currently shadow code assume count_info is 0 for shadow page, however, this is invalid after the new flags. Change some assert in shadow code.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>

Thanks
Yunhong Jiang

[-- Attachment #2: clear_count_info.patch --]
[-- Type: application/octet-stream, Size: 4460 bytes --]

clean the count_info usage to make sure it will not overwrite offling information

diff -r 2c256b324e86 xen/arch/x86/mm/hap/hap.c
--- a/xen/arch/x86/mm/hap/hap.c	Thu Mar 05 02:21:47 2009 +0800
+++ b/xen/arch/x86/mm/hap/hap.c	Thu Mar 05 02:36:04 2009 +0800
@@ -152,7 +152,7 @@ static struct page_info *hap_alloc_p2m_p
         d->arch.paging.hap.total_pages--;
         d->arch.paging.hap.p2m_pages++;
         page_set_owner(pg, d);
-        pg->count_info = 1;
+        pg->count_info |= 1;
     }
 
     hap_unlock(d);
@@ -167,7 +167,7 @@ void hap_free_p2m_page(struct domain *d,
     if ( (pg->count_info & PGC_count_mask) != 1 )
         HAP_ERROR("Odd p2m page count c=%#lx t=%"PRtype_info"\n",
                   pg->count_info, pg->u.inuse.type_info);
-    pg->count_info = 0;
+    pg->count_info &= ~PGC_count_mask;
     /* Free should not decrement domain's total allocation, since
      * these pages were allocated without an owner. */
     page_set_owner(pg, NULL);
@@ -218,7 +218,6 @@ hap_set_allocation(struct domain *d, uns
             ASSERT(pg);
             d->arch.paging.hap.free_pages--;
             d->arch.paging.hap.total_pages--;
-            pg->count_info = 0;
             free_domheap_page(pg);
         }
 
diff -r 2c256b324e86 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c	Thu Mar 05 02:21:47 2009 +0800
+++ b/xen/arch/x86/mm/p2m.c	Thu Mar 05 02:36:04 2009 +0800
@@ -177,7 +177,7 @@ p2m_next_level(struct domain *d, mfn_t *
             return 0;
         page_list_add_tail(pg, &d->arch.p2m->pages);
         pg->u.inuse.type_info = type | 1 | PGT_validated;
-        pg->count_info = 1;
+        pg->count_info |= 1;
 
         new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)),
                                  __PAGE_HYPERVISOR|_PAGE_USER);
@@ -216,7 +216,7 @@ p2m_next_level(struct domain *d, mfn_t *
             return 0;
         page_list_add_tail(pg, &d->arch.p2m->pages);
         pg->u.inuse.type_info = PGT_l1_page_table | 1 | PGT_validated;
-        pg->count_info = 1;
+        pg->count_info |= 1;
         
         /* New splintered mappings inherit the flags of the old superpage, 
          * with a little reorganisation for the _PAGE_PSE_PAT bit. */
diff -r 2c256b324e86 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c	Thu Mar 05 02:21:47 2009 +0800
+++ b/xen/arch/x86/mm/shadow/common.c	Thu Mar 05 03:25:15 2009 +0800
@@ -1677,7 +1677,7 @@ sh_alloc_p2m_pages(struct domain *d)
          * believed to be a concern.
          */
         page_set_owner(&pg[i], d);
-        pg[i].count_info = 1;
+        pg[i].count_info |= 1;
         page_list_add_tail(&pg[i], &d->arch.paging.shadow.p2m_freelist);
     }
     return 1;
@@ -1721,7 +1721,7 @@ shadow_free_p2m_page(struct domain *d, s
         SHADOW_ERROR("Odd p2m page count c=%#lx t=%"PRtype_info"\n",
                      pg->count_info, pg->u.inuse.type_info);
     }
-    pg->count_info = 0;
+    pg->count_info &= ~PGC_count_mask;
     /* Free should not decrement domain's total allocation, since 
      * these pages were allocated without an owner. */
     page_set_owner(pg, NULL); 
@@ -1895,7 +1895,7 @@ static void sh_hash_audit_bucket(struct 
     while ( sp )
     {
         /* Not a shadow? */
-        BUG_ON( sp->count_info != 0 );
+        BUG_ON( (sp->count_info & PGC_count_mask )!= 0 ) ;
         /* Bogus type? */
         BUG_ON( sp->u.sh.type == 0 );
         BUG_ON( sp->u.sh.type > SH_type_max_shadow );
diff -r 2c256b324e86 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c	Thu Mar 05 02:21:47 2009 +0800
+++ b/xen/arch/x86/mm/shadow/multi.c	Thu Mar 05 02:56:00 2009 +0800
@@ -4281,7 +4281,7 @@ int sh_rm_write_access_from_sl1p(struct 
 
     sp = mfn_to_page(smfn);
 
-    if ( sp->count_info != 0
+    if ( ((sp->count_info & PGC_count_mask) != 0)
          || (sp->u.sh.type != SH_type_l1_shadow
              && sp->u.sh.type != SH_type_fl1_shadow) )
         goto fail;
diff -r 2c256b324e86 xen/arch/x86/mm/shadow/private.h
--- a/xen/arch/x86/mm/shadow/private.h	Thu Mar 05 02:21:47 2009 +0800
+++ b/xen/arch/x86/mm/shadow/private.h	Thu Mar 05 02:58:08 2009 +0800
@@ -647,7 +647,7 @@ static inline void sh_put_ref(struct vcp
     struct page_info *sp = mfn_to_page(smfn);
 
     ASSERT(mfn_valid(smfn));
-    ASSERT(sp->count_info == 0);
+    ASSERT(!(sp->count_info & PGC_count_mask));
 
     /* If this is the entry in the up-pointer, remove it */
     if ( entry_pa != 0 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-03-06  3:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-05  9:11 [PATCH] Do not set page's count_info directly Jiang, Yunhong
2009-03-05 12:32 ` Gianluca Guida
2009-03-05 12:38   ` Tim Deegan
2009-03-05 12:45     ` Gianluca Guida
2009-03-05 13:20       ` Keir Fraser
2009-03-05 14:34         ` Jiang, Yunhong
2009-03-05 15:21           ` Gianluca Guida
2009-03-06  3:14             ` Jiang, Yunhong
2009-03-05 12:45   ` Keir Fraser
2009-03-05 14:33     ` Jiang, Yunhong
2009-03-05 14:50       ` Keir Fraser
2009-03-05 15:07         ` Jiang, Yunhong
2009-03-05 14:45   ` Jiang, Yunhong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.