faults.hh revision 5124
12292SN/A/* 212355Snikos.nikoleris@arm.com * Copyright (c) 2007 The Hewlett-Packard Development Company 39444SAndreas.Sandberg@ARM.com * All rights reserved. 49444SAndreas.Sandberg@ARM.com * 59444SAndreas.Sandberg@ARM.com * Redistribution and use of this software in source and binary forms, 69444SAndreas.Sandberg@ARM.com * with or without modification, are permitted provided that the 79444SAndreas.Sandberg@ARM.com * following conditions are met: 89444SAndreas.Sandberg@ARM.com * 99444SAndreas.Sandberg@ARM.com * The software must be used only for Non-Commercial Use which means any 109444SAndreas.Sandberg@ARM.com * use which is NOT directed to receiving any direct monetary 119444SAndreas.Sandberg@ARM.com * compensation for, or commercial advantage from such use. Illustrative 129444SAndreas.Sandberg@ARM.com * examples of non-commercial use are academic research, personal study, 139444SAndreas.Sandberg@ARM.com * teaching, education and corporate research & development. 142329SN/A * Illustrative examples of commercial use are distributing products for 1510239Sbinhpham@cs.rutgers.edu * commercial advantage and providing services using the software for 162292SN/A * commercial advantage. 172292SN/A * 182292SN/A * If you wish to use this software or functionality therein that may be 192292SN/A * covered by patents for commercial use, please contact: 202292SN/A * Director of Intellectual Property Licensing 212292SN/A * Office of Strategy and Technology 222292SN/A * Hewlett-Packard Company 232292SN/A * 1501 Page Mill Road 242292SN/A * Palo Alto, California 94304 252292SN/A * 262292SN/A * Redistributions of source code must retain the above copyright notice, 272292SN/A * this list of conditions and the following disclaimer. Redistributions 282292SN/A * in binary form must reproduce the above copyright notice, this list of 292292SN/A * conditions and the following disclaimer in the documentation and/or 302292SN/A * other materials provided with the distribution. Neither the name of 312292SN/A * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 322292SN/A * contributors may be used to endorse or promote products derived from 332292SN/A * this software without specific prior written permission. No right of 342292SN/A * sublicense is granted herewith. Derivatives of the software and 352292SN/A * output created using the software may be prepared, but only for 362292SN/A * Non-Commercial Uses. Derivatives of the software may be shared with 372292SN/A * others provided: (i) the others agree to abide by the list of 382292SN/A * conditions herein which includes the Non-Commercial Use restrictions; 392292SN/A * and (ii) such Derivatives of the software include the above copyright 402689Sktlim@umich.edu * notice to acknowledge the contribution from this software where 412689Sktlim@umich.edu * applicable, this list of conditions and the disclaimer below. 422689Sktlim@umich.edu * 432292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 442292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 452292SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 462292SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 472292SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 482329SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 494395Ssaidi@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 502292SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 512292SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 522292SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 538591Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 548506Sgblack@eecs.umich.edu * 553326Sktlim@umich.edu * Authors: Gabe Black 568481Sgblack@eecs.umich.edu */ 576658Snate@binkert.org 582292SN/A#ifndef __ARCH_X86_FAULTS_HH__ 598230Snate@binkert.org#define __ARCH_X86_FAULTS_HH__ 608232Snate@binkert.org 613348Sbinkertn@umich.edu#include "base/misc.hh" 622669Sktlim@umich.edu#include "sim/faults.hh" 632292SN/A 648737Skoansin.tan@gmail.comnamespace X86ISA 655529Snate@binkert.org{ 662292SN/A // Base class for all x86 "faults" where faults is in the m5 sense 672329SN/A class X86FaultBase : public FaultBase 682329SN/A { 692329SN/A protected: 702329SN/A const char * faultName; 712329SN/A const char * mnem; 722329SN/A 732329SN/A X86FaultBase(const char * _faultName, const char * _mnem) : 742329SN/A faultName(_faultName), mnem(_mnem) 752329SN/A { 762329SN/A } 772292SN/A 782292SN/A const char * name() const 792292SN/A { 802292SN/A return faultName; 812733Sktlim@umich.edu } 822292SN/A 832292SN/A virtual bool isBenign() 842907Sktlim@umich.edu { 852292SN/A return true; 862292SN/A } 872292SN/A 882292SN/A virtual const char * mnemonic() const 892292SN/A { 902292SN/A return mnem; 912292SN/A } 925529Snate@binkert.org }; 935529Snate@binkert.org 945529Snate@binkert.org // Base class for x86 faults which behave as if the underlying instruction 952292SN/A // didn't happen. 962292SN/A class X86Fault : public X86FaultBase 972292SN/A { 982292SN/A protected: 992727Sktlim@umich.edu X86Fault(const char * name, const char * mnem) : 1002727Sktlim@umich.edu X86FaultBase(name, mnem) 1012727Sktlim@umich.edu {} 1022907Sktlim@umich.edu }; 1038922Swilliam.wang@arm.com 1042907Sktlim@umich.edu // Base class for x86 traps which behave as if the underlying instruction 1059444SAndreas.Sandberg@ARM.com // completed. 1069444SAndreas.Sandberg@ARM.com class X86Trap : public X86FaultBase 1072307SN/A { 1082348SN/A protected: 1092307SN/A X86Trap(const char * name, const char * mnem) : 1102307SN/A X86FaultBase(name, mnem) 1112292SN/A {} 1122292SN/A 1132292SN/A#if FULL_SYSTEM 1142292SN/A void invoke(ThreadContext * tc); 1152292SN/A#endif 11611780Sarthur.perais@inria.fr }; 1172292SN/A 1182292SN/A // Base class for x86 aborts which seem to be catastrophic failures. 1192292SN/A class X86Abort : public X86FaultBase 1202292SN/A { 1212292SN/A protected: 1222292SN/A X86Abort(const char * name, const char * mnem) : 1232292SN/A X86FaultBase(name, mnem) 1242292SN/A {} 1258545Ssaidi@eecs.umich.edu 1268545Ssaidi@eecs.umich.edu#if FULL_SYSTEM 1278545Ssaidi@eecs.umich.edu void invoke(ThreadContext * tc); 1288199SAli.Saidi@ARM.com#endif 1298199SAli.Saidi@ARM.com }; 1308199SAli.Saidi@ARM.com 1318199SAli.Saidi@ARM.com // Base class for x86 interrupts. 1328199SAli.Saidi@ARM.com class X86Interrupt : public X86FaultBase 1338545Ssaidi@eecs.umich.edu { 1348545Ssaidi@eecs.umich.edu protected: 1358545Ssaidi@eecs.umich.edu X86Interrupt(const char * name, const char * mnem) : 1368545Ssaidi@eecs.umich.edu X86FaultBase(name, mnem) 1378545Ssaidi@eecs.umich.edu {} 1388545Ssaidi@eecs.umich.edu 1392292SN/A#if FULL_SYSTEM 1402292SN/A void invoke(ThreadContext * tc); 1412292SN/A#endif 1422329SN/A }; 1432292SN/A 1442292SN/A class UnimpInstFault : public FaultBase 1452292SN/A { 1462292SN/A public: 1472292SN/A const char * name() const 1482292SN/A { 1492292SN/A return "unimplemented_micro"; 1502292SN/A } 1512292SN/A 1522292SN/A void invoke(ThreadContext * tc) 1532292SN/A { 1542292SN/A panic("Unimplemented instruction!"); 1552292SN/A } 1562292SN/A }; 1572790Sktlim@umich.edu 1582790Sktlim@umich.edu static inline Fault genMachineCheckFault() 1592669Sktlim@umich.edu { 1602669Sktlim@umich.edu panic("Machine check fault not implemented in x86!\n"); 1612292SN/A } 1622292SN/A 1632292SN/A // Below is a summary of the interrupt/exception information in the 1642292SN/A // architecture manuals. 1652292SN/A 1662292SN/A // Class | Type | vector | Cause | mnem 1672292SN/A //------------------------------------------------------------------------ 1682292SN/A //Contrib Fault 0 Divide-by-Zero-Error #DE 1692292SN/A //Benign Either 1 Debug #DB 1702292SN/A //Benign Interrupt 2 Non-Maskable-Interrupt #NMI 1712292SN/A //Benign Trap 3 Breakpoint #BP 1722292SN/A //Benign Trap 4 Overflow #OF 1732292SN/A //Benign Fault 5 Bound-Range #BR 1742292SN/A //Benign Fault 6 Invalid-Opcode #UD 1752292SN/A //Benign Fault 7 Device-Not-Available #NM 1762292SN/A //Benign Abort 8 Double-Fault #DF 1772292SN/A // 9 Coprocessor-Segment-Overrun 1782292SN/A //Contrib Fault 10 Invalid-TSS #TS 1792292SN/A //Contrib Fault 11 Segment-Not-Present #NP 1802292SN/A //Contrib Fault 12 Stack #SS 1812292SN/A //Contrib Fault 13 General-Protection #GP 1822292SN/A //Either Fault 14 Page-Fault #PF 1832292SN/A // 15 Reserved 18410239Sbinhpham@cs.rutgers.edu //Benign Fault 16 x87 Floating-Point Exception Pending #MF 18510239Sbinhpham@cs.rutgers.edu //Benign Fault 17 Alignment-Check #AC 18610239Sbinhpham@cs.rutgers.edu //Benign Abort 18 Machine-Check #MC 18710239Sbinhpham@cs.rutgers.edu //Benign Fault 19 SIMD Floating-Point #XF 18810239Sbinhpham@cs.rutgers.edu // 20-29 Reserved 1892292SN/A //Contrib ? 30 Security Exception #SX 1902292SN/A // 31 Reserved 1912292SN/A //Benign Interrupt 0-255 External Interrupts #INTR 1922292SN/A //Benign Interrupt 0-255 Software Interrupts INTn 1932292SN/A 1942292SN/A class DivideByZero : public X86Fault 1952292SN/A { 1962292SN/A public: 1972292SN/A DivideByZero() : 1982292SN/A X86Fault("Divide-by-Zero-Error", "#DE") 1999444SAndreas.Sandberg@ARM.com {} 2009444SAndreas.Sandberg@ARM.com }; 2019444SAndreas.Sandberg@ARM.com 2022292SN/A class DebugException : public X86FaultBase 2032292SN/A { 2042292SN/A public: 2052292SN/A DebugException() : 2062292SN/A X86FaultBase("Debug", "#DB") 2072292SN/A {} 2089444SAndreas.Sandberg@ARM.com }; 2099444SAndreas.Sandberg@ARM.com 2109444SAndreas.Sandberg@ARM.com class NonMaskableInterrupt : public X86Interrupt 2119444SAndreas.Sandberg@ARM.com { 2129444SAndreas.Sandberg@ARM.com public: 2139444SAndreas.Sandberg@ARM.com NonMaskableInterrupt() : 2142292SN/A X86Interrupt("Non-Maskable-Interrupt", "#NMI") 2152292SN/A {} 2162292SN/A }; 2172292SN/A 2182292SN/A class Breakpoint : public X86Trap 2192292SN/A { 2202292SN/A public: 2212292SN/A Breakpoint() : 2222292SN/A X86Trap("Breakpoint", "#BP") 2232292SN/A {} 2242292SN/A }; 2252678Sktlim@umich.edu 2262678Sktlim@umich.edu class OverflowTrap : public X86Trap 2272292SN/A { 2282907Sktlim@umich.edu public: 2292907Sktlim@umich.edu OverflowTrap() : 2302907Sktlim@umich.edu X86Trap("Overflow", "#OF") 2312292SN/A {} 2329444SAndreas.Sandberg@ARM.com }; 2339444SAndreas.Sandberg@ARM.com 2349444SAndreas.Sandberg@ARM.com class BoundRange : public X86Fault 2352698Sktlim@umich.edu { 2362678Sktlim@umich.edu public: 2372678Sktlim@umich.edu BoundRange() : 2386974Stjones1@inf.ed.ac.uk X86Fault("Bound-Range", "#BR") 2396974Stjones1@inf.ed.ac.uk {} 2406974Stjones1@inf.ed.ac.uk }; 2412698Sktlim@umich.edu 2423349Sbinkertn@umich.edu class InvalidOpcode : public X86Fault 2432693Sktlim@umich.edu { 2442292SN/A public: 2452292SN/A InvalidOpcode() : 2462292SN/A X86Fault("Invalid-Opcode", "#UD") 2476974Stjones1@inf.ed.ac.uk {} 2486974Stjones1@inf.ed.ac.uk }; 2496974Stjones1@inf.ed.ac.uk 2502292SN/A class DeviceNotAvailable : public X86Fault 2519440SAndreas.Sandberg@ARM.com { 2522292SN/A public: 2539440SAndreas.Sandberg@ARM.com DeviceNotAvailable() : 2542292SN/A X86Fault("Device-Not-Available", "#NM") 2559440SAndreas.Sandberg@ARM.com {} 2562292SN/A }; 2579440SAndreas.Sandberg@ARM.com 2582292SN/A class DoubleFault : public X86Abort 2592329SN/A { 2602329SN/A public: 2619440SAndreas.Sandberg@ARM.com DoubleFault() : 2622329SN/A X86Abort("Double-Fault", "#DF") 2632292SN/A {} 2642292SN/A }; 2652733Sktlim@umich.edu 2662292SN/A class InvalidTSS : public X86Fault 2672292SN/A { 2682292SN/A public: 2692292SN/A InvalidTSS() : 2702907Sktlim@umich.edu X86Fault("Invalid-TSS", "#TS") 2712907Sktlim@umich.edu {} 2722669Sktlim@umich.edu }; 2732907Sktlim@umich.edu 2748922Swilliam.wang@arm.com class SegmentNotPresent : public X86Fault 2752292SN/A { 2762698Sktlim@umich.edu public: 2779044SAli.Saidi@ARM.com SegmentNotPresent() : 2782678Sktlim@umich.edu X86Fault("Segment-Not-Present", "#NP") 2792678Sktlim@umich.edu {} 2802698Sktlim@umich.edu }; 2812678Sktlim@umich.edu 28210537Sandreas.hansson@arm.com class StackFault : public X86Fault 28310537Sandreas.hansson@arm.com { 28410537Sandreas.hansson@arm.com public: 2859046SAli.Saidi@ARM.com StackFault() : 2862678Sktlim@umich.edu X86Fault("Stack", "#SS") 2872698Sktlim@umich.edu {} 2882678Sktlim@umich.edu }; 2899046SAli.Saidi@ARM.com 2909046SAli.Saidi@ARM.com class GeneralProtection : public X86Fault 2919046SAli.Saidi@ARM.com { 2929046SAli.Saidi@ARM.com public: 2939046SAli.Saidi@ARM.com GeneralProtection() : 2949046SAli.Saidi@ARM.com X86Fault("General-Protection", "#GP") 2959046SAli.Saidi@ARM.com {} 2969046SAli.Saidi@ARM.com }; 2972698Sktlim@umich.edu 2982678Sktlim@umich.edu class PageFault : public X86Fault 2992698Sktlim@umich.edu { 3002678Sktlim@umich.edu public: 3016974Stjones1@inf.ed.ac.uk PageFault() : 3026974Stjones1@inf.ed.ac.uk X86Fault("Page-Fault", "#PF") 3036974Stjones1@inf.ed.ac.uk {} 3046974Stjones1@inf.ed.ac.uk }; 30510333Smitch.hayenga@arm.com 30610333Smitch.hayenga@arm.com class X87FpExceptionPending : public X86Fault 3076974Stjones1@inf.ed.ac.uk { 3086974Stjones1@inf.ed.ac.uk public: 3096974Stjones1@inf.ed.ac.uk X87FpExceptionPending() : 3102678Sktlim@umich.edu X86Fault("x87 Floating-Point Exception Pending", "#MF") 3112678Sktlim@umich.edu {} 3122698Sktlim@umich.edu }; 3132678Sktlim@umich.edu 3142678Sktlim@umich.edu class AlignmentCheck : X86Fault 3152678Sktlim@umich.edu { 3162678Sktlim@umich.edu public: 3172678Sktlim@umich.edu AlignmentCheck() : 3182678Sktlim@umich.edu X86Fault("Alignment-Check", "#AC") 3192678Sktlim@umich.edu {} 3202678Sktlim@umich.edu }; 3212678Sktlim@umich.edu 3225336Shines@cs.fsu.edu class MachineCheck : X86Abort 3232678Sktlim@umich.edu { 3242678Sktlim@umich.edu public: 3252698Sktlim@umich.edu MachineCheck() : 3262678Sktlim@umich.edu X86Abort("Machine-Check", "#MC") 3272678Sktlim@umich.edu {} 3282698Sktlim@umich.edu }; 3292678Sktlim@umich.edu 3302678Sktlim@umich.edu class SIMDFloatingPointFault : X86Fault 3312678Sktlim@umich.edu { 3322678Sktlim@umich.edu public: 3332678Sktlim@umich.edu SIMDFloatingPointFault() : 3342678Sktlim@umich.edu X86Fault("SIMD Floating-Point", "#XF") 3352292SN/A {} 3362292SN/A }; 3372292SN/A 3382292SN/A class SecurityException : X86FaultBase 3394326Sgblack@eecs.umich.edu { 3402292SN/A public: 3414326Sgblack@eecs.umich.edu SecurityException() : 3424395Ssaidi@eecs.umich.edu X86FaultBase("Security Exception", "#SX") 3434326Sgblack@eecs.umich.edu {} 3442292SN/A }; 3459152Satgutier@umich.edu 3469152Satgutier@umich.edu class ExternalInterrupt : X86Interrupt 3479152Satgutier@umich.edu { 3489152Satgutier@umich.edu public: 3499152Satgutier@umich.edu ExternalInterrupt() : 3502292SN/A X86Interrupt("External Interrupt", "#INTR") 3512292SN/A {} 3526974Stjones1@inf.ed.ac.uk }; 35310031SAli.Saidi@ARM.com 3544326Sgblack@eecs.umich.edu class SoftwareInterrupt : X86Interrupt 3554395Ssaidi@eecs.umich.edu { 3564326Sgblack@eecs.umich.edu public: 3579046SAli.Saidi@ARM.com SoftwareInterrupt() : 3589046SAli.Saidi@ARM.com X86Interrupt("Software Interrupt", "INTn") 3592292SN/A {} 3602292SN/A }; 3612669Sktlim@umich.edu 3622669Sktlim@umich.edu // These faults aren't part of the ISA definition. They trigger filling 3636974Stjones1@inf.ed.ac.uk // the tlb on a miss and are to take the place of a hardware table walker. 3646974Stjones1@inf.ed.ac.uk class FakeITLBFault : public X86Fault 3656974Stjones1@inf.ed.ac.uk { 3662292SN/A#if !FULL_SYSTEM 3679046SAli.Saidi@ARM.com protected: 3686974Stjones1@inf.ed.ac.uk Addr vaddr; 3696974Stjones1@inf.ed.ac.uk public: 3702292SN/A FakeITLBFault(Addr _vaddr) : 3712292SN/A X86Fault("fake instruction tlb fault", "itlb"), 3722292SN/A vaddr(_vaddr) 3732292SN/A#else 3742292SN/A public: 3752292SN/A FakeITLBFault() : 37610031SAli.Saidi@ARM.com X86Fault("fake instruction tlb fault", "itlb") 37710031SAli.Saidi@ARM.com#endif 37810031SAli.Saidi@ARM.com {} 37910031SAli.Saidi@ARM.com 38010031SAli.Saidi@ARM.com#if !FULL_SYSTEM 3812292SN/A void invoke(ThreadContext * tc); 3822329SN/A#endif 3832292SN/A }; 3842292SN/A 3856221Snate@binkert.org class FakeDTLBFault : public X86Fault 3862292SN/A { 3872292SN/A#if !FULL_SYSTEM 3882292SN/A protected: 3892292SN/A Addr vaddr; 3902292SN/A public: 3912292SN/A FakeDTLBFault(Addr _vaddr) : 3922292SN/A X86Fault("fake data tlb fault", "dtlb"), 3932329SN/A vaddr(_vaddr) 3942329SN/A#else 3952329SN/A public: 3962292SN/A FakeDTLBFault() : 3972329SN/A X86Fault("fake data tlb fault", "dtlb") 3982329SN/A#endif 3992329SN/A {} 4002292SN/A 4012292SN/A#if !FULL_SYSTEM 4028199SAli.Saidi@ARM.com void invoke(ThreadContext * tc); 4038199SAli.Saidi@ARM.com#endif 4048199SAli.Saidi@ARM.com }; 4058199SAli.Saidi@ARM.com}; 4068199SAli.Saidi@ARM.com 4078199SAli.Saidi@ARM.com#endif // __ARCH_X86_FAULTS_HH__ 4088199SAli.Saidi@ARM.com