Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/pmap.c
Show First 20 Lines • Show All 784 Lines • ▼ Show 20 Lines | if ((pa & L1_OFFSET) != 0) { | ||||||||
if (l1_slot != prev_l1_slot) { | if (l1_slot != prev_l1_slot) { | ||||||||
prev_l1_slot = l1_slot; | prev_l1_slot = l1_slot; | ||||||||
l2 = (pt_entry_t *)freemempos; | l2 = (pt_entry_t *)freemempos; | ||||||||
l2_pa = pmap_early_vtophys(kern_l1, | l2_pa = pmap_early_vtophys(kern_l1, | ||||||||
(vm_offset_t)l2); | (vm_offset_t)l2); | ||||||||
freemempos += PAGE_SIZE; | freemempos += PAGE_SIZE; | ||||||||
pmap_store(&pagetable_dmap[l1_slot], | pmap_store(&pagetable_dmap[l1_slot], | ||||||||
(l2_pa & ~Ln_TABLE_MASK) | L1_TABLE); | (l2_pa & ~Ln_TABLE_MASK) | | ||||||||
TATTR_PXN_TABLE | L1_TABLE); | |||||||||
memset(l2, 0, PAGE_SIZE); | memset(l2, 0, PAGE_SIZE); | ||||||||
} | } | ||||||||
KASSERT(l2 != NULL, | KASSERT(l2 != NULL, | ||||||||
("pmap_bootstrap_dmap: NULL l2 map")); | ("pmap_bootstrap_dmap: NULL l2 map")); | ||||||||
for (; va < DMAP_MAX_ADDRESS && pa < physmap[i + 1]; | for (; va < DMAP_MAX_ADDRESS && pa < physmap[i + 1]; | ||||||||
pa += L2_SIZE, va += L2_SIZE) { | pa += L2_SIZE, va += L2_SIZE) { | ||||||||
/* | /* | ||||||||
▲ Show 20 Lines • Show All 1,067 Lines • ▼ Show 20 Lines | _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp) | ||||||||
dmb(ishst); | dmb(ishst); | ||||||||
/* | /* | ||||||||
* Map the pagetable page into the process address space, if | * Map the pagetable page into the process address space, if | ||||||||
* it isn't already there. | * it isn't already there. | ||||||||
*/ | */ | ||||||||
if (ptepindex >= (NUL2E + NUL1E)) { | if (ptepindex >= (NUL2E + NUL1E)) { | ||||||||
pd_entry_t *l0; | pd_entry_t *l0p, l0; | ||||||||
alc: A stylistic suggestion: Use l0e instead of l0. A few lines later, in the same function, we use… | |||||||||
vm_pindex_t l0index; | vm_pindex_t l0index; | ||||||||
l0index = ptepindex - (NUL2E + NUL1E); | l0index = ptepindex - (NUL2E + NUL1E); | ||||||||
l0 = &pmap->pm_l0[l0index]; | l0p = &pmap->pm_l0[l0index]; | ||||||||
KASSERT((pmap_load(l0) & ATTR_DESCR_VALID) == 0, | KASSERT((pmap_load(l0p) & ATTR_DESCR_VALID) == 0, | ||||||||
("%s: L0 entry %#lx is valid", __func__, pmap_load(l0))); | ("%s: L0 entry %#lx is valid", __func__, pmap_load(l0p))); | ||||||||
pmap_store(l0, VM_PAGE_TO_PHYS(m) | L0_TABLE); | l0 = VM_PAGE_TO_PHYS(m) | L0_TABLE; | ||||||||
Not Done Inline Actions
markj: | |||||||||
/* | |||||||||
* Mark all kernel memory as not accessible from userspace | |||||||||
* and userspace memory as not executable from the kernel. | |||||||||
Not Done Inline ActionsI would suggest adding a note to the effect that this is done for bootstrap L0 entries in locore. And maybe we should assert it in pmap_bootstrap(). markj: I would suggest adding a note to the effect that this is done for bootstrap L0 entries in… | |||||||||
* This has been done for the bootstrap L0 entries in | |||||||||
* locore.S. | |||||||||
*/ | |||||||||
if (pmap == kernel_pmap) | |||||||||
l0 |= TATTR_UXN_TABLE | TATTR_AP_TABLE_NO_EL0; | |||||||||
else | |||||||||
l0 |= TATTR_PXN_TABLE; | |||||||||
pmap_store(l0p, l0); | |||||||||
} else if (ptepindex >= NUL2E) { | } else if (ptepindex >= NUL2E) { | ||||||||
vm_pindex_t l0index, l1index; | vm_pindex_t l0index, l1index; | ||||||||
pd_entry_t *l0, *l1; | pd_entry_t *l0, *l1; | ||||||||
pd_entry_t tl0; | pd_entry_t tl0; | ||||||||
l1index = ptepindex - NUL2E; | l1index = ptepindex - NUL2E; | ||||||||
l0index = l1index >> L0_ENTRIES_SHIFT; | l0index = l1index >> L0_ENTRIES_SHIFT; | ||||||||
▲ Show 20 Lines • Show All 5,253 Lines • Show Last 20 Lines |
A stylistic suggestion: Use l0e instead of l0. A few lines later, in the same function, we use the same variable name, l0, as a pointer instead of a value. In general, I'd like to suggest that going forward new or revised code use names of the form l0p or l0e.