gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 FaultName PalFault::_name = "pal";
102 FaultVect PalFault::_vect = 0x2001;
104 
108 
109 void
111 {
112  FaultBase::invoke(tc);
113  if (!FullSystem)
114  return;
115  countStat()++;
116 
117  PCState pc = tc->pcState();
118 
119  // exception restart address
120  if (setRestartAddress() || !(pc.pc() & 0x3))
122 
123  if (skipFaultingInstruction()) {
124  // traps... skip faulting instruction.
127  }
128 
130  tc->pcState(pc);
131 }
132 
133 void
135 {
136  FaultBase::invoke(tc);
137  if (!FullSystem)
138  return;
139  panic("Arithmetic traps are unimplemented!");
140 }
141 
142 void
144 {
145  if (FullSystem) {
146  // Set fault address and flags. Even though we're modeling an
147  // EV5, we use the EV6 technique of not latching fault registers
148  // on VPTE loads (instead of locking the registers until IPR_VA is
149  // read, like the EV5). The EV6 approach is cleaner and seems to
150  // work with EV5 PAL code, but not the other way around.
152  // set VA register with faulting address
154 
155  // set MM_STAT register flags
156  MachInst machInst = inst->machInst;
158  (((Opcode(machInst) & 0x3f) << 11) |
159  ((Ra(machInst) & 0x1f) << 6) |
160  (flags & 0x3f)));
161 
162  // set VA_FORM register with faulting formatted address
164  tc->readMiscRegNoEffect(IPR_MVPTBR) | (vaddr.vpn() << 3));
165  }
166  }
167 
168  AlphaFault::invoke(tc);
169 }
170 
171 void
173 {
174  if (FullSystem) {
177  tc->readMiscRegNoEffect(IPR_IVPTBR) | (VAddr(pc).vpn() << 3));
178  }
179 
180  AlphaFault::invoke(tc);
181 }
182 
183 void
185 {
186  if (FullSystem) {
187  ItbFault::invoke(tc);
188  return;
189  }
190 
191  Process *p = tc->getProcessPtr();
192  TlbEntry entry;
193  bool success = p->pTable->lookup(pc, entry);
194  if (!success) {
195  panic("Tried to execute unmapped address %#x.\n", pc);
196  } else {
197  VAddr vaddr(pc);
198  tc->getITBPtr()->insert(vaddr.page(), entry);
199  }
200 }
201 
202 void
204 {
205  if (FullSystem) {
206  DtbFault::invoke(tc, inst);
207  return;
208  }
209 
210  Process *p = tc->getProcessPtr();
211  TlbEntry entry;
212  bool success = p->pTable->lookup(vaddr, entry);
213  if (!success) {
214  if (p->fixupStackFault(vaddr))
215  success = p->pTable->lookup(vaddr, entry);
216  }
217  if (!success) {
218  panic("Tried to access unmapped address %#x.\n", (Addr)vaddr);
219  } else {
220  tc->getDTBPtr()->insert(vaddr.page(), entry);
221  }
222 }
223 
224 } // namespace AlphaISA
225 
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:172
virtual FaultStat & countStat()=0
Addr page() const
Definition: pagetable.hh:53
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:203
static FaultStat _count
Definition: faults.hh:189
static FaultName _name
Definition: faults.hh:321
#define panic(...)
Definition: misc.hh:153
static FaultName _name
Definition: faults.hh:101
static FaultName _name
Definition: faults.hh:305
virtual FaultVect vect()=0
static FaultVect _vect
Definition: faults.hh:154
virtual MiscReg readMiscRegNoEffect(int misc_reg) const =0
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:146
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:323
static FaultName _name
Definition: faults.hh:119
virtual TheISA::PCState pcState()=0
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:134
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:145
static FaultVect _vect
Definition: faults.hh:266
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
static FaultVect _vect
Definition: faults.hh:102
static FaultVect _vect
Definition: faults.hh:306
static FaultVect _vect
Definition: faults.hh:89
uint32_t MachInst
Definition: types.hh:40
Addr pc() const
Definition: types.hh:138
static FaultName _name
Definition: faults.hh:203
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:218
static FaultVect _vect
Definition: faults.hh:293
static FaultVect _vect
Definition: faults.hh:188
virtual TheISA::TLB * getDTBPtr()=0
const char * FaultName
Definition: faults.hh:39
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:143
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:110
Request::Flags reqFlags
Definition: faults.hh:136
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 vpn() const
Definition: pagetable.hh:52
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
PageTableBase * pTable
Definition: process.hh:178
static FaultVect _vect
Definition: faults.hh:322
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:184
bool noneSet() const
Definition: flags.hh:66
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:338
static FaultStat _count
Definition: faults.hh:267
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
static FaultStat _count
Definition: faults.hh:63
static FaultName _name
Definition: faults.hh:265
uint64_t flags
Definition: faults.hh:137
virtual bool setRestartAddress()
Definition: faults.hh:49
virtual bool lookup(Addr vaddr, TheISA::TlbEntry &entry)=0
Lookup function.
static FaultName _name
Definition: faults.hh:187
static FaultName _name
Definition: faults.hh:153
static FaultStat _count
Definition: faults.hh:173
IntReg pc
Definition: remote_gdb.hh:91
static FaultStat _count
Definition: faults.hh:103
The request is a prefetch.
Definition: request.hh:153
int Opcode(MachInst inst)
Definition: ev5.hh:105
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)=0
static FaultVect _vect
Definition: faults.hh:220
static FaultStat _count
Definition: faults.hh:307
Bitfield< 0 > p
virtual bool skipFaultingInstruction()
Definition: faults.hh:48
static FaultStat _count
Definition: faults.hh:76
virtual TheISA::TLB * getITBPtr()=0
static FaultStat _count
Definition: faults.hh:294
Addr FaultVect
Definition: faults.hh:43
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 Jun 9 2017 13:03:34 for gem5 by doxygen 1.8.6