Skip to content

Commit e2a7147

Browse files
cpwickmanH. Peter Anvin
authored andcommitted
x86: correct the conversion of EFI memory types
This patch causes all the EFI_RESERVED_TYPE memory reservations to be recorded in the e820 table as type E820_RESERVED. (This patch replaces one called 'x86: vendor reserved memory type'. This version has been discussed a bit with Peter and Yinghai but not given a final opinion.) Without this patch EFI_RESERVED_TYPE memory reservations may be marked usable in the e820 table. There may be a collision between kernel use and some reserver's use of this memory. (An example use of this functionality is the UV system, which will access extremely large areas of memory with a memory engine that allows a user to address beyond the processor's range. Such areas are reserved in the EFI table by the BIOS. Some loaders have a restricted number of entries possible in the e820 table, hence the need to record the reservations in the unrestricted EFI table.) The call to do_add_efi_memmap() is only made if "add_efi_memmap" is specified on the kernel command line. Signed-off-by: Cliff Wickman <cpw@sgi.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent 95ee14e commit e2a7147

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

arch/x86/kernel/efi.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,35 @@ static void __init do_add_efi_memmap(void)
240240
unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
241241
int e820_type;
242242

243-
if (md->attribute & EFI_MEMORY_WB)
244-
e820_type = E820_RAM;
245-
else
243+
switch (md->type) {
244+
case EFI_LOADER_CODE:
245+
case EFI_LOADER_DATA:
246+
case EFI_BOOT_SERVICES_CODE:
247+
case EFI_BOOT_SERVICES_DATA:
248+
case EFI_CONVENTIONAL_MEMORY:
249+
if (md->attribute & EFI_MEMORY_WB)
250+
e820_type = E820_RAM;
251+
else
252+
e820_type = E820_RESERVED;
253+
break;
254+
case EFI_ACPI_RECLAIM_MEMORY:
255+
e820_type = E820_ACPI;
256+
break;
257+
case EFI_ACPI_MEMORY_NVS:
258+
e820_type = E820_NVS;
259+
break;
260+
case EFI_UNUSABLE_MEMORY:
261+
e820_type = E820_UNUSABLE;
262+
break;
263+
default:
264+
/*
265+
* EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE
266+
* EFI_RUNTIME_SERVICES_DATA EFI_MEMORY_MAPPED_IO
267+
* EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE
268+
*/
246269
e820_type = E820_RESERVED;
270+
break;
271+
}
247272
e820_add_region(start, size, e820_type);
248273
}
249274
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);

0 commit comments

Comments
 (0)