[metal] Allow more fine-grained control over page permissions (#663)

- use PAGE_RSRV bit (originally only for blinkenlights),
  rather than PAGE_V bit, to indicate that a virtual address
  page has been reserved — this should allow a program to
  create & reserve inaccessible "guard pages"
- mark page table entries for non-code pages with PAGE_XD bit,
  which should be supported on (circa) post-2004 x86-64 CPUs
This commit is contained in:
tkchia 2022-10-13 02:07:11 +08:00 committed by GitHub
parent 0f89140882
commit d38700687a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 14 deletions

View file

@ -126,7 +126,7 @@ __msabi noasan EFI_STATUS EfiMain(EFI_HANDLE ImageHandle,
pdpt2 = (uint64_t *)0x7c000;
pml4t = (uint64_t *)0x7e000;
for (i = 0; i < 512; ++i) {
pd[i] = 0x1000 * i + PAGE_V + PAGE_RW;
pd[i] = 0x1000 * i + PAGE_V + PAGE_RSRV + PAGE_RW;
}
pdt1[0] = (intptr_t)pd + PAGE_V + PAGE_RW;
pdt2[0] = (intptr_t)pd + PAGE_V + PAGE_RW;