]> xenbits.xensource.com Git - xen.git/commitdiff
x86/shadow: fix refcount overflow check
authorJan Beulich <jbeulich@suse.com>
Tue, 12 Dec 2017 14:08:13 +0000 (15:08 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Dec 2017 14:08:13 +0000 (15:08 +0100)
Commit c385d27079 ("x86 shadow: for multi-page shadows, explicitly track
the first page") reduced the refcount width to 25, without adjusting the
overflow check. Eliminate the disconnect by using a manifest constant.

Interestingly, up to commit 047782fa01 ("Out-of-sync L1 shadows: OOS
snapshot") the refcount was 27 bits wide, yet the check was already
using 26.

This is XSA-249.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
master commit: 54e2292e8df7a1a7b041192be9d6d797b6d00869
master date: 2017-12-12 14:29:13 +0100

xen/arch/x86/mm/shadow/private.h
xen/include/asm-x86/mm.h

index 2d146cf5786653b87bda7dbe0906a322d12eacb4..ee12569bfdf6c24781ff367f2ccea848d753f3fc 100644 (file)
@@ -523,7 +523,7 @@ static inline int sh_get_ref(struct domain *d, mfn_t smfn, paddr_t entry_pa)
     x = sp->u.sh.count;
     nx = x + 1;
 
-    if ( unlikely(nx >= 1U<<26) )
+    if ( unlikely(nx >= (1U << PAGE_SH_REFCOUNT_WIDTH)) )
     {
         SHADOW_PRINTK("shadow ref overflow, gmfn=%lx smfn=%lx\n",
                        __backpointer(sp), mfn_x(smfn));
index 4191e1311253fc1fb02d49660ecdd5e25be91ddf..a381626e123bc25602cc780aeb2060906aa56475 100644 (file)
@@ -82,7 +82,8 @@ struct page_info
             unsigned long type:5;   /* What kind of shadow is this? */
             unsigned long pinned:1; /* Is the shadow pinned? */
             unsigned long head:1;   /* Is this the first page of the shadow? */
-            unsigned long count:25; /* Reference count */
+#define PAGE_SH_REFCOUNT_WIDTH 25
+            unsigned long count:PAGE_SH_REFCOUNT_WIDTH; /* Reference count */
         } sh;
 
         /* Page is on a free list: ((count_info & PGC_count_mask) == 0). */