Commit c05bab779e16f39b78e133797937114512f3c132

Authored by bellard
1 parent a52c757c

force IOPL=3


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@257 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 22 additions and 20 deletions
linux-user/vm86.c
@@ -73,17 +73,17 @@ void save_v86_state(CPUX86State *env) @@ -73,17 +73,17 @@ void save_v86_state(CPUX86State *env)
73 ts->target_v86->regs.ebp = tswap32(env->regs[R_EBP]); 73 ts->target_v86->regs.ebp = tswap32(env->regs[R_EBP]);
74 ts->target_v86->regs.esp = tswap32(env->regs[R_ESP]); 74 ts->target_v86->regs.esp = tswap32(env->regs[R_ESP]);
75 ts->target_v86->regs.eip = tswap32(env->eip); 75 ts->target_v86->regs.eip = tswap32(env->eip);
76 - ts->target_v86->regs.cs = tswap16(env->segs[R_CS]);  
77 - ts->target_v86->regs.ss = tswap16(env->segs[R_SS]);  
78 - ts->target_v86->regs.ds = tswap16(env->segs[R_DS]);  
79 - ts->target_v86->regs.es = tswap16(env->segs[R_ES]);  
80 - ts->target_v86->regs.fs = tswap16(env->segs[R_FS]);  
81 - ts->target_v86->regs.gs = tswap16(env->segs[R_GS]); 76 + ts->target_v86->regs.cs = tswap16(env->segs[R_CS].selector);
  77 + ts->target_v86->regs.ss = tswap16(env->segs[R_SS].selector);
  78 + ts->target_v86->regs.ds = tswap16(env->segs[R_DS].selector);
  79 + ts->target_v86->regs.es = tswap16(env->segs[R_ES].selector);
  80 + ts->target_v86->regs.fs = tswap16(env->segs[R_FS].selector);
  81 + ts->target_v86->regs.gs = tswap16(env->segs[R_GS].selector);
82 set_flags(env->eflags, ts->v86flags, VIF_MASK | ts->v86mask); 82 set_flags(env->eflags, ts->v86flags, VIF_MASK | ts->v86mask);
83 ts->target_v86->regs.eflags = tswap32(env->eflags); 83 ts->target_v86->regs.eflags = tswap32(env->eflags);
84 #ifdef DEBUG_VM86 84 #ifdef DEBUG_VM86
85 fprintf(logfile, "save_v86_state: eflags=%08x cs:ip=%04x:%04x\n", 85 fprintf(logfile, "save_v86_state: eflags=%08x cs:ip=%04x:%04x\n",
86 - env->eflags, env->segs[R_CS], env->eip); 86 + env->eflags, env->segs[R_CS].selector, env->eip);
87 #endif 87 #endif
88 88
89 /* restore 32 bit registers */ 89 /* restore 32 bit registers */
@@ -180,6 +180,7 @@ static inline unsigned int get_vflags(CPUX86State *env) @@ -180,6 +180,7 @@ static inline unsigned int get_vflags(CPUX86State *env)
180 flags = env->eflags & RETURN_MASK; 180 flags = env->eflags & RETURN_MASK;
181 if (ts->v86flags & VIF_MASK) 181 if (ts->v86flags & VIF_MASK)
182 flags |= IF_MASK; 182 flags |= IF_MASK;
  183 + flags |= IOPL_MASK;
183 return flags | (ts->v86flags & ts->v86mask); 184 return flags | (ts->v86flags & ts->v86mask);
184 } 185 }
185 186
@@ -194,7 +195,7 @@ static void do_int(CPUX86State *env, int intno) @@ -194,7 +195,7 @@ static void do_int(CPUX86State *env, int intno)
194 uint8_t *ssp; 195 uint8_t *ssp;
195 unsigned int sp; 196 unsigned int sp;
196 197
197 - if (env->segs[R_CS] == TARGET_BIOSSEG) 198 + if (env->segs[R_CS].selector == TARGET_BIOSSEG)
198 goto cannot_handle; 199 goto cannot_handle;
199 if (is_revectored(intno, &ts->vm86plus.int_revectored)) 200 if (is_revectored(intno, &ts->vm86plus.int_revectored))
200 goto cannot_handle; 201 goto cannot_handle;
@@ -210,10 +211,10 @@ static void do_int(CPUX86State *env, int intno) @@ -210,10 +211,10 @@ static void do_int(CPUX86State *env, int intno)
210 intno, segoffs >> 16, segoffs & 0xffff); 211 intno, segoffs >> 16, segoffs & 0xffff);
211 #endif 212 #endif
212 /* save old state */ 213 /* save old state */
213 - ssp = (uint8_t *)(env->segs[R_SS] << 4); 214 + ssp = (uint8_t *)(env->segs[R_SS].selector << 4);
214 sp = env->regs[R_ESP] & 0xffff; 215 sp = env->regs[R_ESP] & 0xffff;
215 vm_putw(ssp, sp - 2, get_vflags(env)); 216 vm_putw(ssp, sp - 2, get_vflags(env));
216 - vm_putw(ssp, sp - 4, env->segs[R_CS]); 217 + vm_putw(ssp, sp - 4, env->segs[R_CS].selector);
217 vm_putw(ssp, sp - 6, env->eip); 218 vm_putw(ssp, sp - 6, env->eip);
218 ADD16(env->regs[R_ESP], -6); 219 ADD16(env->regs[R_ESP], -6);
219 /* goto interrupt handler */ 220 /* goto interrupt handler */
@@ -257,16 +258,16 @@ void handle_vm86_fault(CPUX86State *env) @@ -257,16 +258,16 @@ void handle_vm86_fault(CPUX86State *env)
257 unsigned int ip, sp, newflags, newip, newcs, opcode, intno; 258 unsigned int ip, sp, newflags, newip, newcs, opcode, intno;
258 int data32, pref_done; 259 int data32, pref_done;
259 260
260 - csp = (uint8_t *)(env->segs[R_CS] << 4); 261 + csp = (uint8_t *)(env->segs[R_CS].selector << 4);
261 ip = env->eip & 0xffff; 262 ip = env->eip & 0xffff;
262 pc = csp + ip; 263 pc = csp + ip;
263 264
264 - ssp = (uint8_t *)(env->segs[R_SS] << 4); 265 + ssp = (uint8_t *)(env->segs[R_SS].selector << 4);
265 sp = env->regs[R_ESP] & 0xffff; 266 sp = env->regs[R_ESP] & 0xffff;
266 267
267 #if defined(DEBUG_VM86) 268 #if defined(DEBUG_VM86)
268 fprintf(logfile, "VM86 exception %04x:%08x %02x %02x\n", 269 fprintf(logfile, "VM86 exception %04x:%08x %02x %02x\n",
269 - env->segs[R_CS], env->eip, pc[0], pc[1]); 270 + env->segs[R_CS].selector, env->eip, pc[0], pc[1]);
270 #endif 271 #endif
271 272
272 data32 = 0; 273 data32 = 0;
@@ -413,12 +414,12 @@ int do_vm86(CPUX86State *env, long subfunction, @@ -413,12 +414,12 @@ int do_vm86(CPUX86State *env, long subfunction,
413 ts->vm86_saved_regs.esp = env->regs[R_ESP]; 414 ts->vm86_saved_regs.esp = env->regs[R_ESP];
414 ts->vm86_saved_regs.eflags = env->eflags; 415 ts->vm86_saved_regs.eflags = env->eflags;
415 ts->vm86_saved_regs.eip = env->eip; 416 ts->vm86_saved_regs.eip = env->eip;
416 - ts->vm86_saved_regs.cs = env->segs[R_CS];  
417 - ts->vm86_saved_regs.ss = env->segs[R_SS];  
418 - ts->vm86_saved_regs.ds = env->segs[R_DS];  
419 - ts->vm86_saved_regs.es = env->segs[R_ES];  
420 - ts->vm86_saved_regs.fs = env->segs[R_FS];  
421 - ts->vm86_saved_regs.gs = env->segs[R_GS]; 417 + ts->vm86_saved_regs.cs = env->segs[R_CS].selector;
  418 + ts->vm86_saved_regs.ss = env->segs[R_SS].selector;
  419 + ts->vm86_saved_regs.ds = env->segs[R_DS].selector;
  420 + ts->vm86_saved_regs.es = env->segs[R_ES].selector;
  421 + ts->vm86_saved_regs.fs = env->segs[R_FS].selector;
  422 + ts->vm86_saved_regs.gs = env->segs[R_GS].selector;
422 423
423 /* build vm86 CPU state */ 424 /* build vm86 CPU state */
424 ts->v86flags = tswap32(target_v86->regs.eflags); 425 ts->v86flags = tswap32(target_v86->regs.eflags);
@@ -466,7 +467,8 @@ int do_vm86(CPUX86State *env, long subfunction, @@ -466,7 +467,8 @@ int do_vm86(CPUX86State *env, long subfunction,
466 target_v86->vm86plus.vm86dbg_intxxtab, 32); 467 target_v86->vm86plus.vm86dbg_intxxtab, 32);
467 468
468 #ifdef DEBUG_VM86 469 #ifdef DEBUG_VM86
469 - fprintf(logfile, "do_vm86: cs:ip=%04x:%04x\n", env->segs[R_CS], env->eip); 470 + fprintf(logfile, "do_vm86: cs:ip=%04x:%04x\n",
  471 + env->segs[R_CS].selector, env->eip);
470 #endif 472 #endif
471 /* now the virtual CPU is ready for vm86 execution ! */ 473 /* now the virtual CPU is ready for vm86 execution ! */
472 out: 474 out: