From 402b94c8fbbe1568c7672a882990ca015cf2a0ca Mon Sep 17 00:00:00 2001 From: Gary Hade <garyhade@us.ibm.com> Date: Tue, 8 Jul 2003 02:46:09 -0700 Subject: [PATCH] [PATCH] ia64: fix for sys32_sysinfo bug --- arch/ia64/ia32/sys_ia32.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c index a6bf41261322..d778e4d6cc7c 100644 --- a/arch/ia64/ia32/sys_ia32.c +++ b/arch/ia64/ia32/sys_ia32.c @@ -2547,13 +2547,31 @@ asmlinkage long sys32_sysinfo (struct sysinfo32 *info) { extern asmlinkage long sys_sysinfo (struct sysinfo *); - mm_segment_t old_fs = get_fs(); struct sysinfo s; long ret, err; + int bitcount = 0; + mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); ret = sys_sysinfo(&s); set_fs(old_fs); + /* Check to see if any memory value is too large for 32-bit and + * scale down if needed. + */ + if ((s.totalram >> 32) || (s.totalswap >> 32)) { + while (s.mem_unit < PAGE_SIZE) { + s.mem_unit <<= 1; + bitcount++; + } + s.totalram >>= bitcount; + s.freeram >>= bitcount; + s.sharedram >>= bitcount; + s.bufferram >>= bitcount; + s.totalswap >>= bitcount; + s.freeswap >>= bitcount; + s.totalhigh >>= bitcount; + s.freehigh >>= bitcount; + } if (!access_ok(VERIFY_WRITE, info, sizeof(*info))) return -EFAULT; -- 2.30.9