1*28fdf718SKonstantin Belousov /*- 2*28fdf718SKonstantin Belousov * SPDX-License-Identifier: BSD-3-Clause 3*28fdf718SKonstantin Belousov * 4*28fdf718SKonstantin Belousov * Copyright (c) 2003 Peter Wemm. 5*28fdf718SKonstantin Belousov * Copyright (c) 1991 Regents of the University of California. 6*28fdf718SKonstantin Belousov * All rights reserved. 7*28fdf718SKonstantin Belousov * 8*28fdf718SKonstantin Belousov * This code is derived from software contributed to Berkeley by 9*28fdf718SKonstantin Belousov * the Systems Programming Group of the University of Utah Computer 10*28fdf718SKonstantin Belousov * Science Department and William Jolitz of UUNET Technologies Inc. 11*28fdf718SKonstantin Belousov * 12*28fdf718SKonstantin Belousov * Redistribution and use in source and binary forms, with or without 13*28fdf718SKonstantin Belousov * modification, are permitted provided that the following conditions 14*28fdf718SKonstantin Belousov * are met: 15*28fdf718SKonstantin Belousov * 1. Redistributions of source code must retain the above copyright 16*28fdf718SKonstantin Belousov * notice, this list of conditions and the following disclaimer. 17*28fdf718SKonstantin Belousov * 2. Redistributions in binary form must reproduce the above copyright 18*28fdf718SKonstantin Belousov * notice, this list of conditions and the following disclaimer in the 19*28fdf718SKonstantin Belousov * documentation and/or other materials provided with the distribution. 20*28fdf718SKonstantin Belousov * 3. Neither the name of the University nor the names of its contributors 21*28fdf718SKonstantin Belousov * may be used to endorse or promote products derived from this software 22*28fdf718SKonstantin Belousov * without specific prior written permission. 23*28fdf718SKonstantin Belousov * 24*28fdf718SKonstantin Belousov * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25*28fdf718SKonstantin Belousov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26*28fdf718SKonstantin Belousov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27*28fdf718SKonstantin Belousov * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28*28fdf718SKonstantin Belousov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29*28fdf718SKonstantin Belousov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30*28fdf718SKonstantin Belousov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31*28fdf718SKonstantin Belousov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32*28fdf718SKonstantin Belousov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33*28fdf718SKonstantin Belousov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34*28fdf718SKonstantin Belousov * SUCH DAMAGE. 35*28fdf718SKonstantin Belousov * 36*28fdf718SKonstantin Belousov * Derived from hp300 version by Mike Hibler, this version by William 37*28fdf718SKonstantin Belousov * Jolitz uses a recursive map [a pde points to the page directory] to 38*28fdf718SKonstantin Belousov * map the page tables using the pagetables themselves. This is done to 39*28fdf718SKonstantin Belousov * reduce the impact on kernel virtual memory for lots of sparse address 40*28fdf718SKonstantin Belousov * space, and to reduce the cost of memory to each process. 41*28fdf718SKonstantin Belousov */ 42*28fdf718SKonstantin Belousov 43*28fdf718SKonstantin Belousov #ifndef _MACHINE_PTE_H_ 44*28fdf718SKonstantin Belousov #define _MACHINE_PTE_H_ 45*28fdf718SKonstantin Belousov 46*28fdf718SKonstantin Belousov /* 47*28fdf718SKonstantin Belousov * Page-directory and page-table entries follow this format, with a few 48*28fdf718SKonstantin Belousov * of the fields not present here and there, depending on a lot of things. 49*28fdf718SKonstantin Belousov */ 50*28fdf718SKonstantin Belousov /* ---- Intel Nomenclature ---- */ 51*28fdf718SKonstantin Belousov #define X86_PG_V 0x001 /* P Valid */ 52*28fdf718SKonstantin Belousov #define X86_PG_RW 0x002 /* R/W Read/Write */ 53*28fdf718SKonstantin Belousov #define X86_PG_U 0x004 /* U/S User/Supervisor */ 54*28fdf718SKonstantin Belousov #define X86_PG_NC_PWT 0x008 /* PWT Write through */ 55*28fdf718SKonstantin Belousov #define X86_PG_NC_PCD 0x010 /* PCD Cache disable */ 56*28fdf718SKonstantin Belousov #define X86_PG_A 0x020 /* A Accessed */ 57*28fdf718SKonstantin Belousov #define X86_PG_M 0x040 /* D Dirty */ 58*28fdf718SKonstantin Belousov #define X86_PG_PS 0x080 /* PS Page size (0=4k,1=2M) */ 59*28fdf718SKonstantin Belousov #define X86_PG_PTE_PAT 0x080 /* PAT PAT index */ 60*28fdf718SKonstantin Belousov #define X86_PG_G 0x100 /* G Global */ 61*28fdf718SKonstantin Belousov #define X86_PG_AVAIL1 0x200 /* / Available for system */ 62*28fdf718SKonstantin Belousov #define X86_PG_AVAIL2 0x400 /* < programmers use */ 63*28fdf718SKonstantin Belousov #define X86_PG_AVAIL3 0x800 /* \ */ 64*28fdf718SKonstantin Belousov #define X86_PG_PDE_PAT 0x1000 /* PAT PAT index */ 65*28fdf718SKonstantin Belousov #define X86_PG_PKU(idx) ((pt_entry_t)idx << 59) 66*28fdf718SKonstantin Belousov #define X86_PG_NX (1ul<<63) /* No-execute */ 67*28fdf718SKonstantin Belousov #define X86_PG_AVAIL(x) (1ul << (x)) 68*28fdf718SKonstantin Belousov 69*28fdf718SKonstantin Belousov /* Page level cache control fields used to determine the PAT type */ 70*28fdf718SKonstantin Belousov #define X86_PG_PDE_CACHE (X86_PG_PDE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD) 71*28fdf718SKonstantin Belousov #define X86_PG_PTE_CACHE (X86_PG_PTE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD) 72*28fdf718SKonstantin Belousov 73*28fdf718SKonstantin Belousov /* Protection keys indexes */ 74*28fdf718SKonstantin Belousov #define PMAP_MAX_PKRU_IDX 0xf 75*28fdf718SKonstantin Belousov #define X86_PG_PKU_MASK X86_PG_PKU(PMAP_MAX_PKRU_IDX) 76*28fdf718SKonstantin Belousov 77*28fdf718SKonstantin Belousov /* 78*28fdf718SKonstantin Belousov * Intel extended page table (EPT) bit definitions. 79*28fdf718SKonstantin Belousov */ 80*28fdf718SKonstantin Belousov #define EPT_PG_READ 0x001 /* R Read */ 81*28fdf718SKonstantin Belousov #define EPT_PG_WRITE 0x002 /* W Write */ 82*28fdf718SKonstantin Belousov #define EPT_PG_EXECUTE 0x004 /* X Execute */ 83*28fdf718SKonstantin Belousov #define EPT_PG_IGNORE_PAT 0x040 /* IPAT Ignore PAT */ 84*28fdf718SKonstantin Belousov #define EPT_PG_PS 0x080 /* PS Page size */ 85*28fdf718SKonstantin Belousov #define EPT_PG_A 0x100 /* A Accessed */ 86*28fdf718SKonstantin Belousov #define EPT_PG_M 0x200 /* D Dirty */ 87*28fdf718SKonstantin Belousov #define EPT_PG_MEMORY_TYPE(x) ((x) << 3) /* MT Memory Type */ 88*28fdf718SKonstantin Belousov 89*28fdf718SKonstantin Belousov #define PG_FRAME (0x000ffffffffff000ul) 90*28fdf718SKonstantin Belousov #define PG_PS_FRAME (0x000fffffffe00000ul) 91*28fdf718SKonstantin Belousov #define PG_PS_PDP_FRAME (0x000fffffc0000000ul) 92*28fdf718SKonstantin Belousov 93*28fdf718SKonstantin Belousov /* 94*28fdf718SKonstantin Belousov * Page Protection Exception bits 95*28fdf718SKonstantin Belousov */ 96*28fdf718SKonstantin Belousov #define PGEX_P 0x01 /* Protection violation vs. not present */ 97*28fdf718SKonstantin Belousov #define PGEX_W 0x02 /* during a Write cycle */ 98*28fdf718SKonstantin Belousov #define PGEX_U 0x04 /* access from User mode (UPL) */ 99*28fdf718SKonstantin Belousov #define PGEX_RSV 0x08 /* reserved PTE field is non-zero */ 100*28fdf718SKonstantin Belousov #define PGEX_I 0x10 /* during an instruction fetch */ 101*28fdf718SKonstantin Belousov #define PGEX_PK 0x20 /* protection key violation */ 102*28fdf718SKonstantin Belousov #define PGEX_SGX 0x8000 /* SGX-related */ 103*28fdf718SKonstantin Belousov 104*28fdf718SKonstantin Belousov #endif 105