Changeset View
Changeset View
Standalone View
Standalone View
sys/riscv/riscv/pmap.c
Show First 20 Lines • Show All 1,210 Lines • ▼ Show 20 Lines | pmap_pinit0(pmap_t pmap) | ||||||||
pmap_activate_boot(pmap); | pmap_activate_boot(pmap); | ||||||||
} | } | ||||||||
int | int | ||||||||
pmap_pinit(pmap_t pmap) | pmap_pinit(pmap_t pmap) | ||||||||
{ | { | ||||||||
vm_paddr_t l1phys; | vm_paddr_t l1phys; | ||||||||
vm_page_t l1pt; | vm_page_t l1pt; | ||||||||
size_t i; | |||||||||
/* | /* | ||||||||
* allocate the l1 page | * allocate the l1 page | ||||||||
*/ | */ | ||||||||
l1pt = vm_page_alloc_noobj(VM_ALLOC_WIRED | VM_ALLOC_ZERO | | l1pt = vm_page_alloc_noobj(VM_ALLOC_WIRED | VM_ALLOC_ZERO | | ||||||||
VM_ALLOC_WAITOK); | VM_ALLOC_WAITOK); | ||||||||
l1phys = VM_PAGE_TO_PHYS(l1pt); | l1phys = VM_PAGE_TO_PHYS(l1pt); | ||||||||
pmap->pm_l1 = (pd_entry_t *)PHYS_TO_DMAP(l1phys); | pmap->pm_l1 = (pd_entry_t *)PHYS_TO_DMAP(l1phys); | ||||||||
pmap->pm_satp = SATP_MODE_SV39 | (l1phys >> PAGE_SHIFT); | pmap->pm_satp = SATP_MODE_SV39 | (l1phys >> PAGE_SHIFT); | ||||||||
bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); | bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); | ||||||||
CPU_ZERO(&pmap->pm_active); | CPU_ZERO(&pmap->pm_active); | ||||||||
/* | |||||||||
* Copy L1 entries from the kernel pmap. This must be done with the | |||||||||
* allpmaps lock held to avoid races with pmap_distribute_l1(). | |||||||||
*/ | |||||||||
mtx_lock(&allpmaps_lock); | mtx_lock(&allpmaps_lock); | ||||||||
LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); | LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); | ||||||||
for (i = pmap_l1_index(VM_MIN_KERNEL_ADDRESS); | |||||||||
jrtc27: The switch from memcpy seems like a separate change?.. | |||||||||
markjAuthorUnsubmitted Done Inline ActionsYes, I'm effectively making two changes here: fixing the race, and trying to reduce the amount of work done under the allpmaps lock. I can commit the changes separately; for review purposes it seemed reasonable to squash the two. markj: Yes, I'm effectively making two changes here: fixing the race, and trying to reduce the amount… | |||||||||
arichardsonUnsubmitted Done Inline Actions
Should be allowed now and avoids an extra line at the start? arichardson: Should be allowed now and avoids an extra line at the start? | |||||||||
i < pmap_l1_index(VM_MAX_KERNEL_ADDRESS); i++) | |||||||||
pmap->pm_l1[i] = kernel_pmap->pm_l1[i]; | |||||||||
for (i = pmap_l1_index(DMAP_MIN_ADDRESS); | |||||||||
i < pmap_l1_index(DMAP_MAX_ADDRESS); i++) | |||||||||
pmap->pm_l1[i] = kernel_pmap->pm_l1[i]; | |||||||||
mtx_unlock(&allpmaps_lock); | mtx_unlock(&allpmaps_lock); | ||||||||
memcpy(pmap->pm_l1, kernel_pmap->pm_l1, PAGE_SIZE); | |||||||||
vm_radix_init(&pmap->pm_root); | vm_radix_init(&pmap->pm_root); | ||||||||
return (1); | return (1); | ||||||||
} | } | ||||||||
/* | /* | ||||||||
* This routine is called if the desired page table page does not exist. | * This routine is called if the desired page table page does not exist. | ||||||||
▲ Show 20 Lines • Show All 3,530 Lines • Show Last 20 Lines |
The switch from memcpy seems like a separate change?..