diff options
author | Jeff Dike <jdike@addtoit.com> | 2008-02-08 07:22:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:42 -0500 |
commit | 536788fe2d28e11db6aeda74207d95d750fb761f (patch) | |
tree | 73df2d3a46c542c71d3a84c20c8fd1ce617386a3 /arch/um/kernel | |
parent | 2f569afd9ced9ebec9a6eb3dbf6f83429be0a7b4 (diff) |
uml: runtime host VMSPLIT detection
Calculate TASK_SIZE at run-time by figuring out the host's VMSPLIT - this is
needed on i386 if UML is to run on hosts with varying VMSPLITs without
recompilation.
TASK_SIZE is now defined in terms of a variable, task_size. This gets rid of
an include of pgtable.h from processor.h, which can cause include loops.
On i386, task_size is calculated early in boot by probing the address space in
a binary search to figure out where the boundary between usable and non-usable
memory is. This tries to make sure that a page that is considered to be in
userspace is, or can be made, read-write. I'm concerned about a system-global
VDSO page in kernel memory being hit and considered to be a userspace page.
On x86_64, task_size is just the old value of CONFIG_TOP_ADDR.
A bunch of config variable are gone now. CONFIG_TOP_ADDR is directly replaced
by TASK_SIZE. NEST_LEVEL is gone since the relocation of the stubs makes it
irrelevant. All the HOST_VMSPLIT stuff is gone. All references to these in
arch/um/Makefile are also gone.
I noticed and fixed a missing extern in os.h when adding os_get_task_size.
Note: This has been revised to fix the 32-bit UML on 64-bit host bug that
Miklos ran into.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r-- | arch/um/kernel/exec.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/um_arch.c | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c index 76a62c0cb2bc..f5d7f4569ba7 100644 --- a/arch/um/kernel/exec.c +++ b/arch/um/kernel/exec.c | |||
@@ -25,7 +25,7 @@ void flush_thread(void) | |||
25 | 25 | ||
26 | ret = unmap(¤t->mm->context.id, 0, STUB_START, 0, &data); | 26 | ret = unmap(¤t->mm->context.id, 0, STUB_START, 0, &data); |
27 | ret = ret || unmap(¤t->mm->context.id, STUB_END, | 27 | ret = ret || unmap(¤t->mm->context.id, STUB_END, |
28 | TASK_SIZE - STUB_END, 1, &data); | 28 | host_task_size - STUB_END, 1, &data); |
29 | if (ret) { | 29 | if (ret) { |
30 | printk(KERN_ERR "flush_thread - clearing address space failed, " | 30 | printk(KERN_ERR "flush_thread - clearing address space failed, " |
31 | "err = %d\n", ret); | 31 | "err = %d\n", ret); |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 468aba990dbd..a6c1dd1cf5a1 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -241,6 +241,11 @@ static struct notifier_block panic_exit_notifier = { | |||
241 | }; | 241 | }; |
242 | 242 | ||
243 | /* Set during early boot */ | 243 | /* Set during early boot */ |
244 | unsigned long task_size; | ||
245 | EXPORT_SYMBOL(task_size); | ||
246 | |||
247 | unsigned long host_task_size; | ||
248 | |||
244 | unsigned long brk_start; | 249 | unsigned long brk_start; |
245 | unsigned long end_iomem; | 250 | unsigned long end_iomem; |
246 | EXPORT_SYMBOL(end_iomem); | 251 | EXPORT_SYMBOL(end_iomem); |
@@ -267,6 +272,13 @@ int __init linux_main(int argc, char **argv) | |||
267 | if (have_root == 0) | 272 | if (have_root == 0) |
268 | add_arg(DEFAULT_COMMAND_LINE); | 273 | add_arg(DEFAULT_COMMAND_LINE); |
269 | 274 | ||
275 | host_task_size = os_get_task_size(); | ||
276 | /* | ||
277 | * TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps | ||
278 | * out | ||
279 | */ | ||
280 | task_size = host_task_size & PGDIR_MASK; | ||
281 | |||
270 | /* OS sanity checks that need to happen before the kernel runs */ | 282 | /* OS sanity checks that need to happen before the kernel runs */ |
271 | os_early_checks(); | 283 | os_early_checks(); |
272 | 284 | ||
@@ -303,7 +315,7 @@ int __init linux_main(int argc, char **argv) | |||
303 | 315 | ||
304 | highmem = 0; | 316 | highmem = 0; |
305 | iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; | 317 | iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; |
306 | max_physmem = CONFIG_TOP_ADDR - uml_physmem - iomem_size - MIN_VMALLOC; | 318 | max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC; |
307 | 319 | ||
308 | /* | 320 | /* |
309 | * Zones have to begin on a 1 << MAX_ORDER page boundary, | 321 | * Zones have to begin on a 1 << MAX_ORDER page boundary, |
@@ -335,7 +347,7 @@ int __init linux_main(int argc, char **argv) | |||
335 | } | 347 | } |
336 | 348 | ||
337 | virtmem_size = physmem_size; | 349 | virtmem_size = physmem_size; |
338 | avail = CONFIG_TOP_ADDR - start_vm; | 350 | avail = TASK_SIZE - start_vm; |
339 | if (physmem_size > avail) | 351 | if (physmem_size > avail) |
340 | virtmem_size = avail; | 352 | virtmem_size = avail; |
341 | end_vm = start_vm + virtmem_size; | 353 | end_vm = start_vm + virtmem_size; |