]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/x86/include/asm/mpx.h
Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into...
[mirror_ubuntu-artful-kernel.git] / arch / x86 / include / asm / mpx.h
1 #ifndef _ASM_X86_MPX_H
2 #define _ASM_X86_MPX_H
3
4 #include <linux/types.h>
5 #include <linux/mm_types.h>
6
7 #include <asm/ptrace.h>
8 #include <asm/insn.h>
9
10 /*
11 * NULL is theoretically a valid place to put the bounds
12 * directory, so point this at an invalid address.
13 */
14 #define MPX_INVALID_BOUNDS_DIR ((void __user *)-1)
15 #define MPX_BNDCFG_ENABLE_FLAG 0x1
16 #define MPX_BD_ENTRY_VALID_FLAG 0x1
17
18 /*
19 * The upper 28 bits [47:20] of the virtual address in 64-bit
20 * are used to index into bounds directory (BD).
21 *
22 * The directory is 2G (2^31) in size, and with 8-byte entries
23 * it has 2^28 entries.
24 */
25 #define MPX_BD_SIZE_BYTES_64 (1UL<<31)
26 #define MPX_BD_ENTRY_BYTES_64 8
27 #define MPX_BD_NR_ENTRIES_64 (MPX_BD_SIZE_BYTES_64/MPX_BD_ENTRY_BYTES_64)
28
29 /*
30 * The 32-bit directory is 4MB (2^22) in size, and with 4-byte
31 * entries it has 2^20 entries.
32 */
33 #define MPX_BD_SIZE_BYTES_32 (1UL<<22)
34 #define MPX_BD_ENTRY_BYTES_32 4
35 #define MPX_BD_NR_ENTRIES_32 (MPX_BD_SIZE_BYTES_32/MPX_BD_ENTRY_BYTES_32)
36
37 /*
38 * A 64-bit table is 4MB total in size, and an entry is
39 * 4 64-bit pointers in size.
40 */
41 #define MPX_BT_SIZE_BYTES_64 (1UL<<22)
42 #define MPX_BT_ENTRY_BYTES_64 32
43 #define MPX_BT_NR_ENTRIES_64 (MPX_BT_SIZE_BYTES_64/MPX_BT_ENTRY_BYTES_64)
44
45 /*
46 * A 32-bit table is 16kB total in size, and an entry is
47 * 4 32-bit pointers in size.
48 */
49 #define MPX_BT_SIZE_BYTES_32 (1UL<<14)
50 #define MPX_BT_ENTRY_BYTES_32 16
51 #define MPX_BT_NR_ENTRIES_32 (MPX_BT_SIZE_BYTES_32/MPX_BT_ENTRY_BYTES_32)
52
53 #define MPX_BNDSTA_TAIL 2
54 #define MPX_BNDCFG_TAIL 12
55 #define MPX_BNDSTA_ADDR_MASK (~((1UL<<MPX_BNDSTA_TAIL)-1))
56 #define MPX_BNDCFG_ADDR_MASK (~((1UL<<MPX_BNDCFG_TAIL)-1))
57 #define MPX_BNDSTA_ERROR_CODE 0x3
58
59 #ifdef CONFIG_X86_INTEL_MPX
60 siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
61 int mpx_handle_bd_fault(void);
62 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
63 {
64 return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR);
65 }
66 static inline void mpx_mm_init(struct mm_struct *mm)
67 {
68 /*
69 * NULL is theoretically a valid place to put the bounds
70 * directory, so point this at an invalid address.
71 */
72 mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR;
73 }
74 void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
75 unsigned long start, unsigned long end);
76 #else
77 static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
78 {
79 return NULL;
80 }
81 static inline int mpx_handle_bd_fault(void)
82 {
83 return -EINVAL;
84 }
85 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
86 {
87 return 0;
88 }
89 static inline void mpx_mm_init(struct mm_struct *mm)
90 {
91 }
92 static inline void mpx_notify_unmap(struct mm_struct *mm,
93 struct vm_area_struct *vma,
94 unsigned long start, unsigned long end)
95 {
96 }
97 #endif /* CONFIG_X86_INTEL_MPX */
98
99 #endif /* _ASM_X86_MPX_H */