]> Pileus Git - ~andy/linux/commitdiff
x86: introduce fill_ldt
authorGlauber de Oliveira Costa <gcosta@redhat.com>
Wed, 30 Jan 2008 12:31:13 +0000 (13:31 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:31:13 +0000 (13:31 +0100)
This patch introduces fill_ldt(), which populates a ldt descriptor
from a user_desc in once, instead of relying in the LDT_entry_a and
LDT_entry_b macros

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>
arch/x86/kernel/ldt.c
arch/x86/kernel/process_64.c
arch/x86/kernel/tls.c
include/asm-x86/desc.h
include/asm-x86/desc_32.h
include/asm-x86/desc_64.h

index 7eb0c8a457341c6fbe519281074f01939daf5a77..3e872b46853333a31a952b79aa3a921feeeb833a 100644 (file)
@@ -223,8 +223,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
                }
        }
 
-       ldt.a = LDT_entry_a(&ldt_info);
-       ldt.b = LDT_entry_b(&ldt_info);
+       fill_ldt(&ldt, &ldt_info);
        if (oldmode)
                ldt.avl = 0;
 
index 86c310acc9891203f08de6ace903c0d238a84479..f91521e26335d11f2139ffd9a9f207c6b0486bcc 100644 (file)
@@ -457,8 +457,7 @@ static inline void set_32bit_tls(struct task_struct *t, int tls, u32 addr)
        };
        struct desc_struct *desc = (void *)t->thread.tls_array;
        desc += tls;
-       desc->a = LDT_entry_a(&ud);
-       desc->b = LDT_entry_b(&ud);
+       fill_ldt(desc, &ud);
 }
 
 static inline u32 read_32bit_tls(struct task_struct *t, int tls)
index 67a377621b129df6a414d7f8f999cc9965dbe5c8..74d2b65a82eb8e975e83e73f6ee86220bdaa7e78 100644 (file)
@@ -67,10 +67,9 @@ int do_set_thread_area(struct task_struct *p, int idx,
        if (LDT_empty(&info)) {
                desc[0] = 0;
                desc[1] = 0;
-       } else {
-               desc[0] = LDT_entry_a(&info);
-               desc[1] = LDT_entry_b(&info);
-       }
+       } else
+               fill_ldt((struct desc_struct *)desc, &info);
+
        if (t == &current->thread)
                load_TLS(t, cpu);
 
index 6065c5092265b6d42602e4f431fffa2b931e0e8b..47086d2d92985fae6551ea8790cf1b47ce1c38b0 100644 (file)
@@ -1,5 +1,34 @@
+#ifndef _ASM_DESC_H_
+#define _ASM_DESC_H_
+
+#ifndef __ASSEMBLY__
+#include <asm/desc_defs.h>
+#include <asm/ldt.h>
+
+static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
+{
+       desc->limit0 = info->limit & 0x0ffff;
+       desc->base0 = info->base_addr & 0x0000ffff;
+
+       desc->base1 = (info->base_addr & 0x00ff0000) >> 16;
+       desc->type = (info->read_exec_only ^ 1) << 1;
+       desc->type |= info->contents << 2;
+       desc->s = 1;
+       desc->dpl = 0x3;
+       desc->p = info->seg_not_present ^ 1;
+       desc->limit = (info->limit & 0xf0000) >> 16;
+       desc->avl = info->useable;
+       desc->d = info->seg_32bit;
+       desc->g = info->limit_in_pages;
+       desc->base2 = (info->base_addr & 0xff000000) >> 24;
+}
+
+#endif
+
 #ifdef CONFIG_X86_32
 # include "desc_32.h"
 #else
 # include "desc_64.h"
 #endif
+
+#endif
index 54b2314f2ddf0f9e2cd4aab445be9a3cd15b8b8c..03700991c5db4d1a81d59b94839129597c0969d5 100644 (file)
@@ -163,21 +163,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 LDT_entry_a(info) \
-       ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
-
-#define LDT_entry_b(info) \
-       (((info)->base_addr & 0xff000000) | \
-       (((info)->base_addr & 0x00ff0000) >> 16) | \
-       ((info)->limit & 0xf0000) | \
-       (((info)->read_exec_only ^ 1) << 9) | \
-       ((info)->contents << 10) | \
-       (((info)->seg_not_present ^ 1) << 15) | \
-       ((info)->seg_32bit << 22) | \
-       ((info)->limit_in_pages << 23) | \
-       ((info)->useable << 20) | \
-       0x7000)
-
 #define LDT_empty(info) (\
        (info)->base_addr       == 0    && \
        (info)->limit           == 0    && \
index c49f928ed8b6963fdd9a2ca62ce9f93522f96ce1..ba7fb87d10f3bea13a32a90f2bd727c8cf9ea1ac 100644 (file)
@@ -147,23 +147,6 @@ static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
                             (unsigned long)addr, DESC_LDT, size * 8 - 1);
 }
 
-#define LDT_entry_a(info) \
-       ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
-/* Don't allow setting of the lm bit. It is useless anyways because
-   64bit system calls require __USER_CS. */
-#define LDT_entry_b(info) \
-       (((info)->base_addr & 0xff000000) | \
-       (((info)->base_addr & 0x00ff0000) >> 16) | \
-       ((info)->limit & 0xf0000) | \
-       (((info)->read_exec_only ^ 1) << 9) | \
-       ((info)->contents << 10) | \
-       (((info)->seg_not_present ^ 1) << 15) | \
-       ((info)->seg_32bit << 22) | \
-       ((info)->limit_in_pages << 23) | \
-       ((info)->useable << 20) | \
-       /* ((info)->lm << 21) | */ \
-       0x7000)
-
 #define LDT_empty(info) (\
        (info)->base_addr       == 0    && \
        (info)->limit           == 0    && \