Set the Execute Never flags in EFI device memory as required by the ARMv8

spec.

Sponsored by:	DARPA, AFRL
This commit is contained in:
Andrew Turner 2018-08-15 13:19:15 +00:00
parent f13a4096b7
commit 916e7b1252

View File

@ -162,7 +162,7 @@ bool
efi_create_1t1_map(struct efi_md *map, int ndesc, int descsz) efi_create_1t1_map(struct efi_md *map, int ndesc, int descsz)
{ {
struct efi_md *p; struct efi_md *p;
pt_entry_t *l3; pt_entry_t *l3, l3_attr;
vm_offset_t va; vm_offset_t va;
uint64_t idx; uint64_t idx;
int i, mode; int i, mode;
@ -218,12 +218,17 @@ efi_create_1t1_map(struct efi_md *map, int ndesc, int descsz)
} }
printf("MAP %lx mode %x pages %lu\n", p->md_phys, mode, p->md_pages); printf("MAP %lx mode %x pages %lu\n", p->md_phys, mode, p->md_pages);
l3_attr = ATTR_DEFAULT | ATTR_IDX(mode) | ATTR_AP(ATTR_AP_RW) |
L3_PAGE;
if (mode == VM_MEMATTR_DEVICE)
l3_attr |= ATTR_UXN | ATTR_PXN;
VM_OBJECT_WLOCK(obj_1t1_pt); VM_OBJECT_WLOCK(obj_1t1_pt);
for (va = p->md_phys, idx = 0; idx < p->md_pages; idx++, for (va = p->md_phys, idx = 0; idx < p->md_pages; idx++,
va += PAGE_SIZE) { va += PAGE_SIZE) {
l3 = efi_1t1_l3(va); l3 = efi_1t1_l3(va);
*l3 = va | ATTR_DEFAULT | ATTR_IDX(mode) | *l3 = va | l3_attr;
ATTR_AP(ATTR_AP_RW) | L3_PAGE;
} }
VM_OBJECT_WUNLOCK(obj_1t1_pt); VM_OBJECT_WUNLOCK(obj_1t1_pt);
} }