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

Function _pmap_alloc_l3

freebsd/arm64/arm64/pmap.c:1846–1969  ·  view source on GitHub ↗

* This routine is called if the desired page table page does not exist. * * If page table page allocation fails, this routine may sleep before * returning NULL. It sleeps only if a lock pointer was given. * * Note: If a page allocation fails at page table level two or three, * one or two pages may be held during the wait, only to be released * afterwards. This conservative approach is eas

Source from the content-addressed store, hash-verified

1844 * race conditions.
1845 */
1846static vm_page_t
1847_pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp)
1848{
1849 vm_page_t m, l1pg, l2pg;
1850
1851 PMAP_LOCK_ASSERT(pmap, MA_OWNED);
1852
1853 /*
1854 * Allocate a page table page.
1855 */
1856 if ((m = vm_page_alloc(NULL, ptepindex, VM_ALLOC_NOOBJ |
1857 VM_ALLOC_WIRED | VM_ALLOC_ZERO)) == NULL) {
1858 if (lockp != NULL) {
1859 RELEASE_PV_LIST_LOCK(lockp);
1860 PMAP_UNLOCK(pmap);
1861 vm_wait(NULL);
1862 PMAP_LOCK(pmap);
1863 }
1864
1865 /*
1866 * Indicate the need to retry. While waiting, the page table
1867 * page may have been allocated.
1868 */
1869 return (NULL);
1870 }
1871 if ((m->flags & PG_ZERO) == 0)
1872 pmap_zero_page(m);
1873
1874 /*
1875 * Because of AArch64's weak memory consistency model, we must have a
1876 * barrier here to ensure that the stores for zeroing "m", whether by
1877 * pmap_zero_page() or an earlier function, are visible before adding
1878 * "m" to the page table. Otherwise, a page table walk by another
1879 * processor's MMU could see the mapping to "m" and a stale, non-zero
1880 * PTE within "m".
1881 */
1882 dmb(ishst);
1883
1884 /*
1885 * Map the pagetable page into the process address space, if
1886 * it isn't already there.
1887 */
1888
1889 if (ptepindex >= (NUL2E + NUL1E)) {
1890 pd_entry_t *l0;
1891 vm_pindex_t l0index;
1892
1893 l0index = ptepindex - (NUL2E + NUL1E);
1894 l0 = &pmap->pm_l0[l0index];
1895 pmap_store(l0, VM_PAGE_TO_PHYS(m) | L0_TABLE);
1896 } else if (ptepindex >= NUL2E) {
1897 vm_pindex_t l0index, l1index;
1898 pd_entry_t *l0, *l1;
1899 pd_entry_t tl0;
1900
1901 l1index = ptepindex - NUL2E;
1902 l0index = l1index >> L0_ENTRIES_SHIFT;
1903

Callers 8

pmap_pinit_stageFunction · 0.85
pmap_alloc_l2Function · 0.85
pmap_alloc_l3Function · 0.85
pmap_enter_largepageFunction · 0.85
pmap_senterFunction · 0.85
pmap_enterFunction · 0.85
pmap_enter_quick_lockedFunction · 0.85
pmap_copyFunction · 0.85

Calls 7

vm_page_allocFunction · 0.85
vm_waitFunction · 0.85
vm_page_unwire_noqFunction · 0.85
vm_page_free_zeroFunction · 0.85
PHYS_TO_VM_PAGEFunction · 0.85
pmap_zero_pageFunction · 0.70
pmap_resident_count_incFunction · 0.70

Tested by

no test coverage detected