MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pmap_flush_cache_phys_range

Function pmap_flush_cache_phys_range

freebsd/amd64/amd64/pmap.c:3622–3657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3620}
3621
3622void
3623pmap_flush_cache_phys_range(vm_paddr_t spa, vm_paddr_t epa, vm_memattr_t mattr)
3624{
3625 pt_entry_t *pte;
3626 vm_offset_t vaddr;
3627 int error, pte_bits;
3628
3629 KASSERT((spa & PAGE_MASK) == 0,
3630 ("pmap_flush_cache_phys_range: spa not page-aligned"));
3631 KASSERT((epa & PAGE_MASK) == 0,
3632 ("pmap_flush_cache_phys_range: epa not page-aligned"));
3633
3634 if (spa < dmaplimit) {
3635 pmap_flush_cache_range(PHYS_TO_DMAP(spa), PHYS_TO_DMAP(MIN(
3636 dmaplimit, epa)));
3637 if (dmaplimit >= epa)
3638 return;
3639 spa = dmaplimit;
3640 }
3641
3642 pte_bits = pmap_cache_bits(kernel_pmap, mattr, 0) | X86_PG_RW |
3643 X86_PG_V;
3644 error = vmem_alloc(kernel_arena, PAGE_SIZE, M_BESTFIT | M_WAITOK,
3645 &vaddr);
3646 KASSERT(error == 0, ("vmem_alloc failed: %d", error));
3647 pte = vtopte(vaddr);
3648 for (; spa < epa; spa += PAGE_SIZE) {
3649 sched_pin();
3650 pte_store(pte, spa | pte_bits);
3651 invlpg(vaddr);
3652 /* XXXKIB atomic inside flush_cache_range are excessive */
3653 pmap_flush_cache_range(vaddr, vaddr + PAGE_SIZE);
3654 sched_unpin();
3655 }
3656 vmem_free(kernel_arena, vaddr, PAGE_SIZE);
3657}
3658
3659/*
3660 * Routine: pmap_extract

Callers

nothing calls this directly

Calls 8

pmap_flush_cache_rangeFunction · 0.85
vmem_allocFunction · 0.85
vtopteFunction · 0.85
sched_pinFunction · 0.85
sched_unpinFunction · 0.85
vmem_freeFunction · 0.85
pmap_cache_bitsFunction · 0.70
invlpgFunction · 0.50

Tested by

no test coverage detected