X86: Add segmentation checks for ldt related descriptors and selectors.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 25 Feb 2009 18:21:21 +0000 (10:21 -0800)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 25 Feb 2009 18:21:21 +0000 (10:21 -0800)
src/arch/x86/isa/microasm.isa
src/arch/x86/isa/microops/regop.isa

index 00baed7682dbff289a440e4926c334a386cda012..c7c6dae2e3e4c08116028ebc0c1d0b2c2b8ddc3a 100644 (file)
@@ -87,7 +87,7 @@ let {{
     # Add in symbols for the various checks of segment selectors.
     for check in ("NoCheck", "CSCheck", "CallGateCheck", "IntGateCheck",
                   "SoftIntGateCheck", "SSCheck", "IretCheck", "IntCSCheck",
-                  "TRCheck", "TSSCheck"):
+                  "TRCheck", "TSSCheck", "InGDTCheck", "LDTCheck"):
         assembler.symbols[check] = "Seg%s" % check
 
     for reg in ("TR", "IDTR"):
index d5eb59f116a845da3da62da81b6a9fbd41294bb0..f9bc8211999ae0c002f504c218c841626433a205 100644 (file)
@@ -235,7 +235,7 @@ output header {{
     enum SegmentSelectorCheck {
       SegNoCheck, SegCSCheck, SegCallGateCheck, SegIntGateCheck,
       SegSoftIntGateCheck, SegSSCheck, SegIretCheck, SegIntCSCheck,
-      SegTRCheck, SegTSSCheck
+      SegTRCheck, SegTSSCheck, SegInGDTCheck, SegLDTCheck
     };
 
     enum LongModeDescriptorType {
@@ -1174,6 +1174,18 @@ let {{
                     fault = new GeneralProtection(selector);
                 }
                 break;
+              case SegInGDTCheck:
+                if (selector.ti) {
+                    fault = new GeneralProtection(selector);
+                }
+                break;
+              case SegLDTCheck:
+                if (!desc.p) {
+                    fault = new SegmentNotPresent(selector);
+                } else if (desc.type != 0x2) {
+                    fault = new GeneralProtection(selector);
+                }
+                break;
               default:
                 panic("Undefined segment check type.\\n");
             }