NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-amd64/54391: EFI boot bootx64.efi doesn't account >4GB RAM



>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:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 21 02:30:00 +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@localhost:/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@localhost:/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



Home | Main Index | Thread Index | Old Index