aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/ldt.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2008-01-30 07:33:14 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:14 -0500
commit4dbf7af6442a9a882855bed0d999659ac413e3ac (patch)
tree333c2fa09ac2740ef8c260053a0c1e6340361d52 /arch/x86/kernel/ldt.c
parentc0400030b28e95fd477fdfe8ba8acb0af21e5c15 (diff)
x86: adjust/fix LDT handling for Xen
Based on patch from Jan Beulich <jbeulich@novell.com>. Don't rely on kmalloc(PAGE_SIZE) returning PAGE_SIZE aligned memory (Xen requires GDT *and* LDT to be page-aligned). Using the page allocator interface also removes the (albeit small) slab allocator overhead. The same change being done for 64-bits for consistency. Further, the Xen hypercall interface expects the LDT address to be virtual, not machine. [ Adjusted to unified ldt.c - Jeremy ] Signed-off-by: Jan Beulich <jbeulich@novell.com> Acked-by: Jeremy Fitzhardinge <jeremy@xensource.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/ldt.c')
-rw-r--r--arch/x86/kernel/ldt.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index b8ef46270e24..8a7660c8394a 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -12,7 +12,6 @@
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/vmalloc.h> 14#include <linux/vmalloc.h>
15#include <linux/slab.h>
16 15
17#include <asm/uaccess.h> 16#include <asm/uaccess.h>
18#include <asm/system.h> 17#include <asm/system.h>
@@ -40,7 +39,7 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
40 if (mincount * LDT_ENTRY_SIZE > PAGE_SIZE) 39 if (mincount * LDT_ENTRY_SIZE > PAGE_SIZE)
41 newldt = vmalloc(mincount * LDT_ENTRY_SIZE); 40 newldt = vmalloc(mincount * LDT_ENTRY_SIZE);
42 else 41 else
43 newldt = kmalloc(mincount * LDT_ENTRY_SIZE, GFP_KERNEL); 42 newldt = (void *)__get_free_page(GFP_KERNEL);
44 43
45 if (!newldt) 44 if (!newldt)
46 return -ENOMEM; 45 return -ENOMEM;
@@ -78,7 +77,7 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
78 if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE) 77 if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE)
79 vfree(oldldt); 78 vfree(oldldt);
80 else 79 else
81 kfree(oldldt); 80 put_page(virt_to_page(oldldt));
82 } 81 }
83 return 0; 82 return 0;
84} 83}
@@ -129,7 +128,7 @@ void destroy_context(struct mm_struct *mm)
129 if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE) 128 if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE)
130 vfree(mm->context.ldt); 129 vfree(mm->context.ldt);
131 else 130 else
132 kfree(mm->context.ldt); 131 put_page(virt_to_page(mm->context.ldt));
133 mm->context.size = 0; 132 mm->context.size = 0;
134 } 133 }
135} 134}