gem5  v21.1.0.2
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/decoder.hh"
46 #include "arch/locked_mem.hh"
47 #include "base/logging.hh"
48 #include "cpu/base.hh"
49 #include "cpu/thread_context.hh"
50 #include "debug/Fault.hh"
51 #include "mem/page_table.hh"
52 #include "sim/full_system.hh"
53 #include "sim/process.hh"
54 
55 namespace gem5
56 {
57 
58 void
60 {
61  panic_if(!FullSystem, "fault (%s) detected @ PC %s",
62  name(), tc->pcState());
63  DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState());
64 }
65 
66 void
68 {
69  panic("Unimpfault: %s", panicStr.c_str());
70 }
71 
72 void
74 {
75  tc->getSystemPtr()->workload->syscall(tc);
76  // Move the PC forward since that doesn't happen automatically.
77  TheISA::PCState pc = tc->pcState();
78  inst->advancePC(pc);
79  tc->pcState(pc);
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  TheISA::Decoder* 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
gem5::ThreadContext::getSystemPtr
virtual System * getSystemPtr()=0
gem5::GenericAlignmentFault::vaddr
Addr vaddr
Definition: faults.hh:131
gem5::ThreadContext::contextId
virtual ContextID contextId() const =0
gem5::System::workload
Workload * workload
OS kernel.
Definition: system.hh:335
faults.hh
gem5::FaultBase::name
virtual FaultName name() const =0
gem5::ThreadContext::getDecoderPtr
virtual TheISA::Decoder * getDecoderPtr()=0
gem5::GenericPageTableFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:95
gem5::RefCountingPtr< StaticInst >
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::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:255
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::GenericHtmFailureFault::getHtmFailureFaultCause
HtmFailureFaultCause getHtmFailureFaultCause() const
Definition: faults.hh:154
gem5::MipsISA::PCState
GenericISA::DelaySlotPCState< 4 > PCState
Definition: pcstate.hh:40
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::GenericAlignmentFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:108
process.hh
gem5::UnimpFault::panicStr
std::string panicStr
Definition: faults.hh:70
gem5::UnimpFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:67
gem5::SyscallRetryFault::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:89
gem5::ThreadContext::pcState
virtual TheISA::PCState pcState() const =0
gem5::ThreadContext::getHtmCheckpointPtr
virtual BaseHTMCheckpointPtr & getHtmCheckpointPtr()=0
gem5::ThreadContext::htmAbortTransaction
virtual void htmAbortTransaction(uint64_t htm_uid, HtmFailureFaultCause cause)=0
gem5::FaultBase::invoke
virtual void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr)
Definition: faults.cc:59
full_system.hh
gem5::Process
Definition: process.hh:67
gem5::System::trapToGdb
bool trapToGdb(int signal, ContextID ctx_id) const
Definition: system.cc:505
gem5::ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
gem5::FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:223
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
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:203
base.hh
gem5::ArmISA::globalClearExclusive
void globalClearExclusive(XC *xc)
Definition: locked_mem.hh:152
gem5::ReExec::invoke
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
Definition: faults.cc:83
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
logging.hh
gem5::GenericHtmFailureFault::htmUid
uint64_t htmUid
Definition: faults.hh:143
gem5::GenericPageTableFault::vaddr
Addr vaddr
Definition: faults.hh:119
page_table.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
thread_context.hh
gem5::StaticInst::advancePC
virtual void advancePC(TheISA::PCState &pc_state) const =0
gem5::Workload::syscall
virtual void syscall(ThreadContext *tc)
Definition: workload.hh:106
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

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