Commit 406a590ba105bfb7b67952f0a5f948e0d374e03e
1 parent
74ff582cd6
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
lguest: prepare to make SWITCHER_ADDR a variable.
We currently use the whole top PGD entry for the switcher, but that's hitting the fixmap in some configurations (mainly, large NR_CPUS). Introduce a variable, currently set to the constant. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Showing 3 changed files with 14 additions and 10 deletions Side-by-side Diff
arch/x86/include/asm/lguest.h
drivers/lguest/core.c
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | #include <asm/asm-offsets.h> |
21 | 21 | #include "lg.h" |
22 | 22 | |
23 | - | |
23 | +unsigned long switcher_addr; | |
24 | 24 | static struct vm_struct *switcher_vma; |
25 | 25 | static struct page **switcher_page; |
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | 29 | |
... | ... | @@ -75,25 +75,27 @@ |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | + switcher_addr = SWITCHER_ADDR; | |
79 | + | |
78 | 80 | /* |
79 | 81 | * First we check that the Switcher won't overlap the fixmap area at |
80 | 82 | * the top of memory. It's currently nowhere near, but it could have |
81 | 83 | * very strange effects if it ever happened. |
82 | 84 | */ |
83 | - if (SWITCHER_ADDR + (TOTAL_SWITCHER_PAGES+1)*PAGE_SIZE > FIXADDR_START){ | |
85 | + if (switcher_addr + (TOTAL_SWITCHER_PAGES+1)*PAGE_SIZE > FIXADDR_START){ | |
84 | 86 | err = -ENOMEM; |
85 | 87 | printk("lguest: mapping switcher would thwack fixmap\n"); |
86 | 88 | goto free_pages; |
87 | 89 | } |
88 | 90 | |
89 | 91 | /* |
90 | - * Now we reserve the "virtual memory area" we want: 0xFFC00000 | |
91 | - * (SWITCHER_ADDR). We might not get it in theory, but in practice | |
92 | - * it's worked so far. The end address needs +1 because __get_vm_area | |
93 | - * allocates an extra guard page, so we need space for that. | |
92 | + * Now we reserve the "virtual memory area" we want. We might | |
93 | + * not get it in theory, but in practice it's worked so far. | |
94 | + * The end address needs +1 because __get_vm_area allocates an | |
95 | + * extra guard page, so we need space for that. | |
94 | 96 | */ |
95 | 97 | switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE, |
96 | - VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR | |
98 | + VM_ALLOC, switcher_addr, switcher_addr | |
97 | 99 | + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE); |
98 | 100 | if (!switcher_vma) { |
99 | 101 | err = -ENOMEM; |
... | ... | @@ -103,7 +105,7 @@ |
103 | 105 | |
104 | 106 | /* |
105 | 107 | * This code actually sets up the pages we've allocated to appear at |
106 | - * SWITCHER_ADDR. map_vm_area() takes the vma we allocated above, the | |
108 | + * switcher_addr. map_vm_area() takes the vma we allocated above, the | |
107 | 109 | * kind of pages we're mapping (kernel pages), and a pointer to our |
108 | 110 | * array of struct pages. It increments that pointer, but we don't |
109 | 111 | * care. |
drivers/lguest/x86/core.c
... | ... | @@ -59,14 +59,14 @@ |
59 | 59 | /* Offset from where switcher.S was compiled to where we've copied it */ |
60 | 60 | static unsigned long switcher_offset(void) |
61 | 61 | { |
62 | - return SWITCHER_ADDR - (unsigned long)start_switcher_text; | |
62 | + return switcher_addr - (unsigned long)start_switcher_text; | |
63 | 63 | } |
64 | 64 | |
65 | 65 | /* This cpu's struct lguest_pages. */ |
66 | 66 | static struct lguest_pages *lguest_pages(unsigned int cpu) |
67 | 67 | { |
68 | 68 | return &(((struct lguest_pages *) |
69 | - (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); | |
69 | + (switcher_addr + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); | |
70 | 70 | } |
71 | 71 | |
72 | 72 | static DEFINE_PER_CPU(struct lg_cpu *, lg_last_cpu); |