summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harris <tharris@microsoft.com>2011-02-07 15:18:52 -0800
committerTim Harris <tharris@microsoft.com>2011-02-07 15:18:52 -0800
commit44e5e7e0533ba2544f2d37f8e051a0422966bd9b (patch)
tree600afb1e183f3fecc1c6fb2100285d2ccadd6525
parent6da83b8a1b06e64a2fc7b14c5ad342188f082848 (diff)
downloadgem5-44e5e7e0533ba2544f2d37f8e051a0422966bd9b.tar.xz
X86: Obey the wp bit of CR0.
If cr0.wp ("write protect" bit) is clear then do not generate page faults when writing to write-protected pages in kernel mode.
-rw-r--r--src/arch/x86/tlb.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/arch/x86/tlb.cc b/src/arch/x86/tlb.cc
index a02c5e6a3..7b7af3288 100644
--- a/src/arch/x86/tlb.cc
+++ b/src/arch/x86/tlb.cc
@@ -634,14 +634,15 @@ TLB::translate(RequestPtr req, ThreadContext *tc, Translation *translation,
// Do paging protection checks.
bool inUser = (m5Reg.cpl == 3 &&
!(flags & (CPL0FlagBit << FlagShift)));
- if ((inUser && !entry->user) ||
- (mode == Write && !entry->writable)) {
+ CR0 cr0 = tc->readMiscRegNoEffect(MISCREG_CR0);
+ bool badWrite = (!entry->writable && (inUser || cr0.wp));
+ if ((inUser && !entry->user) || (mode == Write && badWrite)) {
// 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, mode, inUser, false);
}
- if (storeCheck && !entry->writable) {
+ if (storeCheck && badWrite) {
// This would fault if this were a write, so return a page
// fault that reflects that happening.
return new PageFault(vaddr, true, Write, inUser, false);