Wed Oct 31 12:59:43 2018 UTC ()
When building /memory, skip EFI runtime memory ranges


(jmcneill)
diff -r1.10 -r1.11 src/sys/stand/efiboot/efifdt.c

cvs diff -r1.10 -r1.11 src/sys/stand/efiboot/efifdt.c (expand / switch to unified diff)

--- src/sys/stand/efiboot/efifdt.c 2018/10/31 09:13:32 1.10
+++ src/sys/stand/efiboot/efifdt.c 2018/10/31 12:59:43 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: efifdt.c,v 1.10 2018/10/31 09:13:32 jmcneill Exp $ */ 1/* $NetBSD: efifdt.c,v 1.11 2018/10/31 12:59:43 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -148,26 +148,28 @@ efi_fdt_memory_map(void) @@ -148,26 +148,28 @@ efi_fdt_memory_map(void)
148 fdt_delprop(fdt_data, memory, "reg"); 148 fdt_delprop(fdt_data, memory, "reg");
149 149
150 const int address_cells = fdt_address_cells(fdt_data, fdt_path_offset(fdt_data, "/")); 150 const int address_cells = fdt_address_cells(fdt_data, fdt_path_offset(fdt_data, "/"));
151 const int size_cells = fdt_size_cells(fdt_data, fdt_path_offset(fdt_data, "/")); 151 const int size_cells = fdt_size_cells(fdt_data, fdt_path_offset(fdt_data, "/"));
152 152
153 memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver); 153 memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver);
154 for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) { 154 for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
155#ifdef EFI_MEMORY_DEBUG 155#ifdef EFI_MEMORY_DEBUG
156 printf("MEM: %u: Type 0x%x Attr 0x%lx Phys 0x%lx Virt 0x%lx Size 0x%lx\n", 156 printf("MEM: %u: Type 0x%x Attr 0x%lx Phys 0x%lx Virt 0x%lx Size 0x%lx\n",
157 n, md->Type, md->Attribute, 157 n, md->Type, md->Attribute,
158 md->PhysicalStart, md->VirtualStart, 158 md->PhysicalStart, md->VirtualStart,
159 (u_long)md->NumberOfPages * EFI_PAGE_SIZE); 159 (u_long)md->NumberOfPages * EFI_PAGE_SIZE);
160#endif 160#endif
 161 if ((md->Attribute & EFI_MEMORY_RUNTIME) != 0)
 162 continue;
161 if ((md->Attribute & EFI_MEMORY_WB) == 0) 163 if ((md->Attribute & EFI_MEMORY_WB) == 0)
162 continue; 164 continue;
163 if (!FDT_MEMORY_USABLE(md)) 165 if (!FDT_MEMORY_USABLE(md))
164 continue; 166 continue;
165 if ((address_cells == 1 || size_cells == 1) && md->PhysicalStart + (md->NumberOfPages * EFI_PAGE_SIZE) > 0xffffffff) 167 if ((address_cells == 1 || size_cells == 1) && md->PhysicalStart + (md->NumberOfPages * EFI_PAGE_SIZE) > 0xffffffff)
166 continue; 168 continue;
167 if (md->NumberOfPages <= 1) 169 if (md->NumberOfPages <= 1)
168 continue; 170 continue;
169 171
170 phys_start = md->PhysicalStart; 172 phys_start = md->PhysicalStart;
171 phys_size = md->NumberOfPages * EFI_PAGE_SIZE; 173 phys_size = md->NumberOfPages * EFI_PAGE_SIZE;
172 174
173 if (phys_start & EFI_PAGE_MASK) { 175 if (phys_start & EFI_PAGE_MASK) {