]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/x86/include/asm/desc_defs.h
Merge tag 'befs-v4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/luisbg...
[mirror_ubuntu-artful-kernel.git] / arch / x86 / include / asm / desc_defs.h
CommitLineData
249e83fe 1/* Written 2000 by Andi Kleen */
1965aae3
PA
2#ifndef _ASM_X86_DESC_DEFS_H
3#define _ASM_X86_DESC_DEFS_H
249e83fe
AK
4
5/*
6 * Segment descriptor structure definitions, usable from both x86_64 and i386
7 * archs.
8 */
9
10#ifndef __ASSEMBLY__
11
12#include <linux/types.h>
13
6842ef0e 14/*
af901ca1 15 * FIXME: Accessing the desc_struct through its fields is more elegant,
6842ef0e 16 * and should be the one valid thing to do. However, a lot of open code
af901ca1 17 * still touches the a and b accessors, and doing this allow us to do it
03440c4e 18 * incrementally. We keep the signature as a struct, rather than a union,
6842ef0e
GOC
19 * so we can get rid of it transparently in the future -- glommer
20 */
b7761900 21/* 8 byte segment descriptor */
249e83fe 22struct desc_struct {
6842ef0e 23 union {
b7761900
JP
24 struct {
25 unsigned int a;
26 unsigned int b;
27 };
6842ef0e
GOC
28 struct {
29 u16 limit0;
30 u16 base0;
31 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
32 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
33 };
6842ef0e
GOC
34 };
35} __attribute__((packed));
249e83fe 36
1e5de182
AM
37#define GDT_ENTRY_INIT(flags, base, limit) { { { \
38 .a = ((limit) & 0xffff) | (((base) & 0xffff) << 16), \
39 .b = (((base) & 0xff0000) >> 16) | (((flags) & 0xf0ff) << 8) | \
40 ((limit) & 0xf0000) | ((base) & 0xff000000), \
41 } } }
42
249e83fe
AK
43enum {
44 GATE_INTERRUPT = 0xE,
45 GATE_TRAP = 0xF,
46 GATE_CALL = 0xC,
507f90c9 47 GATE_TASK = 0x5,
249e83fe
AK
48};
49
b7761900 50/* 16byte gate */
010d4f82 51struct gate_struct64 {
249e83fe
AK
52 u16 offset_low;
53 u16 segment;
54 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
55 u16 offset_middle;
56 u32 offset_high;
57 u32 zero1;
58} __attribute__((packed));
59
54cd0eac
GOC
60#define PTR_LOW(x) ((unsigned long long)(x) & 0xFFFF)
61#define PTR_MIDDLE(x) (((unsigned long long)(x) >> 16) & 0xFFFF)
62#define PTR_HIGH(x) ((unsigned long long)(x) >> 32)
249e83fe
AK
63
64enum {
65 DESC_TSS = 0x9,
66 DESC_LDT = 0x2,
b7761900 67 DESCTYPE_S = 0x10, /* !system */
249e83fe
AK
68};
69
b7761900 70/* LDT or TSS descriptor in the GDT. 16 bytes. */
25deca53 71struct ldttss_desc64 {
249e83fe
AK
72 u16 limit0;
73 u16 base0;
74 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
75 unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
76 u32 base3;
77 u32 zero1;
78} __attribute__((packed));
79
010d4f82
GOC
80#ifdef CONFIG_X86_64
81typedef struct gate_struct64 gate_desc;
25deca53 82typedef struct ldttss_desc64 ldt_desc;
18245d5b 83typedef struct ldttss_desc64 tss_desc;
43adfc26
JF
84#define gate_offset(g) ((g).offset_low | ((unsigned long)(g).offset_middle << 16) | ((unsigned long)(g).offset_high << 32))
85#define gate_segment(g) ((g).segment)
010d4f82
GOC
86#else
87typedef struct desc_struct gate_desc;
25deca53 88typedef struct desc_struct ldt_desc;
18245d5b 89typedef struct desc_struct tss_desc;
43adfc26
JF
90#define gate_offset(g) (((g).b & 0xffff0000) | ((g).a & 0x0000ffff))
91#define gate_segment(g) ((g).a >> 16)
010d4f82
GOC
92#endif
93
249e83fe
AK
94struct desc_ptr {
95 unsigned short size;
96 unsigned long address;
97} __attribute__((packed)) ;
98
249e83fe
AK
99#endif /* !__ASSEMBLY__ */
100
8ff5bd2e
AL
101/* Access rights as returned by LAR */
102#define AR_TYPE_RODATA (0 * (1 << 9))
103#define AR_TYPE_RWDATA (1 * (1 << 9))
104#define AR_TYPE_RODATA_EXPDOWN (2 * (1 << 9))
105#define AR_TYPE_RWDATA_EXPDOWN (3 * (1 << 9))
106#define AR_TYPE_XOCODE (4 * (1 << 9))
107#define AR_TYPE_XRCODE (5 * (1 << 9))
108#define AR_TYPE_XOCODE_CONF (6 * (1 << 9))
109#define AR_TYPE_XRCODE_CONF (7 * (1 << 9))
110#define AR_TYPE_MASK (7 * (1 << 9))
111
112#define AR_DPL0 (0 * (1 << 13))
113#define AR_DPL3 (3 * (1 << 13))
114#define AR_DPL_MASK (3 * (1 << 13))
115
116#define AR_A (1 << 8) /* "Accessed" */
117#define AR_S (1 << 12) /* If clear, "System" segment */
118#define AR_P (1 << 15) /* "Present" */
119#define AR_AVL (1 << 20) /* "AVaiLable" (no HW effect) */
120#define AR_L (1 << 21) /* "Long mode" for code segments */
121#define AR_DB (1 << 22) /* D/B, effect depends on type */
122#define AR_G (1 << 23) /* "Granularity" (limit in pages) */
123
1965aae3 124#endif /* _ASM_X86_DESC_DEFS_H */