diff options
author | Jan Beulich <jbeulich@novell.com> | 2008-01-30 07:33:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:14 -0500 |
commit | 4dbf7af6442a9a882855bed0d999659ac413e3ac (patch) | |
tree | 333c2fa09ac2740ef8c260053a0c1e6340361d52 /arch/x86 | |
parent | c0400030b28e95fd477fdfe8ba8acb0af21e5c15 (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')
-rw-r--r-- | arch/x86/kernel/ldt.c | 7 | ||||
-rw-r--r-- | arch/x86/xen/enlighten.c | 9 |
2 files changed, 4 insertions, 12 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 | } |
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 72dd14d0685c..845b4fd94463 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -275,19 +275,12 @@ static unsigned long xen_store_tr(void) | |||
275 | 275 | ||
276 | static void xen_set_ldt(const void *addr, unsigned entries) | 276 | static void xen_set_ldt(const void *addr, unsigned entries) |
277 | { | 277 | { |
278 | unsigned long linear_addr = (unsigned long)addr; | ||
279 | struct mmuext_op *op; | 278 | struct mmuext_op *op; |
280 | struct multicall_space mcs = xen_mc_entry(sizeof(*op)); | 279 | struct multicall_space mcs = xen_mc_entry(sizeof(*op)); |
281 | 280 | ||
282 | op = mcs.args; | 281 | op = mcs.args; |
283 | op->cmd = MMUEXT_SET_LDT; | 282 | op->cmd = MMUEXT_SET_LDT; |
284 | if (linear_addr) { | 283 | op->arg1.linear_addr = (unsigned long)addr; |
285 | /* ldt my be vmalloced, use arbitrary_virt_to_machine */ | ||
286 | xmaddr_t maddr; | ||
287 | maddr = arbitrary_virt_to_machine((unsigned long)addr); | ||
288 | linear_addr = (unsigned long)maddr.maddr; | ||
289 | } | ||
290 | op->arg1.linear_addr = linear_addr; | ||
291 | op->arg2.nr_ents = entries; | 284 | op->arg2.nr_ents = entries; |
292 | 285 | ||
293 | MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); | 286 | MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); |