gem5  v21.1.0.2
faults.hh
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  * Copyright (c) 2003-2005 The Regents of The University of Michigan
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 #ifndef __FAULTS_HH__
42 #define __FAULTS_HH__
43 
44 #include "base/types.hh"
45 #include "cpu/null_static_inst.hh"
46 #include "cpu/static_inst.hh"
47 #include "mem/htm.hh"
48 #include "sim/stats.hh"
49 
50 namespace gem5
51 {
52 
54 
55 typedef const char *FaultName;
57 
58 class FaultBase
59 {
60  public:
61  virtual FaultName name() const = 0;
62  virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst=
64  virtual ~FaultBase() {};
65 };
66 
67 class UnimpFault : public FaultBase
68 {
69  private:
70  std::string panicStr;
71  public:
72  UnimpFault(std::string _str) : panicStr(_str) {}
73 
74  FaultName
75  name() const override
76  {
77  return "Unimplemented simulator feature";
78  }
79  void invoke(ThreadContext *tc, const StaticInstPtr &inst =
80  nullStaticInstPtr) override;
81 };
82 
83 // A fault to trigger a system call in SE mode.
84 class SESyscallFault : public FaultBase
85 {
86  const char *name() const override { return "syscall_fault"; }
87 
88  void invoke(ThreadContext *tc, const StaticInstPtr &inst=
89  nullStaticInstPtr) override;
90 };
91 
92 class ReExec : public FaultBase
93 {
94  public:
95  virtual FaultName name() const override { return "Re-execution fault"; }
96  void invoke(ThreadContext *tc, const StaticInstPtr &inst=
97  nullStaticInstPtr) override;
98 };
99 
100 /*
101  * This class is needed to allow system call retries to occur for blocking
102  * system calls in SE mode. A retry fault will be generated by the system call
103  * emulation code if blocking conditions arise; the fault is passed up the
104  * function call chain into the CPU model where it is handled by retrying the
105  * syscall instruction on a later tick.
106  */
108 {
109  public:
110  FaultName name() const override { return "System call retry fault"; }
112  void invoke(ThreadContext *tc, const StaticInstPtr &inst=
113  nullStaticInstPtr) override;
114 };
115 
117 {
118  private:
120  public:
121  FaultName name() const override { return "Generic page table fault"; }
123  void invoke(ThreadContext *tc, const StaticInstPtr &inst=
124  nullStaticInstPtr) override;
125  Addr getFaultVAddr() const { return vaddr; }
126 };
127 
129 {
130  private:
132  public:
133  FaultName name() const override { return "Generic alignment fault"; }
135  void invoke(ThreadContext *tc, const StaticInstPtr &inst=
136  nullStaticInstPtr) override;
137  Addr getFaultVAddr() const { return vaddr; }
138 };
139 
141 {
142  protected:
143  uint64_t htmUid; // unique identifier used for debugging
145 
146  public:
148  : htmUid(htm_uid), cause(_cause)
149  {}
150 
151  FaultName name() const override { return "Generic HTM failure fault"; }
152 
153  uint64_t getHtmUid() const { return htmUid; }
155  void invoke(ThreadContext *tc, const StaticInstPtr &inst =
156  nullStaticInstPtr) override;
157 };
158 
159 } // namespace gem5
160 
161 #endif // __FAULTS_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::GenericHtmFailureFault
Definition: faults.hh:140
gem5::HtmFailureFaultCause
HtmFailureFaultCause
Definition: htm.hh:47
gem5::GenericPageTableFault::getFaultVAddr
Addr getFaultVAddr() const
Definition: faults.hh:125
gem5::GenericAlignmentFault::vaddr
Addr vaddr
Definition: faults.hh:131
htm.hh
gem5::UnimpFault::name
FaultName name() const override
Definition: faults.hh:75
gem5::SyscallRetryFault::SyscallRetryFault
SyscallRetryFault()
Definition: faults.hh:111
gem5::ReExec::name
virtual FaultName name() const override
Definition: faults.hh:95
gem5::GenericPageTableFault::name
FaultName name() const override
Definition: faults.hh:121
gem5::FaultBase::name
virtual FaultName name() const =0
gem5::GenericPageTableFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:95
gem5::RefCountingPtr< StaticInst >
gem5::SyscallRetryFault
Definition: faults.hh:107
gem5::UnimpFault
Definition: faults.hh:67
stats.hh
gem5::GenericPageTableFault
Definition: faults.hh:116
gem5::nullStaticInstPtr
const StaticInstPtr nullStaticInstPtr
Statically allocated null StaticInstPtr.
Definition: null_static_inst.cc:36
gem5::GenericHtmFailureFault::cause
HtmFailureFaultCause cause
Definition: faults.hh:144
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:93
gem5::GenericHtmFailureFault::getHtmUid
uint64_t getHtmUid() const
Definition: faults.hh:153
gem5::GenericHtmFailureFault::getHtmFailureFaultCause
HtmFailureFaultCause getHtmFailureFaultCause() const
Definition: faults.hh:154
gem5::GenericHtmFailureFault::name
FaultName name() const override
Definition: faults.hh:151
gem5::GenericAlignmentFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:108
gem5::ReExec
Definition: faults.hh:92
gem5::UnimpFault::panicStr
std::string panicStr
Definition: faults.hh:70
gem5::UnimpFault::UnimpFault
UnimpFault(std::string _str)
Definition: faults.hh:72
gem5::UnimpFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:67
gem5::GenericAlignmentFault
Definition: faults.hh:128
static_inst.hh
gem5::SyscallRetryFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:89
gem5::GenericAlignmentFault::GenericAlignmentFault
GenericAlignmentFault(Addr va)
Definition: faults.hh:134
gem5::GenericAlignmentFault::name
FaultName name() const override
Definition: faults.hh:133
null_static_inst.hh
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ArmISA::va
Bitfield< 8 > va
Definition: misc_types.hh:275
gem5::FaultBase::invoke
virtual void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:59
gem5::FaultName
const typedef char * FaultName
Definition: faults.hh:53
gem5::GenericPageTableFault::GenericPageTableFault
GenericPageTableFault(Addr va)
Definition: faults.hh:122
gem5::SESyscallFault::name
const char * name() const override
Definition: faults.hh:86
gem5::SESyscallFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:73
gem5::GenericHtmFailureFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:114
gem5::FaultBase
Definition: faults.hh:58
types.hh
gem5::ReExec::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:83
gem5::FaultBase::~FaultBase
virtual ~FaultBase()
Definition: faults.hh:64
gem5::SESyscallFault
Definition: faults.hh:84
gem5::GenericHtmFailureFault::htmUid
uint64_t htmUid
Definition: faults.hh:143
gem5::GenericPageTableFault::vaddr
Addr vaddr
Definition: faults.hh:119
gem5::SyscallRetryFault::name
FaultName name() const override
Definition: faults.hh:110
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::GenericAlignmentFault::getFaultVAddr
Addr getFaultVAddr() const
Definition: faults.hh:137
gem5::FaultStat
statistics::Scalar FaultStat
Definition: faults.hh:56
gem5::GenericHtmFailureFault::GenericHtmFailureFault
GenericHtmFailureFault(uint64_t htm_uid, HtmFailureFaultCause _cause)
Definition: faults.hh:147

Generated on Tue Sep 21 2021 12:24:31 for gem5 by doxygen 1.8.17