[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Remove useless segments push/pop in VMXAssist.
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Node ID 275a8f9a07109375cd55a2bf90f111ffa09db06d # Parent b08b870770f9dc35d0a069662ec5ec80704cdd37 Remove useless segments push/pop in VMXAssist. According to Intel Spec, segments registors are cleared when exiting virtual-8086 mode through trap or interrupts gate, so it's no need to save their values in stack. Signed-off-by: Xin Li <xin.b.li@xxxxxxxxx> --- tools/firmware/vmxassist/setup.c | 22 +++++++++++----------- tools/firmware/vmxassist/trap.S | 16 ++-------------- tools/firmware/vmxassist/util.c | 6 ++---- tools/firmware/vmxassist/vm86.c | 21 +++++++-------------- tools/firmware/vmxassist/vm86.h | 2 -- 5 files changed, 22 insertions(+), 45 deletions(-) diff -r b08b870770f9 -r 275a8f9a0710 tools/firmware/vmxassist/setup.c --- a/tools/firmware/vmxassist/setup.c Mon Dec 04 09:08:47 2006 +0000 +++ b/tools/firmware/vmxassist/setup.c Mon Dec 04 09:20:12 2006 +0000 @@ -66,7 +66,7 @@ unsigned long memory_size; unsigned long memory_size; int initialize_real_mode; -extern char stack[], stack_top[]; +extern char stack_top[]; extern unsigned trap_handlers[]; void @@ -201,7 +201,7 @@ enter_real_mode(struct regs *regs) enter_real_mode(struct regs *regs) { /* mask off TSS busy bit */ - gdt[TSS_SELECTOR / sizeof(gdt[0])] &= ~0x0000020000000000ULL; + gdt[TSS_SELECTOR / sizeof(gdt[0])] &= ~0x0000020000000000ULL; /* start 8086 emulation of BIOS */ if (initialize_real_mode) { @@ -219,8 +219,10 @@ enter_real_mode(struct regs *regs) regs->cs = booting_vector << 8; /* AP entry point */ regs->eip = 0; } - regs->uesp = 0; - regs->uss = 0; + + regs->uesp = regs->uss = 0; + regs->eax = regs->ecx = regs->edx = regs->ebx = 0; + regs->esp = regs->ebp = regs->esi = regs->edi = 0; /* intercept accesses to the PIC */ setiomap(PIC_MASTER+PIC_CMD); @@ -236,14 +238,12 @@ enter_real_mode(struct regs *regs) /* this should get us into 16-bit mode */ return; - } else { - /* go from protected to real mode */ - regs->eflags |= EFLAGS_VM; - - set_mode(regs, VM86_PROTECTED_TO_REAL); - - emulate(regs); } + + /* go from protected to real mode */ + regs->eflags |= EFLAGS_VM; + set_mode(regs, VM86_PROTECTED_TO_REAL); + emulate(regs); } /* diff -r b08b870770f9 -r 275a8f9a0710 tools/firmware/vmxassist/trap.S --- a/tools/firmware/vmxassist/trap.S Mon Dec 04 09:08:47 2006 +0000 +++ b/tools/firmware/vmxassist/trap.S Mon Dec 04 09:20:12 2006 +0000 @@ -100,10 +100,6 @@ trap_handlers: .code32 .align 16 common_trap: /* common trap handler */ - pushl %gs - pushl %fs - pushl %ds - pushl %es pushal movl $(DATA_SELECTOR), %eax /* make sure these are sane */ @@ -114,17 +110,13 @@ common_trap: /* common trap handler * movl %esp, %ebp pushl %ebp - pushl 52(%ebp) - pushl 48(%ebp) + pushl 36(%ebp) + pushl 32(%ebp) call trap /* trap(trapno, errno, regs) */ addl $12, %esp trap_return: popal - popl %es - popl %ds - popl %fs - popl %gs addl $8, %esp /* skip trapno, errno */ iret /* NOT REACHED */ @@ -152,10 +144,6 @@ switch_to_real_mode: pushl oldctx+VMX_ASSIST_CTX_EIP pushl $-1 /* trapno, errno */ pushl $-1 - pushl %gs - pushl %fs - pushl %ds - pushl %es pushal movl %esp, %ebp diff -r b08b870770f9 -r 275a8f9a0710 tools/firmware/vmxassist/util.c --- a/tools/firmware/vmxassist/util.c Mon Dec 04 09:08:47 2006 +0000 +++ b/tools/firmware/vmxassist/util.c Mon Dec 04 09:20:12 2006 +0000 @@ -62,17 +62,15 @@ dump_regs(struct regs *regs) regs->eax, regs->ecx, regs->edx, regs->ebx); printf("esp %8x ebp %8x esi %8x edi %8x\n", regs->esp, regs->ebp, regs->esi, regs->edi); - printf("es %8x ds %8x fs %8x gs %8x\n", - regs->es, regs->ds, regs->fs, regs->gs); printf("trapno %8x errno %8x\n", regs->trapno, regs->errno); printf("eip %8x cs %8x eflags %8x\n", regs->eip, regs->cs, regs->eflags); - printf("uesp %8x uss %8x \n", + printf("uesp %8x uss %8x\n", regs->uesp, regs->uss); printf("ves %8x vds %8x vfs %8x vgs %8x\n", regs->ves, regs->vds, regs->vfs, regs->vgs); - printf("cr0 %8lx cr2 %8x cr3 %8lx cr4 %8lx\n", + printf("cr0 %8lx cr2 %8x cr3 %8lx cr4 %8lx\n\n", (long)oldctx.cr0, get_cr2(), (long)oldctx.cr3, (long)oldctx.cr4); } diff -r b08b870770f9 -r 275a8f9a0710 tools/firmware/vmxassist/vm86.c --- a/tools/firmware/vmxassist/vm86.c Mon Dec 04 09:08:47 2006 +0000 +++ b/tools/firmware/vmxassist/vm86.c Mon Dec 04 09:20:12 2006 +0000 @@ -376,9 +376,9 @@ segment(unsigned prefix, struct regs *re if (prefix & SEG_SS) seg = regs->uss; if (prefix & SEG_FS) - seg = regs->fs; + seg = regs->vfs; if (prefix & SEG_GS) - seg = regs->gs; + seg = regs->vgs; return seg; } @@ -934,6 +934,8 @@ static void static void protected_mode(struct regs *regs) { + extern char stack_top[]; + regs->eflags &= ~(EFLAGS_TF|EFLAGS_VM); oldctx.eip = regs->eip; @@ -958,12 +960,10 @@ protected_mode(struct regs *regs) &oldctx.gs_limit, &oldctx.gs_arbytes); /* initialize jump environment to warp back to protected mode */ + regs->uss = DATA_SELECTOR; + regs->uesp = stack_top; regs->cs = CODE_SELECTOR; - regs->ds = DATA_SELECTOR; - regs->es = DATA_SELECTOR; - regs->fs = DATA_SELECTOR; - regs->gs = DATA_SELECTOR; - regs->eip = (unsigned) &switch_to_protected_mode; + regs->eip = (unsigned) switch_to_protected_mode; /* this should get us into 32-bit mode */ } @@ -975,10 +975,6 @@ real_mode(struct regs *regs) real_mode(struct regs *regs) { regs->eflags |= EFLAGS_VM | 0x02; - regs->ds = DATA_SELECTOR; - regs->es = DATA_SELECTOR; - regs->fs = DATA_SELECTOR; - regs->gs = DATA_SELECTOR; /* * When we transition from protected to real-mode and we @@ -1070,9 +1066,6 @@ set_mode(struct regs *regs, enum vm86_mo case VM86_PROTECTED: if (mode == VM86_REAL_TO_PROTECTED) { protected_mode(regs); -// printf("<VM86_PROTECTED>\n"); - mode = newmode; - return; } else panic("unexpected protected mode transition"); break; diff -r b08b870770f9 -r 275a8f9a0710 tools/firmware/vmxassist/vm86.h --- a/tools/firmware/vmxassist/vm86.h Mon Dec 04 09:08:47 2006 +0000 +++ b/tools/firmware/vmxassist/vm86.h Mon Dec 04 09:20:12 2006 +0000 @@ -34,7 +34,6 @@ struct regs { unsigned edi, esi, ebp, esp, ebx, edx, ecx, eax; - unsigned es, ds, fs, gs; unsigned trapno, errno; unsigned eip, cs, eflags, uesp, uss; unsigned ves, vds, vfs, vgs; @@ -55,7 +54,6 @@ enum vm86_mode { extern enum vm86_mode prevmode, mode; extern struct vmx_assist_context oldctx; -extern struct vmx_assist_context newctx; extern void emulate(struct regs *); extern void dump_regs(struct regs *); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |