Page Table
include/mem/page_table.h View source View on GitHubStructs
Section titled “Structs”pte_tagged
Section titled “pte_tagged” struct pte_tagged (2 fields) source
This is a bit like a tagged pointer, just that the payload moseys around LOCK_BIT and AVAIL2, and the type sits right above PRESENT
The layout is effectively
[ payload higher ] [ LOCK + AVAIL2 ] [ payload lower ] [ type ] [ P = 0 ]
§
enum pte_tag_type type pte_tag_type
Section titled “pte_tag_type” enum pte_tag_type : uint8_t (2 variants) source
Type Aliases
Section titled “Type Aliases”pte_atomic_t
Section titled “pte_atomic_t”typedef atomic_uint64_t pte_atomic_t source Functions
Section titled “Functions”pte_is_shared
Section titled “pte_is_shared”bool pte_is_shared(uint64_t pte) source pte_tagged_check
Section titled “pte_tagged_check”void pte_tagged_check(struct pte_tagged *pt) source pte_tagged_pack
Section titled “pte_tagged_pack”uint64_t pte_tagged_pack(struct pte_tagged *pt) source pte_tagged_unpack
Section titled “pte_tagged_unpack”struct pte_tagged pte_tagged_unpack(pte_t pte) source pte_locked
Section titled “pte_locked”bool pte_locked(pte_atomic_t *pte) source pte_read
Section titled “pte_read”uint64_t pte_read(pte_atomic_t *pte) source pte_or
Section titled “pte_or”uint64_t pte_or(pte_atomic_t *pte, uint64_t val) source pte_unlock_internal
Section titled “pte_unlock_internal”void pte_unlock_internal(pte_atomic_t *pte) source pte_lock_internal
Section titled “pte_lock_internal”void pte_lock_internal(pte_atomic_t *pte) source TODO
use bit_spinlock.h
pte_lock_irql
Section titled “pte_lock_irql”enum irql pte_lock_irql(pte_atomic_t *pte) source pte_unlock_irql
Section titled “pte_unlock_irql”void pte_unlock_irql(pte_atomic_t *pte, enum irql old_irql) source pte_has_tag
Section titled “pte_has_tag”bool pte_has_tag(pte_atomic_t *pte) source pte_tag_pte
Section titled “pte_tag_pte”uint64_t pte_tag_pte(pte_atomic_t *pte, struct pte_tagged *ptag) source pte_read_tag
Section titled “pte_read_tag”struct pte_tagged pte_read_tag(pte_atomic_t *pte) source pte_in_use
Section titled “pte_in_use”bool pte_in_use(pte_atomic_t *pte) source Macros
Section titled “Macros”PT_LEVELS
Section titled “PT_LEVELS”#define PT_LEVELS 4 source PT_SHIFT_L1
Section titled “PT_SHIFT_L1”#define PT_SHIFT_L1 12 source PT_SHIFT_L2
Section titled “PT_SHIFT_L2”#define PT_SHIFT_L2 21 source PT_SHIFT_L3
Section titled “PT_SHIFT_L3”#define PT_SHIFT_L3 30 source PT_SHIFT_L4
Section titled “PT_SHIFT_L4”#define PT_SHIFT_L4 39 source PT_STRIDE
Section titled “PT_STRIDE”#define PT_STRIDE 9 source PTE_LOCK_SHIFT
Section titled “PTE_LOCK_SHIFT”#define PTE_LOCK_SHIFT 9 source PTE_AVAIL2_SHIFT
Section titled “PTE_AVAIL2_SHIFT”#define PTE_AVAIL2_SHIFT 10 source PTE_LOCK_BIT
Section titled “PTE_LOCK_BIT”#define PTE_LOCK_BIT BIT(PTE_LOCK_SHIFT) source PTE_AVAIL2_BIT
Section titled “PTE_AVAIL2_BIT”#define PTE_AVAIL2_BIT BIT(PTE_AVAIL2_SHIFT) source PTE_SHARED_SHIFT
Section titled “PTE_SHARED_SHIFT”#define PTE_SHARED_SHIFT 11 source Mark an entry whose child table is shared with other entries, this is what we use in aliasing. The subtree should never be freed through this entry, since every other entry pointing at it would see the change too. This should only ever be set on present entries
PTE_SHARED_BIT
Section titled “PTE_SHARED_BIT”#define PTE_SHARED_BIT BIT(PTE_SHARED_SHIFT) source PTE_TAGGED_TYPE_SHIFT
Section titled “PTE_TAGGED_TYPE_SHIFT”#define PTE_TAGGED_TYPE_SHIFT (PAGE_PRESENT_SHIFT + 1) source Packed layout:
bit 0 P = 0bits 1-2 typebits 3-8 payload low (6 bits)bit 9 LOCK (not payload)bit 10 AVAIL2 (not payload)bits 11-63 payload high (53 bits)Do note that SHARED is not accounted for here, because that bit is only ever set on PRESENT entries
PTE_TAGGED_TYPE_MASK
Section titled “PTE_TAGGED_TYPE_MASK”#define PTE_TAGGED_TYPE_MASK 0x3ULL source PTE_TAGGED_PAYLOAD_LOW_BITS
Section titled “PTE_TAGGED_PAYLOAD_LOW_BITS”#define PTE_TAGGED_PAYLOAD_LOW_BITS 6 source PTE_TAGGED_PAYLOAD_LOW_SHIFT
Section titled “PTE_TAGGED_PAYLOAD_LOW_SHIFT”#define PTE_TAGGED_PAYLOAD_LOW_SHIFT 3 source packed position of the low chunk
PTE_TAGGED_PAYLOAD_HIGH_SHIFT
Section titled “PTE_TAGGED_PAYLOAD_HIGH_SHIFT”#define PTE_TAGGED_PAYLOAD_HIGH_SHIFT source Expansion
#define PTE_TAGGED_PAYLOAD_HIGH_SHIFT \
11 /* packed position of the high chunk \
*/ PTE_TAGGED_PAYLOAD_LOW_MASK
Section titled “PTE_TAGGED_PAYLOAD_LOW_MASK”#define PTE_TAGGED_PAYLOAD_LOW_MASK (BIT(PTE_TAGGED_PAYLOAD_LOW_BITS) - 1) source PTE_TAGGED_PAYLOAD_BITS
Section titled “PTE_TAGGED_PAYLOAD_BITS”#define PTE_TAGGED_PAYLOAD_BITS source Expansion
#define PTE_TAGGED_PAYLOAD_BITS \
(PTE_TAGGED_PAYLOAD_LOW_BITS + (64 - PTE_TAGGED_PAYLOAD_HIGH_SHIFT)) PTE_TAGGED_GET_TYPE
Section titled “PTE_TAGGED_GET_TYPE”#define PTE_TAGGED_GET_TYPE(pte) source Expansion
#define PTE_TAGGED_GET_TYPE(pte) \
(((pte) >> PTE_TAGGED_TYPE_SHIFT) & PTE_TAGGED_TYPE_MASK) PTE_TAGGED_SET_TYPE
Section titled “PTE_TAGGED_SET_TYPE”#define PTE_TAGGED_SET_TYPE(type) source Expansion
#define PTE_TAGGED_SET_TYPE(type) ((uint64_t) (type) << PTE_TAGGED_TYPE_SHIFT)