dont modify the bootloader's pagetables #465
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Don't modify the bootloader's page tables.
Previously we assumed that the page tables set up by UEFI would only contain relevant mappings in the first PML4 entry, but it turns out that some implementations map the frame buffer into address space ranges mapped by later PML4 entries. As a result, we can no longer just remove all but the first PML4 entry. The problem is that because we've assumed that only the first PML4 entry is used, we've been mapping memory into the address ranges covered by other PML4 entries, but that may no longer work if UEFI already happened to have mapped some memory there.
Fortunately, there's only a single location where we've been mapping memory into the bootloader page tables: We mapped the boot info and memory map into both the bootloader and kernel address spaces so that we can simply create references to them and pass them directly from the bootloader to the kernel. Instead, we now only map memory into the bootloader's address space. When we need to access the memory from the bootloader, we traverse the kernel's page tables to look up the physical address and use the identify mappings to access the physical memory. This is mostly consistent with how we access the kernel's memory in other places.
@Colepng Could you please test that this resolves the issue on your system?
Supersedes #464
Closes #462