x86: modify get_desc_base
[deliverable/linux.git] / include / asm-x86 / desc.h
CommitLineData
80fbb69a
GOC
1#ifndef _ASM_DESC_H_
2#define _ASM_DESC_H_
3
4#ifndef __ASSEMBLY__
5#include <asm/desc_defs.h>
6#include <asm/ldt.h>
881c2975 7#include <asm/mmu.h>
80fbb69a
GOC
8
9static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
10{
11 desc->limit0 = info->limit & 0x0ffff;
12 desc->base0 = info->base_addr & 0x0000ffff;
13
14 desc->base1 = (info->base_addr & 0x00ff0000) >> 16;
15 desc->type = (info->read_exec_only ^ 1) << 1;
16 desc->type |= info->contents << 2;
17 desc->s = 1;
18 desc->dpl = 0x3;
19 desc->p = info->seg_not_present ^ 1;
20 desc->limit = (info->limit & 0xf0000) >> 16;
21 desc->avl = info->useable;
22 desc->d = info->seg_32bit;
23 desc->g = info->limit_in_pages;
24 desc->base2 = (info->base_addr & 0xff000000) >> 24;
25}
26
881c2975
GOC
27extern struct desc_ptr idt_descr;
28extern gate_desc idt_table[];
80fbb69a 29
96a388de
TG
30#ifdef CONFIG_X86_32
31# include "desc_32.h"
32#else
33# include "desc_64.h"
34#endif
80fbb69a 35
881c2975
GOC
36#define _LDT_empty(info) (\
37 (info)->base_addr == 0 && \
38 (info)->limit == 0 && \
39 (info)->contents == 0 && \
40 (info)->read_exec_only == 1 && \
41 (info)->seg_32bit == 0 && \
42 (info)->limit_in_pages == 0 && \
43 (info)->seg_not_present == 1 && \
44 (info)->useable == 0)
45
46#ifdef CONFIG_X86_64
47#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0))
48#else
49#define LDT_empty(info) (_LDT_empty(info))
50#endif
51
52static inline void clear_LDT(void)
53{
54 set_ldt(NULL, 0);
55}
56
57/*
58 * load one particular LDT into the current CPU
59 */
60static inline void load_LDT_nolock(mm_context_t *pc)
61{
62 set_ldt(pc->ldt, pc->size);
63}
64
65static inline void load_LDT(mm_context_t *pc)
66{
67 preempt_disable();
68 load_LDT_nolock(pc);
69 preempt_enable();
70}
71
cc697852
GOC
72static inline unsigned long get_desc_base(struct desc_struct *desc)
73{
74 return desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24);
75}
76
881c2975
GOC
77#else
78/*
79 * GET_DESC_BASE reads the descriptor base of the specified segment.
80 *
81 * Args:
82 * idx - descriptor index
83 * gdt - GDT pointer
84 * base - 32bit register to which the base will be written
85 * lo_w - lo word of the "base" register
86 * lo_b - lo byte of the "base" register
87 * hi_b - hi byte of the low word of the "base" register
88 *
89 * Example:
90 * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
91 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
92 */
93#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
94 movb idx*8+4(gdt), lo_b; \
95 movb idx*8+7(gdt), hi_b; \
96 shll $16, base; \
97 movw idx*8+2(gdt), lo_w;
98
99
100#endif /* __ASSEMBLY__ */
101
80fbb69a 102#endif
This page took 0.067391 seconds and 5 git commands to generate.