/* SPDX-License-Identifier: GPL-2.0-only */ /* * Page table support for the Hexagon architecture * * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
*/
/* A handy thing to have if one has the RAM. Declared in head.S */ externunsignedlong empty_zero_page;
/* * The PTE model described here is that of the Hexagon Virtual Machine, * which autonomously walks 2-level page tables. At a lower level, we * also describe the RISCish software-loaded TLB entry structure of * the underlying Hexagon processor. A kernel built to run on the * virtual machine has no need to know about the underlying hardware.
*/ #include <asm/vm_mmu.h>
/* * To maximize the comfort level for the PTE manipulation macros, * define the "well known" architecture-specific bits.
*/ #define _PAGE_READ __HVM_PTE_R #define _PAGE_WRITE __HVM_PTE_W #define _PAGE_EXECUTE __HVM_PTE_X #define _PAGE_USER __HVM_PTE_U
/* * We have a total of 4 "soft" bits available in the abstract PTE. * The two mandatory software bits are Dirty and Accessed. * To make nonlinear swap work according to the more recent * model, we want a low order "Present" bit to indicate whether * the PTE describes MMU programming or swap space.
*/ #define _PAGE_PRESENT (1<<0) #define _PAGE_DIRTY (1<<1) #define _PAGE_ACCESSED (1<<2)
/* * For now, let's say that Valid and Present are the same thing. * Alternatively, we could say that it's the "or" of R, W, and X * permissions.
*/ #define _PAGE_VALID _PAGE_PRESENT
/* * We're not defining _PAGE_GLOBAL here, since there's no concept * of global pages or ASIDs exposed to the Hexagon Virtual Machine, * and we want to use the same page table structures and macros in * the native kernel as we do in the virtual machine kernel. * So we'll put up with a bit of inefficiency for now...
*/
/* We borrow bit 6 to store the exclusive marker in swap PTEs. */ #define _PAGE_SWP_EXCLUSIVE (1<<6)
/* * Top "FOURTH" level (pgd), which for the Hexagon VM is really * only the second from the bottom, pgd and pud both being collapsed. * Each entry represents 4MB of virtual address space, 4K of table * thus maps the full 4GB.
*/ #define PGDIR_SHIFT 22 #define PTRS_PER_PGD 1024
/* * Aliases for mapping mmap() protection bits to page protections. * These get used for static initialization, so using the _dflt_cache_att * variable for the default cache attribute isn't workable. If the * default gets changed at boot time, the boot option code has to * update data structures like the protaction_map[] array.
*/ #define CACHEDEF (CACHE_DEFAULT << 6)
extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* located in head.S */
/* HUGETLB not working currently */ #ifdef CONFIG_HUGETLB_PAGE #define pte_mkhuge(pte) __pte((pte_val(pte) & ~0x3) | HVM_HUGEPAGE_SIZE) #endif
/* * For now, assume that higher-level code will do TLB/MMU invalidations * and don't insert that overhead into this low-level function.
*/ externvoid sync_icache_dcache(pte_t pte);
staticinlinevoid set_pte(pte_t *ptep, pte_t pteval)
{ /* should really be using pte_exec, if it weren't declared later. */ if (pte_present_exec_user(pteval))
sync_icache_dcache(pteval);
*ptep = pteval;
}
/* * For the Hexagon Virtual Machine MMU (or its emulation), a null/invalid * L1 PTE (PMD/PGD) has 7 in the least significant bits. For the L2 PTE * (Linux PTE), the key is to have bits 11..9 all zero. We'd use 0x7 * as a universal null entry, but some of those least significant bits * are interpreted by software.
*/ #define _NULL_PMD 0x7 #define _NULL_PTE 0x0
/* * Conveniently, a null PTE value is invalid.
*/ staticinlinevoid pte_clear(struct mm_struct *mm, unsignedlong addr,
pte_t *ptep)
{
pte_val(*ptep) = _NULL_PTE;
}
/** * pmd_none - check if pmd_entry is mapped * @pmd_entry: pmd entry * * MIPS checks it against that "invalid pte table" thing.
*/ staticinlineint pmd_none(pmd_t pmd)
{ return pmd_val(pmd) == _NULL_PMD;
}
/** * pmd_present - is there a page table behind this? * Essentially the inverse of pmd_none. We maybe * save an inline instruction by defining it this * way, instead of simply "!pmd_none".
*/ staticinlineint pmd_present(pmd_t pmd)
{ return pmd_val(pmd) != (unsignedlong)_NULL_PMD;
}
/** * pmd_bad - check if a PMD entry is "bad". That might mean swapped out. * As we have no known cause of badness, it's null, as it is for many * architectures.
*/ staticinlineint pmd_bad(pmd_t pmd)
{ return 0;
}
/* * pmd_pfn - converts a PMD entry to a page frame number
*/ #define pmd_pfn(pmd) (pmd_val(pmd) >> PAGE_SHIFT)
/* * pmd_page - converts a PMD entry to a page pointer
*/ #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
/* ZERO_PAGE - returns the globally shared zero page */ #define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page))
/* * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that * are !pte_none() && !pte_present(). * * Swap/file PTE definitions. If _PAGE_PRESENT is zero, the rest of the PTE is * interpreted as swap information. The remaining free bits are interpreted as * listed below. Rather than have the TLB fill handler test * _PAGE_PRESENT, we're going to reserve the permissions bits and set them to * all zeros for swap entries, which speeds up the miss handler at the cost of * 3 bits of offset. That trade-off can be revisited if necessary, but Hexagon * processor architecture and target applications suggest a lot of TLB misses * and not much swap space. * * Format of swap PTE: * bit 0: Present (zero) * bits 1-5: swap type (arch independent layer uses 5 bits max) * bit 6: exclusive marker * bits 7-9: bits 2:0 of offset * bits 10-12: effectively _PAGE_PROTNONE (all zero) * bits 13-31: bits 21:3 of swap offset * * The split offset makes some of the following macros a little gnarly, * but there's plenty of precedent for this sort of thing.
*/
/* Used for swap PTEs */ #define __swp_type(swp_pte) (((swp_pte).val >> 1) & 0x1f)
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.