arch-x86: Make sure the TLB checks against CS for fetches.

When instructions perform accesses, they embed the segment being used
into the request flags. When the CPU creates a request instead, for
instance when fetching an instruction, it doesn't know to do that.

This change adds a check in the TLB when makes sure CS is used when
checking a fetch, even if the flags didn't say to.

Change-Id: Ie9da3afc0b10eeb96247353150c64f1829cea41b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/55247
Reviewed-by: Matthew Poremba <matthew.poremba@amd.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2022-01-09 01:48:33 -08:00
parent 15df63624b
commit b4c285b3c0

View File

@@ -335,6 +335,11 @@ TLB::translate(const RequestPtr &req,
if (m5Reg.mode != LongMode) {
DPRINTF(TLB, "Not in long mode. Checking segment protection.\n");
// CPUs won't know to use CS when building fetch requests, so we
// need to override the value of "seg" here if this is a fetch.
if (mode == BaseMMU::Execute)
seg = SEGMENT_REG_CS;
SegAttr attr = tc->readMiscRegNoEffect(MISCREG_SEG_ATTR(seg));
// Check for an unusable segment.
if (attr.unusable) {