-static void set_ts(void)
-{
- u32 cr0;
-
- cr0 = read_cr0();
- if (!(cr0 & 8))
- write_cr0(cr0|8);
-}
-
-static void copy_in_guest_info(struct lguest *lg, struct lguest_pages *pages)
-{
- 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;
- }
-
- /* These are pretty cheap, so we do them unconditionally. */
- pages->state.host_cr3 = __pa(current->mm->pgd);
- map_switcher_in_guest(lg, pages);
- pages->state.guest_tss.esp1 = lg->esp1;
- pages->state.guest_tss.ss1 = lg->ss1;
-
- /* Copy direct trap entries. */
- if (lg->changed & CHANGED_IDT)
- copy_traps(lg, pages->state.guest_idt, default_idt_entries);
-
- /* Copy all GDT entries but the TSS. */
- if (lg->changed & CHANGED_GDT)
- copy_gdt(lg, 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);
-
- lg->changed = 0;
-}
-
-static void run_guest_once(struct lguest *lg, struct lguest_pages *pages)
-{
- unsigned int clobber;
-
- copy_in_guest_info(lg, pages);
-
- /* Put eflags on stack, lcall does rest: suitable for iret return. */
- asm volatile("pushf; lcall *lguest_entry"
- : "=a"(clobber), "=b"(clobber)
- : "0"(pages), "1"(__pa(lg->pgdirs[lg->pgdidx].pgdir))
- : "memory", "%edx", "%ecx", "%edi", "%esi");
-}
-