Hugh Dickins | 0994a2c | 2017-09-03 18:57:03 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_KAISER_H |
| 2 | #define _LINUX_KAISER_H |
Dave Hansen | 8f0baad | 2017-08-30 16:23:00 -0700 | [diff] [blame] | 3 | |
Kees Cook | e71fac0 | 2018-01-03 10:17:35 -0800 | [diff] [blame] | 4 | #ifdef CONFIG_PAGE_TABLE_ISOLATION |
Dave Hansen | 8f0baad | 2017-08-30 16:23:00 -0700 | [diff] [blame] | 5 | #include <asm/kaiser.h> |
Hugh Dickins | 0994a2c | 2017-09-03 18:57:03 -0700 | [diff] [blame] | 6 | |
| 7 | static inline int kaiser_map_thread_stack(void *stack) |
| 8 | { |
| 9 | /* |
| 10 | * Map that page of kernel stack on which we enter from user context. |
| 11 | */ |
| 12 | return kaiser_add_mapping((unsigned long)stack + |
| 13 | THREAD_SIZE - PAGE_SIZE, PAGE_SIZE, __PAGE_KERNEL); |
| 14 | } |
| 15 | |
| 16 | static inline void kaiser_unmap_thread_stack(void *stack) |
| 17 | { |
| 18 | /* |
| 19 | * Note: may be called even when kaiser_map_thread_stack() failed. |
| 20 | */ |
| 21 | kaiser_remove_mapping((unsigned long)stack + |
| 22 | THREAD_SIZE - PAGE_SIZE, PAGE_SIZE); |
| 23 | } |
Dave Hansen | 8f0baad | 2017-08-30 16:23:00 -0700 | [diff] [blame] | 24 | #else |
| 25 | |
| 26 | /* |
Kees Cook | e71fac0 | 2018-01-03 10:17:35 -0800 | [diff] [blame] | 27 | * These stubs are used whenever CONFIG_PAGE_TABLE_ISOLATION is off, which |
Hugh Dickins | 0994a2c | 2017-09-03 18:57:03 -0700 | [diff] [blame] | 28 | * includes architectures that support KAISER, but have it disabled. |
Dave Hansen | 8f0baad | 2017-08-30 16:23:00 -0700 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | static inline void kaiser_init(void) |
| 32 | { |
| 33 | } |
Hugh Dickins | 0994a2c | 2017-09-03 18:57:03 -0700 | [diff] [blame] | 34 | static inline int kaiser_add_mapping(unsigned long addr, |
Arnd Bergmann | 95a440b | 2018-02-15 16:16:57 +0100 | [diff] [blame] | 35 | unsigned long size, u64 flags) |
Dave Hansen | 8f0baad | 2017-08-30 16:23:00 -0700 | [diff] [blame] | 36 | { |
| 37 | return 0; |
| 38 | } |
Hugh Dickins | 0994a2c | 2017-09-03 18:57:03 -0700 | [diff] [blame] | 39 | static inline void kaiser_remove_mapping(unsigned long start, |
| 40 | unsigned long size) |
| 41 | { |
| 42 | } |
| 43 | static inline int kaiser_map_thread_stack(void *stack) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | static inline void kaiser_unmap_thread_stack(void *stack) |
| 48 | { |
| 49 | } |
Dave Hansen | 8f0baad | 2017-08-30 16:23:00 -0700 | [diff] [blame] | 50 | |
Kees Cook | e71fac0 | 2018-01-03 10:17:35 -0800 | [diff] [blame] | 51 | #endif /* !CONFIG_PAGE_TABLE_ISOLATION */ |
Hugh Dickins | 0994a2c | 2017-09-03 18:57:03 -0700 | [diff] [blame] | 52 | #endif /* _LINUX_KAISER_H */ |