NetBSD Problem Report #54391
From tsutsui@ceres.dti.ne.jp Sun Jul 21 02:28:24 2019
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 1631D7A17F
for <gnats-bugs@gnats.NetBSD.org>; Sun, 21 Jul 2019 02:28:24 +0000 (UTC)
Message-Id: <201907210228.x6L2SHwo000627@ceres.dti.ne.jp>
Date: Sun, 21 Jul 2019 11:28:17 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: EFI boot bootx64.efi doesn't account >4GB RAM
X-Send-Pr-Version: 3.95
>Number: 54391
>Category: port-amd64
>Synopsis: EFI boot bootx64.efi doesn't account >4GB RAM
>Confidential: no
>Severity: non-critical
>Priority: high
>Responsible: port-amd64-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 21 02:30:00 +0000 2019
>Closed-Date: Sat Nov 02 00:29:16 +0000 2019
>Last-Modified: Sat Nov 02 00:29:16 +0000 2019
>Originator: Izumi Tsutsui
>Release: NetBSD 8.1 and -current 8.99.51
>Organization:
>Environment:
System: NetBSD 8.1 and -current 8.99.51
Architecture: x86_64
Machine: amd64
>Description:
NetBSD/x86 EFI boot loader doesn't account RAM more than 4GB.
---
>> NetBSD/x86 EFI Boot (x64), Revision 1.0 (Wed Jul 17 07:07:59 UTC 2019) (from NetBSD 8.99.51)
>> Memory 352/3343476 k
---
Actually this machine has 8GB RAM (with traditional MBR boot from 8.0):
https://dmesgd.nycbug.org/index.cgi?do=view&id=4691
---
:
NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018
xxx@xxx.xxx:/usr/src/sys/arch/amd64/compile/GENERIC
total memory = 8098 MB
avail memory = 7840 MB
:
---
The same kernel booted from bootx64.efi says:
https://dmesgd.nycbug.org/index.cgi?do=view&id=5070
---
:
NetBSD 8.1 (GENERIC) #0: Fri May 31 08:43:59 UTC 2019
xxx@xxx.xxx:/usr/src/sys/arch/amd64/compile/GENERIC
total memory = 3265 MB
avail memory = 3146 MB
:
---
>How-To-Repeat:
Boot kernels on GPT and UEFI partition from bootx64.efi
on >4GB RAM machines.
>Fix:
getextmemx() function in src/sys/arch/i386/stand/efiboot/efimemory.c
has a comment "get memory size above 1MB below 4GB" and it seems
to skip RAMs at >4GB:
https://nxr.netbsd.org/xref/src/sys/arch/i386/stand/efiboot/efimemory.c?r=1.5#168
---
167 /*
168 * get memory size above 1MB below 4GB
169 */
170 int
171 getextmemx(void)
172 {
173 EFI_MEMORY_DESCRIPTOR *mdtop, *md, *next;
174 UINTN i, NoEntries, MapKey, DescriptorSize, MappingSize;
175 UINT32 DescriptorVersion;
176 EFI_PHYSICAL_ADDRESS extmem16m = 0; /* 0-16MB */
177 EFI_PHYSICAL_ADDRESS extmem4g = 0; /* 16MB-4GB */
178 EFI_PHYSICAL_ADDRESS pa, epa;
179 bool first16m = true, first4g = true;
180 int extmem;
181
182 mdtop = efi_memory_get_map(&NoEntries, &MapKey, &DescriptorSize,
183 &DescriptorVersion, true);
184
185 for (i = 0, md = mdtop; i < NoEntries; i++, md = next) {
186 next = NextMemoryDescriptor(md, DescriptorSize);
187 if (getmemtype(md) == BIM_Reserved)
188 continue;
189 if (md->PhysicalStart >= 4 * 1024 * 1024 * 1024ULL)
190 continue;
191
192 MappingSize = md->NumberOfPages * EFI_PAGE_SIZE;
193 epa = md->PhysicalStart + MappingSize;
194 if (epa == 0 || epa > 4 * 1024 * 1024 * 1024LL)
195 epa = 4 * 1024 * 1024 * 1024LL;
---
Maybe it's okay to simply remove the above >4GB checks, but
I'm not sure how the traditional MBR boot gets >4GM RAMs.
---
Izumi Tsutsui
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 02 Nov 2019 00:29:16 +0000
State-Changed-Why:
Already fixed by "Increase BOOTINFO_MAXSIZE to 16Kib" mentioned in PR/54147.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.