All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]Add a flag for shadow pages
@ 2009-03-04  8:46 Jiang, Yunhong
  2009-03-04  9:06 ` Keir Fraser
  2009-03-04  9:20 ` Keir Fraser
  0 siblings, 2 replies; 15+ messages in thread
From: Jiang, Yunhong @ 2009-03-04  8:46 UTC (permalink / raw)
  To: Keir Fraser, Tim Deegan; +Cc: xen-devel@lists.xensource.com

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

Currently we don't know that a page is a shadow page unless we are in shadow handler. This cause error when we try to get the page owner for the shadow page, this snippet add a flag to it.

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

I'm not quite sure if the sh_put_ref() and sh_rm_write_access_from_sl1p() is try to checking a page is shadow page (I assume so), because when a anonymous page is allocated, the count_info is also 0 (like HVM's vlapic page), so I change it like this patch (checking PGC_count_mask is 0). Since comments in sh_hash_audit_bucket() has stated clearly it is to check if it is shdow, so I replace it with test_bit().

Also, do we need checking in page_get_owner() also?

Thanks
Yunhong Jiang

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

Add a special flag for shadow page

diff -r 02ea044972b7 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c	Wed Mar 04 02:12:22 2009 +0800
+++ b/xen/arch/x86/mm/shadow/common.c	Wed Mar 04 02:53:46 2009 +0800
@@ -1820,6 +1820,7 @@ static unsigned int sh_set_allocation(st
                 sp[j].u.sh.pinned = 0;
                 sp[j].u.sh.count = 0;
                 sp[j].tlbflush_timestamp = 0; /* Not in any TLB */
+                sp[j].count_info |= PGC_shadow;
             }
             sp->v.free.order = order;
             page_list_add_tail(sp, &d->arch.paging.shadow.freelists[order]);
@@ -1835,7 +1836,10 @@ static unsigned int sh_set_allocation(st
              * gets overwritten normally, so need to clear it here.
              */
             for ( j = 0; j < 1U << order; j++ )
+            {
                 page_set_owner(&((struct page_info *)sp)[j], NULL);
+                sp[j].count_info &= ~PGC_shadow;
+            }
             d->arch.paging.shadow.free_pages -= 1 << order;
             d->arch.paging.shadow.total_pages -= 1 << order;
             free_domheap_pages((struct page_info *)sp, order);
@@ -1895,7 +1899,7 @@ static void sh_hash_audit_bucket(struct 
     while ( sp )
     {
         /* Not a shadow? */
-        BUG_ON( sp->count_info != 0 );
+        BUG_ON( !test_bit(_PGC_shadow, &sp->count_info) );
         /* Bogus type? */
         BUG_ON( sp->u.sh.type == 0 );
         BUG_ON( sp->u.sh.type > SH_type_max_shadow );
diff -r 02ea044972b7 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c	Wed Mar 04 02:12:22 2009 +0800
+++ b/xen/arch/x86/mm/shadow/multi.c	Wed Mar 04 02:12:24 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_page_table | PGC_count_mask)) != 0)
          || (sp->u.sh.type != SH_type_l1_shadow
              && sp->u.sh.type != SH_type_fl1_shadow) )
         goto fail;
diff -r 02ea044972b7 xen/arch/x86/mm/shadow/private.h
--- a/xen/arch/x86/mm/shadow/private.h	Wed Mar 04 02:12:22 2009 +0800
+++ b/xen/arch/x86/mm/shadow/private.h	Wed Mar 04 02:12:24 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_page_table | PGC_count_mask) ) == 0);
 
     /* If this is the entry in the up-pointer, remove it */
     if ( entry_pa != 0 
diff -r 02ea044972b7 xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h	Wed Mar 04 02:12:22 2009 +0800
+++ b/xen/include/asm-x86/mm.h	Wed Mar 04 02:48:09 2009 +0800
@@ -59,7 +59,7 @@ struct page_info
             unsigned long type_info;
         } inuse;
 
-        /* Page is in use as a shadow: count_info == 0. */
+        /* Page is in use as a shadow: count_info should be PGC_shadow. */
         struct {
             unsigned long type:5;   /* What kind of shadow is this? */
             unsigned long pinned:1; /* Is the shadow pinned? */
@@ -198,8 +198,12 @@ struct page_info
  /* 3-bit PAT/PCD/PWT cache-attribute hint. */
 #define PGC_cacheattr_base PG_shift(6)
 #define PGC_cacheattr_mask PG_mask(7, 6)
+/* 1-bit flag for shadow page */
+#define _PGC_shadow        PG_shift(7)
+#define PGC_shadow         PG_mask(1, 7)
+
  /* Count of references to this frame. */
-#define PGC_count_width   PG_shift(6)
+#define PGC_count_width   PG_shift(7)
 #define PGC_count_mask    ((1UL<<PGC_count_width)-1)
 
 #if defined(__i386__)

[-- 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] 15+ messages in thread

end of thread, other threads:[~2009-03-05  2:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-04  8:46 [PATCH]Add a flag for shadow pages Jiang, Yunhong
2009-03-04  9:06 ` Keir Fraser
2009-03-04  9:17   ` Jiang, Yunhong
2009-03-04  9:22     ` Keir Fraser
2009-03-04  9:28       ` Jiang, Yunhong
2009-03-04  9:56         ` Keir Fraser
2009-03-04 11:57           ` Keir Fraser
2009-03-04 12:13             ` Tim Deegan
2009-03-04 13:19               ` Keir Fraser
2009-03-04 14:30             ` Keir Fraser
2009-03-04 16:01               ` Jiang, Yunhong
2009-03-04 16:32                 ` Gianluca Guida
2009-03-05  2:41                   ` Jiang, Yunhong
2009-03-04 16:45                 ` Keir Fraser
2009-03-04  9:20 ` Keir Fraser

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.