gem5 v24.0.0.0
Loading...
Searching...
No Matches
tme64ruby.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020-2021 ARM Limited
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#include "arch/arm/faults.hh"
39#include "arch/arm/htm.hh"
42#include "debug/ArmTme.hh"
43#include "mem/packet_access.hh"
44#include "mem/request.hh"
45
46namespace gem5
47{
48
49using namespace ArmISA;
50
51namespace ArmISAInst {
52
54Tstart64::initiateAcc(ExecContext *xc,
55 trace::InstRecord *traceData) const
56{
57 Fault fault = NoFault;
58 const uint64_t htm_depth = xc->getHtmTransactionalDepth();
59
60 DPRINTF(ArmTme, "tme depth is %d\n", htm_depth);
61
62 // Maximum TME nesting depth exceeded
64 const uint64_t htm_uid = xc->getHtmTransactionUid();
65 fault = std::make_shared<GenericHtmFailureFault>(
67 }
68
69 if (fault == NoFault) {
70 Request::Flags memAccessFlags =
72
73 // Nested transaction start/stops never leave the core.
74 // These Requests are marked as NO_ACCESS to indicate that the request
75 // should not be sent to the cache controller.
76 if (htm_depth > 1) {
77 memAccessFlags = memAccessFlags | Request::NO_ACCESS;
78 }
79
80 fault = xc->initiateMemMgmtCmd(memAccessFlags);
81 }
82
83 return fault;
84}
85
87Tstart64::completeAcc(PacketPtr pkt, ExecContext *xc,
88 trace::InstRecord *traceData) const
89{
90 Fault fault = NoFault;
91 uint64_t Mem;
92 uint64_t Dest64 = 0;
93 ThreadContext *tc = xc->tcBase();
94 const uint64_t htm_depth = xc->getHtmTransactionalDepth();
95
96 getMemLE(pkt, Mem, traceData);
97
98 // sanity check
99 if (Mem != 0) {
100 fault = std::make_shared<IllegalInstSetStateFault>();
101 }
102
103 // sanity check
104 if (!xc->inHtmTransactionalState()) {
105 fault = std::make_shared<IllegalInstSetStateFault>();
106 }
107
108 if (fault == NoFault) {
109 Dest64 = 0x0; // tstart returns 0 on success
110
111 // checkpointing occurs in the outer transaction only
112 if (htm_depth == 1) {
113 BaseHTMCheckpointPtr& cpt = xc->tcBase()->getHtmCheckpointPtr();
114
115 HTMCheckpoint *armcpt =
116 dynamic_cast<HTMCheckpoint*>(cpt.get());
117 assert(armcpt != nullptr);
118
119 armcpt->save(tc);
120 armcpt->destinationRegister(dest);
121
122 tc->getIsaPtr()->globalClearExclusive();
123 }
124
125 xc->setRegOperand(this, 0, Dest64 & mask(intWidth));
126
127
128 uint64_t final_val = Dest64;
129 if (traceData) { traceData->setData(intRegClass, final_val); }
130 }
131
132 return fault;
133}
134
135Fault
136Ttest64::execute(ExecContext *xc, trace::InstRecord *traceData) const
137{
138 Fault fault = NoFault;
139 uint64_t Dest64 = 0;
140 const uint64_t htm_depth = xc->getHtmTransactionalDepth();
141
142 // sanity check
143 if (htm_depth > ArmISA::HTMCheckpoint::MAX_HTM_DEPTH) {
144 fault = std::make_shared<IllegalInstSetStateFault>();
145 }
146
147 Dest64 = htm_depth;
148
149
150 // sanity check
151 if (Dest64 == 0)
152 assert(!xc->inHtmTransactionalState());
153 else
154 assert(xc->inHtmTransactionalState());
155
156 if (fault == NoFault) {
157 uint64_t final_val = Dest64;
158 xc->setRegOperand(this, 0, Dest64 & mask(intWidth));
159 if (traceData) { traceData->setData(intRegClass, final_val); }
160 }
161
162 return fault;
163}
164
165Fault
166Tcancel64::initiateAcc(ExecContext *xc, trace::InstRecord *traceData) const
167{
168 Fault fault = NoFault;
169
170 // sanity check
171 if (!xc->inHtmTransactionalState()) {
172 fault = std::make_shared<IllegalInstSetStateFault>();
173 }
174
175 Request::Flags memAccessFlags =
177
178 fault = xc->initiateMemMgmtCmd(memAccessFlags);
179
180 return fault;
181}
182
183Fault
184Tcancel64::completeAcc(PacketPtr pkt, ExecContext *xc,
185 trace::InstRecord *traceData) const
186{
187 Fault fault = NoFault;
188 uint64_t Mem;
189
190 getMemLE(pkt, Mem, traceData);
191
192 // sanity check
193 if (Mem != 0) {
194 fault = std::make_shared<IllegalInstSetStateFault>();
195 }
196
197 if (fault == NoFault) {
198 auto tme_checkpoint = static_cast<HTMCheckpoint*>(
199 xc->tcBase()->getHtmCheckpointPtr().get());
200 tme_checkpoint->cancelReason(imm);
201
202 fault = std::make_shared<GenericHtmFailureFault>(
203 xc->getHtmTransactionUid(),
205 }
206
207 return fault;
208}
209
210Fault
211MicroTcommit64::initiateAcc(ExecContext *xc,
212 trace::InstRecord *traceData) const
213{
214 Fault fault = NoFault;
215 const uint64_t htm_depth = xc->getHtmTransactionalDepth();
216
217 // sanity check
218 if (!xc->inHtmTransactionalState()) {
219 fault = std::make_shared<IllegalInstSetStateFault>();
220 }
221
222 DPRINTF(ArmTme, "tme depth is %d\n", htm_depth);
223
224 Request::Flags memAccessFlags =
226
227 // Nested transaction start/stops never leave the core.
228 // These Requests are marked as NO_ACCESS to indicate that the request
229 // should not be sent to the cache controller.
230 if (htm_depth > 1) {
231 memAccessFlags = memAccessFlags | Request::NO_ACCESS;
232 }
233
234 fault = xc->initiateMemMgmtCmd(memAccessFlags);
235
236 return fault;
237}
238
239Fault
240MicroTcommit64::completeAcc(PacketPtr pkt, ExecContext *xc,
241 trace::InstRecord *traceData) const
242{
243 Fault fault = NoFault;
244 uint64_t Mem;
245 ThreadContext *tc = xc->tcBase();
246 const uint64_t htm_depth = xc->getHtmTransactionalDepth();
247
248 getMemLE(pkt, Mem, traceData);
249
250 // sanity check
251 if (Mem != 0) {
252 fault = std::make_shared<IllegalInstSetStateFault>();
253 }
254
255 if (fault == NoFault) {
256 if (htm_depth == 1) {
257 auto tme_checkpoint = static_cast<HTMCheckpoint*>(
258 xc->tcBase()->getHtmCheckpointPtr().get());
259
260 assert(tme_checkpoint);
261 assert(tme_checkpoint->valid());
262
263 tme_checkpoint->reset();
264 tc->getIsaPtr()->globalClearExclusive();
265 }
266 }
267
268 return fault;
269}
270
271} // namespace ArmISAInst
272} // namespace gem5
ISA-specific types for hardware transactional memory.
#define DPRINTF(x,...)
Definition trace.hh:210
Fault initiateAcc(ExecContext *, trace::InstRecord *) const
Fault completeAcc(PacketPtr, ExecContext *, trace::InstRecord *) const
Fault completeAcc(PacketPtr, ExecContext *, trace::InstRecord *) const
Fault initiateAcc(ExecContext *, trace::InstRecord *) const
Fault initiateAcc(ExecContext *, trace::InstRecord *) const
Fault completeAcc(PacketPtr, ExecContext *, trace::InstRecord *) const
Fault execute(ExecContext *, trace::InstRecord *) const
static const int MAX_HTM_DEPTH
Definition htm.hh:65
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
Definition request.hh:135
@ PHYSICAL
The virtual address is also the physical address.
Definition request.hh:117
@ HTM_COMMIT
The request commits a HTM transaction.
Definition request.hh:210
@ HTM_CANCEL
The request cancels a HTM transaction.
Definition request.hh:213
@ NO_ACCESS
The request should not cause a memory access.
Definition request.hh:146
@ HTM_START
hardware transactional memory
Definition request.hh:207
gem5::Flags< FlagsType > Flags
Definition request.hh:102
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
constexpr RegClass intRegClass
Definition int.hh:173
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
void getMemLE(PacketPtr pkt, MemT &mem, trace::InstRecord *traceData)
Definition memhelpers.hh:87
Packet * PacketPtr
std::unique_ptr< BaseHTMCheckpoint > BaseHTMCheckpointPtr
Definition htm.hh:127
constexpr decltype(nullptr) NoFault
Definition types.hh:253
Declaration of a request, the overall memory request consisting of the parts of the request that are ...

Generated on Tue Jun 18 2024 16:23:56 for gem5 by doxygen 1.11.0