WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Fix possible variable overflow in NUMA code

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Fix possible variable overflow in NUMA code
From: "Yang, Xiaowei" <xiaowei.yang@xxxxxxxxx>
Date: Thu, 23 Apr 2009 17:58:30 +0800
Delivery-date: Thu, 23 Apr 2009 02:59:26 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.21 (X11/20090409)
On PAE system, when "<<" operation is used on type "long" to get a 64-bit value, the result could be overflowed.

Signed-off-by: Yang Xiaowei <xiaowei.yang@xxxxxxxxx>

Thanks,
xiaowei


diff -r dd91d71d4eca xen/arch/x86/numa.c
--- a/xen/arch/x86/numa.c       Tue Apr 21 17:03:23 2009 +0800
+++ b/xen/arch/x86/numa.c       Thu Apr 23 13:57:17 2009 +0800
@@ -74,7 +74,7 @@ populate_memnodemap(const struct node *n
                        if (memnodemap[addr >> shift] != 0xff)
                                return -1;
                        memnodemap[addr >> shift] = i;
-                       addr += (1UL << shift);
+                       addr += (1ULL << shift);
                } while (addr < end);
                res = 1;
        }
@@ -290,7 +290,7 @@ static void dump_numa(unsigned char key)
                  (u32)(now>>32), (u32)now);

        for_each_online_node(i) {
-               paddr_t pa = (NODE_DATA(i)->node_start_pfn + 1)<< PAGE_SHIFT;
+               paddr_t pa = (paddr_t)(NODE_DATA(i)->node_start_pfn + 1) << 
PAGE_SHIFT;
                printk("idx%d -> NODE%d start->%lu size->%lu\n",
                          i, NODE_DATA(i)->node_id,
                          NODE_DATA(i)->node_start_pfn,
@@ -314,7 +314,7 @@ static void dump_numa(unsigned char key)

                page_list_for_each(page, &d->page_list)
                {
-                       i = phys_to_nid(page_to_mfn(page) << PAGE_SHIFT);
+                       i = phys_to_nid((paddr_t)page_to_mfn(page) << 
PAGE_SHIFT);
                        page_num_node[i]++;
                }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Fix possible variable overflow in NUMA code, Yang, Xiaowei <=