aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest/interrupts_and_traps.c
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-07 08:05:33 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-01-30 06:50:11 -0500
commitfc708b3e407dfd2e12ba9a6cf35bd0bffad1796d (patch)
treee9a6df9c9b8cf4077c98198c3f5d3bc6dc991c0f /drivers/lguest/interrupts_and_traps.c
parenta53a35a8b485b9c16b73e5177bddaa4321971199 (diff)
lguest: replace lguest_arch with lg_cpu_arch.
The fields found in lguest_arch are not really per-guest, but per-cpu (gdt, idt, etc). So this patch turns lguest_arch into lg_cpu_arch. It makes sense to have a per-guest per-arch struct, but this can be addressed later, when the need arrives. Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/interrupts_and_traps.c')
-rw-r--r--drivers/lguest/interrupts_and_traps.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 468faf8233d6..306b93c71dcc 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -178,7 +178,7 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
178 /* Look at the IDT entry the Guest gave us for this interrupt. The 178 /* Look at the IDT entry the Guest gave us for this interrupt. The
179 * first 32 (FIRST_EXTERNAL_VECTOR) entries are for traps, so we skip 179 * first 32 (FIRST_EXTERNAL_VECTOR) entries are for traps, so we skip
180 * over them. */ 180 * over them. */
181 idt = &lg->arch.idt[FIRST_EXTERNAL_VECTOR+irq]; 181 idt = &cpu->arch.idt[FIRST_EXTERNAL_VECTOR+irq];
182 /* If they don't have a handler (yet?), we just ignore it */ 182 /* If they don't have a handler (yet?), we just ignore it */
183 if (idt_present(idt->a, idt->b)) { 183 if (idt_present(idt->a, idt->b)) {
184 /* OK, mark it no longer pending and deliver it. */ 184 /* OK, mark it no longer pending and deliver it. */
@@ -251,15 +251,15 @@ int deliver_trap(struct lg_cpu *cpu, unsigned int num)
251{ 251{
252 /* Trap numbers are always 8 bit, but we set an impossible trap number 252 /* Trap numbers are always 8 bit, but we set an impossible trap number
253 * for traps inside the Switcher, so check that here. */ 253 * for traps inside the Switcher, so check that here. */
254 if (num >= ARRAY_SIZE(cpu->lg->arch.idt)) 254 if (num >= ARRAY_SIZE(cpu->arch.idt))
255 return 0; 255 return 0;
256 256
257 /* Early on the Guest hasn't set the IDT entries (or maybe it put a 257 /* Early on the Guest hasn't set the IDT entries (or maybe it put a
258 * bogus one in): if we fail here, the Guest will be killed. */ 258 * bogus one in): if we fail here, the Guest will be killed. */
259 if (!idt_present(cpu->lg->arch.idt[num].a, cpu->lg->arch.idt[num].b)) 259 if (!idt_present(cpu->arch.idt[num].a, cpu->arch.idt[num].b))
260 return 0; 260 return 0;
261 set_guest_interrupt(cpu, cpu->lg->arch.idt[num].a, 261 set_guest_interrupt(cpu, cpu->arch.idt[num].a,
262 cpu->lg->arch.idt[num].b, has_err(num)); 262 cpu->arch.idt[num].b, has_err(num));
263 return 1; 263 return 1;
264} 264}
265 265
@@ -385,7 +385,7 @@ static void set_trap(struct lguest *lg, struct desc_struct *trap,
385 * 385 *
386 * We saw the Guest setting Interrupt Descriptor Table (IDT) entries with the 386 * We saw the Guest setting Interrupt Descriptor Table (IDT) entries with the
387 * LHCALL_LOAD_IDT_ENTRY hypercall before: that comes here. */ 387 * LHCALL_LOAD_IDT_ENTRY hypercall before: that comes here. */
388void load_guest_idt_entry(struct lguest *lg, unsigned int num, u32 lo, u32 hi) 388void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int num, u32 lo, u32 hi)
389{ 389{
390 /* Guest never handles: NMI, doublefault, spurious interrupt or 390 /* Guest never handles: NMI, doublefault, spurious interrupt or
391 * hypercall. We ignore when it tries to set them. */ 391 * hypercall. We ignore when it tries to set them. */
@@ -394,13 +394,13 @@ void load_guest_idt_entry(struct lguest *lg, unsigned int num, u32 lo, u32 hi)
394 394
395 /* Mark the IDT as changed: next time the Guest runs we'll know we have 395 /* Mark the IDT as changed: next time the Guest runs we'll know we have
396 * to copy this again. */ 396 * to copy this again. */
397 lg->changed |= CHANGED_IDT; 397 cpu->lg->changed |= CHANGED_IDT;
398 398
399 /* Check that the Guest doesn't try to step outside the bounds. */ 399 /* Check that the Guest doesn't try to step outside the bounds. */
400 if (num >= ARRAY_SIZE(lg->arch.idt)) 400 if (num >= ARRAY_SIZE(cpu->arch.idt))
401 kill_guest(lg, "Setting idt entry %u", num); 401 kill_guest(cpu->lg, "Setting idt entry %u", num);
402 else 402 else
403 set_trap(lg, &lg->arch.idt[num], num, lo, hi); 403 set_trap(cpu->lg, &cpu->arch.idt[num], num, lo, hi);
404} 404}
405 405
406/* The default entry for each interrupt points into the Switcher routines which 406/* The default entry for each interrupt points into the Switcher routines which
@@ -436,14 +436,14 @@ void setup_default_idt_entries(struct lguest_ro_state *state,
436/*H:240 We don't use the IDT entries in the "struct lguest" directly, instead 436/*H:240 We don't use the IDT entries in the "struct lguest" directly, instead
437 * we copy them into the IDT which we've set up for Guests on this CPU, just 437 * we copy them into the IDT which we've set up for Guests on this CPU, just
438 * before we run the Guest. This routine does that copy. */ 438 * before we run the Guest. This routine does that copy. */
439void copy_traps(const struct lguest *lg, struct desc_struct *idt, 439void copy_traps(const struct lg_cpu *cpu, struct desc_struct *idt,
440 const unsigned long *def) 440 const unsigned long *def)
441{ 441{
442 unsigned int i; 442 unsigned int i;
443 443
444 /* We can simply copy the direct traps, otherwise we use the default 444 /* We can simply copy the direct traps, otherwise we use the default
445 * ones in the Switcher: they will return to the Host. */ 445 * ones in the Switcher: they will return to the Host. */
446 for (i = 0; i < ARRAY_SIZE(lg->arch.idt); i++) { 446 for (i = 0; i < ARRAY_SIZE(cpu->arch.idt); i++) {
447 /* If no Guest can ever override this trap, leave it alone. */ 447 /* If no Guest can ever override this trap, leave it alone. */
448 if (!direct_trap(i)) 448 if (!direct_trap(i))
449 continue; 449 continue;
@@ -452,8 +452,8 @@ void copy_traps(const struct lguest *lg, struct desc_struct *idt,
452 * Interrupt gates (type 14) disable interrupts as they are 452 * Interrupt gates (type 14) disable interrupts as they are
453 * entered, which we never let the Guest do. Not present 453 * entered, which we never let the Guest do. Not present
454 * entries (type 0x0) also can't go direct, of course. */ 454 * entries (type 0x0) also can't go direct, of course. */
455 if (idt_type(lg->arch.idt[i].a, lg->arch.idt[i].b) == 0xF) 455 if (idt_type(cpu->arch.idt[i].a, cpu->arch.idt[i].b) == 0xF)
456 idt[i] = lg->arch.idt[i]; 456 idt[i] = cpu->arch.idt[i];
457 else 457 else
458 /* Reset it to the default. */ 458 /* Reset it to the default. */
459 default_idt_entry(&idt[i], i, def[i]); 459 default_idt_entry(&idt[i], i, def[i]);