aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest/x86
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/x86
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/x86')
-rw-r--r--drivers/lguest/x86/core.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index d96a93d95aea..e989b8358864 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -100,14 +100,14 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
100 100
101 /* Copy direct-to-Guest trap entries. */ 101 /* Copy direct-to-Guest trap entries. */
102 if (lg->changed & CHANGED_IDT) 102 if (lg->changed & CHANGED_IDT)
103 copy_traps(lg, pages->state.guest_idt, default_idt_entries); 103 copy_traps(cpu, pages->state.guest_idt, default_idt_entries);
104 104
105 /* Copy all GDT entries which the Guest can change. */ 105 /* Copy all GDT entries which the Guest can change. */
106 if (lg->changed & CHANGED_GDT) 106 if (lg->changed & CHANGED_GDT)
107 copy_gdt(lg, pages->state.guest_gdt); 107 copy_gdt(cpu, pages->state.guest_gdt);
108 /* If only the TLS entries have changed, copy them. */ 108 /* If only the TLS entries have changed, copy them. */
109 else if (lg->changed & CHANGED_GDT_TLS) 109 else if (lg->changed & CHANGED_GDT_TLS)
110 copy_gdt_tls(lg, pages->state.guest_gdt); 110 copy_gdt_tls(cpu, pages->state.guest_gdt);
111 111
112 /* Mark the Guest as unchanged for next time. */ 112 /* Mark the Guest as unchanged for next time. */
113 lg->changed = 0; 113 lg->changed = 0;
@@ -196,7 +196,7 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
196 * re-enable interrupts an interrupt could fault and thus overwrite 196 * re-enable interrupts an interrupt could fault and thus overwrite
197 * cr2, or we could even move off to a different CPU. */ 197 * cr2, or we could even move off to a different CPU. */
198 if (cpu->regs->trapnum == 14) 198 if (cpu->regs->trapnum == 14)
199 lg->arch.last_pagefault = read_cr2(); 199 cpu->arch.last_pagefault = read_cr2();
200 /* Similarly, if we took a trap because the Guest used the FPU, 200 /* Similarly, if we took a trap because the Guest used the FPU,
201 * we have to restore the FPU it expects to see. */ 201 * we have to restore the FPU it expects to see. */
202 else if (cpu->regs->trapnum == 7) 202 else if (cpu->regs->trapnum == 7)
@@ -307,7 +307,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
307 * 307 *
308 * The errcode tells whether this was a read or a write, and 308 * The errcode tells whether this was a read or a write, and
309 * whether kernel or userspace code. */ 309 * whether kernel or userspace code. */
310 if (demand_page(lg, lg->arch.last_pagefault, cpu->regs->errcode)) 310 if (demand_page(lg,cpu->arch.last_pagefault,cpu->regs->errcode))
311 return; 311 return;
312 312
313 /* OK, it's really not there (or not OK): the Guest needs to 313 /* OK, it's really not there (or not OK): the Guest needs to
@@ -318,7 +318,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
318 * happen before it's done the LHCALL_LGUEST_INIT hypercall, so 318 * happen before it's done the LHCALL_LGUEST_INIT hypercall, so
319 * lg->lguest_data could be NULL */ 319 * lg->lguest_data could be NULL */
320 if (lg->lguest_data && 320 if (lg->lguest_data &&
321 put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2)) 321 put_user(cpu->arch.last_pagefault, &lg->lguest_data->cr2))
322 kill_guest(lg, "Writing cr2"); 322 kill_guest(lg, "Writing cr2");
323 break; 323 break;
324 case 7: /* We've intercepted a Device Not Available fault. */ 324 case 7: /* We've intercepted a Device Not Available fault. */
@@ -349,7 +349,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
349 * it handle), it dies with a cryptic error message. */ 349 * it handle), it dies with a cryptic error message. */
350 kill_guest(lg, "unhandled trap %li at %#lx (%#lx)", 350 kill_guest(lg, "unhandled trap %li at %#lx (%#lx)",
351 cpu->regs->trapnum, cpu->regs->eip, 351 cpu->regs->trapnum, cpu->regs->eip,
352 cpu->regs->trapnum == 14 ? lg->arch.last_pagefault 352 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault
353 : cpu->regs->errcode); 353 : cpu->regs->errcode);
354} 354}
355 355
@@ -495,17 +495,15 @@ void __exit lguest_arch_host_fini(void)
495/*H:122 The i386-specific hypercalls simply farm out to the right functions. */ 495/*H:122 The i386-specific hypercalls simply farm out to the right functions. */
496int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args) 496int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
497{ 497{
498 struct lguest *lg = cpu->lg;
499
500 switch (args->arg0) { 498 switch (args->arg0) {
501 case LHCALL_LOAD_GDT: 499 case LHCALL_LOAD_GDT:
502 load_guest_gdt(lg, args->arg1, args->arg2); 500 load_guest_gdt(cpu, args->arg1, args->arg2);
503 break; 501 break;
504 case LHCALL_LOAD_IDT_ENTRY: 502 case LHCALL_LOAD_IDT_ENTRY:
505 load_guest_idt_entry(lg, args->arg1, args->arg2, args->arg3); 503 load_guest_idt_entry(cpu, args->arg1, args->arg2, args->arg3);
506 break; 504 break;
507 case LHCALL_LOAD_TLS: 505 case LHCALL_LOAD_TLS:
508 guest_load_tls(lg, args->arg1); 506 guest_load_tls(cpu, args->arg1);
509 break; 507 break;
510 default: 508 default:
511 /* Bad Guest. Bad! */ 509 /* Bad Guest. Bad! */
@@ -586,5 +584,5 @@ void lguest_arch_setup_regs(struct lg_cpu *cpu, unsigned long start)
586 584
587 /* There are a couple of GDT entries the Guest expects when first 585 /* There are a couple of GDT entries the Guest expects when first
588 * booting. */ 586 * booting. */
589 setup_guest_gdt(cpu->lg); 587 setup_guest_gdt(cpu);
590} 588}