Date: Fri, 14 Aug 2009 12:34:54 -0400 From: Jung-uk Kim <jkim@FreeBSD.org> To: freebsd-amd64@FreeBSD.org Cc: "Bjoern A. Zeeb" <bz@FreeBSD.org>, rnoland@FreeBSD.org Subject: Re: 8.0-BETA2 not getting my 4Gigs of ram Message-ID: <200908141234.56644.jkim@FreeBSD.org> In-Reply-To: <200908141101.25676.jkim@FreeBSD.org> References: <4A83F9DE.3020406@mapper.nl> <20090814093104.GG1884@deviant.kiev.zoral.com.ua> <200908141101.25676.jkim@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_wIZhKvL3mP8HvDW Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Friday 14 August 2009 11:01 am, Jung-uk Kim wrote: > On Friday 14 August 2009 05:31 am, Kostik Belousov wrote: > > I do agree that the printout is very confusing, and I suspect > > that our smbios parser has a bug. Contact jkim@, who is the > > author of r190599, that introduced this behaviour. > > So far I got few similar reports but all issues were BIOS bugs, not > my code. Except for one ancient board, there were BIOS updates to > fix the problem. Please try the attached patch. I added minimal sanity check. If it is less than realmem, we just fall back to the old way for *i386*. FYI, amd64 and i386 used to display different numbers before r190599. Since this type of BIOS bug is rare, it should be reasonable compromise, IMHO. Jung-uk Kim --Boundary-00=_wIZhKvL3mP8HvDW Content-Type: text/plain; charset="iso-8859-1"; name="physmem.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="physmem.diff" --- sys/amd64/amd64/machdep.c +++ sys/amd64/amd64/machdep.c @@ -235,19 +235,21 @@ cpu_startup(dummy) #ifdef PERFMON perfmon_init(); #endif + realmem = Maxmem; + + /* + * Display physical memory if SMBIOS reports reasonable amount. + */ + memsize = 0; sysenv = getenv("smbios.memory.enabled"); if (sysenv != NULL) { - memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10); + memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10; freeenv(sysenv); - } else - memsize = 0; - if (memsize > 0) - printf("real memory = %ju (%ju MB)\n", memsize << 10, - memsize >> 10); - else - printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem), - ptoa((uintmax_t)Maxmem) / 1048576); - realmem = Maxmem; + } + if (memsize < realmem) + memsize = ptoa((uintmax_t)Maxmem); + printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20); + /* * Display any holes after the first chunk of extended memory. */ --- sys/i386/i386/machdep.c +++ sys/i386/i386/machdep.c @@ -279,19 +279,21 @@ cpu_startup(dummy) #ifdef PERFMON perfmon_init(); #endif + realmem = Maxmem; + + /* + * Display physical memory if SMBIOS reports reasonable amount. + */ + memsize = 0; sysenv = getenv("smbios.memory.enabled"); if (sysenv != NULL) { - memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10); + memsize = (uintmax_t)strtoul(sysenv, (char **)NULL, 10) << 10; freeenv(sysenv); - } else - memsize = 0; - if (memsize > 0) - printf("real memory = %ju (%ju MB)\n", memsize << 10, - memsize >> 10); - else - printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)Maxmem), - ptoa((uintmax_t)Maxmem) / 1048576); - realmem = Maxmem; + } + if (memsize < realmem) + memsize = ptoa((uintmax_t)Maxmem); + printf("real memory = %ju (%ju MB)\n", memsize, memsize >> 20); + /* * Display any holes after the first chunk of extended memory. */ --Boundary-00=_wIZhKvL3mP8HvDW--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908141234.56644.jkim>