Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/include/pmap.h
| Show First 20 Lines • Show All 425 Lines • ▼ Show 20 Lines | |||||
| extern caddr_t CADDR1; | extern caddr_t CADDR1; | ||||
| extern pt_entry_t *CMAP1; | extern pt_entry_t *CMAP1; | ||||
| extern vm_offset_t virtual_avail; | extern vm_offset_t virtual_avail; | ||||
| extern vm_offset_t virtual_end; | extern vm_offset_t virtual_end; | ||||
| extern vm_paddr_t dmaplimit; | extern vm_paddr_t dmaplimit; | ||||
| extern int pmap_pcid_enabled; | extern int pmap_pcid_enabled; | ||||
| extern int invpcid_works; | extern int invpcid_works; | ||||
| extern int pmap_pcid_invlpg_workaround; | |||||
| #define pmap_page_get_memattr(m) ((vm_memattr_t)(m)->md.pat_mode) | #define pmap_page_get_memattr(m) ((vm_memattr_t)(m)->md.pat_mode) | ||||
| #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) | #define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) | ||||
| #define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz)) | #define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz)) | ||||
| #define pmap_vm_page_alloc_check(m) \ | #define pmap_vm_page_alloc_check(m) \ | ||||
| KASSERT(m->phys_addr < kernphys || \ | KASSERT(m->phys_addr < kernphys || \ | ||||
| m->phys_addr >= kernphys + (vm_offset_t)&_end - KERNSTART, \ | m->phys_addr >= kernphys + (vm_offset_t)&_end - KERNSTART, \ | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
| * Returns a pointer to a set of CPUs on which the pmap is currently active. | * Returns a pointer to a set of CPUs on which the pmap is currently active. | ||||
| * Note that the set can be modified without any mutual exclusion, so a copy | * Note that the set can be modified without any mutual exclusion, so a copy | ||||
| * must be made if a stable value is required. | * must be made if a stable value is required. | ||||
| */ | */ | ||||
| static __inline volatile cpuset_t * | static __inline volatile cpuset_t * | ||||
| pmap_invalidate_cpu_mask(pmap_t pmap) | pmap_invalidate_cpu_mask(pmap_t pmap) | ||||
| { | { | ||||
| return (&pmap->pm_active); | return (&pmap->pm_active); | ||||
| } | |||||
| /* | |||||
| * It seems that AlderLake+ small cores have some microarchitectural | |||||
markj: ```
pmap_invlpg(pmap_t pmap, vm_offset_t)
{
if (pmap != kernel_pmap)
return;
... | |||||
Done Inline ActionsOk, I did it almost this way, but the function still needs to perform invalidation, so it cannot just return for !kernel_pmap. kib: Ok, I did it almost this way, but the function still needs to perform invalidation, so it… | |||||
| * bug, which results in the INVLPG instruction failing to flush all | |||||
Done Inline Actions"..., which results in the INVLPG instruction failing to flush all alc: "..., which results in the INVLPG instruction failing to flush all | |||||
| * global TLB entries when PCID is enabled. Work around it for now, | |||||
| * by doing global invalidation on small cores instead of INVLPG. | |||||
| */ | |||||
| static __inline void | |||||
| pmap_invlpg(pmap_t pmap, vm_offset_t va) | |||||
| { | |||||
| if (pmap == kernel_pmap && PCPU_GET(pcid_invlpg_bug)) { | |||||
| struct invpcid_descr d = { 0 }; | |||||
| invpcid(&d, INVPCID_CTXGLOB); | |||||
| } else { | |||||
| invlpg(va); | |||||
| } | |||||
| } | } | ||||
| #endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
| /* Return various clipped indexes for a given VA */ | /* Return various clipped indexes for a given VA */ | ||||
| static __inline vm_pindex_t | static __inline vm_pindex_t | ||||
| pmap_pte_index(vm_offset_t va) | pmap_pte_index(vm_offset_t va) | ||||
| { | { | ||||
| Show All 37 Lines | |||||
pmap_invlpg(pmap_t pmap, vm_offset_t) { if (pmap != kernel_pmap) return; ... }feels more intuitive. The compiler should be able to remove the branch in most callers.
Otherwise, it is not obvious to me what the "_pmap" suffix means.