Commit 42a2b54ce8c7b9d4f418995a7950e7e2e15e52ce
Committed by
Linus Torvalds
1 parent
b7c000cbc4
Exists in
master
and in
7 other branches
uml: clean up TASK_SIZE usage
Clean up the calculation and use of the usable address space size on the host. task_size is gone, replaced with TASK_SIZE, which is calculated from CONFIG_TOP_ADDR. get_kmem_end and set_task_sizes_skas are also gone. host_task_size, which refers to the entire address space usable by the UML kernel and which may be larger than the address space usable by a UML process, since that has to end on a pgdir boundary, is replaced by CONFIG_TOP_ADDR. STACK_TOP is now TASK_SIZE minus the two stub pages. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 11 changed files with 23 additions and 49 deletions Side-by-side Diff
arch/um/include/as-layout.h
... | ... | @@ -29,9 +29,20 @@ |
29 | 29 | #define _AC(X, Y) __AC(X, Y) |
30 | 30 | #endif |
31 | 31 | |
32 | +/* | |
33 | + * The "- 1"'s are to avoid gcc complaining about integer overflows | |
34 | + * and unrepresentable decimal constants. With 3-level page tables, | |
35 | + * TASK_SIZE is 0x80000000, which gets turned into its signed decimal | |
36 | + * equivalent in asm-offsets.s. gcc then complains about that being | |
37 | + * unsigned only in C90. To avoid that, UM_TASK_SIZE is defined as | |
38 | + * TASK_SIZE - 1. To compensate, we need to add the 1 back here. | |
39 | + * However, adding it back to UM_TASK_SIZE produces more gcc | |
40 | + * complaints. So, I adjust the thing being subtracted from | |
41 | + * UM_TASK_SIZE instead. Bah. | |
42 | + */ | |
32 | 43 | #define STUB_CODE _AC((unsigned long), \ |
33 | - UML_CONFIG_TOP_ADDR - 2 * UM_KERN_PAGE_SIZE) | |
34 | -#define STUB_DATA _AC((unsigned long), UML_CONFIG_TOP_ADDR - UM_KERN_PAGE_SIZE) | |
44 | + UM_TASK_SIZE - (2 * UM_KERN_PAGE_SIZE - 1)) | |
45 | +#define STUB_DATA _AC((unsigned long), UM_TASK_SIZE - (UM_KERN_PAGE_SIZE - 1)) | |
35 | 46 | #define STUB_START _AC(, STUB_CODE) |
36 | 47 | |
37 | 48 | #ifndef __ASSEMBLY__ |
arch/um/include/common-offsets.h
arch/um/include/mem_user.h
... | ... | @@ -46,9 +46,6 @@ |
46 | 46 | |
47 | 47 | #define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1)) |
48 | 48 | |
49 | -extern unsigned long host_task_size; | |
50 | -extern unsigned long task_size; | |
51 | - | |
52 | 49 | extern int init_mem_user(void); |
53 | 50 | extern void setup_memory(void *entry); |
54 | 51 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); |
... | ... | @@ -62,7 +59,6 @@ |
62 | 59 | extern void unmap_physmem(void); |
63 | 60 | extern void map_memory(unsigned long virt, unsigned long phys, |
64 | 61 | unsigned long len, int r, int w, int x); |
65 | -extern unsigned long get_kmem_end(void); | |
66 | 62 | |
67 | 63 | #endif |
arch/um/kernel/exec.c
arch/um/kernel/ksyms.c
... | ... | @@ -18,11 +18,8 @@ |
18 | 18 | EXPORT_SYMBOL(get_signals); |
19 | 19 | EXPORT_SYMBOL(kernel_thread); |
20 | 20 | EXPORT_SYMBOL(sys_waitpid); |
21 | -EXPORT_SYMBOL(task_size); | |
22 | 21 | EXPORT_SYMBOL(flush_tlb_range); |
23 | -EXPORT_SYMBOL(host_task_size); | |
24 | 22 | EXPORT_SYMBOL(arch_validate); |
25 | -EXPORT_SYMBOL(get_kmem_end); | |
26 | 23 | |
27 | 24 | EXPORT_SYMBOL(high_physmem); |
28 | 25 | EXPORT_SYMBOL(empty_zero_page); |
arch/um/kernel/physmem.c
... | ... | @@ -55,16 +55,6 @@ |
55 | 55 | return 0; |
56 | 56 | } |
57 | 57 | |
58 | -/* Changed during early boot */ | |
59 | -static unsigned long kmem_top = 0; | |
60 | - | |
61 | -unsigned long get_kmem_end(void) | |
62 | -{ | |
63 | - if (kmem_top == 0) | |
64 | - kmem_top = host_task_size - 1024 * 1024; | |
65 | - return kmem_top; | |
66 | -} | |
67 | - | |
68 | 58 | void map_memory(unsigned long virt, unsigned long phys, unsigned long len, |
69 | 59 | int r, int w, int x) |
70 | 60 | { |
arch/um/kernel/tlb.c
arch/um/kernel/um_arch.c
... | ... | @@ -101,8 +101,6 @@ |
101 | 101 | }; |
102 | 102 | |
103 | 103 | /* Set in linux_main */ |
104 | -unsigned long host_task_size; | |
105 | -unsigned long task_size; | |
106 | 104 | unsigned long uml_physmem; |
107 | 105 | unsigned long uml_reserved; /* Also modified in mem_init */ |
108 | 106 | unsigned long start_vm; |
... | ... | @@ -234,20 +232,6 @@ |
234 | 232 | |
235 | 233 | extern char __binary_start; |
236 | 234 | |
237 | -static unsigned long set_task_sizes_skas(unsigned long *task_size_out) | |
238 | -{ | |
239 | - /* Round up to the nearest 4M */ | |
240 | - unsigned long host_task_size = ROUND_4M((unsigned long) | |
241 | - &host_task_size); | |
242 | - | |
243 | - if (!skas_needs_stub) | |
244 | - *task_size_out = host_task_size; | |
245 | - else | |
246 | - *task_size_out = STUB_START & PGDIR_MASK; | |
247 | - | |
248 | - return host_task_size; | |
249 | -} | |
250 | - | |
251 | 235 | int __init linux_main(int argc, char **argv) |
252 | 236 | { |
253 | 237 | unsigned long avail, diff; |
... | ... | @@ -278,8 +262,6 @@ |
278 | 262 | |
279 | 263 | printf("UML running in %s mode\n", mode); |
280 | 264 | |
281 | - host_task_size = set_task_sizes_skas(&task_size); | |
282 | - | |
283 | 265 | brk_start = (unsigned long) sbrk(0); |
284 | 266 | |
285 | 267 | /* |
... | ... | @@ -304,7 +286,7 @@ |
304 | 286 | |
305 | 287 | highmem = 0; |
306 | 288 | iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; |
307 | - max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC; | |
289 | + max_physmem = CONFIG_TOP_ADDR - uml_physmem - iomem_size - MIN_VMALLOC; | |
308 | 290 | |
309 | 291 | /* |
310 | 292 | * Zones have to begin on a 1 << MAX_ORDER page boundary, |
... | ... | @@ -336,7 +318,7 @@ |
336 | 318 | } |
337 | 319 | |
338 | 320 | virtmem_size = physmem_size; |
339 | - avail = get_kmem_end() - start_vm; | |
321 | + avail = CONFIG_TOP_ADDR - start_vm; | |
340 | 322 | if (physmem_size > avail) |
341 | 323 | virtmem_size = avail; |
342 | 324 | end_vm = start_vm + virtmem_size; |
include/asm-um/a.out.h
... | ... | @@ -13,11 +13,9 @@ |
13 | 13 | |
14 | 14 | extern unsigned long stacksizelim; |
15 | 15 | |
16 | -extern unsigned long host_task_size; | |
17 | - | |
18 | 16 | #define STACK_ROOM (stacksizelim) |
19 | 17 | |
20 | -#define STACK_TOP task_size | |
18 | +#define STACK_TOP (TASK_SIZE - 2 * PAGE_SIZE) | |
21 | 19 | |
22 | 20 | #define STACK_TOP_MAX STACK_TOP |
23 | 21 |
include/asm-um/fixmap.h
... | ... | @@ -56,9 +56,8 @@ |
56 | 56 | * the start of the fixmap, and leave one page empty |
57 | 57 | * at the top of mem.. |
58 | 58 | */ |
59 | -extern unsigned long get_kmem_end(void); | |
60 | 59 | |
61 | -#define FIXADDR_TOP (get_kmem_end() - 0x2000) | |
60 | +#define FIXADDR_TOP (CONFIG_TOP_ADDR - 2 * PAGE_SIZE) | |
62 | 61 | #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) |
63 | 62 | #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) |
64 | 63 |
include/asm-um/processor-generic.h
... | ... | @@ -94,9 +94,7 @@ |
94 | 94 | /* |
95 | 95 | * User space process size: 3GB (default). |
96 | 96 | */ |
97 | -extern unsigned long task_size; | |
98 | - | |
99 | -#define TASK_SIZE (task_size) | |
97 | +#define TASK_SIZE (CONFIG_TOP_ADDR & PGDIR_MASK) | |
100 | 98 | |
101 | 99 | /* This decides where the kernel will search for a free chunk of vm |
102 | 100 | * space during mmap's. |