]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/x86/include/asm/mpx.h
Merge tag 'jfs-4.13' of git://github.com/kleikamp/linux-shaggy
[mirror_ubuntu-artful-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>
589ee628
IM
5#include <linux/mm_types.h>
6
57319d80 7#include <asm/ptrace.h>
fcc7ffd6 8#include <asm/insn.h>
57319d80 9
fe3d197f
DH
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
613fcb7d
DH
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.
57319d80 24 */
613fcb7d
DH
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)
57319d80 28
613fcb7d
DH
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)
57319d80 36
613fcb7d
DH
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)
57319d80 44
613fcb7d
DH
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)
57319d80 52
fe3d197f
DH
53#define MPX_BNDSTA_TAIL 2
54#define MPX_BNDCFG_TAIL 12
55#define MPX_BNDSTA_ADDR_MASK (~((1UL<<MPX_BNDSTA_TAIL)-1))
fe3d197f 56#define MPX_BNDCFG_ADDR_MASK (~((1UL<<MPX_BNDCFG_TAIL)-1))
57319d80
QR
57#define MPX_BNDSTA_ERROR_CODE 0x3
58
fcc7ffd6 59#ifdef CONFIG_X86_INTEL_MPX
46a6e0cf
DH
60siginfo_t *mpx_generate_siginfo(struct pt_regs *regs);
61int mpx_handle_bd_fault(void);
fe3d197f
DH
62static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
63{
cb02de96 64 return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR);
fe3d197f
DH
65}
66static 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 */
cb02de96 72 mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR;
fe3d197f 73}
1de4fa14
DH
74void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
75 unsigned long start, unsigned long end);
fcc7ffd6 76#else
46a6e0cf 77static inline siginfo_t *mpx_generate_siginfo(struct pt_regs *regs)
fcc7ffd6
DH
78{
79 return NULL;
80}
46a6e0cf 81static inline int mpx_handle_bd_fault(void)
fe3d197f
DH
82{
83 return -EINVAL;
84}
85static inline int kernel_managing_mpx_tables(struct mm_struct *mm)
86{
87 return 0;
88}
89static inline void mpx_mm_init(struct mm_struct *mm)
90{
91}
1de4fa14
DH
92static inline void mpx_notify_unmap(struct mm_struct *mm,
93 struct vm_area_struct *vma,
94 unsigned long start, unsigned long end)
95{
96}
fcc7ffd6
DH
97#endif /* CONFIG_X86_INTEL_MPX */
98
57319d80 99#endif /* _ASM_X86_MPX_H */