18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Hexagon VM page table entry definitions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2011,2013 The Linux Foundation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _ASM_VM_MMU_H 98c2ecf20Sopenharmony_ci#define _ASM_VM_MMU_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* 128c2ecf20Sopenharmony_ci * Shift, mask, and other constants for the Hexagon Virtual Machine 138c2ecf20Sopenharmony_ci * page tables. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * Virtual machine MMU allows first-level entries to either be 168c2ecf20Sopenharmony_ci * single-level lookup PTEs for very large pages, or PDEs pointing 178c2ecf20Sopenharmony_ci * to second-level PTEs for smaller pages. If PTE is single-level, 188c2ecf20Sopenharmony_ci * the least significant bits cannot be used as software bits to encode 198c2ecf20Sopenharmony_ci * virtual memory subsystem information about the page, and that state 208c2ecf20Sopenharmony_ci * must be maintained in some parallel data structure. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* S or Page Size field in PDE */ 248c2ecf20Sopenharmony_ci#define __HVM_PDE_S (0x7 << 0) 258c2ecf20Sopenharmony_ci#define __HVM_PDE_S_4KB 0 268c2ecf20Sopenharmony_ci#define __HVM_PDE_S_16KB 1 278c2ecf20Sopenharmony_ci#define __HVM_PDE_S_64KB 2 288c2ecf20Sopenharmony_ci#define __HVM_PDE_S_256KB 3 298c2ecf20Sopenharmony_ci#define __HVM_PDE_S_1MB 4 308c2ecf20Sopenharmony_ci#define __HVM_PDE_S_4MB 5 318c2ecf20Sopenharmony_ci#define __HVM_PDE_S_16MB 6 328c2ecf20Sopenharmony_ci#define __HVM_PDE_S_INVALID 7 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* Masks for L2 page table pointer, as function of page size */ 358c2ecf20Sopenharmony_ci#define __HVM_PDE_PTMASK_4KB 0xfffff000 368c2ecf20Sopenharmony_ci#define __HVM_PDE_PTMASK_16KB 0xfffffc00 378c2ecf20Sopenharmony_ci#define __HVM_PDE_PTMASK_64KB 0xffffff00 388c2ecf20Sopenharmony_ci#define __HVM_PDE_PTMASK_256KB 0xffffffc0 398c2ecf20Sopenharmony_ci#define __HVM_PDE_PTMASK_1MB 0xfffffff0 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* 428c2ecf20Sopenharmony_ci * Virtual Machine PTE Bits/Fields 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci#define __HVM_PTE_T (1<<4) 458c2ecf20Sopenharmony_ci#define __HVM_PTE_U (1<<5) 468c2ecf20Sopenharmony_ci#define __HVM_PTE_C (0x7<<6) 478c2ecf20Sopenharmony_ci#define __HVM_PTE_CVAL(pte) (((pte) & __HVM_PTE_C) >> 6) 488c2ecf20Sopenharmony_ci#define __HVM_PTE_R (1<<9) 498c2ecf20Sopenharmony_ci#define __HVM_PTE_W (1<<10) 508c2ecf20Sopenharmony_ci#define __HVM_PTE_X (1<<11) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * Cache Attributes, to be shifted as necessary for virtual/physical PTEs 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define __HEXAGON_C_WB 0x0 /* Write-back, no L2 */ 578c2ecf20Sopenharmony_ci#define __HEXAGON_C_WT 0x1 /* Write-through, no L2 */ 588c2ecf20Sopenharmony_ci#define __HEXAGON_C_UNC 0x6 /* Uncached memory */ 598c2ecf20Sopenharmony_ci#if CONFIG_HEXAGON_ARCH_VERSION >= 2 608c2ecf20Sopenharmony_ci#define __HEXAGON_C_DEV 0x4 /* Device register space */ 618c2ecf20Sopenharmony_ci#else 628c2ecf20Sopenharmony_ci#define __HEXAGON_C_DEV __HEXAGON_C_UNC 638c2ecf20Sopenharmony_ci#endif 648c2ecf20Sopenharmony_ci#define __HEXAGON_C_WT_L2 0x5 /* Write-through, with L2 */ 658c2ecf20Sopenharmony_ci#define __HEXAGON_C_WB_L2 0x7 /* Write-back, with L2 */ 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* 688c2ecf20Sopenharmony_ci * This can be overridden, but we're defaulting to the most aggressive 698c2ecf20Sopenharmony_ci * cache policy, the better to find bugs sooner. 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define CACHE_DEFAULT __HEXAGON_C_WB_L2 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* Masks for physical page address, as a function of page size */ 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_4KB 0xfffff000 778c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_16KB 0xffffc000 788c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_64KB 0xffff0000 798c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_256KB 0xfffc0000 808c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_1MB 0xfff00000 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* Masks for single-level large page lookups */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_4MB 0xffc00000 858c2ecf20Sopenharmony_ci#define __HVM_PTE_PGMASK_16MB 0xff000000 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* 888c2ecf20Sopenharmony_ci * "Big kernel page mappings" (see vm_init_segtable.S) 898c2ecf20Sopenharmony_ci * are currently 16MB 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define BIG_KERNEL_PAGE_SHIFT 24 938c2ecf20Sopenharmony_ci#define BIG_KERNEL_PAGE_SIZE (1 << BIG_KERNEL_PAGE_SHIFT) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#endif /* _ASM_VM_MMU_H */ 98