arch-x86: Fixes page fault for CLFLUSH on write-protected pages

Converts CLFLUSHOPT/WB/FLUSH operations from Write to Read operations
during address translation so that they don't trigger a page fault
when done on write-protected pages.

Change-Id: I20e89cc0cb2b288b36ba1f0ba39a2e1bf0f728af
This commit is contained in:
Aditya K Kamath
2023-11-22 20:09:45 +00:00
committed by aditya
parent 6e433ed885
commit 9a0566e295

View File

@@ -509,6 +509,9 @@ TLB::translateAtomic(const RequestPtr &req, ThreadContext *tc,
BaseMMU::Mode mode)
{
bool delayedResponse;
// CLFLUSHOPT/WB/FLUSH should be treated as read for protection checks
if (req->isCacheClean())
mode = BaseMMU::Read;
return TLB::translate(req, tc, NULL, mode, delayedResponse, false);
}
@@ -516,6 +519,9 @@ Fault
TLB::translateFunctional(const RequestPtr &req, ThreadContext *tc,
BaseMMU::Mode mode)
{
// CLFLUSHOPT/WB/FLUSH should be treated as read for protection checks
if (req->isCacheClean())
mode = BaseMMU::Read;
unsigned logBytes;
const Addr vaddr = req->getVaddr();
Addr addr = vaddr;
@@ -553,6 +559,9 @@ TLB::translateTiming(const RequestPtr &req, ThreadContext *tc,
{
bool delayedResponse;
assert(translation);
// CLFLUSHOPT/WB/FLUSH should be treated as read for protection checks
if (req->isCacheClean())
mode = BaseMMU::Read;
Fault fault =
TLB::translate(req, tc, translation, mode, delayedResponse, true);
if (!delayedResponse)