aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-17 16:14:46 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-01-30 06:50:17 -0500
commitae3749dcd8c31dcfbab14ea28c68a944c93f418f (patch)
treebdbbe9207bb7c50e9aeb7afc5b5653b79501c03f /drivers/lguest
parentf34f8c5fea079065671163c37d98328cff31980b (diff)
lguest: move changed bitmap to lg_cpu
events represented in the 'changed' bitmap are per-cpu, not per-guest. move it to the lg_cpu structure Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest')
-rw-r--r--drivers/lguest/interrupts_and_traps.c2
-rw-r--r--drivers/lguest/lg.h6
-rw-r--r--drivers/lguest/segments.c4
-rw-r--r--drivers/lguest/x86/core.c11
4 files changed, 11 insertions, 12 deletions
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 6bbfce4e5987..9ac7455ec7fb 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -395,7 +395,7 @@ void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int num, u32 lo, u32 hi)
395 395
396 /* Mark the IDT as changed: next time the Guest runs we'll know we have 396 /* Mark the IDT as changed: next time the Guest runs we'll know we have
397 * to copy this again. */ 397 * to copy this again. */
398 cpu->lg->changed |= CHANGED_IDT; 398 cpu->changed |= CHANGED_IDT;
399 399
400 /* Check that the Guest doesn't try to step outside the bounds. */ 400 /* Check that the Guest doesn't try to step outside the bounds. */
401 if (num >= ARRAY_SIZE(cpu->arch.idt)) 401 if (num >= ARRAY_SIZE(cpu->arch.idt))
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index f1c4c33e4153..0d6f6435d72c 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -51,6 +51,9 @@ struct lg_cpu {
51 u32 esp1; 51 u32 esp1;
52 u8 ss1; 52 u8 ss1;
53 53
54 /* Bitmap of what has changed: see CHANGED_* above. */
55 int changed;
56
54 unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ 57 unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */
55 58
56 /* At end of a page shared mapped over lguest_pages in guest. */ 59 /* At end of a page shared mapped over lguest_pages in guest. */
@@ -92,9 +95,6 @@ struct lguest
92 void __user *mem_base; 95 void __user *mem_base;
93 unsigned long kernel_address; 96 unsigned long kernel_address;
94 97
95 /* Bitmap of what has changed: see CHANGED_* above. */
96 int changed;
97
98 struct pgdir pgdirs[4]; 98 struct pgdir pgdirs[4];
99 99
100 unsigned long noirq_start, noirq_end; 100 unsigned long noirq_start, noirq_end;
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c
index 02138450ecf5..635f54c719ae 100644
--- a/drivers/lguest/segments.c
+++ b/drivers/lguest/segments.c
@@ -159,7 +159,7 @@ void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num)
159 fixup_gdt_table(cpu, 0, ARRAY_SIZE(cpu->arch.gdt)); 159 fixup_gdt_table(cpu, 0, ARRAY_SIZE(cpu->arch.gdt));
160 /* Mark that the GDT changed so the core knows it has to copy it again, 160 /* Mark that the GDT changed so the core knows it has to copy it again,
161 * even if the Guest is run on the same CPU. */ 161 * even if the Guest is run on the same CPU. */
162 lg->changed |= CHANGED_GDT; 162 cpu->changed |= CHANGED_GDT;
163} 163}
164 164
165/* This is the fast-track version for just changing the three TLS entries. 165/* This is the fast-track version for just changing the three TLS entries.
@@ -174,7 +174,7 @@ void guest_load_tls(struct lg_cpu *cpu, unsigned long gtls)
174 __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); 174 __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES);
175 fixup_gdt_table(cpu, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); 175 fixup_gdt_table(cpu, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1);
176 /* Note that just the TLS entries have changed. */ 176 /* Note that just the TLS entries have changed. */
177 lg->changed |= CHANGED_GDT_TLS; 177 cpu->changed |= CHANGED_GDT_TLS;
178} 178}
179/*:*/ 179/*:*/
180 180
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index f8dfdc9a3e5b..fd6a8512443c 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -75,7 +75,6 @@ static DEFINE_PER_CPU(struct lg_cpu *, last_cpu);
75 */ 75 */
76static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) 76static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
77{ 77{
78 struct lguest *lg = cpu->lg;
79 /* Copying all this data can be quite expensive. We usually run the 78 /* Copying all this data can be quite expensive. We usually run the
80 * same Guest we ran last time (and that Guest hasn't run anywhere else 79 * same Guest we ran last time (and that Guest hasn't run anywhere else
81 * meanwhile). If that's not the case, we pretend everything in the 80 * meanwhile). If that's not the case, we pretend everything in the
@@ -83,7 +82,7 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
83 if (__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) { 82 if (__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) {
84 __get_cpu_var(last_cpu) = cpu; 83 __get_cpu_var(last_cpu) = cpu;
85 cpu->last_pages = pages; 84 cpu->last_pages = pages;
86 lg->changed = CHANGED_ALL; 85 cpu->changed = CHANGED_ALL;
87 } 86 }
88 87
89 /* These copies are pretty cheap, so we do them unconditionally: */ 88 /* These copies are pretty cheap, so we do them unconditionally: */
@@ -99,18 +98,18 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
99 pages->state.guest_tss.ss1 = cpu->ss1; 98 pages->state.guest_tss.ss1 = cpu->ss1;
100 99
101 /* Copy direct-to-Guest trap entries. */ 100 /* Copy direct-to-Guest trap entries. */
102 if (lg->changed & CHANGED_IDT) 101 if (cpu->changed & CHANGED_IDT)
103 copy_traps(cpu, pages->state.guest_idt, default_idt_entries); 102 copy_traps(cpu, pages->state.guest_idt, default_idt_entries);
104 103
105 /* Copy all GDT entries which the Guest can change. */ 104 /* Copy all GDT entries which the Guest can change. */
106 if (lg->changed & CHANGED_GDT) 105 if (cpu->changed & CHANGED_GDT)
107 copy_gdt(cpu, pages->state.guest_gdt); 106 copy_gdt(cpu, pages->state.guest_gdt);
108 /* If only the TLS entries have changed, copy them. */ 107 /* If only the TLS entries have changed, copy them. */
109 else if (lg->changed & CHANGED_GDT_TLS) 108 else if (cpu->changed & CHANGED_GDT_TLS)
110 copy_gdt_tls(cpu, pages->state.guest_gdt); 109 copy_gdt_tls(cpu, pages->state.guest_gdt);
111 110
112 /* Mark the Guest as unchanged for next time. */ 111 /* Mark the Guest as unchanged for next time. */
113 lg->changed = 0; 112 cpu->changed = 0;
114} 113}
115 114
116/* Finally: the code to actually call into the Switcher to run the Guest. */ 115/* Finally: the code to actually call into the Switcher to run the Guest. */