From owner-freebsd-current@FreeBSD.ORG Wed Aug 26 21:10:39 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FF571065693 for ; Wed, 26 Aug 2009 21:10:39 +0000 (UTC) (envelope-from james-freebsd-current@jrv.org) Received: from mail.jrv.org (adsl-70-243-84-13.dsl.austtx.swbell.net [70.243.84.13]) by mx1.freebsd.org (Postfix) with ESMTP id C70D58FC14 for ; Wed, 26 Aug 2009 21:10:38 +0000 (UTC) Received: from kremvax.housenet.jrv (kremvax.housenet.jrv [192.168.3.124]) by mail.jrv.org (8.14.3/8.14.3) with ESMTP id n7QLAbwx043439 for ; Wed, 26 Aug 2009 16:10:37 -0500 (CDT) (envelope-from james-freebsd-current@jrv.org) Authentication-Results: mail.jrv.org; domainkeys=pass (testing) header.from=james-freebsd-current@jrv.org DomainKey-Signature: a=rsa-sha1; s=enigma; d=jrv.org; c=nofws; q=dns; h=message-id:date:from:user-agent:mime-version:to:subject:content-type; b=jBL5apdKL+E82aW6pBscGFtoBffme3UcTZ6P7cHNtt/saT0JayG2LlUU5chDgsXBV M3dKp/hNtQoXVYvM0cXcxqnNVAzLeeFSRBEMQMede3QlpKHkg+Rwr7HlZ2Cm63Dn+da 6XYyxYb1Qoj/zAwh4XQ/I3MLUw4fvoXiKp76FS0= Message-ID: <4A95A4CD.1020600@jrv.org> Date: Wed, 26 Aug 2009 16:10:37 -0500 From: "James R. Van Artsdalen" User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: FreeBSD Current Content-Type: multipart/mixed; boundary="------------010108050102020003040005" Subject: [patch] FreeBSD/amd64 can't see all system memory X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 21:10:39 -0000 This is a multi-part message in MIME format. --------------010108050102020003040005 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit This fixes two bugs on amd64 only: 1. FreeBSD erroneously assumes that the BIOS E820 system memory map data is non-descending. The Zotac GF9300-D-E is an example of a system where this is not true. 2. There is a typo in code that detects overlaps in regions reported by E820. No action is in fact taken right now on amd64. i386 may have bug #1 but not #2. With this patch "available memory" goes from 2689 MB to 7605 MB on the Zotac GF9300-D-E. --------------010108050102020003040005 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="smap.pat" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="smap.pat" Index: sys/amd64/amd64/machdep.c =================================================================== --- sys/amd64/amd64/machdep.c (revision 196500) +++ sys/amd64/amd64/machdep.c (working copy) @@ -1236,6 +1236,19 @@ smapend = (struct bios_smap *)((uintptr_t)smapbase + smapsize); for (smap = smapbase; smap < smapend; smap++) { + struct bios_smap *sp, *low = smap; + + for (sp = smap + 1; sp < smapend; sp++) + if (low->base > sp->base) + low = sp; + if (low != smap) { + struct bios_smap ts; + + ts = *smap; + *smap = *low; + *low = ts; + } + if (boothowto & RB_VERBOSE) printf("SMAP type=%02x base=%016lx len=%016lx\n", smap->type, smap->base, smap->length); @@ -1250,10 +1263,12 @@ if (smap->base < physmap[i + 1]) { if (boothowto & RB_VERBOSE) printf( - "Overlapping or non-monotonic memory region, ignoring second region\n"); - continue; + "Overlapping memory region, ignoring second region\n"); + break; } } + if (i <= physmap_idx) + continue; if (smap->base == physmap[physmap_idx + 1]) { physmap[physmap_idx + 1] += smap->length; --------------010108050102020003040005--