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 #define PAGE_SHIFT 12 14 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 15 #define PAGE_MASK (~(PAGE_SIZE-1)) 16 17 #ifndef __ASSEMBLY__ 18 19 #ifdef __x86_64__ 20 #define LARGE_PAGE_SIZE (512 * PAGE_SIZE) 21 #else 22 #define LARGE_PAGE_SIZE (1024 * PAGE_SIZE) 23 #endif 24 25 #define PT_PRESENT_MASK (1ull << 0) 26 #define PT_WRITABLE_MASK (1ull << 1) 27 #define PT_USER_MASK (1ull << 2) 28 #define PT_ACCESSED_MASK (1ull << 5) 29 #define PT_DIRTY_MASK (1ull << 6) 30 #define PT_PAGE_SIZE_MASK (1ull << 7) 31 #define PT64_NX_MASK (1ull << 63) 32 #define PT_ADDR_MASK GENMASK_ULL(51, 12) 33 34 #define PT_AD_MASK (PT_ACCESSED_MASK | PT_DIRTY_MASK) 35 36 #ifdef __x86_64__ 37 #define PAGE_LEVEL 4 38 #define PGDIR_WIDTH 9 39 #define PGDIR_MASK 511 40 #else 41 #define PAGE_LEVEL 2 42 #define PGDIR_WIDTH 10 43 #define PGDIR_MASK 1023 44 #endif 45 46 #define PGDIR_BITS(lvl) (((lvl) - 1) * PGDIR_WIDTH + PAGE_SHIFT) 47 #define PGDIR_OFFSET(va, lvl) (((va) >> PGDIR_BITS(lvl)) & PGDIR_MASK) 48 49 #endif /* !__ASSEMBLY__ */ 50 #endif 51