X86: Actually check page protections.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 25 Feb 2009 18:18:58 +0000 (10:18 -0800)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 25 Feb 2009 18:18:58 +0000 (10:18 -0800)
src/arch/x86/tlb.cc

index 372c8b997c413c3a1162a0b727127e6e2c2bd4b9..603d4e45f1c4cac650fab15e8f8091029351a3ac 100644 (file)
@@ -649,6 +649,18 @@ TLB::translate(RequestPtr req, ThreadContext *tc,
 #endif
             }
             // Do paging protection checks.
+            bool inUser = (csAttr.dpl == 3 &&
+                    !(flags & (CPL0FlagBit << FlagShift)));
+            if (inUser && !entry->user ||
+                    write && !entry->writable) {
+                // The page must have been present to get into the TLB in
+                // the first place. We'll assume the reserved bits are
+                // fine even though we're not checking them.
+                return new PageFault(vaddr, true, write,
+                                     inUser, false, execute);
+            }
+
+
             DPRINTF(TLB, "Entry found with paddr %#x, "
                     "doing protection checks.\n", entry->paddr);
             Addr paddr = entry->paddr | (vaddr & (entry->size-1));