// SPDX-License-Identifier: GPL-2.0-or-later /* * This file contains the routines setting up the linux page tables. * -- paulus * * Derived from arch/ppc/mm/init.c: * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) * * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au) * and Cort Dougan (PReP) (cort@cs.nmt.edu) * Copyright (C) 1996 Paul Mackerras * * Derived from "arch/i386/mm/init.c" * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
*/
int __ref map_kernel_page(unsignedlong va, phys_addr_t pa, pgprot_t prot)
{
pmd_t *pd;
pte_t *pg; int err = -ENOMEM;
/* Use upper 10 bits of VA to index the first level map */
pd = pmd_off_k(va); /* Use middle 10 bits of VA to index the second-level map */ if (likely(slab_is_available()))
pg = pte_alloc_kernel(pd, va); else
pg = early_pte_alloc_kernel(pd, va); if (pg) {
err = 0; /* The PTE should never be already set nor present in the * hash table
*/
BUG_ON((pte_present(*pg) | pte_hashpte(*pg)) && pgprot_val(prot));
set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT, prot));
}
smp_wmb(); return err;
}
/* * Map in a chunk of physical memory starting at start.
*/ staticvoid __init __mapin_ram_chunk(unsignedlong offset, unsignedlong top)
{ unsignedlong v, s;
phys_addr_t p; bool ktext;
s = offset;
v = PAGE_OFFSET + s;
p = memstart_addr + s; for (; s < top; s += PAGE_SIZE) {
ktext = core_kernel_text(v);
map_kernel_page(v, p, ktext ? PAGE_KERNEL_X : PAGE_KERNEL);
v += PAGE_SIZE;
p += PAGE_SIZE;
}
}
if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX) && mmu_has_feature(MMU_FTR_HPTE_TABLE))
pr_warn("This platform has HASH MMU, STRICT_MODULE_RWX won't work\n");
if (v_block_mapped((unsignedlong)_stext + 1)) return mmu_mark_rodata_ro();
/* * mark text and rodata as read only. __end_rodata is set by * powerpc's linker script and includes tables and data * requiring relocation which are not put in RO_DATA.
*/
numpages = PFN_UP((unsignedlong)__end_rodata) -
PFN_DOWN((unsignedlong)_stext);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.