Use an invalid virtual address when preventing prediction, and also

detect invalid virtual addresses in the TLB and miss rather than proceed
with page walking.
This commit is contained in:
Jonathan Woodruff
2021-10-08 11:00:11 +00:00
parent cec55419f5
commit 5d5bee3e08
3 changed files with 10 additions and 6 deletions

View File

@@ -746,7 +746,7 @@ module mkFetchStage(FetchStage);
end
end else if (!isValid(nextPc)) begin
// A Jr will jump; if we don't have a record, we should wait to prevent wasted work.
nextPc = Valid (0); // Dummy value to prevent progress.
nextPc = Valid ({2'b01,?}); // Invalid virtual address to prevent progress.
end
end

View File

@@ -304,7 +304,8 @@ module mkITlb(ITlb::ITlb);
else if (vm_info.sv39) begin
let vpn = getVpn(vaddr);
let trans_result = tlb.translate(vpn, vm_info.asid);
if (trans_result.hit) begin
if (!validVirtualAddress(vaddr)) hitQ.enq(tuple3(?, Valid (excInstPageFault), False));
else if (trans_result.hit) begin
// TLB hit
let entry = trans_result.entry;
// check permission

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2017 Massachusetts Institute of Technology
//
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -8,10 +8,10 @@
// modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -51,7 +51,7 @@ typedef 44 PpnSz;
typedef Bit#(PpnSz) Ppn;
typedef 12 PageOffsetSz; // 4KB basic page
typedef Bit#(PageOffsetSz) PageOffset;
typedef 9 VpnIdxSz; // Vpn is broken down to 3 indexes to 3 levels of page table
typedef 9 VpnIdxSz; // Vpn is broken down to 3 indexes to 3 levels of page table
typedef Bit#(VpnIdxSz) VpnIdx;
typedef Bit#(2) PageWalkLevel; // 2: 1GB page, 1: 2MB page, 0: 4KB page
typedef 3 NumPageWalkLevels;
@@ -99,6 +99,9 @@ function Vpn getVpn(Addr addr) = addr[38:12];
function PageOffset getPageOffset(Addr addr) = truncate(addr);
// All the upper bits should be equal for a valid SV39 virtual address.
function Bool validVirtualAddress(Addr addr) = ((^addr[63:39]) == 0);
function Addr getPTBaseAddr(Ppn basePpn);
PageOffset offset = 0;
return zeroExtend({basePpn, offset});