Skip to contentSkip to conversation

: hvmloader: Fixed get_memsize() overflow

PATCH New Joe Jin 1 participant 1 message Jul 24, 2009

lore
Share & tools
lore

Joe Jin

author
#0 lore raw

PATCH 1/1 : hvmloader: Fixed get_memsize() overflow

Hi,

When hvmloader calculate memory via get_memsize(), we have to cast hvm_info->high_mem_pgend to uint64_t, or may overflow and made hvm guest bootup failed.

How to reproduce:
Set memory size more than 3840M and the value a little less than multi 1024M like 4095, 4094, 8024 and so on, boot hvm will failed.

Cc Keir Fraser <[email protected]>
 smbios.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

tools/firmware/hvmloader/smbios.c +1 -1
diff -r c0cb307d927f tools/firmware/hvmloader/smbios.c
@@ -148,7 +148,7 @@
 
     sz = (uint64_t)hvm_info->low_mem_pgend << PAGE_SHIFT;
     if ( hvm_info->high_mem_pgend )
-        sz += (hvm_info->high_mem_pgend << PAGE_SHIFT) - (1ull << 32);
+        sz += ((uint64_t)hvm_info->high_mem_pgend << PAGE_SHIFT) - (1ull << 32);
 
     /*
      * Round up to the nearest MB.  The user specifies domU pseudo-physical