ia64/xen-unstable

changeset 12773:275a8f9a0710

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@intel.com>
author kfraser@localhost.localdomain
date Mon Dec 04 09:20:12 2006 +0000 (2006-12-04)
parents b08b870770f9
children d603aed5ad6d d8befb109c39
files tools/firmware/vmxassist/setup.c tools/firmware/vmxassist/trap.S tools/firmware/vmxassist/util.c tools/firmware/vmxassist/vm86.c tools/firmware/vmxassist/vm86.h
line diff
     1.1 --- a/tools/firmware/vmxassist/setup.c	Mon Dec 04 09:08:47 2006 +0000
     1.2 +++ b/tools/firmware/vmxassist/setup.c	Mon Dec 04 09:20:12 2006 +0000
     1.3 @@ -66,7 +66,7 @@ struct vmx_assist_context newctx;
     1.4  unsigned long memory_size;
     1.5  int initialize_real_mode;
     1.6  
     1.7 -extern char stack[], stack_top[];
     1.8 +extern char stack_top[];
     1.9  extern unsigned trap_handlers[];
    1.10  
    1.11  void
    1.12 @@ -201,7 +201,7 @@ void
    1.13  enter_real_mode(struct regs *regs)
    1.14  {
    1.15  	/* mask off TSS busy bit */
    1.16 -        gdt[TSS_SELECTOR / sizeof(gdt[0])] &= ~0x0000020000000000ULL;
    1.17 +	gdt[TSS_SELECTOR / sizeof(gdt[0])] &= ~0x0000020000000000ULL;
    1.18  
    1.19  	/* start 8086 emulation of BIOS */
    1.20  	if (initialize_real_mode) {
    1.21 @@ -219,8 +219,10 @@ enter_real_mode(struct regs *regs)
    1.22  			regs->cs = booting_vector << 8; /* AP entry point */
    1.23  			regs->eip = 0;
    1.24  		}
    1.25 -		regs->uesp = 0;
    1.26 -		regs->uss = 0;
    1.27 +
    1.28 +		regs->uesp = regs->uss = 0;
    1.29 +		regs->eax = regs->ecx = regs->edx = regs->ebx = 0;
    1.30 +		regs->esp = regs->ebp = regs->esi = regs->edi = 0;
    1.31  
    1.32  		/* intercept accesses to the PIC */
    1.33  		setiomap(PIC_MASTER+PIC_CMD);
    1.34 @@ -236,14 +238,12 @@ enter_real_mode(struct regs *regs)
    1.35  
    1.36  		/* this should get us into 16-bit mode */
    1.37  		return;
    1.38 -	} else {
    1.39 -		/* go from protected to real mode */
    1.40 -		regs->eflags |= EFLAGS_VM;
    1.41 +	}
    1.42  
    1.43 -		set_mode(regs, VM86_PROTECTED_TO_REAL);
    1.44 -
    1.45 -		emulate(regs);
    1.46 -	}
    1.47 +	/* go from protected to real mode */
    1.48 +	regs->eflags |= EFLAGS_VM;
    1.49 +	set_mode(regs, VM86_PROTECTED_TO_REAL);
    1.50 +	emulate(regs);
    1.51  }
    1.52  
    1.53  /*
     2.1 --- a/tools/firmware/vmxassist/trap.S	Mon Dec 04 09:08:47 2006 +0000
     2.2 +++ b/tools/firmware/vmxassist/trap.S	Mon Dec 04 09:20:12 2006 +0000
     2.3 @@ -100,10 +100,6 @@ trap_handlers:
     2.4  	.code32
     2.5  	.align	16
     2.6  common_trap:				/* common trap handler */
     2.7 -	pushl	%gs
     2.8 -	pushl	%fs
     2.9 -	pushl	%ds
    2.10 -	pushl	%es
    2.11  	pushal
    2.12  
    2.13  	movl	$(DATA_SELECTOR), %eax	/* make sure these are sane */
    2.14 @@ -114,17 +110,13 @@ common_trap:				/* common trap handler *
    2.15  	movl	%esp, %ebp
    2.16  
    2.17  	pushl	%ebp
    2.18 -	pushl	52(%ebp)
    2.19 -	pushl	48(%ebp)
    2.20 +	pushl	36(%ebp)
    2.21 +	pushl	32(%ebp)
    2.22  	call	trap			/* trap(trapno, errno, regs) */
    2.23  	addl	$12, %esp
    2.24  
    2.25  trap_return:
    2.26  	popal
    2.27 -	popl	%es
    2.28 -	popl	%ds
    2.29 -	popl	%fs
    2.30 -	popl	%gs
    2.31  	addl	$8, %esp		/* skip trapno, errno */
    2.32  	iret
    2.33  	/* NOT REACHED */
    2.34 @@ -152,10 +144,6 @@ switch_to_real_mode:
    2.35  	pushl	oldctx+VMX_ASSIST_CTX_EIP
    2.36  	pushl	$-1			/* trapno, errno */
    2.37  	pushl	$-1
    2.38 -	pushl	%gs
    2.39 -	pushl	%fs
    2.40 -	pushl	%ds
    2.41 -	pushl	%es
    2.42  	pushal
    2.43  
    2.44  	movl	%esp, %ebp
     3.1 --- a/tools/firmware/vmxassist/util.c	Mon Dec 04 09:08:47 2006 +0000
     3.2 +++ b/tools/firmware/vmxassist/util.c	Mon Dec 04 09:20:12 2006 +0000
     3.3 @@ -62,17 +62,15 @@ dump_regs(struct regs *regs)
     3.4  		regs->eax, regs->ecx, regs->edx, regs->ebx);
     3.5  	printf("esp    %8x ebp    %8x esi    %8x edi    %8x\n",
     3.6  		regs->esp, regs->ebp, regs->esi, regs->edi);
     3.7 -	printf("es     %8x ds     %8x fs     %8x gs     %8x\n",
     3.8 -		regs->es, regs->ds, regs->fs, regs->gs);
     3.9  	printf("trapno %8x errno  %8x\n", regs->trapno, regs->errno);
    3.10  	printf("eip    %8x cs     %8x eflags %8x\n",
    3.11  		regs->eip, regs->cs, regs->eflags);
    3.12 -	printf("uesp   %8x uss    %8x \n",
    3.13 +	printf("uesp   %8x uss    %8x\n",
    3.14  		regs->uesp, regs->uss);
    3.15  	printf("ves    %8x vds    %8x vfs    %8x vgs    %8x\n",
    3.16  		regs->ves, regs->vds, regs->vfs, regs->vgs);
    3.17  
    3.18 -	printf("cr0    %8lx cr2    %8x cr3    %8lx cr4    %8lx\n",
    3.19 +	printf("cr0    %8lx cr2    %8x cr3    %8lx cr4    %8lx\n\n",
    3.20  		(long)oldctx.cr0, get_cr2(),
    3.21  		(long)oldctx.cr3, (long)oldctx.cr4);
    3.22  }
     4.1 --- a/tools/firmware/vmxassist/vm86.c	Mon Dec 04 09:08:47 2006 +0000
     4.2 +++ b/tools/firmware/vmxassist/vm86.c	Mon Dec 04 09:20:12 2006 +0000
     4.3 @@ -376,9 +376,9 @@ segment(unsigned prefix, struct regs *re
     4.4  	if (prefix & SEG_SS)
     4.5  		seg = regs->uss;
     4.6  	if (prefix & SEG_FS)
     4.7 -		seg = regs->fs;
     4.8 +		seg = regs->vfs;
     4.9  	if (prefix & SEG_GS)
    4.10 -		seg = regs->gs;
    4.11 +		seg = regs->vgs;
    4.12  	return seg;
    4.13  }
    4.14  
    4.15 @@ -934,6 +934,8 @@ load_or_clear_seg(unsigned long sel, uin
    4.16  static void
    4.17  protected_mode(struct regs *regs)
    4.18  {
    4.19 +	extern char stack_top[];
    4.20 +
    4.21  	regs->eflags &= ~(EFLAGS_TF|EFLAGS_VM);
    4.22  
    4.23  	oldctx.eip = regs->eip;
    4.24 @@ -958,12 +960,10 @@ protected_mode(struct regs *regs)
    4.25  			  &oldctx.gs_limit, &oldctx.gs_arbytes);
    4.26  
    4.27  	/* initialize jump environment to warp back to protected mode */
    4.28 +	regs->uss = DATA_SELECTOR;
    4.29 +	regs->uesp = stack_top;
    4.30  	regs->cs = CODE_SELECTOR;
    4.31 -	regs->ds = DATA_SELECTOR;
    4.32 -	regs->es = DATA_SELECTOR;
    4.33 -	regs->fs = DATA_SELECTOR;
    4.34 -	regs->gs = DATA_SELECTOR;
    4.35 -	regs->eip = (unsigned) &switch_to_protected_mode;
    4.36 +	regs->eip = (unsigned) switch_to_protected_mode;
    4.37  
    4.38  	/* this should get us into 32-bit mode */
    4.39  }
    4.40 @@ -975,10 +975,6 @@ static void
    4.41  real_mode(struct regs *regs)
    4.42  {
    4.43  	regs->eflags |= EFLAGS_VM | 0x02;
    4.44 -	regs->ds = DATA_SELECTOR;
    4.45 -	regs->es = DATA_SELECTOR;
    4.46 -	regs->fs = DATA_SELECTOR;
    4.47 -	regs->gs = DATA_SELECTOR;
    4.48  
    4.49  	/*
    4.50  	 * When we transition from protected to real-mode and we
    4.51 @@ -1070,9 +1066,6 @@ set_mode(struct regs *regs, enum vm86_mo
    4.52  	case VM86_PROTECTED:
    4.53  		if (mode == VM86_REAL_TO_PROTECTED) {
    4.54  			protected_mode(regs);
    4.55 -//			printf("<VM86_PROTECTED>\n");
    4.56 -			mode = newmode;
    4.57 -			return;
    4.58  		} else
    4.59  			panic("unexpected protected mode transition");
    4.60  		break;
     5.1 --- a/tools/firmware/vmxassist/vm86.h	Mon Dec 04 09:08:47 2006 +0000
     5.2 +++ b/tools/firmware/vmxassist/vm86.h	Mon Dec 04 09:20:12 2006 +0000
     5.3 @@ -34,7 +34,6 @@
     5.4  
     5.5  struct regs {
     5.6  	unsigned	edi, esi, ebp, esp, ebx, edx, ecx, eax;
     5.7 -	unsigned	es, ds, fs, gs;
     5.8  	unsigned	trapno, errno;
     5.9  	unsigned	eip, cs, eflags, uesp, uss;
    5.10  	unsigned	ves, vds, vfs, vgs;
    5.11 @@ -55,7 +54,6 @@ enum vm86_mode {
    5.12  
    5.13  extern enum vm86_mode prevmode, mode;
    5.14  extern struct vmx_assist_context oldctx;
    5.15 -extern struct vmx_assist_context newctx;
    5.16  
    5.17  extern void emulate(struct regs *);
    5.18  extern void dump_regs(struct regs *);