debuggers.hg
changeset 22892:52e928af3637
libxc: Do not use dom0 physmem as parameter to lzma decoder
It's not clear why a userspace lzma decode would want to use that
particular value, what bearing it has on anything or why it would
assume it could use 1/3 of the total RAM in the system (potentially
quite a large amount of RAM) as opposed to any other limit number.
Instead, hardcode 32Mby.
This reverts 22830:c80960244942, removes the xc_get_physmem/physmem
function entirely, and replaces the expression at the call site with a
fixed constant.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
It's not clear why a userspace lzma decode would want to use that
particular value, what bearing it has on anything or why it would
assume it could use 1/3 of the total RAM in the system (potentially
quite a large amount of RAM) as opposed to any other limit number.
Instead, hardcode 32Mby.
This reverts 22830:c80960244942, removes the xc_get_physmem/physmem
function entirely, and replaces the expression at the call site with a
fixed constant.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Ian Jackson <Ian.Jackson@eu.citrix.com> |
---|---|
date | Fri Jan 28 19:37:49 2011 +0000 (2011-01-28) |
parents | 88cf07fed7d2 |
children | e7b31cc0093c |
files | tools/libxc/xc_dom_bzimageloader.c tools/libxc/xc_linux.c tools/libxc/xc_netbsd.c tools/libxc/xc_private.h |
line diff
1.1 --- a/tools/libxc/xc_dom_bzimageloader.c Fri Jan 28 18:39:09 2011 +0000 1.2 +++ b/tools/libxc/xc_dom_bzimageloader.c Fri Jan 28 19:37:49 2011 +0000 1.3 @@ -152,7 +152,7 @@ static int xc_try_lzma_decode( 1.4 int outsize; 1.5 const char *msg; 1.6 1.7 - ret = lzma_alone_decoder(&stream, xc_get_physmem() / 3); 1.8 + ret = lzma_alone_decoder(&stream, 32*1024*1024); 1.9 if ( ret != LZMA_OK ) 1.10 { 1.11 DOMPRINTF("LZMA: Failed to init stream decoder");
2.1 --- a/tools/libxc/xc_linux.c Fri Jan 28 18:39:09 2011 +0000 2.2 +++ b/tools/libxc/xc_linux.c Fri Jan 28 19:37:49 2011 +0000 2.3 @@ -55,27 +55,6 @@ void discard_file_cache(xc_interface *xc 2.4 errno = saved_errno; 2.5 } 2.6 2.7 -uint64_t xc_get_physmem(void) 2.8 -{ 2.9 - uint64_t ret = 0; 2.10 - const long pagesize = sysconf(_SC_PAGESIZE); 2.11 - const long pages = sysconf(_SC_PHYS_PAGES); 2.12 - 2.13 - if ( (pagesize != -1) || (pages != -1) ) 2.14 - { 2.15 - /* 2.16 - * According to docs, pagesize * pages can overflow. 2.17 - * Simple case is 32-bit box with 4 GiB or more RAM, 2.18 - * which may report exactly 4 GiB of RAM, and "long" 2.19 - * being 32-bit will overflow. Casting to uint64_t 2.20 - * hopefully avoids overflows in the near future. 2.21 - */ 2.22 - ret = (uint64_t)(pagesize) * (uint64_t)(pages); 2.23 - } 2.24 - 2.25 - return ret; 2.26 -} 2.27 - 2.28 /* 2.29 * Local variables: 2.30 * mode: C
3.1 --- a/tools/libxc/xc_netbsd.c Fri Jan 28 18:39:09 2011 +0000 3.2 +++ b/tools/libxc/xc_netbsd.c Fri Jan 28 19:37:49 2011 +0000 3.3 @@ -23,9 +23,6 @@ 3.4 #include <xen/sys/evtchn.h> 3.5 #include <unistd.h> 3.6 #include <fcntl.h> 3.7 -#include <stdio.h> 3.8 -#include <errno.h> 3.9 -#include <sys/sysctl.h> 3.10 3.11 static xc_osdep_handle netbsd_privcmd_open(xc_interface *xch) 3.12 { 3.13 @@ -354,24 +351,6 @@ void discard_file_cache(xc_interface *xc 3.14 errno = saved_errno; 3.15 } 3.16 3.17 -uint64_t xc_get_physmem(void) 3.18 -{ 3.19 - int mib[2], rc; 3.20 - size_t len; 3.21 - uint64_t physmem; 3.22 - 3.23 - mib[0] = CTL_HW; 3.24 - mib[1] = HW_PHYSMEM64; 3.25 - rc = sysctl(mib, 2, &physmem, &len, NULL, 0); 3.26 - 3.27 - if (rc == -1) { 3.28 - /* PERROR("%s: Failed to get hw.physmem64: %s\n", strerror(errno)); */ 3.29 - return 0; 3.30 - } 3.31 - 3.32 - return physmem; 3.33 -} 3.34 - 3.35 static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_type type) 3.36 { 3.37 switch ( type )
4.1 --- a/tools/libxc/xc_private.h Fri Jan 28 18:39:09 2011 +0000 4.2 +++ b/tools/libxc/xc_private.h Fri Jan 28 19:37:49 2011 +0000 4.3 @@ -275,9 +275,6 @@ void bitmap_byte_to_64(uint64_t *lp, con 4.4 /* Optionally flush file to disk and discard page cache */ 4.5 void discard_file_cache(xc_interface *xch, int fd, int flush); 4.6 4.7 -/* How much physical RAM is available? */ 4.8 -uint64_t xc_get_physmem(void); 4.9 - 4.10 #define MAX_MMU_UPDATES 1024 4.11 struct xc_mmu { 4.12 mmu_update_t updates[MAX_MMU_UPDATES];