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  
   3.205 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.206 +	regs->cs = cs;
   3.207 +	regs->eip = eip;
   3.208  
   3.209 -                regs->cs = cs;
   3.210 -                regs->eip = eip;
   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 +	addr = operand(prefix, regs, modrm);
   3.234 +
   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 -	if (mode == VM86_REAL_TO_PROTECTED) { /* jump to protected mode */
   3.240 -		eip = (prefix & DATA32) ? read32(addr) : read16(addr);
   3.241 -		addr += (prefix & DATA32) ? 4 : 2;
   3.242 -		cs = read16(addr);
   3.243 +	TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.244  
   3.245 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.246 +	regs->cs = cs;
   3.247 +	regs->eip = eip;
   3.248  
   3.249 -                regs->cs = cs;
   3.250 -                regs->eip = eip;
   3.251 +	if (mode == VM86_REAL_TO_PROTECTED)		/* jump to protected mode */
   3.252  		set_mode(regs, VM86_PROTECTED);
   3.253 -	} else if (mode == VM86_PROTECTED_TO_REAL) { /* jump to real mode */
   3.254 -		eip = (prefix & DATA32) ? read32(addr) : read16(addr);
   3.255 -		addr += (prefix & DATA32) ? 4 : 2;
   3.256 -		cs = read16(addr);
   3.257 -
   3.258 -		TRACE((regs, (regs->eip - n) + 1, "jmpl 0x%x:0x%x", cs, eip));
   3.259 -
   3.260 -                regs->cs = cs;
   3.261 -                regs->eip = eip;
   3.262 +	else if (mode == VM86_PROTECTED_TO_REAL)/* jump to real mode */
   3.263  		set_mode(regs, VM86_REAL);
   3.264 -	} else
   3.265 +	else
   3.266  		panic("jmpl");
   3.267  }
   3.268  
   3.269 @@ -1151,15 +1129,14 @@ retl(struct regs *regs, int prefix)
   3.270  
   3.271  	TRACE((regs, 1, "retl (to 0x%x:0x%x)", cs, eip));
   3.272  
   3.273 -	if (mode == VM86_REAL_TO_PROTECTED) { /* jump to protected mode */
   3.274 -                regs->cs = cs;
   3.275 -                regs->eip = eip;
   3.276 +	regs->cs = cs;
   3.277 +	regs->eip = eip;
   3.278 +
   3.279 +	if (mode == VM86_REAL_TO_PROTECTED)		/* jump to protected mode */
   3.280  		set_mode(regs, VM86_PROTECTED);
   3.281 -	} else if (mode == VM86_PROTECTED_TO_REAL) { /* jump to real mode */
   3.282 -                regs->cs = cs;
   3.283 -                regs->eip = eip;
   3.284 +	else if (mode == VM86_PROTECTED_TO_REAL)/* jump to real mode */
   3.285  		set_mode(regs, VM86_REAL);
   3.286 -	} else
   3.287 +	else
   3.288  		panic("retl");
   3.289  }
   3.290  
   3.291 @@ -1259,8 +1236,8 @@ pushrm(struct regs *regs, int prefix, un
   3.292  	unsigned addr;
   3.293  	unsigned data;
   3.294  
   3.295 -	addr  = operand(prefix, regs, modrm);
   3.296 -	
   3.297 +	addr = operand(prefix, regs, modrm);
   3.298 +
   3.299  	if (prefix & DATA32) {
   3.300  		data = read32(addr);
   3.301  		push32(regs, data);
   3.302 @@ -1386,11 +1363,11 @@ opcode(struct regs *regs)
   3.303  		case 0x3B: /* addr32 cmp r/m16, r16 */
   3.304  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
   3.305  				goto invalid;
   3.306 -                        if ((prefix & ADDR32) == 0)
   3.307 -                                goto invalid;
   3.308 -                        if (!cmp(regs, prefix, opc))
   3.309 -                                goto invalid;
   3.310 -                        return OPC_EMULATED;
   3.311 +			if ((prefix & ADDR32) == 0)
   3.312 +				goto invalid;
   3.313 +			if (!cmp(regs, prefix, opc))
   3.314 +				goto invalid;
   3.315 +			return OPC_EMULATED;
   3.316  
   3.317  		case 0x3E:
   3.318  			TRACE((regs, regs->eip - eip, "%%ds:"));
   3.319 @@ -1412,7 +1389,7 @@ opcode(struct regs *regs)
   3.320  			prefix |= DATA32;
   3.321  			continue;
   3.322  
   3.323 -		case 0x67: 
   3.324 +		case 0x67:
   3.325  			TRACE((regs, regs->eip - eip, "addr32"));
   3.326  			prefix |= ADDR32;
   3.327  			continue;
   3.328 @@ -1421,18 +1398,18 @@ opcode(struct regs *regs)
   3.329  		case 0x8A: /* addr32 mov r/m8, r8 */
   3.330  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
   3.331  				goto invalid;
   3.332 -                        if ((prefix & ADDR32) == 0)
   3.333 -                                goto invalid;
   3.334 -                        if (!movr(regs, prefix, opc))
   3.335 -                                goto invalid;
   3.336 -                        return OPC_EMULATED;
   3.337 +			if ((prefix & ADDR32) == 0)
   3.338 +				goto invalid;
   3.339 +			if (!movr(regs, prefix, opc))
   3.340 +				goto invalid;
   3.341 +			return OPC_EMULATED;
   3.342  
   3.343  		case 0x89: /* addr32 mov r16, r/m16 */
   3.344  			if (mode == VM86_PROTECTED_TO_REAL) {
   3.345  				unsigned modrm = fetch8(regs);
   3.346  				unsigned addr = operand(prefix, regs, modrm);
   3.347  				unsigned val, r = (modrm >> 3) & 7;
   3.348 -				
   3.349 +
   3.350  				if (prefix & DATA32) {
   3.351  					val = getreg16(regs, r);
   3.352  					write32(addr, val);
   3.353 @@ -1447,11 +1424,11 @@ opcode(struct regs *regs)
   3.354  		case 0x8B: /* addr32 mov r/m16, r16 */
   3.355  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
   3.356  				goto invalid;
   3.357 -                        if ((prefix & ADDR32) == 0)
   3.358 -                                goto invalid;
   3.359 -                        if (!movr(regs, prefix, opc))
   3.360 -                                goto invalid;
   3.361 -                        return OPC_EMULATED;
   3.362 +			if ((prefix & ADDR32) == 0)
   3.363 +				goto invalid;
   3.364 +			if (!movr(regs, prefix, opc))
   3.365 +				goto invalid;
   3.366 +			return OPC_EMULATED;
   3.367  
   3.368  		case 0x8E: /* mov r16, sreg */
   3.369  			if (!mov_to_seg(regs, prefix, opc))
   3.370 @@ -1459,11 +1436,11 @@ opcode(struct regs *regs)
   3.371  			return OPC_EMULATED;
   3.372  
   3.373  		case 0x8F: /* addr32 pop r/m16 */
   3.374 -                        if ((prefix & ADDR32) == 0)
   3.375 -                                goto invalid;
   3.376 -                        if (!pop(regs, prefix, opc))
   3.377 -                                goto invalid;
   3.378 -                        return OPC_EMULATED;
   3.379 +			if ((prefix & ADDR32) == 0)
   3.380 +				goto invalid;
   3.381 +			if (!pop(regs, prefix, opc))
   3.382 +				goto invalid;
   3.383 +			return OPC_EMULATED;
   3.384  
   3.385  		case 0x90: /* nop */
   3.386  			TRACE((regs, regs->eip - eip, "nop"));
   3.387 @@ -1487,7 +1464,7 @@ opcode(struct regs *regs)
   3.388  			regs->eflags |= EFLAGS_VM;
   3.389  			return OPC_EMULATED;
   3.390  
   3.391 -		case 0xA1: /* mov ax, r/m16 */ 
   3.392 +		case 0xA1: /* mov ax, r/m16 */
   3.393  			{
   3.394  				int addr, data;
   3.395  				int seg = segment(prefix, regs, regs->vds);
   3.396 @@ -1521,15 +1498,15 @@ opcode(struct regs *regs)
   3.397  			return OPC_EMULATED;
   3.398  
   3.399  		case 0xC6: /* addr32 movb $imm, r/m8 */
   3.400 -                        if ((prefix & ADDR32) == 0)
   3.401 -                                goto invalid;
   3.402 -                        if (!movr(regs, prefix, opc))
   3.403 -                                goto invalid;
   3.404 +			if ((prefix & ADDR32) == 0)
   3.405 +				goto invalid;
   3.406 +			if (!movr(regs, prefix, opc))
   3.407 +				goto invalid;
   3.408  			return OPC_EMULATED;
   3.409  
   3.410  		case 0xCB: /* retl */
   3.411  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.412 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.413 +				(mode == VM86_PROTECTED_TO_REAL)) {
   3.414  				retl(regs, prefix);
   3.415  				return OPC_INVALID;
   3.416  			}
   3.417 @@ -1567,7 +1544,7 @@ opcode(struct regs *regs)
   3.418  
   3.419  		case 0xEA: /* jmpl */
   3.420  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.421 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.422 +				(mode == VM86_PROTECTED_TO_REAL)) {
   3.423  				jmpl(regs, prefix);
   3.424  				return OPC_INVALID;
   3.425  			}
   3.426 @@ -1579,7 +1556,7 @@ opcode(struct regs *regs)
   3.427  				switch((modrm >> 3) & 7) {
   3.428  				case 5: /* jmpl (indirect) */
   3.429  					if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.430 -					    (mode == VM86_PROTECTED_TO_REAL)) {
   3.431 +						(mode == VM86_PROTECTED_TO_REAL)) {
   3.432  						jmpl_indirect(regs, prefix, modrm);
   3.433  						return OPC_INVALID;
   3.434  					}
   3.435 @@ -1596,7 +1573,7 @@ opcode(struct regs *regs)
   3.436  
   3.437  		case 0xEB: /* short jump */
   3.438  			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.439 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.440 +				(mode == VM86_PROTECTED_TO_REAL)) {
   3.441  				disp = (char) fetch8(regs);
   3.442  				TRACE((regs, 2, "jmp 0x%x", regs->eip + disp));
   3.443  				regs->eip += disp;
   3.444 @@ -1619,10 +1596,10 @@ opcode(struct regs *regs)
   3.445  			continue;
   3.446  
   3.447  		case 0xF6: /* addr32 testb $imm, r/m8 */
   3.448 -                        if ((prefix & ADDR32) == 0)
   3.449 -                                goto invalid;
   3.450 -                        if (!test(regs, prefix, opc))
   3.451 -                                goto invalid;
   3.452 +			if ((prefix & ADDR32) == 0)
   3.453 +				goto invalid;
   3.454 +			if (!test(regs, prefix, opc))
   3.455 +				goto invalid;
   3.456  			return OPC_EMULATED;
   3.457  
   3.458  		case 0xFA: /* cli */
   3.459 @@ -1682,6 +1659,8 @@ trap(int trapno, int errno, struct regs 
   3.460  	case 1: /* Debug */
   3.461  		if (regs->eflags & EFLAGS_VM) {
   3.462  			/* emulate any 8086 instructions  */
   3.463 +			if (mode == VM86_REAL)
   3.464 +				return;
   3.465  			if (mode != VM86_REAL_TO_PROTECTED)
   3.466  				panic("not in real-to-protected mode");
   3.467  			emulate(regs);
   3.468 @@ -1702,7 +1681,7 @@ trap(int trapno, int errno, struct regs 
   3.469  	default:
   3.470  	invalid:
   3.471  		printf("Trap (0x%x) while in %s mode\n",
   3.472 -		    trapno, regs->eflags & EFLAGS_VM ? "real" : "protected");
   3.473 +			trapno, regs->eflags & EFLAGS_VM ? "real" : "protected");
   3.474  		if (trapno == 14)
   3.475  			printf("Page fault address 0x%x\n", get_cr2());
   3.476  		dump_regs(regs);