gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
faults.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Gabe Black
29  * Kevin Lim
30  */
31 
32 #include "arch/alpha/faults.hh"
33 
34 #include "arch/alpha/ev5.hh"
35 #include "arch/alpha/tlb.hh"
36 #include "base/trace.hh"
37 #include "cpu/base.hh"
38 #include "cpu/thread_context.hh"
39 #include "mem/page_table.hh"
40 #include "sim/full_system.hh"
41 #include "sim/process.hh"
42 
43 namespace AlphaISA {
44 
48 
52 
56 
60 
61 FaultName InterruptFault::_name = "interrupt";
64 
65 FaultName NDtbMissFault::_name = "dtb_miss_single";
68 
69 FaultName PDtbMissFault::_name = "dtb_miss_double";
72 
73 FaultName DtbPageFault::_name = "dtb_page_fault";
76 
77 FaultName DtbAcvFault::_name = "dtb_acv_fault";
80 
84 
85 FaultName ItbPageFault::_name = "itbmiss";
88 
89 FaultName ItbAcvFault::_name = "iaccvio";
92 
96 
100 
101 /* We use the same fault vector, as for the guest system these should be the
102  * same, but for host purposes, having differentiation is helpful for
103  * debug/monitorization purposes. */
107 
108 FaultName PalFault::_name = "pal";
109 FaultVect PalFault::_vect = 0x2001;
111 
115 
116 void
118 {
119  FaultBase::invoke(tc);
120  if (!FullSystem)
121  return;
122  countStat()++;
123 
124  PCState pc = tc->pcState();
125 
126  // exception restart address
127  if (setRestartAddress() || !(pc.pc() & 0x3))
129 
130  if (skipFaultingInstruction()) {
131  // traps... skip faulting instruction.
134  }
135 
137  tc->pcState(pc);
138 }
139 
140 void
142 {
143  FaultBase::invoke(tc);
144  if (!FullSystem)
145  return;
146  panic("Arithmetic traps are unimplemented!");
147 }
148 
149 void
151 {
152  if (FullSystem) {
153  // Set fault address and flags. Even though we're modeling an
154  // EV5, we use the EV6 technique of not latching fault registers
155  // on VPTE loads (instead of locking the registers until IPR_VA is
156  // read, like the EV5). The EV6 approach is cleaner and seems to
157  // work with EV5 PAL code, but not the other way around.
158  if (reqFlags.noneSet(AlphaRequestFlags::VPTE | Request::PREFETCH)) {
159  // set VA register with faulting address
161 
162  // set MM_STAT register flags
163  MachInst machInst = inst->machInst;
165  (((Opcode(machInst) & 0x3f) << 11) |
166  ((Ra(machInst) & 0x1f) << 6) |
167  (flags & 0x3f)));
168 
169  // set VA_FORM register with faulting formatted address
171  tc->readMiscRegNoEffect(IPR_MVPTBR) | (vaddr.vpn() << 3));
172  }
173  }
174 
175  AlphaFault::invoke(tc);
176 }
177 
178 void
180 {
181  if (FullSystem) {
184  tc->readMiscRegNoEffect(IPR_IVPTBR) | (VAddr(pc).vpn() << 3));
185  }
186 
187  AlphaFault::invoke(tc);
188 }
189 
190 void
192 {
193  if (FullSystem) {
194  ItbFault::invoke(tc);
195  return;
196  }
197 
198  Process *p = tc->getProcessPtr();
199  const EmulationPageTable::Entry *pte = p->pTable->lookup(pc);
200  panic_if(!pte, "Tried to execute unmapped address %#x.\n", pc);
201 
202  VAddr vaddr(pc);
203  TlbEntry entry(p->pTable->pid(), vaddr.page(), pte->paddr,
206  dynamic_cast<TLB *>(tc->getITBPtr())->insert(vaddr.page(), entry);
207 }
208 
209 void
211 {
212  if (FullSystem) {
213  DtbFault::invoke(tc, inst);
214  return;
215  }
216 
217  Process *p = tc->getProcessPtr();
218  const EmulationPageTable::Entry *pte = p->pTable->lookup(vaddr);
219  if (!pte && p->fixupStackFault(vaddr))
220  pte = p->pTable->lookup(vaddr);
221  panic_if(!pte, "Tried to access unmapped address %#x.\n", (Addr)vaddr);
222  TlbEntry entry(p->pTable->pid(), vaddr.page(), pte->paddr,
225  dynamic_cast<TLB *>(tc->getDTBPtr())->insert(vaddr.page(), entry);
226 }
227 
228 } // namespace AlphaISA
229 
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
static FaultVect _vect
Definition: faults.hh:75
static FaultName _name
Definition: faults.hh:171
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:179
virtual FaultStat & countStat()=0
static FaultName _name
Definition: faults.hh:249
static FaultName _name
Definition: faults.hh:88
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:210
static FaultStat _count
Definition: faults.hh:189
static FaultName _name
Definition: faults.hh:334
virtual BaseTLB * getDTBPtr()=0
static FaultName _name
Definition: faults.hh:101
virtual TheISA::PCState pcState() const =0
static FaultName _name
Definition: faults.hh:318
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
virtual FaultVect vect()=0
static FaultVect _vect
Definition: faults.hh:154
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:136
virtual Process * getProcessPtr()=0
static FaultStat _count
Definition: faults.hh:121
static FaultStat _count
Definition: faults.hh:90
static FaultName _name
Definition: faults.hh:219
int Ra(MachInst inst)
Definition: ev5.hh:106
static FaultStat _count
Definition: faults.hh:336
static FaultName _name
Definition: faults.hh:119
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:141
static FaultVect _vect
Definition: faults.hh:172
static FaultStat _count
Definition: faults.hh:221
static FaultVect _vect
Definition: faults.hh:120
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void set(Addr val)
Definition: types.hh:155
static FaultVect _vect
Definition: faults.hh:266
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
static FaultVect _vect
Definition: faults.hh:102
static FaultVect _vect
Definition: faults.hh:319
static FaultVect _vect
Definition: faults.hh:89
uint32_t MachInst
Definition: types.hh:40
static FaultName _name
Definition: faults.hh:203
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:229
Bitfield< 4 > pc
static FaultVect _vect
Definition: faults.hh:306
static FaultVect _vect
Definition: faults.hh:293
static FaultVect _vect
Definition: faults.hh:188
const char * FaultName
Definition: faults.hh:39
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:150
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:117
The request is a prefetch.
Definition: request.hh:154
virtual BaseTLB * getITBPtr()=0
static FaultVect _vect
Definition: faults.hh:250
static const ArchFlagsType VPTE
The request is an ALPHA VPTE pal access (hw_ld).
Definition: types.hh:63
Addr page() const
Definition: pagetable.hh:54
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
static FaultStat _count
Definition: faults.hh:205
static FaultVect _vect
Definition: faults.hh:335
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:191
static FaultVect _vect
Definition: faults.hh:62
bool fixupStackFault(Addr vaddr)
Attempt to fix up a fault at vaddr by allocating a page on the stack.
Definition: process.cc:362
static FaultStat _count
Definition: faults.hh:267
EmulationPageTable * pTable
Definition: process.hh:181
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
Declarations of a non-full system Page Table.
static FaultStat _count
Definition: faults.hh:251
static FaultName _name
Definition: faults.hh:61
static FaultName _name
Definition: faults.hh:74
static FaultVect _vect
Definition: faults.hh:204
Addr vpn() const
Definition: pagetable.hh:53
static FaultStat _count
Definition: faults.hh:63
static FaultName _name
Definition: faults.hh:265
virtual bool setRestartAddress()
Definition: faults.hh:49
const Entry * lookup(Addr vaddr)
Lookup function.
Definition: page_table.cc:134
static FaultName _name
Definition: faults.hh:187
static FaultName _name
Definition: faults.hh:153
static FaultStat _count
Definition: faults.hh:173
static FaultStat _count
Definition: faults.hh:103
int Opcode(MachInst inst)
Definition: ev5.hh:105
static FaultVect _vect
Definition: faults.hh:220
static FaultStat _count
Definition: faults.hh:320
Bitfield< 0 > p
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:185
virtual bool skipFaultingInstruction()
Definition: faults.hh:48
static FaultStat _count
Definition: faults.hh:76
uint64_t pid() const
Definition: page_table.hh:83
static FaultName _name
Definition: faults.hh:305
static FaultStat _count
Definition: faults.hh:294
Addr FaultVect
Definition: faults.hh:43
static FaultStat _count
Definition: faults.hh:307
virtual void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:43
static FaultName _name
Definition: faults.hh:292
static FaultStat _count
Definition: faults.hh:155

Generated on Fri Feb 28 2020 16:26:55 for gem5 by doxygen 1.8.13