gem5  v20.1.0.0
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/registers.hh"
43 #include "arch/locked_mem.hh"
44 #include "debug/ArmTme.hh"
45 #include "mem/packet_access.hh"
46 #include "mem/request.hh"
47 
48 using namespace ArmISA;
49 
50 namespace ArmISAInst {
51 
52 Fault
53 Tstart64::initiateAcc(ExecContext *xc,
54  Trace::InstRecord *traceData) const
55 {
56  Fault fault = NoFault;
57  const uint64_t htm_depth = xc->getHtmTransactionalDepth();
58 
59  DPRINTF(ArmTme, "tme depth is %d\n", htm_depth);
60 
61  // Maximum TME nesting depth exceeded
62  if (htm_depth > ArmISA::HTMCheckpoint::MAX_HTM_DEPTH) {
63  const uint64_t htm_uid = xc->getHtmTransactionUid();
64  fault = std::make_shared<GenericHtmFailureFault>(
66  }
67 
68  if (fault == NoFault) {
69  Request::Flags memAccessFlags =
71 
72  // Nested transaction start/stops never leave the core.
73  // These Requests are marked as NO_ACCESS to indicate that the request
74  // should not be sent to the cache controller.
75  if (htm_depth > 1) {
76  memAccessFlags = memAccessFlags | Request::NO_ACCESS;
77  }
78 
79  fault = xc->initiateHtmCmd(memAccessFlags);
80  }
81 
82  return fault;
83 }
84 
85 Fault
86 Tstart64::completeAcc(PacketPtr pkt, ExecContext *xc,
87  Trace::InstRecord *traceData) const
88 {
89  Fault fault = NoFault;
90  uint64_t Mem;
91  uint64_t Dest64 = 0;
92  ThreadContext *tc = xc->tcBase();
93  const uint64_t htm_depth = xc->getHtmTransactionalDepth();
94 
95  getMemLE(pkt, Mem, traceData);
96 
97  // sanity check
98  if (Mem != 0) {
99  fault = std::make_shared<IllegalInstSetStateFault>();
100  }
101 
102  // sanity check
103  if (!xc->inHtmTransactionalState()) {
104  fault = std::make_shared<IllegalInstSetStateFault>();
105  }
106 
107  if (fault == NoFault) {
108  Dest64 = 0x0; // tstart returns 0 on success
109 
110  // checkpointing occurs in the outer transaction only
111  if (htm_depth == 1) {
113 
114  HTMCheckpoint *armcpt =
115  dynamic_cast<HTMCheckpoint*>(cpt.get());
116  assert(armcpt != nullptr);
117 
118  armcpt->save(tc);
119  armcpt->destinationRegister(dest);
120 
122  }
123 
124  xc->setIntRegOperand(this, 0, (Dest64) & mask(intWidth));
125 
126 
127  uint64_t final_val = Dest64;
128  if (traceData) { traceData->setData(final_val); }
129  }
130 
131  return fault;
132 }
133 
134 Fault
135 Ttest64::execute(ExecContext *xc, Trace::InstRecord *traceData) const
136 {
137  Fault fault = NoFault;
138  uint64_t Dest64 = 0;
139  const uint64_t htm_depth = xc->getHtmTransactionalDepth();
140 
141  // sanity check
142  if (htm_depth > ArmISA::HTMCheckpoint::MAX_HTM_DEPTH) {
143  fault = std::make_shared<IllegalInstSetStateFault>();
144  }
145 
146  Dest64 = htm_depth;
147 
148 
149  // sanity check
150  if (Dest64 == 0)
151  assert(!xc->inHtmTransactionalState());
152  else
153  assert(xc->inHtmTransactionalState());
154 
155  if (fault == NoFault) {
156  uint64_t final_val = Dest64;
157  xc->setIntRegOperand(this, 0, (Dest64) & mask(intWidth));
158  if (traceData) { traceData->setData(final_val); }
159  }
160 
161  return fault;
162 }
163 
164 Fault
165 Tcancel64::initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const
166 {
167  Fault fault = NoFault;
168 
169  // sanity check
170  if (!xc->inHtmTransactionalState()) {
171  fault = std::make_shared<IllegalInstSetStateFault>();
172  }
173 
174  Request::Flags memAccessFlags =
176 
177  fault = xc->initiateHtmCmd(memAccessFlags);
178 
179  return fault;
180 }
181 
182 Fault
183 Tcancel64::completeAcc(PacketPtr pkt, ExecContext *xc,
184  Trace::InstRecord *traceData) const
185 {
186  Fault fault = NoFault;
187  uint64_t Mem;
188 
189  getMemLE(pkt, Mem, traceData);
190 
191  // sanity check
192  if (Mem != 0) {
193  fault = std::make_shared<IllegalInstSetStateFault>();
194  }
195 
196  if (fault == NoFault) {
197  auto tme_checkpoint = static_cast<HTMCheckpoint*>(
198  xc->tcBase()->getHtmCheckpointPtr().get());
199  tme_checkpoint->cancelReason(imm);
200 
201  fault = std::make_shared<GenericHtmFailureFault>(
202  xc->getHtmTransactionUid(),
204  }
205 
206  return fault;
207 }
208 
209 Fault
210 MicroTcommit64::initiateAcc(ExecContext *xc,
211  Trace::InstRecord *traceData) const
212 {
213  Fault fault = NoFault;
214  const uint64_t htm_depth = xc->getHtmTransactionalDepth();
215 
216  // sanity check
217  if (!xc->inHtmTransactionalState()) {
218  fault = std::make_shared<IllegalInstSetStateFault>();
219  }
220 
221  DPRINTF(ArmTme, "tme depth is %d\n", htm_depth);
222 
223  Request::Flags memAccessFlags =
225 
226  // Nested transaction start/stops never leave the core.
227  // These Requests are marked as NO_ACCESS to indicate that the request
228  // should not be sent to the cache controller.
229  if (htm_depth > 1) {
230  memAccessFlags = memAccessFlags | Request::NO_ACCESS;
231  }
232 
233  fault = xc->initiateHtmCmd(memAccessFlags);
234 
235  return fault;
236 }
237 
238 Fault
239 MicroTcommit64::completeAcc(PacketPtr pkt, ExecContext *xc,
240  Trace::InstRecord *traceData) const
241 {
242  Fault fault = NoFault;
243  uint64_t Mem;
244  ThreadContext *tc = xc->tcBase();
245  const uint64_t htm_depth = xc->getHtmTransactionalDepth();
246 
247  getMemLE(pkt, Mem, traceData);
248 
249  // sanity check
250  if (Mem != 0) {
251  fault = std::make_shared<IllegalInstSetStateFault>();
252  }
253 
254  if (fault == NoFault) {
255  if (htm_depth == 1) {
256  auto tme_checkpoint = static_cast<HTMCheckpoint*>(
257  xc->tcBase()->getHtmCheckpointPtr().get());
258 
259  assert(tme_checkpoint);
260  assert(tme_checkpoint->valid());
261 
262  tme_checkpoint->reset();
264  }
265  }
266 
267  return fault;
268 }
269 
270 } // namespace
Request::HTM_CANCEL
@ HTM_CANCEL
The request cancels a HTM transaction.
Definition: request.hh:200
memhelpers.hh
ArmISA::HTMCheckpoint::MAX_HTM_DEPTH
const static int MAX_HTM_DEPTH
Definition: htm.hh:61
ArmISA::HTMCheckpoint::save
void save(ThreadContext *tc) override
Every ISA implementing HTM support should override the save method.
Definition: htm.cc:66
Flags< FlagsType >
Request::NO_ACCESS
@ NO_ACCESS
The request should not cause a memory access.
Definition: request.hh:135
ExecContext::inHtmTransactionalState
virtual bool inHtmTransactionalState() const =0
Trace::InstRecord
Definition: insttracer.hh:55
ArmISA::HTMCheckpoint
Definition: htm.hh:54
tme64.hh
Request::HTM_START
@ HTM_START
hardware transactional memory
Definition: request.hh:194
ArmISA
Definition: ccregs.hh:41
request.hh
ArmISA::HTMCheckpoint::cancelReason
void cancelReason(uint16_t reason)
Definition: htm.hh:68
Request::STRICT_ORDER
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
Definition: request.hh:124
htm.hh
Request::PHYSICAL
@ PHYSICAL
The virtual address is also the physical address.
Definition: request.hh:106
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
ArmISA::imm
Bitfield< 7, 0 > imm
Definition: types.hh:141
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
HtmFailureFaultCause::EXPLICIT
@ EXPLICIT
ArmISAInst
Definition: tme64.cc:45
ExecContext
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:70
ArmISA::HTMCheckpoint::destinationRegister
void destinationRegister(RegIndex dest)
Definition: htm.hh:67
ArmISA::globalClearExclusive
void globalClearExclusive(XC *xc)
Definition: locked_mem.hh:150
Trace::InstRecord::setData
void setData(std::array< T, N > d)
Definition: insttracer.hh:183
faults.hh
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
BaseHTMCheckpointPtr
std::unique_ptr< BaseHTMCheckpoint > BaseHTMCheckpointPtr
Definition: htm.hh:122
packet_access.hh
Request::HTM_COMMIT
@ HTM_COMMIT
The request commits a HTM transaction.
Definition: request.hh:197
HtmFailureFaultCause::NEST
@ NEST
ExecContext::tcBase
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
getMemLE
void getMemLE(PacketPtr pkt, MemT &mem, Trace::InstRecord *traceData)
Definition: memhelpers.hh:73
registers.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
ExecContext::getHtmTransactionUid
virtual uint64_t getHtmTransactionUid() const =0
ExecContext::getHtmTransactionalDepth
virtual uint64_t getHtmTransactionalDepth() const =0
ExecContext::setIntRegOperand
virtual void setIntRegOperand(const StaticInst *si, int idx, RegVal val)=0
Sets an integer register to a value.
ThreadContext::getHtmCheckpointPtr
virtual BaseHTMCheckpointPtr & getHtmCheckpointPtr()=0
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711
ExecContext::initiateHtmCmd
virtual Fault initiateHtmCmd(Request::Flags flags)=0
Initiate an HTM command, e.g.

Generated on Wed Sep 30 2020 14:02:00 for gem5 by doxygen 1.8.17