summaryrefslogtreecommitdiff
path: root/include/linux/kaiser.h
blob: b56c19010480b0f61b28c33b4b3cd2fa03513f82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _LINUX_KAISER_H
#define _LINUX_KAISER_H

#ifdef CONFIG_PAGE_TABLE_ISOLATION
#include <asm/kaiser.h>

static inline int kaiser_map_thread_stack(void *stack)
{
	/*
	 * Map that page of kernel stack on which we enter from user context.
	 */
	return kaiser_add_mapping((unsigned long)stack +
			THREAD_SIZE - PAGE_SIZE, PAGE_SIZE, __PAGE_KERNEL);
}

static inline void kaiser_unmap_thread_stack(void *stack)
{
	/*
	 * Note: may be called even when kaiser_map_thread_stack() failed.
	 */
	kaiser_remove_mapping((unsigned long)stack +
			THREAD_SIZE - PAGE_SIZE, PAGE_SIZE);
}
#else

/*
 * These stubs are used whenever CONFIG_PAGE_TABLE_ISOLATION is off, which
 * includes architectures that support KAISER, but have it disabled.
 */

static inline void kaiser_init(void)
{
}
static inline int kaiser_add_mapping(unsigned long addr,
				     unsigned long size, u64 flags)
{
	return 0;
}
static inline void kaiser_remove_mapping(unsigned long start,
					 unsigned long size)
{
}
static inline int kaiser_map_thread_stack(void *stack)
{
	return 0;
}
static inline void kaiser_unmap_thread_stack(void *stack)
{
}

#endif /* !CONFIG_PAGE_TABLE_ISOLATION */
#endif /* _LINUX_KAISER_H */