Commit a412ac572ffad45f663795ba7dfa8fa1603ef206

Authored by bellard
1 parent b2b5fb22

real mode support


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@335 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 7 additions and 9 deletions
cpu-exec.c
@@ -244,12 +244,12 @@ int cpu_exec(CPUState *env1) @@ -244,12 +244,12 @@ int cpu_exec(CPUState *env1)
244 (unsigned long)env->segs[R_ES].base | 244 (unsigned long)env->segs[R_ES].base |
245 (unsigned long)env->segs[R_SS].base) != 0) << 245 (unsigned long)env->segs[R_SS].base) != 0) <<
246 GEN_FLAG_ADDSEG_SHIFT; 246 GEN_FLAG_ADDSEG_SHIFT;
247 - if (!(env->eflags & VM_MASK)) {  
248 - flags |= (env->segs[R_CS].selector & 3) << GEN_FLAG_CPL_SHIFT;  
249 - } else {  
250 - /* NOTE: a dummy CPL is kept */  
251 - flags |= (1 << GEN_FLAG_VM_SHIFT);  
252 - flags |= (3 << GEN_FLAG_CPL_SHIFT); 247 + if (env->cr[0] & CR0_PE_MASK) {
  248 + if (!(env->eflags & VM_MASK))
  249 + flags |= (env->segs[R_CS].selector & 3) <<
  250 + GEN_FLAG_CPL_SHIFT;
  251 + else
  252 + flags |= (1 << GEN_FLAG_VM_SHIFT);
253 } 253 }
254 flags |= (env->eflags & (IOPL_MASK | TF_MASK)); 254 flags |= (env->eflags & (IOPL_MASK | TF_MASK));
255 cs_base = env->segs[R_CS].base; 255 cs_base = env->segs[R_CS].base;
@@ -396,12 +396,10 @@ void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector) @@ -396,12 +396,10 @@ void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector)
396 396
397 saved_env = env; 397 saved_env = env;
398 env = s; 398 env = s;
399 - if (env->eflags & VM_MASK) { 399 + if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK)) {
400 SegmentCache *sc; 400 SegmentCache *sc;
401 selector &= 0xffff; 401 selector &= 0xffff;
402 sc = &env->segs[seg_reg]; 402 sc = &env->segs[seg_reg];
403 - /* NOTE: in VM86 mode, limit and flags are never reloaded,  
404 - so we must load them here */  
405 sc->base = (void *)(selector << 4); 403 sc->base = (void *)(selector << 4);
406 sc->limit = 0xffff; 404 sc->limit = 0xffff;
407 sc->flags = 0; 405 sc->flags = 0;