hat_pte.h revision aa2ed9e57a76431fbe2ba230496f4fcd22b2d41d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _VM_HAT_PTE_H
#define _VM_HAT_PTE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Defines for the bits in X86 and AMD64 Page Tables
*
* Notes:
*
* Largepages and PAT bits:
*
* bit 7 at level 0 is the PAT bit
* bit 7 above level 0 is the Pagesize bit (set for large page)
* bit 12 (when a large page) is the PAT bit
*
*
* PAT & PWT -> Write Protected
* PAT & PCD -> Write Combining
* PAT by itself (PWT == 0 && PCD == 0) yields uncacheable (same as PCD == 1)
*
*
* Permission bits:
*
* - PT_USER must be set in all levels for user pages
* - PT_WRITE must be set in all levels for user writable pages
* - PT_NX applies if set at any level
*
* For these, we use the "allow" settings in all tables above level 0 and only
* ever disable things in PTEs.
*
* The use of PT_GLOBAL and PT_NX depend on being enabled in processor
* control registers. Hence, we use a variable to reference these bit
* masks. During hat_kern_setup() if the feature isn't enabled we
* clear out the variables.
*/
/*
* The software bits are used by the HAT to track attributes.
*
* The hat will install them as always set.
*
* PT_NOCONSIST - There is no entry for this hment for this mapping.
*/
/*
*/
#define PTE_SET(p, f) ((p) |= (f))
#define PTE_GET(p, f) ((p) & (f))
/*
* Handy macro to check if a pagetable entry or pointer is valid
*/
/*
* Does a PTE map a large page.
*/
/*
* does this PTE represent a page (not a pointer to another page table)?
*/
#define PTE_ISPAGE(p, l) \
/*
*/
/*
* Shorthand for converting a PTE to it's pfn.
*/
#define PTE2PFN(p, l) \
/*
* The software extraction for a single Page Table Entry will always
* be a 64 bit unsigned int. If running a non-PAE hat, the page table
*/
typedef uint32_t x86pte32_t;
#define PT_NX (0x8000000000000000ull)
#define PT_PADDR (0x00fffffffffff000ull)
/*
* Macros to create a PTP or PTE from the pfn and level
*/
/*
* The idea of "level" refers to the level where the page table is used in the
* the hardware address translation steps. The level values correspond to the
*
* ---------------------- -------
* Page Map Level 4 3
* Page Directory Pointer 2
* Page Directory 1
* Page Table 0
*
* The numbering scheme is such that the values of 0 and 1 can correspond to
* the pagesize codes used for MPSS support. For now the Maximum level at
* which you can have a large page is a constant, that may change in
* future processors.
*
* The type of "level_t" is signed so that it can be used like:
* level_t l;
* ...
* while (--l >= 0)
* ...
*/
#define MAX_NUM_LEVEL 4
/*
* Macros to:
* Check for a PFN above 4Gig and 64Gig for 32 bit PAE support
*/
/*
* The CR3 register holds the physical address of the top level page table.
*/
/*
*/
struct htable;
struct hat_mmu_info {
/*
* The following tables are equivalent to PAGEXXXXX at different levels
* in the page table hierarchy.
*/
};
#if defined(_KERNEL)
/*
* The concept of a VA hole exists in AMD64. This might need to be made
* model specific eventually.
*
* In the 64 bit kernel PTE loads are atomic, but need cas64 on 32 bit kernel.
*/
#if defined(__amd64)
#ifdef lint
#else
#endif
#define FMT_PTE "%lx"
#ifdef lint
#else
#define IN_VA_HOLE(va) (0)
#endif
#define FMT_PTE "%llx"
#endif /* __i386 */
extern struct hat_mmu_info mmu;
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _VM_HAT_PTE_H */