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 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef __ARCH_X86_PAGE_TABLE_WALKER_HH__
39#define __ARCH_X86_PAGE_TABLE_WALKER_HH__
40
41#include <vector>
42
43#include "arch/generic/mmu.hh"
44#include "arch/x86/pagetable.hh"
45#include "arch/x86/tlb.hh"
46#include "base/types.hh"
47#include "mem/packet.hh"
48#include "params/X86PagetableWalker.hh"
49#include "sim/clocked_object.hh"
50#include "sim/faults.hh"
51#include "sim/system.hh"
52
53namespace gem5
54{
55
56class ThreadContext;
57
58namespace X86ISA
59{
60 class Walker : public ClockedObject
61 {
62 protected:
63 // Port for accessing memory
64 class WalkerPort : public RequestPort
65 {
66 public:
67 WalkerPort(const std::string &_name, Walker * _walker) :
68 RequestPort(_name), walker(_walker)
69 {}
70
71 protected:
73
74 bool recvTimingResp(PacketPtr pkt);
75 void recvReqRetry();
76 };
77
78 friend class WalkerPort;
80
81 // State to track each walk of the page table
83 {
84 friend class Walker;
85 private:
86 enum State
87 {
90 // Long mode
92 // PAE legacy mode
94 // Non PAE legacy mode with and without PSE
96 };
97
98 protected:
106 unsigned inflight;
114 bool timing;
118 public:
119 WalkerState(Walker * _walker, BaseMMU::Translation *_translation,
120 const RequestPtr &_req, bool _isFunctional = false) :
121 walker(_walker), req(_req), state(Ready),
123 translation(_translation),
124 functional(_isFunctional), timing(false),
125 retrying(false), started(false), squashed(false)
126 {
127 }
128 void initState(ThreadContext * _tc, BaseMMU::Mode _mode,
129 bool _isTiming = false);
131 Fault startFunctional(Addr &addr, unsigned &logBytes);
132 bool recvPacket(PacketPtr pkt);
133 unsigned numInflight() const;
134 bool isRetrying();
135 bool wasStarted();
136 bool isTiming();
137 void retry();
138 void squash();
139 std::string name() const {return walker->name();}
140
141 private:
142 void setupWalk(Addr vaddr);
143 Fault stepWalk(PacketPtr &write);
144 void sendPackets();
145 void endWalk();
146 Fault pageFault(bool present);
147 };
148
149 friend class WalkerState;
150 // State for timing and atomic accesses (need multiple per walker in
151 // the case of multiple outstanding requests in timing mode)
153 // State for functional accesses (only need one of these per walker)
155
157 {
160 senderWalk(_senderWalk) {}
161 };
162
163 public:
164 // Kick off the state machine.
165 Fault start(ThreadContext * _tc, BaseMMU::Translation *translation,
166 const RequestPtr &req, BaseMMU::Mode mode);
168 unsigned &logBytes, BaseMMU::Mode mode);
169 Port &getPort(const std::string &if_name,
170 PortID idx=InvalidPortID) override;
171
172 protected:
173 // The TLB we're supposed to load.
177
178 // The number of outstanding walks that can be squashed per cycle.
180
181 // Wrapper for checking for squashes before starting a translation.
182 void startWalkWrapper();
183
188
189 // Functions for dealing with packets.
190 bool recvTimingResp(PacketPtr pkt);
191 void recvReqRetry();
192 bool sendTiming(WalkerState * sendingState, PacketPtr pkt);
193
194 public:
195
196 void setTLB(TLB * _tlb)
197 {
198 tlb = _tlb;
199 }
200
201 using Params = X86PagetableWalkerParams;
202
204 ClockedObject(params), port(name() + ".port", this),
205 funcState(this, NULL, NULL, true), tlb(NULL), sys(params.system),
206 requestorId(sys->getRequestorId(this)),
207 numSquashable(params.num_squash_per_cycle),
209 {
210 }
211 };
212
213} // namespace X86ISA
214} // namespace gem5
215
216#endif // __ARCH_X86_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
ThreadContext is the external interface to all thread state for anything outside of the CPU.
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)
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool recvTimingResp(PacketPtr pkt)
bool sendTiming(WalkerState *sendingState, PacketPtr pkt)
Fault start(ThreadContext *_tc, BaseMMU::Translation *translation, const RequestPtr &req, BaseMMU::Mode mode)
EventFunctionWrapper startWalkWrapperEvent
Event used to call startWalkWrapper.
Walker(const Params &params)
std::list< WalkerState * > currStates
Fault startFunctional(ThreadContext *_tc, Addr &addr, unsigned &logBytes, BaseMMU::Mode mode)
X86PagetableWalkerParams Params
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
Bitfield< 3 > mode
Definition types.hh:192
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.
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469
WalkerSenderState(WalkerState *_senderWalk)

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