Merge tag 'pm-4.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
[linux/fpc-iii.git] / arch / x86 / include / asm / mpx.h
bloba0d662be4c5b8545a7b0b8c5c846187ced8d0020
1 #ifndef _ASM_X86_MPX_H
2 #define _ASM_X86_MPX_H
4 #include <linux/types.h>
5 #include <linux/mm_types.h>
7 #include <asm/ptrace.h>
8 #include <asm/insn.h>
11 * NULL is theoretically a valid place to put the bounds
12 * directory, so point this at an invalid address.
14 #define MPX_INVALID_BOUNDS_DIR ((void __user *)-1)
15 #define MPX_BNDCFG_ENABLE_FLAG 0x1
16 #define MPX_BD_ENTRY_VALID_FLAG 0x1
19 * The upper 28 bits [47:20] of the virtual address in 64-bit
20 * are used to index into bounds directory (BD).
22 * The directory is 2G (2^31) in size, and with 8-byte entries
23 * it has 2^28 entries.
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)
30 * The 32-bit directory is 4MB (2^22) in size, and with 4-byte
31 * entries it has 2^20 entries.
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)
38 * A 64-bit table is 4MB total in size, and an entry is
39 * 4 64-bit pointers in size.
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)
46 * A 32-bit table is 16kB total in size, and an entry is
47 * 4 32-bit pointers in size.
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)
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
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)
64 return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR);
66 static inline void mpx_mm_init(struct mm_struct *mm)
69 * NULL is theoretically a valid place to put the bounds
70 * directory, so point this at an invalid address.
72 mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR;
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)
79 return NULL;
81 static inline int mpx_handle_bd_fault(void)
83 return -EINVAL;
85 static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
87 return 0;
89 static inline void mpx_mm_init(struct mm_struct *mm)
92 static inline void mpx_notify_unmap(struct mm_struct *mm,
93 struct vm_area_struct *vma,
94 unsigned long start, unsigned long end)
97 #endif /* CONFIG_X86_INTEL_MPX */
99 #endif /* _ASM_X86_MPX_H */