ia64/xen-unstable

changeset 9564:60071beccf18

This patch fixes several issues related to vmxassist:
1) AP bring up;
2) RHEL4 IA32e installation;
3) SLES10 IA32e installation;

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 01 14:59:12 2006 +0100 (2006-04-01)
parents 9bee4875a848
children b524714dfb66
files tools/firmware/vmxassist/Makefile 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/Makefile	Sat Apr 01 11:08:50 2006 +0100
     1.2 +++ b/tools/firmware/vmxassist/Makefile	Sat Apr 01 14:59:12 2006 +0100
     1.3 @@ -53,25 +53,25 @@ vmxassist.bin: vmxassist.ld $(OBJECTS)
     1.4  	dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
     1.5  	rm -f vmxassist.tmp
     1.6  
     1.7 -head.o: machine.h head.S
     1.8 +head.o: machine.h vm86.h head.S
     1.9  	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c head.S
    1.10  
    1.11 -trap.o: machine.h offsets.h trap.S
    1.12 +trap.o: machine.h vm86.h offsets.h trap.S
    1.13  	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c trap.S
    1.14  
    1.15 -vm86.o: machine.h vm86.c
    1.16 +vm86.o: machine.h vm86.h vm86.c
    1.17  	$(CC) $(CFLAGS) -c vm86.c
    1.18  
    1.19 -setup.o: machine.h setup.c
    1.20 +setup.o: machine.h vm86.h setup.c
    1.21  	$(CC) $(CFLAGS) -c setup.c
    1.22  
    1.23 -util.o: machine.h util.c
    1.24 +util.o: machine.h vm86.h util.c
    1.25  	$(CC) $(CFLAGS) -c util.c
    1.26  
    1.27  offsets.h: gen
    1.28  	./gen > offsets.h
    1.29  
    1.30 -gen:	gen.c
    1.31 +gen:	vm86.h gen.c
    1.32  	$(HOSTCC) $(HOSTCFLAGS) -I. $(XENINC) -o gen gen.c
    1.33  
    1.34  clean:
     2.1 --- a/tools/firmware/vmxassist/trap.S	Sat Apr 01 11:08:50 2006 +0100
     2.2 +++ b/tools/firmware/vmxassist/trap.S	Sat Apr 01 14:59:12 2006 +0100
     2.3 @@ -18,6 +18,7 @@
     2.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
     2.5   */
     2.6  #include "machine.h"
     2.7 +#include "vm86.h"
     2.8  #include "offsets.h"
     2.9  
    2.10  /*
     3.1 --- a/tools/firmware/vmxassist/util.c	Sat Apr 01 11:08:50 2006 +0100
     3.2 +++ b/tools/firmware/vmxassist/util.c	Sat Apr 01 14:59:12 2006 +0100
     3.3 @@ -18,7 +18,6 @@
     3.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
     3.5   */
     3.6  #include <stdarg.h>
     3.7 -#include <vm86.h>
     3.8  
     3.9  #include "util.h"
    3.10  #include "machine.h"
     4.1 --- a/tools/firmware/vmxassist/vm86.c	Sat Apr 01 11:08:50 2006 +0100
     4.2 +++ b/tools/firmware/vmxassist/vm86.c	Sat Apr 01 14:59:12 2006 +0100
     4.3 @@ -34,7 +34,7 @@
     4.4  #define	SEG_FS		0x0040
     4.5  #define	SEG_GS		0x0080
     4.6  
     4.7 -unsigned prev_eip = 0;
     4.8 +static unsigned prev_eip = 0;
     4.9  enum vm86_mode mode = 0;
    4.10  
    4.11  #ifdef DEBUG
    4.12 @@ -50,23 +50,41 @@ char *states[] = {
    4.13  static char *rnames[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
    4.14  #endif /* DEBUG */
    4.15  
    4.16 -unsigned
    4.17 +static unsigned
    4.18  address(struct regs *regs, unsigned seg, unsigned off)
    4.19  {
    4.20  	unsigned long long entry;
    4.21 -	unsigned addr;
    4.22 +	unsigned seg_base, seg_limit;
    4.23 +	unsigned entry_low, entry_high;
    4.24  
    4.25 -	if (seg == 0)
    4.26 -		return off;
    4.27 +	if (seg == 0) {
    4.28 +		if (mode == VM86_REAL || mode == VM86_REAL_TO_PROTECTED)
    4.29 +			return off;
    4.30 +		else
    4.31 +			panic("segment is zero, but not in real mode!\n");
    4.32 +	}
    4.33  
    4.34 -	if (seg > oldctx.gdtr_limit)
    4.35 +	if (mode == VM86_REAL || seg > oldctx.gdtr_limit ||
    4.36 +	    (mode == VM86_REAL_TO_PROTECTED && regs->cs == seg))
    4.37  		return ((seg & 0xFFFF) << 4) + off;
    4.38  
    4.39  	entry = ((unsigned long long *) oldctx.gdtr_base)[seg >> 3];
    4.40 -	addr = (((entry >> (56-24)) & 0xFF000000) |
    4.41 -		((entry >> (32-16)) & 0x00FF0000) |
    4.42 -		((entry >> (   16)) & 0x0000FFFF)) + off;
    4.43 -	return addr;
    4.44 +	entry_high = entry >> 32;
    4.45 +	entry_low = entry & 0xFFFFFFFF;
    4.46 +
    4.47 +	seg_base  = (entry_high & 0xFF000000) | ((entry >> 16) & 0xFFFFFF);
    4.48 +	seg_limit = (entry_high & 0xF0000) | (entry_low & 0xFFFF);
    4.49 +
    4.50 +	if (entry_high & 0x8000 &&
    4.51 +	    ((entry_high & 0x800000 && off >> 12 <= seg_limit) ||
    4.52 +	    (!(entry_high & 0x800000) && off <= seg_limit)))
    4.53 +		return seg_base + off;
    4.54 +
    4.55 +	panic("should never reach here in function address():\n\t"
    4.56 +	      "entry=0x%08x%08x, mode=%d, seg=0x%08x, offset=0x%08x\n",
    4.57 +	      entry_high, entry_low, mode, seg, off);
    4.58 +
    4.59 +	return 0;
    4.60  }
    4.61  
    4.62  #ifdef DEBUG
    4.63 @@ -194,7 +212,7 @@ fetch8(struct regs *regs)
    4.64  	return read8(addr);
    4.65  }
    4.66  
    4.67 -unsigned
    4.68 +static unsigned
    4.69  getreg32(struct regs *regs, int r)
    4.70  {
    4.71  	switch (r & 7) {
    4.72 @@ -210,13 +228,13 @@ getreg32(struct regs *regs, int r)
    4.73  	return ~0;
    4.74  }
    4.75  
    4.76 -unsigned
    4.77 +static unsigned
    4.78  getreg16(struct regs *regs, int r)
    4.79  {
    4.80  	return MASK16(getreg32(regs, r));
    4.81  }
    4.82  
    4.83 -unsigned
    4.84 +static unsigned
    4.85  getreg8(struct regs *regs, int r)
    4.86  {
    4.87  	switch (r & 7) {
    4.88 @@ -232,7 +250,7 @@ getreg8(struct regs *regs, int r)
    4.89  	return ~0;
    4.90  }
    4.91  
    4.92 -void
    4.93 +static void
    4.94  setreg32(struct regs *regs, int r, unsigned v)
    4.95  {
    4.96  	switch (r & 7) {
    4.97 @@ -247,13 +265,13 @@ setreg32(struct regs *regs, int r, unsig
    4.98  	}
    4.99  }
   4.100  
   4.101 -void
   4.102 +static void
   4.103  setreg16(struct regs *regs, int r, unsigned v)
   4.104  {
   4.105  	setreg32(regs, r, (getreg32(regs, r) & ~0xFFFF) | MASK16(v));
   4.106  }
   4.107  
   4.108 -void
   4.109 +static void
   4.110  setreg8(struct regs *regs, int r, unsigned v)
   4.111  {
   4.112  	v &= 0xFF;
   4.113 @@ -269,7 +287,7 @@ setreg8(struct regs *regs, int r, unsign
   4.114  	}
   4.115  }
   4.116  
   4.117 -unsigned
   4.118 +static unsigned
   4.119  segment(unsigned prefix, struct regs *regs, unsigned seg)
   4.120  {
   4.121  	if (prefix & SEG_ES)
   4.122 @@ -287,7 +305,7 @@ segment(unsigned prefix, struct regs *re
   4.123  	return seg;
   4.124  }
   4.125  
   4.126 -unsigned
   4.127 +static unsigned
   4.128  sib(struct regs *regs, int mod, unsigned byte)
   4.129  {
   4.130  	unsigned scale = (byte >> 6) & 3;
   4.131 @@ -319,7 +337,7 @@ sib(struct regs *regs, int mod, unsigned
   4.132  /*
   4.133   * Operand (modrm) decode
   4.134   */
   4.135 -unsigned
   4.136 +static unsigned
   4.137  operand(unsigned prefix, struct regs *regs, unsigned modrm)
   4.138  {
   4.139  	int mod, disp = 0, seg;
   4.140 @@ -418,7 +436,7 @@ operand(unsigned prefix, struct regs *re
   4.141  /*
   4.142   * Load new IDT
   4.143   */
   4.144 -int
   4.145 +static int
   4.146  lidt(struct regs *regs, unsigned prefix, unsigned modrm)
   4.147  {
   4.148  	unsigned eip = regs->eip - 3;
   4.149 @@ -438,7 +456,7 @@ lidt(struct regs *regs, unsigned prefix,
   4.150  /*
   4.151   * Load new GDT
   4.152   */
   4.153 -int
   4.154 +static int
   4.155  lgdt(struct regs *regs, unsigned prefix, unsigned modrm)
   4.156  {
   4.157  	unsigned eip = regs->eip - 3;
   4.158 @@ -458,7 +476,7 @@ lgdt(struct regs *regs, unsigned prefix,
   4.159  /*
   4.160   * Modify CR0 either through an lmsw instruction.
   4.161   */
   4.162 -int
   4.163 +static int
   4.164  lmsw(struct regs *regs, unsigned prefix, unsigned modrm)
   4.165  {
   4.166  	unsigned eip = regs->eip - 3;
   4.167 @@ -481,7 +499,7 @@ lmsw(struct regs *regs, unsigned prefix,
   4.168   * We need to handle moves that address memory beyond the 64KB segment
   4.169   * limit that VM8086 mode enforces.
   4.170   */
   4.171 -int
   4.172 +static int
   4.173  movr(struct regs *regs, unsigned prefix, unsigned opc)
   4.174  {
   4.175  	unsigned eip = regs->eip - 1;
   4.176 @@ -546,7 +564,7 @@ movr(struct regs *regs, unsigned prefix,
   4.177  /*
   4.178   * Move to and from a control register.
   4.179   */
   4.180 -int
   4.181 +static int
   4.182  movcr(struct regs *regs, unsigned prefix, unsigned opc)
   4.183  {
   4.184  	unsigned eip = regs->eip - 2;
   4.185 @@ -618,7 +636,7 @@ static inline void set_eflags_ZF(unsigne
   4.186   * We need to handle cmp opcodes that address memory beyond the 64KB
   4.187   * segment limit that VM8086 mode enforces.
   4.188   */
   4.189 -int
   4.190 +static int
   4.191  cmp(struct regs *regs, unsigned prefix, unsigned opc)
   4.192  {
   4.193  	unsigned eip = regs->eip - 1;
   4.194 @@ -658,7 +676,7 @@ cmp(struct regs *regs, unsigned prefix, 
   4.195   * We need to handle test opcodes that address memory beyond the 64KB
   4.196   * segment limit that VM8086 mode enforces.
   4.197   */
   4.198 -int
   4.199 +static int
   4.200  test(struct regs *regs, unsigned prefix, unsigned opc)
   4.201  {
   4.202  	unsigned eip = regs->eip - 1;
   4.203 @@ -691,7 +709,7 @@ test(struct regs *regs, unsigned prefix,
   4.204   * We need to handle pop opcodes that address memory beyond the 64KB
   4.205   * segment limit that VM8086 mode enforces.
   4.206   */
   4.207 -int
   4.208 +static int
   4.209  pop(struct regs *regs, unsigned prefix, unsigned opc)
   4.210  {
   4.211  	unsigned eip = regs->eip - 1;
   4.212 @@ -721,7 +739,7 @@ pop(struct regs *regs, unsigned prefix, 
   4.213  /*
   4.214   * Emulate a segment load in protected mode
   4.215   */
   4.216 -int
   4.217 +static int
   4.218  load_seg(unsigned long sel, uint32_t *base, uint32_t *limit, union vmcs_arbytes *arbytes)
   4.219  {
   4.220  	unsigned long long entry;
   4.221 @@ -768,7 +786,7 @@ load_seg(unsigned long sel, uint32_t *ba
   4.222  /*
   4.223   * Transition to protected mode
   4.224   */
   4.225 -void
   4.226 +static void
   4.227  protected_mode(struct regs *regs)
   4.228  {
   4.229  	regs->eflags &= ~(EFLAGS_TF|EFLAGS_VM);
   4.230 @@ -842,7 +860,7 @@ protected_mode(struct regs *regs)
   4.231  /*
   4.232   * Start real-mode emulation
   4.233   */
   4.234 -void
   4.235 +static void
   4.236  real_mode(struct regs *regs)
   4.237  {
   4.238  	regs->eflags |= EFLAGS_VM | 0x02;
   4.239 @@ -935,7 +953,7 @@ set_mode(struct regs *regs, enum vm86_mo
   4.240  	TRACE((regs, 0, states[mode]));
   4.241  }
   4.242  
   4.243 -void
   4.244 +static void
   4.245  jmpl(struct regs *regs, int prefix)
   4.246  {
   4.247  	unsigned n = regs->eip;
   4.248 @@ -963,7 +981,7 @@ jmpl(struct regs *regs, int prefix)
   4.249  		panic("jmpl");
   4.250  }
   4.251  
   4.252 -void
   4.253 +static void
   4.254  retl(struct regs *regs, int prefix)
   4.255  {
   4.256  	unsigned cs, eip;
   4.257 @@ -990,7 +1008,7 @@ retl(struct regs *regs, int prefix)
   4.258  		panic("retl");
   4.259  }
   4.260  
   4.261 -void
   4.262 +static void
   4.263  interrupt(struct regs *regs, int n)
   4.264  {
   4.265  	TRACE((regs, 0, "external interrupt %d", n));
   4.266 @@ -1008,7 +1026,7 @@ interrupt(struct regs *regs, int n)
   4.267   * interrupt vectors. The following simple state machine catches
   4.268   * these attempts and rewrites them.
   4.269   */
   4.270 -int
   4.271 +static int
   4.272  outbyte(struct regs *regs, unsigned prefix, unsigned opc)
   4.273  {
   4.274  	static char icw2[2] = { 0 };
   4.275 @@ -1059,7 +1077,7 @@ outbyte(struct regs *regs, unsigned pref
   4.276  	return 1;
   4.277  }
   4.278  
   4.279 -int
   4.280 +static int
   4.281  inbyte(struct regs *regs, unsigned prefix, unsigned opc)
   4.282  {
   4.283  	int port;
   4.284 @@ -1086,7 +1104,7 @@ enum { OPC_INVALID, OPC_EMULATED };
   4.285   * a small subset of the opcodes, and not all opcodes are implemented for each
   4.286   * of the four modes we can operate in.
   4.287   */
   4.288 -int
   4.289 +static int
   4.290  opcode(struct regs *regs)
   4.291  {
   4.292  	unsigned eip = regs->eip;
   4.293 @@ -1246,7 +1264,7 @@ opcode(struct regs *regs)
   4.294  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   4.295  			    (mode == VM86_PROTECTED_TO_REAL)) {
   4.296  				retl(regs, prefix);
   4.297 -				return OPC_EMULATED;
   4.298 +				return OPC_INVALID;
   4.299  			}
   4.300  			goto invalid;
   4.301  
   4.302 @@ -1284,7 +1302,7 @@ opcode(struct regs *regs)
   4.303  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   4.304  			    (mode == VM86_PROTECTED_TO_REAL)) {
   4.305  				jmpl(regs, prefix);
   4.306 -				return OPC_EMULATED;
   4.307 +				return OPC_INVALID;
   4.308  			}
   4.309  			goto invalid;
   4.310  
     5.1 --- a/tools/firmware/vmxassist/vm86.h	Sat Apr 01 11:08:50 2006 +0100
     5.2 +++ b/tools/firmware/vmxassist/vm86.h	Sat Apr 01 14:59:12 2006 +0100
     5.3 @@ -58,7 +58,6 @@ extern struct vmx_assist_context oldctx;
     5.4  extern struct vmx_assist_context newctx;
     5.5  
     5.6  extern void emulate(struct regs *);
     5.7 -extern void interrupt(struct regs *, int);
     5.8  extern void dump_regs(struct regs *);
     5.9  extern void trace(struct regs *, int, char *, ...);
    5.10