gem5 v24.0.0.0
Loading...
Searching...
No Matches
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"
47#include "mem/htm.hh"
48#include "sim/stats.hh"
49
50namespace gem5
51{
52
53class ThreadContext;
54
55typedef const char *FaultName;
57
59{
60 public:
61 virtual FaultName name() const = 0;
62 virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst=
64 virtual ~FaultBase() {};
65};
66
67class UnimpFault : public FaultBase
68{
69 private:
70 std::string panicStr;
71 public:
72 UnimpFault(std::string _str) : panicStr(_str) {}
73
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.
85{
86 const char *name() const override { return "syscall_fault"; }
87
88 void invoke(ThreadContext *tc, const StaticInstPtr &inst=
89 nullStaticInstPtr) override;
90};
91
92class 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__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
virtual FaultName name() const =0
virtual ~FaultBase()
Definition faults.hh:64
virtual void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition faults.cc:58
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:108
FaultName name() const override
Definition faults.hh:133
Addr getFaultVAddr() const
Definition faults.hh:137
FaultName name() const override
Definition faults.hh:151
GenericHtmFailureFault(uint64_t htm_uid, HtmFailureFaultCause _cause)
Definition faults.hh:147
HtmFailureFaultCause getHtmFailureFaultCause() const
Definition faults.hh:154
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:114
HtmFailureFaultCause cause
Definition faults.hh:144
uint64_t getHtmUid() const
Definition faults.hh:153
FaultName name() const override
Definition faults.hh:121
Addr getFaultVAddr() const
Definition faults.hh:125
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:95
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:83
virtual FaultName name() const override
Definition faults.hh:95
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:72
const char * name() const override
Definition faults.hh:86
FaultName name() const override
Definition faults.hh:110
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:89
ThreadContext is the external interface to all thread state for anything outside of the CPU.
FaultName name() const override
Definition faults.hh:75
UnimpFault(std::string _str)
Definition faults.hh:72
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition faults.cc:66
std::string panicStr
Definition faults.hh:70
This is a simple scalar statistic, like a counter.
Bitfield< 8 > va
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
const char * FaultName
Definition faults.hh:55
statistics::Scalar FaultStat
Definition faults.hh:56
const StaticInstPtr nullStaticInstPtr
Statically allocated null StaticInstPtr.
HtmFailureFaultCause
Definition htm.hh:48

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