1 #ifndef _ASM_X86_PAGE_H_ 2 #define _ASM_X86_PAGE_H_ 3 /* 4 * Copyright (C) 2016, Red Hat Inc, Alexander Gordeev <agordeev@redhat.com> 5 * 6 * This work is licensed under the terms of the GNU LGPL, version 2. 7 */ 8 9 10 #include <linux/const.h> 11 #include <bitops.h> 12 13 typedef unsigned long pteval_t; 14 typedef unsigned long pgd_t; 15 16 #define PAGE_SHIFT 12 17 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 18 #define PAGE_MASK (~(PAGE_SIZE-1)) 19 20 #ifndef __ASSEMBLY__ 21 22 #ifdef __x86_64__ 23 #define LARGE_PAGE_SIZE (512 * PAGE_SIZE) 24 #else 25 #define LARGE_PAGE_SIZE (1024 * PAGE_SIZE) 26 #endif 27 28 #define PT_PRESENT_MASK (1ull << 0) 29 #define PT_WRITABLE_MASK (1ull << 1) 30 #define PT_USER_MASK (1ull << 2) 31 #define PT_ACCESSED_MASK (1ull << 5) 32 #define PT_DIRTY_MASK (1ull << 6) 33 #define PT_PAGE_SIZE_MASK (1ull << 7) 34 #define PT64_NX_MASK (1ull << 63) 35 #define PT_ADDR_MASK GENMASK_ULL(51, 12) 36 37 #define PT_AD_MASK (PT_ACCESSED_MASK | PT_DIRTY_MASK) 38 39 #ifdef __x86_64__ 40 #define PAGE_LEVEL 4 41 #define PGDIR_WIDTH 9 42 #define PGDIR_MASK 511 43 #else 44 #define PAGE_LEVEL 2 45 #define PGDIR_WIDTH 10 46 #define PGDIR_MASK 1023 47 #endif 48 49 #define PGDIR_BITS(lvl) (((lvl) - 1) * PGDIR_WIDTH + PAGE_SHIFT) 50 #define PGDIR_OFFSET(va, lvl) (((va) >> PGDIR_BITS(lvl)) & PGDIR_MASK) 51 52 #endif /* !__ASSEMBLY__ */ 53 #endif 54