Skip to contentSkip to conversation

libxc: Make conversion from page count to bytes 32-bit safe

PATCH In review Boris Ostrovsky 2 participants 2 messages Mar 26, 2015 – Mar 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxc: Make conversion from page count to bytes 32-bit safe

Commit ba59e2ce935d ("libxc: allocate memory with vNUMA information for PV guest") creates default vNUMA layout with a single range containing all memory. The end of the range is calculated by shifting dom->total_pages by 12 to the left.

On 32-bit dom0 this may result in losing upper bits since total_pages is a 32-bit type.

---
 tools/libxc/xc_dom_x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxc/xc_dom_x86.c +1 -1
index 3301f53..783f749 100644
@@ -829,7 +829,7 @@ int arch_setup_meminit(struct xc_dom_image *dom)
             dom->nr_vmemranges = 1;
             dom->vmemranges = xc_dom_malloc(dom, sizeof(*dom->vmemranges));
             dom->vmemranges[0].start = 0;
-            dom->vmemranges[0].end   = dom->total_pages << PAGE_SHIFT;
+            dom->vmemranges[0].end   = (uint64_t)dom->total_pages << PAGE_SHIFT;
             dom->vmemranges[0].flags = 0;
             dom->vmemranges[0].nid   = 0;
 
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 9 lines · Boris Ostrovsky

Commit ba59e2ce935d ("libxc: allocate memory with vNUMA information for PV guest") creates default vNUMA layout with a single range containing all memory. The end of the range is calculated by shifting dom->total_pages by 12 to the left.

On 32-bit dom0 this may result in losing upper bits since total_pages is a 32-bit type.

Acked + applied, thanks.