Commit cc697852 authored by Glauber de Oliveira Costa's avatar Glauber de Oliveira Costa Committed by Ingo Molnar

x86: modify get_desc_base

This patch makes get_desc_base() receive a struct desc_struct,
and then uses its internal fields to compute the base address.
This is done at both i386 and x86_64, and then it is moved
to common header
Signed-off-by: default avatarGlauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 26048d75
...@@ -112,7 +112,7 @@ int do_get_thread_area(struct task_struct *p, int idx, ...@@ -112,7 +112,7 @@ int do_get_thread_area(struct task_struct *p, int idx,
memset(&info, 0, sizeof(struct user_desc)); memset(&info, 0, sizeof(struct user_desc));
info.entry_number = idx; info.entry_number = idx;
info.base_addr = get_desc_base((void *)desc); info.base_addr = get_desc_base((struct desc_struct *)desc);
info.limit = GET_LIMIT(desc); info.limit = GET_LIMIT(desc);
info.seg_32bit = GET_32BIT(desc); info.seg_32bit = GET_32BIT(desc);
info.contents = GET_CONTENTS(desc); info.contents = GET_CONTENTS(desc);
......
...@@ -115,7 +115,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs, ...@@ -115,7 +115,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
} }
/* Decode the code segment base from the descriptor */ /* Decode the code segment base from the descriptor */
base = get_desc_base((unsigned long *)desc); base = get_desc_base((struct desc_struct *)desc);
if (seg & (1<<2)) { if (seg & (1<<2)) {
mutex_unlock(&current->mm->context.lock); mutex_unlock(&current->mm->context.lock);
......
...@@ -69,6 +69,11 @@ static inline void load_LDT(mm_context_t *pc) ...@@ -69,6 +69,11 @@ static inline void load_LDT(mm_context_t *pc)
preempt_enable(); preempt_enable();
} }
static inline unsigned long get_desc_base(struct desc_struct *desc)
{
return desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24);
}
#else #else
/* /*
* GET_DESC_BASE reads the descriptor base of the specified segment. * GET_DESC_BASE reads the descriptor base of the specified segment.
......
...@@ -168,14 +168,6 @@ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const vo ...@@ -168,14 +168,6 @@ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const vo
#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr) #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
static inline unsigned long get_desc_base(unsigned long *desc)
{
unsigned long base;
base = ((desc[0] >> 16) & 0x0000ffff) |
((desc[1] << 16) & 0x00ff0000) |
(desc[1] & 0xff000000);
return base;
}
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#endif #endif
...@@ -156,15 +156,6 @@ static inline void load_TLS(struct thread_struct *t, unsigned int cpu) ...@@ -156,15 +156,6 @@ static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
gdt[i] = t->tls_array[i]; gdt[i] = t->tls_array[i];
} }
static inline unsigned long get_desc_base(const void *ptr)
{
const u32 *desc = ptr;
unsigned long base;
base = ((desc[0] >> 16) & 0x0000ffff) |
((desc[1] << 16) & 0x00ff0000) |
(desc[1] & 0xff000000);
return base;
}
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment