gem5  v22.1.0.0
faults.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  * 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 #include "sim/faults.hh"
42 
43 #include <csignal>
44 
45 #include "arch/generic/decoder.hh"
46 #include "base/logging.hh"
47 #include "cpu/base.hh"
48 #include "cpu/thread_context.hh"
49 #include "debug/Faults.hh"
50 #include "mem/page_table.hh"
51 #include "sim/full_system.hh"
52 #include "sim/process.hh"
53 
54 namespace gem5
55 {
56 
57 void
59 {
60  panic_if(!FullSystem, "fault (%s) detected @ PC %s",
61  name(), tc->pcState());
62  DPRINTF(Faults, "Fault %s at PC: %s\n", name(), tc->pcState());
63 }
64 
65 void
67 {
68  panic("Unimpfault: %s", panicStr.c_str());
69 }
70 
71 void
73 {
74  // Move the PC forward since that doesn't happen automatically.
75  std::unique_ptr<PCStateBase> pc(tc->pcState().clone());
76  inst->advancePC(*pc);
77  tc->pcState(*pc);
78 
79  tc->getSystemPtr()->workload->syscall(tc);
80 }
81 
82 void
84 {
85  tc->pcState(tc->pcState());
86 }
87 
88 void
90 {
91  tc->pcState(tc->pcState());
92 }
93 
94 void
96 {
97  bool handled = false;
98  if (!FullSystem) {
99  Process *p = tc->getProcessPtr();
100  handled = p->fixupFault(vaddr);
101  }
102  panic_if(!handled &&
103  !tc->getSystemPtr()->trapToGdb(SIGSEGV, tc->contextId()),
104  "Page table fault when accessing virtual address %#x\n", vaddr);
105 }
106 
107 void
109 {
110  panic_if(!tc->getSystemPtr()->trapToGdb(SIGSEGV, tc->contextId()),
111  "Alignment fault when accessing virtual address %#x\n", vaddr);
112 }
113 
115  const StaticInstPtr &inst)
116 {
117  // reset decoder
118  InstDecoder* dcdr = tc->getDecoderPtr();
119  dcdr->reset();
120 
121  // restore transaction checkpoint
122  const auto& checkpoint = tc->getHtmCheckpointPtr();
123  assert(checkpoint);
124  assert(checkpoint->valid());
125 
126  checkpoint->restore(tc, getHtmFailureFaultCause());
127 
128  // reset the global monitor
130 
131  // send abort packet to ruby (in final breath)
133 }
134 
135 } // namespace gem5
#define DPRINTF(x,...)
Definition: trace.hh:186
virtual void globalClearExclusive()
Definition: isa.hh:120
virtual FaultName name() const =0
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
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
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:95
virtual void reset()
Definition: decoder.hh:63
virtual PCStateBase * clone() const =0
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:83
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:72
virtual void advancePC(PCStateBase &pc_state) const =0
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:89
Workload * workload
OS kernel.
Definition: system.hh:329
bool trapToGdb(int signal, ContextID ctx_id) const
Definition: system.cc:394
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause)=0
virtual const PCStateBase & pcState() const =0
virtual System * getSystemPtr()=0
virtual BaseISA * getIsaPtr() const =0
virtual InstDecoder * getDecoderPtr()=0
virtual BaseHTMCheckpointPtr & getHtmCheckpointPtr()=0
virtual ContextID contextId() const =0
virtual Process * getProcessPtr()=0
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:66
std::string panicStr
Definition: faults.hh:70
virtual void syscall(ThreadContext *tc)
Definition: workload.hh:110
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
Bitfield< 4 > pc
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:220
Declarations of a non-full system Page Table.

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