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

Generated on Tue Sep 7 2021 14:53:41 for gem5 by doxygen 1.8.17