ia64/xen-unstable

changeset 12832:44319e9dc0c5

VMXAssist cleanups

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kfraser@localhost.localdomain
date Thu Dec 07 11:18:38 2006 +0000 (2006-12-07)
parents 49bb6b82654a
children 1c15f97a220d
files tools/firmware/vmxassist/head.S tools/firmware/vmxassist/setup.c tools/firmware/vmxassist/vm86.c
line diff
     1.1 --- a/tools/firmware/vmxassist/head.S	Thu Dec 07 11:17:28 2006 +0000
     1.2 +++ b/tools/firmware/vmxassist/head.S	Thu Dec 07 11:18:38 2006 +0000
     1.3 @@ -130,7 +130,7 @@ 1:
     1.4  	clts
     1.5  
     1.6  	/* setup my own stack */
     1.7 -	movl	$stack_top - 4*4, %esp
     1.8 +	movl	$stack_top, %esp
     1.9  	movl	%esp, %ebp
    1.10  
    1.11  	/* go ... */
     2.1 --- a/tools/firmware/vmxassist/setup.c	Thu Dec 07 11:17:28 2006 +0000
     2.2 +++ b/tools/firmware/vmxassist/setup.c	Thu Dec 07 11:18:38 2006 +0000
     2.3 @@ -125,7 +125,7 @@ setup_gdt(void)
     2.4  	/* setup task state segment */
     2.5  	memset(&tss, 0, sizeof(tss));
     2.6  	tss.ss0 = DATA_SELECTOR;
     2.7 -	tss.esp0 = (unsigned) stack_top - 4*4;
     2.8 +	tss.esp0 = (unsigned) stack_top;
     2.9  	tss.iomap_base = offsetof(struct tss, iomap);
    2.10  
    2.11  	/* initialize gdt's tss selector */
    2.12 @@ -258,7 +258,7 @@ setup_ctx(void)
    2.13  
    2.14  	memset(c, 0, sizeof(*c));
    2.15  	c->eip = (unsigned long) switch_to_real_mode;
    2.16 -	c->esp = (unsigned) stack_top - 4*4;
    2.17 +	c->esp = (unsigned) stack_top;
    2.18  	c->eflags = 0x2; /* no interrupts, please */
    2.19  
    2.20  	/*
     3.1 --- a/tools/firmware/vmxassist/vm86.c	Thu Dec 07 11:17:28 2006 +0000
     3.2 +++ b/tools/firmware/vmxassist/vm86.c	Thu Dec 07 11:18:38 2006 +0000
     3.3 @@ -1,6 +1,6 @@
     3.4  /*
     3.5   * vm86.c: A vm86 emulator. The main purpose of this emulator is to do as
     3.6 - * little work as possible. 
     3.7 + * little work as possible.
     3.8   *
     3.9   * Leendert van Doorn, leendert@watson.ibm.com
    3.10   * Copyright (c) 2005-2006, International Business Machines Corporation.
    3.11 @@ -52,8 +52,8 @@ char *states[] = {
    3.12  static char *rnames[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
    3.13  #endif /* DEBUG */
    3.14  
    3.15 -#define PDE_PS           (1 << 7)
    3.16 -#define PT_ENTRY_PRESENT 0x1
    3.17 +#define PDE_PS				(1 << 7)
    3.18 +#define PT_ENTRY_PRESENT	0x1
    3.19  
    3.20  /* We only support access to <=4G physical memory due to 1:1 mapping */
    3.21  static uint64_t
    3.22 @@ -136,7 +136,7 @@ address(struct regs *regs, unsigned seg,
    3.23  	}
    3.24  
    3.25  	if (mode == VM86_REAL || seg > oldctx.gdtr_limit ||
    3.26 -	    (mode == VM86_REAL_TO_PROTECTED && regs->cs == seg))
    3.27 +		(mode == VM86_REAL_TO_PROTECTED && regs->cs == seg))
    3.28  		return ((seg & 0xFFFF) << 4) + off;
    3.29  
    3.30  	gdt_phys_base = guest_linear_to_phys(oldctx.gdtr_base);
    3.31 @@ -153,13 +153,13 @@ address(struct regs *regs, unsigned seg,
    3.32  	seg_limit = (entry_high & 0xF0000) | (entry_low & 0xFFFF);
    3.33  
    3.34  	if (entry_high & 0x8000 &&
    3.35 -	    ((entry_high & 0x800000 && off >> 12 <= seg_limit) ||
    3.36 -	    (!(entry_high & 0x800000) && off <= seg_limit)))
    3.37 +		((entry_high & 0x800000 && off >> 12 <= seg_limit) ||
    3.38 +		(!(entry_high & 0x800000) && off <= seg_limit)))
    3.39  		return seg_base + off;
    3.40  
    3.41  	panic("should never reach here in function address():\n\t"
    3.42 -	      "entry=0x%08x%08x, mode=%d, seg=0x%08x, offset=0x%08x\n",
    3.43 -	      entry_high, entry_low, mode, seg, off);
    3.44 +		  "entry=0x%08x%08x, mode=%d, seg=0x%08x, offset=0x%08x\n",
    3.45 +		  entry_high, entry_low, mode, seg, off);
    3.46  
    3.47  	return 0;
    3.48  }
    3.49 @@ -172,7 +172,7 @@ trace(struct regs *regs, int adjust, cha
    3.50  	va_list ap;
    3.51  
    3.52  	if ((traceset & (1 << mode)) &&
    3.53 -	   (mode == VM86_REAL_TO_PROTECTED || mode == VM86_REAL)) {
    3.54 +		(mode == VM86_REAL_TO_PROTECTED || mode == VM86_REAL)) {
    3.55  		/* 16-bit, seg:off addressing */
    3.56  		unsigned addr = address(regs, regs->cs, off);
    3.57  		printf("0x%08x: 0x%x:0x%04x ", addr, regs->cs, off);
    3.58 @@ -183,7 +183,7 @@ trace(struct regs *regs, int adjust, cha
    3.59  		printf("\n");
    3.60  	}
    3.61  	if ((traceset & (1 << mode)) &&
    3.62 -	   (mode == VM86_PROTECTED_TO_REAL || mode == VM86_PROTECTED)) {
    3.63 +		(mode == VM86_PROTECTED_TO_REAL || mode == VM86_PROTECTED)) {
    3.64  		/* 16-bit, gdt addressing */
    3.65  		unsigned addr = address(regs, regs->cs, off);
    3.66  		printf("0x%08x: 0x%x:0x%08x ", addr, regs->cs, off);
    3.67 @@ -430,7 +430,7 @@ operand(unsigned prefix, struct regs *re
    3.68  			case 2: return address(regs, seg, regs->edx);
    3.69  			case 3: return address(regs, seg, regs->ebx);
    3.70  			case 4: return address(regs, seg,
    3.71 -					       sib(regs, mod, fetch8(regs)));
    3.72 +						   sib(regs, mod, fetch8(regs)));
    3.73  			case 5: return address(regs, seg, fetch32(regs));
    3.74  			case 6: return address(regs, seg, regs->esi);
    3.75  			case 7: return address(regs, seg, regs->edi);
    3.76 @@ -450,7 +450,7 @@ operand(unsigned prefix, struct regs *re
    3.77  			case 2: return address(regs, seg, regs->edx + disp);
    3.78  			case 3: return address(regs, seg, regs->ebx + disp);
    3.79  			case 4: return address(regs, seg,
    3.80 -					       sib(regs, mod, fetch8(regs)));
    3.81 +						   sib(regs, mod, fetch8(regs)));
    3.82  			case 5: return address(regs, seg, regs->ebp + disp);
    3.83  			case 6: return address(regs, seg, regs->esi + disp);
    3.84  			case 7: return address(regs, seg, regs->edi + disp);
    3.85 @@ -507,7 +507,7 @@ operand(unsigned prefix, struct regs *re
    3.86  		}
    3.87  	}
    3.88  
    3.89 -	return 0; 
    3.90 +	return 0;
    3.91  }
    3.92  
    3.93  /*
    3.94 @@ -859,7 +859,7 @@ mov_to_seg(struct regs *regs, unsigned p
    3.95  
    3.96   fail:
    3.97  	printf("%s:%d: missed opcode %02x %02x\n",
    3.98 -	       __FUNCTION__, __LINE__, opc, modrm);
    3.99 +		   __FUNCTION__, __LINE__, opc, modrm);
   3.100  	return 0;
   3.101  }
   3.102  
   3.103 @@ -896,11 +896,11 @@ load_seg(unsigned long sel, uint32_t *ba
   3.104  		  ((entry >> (32-16)) & 0x00FF0000) |
   3.105  		  ((entry >> (   16)) & 0x0000FFFF));
   3.106  	*limit = (((entry >> (48-16)) & 0x000F0000) |
   3.107 -		  ((entry           ) & 0x0000FFFF));
   3.108 +		  (entry & 0x0000FFFF));
   3.109  
   3.110  	arbytes->bytes = 0;
   3.111  	arbytes->fields.seg_type = (entry >> (8+32)) & 0xF; /* TYPE */
   3.112 -	arbytes->fields.s =  (entry >> (12+32)) & 0x1; /* S */
   3.113 +	arbytes->fields.s = (entry >> (12+32)) & 0x1; /* S */
   3.114  	if (arbytes->fields.s)
   3.115  		arbytes->fields.seg_type |= 1; /* accessed */
   3.116  	arbytes->fields.dpl = (entry >> (13+32)) & 0x3; /* DPL */
   3.117 @@ -924,7 +924,7 @@ static void
   3.118  load_or_clear_seg(unsigned long sel, uint32_t *base, uint32_t *limit, union vmcs_arbytes *arbytes)
   3.119  {
   3.120  	if (!load_seg(sel, base, limit, arbytes))
   3.121 -		load_seg(0, base, limit, arbytes);	    
   3.122 +		load_seg(0, base, limit, arbytes);
   3.123  }
   3.124  
   3.125  
   3.126 @@ -988,21 +988,21 @@ real_mode(struct regs *regs)
   3.127  			panic("%%ss 0x%lx higher than 1MB", regs->uss);
   3.128  		regs->uss = address(regs, regs->uss, 0) >> 4;
   3.129  	} else {
   3.130 -	  regs->uss = saved_rm_regs.uss;
   3.131 +		regs->uss = saved_rm_regs.uss;
   3.132  	}
   3.133  	if (regs->vds != 0) {
   3.134  		if (regs->vds >= HIGHMEM)
   3.135  			panic("%%ds 0x%lx higher than 1MB", regs->vds);
   3.136  		regs->vds = address(regs, regs->vds, 0) >> 4;
   3.137  	} else {
   3.138 -	  regs->vds = saved_rm_regs.vds;
   3.139 +		regs->vds = saved_rm_regs.vds;
   3.140  	}
   3.141  	if (regs->ves != 0) {
   3.142  		if (regs->ves >= HIGHMEM)
   3.143  			panic("%%es 0x%lx higher than 1MB", regs->ves);
   3.144  		regs->ves = address(regs, regs->ves, 0) >> 4;
   3.145  	} else {
   3.146 -	  regs->ves = saved_rm_regs.ves;
   3.147 +		regs->ves = saved_rm_regs.ves;
   3.148  	}
   3.149  
   3.150  	/* this should get us into 16-bit mode */
   3.151 @@ -1029,10 +1029,7 @@ set_mode(struct regs *regs, enum vm86_mo
   3.152  		    (mode == VM86_REAL_TO_PROTECTED)) {
   3.153  			regs->eflags &= ~EFLAGS_TF;
   3.154  			real_mode(regs);
   3.155 -			break;
   3.156 -		} else if (mode == VM86_REAL) {
   3.157 -			break;
   3.158 -		} else
   3.159 +		} else if (mode != VM86_REAL)
   3.160  			panic("unexpected real mode transition");
   3.161  		break;
   3.162  
   3.163 @@ -1049,25 +1046,19 @@ set_mode(struct regs *regs, enum vm86_mo
   3.164  			oldctx.fs_sel = 0;
   3.165  			oldctx.gs_sel = 0;
   3.166  			oldctx.ss_sel = 0;
   3.167 -			break;
   3.168 -		} else if (mode == VM86_REAL_TO_PROTECTED) {
   3.169 -			break;
   3.170 -		} else
   3.171 +		} else if (mode != VM86_REAL_TO_PROTECTED)
   3.172  			panic("unexpected real-to-protected mode transition");
   3.173  		break;
   3.174  
   3.175  	case VM86_PROTECTED_TO_REAL:
   3.176 -		if (mode == VM86_PROTECTED) {
   3.177 -			break;
   3.178 -		} else
   3.179 +		if (mode != VM86_PROTECTED)
   3.180  			panic("unexpected protected-to-real mode transition");
   3.181  		break;
   3.182  
   3.183  	case VM86_PROTECTED:
   3.184 -		if (mode == VM86_REAL_TO_PROTECTED) {
   3.185 -			protected_mode(regs);
   3.186 -		} else
   3.187 +		if (mode != VM86_REAL_TO_PROTECTED)
   3.188  			panic("unexpected protected mode transition");
   3.189 +		protected_mode(regs);
   3.190  		break;
   3.191  	}
   3.192  
   3.193 @@ -1081,25 +1072,19 @@ jmpl(struct regs *regs, int prefix)
   3.194  	unsigned n = regs->eip;
   3.195  	unsigned cs, eip;
   3.196  
   3.197 -	if (mode == VM86_REAL_TO_PROTECTED) { /* jump to protected mode */
   3.198 -		eip = (prefix & DATA32) ? fetch32(regs) : fetch16(regs);
   3.199 -		cs = fetch16(regs);
   3.200 +	eip = (prefix & DATA32) ? fetch32(regs) : fetch16(regs);
   3.201 +	cs = fetch16(regs);
   3.202  
   3.203 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.204 +	TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.205  
   3.206 -                regs->cs = cs;
   3.207 -                regs->eip = eip;
   3.208 +	regs->cs = cs;
   3.209 +	regs->eip = eip;
   3.210 +
   3.211 +	if (mode == VM86_REAL_TO_PROTECTED)		/* jump to protected mode */
   3.212  		set_mode(regs, VM86_PROTECTED);
   3.213 -	} else if (mode == VM86_PROTECTED_TO_REAL) { /* jump to real mode */
   3.214 -		eip = (prefix & DATA32) ? fetch32(regs) : fetch16(regs);
   3.215 -		cs = fetch16(regs);
   3.216 -
   3.217 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.218 -
   3.219 -                regs->cs = cs;
   3.220 -                regs->eip = eip;
   3.221 +	else if (mode == VM86_PROTECTED_TO_REAL)/* jump to real mode */
   3.222  		set_mode(regs, VM86_REAL);
   3.223 -	} else
   3.224 +	else
   3.225  		panic("jmpl");
   3.226  }
   3.227  
   3.228 @@ -1110,29 +1095,22 @@ jmpl_indirect(struct regs *regs, int pre
   3.229  	unsigned cs, eip;
   3.230  	unsigned addr;
   3.231  
   3.232 -	addr  = operand(prefix, regs, modrm);
   3.233 -
   3.234 -	if (mode == VM86_REAL_TO_PROTECTED) { /* jump to protected mode */
   3.235 -		eip = (prefix & DATA32) ? read32(addr) : read16(addr);
   3.236 -		addr += (prefix & DATA32) ? 4 : 2;
   3.237 -		cs = read16(addr);
   3.238 -
   3.239 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.240 +	addr = operand(prefix, regs, modrm);
   3.241  
   3.242 -                regs->cs = cs;
   3.243 -                regs->eip = eip;
   3.244 +	eip = (prefix & DATA32) ? read32(addr) : read16(addr);
   3.245 +	addr += (prefix & DATA32) ? 4 : 2;
   3.246 +	cs = read16(addr);
   3.247 +
   3.248 +	TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.249 +
   3.250 +	regs->cs = cs;
   3.251 +	regs->eip = eip;
   3.252 +
   3.253 +	if (mode == VM86_REAL_TO_PROTECTED)		/* jump to protected mode */
   3.254  		set_mode(regs, VM86_PROTECTED);
   3.255 -	} else if (mode == VM86_PROTECTED_TO_REAL) { /* jump to real mode */
   3.256 -		eip = (prefix & DATA32) ? read32(addr) : read16(addr);
   3.257 -		addr += (prefix & DATA32) ? 4 : 2;
   3.258 -		cs = read16(addr);
   3.259 -
   3.260 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.261 -
   3.262 -                regs->cs = cs;
   3.263 -                regs->eip = eip;
   3.264 +	else if (mode == VM86_PROTECTED_TO_REAL)/* jump to real mode */
   3.265  		set_mode(regs, VM86_REAL);
   3.266 -	} else
   3.267 +	else
   3.268  		panic("jmpl");
   3.269  }
   3.270  
   3.271 @@ -1151,15 +1129,14 @@ retl(struct regs *regs, int prefix)
   3.272  
   3.273  	TRACE((regs, 1, "retl (to 0x%x:0x%x)", cs, eip));
   3.274  
   3.275 -	if (mode == VM86_REAL_TO_PROTECTED) { /* jump to protected mode */
   3.276 -                regs->cs = cs;
   3.277 -                regs->eip = eip;
   3.278 +	regs->cs = cs;
   3.279 +	regs->eip = eip;
   3.280 +
   3.281 +	if (mode == VM86_REAL_TO_PROTECTED)		/* jump to protected mode */
   3.282  		set_mode(regs, VM86_PROTECTED);
   3.283 -	} else if (mode == VM86_PROTECTED_TO_REAL) { /* jump to real mode */
   3.284 -                regs->cs = cs;
   3.285 -                regs->eip = eip;
   3.286 +	else if (mode == VM86_PROTECTED_TO_REAL)/* jump to real mode */
   3.287  		set_mode(regs, VM86_REAL);
   3.288 -	} else
   3.289 +	else
   3.290  		panic("retl");
   3.291  }
   3.292  
   3.293 @@ -1259,8 +1236,8 @@ pushrm(struct regs *regs, int prefix, un
   3.294  	unsigned addr;
   3.295  	unsigned data;
   3.296  
   3.297 -	addr  = operand(prefix, regs, modrm);
   3.298 -	
   3.299 +	addr = operand(prefix, regs, modrm);
   3.300 +
   3.301  	if (prefix & DATA32) {
   3.302  		data = read32(addr);
   3.303  		push32(regs, data);
   3.304 @@ -1386,11 +1363,11 @@ opcode(struct regs *regs)
   3.305  		case 0x3B: /* addr32 cmp r/m16, r16 */
   3.306  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
   3.307  				goto invalid;
   3.308 -                        if ((prefix & ADDR32) == 0)
   3.309 -                                goto invalid;
   3.310 -                        if (!cmp(regs, prefix, opc))
   3.311 -                                goto invalid;
   3.312 -                        return OPC_EMULATED;
   3.313 +			if ((prefix & ADDR32) == 0)
   3.314 +				goto invalid;
   3.315 +			if (!cmp(regs, prefix, opc))
   3.316 +				goto invalid;
   3.317 +			return OPC_EMULATED;
   3.318  
   3.319  		case 0x3E:
   3.320  			TRACE((regs, regs->eip - eip, "%%ds:"));
   3.321 @@ -1412,7 +1389,7 @@ opcode(struct regs *regs)
   3.322  			prefix |= DATA32;
   3.323  			continue;
   3.324  
   3.325 -		case 0x67: 
   3.326 +		case 0x67:
   3.327  			TRACE((regs, regs->eip - eip, "addr32"));
   3.328  			prefix |= ADDR32;
   3.329  			continue;
   3.330 @@ -1421,18 +1398,18 @@ opcode(struct regs *regs)
   3.331  		case 0x8A: /* addr32 mov r/m8, r8 */
   3.332  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
   3.333  				goto invalid;
   3.334 -                        if ((prefix & ADDR32) == 0)
   3.335 -                                goto invalid;
   3.336 -                        if (!movr(regs, prefix, opc))
   3.337 -                                goto invalid;
   3.338 -                        return OPC_EMULATED;
   3.339 +			if ((prefix & ADDR32) == 0)
   3.340 +				goto invalid;
   3.341 +			if (!movr(regs, prefix, opc))
   3.342 +				goto invalid;
   3.343 +			return OPC_EMULATED;
   3.344  
   3.345  		case 0x89: /* addr32 mov r16, r/m16 */
   3.346  			if (mode == VM86_PROTECTED_TO_REAL) {
   3.347  				unsigned modrm = fetch8(regs);
   3.348  				unsigned addr = operand(prefix, regs, modrm);
   3.349  				unsigned val, r = (modrm >> 3) & 7;
   3.350 -				
   3.351 +
   3.352  				if (prefix & DATA32) {
   3.353  					val = getreg16(regs, r);
   3.354  					write32(addr, val);
   3.355 @@ -1447,11 +1424,11 @@ opcode(struct regs *regs)
   3.356  		case 0x8B: /* addr32 mov r/m16, r16 */
   3.357  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
   3.358  				goto invalid;
   3.359 -                        if ((prefix & ADDR32) == 0)
   3.360 -                                goto invalid;
   3.361 -                        if (!movr(regs, prefix, opc))
   3.362 -                                goto invalid;
   3.363 -                        return OPC_EMULATED;
   3.364 +			if ((prefix & ADDR32) == 0)
   3.365 +				goto invalid;
   3.366 +			if (!movr(regs, prefix, opc))
   3.367 +				goto invalid;
   3.368 +			return OPC_EMULATED;
   3.369  
   3.370  		case 0x8E: /* mov r16, sreg */
   3.371  			if (!mov_to_seg(regs, prefix, opc))
   3.372 @@ -1459,11 +1436,11 @@ opcode(struct regs *regs)
   3.373  			return OPC_EMULATED;
   3.374  
   3.375  		case 0x8F: /* addr32 pop r/m16 */
   3.376 -                        if ((prefix & ADDR32) == 0)
   3.377 -                                goto invalid;
   3.378 -                        if (!pop(regs, prefix, opc))
   3.379 -                                goto invalid;
   3.380 -                        return OPC_EMULATED;
   3.381 +			if ((prefix & ADDR32) == 0)
   3.382 +				goto invalid;
   3.383 +			if (!pop(regs, prefix, opc))
   3.384 +				goto invalid;
   3.385 +			return OPC_EMULATED;
   3.386  
   3.387  		case 0x90: /* nop */
   3.388  			TRACE((regs, regs->eip - eip, "nop"));
   3.389 @@ -1487,7 +1464,7 @@ opcode(struct regs *regs)
   3.390  			regs->eflags |= EFLAGS_VM;
   3.391  			return OPC_EMULATED;
   3.392  
   3.393 -		case 0xA1: /* mov ax, r/m16 */ 
   3.394 +		case 0xA1: /* mov ax, r/m16 */
   3.395  			{
   3.396  				int addr, data;
   3.397  				int seg = segment(prefix, regs, regs->vds);
   3.398 @@ -1521,15 +1498,15 @@ opcode(struct regs *regs)
   3.399  			return OPC_EMULATED;
   3.400  
   3.401  		case 0xC6: /* addr32 movb $imm, r/m8 */
   3.402 -                        if ((prefix & ADDR32) == 0)
   3.403 -                                goto invalid;
   3.404 -                        if (!movr(regs, prefix, opc))
   3.405 -                                goto invalid;
   3.406 +			if ((prefix & ADDR32) == 0)
   3.407 +				goto invalid;
   3.408 +			if (!movr(regs, prefix, opc))
   3.409 +				goto invalid;
   3.410  			return OPC_EMULATED;
   3.411  
   3.412  		case 0xCB: /* retl */
   3.413  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.414 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.415 +				(mode == VM86_PROTECTED_TO_REAL)) {
   3.416  				retl(regs, prefix);
   3.417  				return OPC_INVALID;
   3.418  			}
   3.419 @@ -1567,7 +1544,7 @@ opcode(struct regs *regs)
   3.420  
   3.421  		case 0xEA: /* jmpl */
   3.422  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.423 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.424 +				(mode == VM86_PROTECTED_TO_REAL)) {
   3.425  				jmpl(regs, prefix);
   3.426  				return OPC_INVALID;
   3.427  			}
   3.428 @@ -1579,7 +1556,7 @@ opcode(struct regs *regs)
   3.429  				switch((modrm >> 3) & 7) {
   3.430  				case 5: /* jmpl (indirect) */
   3.431  					if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.432 -					    (mode == VM86_PROTECTED_TO_REAL)) {
   3.433 +						(mode == VM86_PROTECTED_TO_REAL)) {
   3.434  						jmpl_indirect(regs, prefix, modrm);
   3.435  						return OPC_INVALID;
   3.436  					}
   3.437 @@ -1596,7 +1573,7 @@ opcode(struct regs *regs)
   3.438  
   3.439  		case 0xEB: /* short jump */
   3.440  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.441 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.442 +				(mode == VM86_PROTECTED_TO_REAL)) {
   3.443  				disp = (char) fetch8(regs);
   3.444  				TRACE((regs, 2, "jmp 0x%x", regs->eip + disp));
   3.445  				regs->eip += disp;
   3.446 @@ -1619,10 +1596,10 @@ opcode(struct regs *regs)
   3.447  			continue;
   3.448  
   3.449  		case 0xF6: /* addr32 testb $imm, r/m8 */
   3.450 -                        if ((prefix & ADDR32) == 0)
   3.451 -                                goto invalid;
   3.452 -                        if (!test(regs, prefix, opc))
   3.453 -                                goto invalid;
   3.454 +			if ((prefix & ADDR32) == 0)
   3.455 +				goto invalid;
   3.456 +			if (!test(regs, prefix, opc))
   3.457 +				goto invalid;
   3.458  			return OPC_EMULATED;
   3.459  
   3.460  		case 0xFA: /* cli */
   3.461 @@ -1682,6 +1659,8 @@ trap(int trapno, int errno, struct regs 
   3.462  	case 1: /* Debug */
   3.463  		if (regs->eflags & EFLAGS_VM) {
   3.464  			/* emulate any 8086 instructions  */
   3.465 +			if (mode == VM86_REAL)
   3.466 +				return;
   3.467  			if (mode != VM86_REAL_TO_PROTECTED)
   3.468  				panic("not in real-to-protected mode");
   3.469  			emulate(regs);
   3.470 @@ -1702,7 +1681,7 @@ trap(int trapno, int errno, struct regs 
   3.471  	default:
   3.472  	invalid:
   3.473  		printf("Trap (0x%x) while in %s mode\n",
   3.474 -		    trapno, regs->eflags & EFLAGS_VM ? "real" : "protected");
   3.475 +			trapno, regs->eflags & EFLAGS_VM ? "real" : "protected");
   3.476  		if (trapno == 14)
   3.477  			printf("Page fault address 0x%x\n", get_cr2());
   3.478  		dump_regs(regs);