blob: b56c19010480b0f61b28c33b4b3cd2fa03513f82 [file] [log] [blame]
Hugh Dickins0994a2c2017-09-03 18:57:03 -07001#ifndef _LINUX_KAISER_H
2#define _LINUX_KAISER_H
Dave Hansen8f0baad2017-08-30 16:23:00 -07003
Kees Cooke71fac02018-01-03 10:17:35 -08004#ifdef CONFIG_PAGE_TABLE_ISOLATION
Dave Hansen8f0baad2017-08-30 16:23:00 -07005#include <asm/kaiser.h>
Hugh Dickins0994a2c2017-09-03 18:57:03 -07006
7static 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
16static 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 Hansen8f0baad2017-08-30 16:23:00 -070024#else
25
26/*
Kees Cooke71fac02018-01-03 10:17:35 -080027 * These stubs are used whenever CONFIG_PAGE_TABLE_ISOLATION is off, which
Hugh Dickins0994a2c2017-09-03 18:57:03 -070028 * includes architectures that support KAISER, but have it disabled.
Dave Hansen8f0baad2017-08-30 16:23:00 -070029 */
30
31static inline void kaiser_init(void)
32{
33}
Hugh Dickins0994a2c2017-09-03 18:57:03 -070034static inline int kaiser_add_mapping(unsigned long addr,
Arnd Bergmann95a440b2018-02-15 16:16:57 +010035 unsigned long size, u64 flags)
Dave Hansen8f0baad2017-08-30 16:23:00 -070036{
37 return 0;
38}
Hugh Dickins0994a2c2017-09-03 18:57:03 -070039static inline void kaiser_remove_mapping(unsigned long start,
40 unsigned long size)
41{
42}
43static inline int kaiser_map_thread_stack(void *stack)
44{
45 return 0;
46}
47static inline void kaiser_unmap_thread_stack(void *stack)
48{
49}
Dave Hansen8f0baad2017-08-30 16:23:00 -070050
Kees Cooke71fac02018-01-03 10:17:35 -080051#endif /* !CONFIG_PAGE_TABLE_ISOLATION */
Hugh Dickins0994a2c2017-09-03 18:57:03 -070052#endif /* _LINUX_KAISER_H */