From: Joe Jin Subject: [PATCH]: hvmloader: Fixed get_memsize() overflow Date: Fri, 24 Jul 2009 10:55:40 +0800 Message-ID: <20090724025540.GB1675@joejin-pc.cn.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com, keir.fraser@citrix.com, joe.jin@oracle.com Cc: kurt.hackel@oracle.com, greg.marsden@oracle.com, deepak.patel@oracle.com, andrew.thomas@oracle.com List-Id: xen-devel@lists.xenproject.org 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. Signed-off-by: Joe Jin Cc: Keir Fraser smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- diff -r c0cb307d927f tools/firmware/hvmloader/smbios.c --- a/tools/firmware/hvmloader/smbios.c Mon Jul 13 12:35:34 2009 +0100 +++ b/tools/firmware/hvmloader/smbios.c Fri Jul 24 10:24:28 2009 +0800 @@ -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