From owner-freebsd-amd64@FreeBSD.ORG Fri Aug 14 16:35:05 2009 Return-Path: Delivered-To: freebsd-amd64@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 8D28E106564A; Fri, 14 Aug 2009 16:35:04 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-amd64@FreeBSD.org Date: Fri, 14 Aug 2009 12:34:54 -0400 User-Agent: KMail/1.6.2 References: <4A83F9DE.3020406@mapper.nl> <20090814093104.GG1884@deviant.kiev.zoral.com.ua> <200908141101.25676.jkim@FreeBSD.org> In-Reply-To: <200908141101.25676.jkim@FreeBSD.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_wIZhKvL3mP8HvDW" Message-Id: <200908141234.56644.jkim@FreeBSD.org> Cc: "Bjoern A. Zeeb" , rnoland@FreeBSD.org Subject: Re: 8.0-BETA2 not getting my 4Gigs of ram X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Aug 2009 16:35:05 -0000 --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--