gem5  v22.1.0.0
pseudo.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014,2016-2018 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  * Copyright (c) 2007-2008 The Florida State University
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #include "arch/arm/insts/pseudo.hh"
42 
43 #include "cpu/exec_context.hh"
44 
45 namespace gem5
46 {
47 
48 using namespace ArmISA;
49 
51  : ArmStaticInst("gem5decoderFault", _machInst, No_OpClass),
52  faultId(static_cast<DecoderFault>(
53  static_cast<uint8_t>(_machInst.decoderFault)))
54 {
55  // Don't call execute() if we're on a speculative path and the
56  // fault is an internal panic fault.
57  flags[IsNonSpeculative] = (faultId == DecoderFault::PANIC);
58 }
59 
60 Fault
62 {
63  const Addr pc = xc->pcState().instAddr();
64 
65  switch (faultId) {
67  if (machInst.aarch64) {
68  return std::make_shared<PCAlignmentFault>(pc);
69  } else {
70  // TODO: We should check if we the receiving end is in
71  // aarch64 mode and raise a PCAlignment fault instead.
72  return std::make_shared<PrefetchAbort>(
74  }
75 
77  panic("Internal error in instruction decoder\n");
78 
79  case DecoderFault::OK:
80  panic("Decoder fault instruction without decoder fault.\n");
81  }
82 
83  panic("Unhandled fault type");
84 }
85 
86 const char *
88 {
89  switch (faultId) {
90  case DecoderFault::OK:
91  return "OK";
92 
94  return "UnalignedInstruction";
95 
97  return "DecoderPanic";
98  }
99 
100  panic("Unhandled fault type");
101 }
102 
103 std::string
105  Addr pc, const loader::SymbolTable *symtab) const
106 {
107  return csprintf("gem5fault %s", faultName());
108 }
109 
110 
111 
112 FailUnimplemented::FailUnimplemented(const char *_mnemonic,
113  ExtMachInst _machInst)
114  : ArmStaticInst(_mnemonic, _machInst, No_OpClass)
115 {
116  // don't call execute() (which panics) if we're on a
117  // speculative path
118  flags[IsNonSpeculative] = true;
119 }
120 
121 FailUnimplemented::FailUnimplemented(const char *_mnemonic,
122  ExtMachInst _machInst,
123  const std::string& _fullMnemonic)
124  : ArmStaticInst(_mnemonic, _machInst, No_OpClass),
125  fullMnemonic(_fullMnemonic)
126 {
127  // don't call execute() (which panics) if we're on a
128  // speculative path
129  flags[IsNonSpeculative] = true;
130 }
131 
132 Fault
134 {
135  return std::make_shared<UndefinedInstruction>(machInst, false, mnemonic);
136 }
137 
138 std::string
140  Addr pc, const loader::SymbolTable *symtab) const
141 {
142  return csprintf("%-10s (unimplemented)",
143  fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
144 }
145 
146 
147 
148 WarnUnimplemented::WarnUnimplemented(const char *_mnemonic,
149  ExtMachInst _machInst)
150  : ArmStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
151 {
152  // don't call execute() (which panics) if we're on a
153  // speculative path
154  flags[IsNonSpeculative] = true;
155 }
156 
157 WarnUnimplemented::WarnUnimplemented(const char *_mnemonic,
158  ExtMachInst _machInst,
159  const std::string& _fullMnemonic)
160  : ArmStaticInst(_mnemonic, _machInst, No_OpClass), warned(false),
161  fullMnemonic(_fullMnemonic)
162 {
163  // don't call execute() (which panics) if we're on a
164  // speculative path
165  flags[IsNonSpeculative] = true;
166 }
167 
168 Fault
170 {
171  if (!warned) {
172  warn("\tinstruction '%s' unimplemented\n",
173  fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
174  warned = true;
175  }
176 
177  return NoFault;
178 }
179 
180 std::string
182  Addr pc, const loader::SymbolTable *symtab) const
183 {
184  return csprintf("%-10s (unimplemented)",
185  fullMnemonic.size() ? fullMnemonic.c_str() : mnemonic);
186 }
187 
189  : ArmStaticInst("Illegal Execution", _machInst, No_OpClass)
190 {}
191 
192 Fault
194 {
195  return std::make_shared<IllegalInstSetStateFault>();
196 }
197 
199  : ArmStaticInst("DebugStep", _machInst, No_OpClass)
200 { }
201 
202 Fault
204 {
205  PCState pc_state = xc->pcState().as<PCState>();
206  pc_state.debugStep(false);
207  xc->pcState(pc_state);
208 
210 
211  bool ldx = sd->getSstep()->getLdx();
212 
213  return std::make_shared<SoftwareStepFault>(machInst, ldx,
214  pc_state.stepped());
215 }
216 
217 } // namespace gem5
SelfDebug * getSelfDebug() const
Definition: isa.hh:181
DebugStep(ArmISA::ExtMachInst _machInst)
Definition: pseudo.cc:198
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition: pseudo.cc:203
DecoderFaultInst(ArmISA::ExtMachInst _machInst)
Definition: pseudo.cc:50
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition: pseudo.cc:61
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: pseudo.cc:104
const char * faultName() const
Definition: pseudo.cc:87
ArmISA::DecoderFault faultId
Definition: pseudo.hh:52
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:72
virtual const PCStateBase & pcState() const =0
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
std::string fullMnemonic
Full mnemonic for MRC and MCR instructions including the coproc.
Definition: pseudo.hh:78
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: pseudo.cc:139
FailUnimplemented(const char *_mnemonic, ArmISA::ExtMachInst _machInst)
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition: pseudo.cc:133
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition: pseudo.cc:193
IllegalExecInst(ArmISA::ExtMachInst _machInst)
Definition: pseudo.cc:188
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
Definition: pcstate.hh:107
Target & as()
Definition: pcstate.hh:72
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:259
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition: static_inst.hh:103
std::string fullMnemonic
Full mnemonic for MRC and MCR instructions including the coproc.
Definition: pseudo.hh:108
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: pseudo.cc:181
WarnUnimplemented(const char *_mnemonic, ArmISA::ExtMachInst _machInst)
bool warned
Have we warned on this instruction yet?
Definition: pseudo.hh:105
Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override
Definition: pseudo.cc:169
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
#define warn(...)
Definition: logging.hh:246
DecoderFault
Instruction decoder fault codes in ExtMachInst.
Definition: types.hh:357
@ UNALIGNED
Unaligned instruction fault.
Definition: types.hh:359
@ OK
No fault.
Definition: types.hh:358
@ PANIC
Internal gem5 error.
Definition: types.hh:361
Bitfield< 4 > sd
Definition: misc_types.hh:833
Bitfield< 4 > pc
uint64_t ExtMachInst
Definition: types.hh:43
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
constexpr decltype(nullptr) NoFault
Definition: types.hh:253

Generated on Wed Dec 21 2022 10:22:26 for gem5 by doxygen 1.9.1