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