aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/lguest.h2
-rw-r--r--drivers/lguest/core.c18
-rw-r--r--drivers/lguest/x86/core.c4
3 files changed, 14 insertions, 10 deletions
diff --git a/arch/x86/include/asm/lguest.h b/arch/x86/include/asm/lguest.h
index 0d97deba1e35..85ecdb80d121 100644
--- a/arch/x86/include/asm/lguest.h
+++ b/arch/x86/include/asm/lguest.h
@@ -23,6 +23,8 @@
23#else 23#else
24#define SWITCHER_ADDR 0xFFC00000 24#define SWITCHER_ADDR 0xFFC00000
25#endif 25#endif
26/* Where we map the Switcher, in both Host and Guest. */
27extern unsigned long switcher_addr;
26 28
27/* Found in switcher.S */ 29/* Found in switcher.S */
28extern unsigned long default_idt_entries[]; 30extern unsigned long default_idt_entries[];
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index a5ebc0083d87..099252301132 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -20,7 +20,7 @@
20#include <asm/asm-offsets.h> 20#include <asm/asm-offsets.h>
21#include "lg.h" 21#include "lg.h"
22 22
23 23unsigned long switcher_addr;
24static struct vm_struct *switcher_vma; 24static struct vm_struct *switcher_vma;
25static struct page **switcher_page; 25static struct page **switcher_page;
26 26
@@ -75,25 +75,27 @@ static __init int map_switcher(void)
75 } 75 }
76 } 76 }
77 77
78 switcher_addr = SWITCHER_ADDR;
79
78 /* 80 /*
79 * First we check that the Switcher won't overlap the fixmap area at 81 * First we check that the Switcher won't overlap the fixmap area at
80 * the top of memory. It's currently nowhere near, but it could have 82 * the top of memory. It's currently nowhere near, but it could have
81 * very strange effects if it ever happened. 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 err = -ENOMEM; 86 err = -ENOMEM;
85 printk("lguest: mapping switcher would thwack fixmap\n"); 87 printk("lguest: mapping switcher would thwack fixmap\n");
86 goto free_pages; 88 goto free_pages;
87 } 89 }
88 90
89 /* 91 /*
90 * Now we reserve the "virtual memory area" we want: 0xFFC00000 92 * Now we reserve the "virtual memory area" we want. We might
91 * (SWITCHER_ADDR). We might not get it in theory, but in practice 93 * not get it in theory, but in practice it's worked so far.
92 * it's worked so far. The end address needs +1 because __get_vm_area 94 * The end address needs +1 because __get_vm_area allocates an
93 * allocates an extra guard page, so we need space for that. 95 * extra guard page, so we need space for that.
94 */ 96 */
95 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE, 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 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE); 99 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
98 if (!switcher_vma) { 100 if (!switcher_vma) {
99 err = -ENOMEM; 101 err = -ENOMEM;
@@ -103,7 +105,7 @@ static __init int map_switcher(void)
103 105
104 /* 106 /*
105 * This code actually sets up the pages we've allocated to appear at 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 * kind of pages we're mapping (kernel pages), and a pointer to our 109 * kind of pages we're mapping (kernel pages), and a pointer to our
108 * array of struct pages. It increments that pointer, but we don't 110 * array of struct pages. It increments that pointer, but we don't
109 * care. 111 * care.
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 4af12e1844d5..20fae765d600 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -59,14 +59,14 @@ static struct {
59/* Offset from where switcher.S was compiled to where we've copied it */ 59/* Offset from where switcher.S was compiled to where we've copied it */
60static unsigned long switcher_offset(void) 60static 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/* This cpu's struct lguest_pages. */ 65/* This cpu's struct lguest_pages. */
66static struct lguest_pages *lguest_pages(unsigned int cpu) 66static struct lguest_pages *lguest_pages(unsigned int cpu)
67{ 67{
68 return &(((struct lguest_pages *) 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
72static DEFINE_PER_CPU(struct lg_cpu *, lg_last_cpu); 72static DEFINE_PER_CPU(struct lg_cpu *, lg_last_cpu);