Browse Source

x86: introduce ldt_write accessor

Create a ldt write accessor like the 32 bit one.

Preparatory patch for merging ldt.c and anyway necessary for
64bit paravirt ops.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Thomas Gleixner 17 years ago
parent
commit
fc2d625c4f
2 changed files with 12 additions and 5 deletions
  1. 3 5
      arch/x86/kernel/ldt_64.c
  2. 9 0
      include/asm-x86/desc_64.h

+ 3 - 5
arch/x86/kernel/ldt_64.c

@@ -172,7 +172,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
 {
 {
 	struct task_struct *me = current;
 	struct task_struct *me = current;
 	struct mm_struct *mm = me->mm;
 	struct mm_struct *mm = me->mm;
-	__u32 entry_1, entry_2, *lp;
+	__u32 entry_1, entry_2;
 	int error;
 	int error;
 	struct user_desc ldt_info;
 	struct user_desc ldt_info;
 
 
@@ -202,8 +202,6 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
 			goto out_unlock;
 			goto out_unlock;
 	}
 	}
 
 
-	lp = (__u32 *)((ldt_info.entry_number << 3) + (char *)mm->context.ldt);
-
 	/* Allow LDTs to be cleared by the user. */
 	/* Allow LDTs to be cleared by the user. */
 	if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
 	if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
 		if (oldmode || LDT_empty(&ldt_info)) {
 		if (oldmode || LDT_empty(&ldt_info)) {
@@ -220,8 +218,8 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
 
 
 	/* Install the new entry ...  */
 	/* Install the new entry ...  */
 install:
 install:
-	*lp	= entry_1;
-	*(lp+1)	= entry_2;
+	write_ldt_entry(mm->context.ldt, ldt_info.entry_number, entry_1,
+			entry_2);
 	error = 0;
 	error = 0;
 
 
 out_unlock:
 out_unlock:

+ 9 - 0
include/asm-x86/desc_64.h

@@ -38,6 +38,15 @@ extern struct desc_struct default_ldt[];
 extern struct gate_struct idt_table[];
 extern struct gate_struct idt_table[];
 extern struct desc_ptr cpu_gdt_descr[];
 extern struct desc_ptr cpu_gdt_descr[];
 
 
+static inline void write_ldt_entry(struct desc_struct *ldt,
+				   int entry, u32 entry_low, u32 entry_high)
+{
+	__u32 *lp = (__u32 *)((entry << 3) + (char *)ldt);
+
+	lp[0] = entry_low;
+	lp[1] = entry_high;
+}
+
 /* the cpu gdt accessor */
 /* the cpu gdt accessor */
 #define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)
 #define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)