pmm: Do not reclaim EfiLoader sections as usable

This commit is contained in:
mintsuki 2021-06-15 03:10:59 +02:00
parent eb83d013ca
commit 7bf53f1406
3 changed files with 4 additions and 9 deletions

View File

@ -15,7 +15,6 @@
#define MEMMAP_KERNEL_AND_MODULES 0x1001
#define MEMMAP_FRAMEBUFFER 0x1002
#define MEMMAP_EFI_RECLAIMABLE 0x2000
#define MEMMAP_EFI_LOADER 0x2001
extern struct e820_entry_t memmap[];
extern size_t memmap_entries;

View File

@ -69,8 +69,6 @@ static const char *memmap_type(uint32_t type) {
return "Kernel/Modules";
case MEMMAP_EFI_RECLAIMABLE:
return "EFI reclaimable";
case MEMMAP_EFI_LOADER:
return "EFI loader";
default:
return "???";
}
@ -275,14 +273,13 @@ void init_memmap(void) {
case EfiMemoryMappedIO:
case EfiMemoryMappedIOPortSpace:
case EfiPalCode:
case EfiLoaderCode:
case EfiLoaderData:
default:
our_type = MEMMAP_RESERVED; break;
case EfiBootServicesCode:
case EfiBootServicesData:
our_type = MEMMAP_EFI_RECLAIMABLE; break;
case EfiLoaderCode:
case EfiLoaderData:
our_type = MEMMAP_EFI_LOADER; break;
case EfiACPIReclaimMemory:
our_type = MEMMAP_ACPI_RECLAIMABLE; break;
case EfiACPIMemoryNVS:
@ -331,8 +328,7 @@ void init_memmap(void) {
void pmm_reclaim_uefi_mem(void) {
for (size_t i = 0; i < memmap_entries; i++) {
if (memmap[i].type != MEMMAP_EFI_RECLAIMABLE
&& memmap[i].type != MEMMAP_EFI_LOADER)
if (memmap[i].type != MEMMAP_EFI_RECLAIMABLE)
continue;
memmap[i].type = MEMMAP_USABLE;

View File

@ -119,7 +119,7 @@ void chainload(char *config) {
if (!uri_open(image, image_path))
panic("chainload: Could not open image");
void *ptr = freadall(image, MEMMAP_EFI_LOADER);
void *ptr = freadall(image, MEMMAP_RESERVED);
size_t image_size = image->size;
term_deinit();