faults.cc revision 2289
112837Sgabeblack@google.com/*
212837Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan
312837Sgabeblack@google.com * All rights reserved.
412837Sgabeblack@google.com *
512837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612837Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112837Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412837Sgabeblack@google.com * this software without specific prior written permission.
1512837Sgabeblack@google.com *
1612837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712837Sgabeblack@google.com */
2812837Sgabeblack@google.com
2912837Sgabeblack@google.com#include "arch/alpha/faults.hh"
3012950Sgabeblack@google.com#include "cpu/exec_context.hh"
3112950Sgabeblack@google.com#include "cpu/base.hh"
3212950Sgabeblack@google.com#include "base/trace.hh"
3312837Sgabeblack@google.com#if FULL_SYSTEM
3412837Sgabeblack@google.com#include "arch/alpha/ev5.hh"
3512837Sgabeblack@google.com#endif
3612837Sgabeblack@google.com
3712837Sgabeblack@google.comnamespace AlphaISA
3812950Sgabeblack@google.com{
3912950Sgabeblack@google.com
4012950Sgabeblack@google.comFaultName MachineCheckFault::_name = "mchk";
4112950Sgabeblack@google.comFaultVect MachineCheckFault::_vect = 0x0401;
4212950Sgabeblack@google.comFaultStat MachineCheckFault::_count;
4312950Sgabeblack@google.com
4412950Sgabeblack@google.comFaultName AlignmentFault::_name = "unalign";
4512837Sgabeblack@google.comFaultVect AlignmentFault::_vect = 0x0301;
4612837Sgabeblack@google.comFaultStat AlignmentFault::_count;
4712837Sgabeblack@google.com
4812950Sgabeblack@google.comFaultName ResetFault::_name = "reset";
4912837Sgabeblack@google.comFaultVect ResetFault::_vect = 0x0001;
5012837Sgabeblack@google.comFaultStat ResetFault::_count;
5112837Sgabeblack@google.com
5212837Sgabeblack@google.comFaultName ArithmeticFault::_name = "arith";
5312837Sgabeblack@google.comFaultVect ArithmeticFault::_vect = 0x0501;
5412950Sgabeblack@google.comFaultStat ArithmeticFault::_count;
5512837Sgabeblack@google.com
5612837Sgabeblack@google.comFaultName InterruptFault::_name = "interrupt";
5712837Sgabeblack@google.comFaultVect InterruptFault::_vect = 0x0101;
5812837Sgabeblack@google.comFaultStat InterruptFault::_count;
5912837Sgabeblack@google.com
6012950Sgabeblack@google.comFaultName NDtbMissFault::_name = "dtb_miss_single";
6112837Sgabeblack@google.comFaultVect NDtbMissFault::_vect = 0x0201;
6212837Sgabeblack@google.comFaultStat NDtbMissFault::_count;
6312837Sgabeblack@google.com
6412837Sgabeblack@google.comFaultName PDtbMissFault::_name = "dtb_miss_double";
6512837Sgabeblack@google.comFaultVect PDtbMissFault::_vect = 0x0281;
6612950Sgabeblack@google.comFaultStat PDtbMissFault::_count;
6712837Sgabeblack@google.com
6812837Sgabeblack@google.comFaultName DtbPageFault::_name = "dfault";
6912837Sgabeblack@google.comFaultVect DtbPageFault::_vect = 0x0381;
7012837Sgabeblack@google.comFaultStat DtbPageFault::_count;
7112837Sgabeblack@google.com
7212950Sgabeblack@google.comFaultName DtbAcvFault::_name = "dfault";
7312837Sgabeblack@google.comFaultVect DtbAcvFault::_vect = 0x0381;
7412837Sgabeblack@google.comFaultStat DtbAcvFault::_count;
7512837Sgabeblack@google.com
7612837Sgabeblack@google.comFaultName DtbAlignmentFault::_name = "unalign";
7712837Sgabeblack@google.comFaultVect DtbAlignmentFault::_vect = 0x0301;
7812950Sgabeblack@google.comFaultStat DtbAlignmentFault::_count;
7912837Sgabeblack@google.com
8012837Sgabeblack@google.comFaultName ItbMissFault::_name = "itbmiss";
8112837Sgabeblack@google.comFaultVect ItbMissFault::_vect = 0x0181;
8212837Sgabeblack@google.comFaultStat ItbMissFault::_count;
8312837Sgabeblack@google.com
8412950Sgabeblack@google.comFaultName ItbPageFault::_name = "itbmiss";
8512837Sgabeblack@google.comFaultVect ItbPageFault::_vect = 0x0181;
8612837Sgabeblack@google.comFaultStat ItbPageFault::_count;
8712837Sgabeblack@google.com
8812950Sgabeblack@google.comFaultName ItbAcvFault::_name = "iaccvio";
8912837Sgabeblack@google.comFaultVect ItbAcvFault::_vect = 0x0081;
9012950Sgabeblack@google.comFaultStat ItbAcvFault::_count;
9112837Sgabeblack@google.com
9212837Sgabeblack@google.comFaultName UnimplementedOpcodeFault::_name = "opdec";
9312837Sgabeblack@google.comFaultVect UnimplementedOpcodeFault::_vect = 0x0481;
9412950Sgabeblack@google.comFaultStat UnimplementedOpcodeFault::_count;
9512837Sgabeblack@google.com
9612950Sgabeblack@google.comFaultName FloatEnableFault::_name = "fen";
9712837Sgabeblack@google.comFaultVect FloatEnableFault::_vect = 0x0581;
9812837Sgabeblack@google.comFaultStat FloatEnableFault::_count;
9912837Sgabeblack@google.com
10012950Sgabeblack@google.comFaultName PalFault::_name = "pal";
10112837Sgabeblack@google.comFaultVect PalFault::_vect = 0x2001;
10212950Sgabeblack@google.comFaultStat PalFault::_count;
10312837Sgabeblack@google.com
10412837Sgabeblack@google.comFaultName IntegerOverflowFault::_name = "intover";
10512837Sgabeblack@google.comFaultVect IntegerOverflowFault::_vect = 0x0501;
10612837Sgabeblack@google.comFaultStat IntegerOverflowFault::_count;
10712837Sgabeblack@google.com
10812950Sgabeblack@google.com#if FULL_SYSTEM
10912837Sgabeblack@google.com
11012837Sgabeblack@google.comvoid AlphaFault::invoke(ExecContext * xc)
11112837Sgabeblack@google.com{
11212837Sgabeblack@google.com    FaultBase::invoke(xc);
11312837Sgabeblack@google.com    countStat()++;
11412950Sgabeblack@google.com
11512837Sgabeblack@google.com    // exception restart address
11612837Sgabeblack@google.com    if (setRestartAddress() || !xc->inPalMode())
11712837Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR, xc->readPC());
11812837Sgabeblack@google.com
11912837Sgabeblack@google.com    if (skipFaultingInstruction()) {
12012950Sgabeblack@google.com        // traps...  skip faulting instruction.
12112837Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_EXC_ADDR,
12212837Sgabeblack@google.com                   xc->readMiscReg(AlphaISA::IPR_EXC_ADDR) + 4);
12312837Sgabeblack@google.com    }
12412837Sgabeblack@google.com
12512837Sgabeblack@google.com    xc->setPC(xc->readMiscReg(AlphaISA::IPR_PAL_BASE) + vect());
12612950Sgabeblack@google.com    xc->setNextPC(xc->readPC() + sizeof(MachInst));
12712837Sgabeblack@google.com}
12812837Sgabeblack@google.com
12912940Sgabeblack@google.comvoid ArithmeticFault::invoke(ExecContext * xc)
13012940Sgabeblack@google.com{
13112940Sgabeblack@google.com    FaultBase::invoke(xc);
13212950Sgabeblack@google.com    panic("Arithmetic traps are unimplemented!");
13312940Sgabeblack@google.com}
13412940Sgabeblack@google.com
13512837Sgabeblack@google.comvoid DtbFault::invoke(ExecContext * xc)
13612837Sgabeblack@google.com{
13712950Sgabeblack@google.com    // Set fault address and flags.  Even though we're modeling an
13812837Sgabeblack@google.com    // EV5, we use the EV6 technique of not latching fault registers
13912837Sgabeblack@google.com    // on VPTE loads (instead of locking the registers until IPR_VA is
14012837Sgabeblack@google.com    // read, like the EV5).  The EV6 approach is cleaner and seems to
14112837Sgabeblack@google.com    // work with EV5 PAL code, but not the other way around.
14212950Sgabeblack@google.com    if (!xc->misspeculating()
14312837Sgabeblack@google.com        && !(reqFlags & VPTE) && !(reqFlags & NO_FAULT)) {
14412837Sgabeblack@google.com        // set VA register with faulting address
14512950Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_VA, vaddr);
14612837Sgabeblack@google.com
14712950Sgabeblack@google.com        // set MM_STAT register flags
14812837Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_MM_STAT,
14912837Sgabeblack@google.com            (((EV5::Opcode(xc->getInst()) & 0x3f) << 11)
15012837Sgabeblack@google.com             | ((EV5::Ra(xc->getInst()) & 0x1f) << 6)
15112950Sgabeblack@google.com             | (flags & 0x3f)));
15212837Sgabeblack@google.com
15312950Sgabeblack@google.com        // set VA_FORM register with faulting formatted address
15412837Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_VA_FORM,
15512837Sgabeblack@google.com            xc->readMiscReg(AlphaISA::IPR_MVPTBR) | (vaddr.vpn() << 3));
15612837Sgabeblack@google.com    }
15712837Sgabeblack@google.com
15812837Sgabeblack@google.com    AlphaFault::invoke(xc);
15912950Sgabeblack@google.com}
16012837Sgabeblack@google.com
16112837Sgabeblack@google.comvoid ItbFault::invoke(ExecContext * xc)
16212837Sgabeblack@google.com{
16312837Sgabeblack@google.com    if (!xc->misspeculating()) {
16412837Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_ITB_TAG, pc);
16512950Sgabeblack@google.com        xc->setMiscReg(AlphaISA::IPR_IFAULT_VA_FORM,
16612837Sgabeblack@google.com                       xc->readMiscReg(AlphaISA::IPR_IVPTBR) |
16712837Sgabeblack@google.com                       (AlphaISA::VAddr(pc).vpn() << 3));
16812837Sgabeblack@google.com    }
16912950Sgabeblack@google.com
17012837Sgabeblack@google.com    AlphaFault::invoke(xc);
17112950Sgabeblack@google.com}
17212837Sgabeblack@google.com
17312837Sgabeblack@google.com#endif
17412837Sgabeblack@google.com
175} // namespace AlphaISA
176
177