This source file includes following definitions.
- kernel_managing_mpx_tables
- mpx_mm_init
- mpx_fault_info
- mpx_handle_bd_fault
- kernel_managing_mpx_tables
- mpx_mm_init
- mpx_notify_unmap
- mpx_unmapped_area_check
1
2 #ifndef _ASM_X86_MPX_H
3 #define _ASM_X86_MPX_H
4
5 #include <linux/types.h>
6 #include <linux/mm_types.h>
7
8 #include <asm/ptrace.h>
9 #include <asm/insn.h>
10
11
12
13
14
15 #define MPX_INVALID_BOUNDS_DIR ((void __user *)-1)
16 #define MPX_BNDCFG_ENABLE_FLAG 0x1
17 #define MPX_BD_ENTRY_VALID_FLAG 0x1
18
19
20
21
22
23
24
25
26 #define MPX_BD_SIZE_BYTES_64 (1UL<<31)
27 #define MPX_BD_ENTRY_BYTES_64 8
28 #define MPX_BD_NR_ENTRIES_64 (MPX_BD_SIZE_BYTES_64/MPX_BD_ENTRY_BYTES_64)
29
30
31
32
33
34 #define MPX_BD_SIZE_BYTES_32 (1UL<<22)
35 #define MPX_BD_ENTRY_BYTES_32 4
36 #define MPX_BD_NR_ENTRIES_32 (MPX_BD_SIZE_BYTES_32/MPX_BD_ENTRY_BYTES_32)
37
38
39
40
41
42 #define MPX_BT_SIZE_BYTES_64 (1UL<<22)
43 #define MPX_BT_ENTRY_BYTES_64 32
44 #define MPX_BT_NR_ENTRIES_64 (MPX_BT_SIZE_BYTES_64/MPX_BT_ENTRY_BYTES_64)
45
46
47
48
49
50 #define MPX_BT_SIZE_BYTES_32 (1UL<<14)
51 #define MPX_BT_ENTRY_BYTES_32 16
52 #define MPX_BT_NR_ENTRIES_32 (MPX_BT_SIZE_BYTES_32/MPX_BT_ENTRY_BYTES_32)
53
54 #define MPX_BNDSTA_TAIL 2
55 #define MPX_BNDCFG_TAIL 12
56 #define MPX_BNDSTA_ADDR_MASK (~((1UL<<MPX_BNDSTA_TAIL)-1))
57 #define MPX_BNDCFG_ADDR_MASK (~((1UL<<MPX_BNDCFG_TAIL)-1))
58 #define MPX_BNDSTA_ERROR_CODE 0x3
59
60 struct mpx_fault_info {
61 void __user *addr;
62 void __user *lower;
63 void __user *upper;
64 };
65
66 #ifdef CONFIG_X86_INTEL_MPX
67
68 extern int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs);
69 extern int mpx_handle_bd_fault(void);
70
71 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
72 {
73 return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR);
74 }
75
76 static inline void mpx_mm_init(struct mm_struct *mm)
77 {
78
79
80
81
82 mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR;
83 }
84
85 extern void mpx_notify_unmap(struct mm_struct *mm, unsigned long start, unsigned long end);
86 extern unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, unsigned long flags);
87
88 #else
89 static inline int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs)
90 {
91 return -EINVAL;
92 }
93 static inline int mpx_handle_bd_fault(void)
94 {
95 return -EINVAL;
96 }
97 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
98 {
99 return 0;
100 }
101 static inline void mpx_mm_init(struct mm_struct *mm)
102 {
103 }
104 static inline void mpx_notify_unmap(struct mm_struct *mm,
105 unsigned long start, unsigned long end)
106 {
107 }
108
109 static inline unsigned long mpx_unmapped_area_check(unsigned long addr,
110 unsigned long len, unsigned long flags)
111 {
112 return addr;
113 }
114 #endif
115
116 #endif