[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bochs-cvs
Subject:    [Bochs-cvs] CVS: bochs/cpu cpu.h,1.223,1.224 ctrl_xfer64.cc,1.34,1.35 ctrl_xfer_pro.cc,1.41,1.42 des
From:       Stanislav Shwartsman <sshwarts () users ! sourceforge ! net>
Date:       2005-07-10 20:32:36
Message-ID: E1DriTc-0001Yq-IX () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/bochs/bochs/cpu
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4829/cpu

Modified Files:
	cpu.h ctrl_xfer64.cc ctrl_xfer_pro.cc descriptor.h 
	exception.cc protect_ctrl.cc segment_ctrl_pro.cc tasking.cc 
Log Message:
Clearify the code. x86-64 code always running in pmode so it is not needed to check \
if we are in protected mode everytime


Index: cpu.h
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/cpu.h,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -d -r1.223 -r1.224
--- cpu.h	4 Jul 2005 17:44:08 -0000	1.223
+++ cpu.h	10 Jul 2005 20:32:22 -0000	1.224
@@ -2712,6 +2712,9 @@
   BX_SMF void call_protected(bxInstruction_c *, Bit16u cs, bx_address disp) \
BX_CPP_AttrRegparmN(3);  BX_SMF void return_protected(bxInstruction_c *, Bit16u \
pop_bytes) BX_CPP_AttrRegparmN(2);  BX_SMF void iret_protected(bxInstruction_c *) \
BX_CPP_AttrRegparmN(1); +#if BX_SUPPORT_X86_64
+  BX_SMF void long_return(bxInstruction_c *, Bit16u pop_bytes) \
BX_CPP_AttrRegparmN(2); +#endif
   BX_SMF void validate_seg_regs(void);
   BX_SMF void stack_return_to_v86(Bit32u new_eip, Bit32u raw_cs_selector,
                                      Bit32u flags32);

Index: ctrl_xfer64.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/ctrl_xfer64.cc,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- ctrl_xfer64.cc	19 May 2005 18:13:07 -0000	1.34
+++ ctrl_xfer64.cc	10 Jul 2005 20:32:30 -0000	1.35
@@ -98,21 +98,10 @@
   BX_CPU_THIS_PTR show_flag |= Flag_ret;
 #endif
 
-  Bit16u imm16 = i->Iw();
-
-  if (protected_mode()) {
-    BX_PANIC(("Return protected is not implemented in x86-64 mode !"));
-    BX_CPU_THIS_PTR return_protected(i, imm16);
-    goto done;
-  }
+  BX_ASSERT(protected_mode());
 
-  pop_64(&rip);
-  pop_64(&rcs_raw);
-  RIP = rip;
-  load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], (Bit16u) rcs_raw);
-  RSP += imm16;
+  long_return(i, i->Iw());
 
-done:
   BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET,
                       BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, \
BX_CPU_THIS_PTR rip);  }
@@ -127,18 +116,10 @@
   BX_CPU_THIS_PTR show_flag |= Flag_ret;
 #endif
 
-  if ( protected_mode() ) {
-    BX_PANIC(("Return protected is not implemented in x86-64 mode !"));
-    BX_CPU_THIS_PTR return_protected(i, 0);
-    goto done;
-  }
+  BX_ASSERT(protected_mode());
 
-  pop_64(&rip);
-  pop_64(&rcs_raw); /* 64bit pop, upper 48 bits discarded */
-  RIP = rip;
-  load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], (Bit16u) rcs_raw);
+  long_return(i, 0);
 
-done:
   BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET,
                       BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, \
BX_CPU_THIS_PTR rip);  }

Index: ctrl_xfer_pro.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/ctrl_xfer_pro.cc,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- ctrl_xfer_pro.cc	20 May 2005 17:04:42 -0000	1.41
+++ ctrl_xfer_pro.cc	10 Jul 2005 20:32:31 -0000	1.42
@@ -91,8 +91,8 @@
       }
     }
 
-    /* segment must be PRESENT else #NP(selector) */
-    if (descriptor.p == 0) {
+    /* segment must be present else #NP(selector) */
+    if (! IS_PRESENT(descriptor)) {
       BX_ERROR(("jump_protected: p == 0"));
       exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
       return;
@@ -177,7 +177,7 @@
         BX_DEBUG(("jump_protected: JUMP TO 286 CALL GATE"));
 
         // gate must be present else #NP(gate selector)
-        if (descriptor.p==0) {
+        if (! IS_PRESENT(descriptor)) {
           BX_ERROR(("jump_protected: task gate.p == 0"));
           exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
           return;
@@ -221,7 +221,7 @@
         }
 
         // code segment must be present else #NP(CS selector)
-        if (gate_cs_descriptor.p==0) {
+        if (! IS_PRESENT(gate_cs_descriptor)) {
           BX_ERROR(("jump_protected: code seg not present"));
           exception(BX_NP_EXCEPTION, gate_cs_raw & 0xfffc, 0);
         }
@@ -243,7 +243,7 @@
 
       case BX_TASK_GATE:
         // task gate must be present else #NP(gate selector)
-        if (descriptor.p==0) {
+        if (! IS_PRESENT(descriptor)) {
           BX_ERROR(("jump_protected: task gate.p == 0"));
           exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
           return;
@@ -276,7 +276,7 @@
         }
 
         // task state segment must be present, else #NP(tss selector)
-        if (tss_descriptor.p==0) {
+        if (! IS_PRESENT(tss_descriptor)) {
           BX_ERROR(("jump_protected: task descriptor.p == 0"));
           exception(BX_NP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
         }
@@ -307,7 +307,7 @@
 #endif
 
         // gate must be present else #NP(gate selector)
-        if (descriptor.p==0) {
+        if (! IS_PRESENT(descriptor)) {
           BX_ERROR(("jump_protected: task gate.p == 0"));
           exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
           return;
@@ -350,7 +350,7 @@
         }
 
         // code segment must be present else #NP(CS selector)
-        if (gate_cs_descriptor.p==0) {
+        if (! IS_PRESENT(gate_cs_descriptor)) {
           BX_ERROR(("jump_protected: code seg not present"));
           exception(BX_NP_EXCEPTION, gate_cs_raw & 0xfffc, 0);
         }
@@ -440,7 +440,7 @@
     }
 
     // segment must be present, else #NP(code seg selector)
-    if (cs_descriptor.p == 0) {
+    if (! IS_PRESENT(cs_descriptor)) {
       BX_ERROR(("call_protected: cs.p = 0"));
       exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
     }
@@ -556,7 +556,7 @@
 
       case BX_TASK_GATE:
         // task gate must be present else #NP(gate selector)
-        if (gate_descriptor.p==0) {
+        if (! IS_PRESENT(gate_descriptor)) {
           BX_ERROR(("call_protected: task gate.p == 0"));
           exception(BX_NP_EXCEPTION, cs_raw & 0xfffc, 0);
           return;
@@ -589,7 +589,7 @@
         }
 
         // task state segment must be present, else #NP(tss selector)
-        if (tss_descriptor.p==0) {
+        if (! IS_PRESENT(tss_descriptor)) {
           BX_ERROR(("call_protected: task descriptor.p == 0"));
           exception(BX_NP_EXCEPTION, raw_tss_selector & 0xfffc, 0);
         }
@@ -620,7 +620,7 @@
         //  BX_INFO(("CALL: 32bit call gate"));
 
         // call gate must be present, else #NP(call gate selector)
-        if (gate_descriptor.p==0) {
+        if (! IS_PRESENT(gate_descriptor)) {
           BX_ERROR(("call_protected: not present"));
           exception(BX_NP_EXCEPTION, gate_selector.value & 0xfffc, 0);
         }
@@ -738,7 +738,7 @@
           }
 
           // segment must be present, else #SS(SS selector)
-          if (ss_descriptor.p==0) {
+          if (! IS_PRESENT(ss_descriptor)) {
             BX_ERROR(("call_protected: ss descriptor not present."));
             exception(BX_SS_EXCEPTION, SS_for_cpl_x & 0xfffc, 0);
             return;
@@ -932,6 +932,16 @@
   BX_PANIC(("call_protected: shouldn't get here!"));
 }
 
+#if BX_SUPPORT_X86_64
+
+  void BX_CPP_AttrRegparmN(2)
+BX_CPU_C::long_return(bxInstruction_c *i, Bit16u pop_bytes)
+{
+  BX_PANIC(("Return protected is not implemented in x86-64 mode !"));
+}
+
+#endif
+
   void BX_CPP_AttrRegparmN(2)
 BX_CPU_C::return_protected(bxInstruction_c *i, Bit16u pop_bytes)
 {
@@ -991,7 +1001,7 @@
   }
 
   // if return selector RPL == CPL then
-  // RETURN TO SAME LEVEL
+  // RETURN TO SAME PRIVILEGE LEVEL
   if ( cs_selector.rpl == CPL ) {
     //BX_INFO(("return: to same level %04x:%08x",
     //   BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
@@ -1040,7 +1050,7 @@
     }
 
     // code segment must be present, else #NP(selector)
-    if (cs_descriptor.p==0) {
+    if (! IS_PRESENT(cs_descriptor)) {
       BX_ERROR(("return_protected: not present"));
       exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
       return;
@@ -1093,9 +1103,9 @@
     /* + 2:     CS      | + 4:         CS */
     /* + 0:     IP      | + 0:        EIP */
 
-//BX_INFO(("return: to outer level %04x:%08x",
-//  BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
-//  BX_CPU_THIS_PTR prev_eip));
+    //BX_INFO(("return: to outer level %04x:%08x",
+    //  BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
+    //  BX_CPU_THIS_PTR prev_eip));
 
     if (i->os32L()) {
       /* top 16+immediate bytes on stack must be within stack limits, else #SS(0) */
@@ -1158,8 +1168,8 @@
     }
 
     /* segment must be present else #NP(selector) */
-    if (cs_descriptor.p==0) {
-      BX_INFO(("return_protected: segment not present"));
+    if (! IS_PRESENT(cs_descriptor)) {
+      BX_ERROR(("return_protected: segment not present"));
       exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
       return;
     }
@@ -1228,8 +1238,8 @@
     }
 
     /* segment must be present else #SS(selector) */
-    if (ss_descriptor.p==0) {
-      BX_ERROR(("ss.p == 0"));
+    if (! IS_PRESENT(ss_descriptor)) {
+      BX_ERROR(("ss.present == 0"));
       exception(BX_SS_EXCEPTION, raw_ss_selector & 0xfffc, 0);
       return;
     }
@@ -1319,8 +1329,8 @@
     }
 
     // TSS must be present, else #NP(new TSS selector)
-    if (tss_descriptor.p==0) {
-      BX_INFO(("iret: task descriptor.p == 0"));
+    if (! IS_PRESENT(tss_descriptor)) {
+      BX_ERROR(("iret: task descriptor.p == 0"));
       exception(BX_NP_EXCEPTION, raw_link_selector & 0xfffc, 0);
     }
 
@@ -1442,8 +1452,8 @@
     }
 
     // segment must be present else #NP(return selector)
-    if ( cs_descriptor.p==0 ) {
-      BX_PANIC(("iret: not present"));
+    if (! IS_PRESENT(cs_descriptor)) {
+      BX_ERROR(("iret: not present"));
       exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
       return;
     }
@@ -1524,8 +1534,8 @@
         }
 
         /* SS must be present, else #NP(SS selector) */
-        if ( ss_descriptor.p==0 ) {
-          BX_PANIC(("iret: SS not present!"));
+        if (! IS_PRESENT(ss_descriptor)) {
+          BX_ERROR(("iret: SS not present!"));
           exception(BX_NP_EXCEPTION, raw_ss_selector & 0xfffc, 0);
           return;
         }
@@ -1699,8 +1709,8 @@
     }
 
     // segment must be present else #NP(return selector)
-    if ( cs_descriptor.p==0 ) {
-      BX_PANIC(("iret: not present"));
+    if (! IS_PRESENT(cs_descriptor)) {
+      BX_ERROR(("iret: segment not present"));
       exception(BX_NP_EXCEPTION, raw_cs_selector & 0xfffc, 0);
       return;
     }
@@ -1812,7 +1822,7 @@
       }
 
       /* SS must be present, else #NP(SS selector) */
-      if ( ss_descriptor.p==0 ) {
+      if (! IS_PRESENT(ss_descriptor)) {
         BX_ERROR(("iret: SS not present!"));
         exception(BX_NP_EXCEPTION, raw_ss_selector & 0xfffc, 0);
         return;

Index: descriptor.h
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/descriptor.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- descriptor.h	19 May 2005 19:46:20 -0000	1.7
+++ descriptor.h	10 Jul 2005 20:32:31 -0000	1.8
@@ -148,6 +148,7 @@
 
 } bx_descriptor_t;
 
+#define IS_PRESENT(descriptor) (descriptor.p)
 
 #if BX_SUPPORT_X86_64
   #define IS_LONG64_SEGMENT(descriptor)  (descriptor.u.segment.l)

Index: exception.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/exception.cc,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- exception.cc	7 Jul 2005 18:40:26 -0000	1.57
+++ exception.cc	10 Jul 2005 20:32:31 -0000	1.58
@@ -111,7 +111,7 @@
   }
 
   // Gate must be present, else #NP(vector * 8 + 2 + EXT)
-  if (gate_descriptor.p == 0) {
+  if (! IS_PRESENT(gate_descriptor)) {
     BX_ERROR(("interrupt(long mode): p == 0"));
     exception(BX_NP_EXCEPTION, vector*8 + 2, 0);
   }
@@ -157,7 +157,7 @@
   }
 
   // segment must be present, else #NP(selector + EXT)
-  if ( cs_descriptor.p==0 ) {
+  if (! IS_PRESENT(cs_descriptor)) {
     BX_ERROR(("interrupt(long mode): segment not present"));
     exception(BX_NP_EXCEPTION, cs_selector.value & 0xfffc, 0);
   }
@@ -351,7 +351,7 @@
   }
 
   // Gate must be present, else #NP(vector * 8 + 2 + EXT)
-  if (gate_descriptor.p == 0) {
+  if (! IS_PRESENT(gate_descriptor)) {
     BX_DEBUG(("interrupt(): gate not present"));
     exception(BX_NP_EXCEPTION, vector*8 + 2, 0);
   }
@@ -458,8 +458,7 @@
     }
 
     // segment must be present, else #NP(selector + EXT)
-    if ( cs_descriptor.p==0 )
-    {
+    if (! IS_PRESENT(cs_descriptor)) {
       BX_DEBUG(("interrupt(): segment not present"));
       exception(BX_NP_EXCEPTION, cs_selector.value & 0xfffc, 0);
     }
@@ -525,8 +524,8 @@
       }
 
       // seg must be present, else #SS(SS selector + ext)
-      if (ss_descriptor.p==0) {
-        BX_PANIC(("interrupt(): SS not present"));
+      if (! IS_PRESENT(ss_descriptor)) {
+        BX_ERROR(("interrupt(): SS not present"));
         exception(BX_SS_EXCEPTION, SS_for_cpl_x & 0xfffc, 0);
       }
 

Index: protect_ctrl.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/protect_ctrl.cc,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- protect_ctrl.cc	22 Jun 2005 18:13:45 -0000	1.39
+++ protect_ctrl.cc	10 Jul 2005 20:32:31 -0000	1.40
@@ -390,7 +390,7 @@
   }
 
   /* #NP(selector) if LDT descriptor is not present */
-  if (descriptor.p==0) {
+  if (! IS_PRESENT(descriptor)) {
     BX_ERROR(("LLDT: LDT descriptor not present!"));
     exception(BX_NP_EXCEPTION, raw_selector & 0xfffc, 0);
   }
@@ -486,7 +486,7 @@
   }
 
   /* #NP(selector) if TSS descriptor is not present */
-  if (descriptor.p==0) {
+  if (! IS_PRESENT(descriptor)) {
     BX_ERROR(("LTR: LDT descriptor not present!"));
     exception(BX_NP_EXCEPTION, raw_selector & 0xfffc, 0);
     return;

Index: segment_ctrl_pro.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/segment_ctrl_pro.cc,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- segment_ctrl_pro.cc	19 May 2005 18:13:08 -0000	1.38
+++ segment_ctrl_pro.cc	10 Jul 2005 20:32:32 -0000	1.39
@@ -159,7 +159,7 @@
       }
 
       /* segment must be marked PRESENT else #SS(selector) */
-      if (descriptor.p == 0) {
+      if (! IS_PRESENT(descriptor)) {
         BX_ERROR(("load_seg_reg(): not present"));
         exception(BX_SS_EXCEPTION, new_value & 0xfffc, 0);
       }
@@ -274,7 +274,7 @@
       }
 
       /* segment must be marked PRESENT else #NP(selector) */
-      if (descriptor.p == 0) {
+      if (! IS_PRESENT(descriptor)) {
         BX_ERROR(("load_seg_reg: segment not present"));
         exception(BX_NP_EXCEPTION, new_value & 0xfffc, 0);
         return;

Index: tasking.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/cpu/tasking.cc,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- tasking.cc	22 Jun 2005 18:13:45 -0000	1.21
+++ tasking.cc	10 Jul 2005 20:32:32 -0000	1.22
@@ -557,11 +557,12 @@
     }
 
     // LDT of new task is present in memory, else #TS(new tasks's LDT)
-    else if (ldt_descriptor.p==0) {
+    if (! IS_PRESENT(ldt_descriptor)) {
       exception_no = BX_TS_EXCEPTION;
       error_code   = raw_ldt_selector & 0xfffc;
       goto post_exception;
     }
+
     // All checks pass, fill in LDTR shadow cache
     BX_CPU_THIS_PTR ldtr.cache = ldt_descriptor;
   }
@@ -603,7 +604,7 @@
       }
 
       // if non-conforming then DPL must equal selector RPL else #TS(CS)
-      else if (cs_descriptor.u.segment.c_ed==0 &&
+      if (cs_descriptor.u.segment.c_ed==0 &&
           cs_descriptor.dpl!=cs_selector.rpl)
       {
         BX_INFO(("task_switch: non-conforming: CS.dpl!=CS.RPL"));
@@ -613,7 +614,7 @@
       }
 
       // if conforming then DPL must be <= selector RPL else #TS(CS)
-      else if (cs_descriptor.u.segment.c_ed &&
+      if (cs_descriptor.u.segment.c_ed &&
                cs_descriptor.dpl>cs_selector.rpl)
       {
         BX_INFO(("task_switch: conforming: CS.dpl>RPL"));
@@ -623,8 +624,7 @@
       }
 
       // Code segment is present in memory, else #NP(new code segment)
-      else if (cs_descriptor.p==0)
-      {
+      if (! IS_PRESENT(cs_descriptor)) {
         BX_PANIC(("task_switch: CS.p==0"));
         exception_no = BX_NP_EXCEPTION;
         error_code   = raw_cs_selector & 0xfffc;
@@ -671,7 +671,7 @@
       //
       // Stack segment is present in memory, else #SF(new stack segment)
       //
-      else if (ss_descriptor.p==0) {
+      if (! IS_PRESENT(ss_descriptor)) {
         BX_PANIC(("task_switch: SS not present"));
         exception_no = BX_SS_EXCEPTION;
         error_code   = raw_ss_selector & 0xfffc;
@@ -679,7 +679,7 @@
       }
 
       // Stack segment DPL matches CS.RPL, else #TS(new stack segment)
-      else if (ss_descriptor.dpl != cs_selector.rpl) {
+      if (ss_descriptor.dpl != cs_selector.rpl) {
         BX_PANIC(("task_switch: SS.rpl != CS.RPL"));
         exception_no = BX_TS_EXCEPTION;
         error_code   = raw_ss_selector & 0xfffc;
@@ -687,7 +687,7 @@
       }
 
       // Stack segment DPL matches selector RPL, else #TS(new stack segment)
-      else if (ss_descriptor.dpl != ss_selector.rpl) {
+      if (ss_descriptor.dpl != ss_selector.rpl) {
         BX_PANIC(("task_switch: SS.dpl != SS.rpl"));
         exception_no = BX_TS_EXCEPTION;
         error_code   = raw_ss_selector & 0xfffc;
@@ -695,8 +695,7 @@
       }
 
 #if 0
-      // +++
-      else if (ss_descriptor.u.segment.d_b && (tss_descriptor->type<9)) {
+      if (ss_descriptor.u.segment.d_b && (tss_descriptor->type<9)) {
         BX_DEBUG(( "++++++++++++++++++++++++++" ));
         exception_no = BX_TS_EXCEPTION;
         error_code   = raw_ss_selector & 0xfffc;
@@ -735,6 +734,7 @@
       }
 
       parse_descriptor(dword1, dword2, &ds_descriptor);
+
       if (ds_descriptor.valid==0 || ds_descriptor.segment==0 ||
          (ds_descriptor.u.segment.executable &&
           ds_descriptor.u.segment.r_w==0))
@@ -744,17 +744,19 @@
         error_code   = raw_ds_selector & 0xfffc;
         goto post_exception;
       }
+
       // if data or non-conforming code
-      else if (ds_descriptor.type<12 &&
-              (ds_descriptor.dpl<cs_selector.rpl ||
-               ds_descriptor.dpl<ds_selector.rpl))
+      if (ds_descriptor.type<12 &&
+         (ds_descriptor.dpl<cs_selector.rpl ||
+          ds_descriptor.dpl<ds_selector.rpl))
       {
         BX_PANIC(("task_switch: DS.dpl not valid"));
         exception_no = BX_TS_EXCEPTION;
         error_code   = raw_ds_selector & 0xfffc;
         goto post_exception;
       }
-      else if (ds_descriptor.p==0) {
+
+      if (! IS_PRESENT(ds_descriptor)) {
         BX_PANIC(("task_switch: DS.p==0"));
         exception_no = BX_NP_EXCEPTION;
         error_code   = raw_ds_selector & 0xfffc;
@@ -779,6 +781,7 @@
       }
 
       parse_descriptor(dword1, dword2, &es_descriptor);
+
       if (es_descriptor.valid==0 || es_descriptor.segment==0 ||
          (es_descriptor.u.segment.executable &&
           es_descriptor.u.segment.r_w==0))
@@ -788,17 +791,19 @@
         error_code   = raw_es_selector & 0xfffc;
         goto post_exception;
       }
+
       // if data or non-conforming code
-      else if (es_descriptor.type<12 &&
-              (es_descriptor.dpl<cs_selector.rpl ||
-               es_descriptor.dpl<es_selector.rpl))
+      if (es_descriptor.type<12 &&
+         (es_descriptor.dpl<cs_selector.rpl ||
+          es_descriptor.dpl<es_selector.rpl))
       {
         BX_PANIC(("task_switch: ES.dpl not valid"));
         exception_no = BX_TS_EXCEPTION;
         error_code   = raw_es_selector & 0xfffc;
         goto post_exception;
       }
-      else if (es_descriptor.p==0) {
+
+      if (! IS_PRESENT(es_descriptor)) {
         BX_PANIC(("task_switch: ES.p==0"));
         exception_no = BX_NP_EXCEPTION;
         error_code   = raw_es_selector & 0xfffc;
@@ -832,8 +837,9 @@
         error_code   = raw_fs_selector & 0xfffc;
         goto post_exception;
       }
+
       // if data or non-conforming code
-      else if (fs_descriptor.type<12 &&
+      if (fs_descriptor.type<12 &&
               (fs_descriptor.dpl<cs_selector.rpl ||
                fs_descriptor.dpl<fs_selector.rpl))
       {
@@ -842,7 +848,8 @@
         error_code   = raw_fs_selector & 0xfffc;
         goto post_exception;
       }
-      else if (fs_descriptor.p==0) {
+
+      if (! IS_PRESENT(fs_descriptor)) {
         BX_PANIC(("task_switch: FS.p==0"));
         exception_no = BX_NP_EXCEPTION;
         error_code   = raw_fs_selector & 0xfffc;
@@ -876,17 +883,19 @@
         error_code   = raw_gs_selector & 0xfffc;
         goto post_exception;
       }
+
       // if data or non-conforming code
-      else if (gs_descriptor.type<12 &&
-              (gs_descriptor.dpl<cs_selector.rpl ||
-               gs_descriptor.dpl<gs_selector.rpl))
+      if (gs_descriptor.type<12 &&
+         (gs_descriptor.dpl<cs_selector.rpl ||
+          gs_descriptor.dpl<gs_selector.rpl))
       {
         BX_PANIC(("task_switch: GS.dpl not valid"));
         exception_no = BX_TS_EXCEPTION;
         error_code   = raw_gs_selector & 0xfffc;
         goto post_exception;
       }
-      else if (gs_descriptor.p==0) {
+
+      if (! IS_PRESENT(gs_descriptor)) {
         BX_PANIC(("task_switch: GS.p==0"));
         exception_no = BX_NP_EXCEPTION;
         error_code   = raw_gs_selector & 0xfffc;



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Bochs-cvs mailing list
Bochs-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bochs-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic