gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
pagetable_walker.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Advanced Micro Devices, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef __DEV_AMDGPU_PAGETABLE_WALKER_HH__
33#define __DEV_AMDGPU_PAGETABLE_WALKER_HH__
34
35#include <vector>
36
40#include "base/types.hh"
41#include "debug/GPUPTWalker.hh"
42#include "mem/packet.hh"
43#include "params/VegaPagetableWalker.hh"
44#include "sim/clocked_object.hh"
45#include "sim/system.hh"
46
47namespace gem5
48{
49
50class ThreadContext;
51
52namespace VegaISA
53{
54
55class Walker : public ClockedObject
56{
57 protected:
58
60
61 // Port for accessing memory
62 class WalkerPort : public RequestPort
63 {
64 public:
65 WalkerPort(const std::string &_name, Walker * _walker) :
66 RequestPort(_name), walker(_walker)
67 {}
68
69 protected:
71
72 bool recvTimingResp(PacketPtr pkt);
73 void recvReqRetry();
74 };
75
76 friend class WalkerPort;
78
79 // State to track each walk of the page table
81 {
82 friend class Walker;
83
84 private:
91
92 protected:
98 VegaTlbEntry entry;
104 bool timing;
107
108 public:
109 WalkerState(Walker *_walker, PacketPtr pkt, bool is_functional = false)
110 : walker(_walker), state(Ready), nextState(Ready), dataSize(8),
111 enableNX(true), retrying(false), started(false), tlbPkt(pkt),
113 {
114 DPRINTF(GPUPTWalker, "Walker::WalkerState %p %p %d\n",
115 this, walker, state);
116 }
117
119 bool is_functional = false);
120 void startWalk();
122 unsigned &logBytes);
123
124 bool isRetrying();
125 void retry();
126 std::string name() const { return walker->name(); }
127 Walker* getWalker() const { return walker; }
128
129 private:
130 Fault stepWalk();
132 void walkStateMachine(PageTableEntry &pte, Addr &nextRead,
133 bool &doEndWalk, Fault &fault);
134 void sendPackets();
135 void endWalk();
136 Fault pageFault(bool present);
137 uint64_t offsetFunc(Addr logicalAddr, int top, int lsb);
138 };
139
140 friend class WalkerState;
141 // State for timing and atomic accesses (need multiple per walker in
142 // the case of multiple outstanding requests in timing mode)
144 // State for functional accesses (only need one of these per walker)
146
148 {
151 senderWalk(_senderWalk) {}
152 };
153
154 public:
155 // Kick off the state machine.
158 unsigned &logBytes, BaseMMU::Mode mode);
159 Fault startFunctional(Addr base, Addr &addr, unsigned &logBytes,
160 BaseMMU::Mode mode, bool &isSystem);
161
162 Port &getPort(const std::string &if_name,
163 PortID idx=InvalidPortID) override;
164
165 Addr getBaseAddr() const { return baseAddr; }
167
170
171 void invalidatePWC();
172
173 protected:
175 // The TLB we're supposed to load.
178
179 // Base address set by MAP_PROCESS packet
182
183 // Functions for dealing with packets.
184 void recvTimingResp(PacketPtr pkt);
185 void recvReqRetry();
186 bool sendTiming(WalkerState * sendingState, PacketPtr pkt);
187
188 void walkerResponse(WalkerState *state, VegaTlbEntry& entry,
189 PacketPtr pkt);
190
191 // System pointer for functional accesses
193
194 public:
195 void setTLB(GpuTLB * _tlb)
196 {
197 assert(tlb == nullptr); // only set it once
198 tlb = _tlb;
199 }
200
201 Walker(const VegaPagetableWalkerParams &p)
202 : ClockedObject(p),
203 pwc(name()+".pwc", p.page_walk_cache_entries,
204 p.page_walk_cache_entries, p.pwc_replacement_policy,
205 p.pwc_indexing_policy),
206 port(name() + ".port", this),
207 funcState(this, nullptr, true),
208 enable_pwc(p.enable_pwc), tlb(nullptr),
209 requestorId(p.system->getRequestorId(this)),
211 {
212 DPRINTF(GPUPTWalker, "Walker::Walker %p\n", this);
213 }
214};
215
216} // namespace VegaISA
217} // namespace gem5
218
219#endif // __DEV_AMDGPU_PAGETABLE_WALKER_HH__
#define DPRINTF(x,...)
Definition trace.hh:209
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
ClockedObject(const ClockedObjectParams &p)
const std::string _name
Definition named.hh:54
virtual std::string name() const
Definition named.hh:60
Ports are used to interface objects to each other.
Definition port.hh:62
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition port.cc:125
ThreadContext is the external interface to all thread state for anything outside of the CPU.
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
WalkerPort(const std::string &_name, Walker *_walker)
Fault startFunctional(Addr base, Addr vaddr, PageTableEntry &pte, unsigned &logBytes)
uint64_t offsetFunc(Addr logicalAddr, int top, int lsb)
void walkStateMachine(PageTableEntry &pte, Addr &nextRead, bool &doEndWalk, Fault &fault)
void sendPackets()
Port related methods.
WalkerState(Walker *_walker, PacketPtr pkt, bool is_functional=false)
void setDevRequestor(RequestorID mid)
void recvTimingResp(PacketPtr pkt)
void walkerResponse(WalkerState *state, VegaTlbEntry &entry, PacketPtr pkt)
void setTLB(GpuTLB *_tlb)
Walker(const VegaPagetableWalkerParams &p)
bool sendTiming(WalkerState *sendingState, PacketPtr pkt)
Fault startFunctional(Addr base, Addr vaddr, PageTableEntry &pte, unsigned &logBytes, BaseMMU::Mode mode)
RequestorID getDevRequestor() const
std::list< WalkerState * > currStates
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
gem5 methods
void startTiming(PacketPtr pkt, Addr base, Addr vaddr, BaseMMU::Mode mode)
STL list class.
Definition stl.hh:51
Definition test.h:63
ClockedObject declaration and implementation.
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition sim_object.cc:91
Bitfield< 4, 0 > mode
Definition misc_types.hh:74
Bitfield< 19, 16 > ta
classes that represnt vector/scalar operands in VEGA ISA.
Definition faults.cc:39
Bitfield< 54 > p
Definition pagetable.hh:70
Bitfield< 7 > present
Definition misc.hh:1027
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
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
Packet * PacketPtr
Declaration of the Packet class.
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469

Generated on Mon May 26 2025 09:19:06 for gem5 by doxygen 1.13.2