faults.cc revision 3523
12131SN/A/* 22131SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32131SN/A * All rights reserved. 42131SN/A * 52131SN/A * Redistribution and use in source and binary forms, with or without 62131SN/A * modification, are permitted provided that the following conditions are 72131SN/A * met: redistributions of source code must retain the above copyright 82131SN/A * notice, this list of conditions and the following disclaimer; 92131SN/A * redistributions in binary form must reproduce the above copyright 102131SN/A * notice, this list of conditions and the following disclaimer in the 112131SN/A * documentation and/or other materials provided with the distribution; 122131SN/A * neither the name of the copyright holders nor the names of its 132131SN/A * contributors may be used to endorse or promote products derived from 142131SN/A * this software without specific prior written permission. 152131SN/A * 162131SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172131SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182131SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192131SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202131SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212131SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222131SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232131SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242131SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252131SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262131SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282935Sksewell@umich.edu * Authors: Gabe Black 292935Sksewell@umich.edu * Korey Sewell 302131SN/A */ 312131SN/A 322239SN/A#include "arch/mips/faults.hh" 332680Sktlim@umich.edu#include "cpu/thread_context.hh" 342447SN/A#include "cpu/base.hh" 352447SN/A#include "base/trace.hh" 362935Sksewell@umich.edu 372800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM 382800Ssaidi@eecs.umich.edu#include "sim/process.hh" 392800Ssaidi@eecs.umich.edu#include "mem/page_table.hh" 402800Ssaidi@eecs.umich.edu#endif 412131SN/A 422447SN/Anamespace MipsISA 432447SN/A{ 442131SN/A 452479SN/AFaultName MachineCheckFault::_name = "Machine Check"; 462447SN/AFaultVect MachineCheckFault::_vect = 0x0401; 472447SN/AFaultStat MachineCheckFault::_count; 482131SN/A 492479SN/AFaultName AlignmentFault::_name = "Alignment"; 502447SN/AFaultVect AlignmentFault::_vect = 0x0301; 512447SN/AFaultStat AlignmentFault::_count; 522447SN/A 532447SN/AFaultName ResetFault::_name = "reset"; 542447SN/AFaultVect ResetFault::_vect = 0x0001; 552447SN/AFaultStat ResetFault::_count; 562447SN/A 572447SN/AFaultName ArithmeticFault::_name = "arith"; 582447SN/AFaultVect ArithmeticFault::_vect = 0x0501; 592447SN/AFaultStat ArithmeticFault::_count; 602447SN/A 612800Ssaidi@eecs.umich.edu#if !FULL_SYSTEM 622800Ssaidi@eecs.umich.eduFaultName PageTableFault::_name = "page_table_fault"; 632800Ssaidi@eecs.umich.eduFaultVect PageTableFault::_vect = 0x0000; 642800Ssaidi@eecs.umich.eduFaultStat PageTableFault::_count; 652800Ssaidi@eecs.umich.edu#endif 662800Ssaidi@eecs.umich.edu 672447SN/AFaultName InterruptFault::_name = "interrupt"; 682447SN/AFaultVect InterruptFault::_vect = 0x0101; 692447SN/AFaultStat InterruptFault::_count; 702447SN/A 712447SN/AFaultName NDtbMissFault::_name = "dtb_miss_single"; 722447SN/AFaultVect NDtbMissFault::_vect = 0x0201; 732447SN/AFaultStat NDtbMissFault::_count; 742447SN/A 752447SN/AFaultName PDtbMissFault::_name = "dtb_miss_double"; 762447SN/AFaultVect PDtbMissFault::_vect = 0x0281; 772447SN/AFaultStat PDtbMissFault::_count; 782447SN/A 792447SN/AFaultName DtbPageFault::_name = "dfault"; 802447SN/AFaultVect DtbPageFault::_vect = 0x0381; 812447SN/AFaultStat DtbPageFault::_count; 822447SN/A 832447SN/AFaultName DtbAcvFault::_name = "dfault"; 842447SN/AFaultVect DtbAcvFault::_vect = 0x0381; 852447SN/AFaultStat DtbAcvFault::_count; 862447SN/A 872447SN/AFaultName ItbMissFault::_name = "itbmiss"; 882447SN/AFaultVect ItbMissFault::_vect = 0x0181; 892447SN/AFaultStat ItbMissFault::_count; 902447SN/A 912447SN/AFaultName ItbPageFault::_name = "itbmiss"; 922447SN/AFaultVect ItbPageFault::_vect = 0x0181; 932447SN/AFaultStat ItbPageFault::_count; 942447SN/A 952447SN/AFaultName ItbAcvFault::_name = "iaccvio"; 962447SN/AFaultVect ItbAcvFault::_vect = 0x0081; 972447SN/AFaultStat ItbAcvFault::_count; 982447SN/A 992447SN/AFaultName UnimplementedOpcodeFault::_name = "opdec"; 1002447SN/AFaultVect UnimplementedOpcodeFault::_vect = 0x0481; 1012447SN/AFaultStat UnimplementedOpcodeFault::_count; 1022447SN/A 1032447SN/AFaultName FloatEnableFault::_name = "fen"; 1042447SN/AFaultVect FloatEnableFault::_vect = 0x0581; 1052447SN/AFaultStat FloatEnableFault::_count; 1062447SN/A 1072447SN/AFaultName PalFault::_name = "pal"; 1082447SN/AFaultVect PalFault::_vect = 0x2001; 1092447SN/AFaultStat PalFault::_count; 1102447SN/A 1112447SN/AFaultName IntegerOverflowFault::_name = "intover"; 1122447SN/AFaultVect IntegerOverflowFault::_vect = 0x0501; 1132447SN/AFaultStat IntegerOverflowFault::_count; 1142447SN/A 1152800Ssaidi@eecs.umich.eduvoid PageTableFault::invoke(ThreadContext *tc) 1162800Ssaidi@eecs.umich.edu{ 1172800Ssaidi@eecs.umich.edu Process *p = tc->getProcessPtr(); 1182800Ssaidi@eecs.umich.edu 1192800Ssaidi@eecs.umich.edu // address is higher than the stack region or in the current stack region 1202800Ssaidi@eecs.umich.edu if (vaddr > p->stack_base || vaddr > p->stack_min) 1212800Ssaidi@eecs.umich.edu FaultBase::invoke(tc); 1222800Ssaidi@eecs.umich.edu 1232800Ssaidi@eecs.umich.edu // We've accessed the next page 1242800Ssaidi@eecs.umich.edu if (vaddr > p->stack_min - PageBytes) { 1252800Ssaidi@eecs.umich.edu p->stack_min -= PageBytes; 1262800Ssaidi@eecs.umich.edu if (p->stack_base - p->stack_min > 8*1024*1024) 1272800Ssaidi@eecs.umich.edu fatal("Over max stack size for one thread\n"); 1282800Ssaidi@eecs.umich.edu p->pTable->allocate(p->stack_min, PageBytes); 1292800Ssaidi@eecs.umich.edu warn("Increasing stack size by one page."); 1302800Ssaidi@eecs.umich.edu } else { 1312800Ssaidi@eecs.umich.edu FaultBase::invoke(tc); 1322800Ssaidi@eecs.umich.edu } 1332800Ssaidi@eecs.umich.edu} 1342800Ssaidi@eecs.umich.edu 1352447SN/A} // namespace MipsISA 1362447SN/A 137