]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Jan 2008 22:35:32 +0000 (09:35 +1100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Jan 2008 22:35:32 +0000 (09:35 +1100)
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: (27 commits)
  lguest: use __PAGE_KERNEL instead of _PAGE_KERNEL
  lguest: Use explicit includes rateher than indirect
  lguest: get rid of lg variable assignments
  lguest: change gpte_addr header
  lguest: move changed bitmap to lg_cpu
  lguest: move last_pages to lg_cpu
  lguest: change last_guest to last_cpu
  lguest: change spte_addr header
  lguest: per-vcpu lguest pgdir management
  lguest: make pending notifications per-vcpu
  lguest: makes special fields be per-vcpu
  lguest: per-vcpu lguest task management
  lguest: replace lguest_arch with lg_cpu_arch.
  lguest: make registers per-vcpu
  lguest: make emulate_insn receive a vcpu struct.
  lguest: map_switcher_in_guest() per-vcpu
  lguest: per-vcpu interrupt processing.
  lguest: per-vcpu lguest timers
  lguest: make hypercalls use the vcpu struct
  lguest: make write() operation smp aware
  ...

Manual conflict resolved (maybe even correctly, who knows) in
drivers/lguest/x86/core.c

1  2 
arch/x86/lguest/boot.c
drivers/Makefile
drivers/lguest/x86/core.c
include/asm-x86/lguest.h

diff --combined arch/x86/lguest/boot.c
index a63373759f08db6fd1652a2f3d62b8ab962aabbe,d6b18e2e54315d27cb851a1f405b098dcc8d1b75..5afdde4895dcefe823e0e500df57d977a7ffa350
@@@ -67,6 -67,7 +67,7 @@@
  #include <asm/mce.h>
  #include <asm/io.h>
  #include <asm/i387.h>
+ #include <asm/reboot.h>               /* for struct machine_ops */
  
  /*G:010 Welcome to the Guest!
   *
@@@ -175,8 -176,8 +176,8 @@@ static void lguest_leave_lazy_mode(void
   * check there when it wants to deliver an interrupt.
   */
  
 -/* save_flags() is expected to return the processor state (ie. "eflags").  The
 - * eflags word contains all kind of stuff, but in practice Linux only cares
 +/* save_flags() is expected to return the processor state (ie. "flags").  The
 + * flags word contains all kind of stuff, but in practice Linux only cares
   * about the interrupt flag.  Our "save_flags()" just returns that. */
  static unsigned long save_fl(void)
  {
@@@ -217,20 -218,19 +218,20 @@@ static void irq_enable(void
   * address of the handler, and... well, who cares?  The Guest just asks the
   * Host to make the change anyway, because the Host controls the real IDT.
   */
 -static void lguest_write_idt_entry(struct desc_struct *dt,
 -                                 int entrynum, u32 low, u32 high)
 +static void lguest_write_idt_entry(gate_desc *dt,
 +                                 int entrynum, const gate_desc *g)
  {
 +      u32 *desc = (u32 *)g;
        /* Keep the local copy up to date. */
 -      write_dt_entry(dt, entrynum, low, high);
 +      native_write_idt_entry(dt, entrynum, g);
        /* Tell Host about this new entry. */
 -      hcall(LHCALL_LOAD_IDT_ENTRY, entrynum, low, high);
 +      hcall(LHCALL_LOAD_IDT_ENTRY, entrynum, desc[0], desc[1]);
  }
  
  /* Changing to a different IDT is very rare: we keep the IDT up-to-date every
   * time it is written, so we can simply loop through all entries and tell the
   * Host about them. */
 -static void lguest_load_idt(const struct Xgt_desc_struct *desc)
 +static void lguest_load_idt(const struct desc_ptr *desc)
  {
        unsigned int i;
        struct desc_struct *idt = (void *)desc->address;
   * hypercall and use that repeatedly to load a new IDT.  I don't think it
   * really matters, but wouldn't it be nice if they were the same?
   */
 -static void lguest_load_gdt(const struct Xgt_desc_struct *desc)
 +static void lguest_load_gdt(const struct desc_ptr *desc)
  {
        BUG_ON((desc->size+1)/8 != GDT_ENTRIES);
        hcall(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES, 0);
  /* For a single GDT entry which changes, we do the lazy thing: alter our GDT,
   * then tell the Host to reload the entire thing.  This operation is so rare
   * that this naive implementation is reasonable. */
 -static void lguest_write_gdt_entry(struct desc_struct *dt,
 -                                 int entrynum, u32 low, u32 high)
 +static void lguest_write_gdt_entry(struct desc_struct *dt, int entrynum,
 +                                 const void *desc, int type)
  {
 -      write_dt_entry(dt, entrynum, low, high);
 +      native_write_gdt_entry(dt, entrynum, desc, type);
        hcall(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES, 0);
  }
  
@@@ -324,30 -324,30 +325,30 @@@ static void lguest_load_tr_desc(void
   * anyone (including userspace) can just use the raw "cpuid" instruction and
   * the Host won't even notice since it isn't privileged.  So we try not to get
   * too worked up about it. */
 -static void lguest_cpuid(unsigned int *eax, unsigned int *ebx,
 -                       unsigned int *ecx, unsigned int *edx)
 +static void lguest_cpuid(unsigned int *ax, unsigned int *bx,
 +                       unsigned int *cx, unsigned int *dx)
  {
 -      int function = *eax;
 +      int function = *ax;
  
 -      native_cpuid(eax, ebx, ecx, edx);
 +      native_cpuid(ax, bx, cx, dx);
        switch (function) {
        case 1: /* Basic feature request. */
                /* We only allow kernel to see SSE3, CMPXCHG16B and SSSE3 */
 -              *ecx &= 0x00002201;
 +              *cx &= 0x00002201;
                /* SSE, SSE2, FXSR, MMX, CMOV, CMPXCHG8B, FPU. */
 -              *edx &= 0x07808101;
 +              *dx &= 0x07808101;
                /* The Host can do a nice optimization if it knows that the
                 * kernel mappings (addresses above 0xC0000000 or whatever
                 * PAGE_OFFSET is set to) haven't changed.  But Linux calls
                 * flush_tlb_user() for both user and kernel mappings unless
                 * the Page Global Enable (PGE) feature bit is set. */
 -              *edx |= 0x00002000;
 +              *dx |= 0x00002000;
                break;
        case 0x80000000:
                /* Futureproof this a little: if they ask how much extended
                 * processor information there is, limit it to known fields. */
 -              if (*eax > 0x80000008)
 -                      *eax = 0x80000008;
 +              if (*ax > 0x80000008)
 +                      *ax = 0x80000008;
                break;
        }
  }
@@@ -756,10 -756,10 +757,10 @@@ static void lguest_time_init(void
   * segment), the privilege level (we're privilege level 1, the Host is 0 and
   * will not tolerate us trying to use that), the stack pointer, and the number
   * of pages in the stack. */
 -static void lguest_load_esp0(struct tss_struct *tss,
 +static void lguest_load_sp0(struct tss_struct *tss,
                                     struct thread_struct *thread)
  {
 -      lazy_hcall(LHCALL_SET_STACK, __KERNEL_DS|0x1, thread->esp0,
 +      lazy_hcall(LHCALL_SET_STACK, __KERNEL_DS|0x1, thread->sp0,
                   THREAD_SIZE/PAGE_SIZE);
  }
  
@@@ -789,11 -789,11 +790,11 @@@ static void lguest_wbinvd(void
   * code qualifies for Advanced.  It will also never interrupt anything.  It
   * does, however, allow us to get through the Linux boot code. */
  #ifdef CONFIG_X86_LOCAL_APIC
 -static void lguest_apic_write(unsigned long reg, unsigned long v)
 +static void lguest_apic_write(unsigned long reg, u32 v)
  {
  }
  
 -static unsigned long lguest_apic_read(unsigned long reg)
 +static u32 lguest_apic_read(unsigned long reg)
  {
        return 0;
  }
@@@ -813,7 -813,7 +814,7 @@@ static void lguest_safe_halt(void
   * rather than virtual addresses, so we use __pa() here. */
  static void lguest_power_off(void)
  {
-       hcall(LHCALL_CRASH, __pa("Power down"), 0, 0);
+       hcall(LHCALL_SHUTDOWN, __pa("Power down"), LGUEST_SHUTDOWN_POWEROFF, 0);
  }
  
  /*
   */
  static int lguest_panic(struct notifier_block *nb, unsigned long l, void *p)
  {
-       hcall(LHCALL_CRASH, __pa(p), 0, 0);
+       hcall(LHCALL_SHUTDOWN, __pa(p), LGUEST_SHUTDOWN_POWEROFF, 0);
        /* The hcall won't return, but to keep gcc happy, we're "done". */
        return NOTIFY_DONE;
  }
@@@ -927,6 -927,11 +928,11 @@@ static unsigned lguest_patch(u8 type, u
        return insn_len;
  }
  
+ static void lguest_restart(char *reason)
+ {
+       hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0);
+ }
  /*G:030 Once we get to lguest_init(), we know we're a Guest.  The pv_ops
   * structures in the kernel provide points for (almost) every routine we have
   * to override to avoid privileged instructions. */
@@@ -958,7 -963,7 +964,7 @@@ __init void lguest_init(void
        pv_cpu_ops.cpuid = lguest_cpuid;
        pv_cpu_ops.load_idt = lguest_load_idt;
        pv_cpu_ops.iret = lguest_iret;
 -      pv_cpu_ops.load_esp0 = lguest_load_esp0;
 +      pv_cpu_ops.load_sp0 = lguest_load_sp0;
        pv_cpu_ops.load_tr_desc = lguest_load_tr_desc;
        pv_cpu_ops.set_ldt = lguest_set_ldt;
        pv_cpu_ops.load_tls = lguest_load_tls;
         * the Guest routine to power off. */
        pm_power_off = lguest_power_off;
  
+       machine_ops.restart = lguest_restart;
        /* Now we're set up, call start_kernel() in init/main.c and we proceed
         * to boot as normal.  It never returns. */
        start_kernel();
diff --combined drivers/Makefile
index 9e1f808e43cfe9fb793d284e10788ca76e458702,57fb1450560ae6ad6816b49bb2f16b5b8b57ec91..0ee9a8a4095e6a5106789717dc57516a73d81fa8
@@@ -38,7 -38,7 +38,7 @@@ obj-$(CONFIG_SCSI)            += scsi
  obj-$(CONFIG_ATA)             += ata/
  obj-$(CONFIG_FUSION)          += message/
  obj-$(CONFIG_FIREWIRE)                += firewire/
 -obj-$(CONFIG_IEEE1394)                += ieee1394/
 +obj-y                         += ieee1394/
  obj-$(CONFIG_UIO)             += uio/
  obj-y                         += cdrom/
  obj-y                         += auxdisplay/
@@@ -47,6 -47,7 +47,6 @@@ obj-$(CONFIG_SPI)             += spi
  obj-$(CONFIG_PCCARD)          += pcmcia/
  obj-$(CONFIG_DIO)             += dio/
  obj-$(CONFIG_SBUS)            += sbus/
 -obj-$(CONFIG_KVM)             += kvm/
  obj-$(CONFIG_ZORRO)           += zorro/
  obj-$(CONFIG_MAC)             += macintosh/
  obj-$(CONFIG_ATA_OVER_ETH)    += block/aoe/
@@@ -72,7 -73,7 +72,7 @@@ obj-$(CONFIG_ISDN)            += isdn
  obj-$(CONFIG_EDAC)            += edac/
  obj-$(CONFIG_MCA)             += mca/
  obj-$(CONFIG_EISA)            += eisa/
- obj-$(CONFIG_LGUEST_GUEST)    += lguest/
+ obj-y                         += lguest/
  obj-$(CONFIG_CPU_FREQ)                += cpufreq/
  obj-$(CONFIG_CPU_IDLE)                += cpuidle/
  obj-$(CONFIG_MMC)             += mmc/
index 44adb00e1490a7cea29e28c217cc81cd907e570a,e9c3ba8aa1ecc7b486069d259586b11a0a7e98ad..61f2f8eb8cad7edb744559c873a854b483a3fcdc
@@@ -60,7 -60,7 +60,7 @@@ static struct lguest_pages *lguest_page
                  (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]);
  }
  
- static DEFINE_PER_CPU(struct lguest *, last_guest);
+ static DEFINE_PER_CPU(struct lg_cpu *, last_cpu);
  
  /*S:010
   * We approach the Switcher.
   * since it last ran.  We saw this set in interrupts_and_traps.c and
   * segments.c.
   */
- static void copy_in_guest_info(struct lguest *lg, struct lguest_pages *pages)
+ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
  {
        /* Copying all this data can be quite expensive.  We usually run the
         * same Guest we ran last time (and that Guest hasn't run anywhere else
         * meanwhile).  If that's not the case, we pretend everything in the
         * Guest has changed. */
-       if (__get_cpu_var(last_guest) != lg || lg->last_pages != pages) {
-               __get_cpu_var(last_guest) = lg;
-               lg->last_pages = pages;
-               lg->changed = CHANGED_ALL;
+       if (__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) {
+               __get_cpu_var(last_cpu) = cpu;
+               cpu->last_pages = pages;
+               cpu->changed = CHANGED_ALL;
        }
  
        /* These copies are pretty cheap, so we do them unconditionally: */
        pages->state.host_cr3 = __pa(current->mm->pgd);
        /* Set up the Guest's page tables to see this CPU's pages (and no
         * other CPU's pages). */
-       map_switcher_in_guest(lg, pages);
+       map_switcher_in_guest(cpu, pages);
        /* Set up the two "TSS" members which tell the CPU what stack to use
         * for traps which do directly into the Guest (ie. traps at privilege
         * level 1). */
-       pages->state.guest_tss.sp1 = lg->esp1;
-       pages->state.guest_tss.ss1 = lg->ss1;
+       pages->state.guest_tss.esp1 = cpu->esp1;
+       pages->state.guest_tss.ss1 = cpu->ss1;
  
        /* Copy direct-to-Guest trap entries. */
-       if (lg->changed & CHANGED_IDT)
-               copy_traps(lg, pages->state.guest_idt, default_idt_entries);
+       if (cpu->changed & CHANGED_IDT)
+               copy_traps(cpu, pages->state.guest_idt, default_idt_entries);
  
        /* Copy all GDT entries which the Guest can change. */
-       if (lg->changed & CHANGED_GDT)
-               copy_gdt(lg, pages->state.guest_gdt);
+       if (cpu->changed & CHANGED_GDT)
+               copy_gdt(cpu, pages->state.guest_gdt);
        /* If only the TLS entries have changed, copy them. */
-       else if (lg->changed & CHANGED_GDT_TLS)
-               copy_gdt_tls(lg, pages->state.guest_gdt);
+       else if (cpu->changed & CHANGED_GDT_TLS)
+               copy_gdt_tls(cpu, pages->state.guest_gdt);
  
        /* Mark the Guest as unchanged for next time. */
-       lg->changed = 0;
+       cpu->changed = 0;
  }
  
  /* Finally: the code to actually call into the Switcher to run the Guest. */
- static void run_guest_once(struct lguest *lg, struct lguest_pages *pages)
+ static void run_guest_once(struct lg_cpu *cpu, struct lguest_pages *pages)
  {
        /* This is a dummy value we need for GCC's sake. */
        unsigned int clobber;
  
        /* Copy the guest-specific information into this CPU's "struct
         * lguest_pages". */
-       copy_in_guest_info(lg, pages);
+       copy_in_guest_info(cpu, pages);
  
        /* Set the trap number to 256 (impossible value).  If we fault while
         * switching to the Guest (bad segment registers or bug), this will
         * cause us to abort the Guest. */
-       lg->regs->trapnum = 256;
+       cpu->regs->trapnum = 256;
  
        /* Now: we push the "eflags" register on the stack, then do an "lcall".
         * This is how we change from using the kernel code segment to using
                      * 0-th argument above, ie "a").  %ebx contains the
                      * physical address of the Guest's top-level page
                      * directory. */
-                    : "0"(pages), "1"(__pa(lg->pgdirs[lg->pgdidx].pgdir))
+                    : "0"(pages), "1"(__pa(cpu->lg->pgdirs[cpu->cpu_pgd].pgdir))
                     /* We tell gcc that all these registers could change,
                      * which means we don't have to save and restore them in
                      * the Switcher. */
  
  /*H:040 This is the i386-specific code to setup and run the Guest.  Interrupts
   * are disabled: we own the CPU. */
- void lguest_arch_run_guest(struct lguest *lg)
+ void lguest_arch_run_guest(struct lg_cpu *cpu)
  {
        /* Remember the awfully-named TS bit?  If the Guest has asked to set it
         * we set it now, so we can trap and pass that trap to the Guest if it
         * uses the FPU. */
-       if (lg->ts)
+       if (cpu->ts)
                lguest_set_ts();
  
        /* SYSENTER is an optimized way of doing system calls.  We can't allow
        /* Now we actually run the Guest.  It will return when something
         * interesting happens, and we can examine its registers to see what it
         * was doing. */
-       run_guest_once(lg, lguest_pages(raw_smp_processor_id()));
+       run_guest_once(cpu, lguest_pages(raw_smp_processor_id()));
  
        /* Note that the "regs" pointer contains two extra entries which are
         * not really registers: a trap number which says what interrupt or
         * bad virtual address.  We have to grab this now, because once we
         * re-enable interrupts an interrupt could fault and thus overwrite
         * cr2, or we could even move off to a different CPU. */
-       if (lg->regs->trapnum == 14)
-               lg->arch.last_pagefault = read_cr2();
+       if (cpu->regs->trapnum == 14)
+               cpu->arch.last_pagefault = read_cr2();
        /* Similarly, if we took a trap because the Guest used the FPU,
         * we have to restore the FPU it expects to see. */
-       else if (lg->regs->trapnum == 7)
+       else if (cpu->regs->trapnum == 7)
                math_state_restore();
  
        /* Restore SYSENTER if it's supposed to be on. */
   * When the Guest uses one of these instructions, we get a trap (General
   * Protection Fault) and come here.  We see if it's one of those troublesome
   * instructions and skip over it.  We return true if we did. */
- static int emulate_insn(struct lguest *lg)
+ static int emulate_insn(struct lg_cpu *cpu)
  {
        u8 insn;
        unsigned int insnlen = 0, in = 0, shift = 0;
        /* The eip contains the *virtual* address of the Guest's instruction:
         * guest_pa just subtracts the Guest's page_offset. */
-       unsigned long physaddr = guest_pa(lg, lg->regs->eip);
+       unsigned long physaddr = guest_pa(cpu, cpu->regs->eip);
  
        /* This must be the Guest kernel trying to do something, not userspace!
         * The bottom two bits of the CS segment register are the privilege
         * level. */
-       if ((lg->regs->cs & 3) != GUEST_PL)
+       if ((cpu->regs->cs & 3) != GUEST_PL)
                return 0;
  
        /* Decoding x86 instructions is icky. */
-       insn = lgread(lg, physaddr, u8);
+       insn = lgread(cpu, physaddr, u8);
  
        /* 0x66 is an "operand prefix".  It means it's using the upper 16 bits
           of the eax register. */
                shift = 16;
                /* The instruction is 1 byte so far, read the next byte. */
                insnlen = 1;
-               insn = lgread(lg, physaddr + insnlen, u8);
+               insn = lgread(cpu, physaddr + insnlen, u8);
        }
  
        /* We can ignore the lower bit for the moment and decode the 4 opcodes
        if (in) {
                /* Lower bit tells is whether it's a 16 or 32 bit access */
                if (insn & 0x1)
-                       lg->regs->eax = 0xFFFFFFFF;
+                       cpu->regs->eax = 0xFFFFFFFF;
                else
-                       lg->regs->eax |= (0xFFFF << shift);
+                       cpu->regs->eax |= (0xFFFF << shift);
        }
        /* Finally, we've "done" the instruction, so move past it. */
-       lg->regs->eip += insnlen;
+       cpu->regs->eip += insnlen;
        /* Success! */
        return 1;
  }
  
  /*H:050 Once we've re-enabled interrupts, we look at why the Guest exited. */
- void lguest_arch_handle_trap(struct lguest *lg)
+ void lguest_arch_handle_trap(struct lg_cpu *cpu)
  {
-       switch (lg->regs->trapnum) {
+       switch (cpu->regs->trapnum) {
        case 13: /* We've intercepted a General Protection Fault. */
                /* Check if this was one of those annoying IN or OUT
                 * instructions which we need to emulate.  If so, we just go
                 * back into the Guest after we've done it. */
-               if (lg->regs->errcode == 0) {
-                       if (emulate_insn(lg))
+               if (cpu->regs->errcode == 0) {
+                       if (emulate_insn(cpu))
                                return;
                }
                break;
                 *
                 * The errcode tells whether this was a read or a write, and
                 * whether kernel or userspace code. */
-               if (demand_page(lg, lg->arch.last_pagefault, lg->regs->errcode))
+               if (demand_page(cpu, cpu->arch.last_pagefault,
+                               cpu->regs->errcode))
                        return;
  
                /* OK, it's really not there (or not OK): the Guest needs to
                 * Note that if the Guest were really messed up, this could
                 * happen before it's done the LHCALL_LGUEST_INIT hypercall, so
                 * lg->lguest_data could be NULL */
-               if (lg->lguest_data &&
-                   put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2))
-                       kill_guest(lg, "Writing cr2");
+               if (cpu->lg->lguest_data &&
+                   put_user(cpu->arch.last_pagefault,
+                            &cpu->lg->lguest_data->cr2))
+                       kill_guest(cpu, "Writing cr2");
                break;
        case 7: /* We've intercepted a Device Not Available fault. */
                /* If the Guest doesn't want to know, we already restored the
                 * Floating Point Unit, so we just continue without telling
                 * it. */
-               if (!lg->ts)
+               if (!cpu->ts)
                        return;
                break;
        case 32 ... 255:
        case LGUEST_TRAP_ENTRY:
                /* Our 'struct hcall_args' maps directly over our regs: we set
                 * up the pointer now to indicate a hypercall is pending. */
-               lg->hcall = (struct hcall_args *)lg->regs;
+               cpu->hcall = (struct hcall_args *)cpu->regs;
                return;
        }
  
        /* We didn't handle the trap, so it needs to go to the Guest. */
-       if (!deliver_trap(lg, lg->regs->trapnum))
+       if (!deliver_trap(cpu, cpu->regs->trapnum))
                /* If the Guest doesn't have a handler (either it hasn't
                 * registered any yet, or it's one of the faults we don't let
                 * it handle), it dies with a cryptic error message. */
-               kill_guest(lg, "unhandled trap %li at %#lx (%#lx)",
-                          lg->regs->trapnum, lg->regs->eip,
-                          lg->regs->trapnum == 14 ? lg->arch.last_pagefault
-                          : lg->regs->errcode);
+               kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)",
+                          cpu->regs->trapnum, cpu->regs->eip,
+                          cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault
+                          : cpu->regs->errcode);
  }
  
  /* Now we can look at each of the routines this calls, in increasing order of
@@@ -416,7 -418,7 +418,7 @@@ void __init lguest_arch_host_init(void
                /* We know where we want the stack to be when the Guest enters
                 * the switcher: in pages->regs.  The stack grows upwards, so
                 * we start it at the end of that structure. */
 -              state->guest_tss.esp0 = (long)(&pages->regs + 1);
 +              state->guest_tss.sp0 = (long)(&pages->regs + 1);
                /* And this is the GDT entry to use for the stack: we keep a
                 * couple of special LGUEST entries. */
                state->guest_tss.ss0 = LGUEST_DS;
@@@ -487,17 -489,17 +489,17 @@@ void __exit lguest_arch_host_fini(void
  
  
  /*H:122 The i386-specific hypercalls simply farm out to the right functions. */
- int lguest_arch_do_hcall(struct lguest *lg, struct hcall_args *args)
+ int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
  {
        switch (args->arg0) {
        case LHCALL_LOAD_GDT:
-               load_guest_gdt(lg, args->arg1, args->arg2);
+               load_guest_gdt(cpu, args->arg1, args->arg2);
                break;
        case LHCALL_LOAD_IDT_ENTRY:
-               load_guest_idt_entry(lg, args->arg1, args->arg2, args->arg3);
+               load_guest_idt_entry(cpu, args->arg1, args->arg2, args->arg3);
                break;
        case LHCALL_LOAD_TLS:
-               guest_load_tls(lg, args->arg1);
+               guest_load_tls(cpu, args->arg1);
                break;
        default:
                /* Bad Guest.  Bad! */
  }
  
  /*H:126 i386-specific hypercall initialization: */
- int lguest_arch_init_hypercalls(struct lguest *lg)
+ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
  {
        u32 tsc_speed;
  
        /* The pointer to the Guest's "struct lguest_data" is the only
         * argument.  We check that address now. */
-       if (!lguest_address_ok(lg, lg->hcall->arg1, sizeof(*lg->lguest_data)))
+       if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1,
+                              sizeof(*cpu->lg->lguest_data)))
                return -EFAULT;
  
        /* Having checked it, we simply set lg->lguest_data to point straight
         * copy_to_user/from_user from now on, instead of lgread/write.  I put
         * this in to show that I'm not immune to writing stupid
         * optimizations. */
-       lg->lguest_data = lg->mem_base + lg->hcall->arg1;
+       cpu->lg->lguest_data = cpu->lg->mem_base + cpu->hcall->arg1;
  
        /* We insist that the Time Stamp Counter exist and doesn't change with
         * cpu frequency.  Some devious chip manufacturers decided that TSC
                tsc_speed = tsc_khz;
        else
                tsc_speed = 0;
-       if (put_user(tsc_speed, &lg->lguest_data->tsc_khz))
+       if (put_user(tsc_speed, &cpu->lg->lguest_data->tsc_khz))
                return -EFAULT;
  
        /* The interrupt code might not like the system call vector. */
-       if (!check_syscall_vector(lg))
-               kill_guest(lg, "bad syscall vector");
+       if (!check_syscall_vector(cpu->lg))
+               kill_guest(cpu, "bad syscall vector");
  
        return 0;
  }
   *
   * Most of the Guest's registers are left alone: we used get_zeroed_page() to
   * allocate the structure, so they will be 0. */
- void lguest_arch_setup_regs(struct lguest *lg, unsigned long start)
+ void lguest_arch_setup_regs(struct lg_cpu *cpu, unsigned long start)
  {
-       struct lguest_regs *regs = lg->regs;
+       struct lguest_regs *regs = cpu->regs;
  
        /* There are four "segment" registers which the Guest needs to boot:
         * The "code segment" register (cs) refers to the kernel code segment
  
        /* There are a couple of GDT entries the Guest expects when first
         * booting. */
-       setup_guest_gdt(lg);
+       setup_guest_gdt(cpu);
  }
diff --combined include/asm-x86/lguest.h
index 1c8367a692f67f106af26352e0d64650fc24f8a1,b9d003b8005ead3da2037a84c24f0ac3b7d91cc6..4d9367b72976a1601897af8ce3f448ad58245c11
@@@ -44,19 -44,19 +44,19 @@@ struct lguest_ro_stat
  {
        /* Host information we need to restore when we switch back. */
        u32 host_cr3;
 -      struct Xgt_desc_struct host_idt_desc;
 -      struct Xgt_desc_struct host_gdt_desc;
 +      struct desc_ptr host_idt_desc;
 +      struct desc_ptr host_gdt_desc;
        u32 host_sp;
  
        /* Fields which are used when guest is running. */
 -      struct Xgt_desc_struct guest_idt_desc;
 -      struct Xgt_desc_struct guest_gdt_desc;
 -      struct i386_hw_tss guest_tss;
 +      struct desc_ptr guest_idt_desc;
 +      struct desc_ptr guest_gdt_desc;
 +      struct x86_hw_tss guest_tss;
        struct desc_struct guest_idt[IDT_ENTRIES];
        struct desc_struct guest_gdt[GDT_ENTRIES];
  };
  
- struct lguest_arch
+ struct lg_cpu_arch
  {
        /* The GDT entries copied into lguest_ro_state when running. */
        struct desc_struct gdt[GDT_ENTRIES];
@@@ -78,8 -78,8 +78,8 @@@ static inline void lguest_set_ts(void
  }
  
  /* Full 4G segment descriptors, suitable for CS and DS. */
 -#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
 -#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
 +#define FULL_EXEC_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9b00} } })
 +#define FULL_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9300} } })
  
  #endif /* __ASSEMBLY__ */