gem5 v24.0.0.0
Loading...
Searching...
No Matches
pagetable_walker.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
3 * Copyright (c) 2020 Barkhausen Institut
4 * All rights reserved.
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are
17 * met: redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer;
19 * redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution;
22 * neither the name of the copyright holders nor the names of its
23 * contributors may be used to endorse or promote products derived from
24 * this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef __ARCH_RISCV_TABLE_WALKER_HH__
40#define __ARCH_RISCV_TABLE_WALKER_HH__
41
42#include <vector>
43
44#include "arch/generic/mmu.hh"
47#include "arch/riscv/pmp.hh"
48#include "arch/riscv/tlb.hh"
49#include "base/statistics.hh"
50#include "base/types.hh"
51#include "mem/packet.hh"
52#include "params/RiscvPagetableWalker.hh"
53#include "sim/clocked_object.hh"
54#include "sim/faults.hh"
55#include "sim/system.hh"
56
57namespace gem5
58{
59
60class ThreadContext;
61
62namespace RiscvISA
63{
64 class Walker : public ClockedObject
65 {
66 protected:
67 // Port for accessing memory
68 class WalkerPort : public RequestPort
69 {
70 public:
71 WalkerPort(const std::string &_name, Walker * _walker) :
72 RequestPort(_name), walker(_walker)
73 {}
74
75 protected:
77
78 bool recvTimingResp(PacketPtr pkt);
79 void recvReqRetry();
80 };
81
82 friend class WalkerPort;
84
85 // State to track each walk of the page table
87 {
88 friend class Walker;
89 private:
96
97 protected:
103 int level;
104 unsigned inflight;
111 SATP satp;
112 STATUS status;
115 bool timing;
119 public:
120 WalkerState(Walker * _walker, BaseMMU::Translation *_translation,
121 const RequestPtr &_req, bool _isFunctional = false) :
122 walker(_walker), req(_req), state(Ready),
123 nextState(Ready), level(0), inflight(0),
124 translation(_translation),
125 functional(_isFunctional), timing(false),
126 retrying(false), started(false), squashed(false)
127 {
128 }
129 void initState(ThreadContext * _tc, BaseMMU::Mode _mode,
130 bool _isTiming = false);
132 Fault startFunctional(Addr &addr, unsigned &logBytes);
133 bool recvPacket(PacketPtr pkt);
134 unsigned numInflight() const;
135 bool isRetrying();
136 bool wasStarted();
137 bool isTiming();
138 void retry();
139 void squash();
140 std::string name() const {return walker->name();}
141
142 private:
143 void setupWalk(Addr vaddr);
144 Fault stepWalk(PacketPtr &write);
145 void sendPackets();
146 void endWalk();
147 Fault pageFault(bool present);
148 };
149
150 friend class WalkerState;
151 // State for timing and atomic accesses (need multiple per walker in
152 // the case of multiple outstanding requests in timing mode)
154 // State for functional accesses (only need one of these per walker)
156
158 {
161 senderWalk(_senderWalk) {}
162 };
163
164 public:
165 // Kick off the state machine.
166 Fault start(ThreadContext * _tc, BaseMMU::Translation *translation,
167 const RequestPtr &req, BaseMMU::Mode mode);
169 unsigned &logBytes, BaseMMU::Mode mode);
170 Port &getPort(const std::string &if_name,
171 PortID idx=InvalidPortID) override;
172
173 protected:
174 // The TLB we're supposed to load.
180
181 // The number of outstanding walks that can be squashed per cycle.
183
184 // Wrapper for checking for squashes before starting a translation.
185 void startWalkWrapper();
186
191
192 // Functions for dealing with packets.
193 bool recvTimingResp(PacketPtr pkt);
194 void recvReqRetry();
195 bool sendTiming(WalkerState * sendingState, PacketPtr pkt);
196
205
206
207 public:
208
209 void setTLB(TLB * _tlb)
210 {
211 tlb = _tlb;
212 }
213
214 using Params = RiscvPagetableWalkerParams;
215
217 ClockedObject(params), port(name() + ".port", this),
218 funcState(this, NULL, NULL, true), tlb(NULL), sys(params.system),
219 pma(params.pma_checker),
220 pmp(params.pmp),
221 requestorId(sys->getRequestorId(this)),
222 numSquashable(params.num_squash_per_cycle),
224 pagewalkerstats(this)
225 {
226 }
227 };
228
229} // namespace RiscvISA
230} // namespace gem5
231
232#endif // __ARCH_RISCV_PAGE_TABLE_WALKER_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
const std::string _name
Definition named.hh:41
virtual std::string name() const
Definition named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Ports are used to interface objects to each other.
Definition port.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition port.hh:136
Based on the RISC-V ISA privileged specifications V1.11, there is no implementation guidelines on the...
This class helps to implement RISCV's physical memory protection (pmp) primitive.
Definition pmp.hh:58
WalkerPort(const std::string &_name, Walker *_walker)
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Fault startFunctional(Addr &addr, unsigned &logBytes)
WalkerState(Walker *_walker, BaseMMU::Translation *_translation, const RequestPtr &_req, bool _isFunctional=false)
Fault startFunctional(ThreadContext *_tc, Addr &addr, unsigned &logBytes, BaseMMU::Mode mode)
EventFunctionWrapper startWalkWrapperEvent
Event used to call startWalkWrapper.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool sendTiming(WalkerState *sendingState, PacketPtr pkt)
gem5::RiscvISA::Walker::PagewalkerStats pagewalkerstats
bool recvTimingResp(PacketPtr pkt)
std::list< WalkerState * > currStates
Fault start(ThreadContext *_tc, BaseMMU::Translation *translation, const RequestPtr &req, BaseMMU::Mode mode)
RiscvPagetableWalkerParams Params
Walker(const Params &params)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition sim_object.cc:91
const Params & params() const
Bitfield< 15 > system
Definition misc.hh:1032
Bitfield< 7 > present
Definition misc.hh:1027
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
const PortID InvalidPortID
Definition types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint16_t RequestorID
Definition request.hh:95
Declaration of the Packet class.
PMP header file.
Declaration of Statistics objects.
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469
PagewalkerStats(statistics::Group *parent)

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0