Skip to contentSkip to conversation

x86: fix frame table initialization when hotplug memory regions were detected

PATCH In review Jan Beulich 2 participants 2 messages Feb 3, 2010 – Feb 4, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix frame table initialization when hotplug memory regions were detected

max_idx is not a pdx, and hence needs to be converted to one in all cases where it is being passed to pdx_to_page().

Also, just like for max_pdx, the conversion result of max_idx may point into an address space hole, and hence it must not be used directly as an argument to pdx_to_page(). Note that this doesn't apply to the arguments passed to memset(), as the size argument would be zero in the case of hitting an address space hole.

xen/arch/x86/mm.c +5 -4
@@ -227,10 +227,11 @@ void __init init_frametable(void)
                               pdx_to_page(max_pdx - 1) + 1);
     else
     {
-        init_frametable_chunk(pdx_to_page(sidx *PDX_GROUP_COUNT),
-                              pdx_to_page(max_idx * PDX_GROUP_COUNT));
-        memset(pdx_to_page(max_pdx), -1, (unsigned long)pdx_to_page(max_idx) -
-                        (unsigned long)(pdx_to_page(max_pdx)));
+        init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT),
+                              pdx_to_page(max_idx * PDX_GROUP_COUNT - 1) + 1);
+        memset(pdx_to_page(max_pdx), -1,
+               (unsigned long)pdx_to_page(max_idx * PDX_GROUP_COUNT) -
+               (unsigned long)pdx_to_page(max_pdx));
     }
 }
 

max_idx is not a pdx, and hence needs to be converted to one in all cases where it is being passed to pdx_to_page().

Also, just like for max_pdx, the conversion result of max_idx may point into an address space hole, and hence it must not be used directly as an argument to pdx_to_page(). Note that this doesn't apply to the arguments passed to memset(), as the size argument would be zero in the case of hitting an address space hole.

xen/arch/x86/mm.c +5 -4
@@ -227,10 +227,11 @@ void __init init_frametable(void)
                               pdx_to_page(max_pdx - 1) + 1);
     else
     {
-        init_frametable_chunk(pdx_to_page(sidx *PDX_GROUP_COUNT),
-                              pdx_to_page(max_idx * PDX_GROUP_COUNT));
-        memset(pdx_to_page(max_pdx), -1, (unsigned long)pdx_to_page(max_idx) -
-                        (unsigned long)(pdx_to_page(max_pdx)));
+        init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT),
+                              pdx_to_page(max_idx * PDX_GROUP_COUNT - 1) + 1);
+        memset(pdx_to_page(max_pdx), -1,
+               (unsigned long)pdx_to_page(max_idx * PDX_GROUP_COUNT) -
+               (unsigned long)pdx_to_page(max_pdx));
     }
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Thanks for catch this!

--jyh

Quoted 42 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: Wednesday, February 03, 2010 9:12 PM
To: [email protected]
Subject: [Xen-devel] [PATCH] x86: fix frame table initialization when hotplug memory regions were detected

max_idx is not a pdx, and hence needs to be converted to one in all cases where it is being passed to pdx_to_page().

Also, just like for max_pdx, the conversion result of max_idx may point into an address space hole, and hence it must not be used directly as an argument to pdx_to_page(). Note that this doesn't apply to the arguments passed to memset(), as the size argument would be zero in the case of hitting an address space hole.

xen/arch/x86/mm.c +0 -3
@@ -227,10 +227,11 @@ void __init init_frametable(void)
                              pdx_to_page(max_pdx - 1) + 1);
    else
    {
-        init_frametable_chunk(pdx_to_page(sidx *PDX_GROUP_COUNT),
-                              pdx_to_page(max_idx *
 PDX_GROUP_COUNT));
-        memset(pdx_to_page(max_pdx), -1, (unsigned

long)pdx_to_page(max_idx) -

xen/arch/x86/mm.c +5 -2
-                        (unsigned long)(pdx_to_page(max_pdx)));
+        init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT),
+                              pdx_to_page(max_idx * PDX_GROUP_COUNT
- 1) + 1);
+        memset(pdx_to_page(max_pdx), -1,
+               (unsigned long)pdx_to_page(max_idx * PDX_GROUP_COUNT) -
+               (unsigned long)pdx_to_page(max_pdx));
    }

}