aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/desc.h
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:31:14 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:14 -0500
commit881c2975d02b6575c417a6eee40868d60a9ecba9 (patch)
tree402785bef46e3051aca5d006eaddbf0b99aff502 /include/asm-x86/desc.h
parent59fbed775aa5a6f352bfbde6b40508b541086b7e (diff)
x86: unify non-paravirt parts of desc.h
This patch unifies the non-paravirt part of desc_{32,64}.h into desc.h. Most of it, is simply common code, that is moved to the shared header. The only exception is the set_ldt_desc in desc_64.h, which is changed - included its name - to accomodate for the way the ldt is set up in i386. Also, constant definitions used in desc_32.h are moved to desc_defs.h Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86/desc.h')
-rw-r--r--include/asm-x86/desc.h65
1 files changed, 64 insertions, 1 deletions
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
index 47086d2d9298..99c4adc851e2 100644
--- a/include/asm-x86/desc.h
+++ b/include/asm-x86/desc.h
@@ -4,6 +4,7 @@
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5#include <asm/desc_defs.h> 5#include <asm/desc_defs.h>
6#include <asm/ldt.h> 6#include <asm/ldt.h>
7#include <asm/mmu.h>
7 8
8static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info) 9static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
9{ 10{
@@ -23,7 +24,8 @@ static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
23 desc->base2 = (info->base_addr & 0xff000000) >> 24; 24 desc->base2 = (info->base_addr & 0xff000000) >> 24;
24} 25}
25 26
26#endif 27extern struct desc_ptr idt_descr;
28extern gate_desc idt_table[];
27 29
28#ifdef CONFIG_X86_32 30#ifdef CONFIG_X86_32
29# include "desc_32.h" 31# include "desc_32.h"
@@ -31,4 +33,65 @@ static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
31# include "desc_64.h" 33# include "desc_64.h"
32#endif 34#endif
33 35
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
72#else
73/*
74 * GET_DESC_BASE reads the descriptor base of the specified segment.
75 *
76 * Args:
77 * idx - descriptor index
78 * gdt - GDT pointer
79 * base - 32bit register to which the base will be written
80 * lo_w - lo word of the "base" register
81 * lo_b - lo byte of the "base" register
82 * hi_b - hi byte of the low word of the "base" register
83 *
84 * Example:
85 * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
86 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
87 */
88#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
89 movb idx*8+4(gdt), lo_b; \
90 movb idx*8+7(gdt), hi_b; \
91 shll $16, base; \
92 movw idx*8+2(gdt), lo_w;
93
94
95#endif /* __ASSEMBLY__ */
96
34#endif 97#endif