using namespace AlphaISA;
 
-Fault
-SimpleThread::hwrei()
-{
-    if (!(readPC() & 0x3))
-        return new UnimplementedOpcodeFault;
-
-    setNextPC(readMiscRegNoEffect(IPR_EXC_ADDR));
-
-    if (!misspeculating()) {
-        if (kernelStats)
-            kernelStats->hwrei();
-    }
-
-    // FIXME: XXX check for interrupts? XXX
-    return NoFault;
-}
-
 /**
  * Check for special simulator handling of specific PAL calls.
  * If return value is false, actual PAL call will be suppressed.
 
     format BasicOperate {
         0x1e: decode PALMODE {
             0: OpcdecFault::hw_rei();
-            1:hw_rei({{ xc->hwrei(); }}, IsSerializing, IsSerializeBefore);
+            1: hw_rei({{
+                NPC = ExcAddr;
+                ThreadContext * tc = xc->tcBase();
+                if (!tc->misspeculating()) {
+                    AlphaISA::Kernel::Statistics * kernelStats =
+                        tc->getKernelStats();
+                    if (kernelStats)
+                        kernelStats->hwrei();
+                }
+            }}, IsSerializing, IsSerializeBefore);
         }
 
         // M5 special opcodes use the reserved 0x01 opcode space
 
 #include <math.h>
 
 #if FULL_SYSTEM
+#include "arch/alpha/kernel_stats.hh"
 #include "sim/pseudo_inst.hh"
 #endif
 #include "arch/alpha/ipr.hh"
     'Runiq': ('ControlReg', 'uq', 'MISCREG_UNIQ', None, 1),
     'FPCR':  ('ControlReg', 'uq', 'MISCREG_FPCR', None, 1),
     'IntrFlag': ('ControlReg', 'uq', 'MISCREG_INTR', None, 1),
+    'ExcAddr': ('ControlReg', 'uq', 'IPR_EXC_ADDR', None, 1),
     # The next two are hacks for non-full-system call-pal emulation
     'R0':  ('IntReg', 'uq', '0', None, 1),
     'R16': ('IntReg', 'uq', '16', None, 1),
 
     void translateDataReadReq(Request *req);
 
 #if FULL_SYSTEM
-    Fault hwrei() { return thread->hwrei(); }
     void ev5_trap(Fault fault) { fault->invoke(tc); }
     bool simPalCheck(int palFunc) { return thread->simPalCheck(palFunc); }
 #else
 
     void writeHint(Addr addr, int size, unsigned flags);
 
 #if FULL_SYSTEM
-    /** Somewhat Alpha-specific function that handles returning from
-     * an error or interrupt. */
-    Fault hwrei();
-
     /**
      * Check for special simulator handling of specific PAL calls.  If
      * return value is false, actual PAL call will be suppressed.
 
     }
 }
 
-template <class Impl>
-Fault
-FullO3CPU<Impl>::hwrei(unsigned tid)
-{
-#if THE_ISA == ALPHA_ISA
-    // Need to clear the lock flag upon returning from an interrupt.
-    this->setMiscRegNoEffect(AlphaISA::MISCREG_LOCKFLAG, false, tid);
-
-    this->thread[tid]->kernelStats->hwrei();
-
-    // FIXME: XXX check for interrupts? XXX
-#endif
-    return NoFault;
-}
-
 template <class Impl>
 bool
 FullO3CPU<Impl>::simPalCheck(int palFunc, unsigned tid)
 
     /** Posts an interrupt. */
     void post_interrupt(int int_num, int index);
 
-    /** HW return from error interrupt. */
-    Fault hwrei(unsigned tid);
-
     bool simPalCheck(int palFunc, unsigned tid);
 
     /** Returns the Fault for any valid interrupt. */
 
     }
 
 #if FULL_SYSTEM
-    /** Calls hardware return from error interrupt. */
-    Fault hwrei();
     /** Traps to handle specified fault. */
     void trap(Fault fault);
     bool simPalCheck(int palFunc);
 
 }
 
 #if FULL_SYSTEM
-template <class Impl>
-Fault
-BaseO3DynInst<Impl>::hwrei()
-{
-#if THE_ISA == ALPHA_ISA
-    // Can only do a hwrei when in pal mode.
-    if (!(this->readPC() & 0x3))
-        return new AlphaISA::UnimplementedOpcodeFault;
-
-    // Set the next PC based on the value of the EXC_ADDR IPR.
-    this->setNextPC(this->cpu->readMiscRegNoEffect(AlphaISA::IPR_EXC_ADDR,
-                                           this->threadNumber));
-
-    // Tell CPU to clear any state it needs to if a hwrei is taken.
-    this->cpu->hwrei(this->threadNumber);
-#else
-
-#endif
-    // FIXME: XXX check for interrupts? XXX
-    return NoFault;
-}
-
 template <class Impl>
 void
 BaseO3DynInst<Impl>::trap(Fault fault)
 
     void dumpInsts() { frontEnd->dumpInsts(); }
 
 #if FULL_SYSTEM
-    Fault hwrei();
     bool simPalCheck(int palFunc);
     void processInterrupts();
 #else
 
     }
 }
 #else
-template <class Impl>
-Fault
-OzoneCPU<Impl>::hwrei()
-{
-    // Need to move this to ISA code
-    // May also need to make this per thread
-
-    lockFlag = false;
-    lockAddrList.clear();
-    thread.kernelStats->hwrei();
-
-    // FIXME: XXX check for interrupts? XXX
-    return NoFault;
-}
-
 template <class Impl>
 void
 OzoneCPU<Impl>::processInterrupts()
 
     void setMiscReg(int misc_reg, const MiscReg &val);
 
 #if FULL_SYSTEM
-    Fault hwrei();
     void trap(Fault fault);
     bool simPalCheck(int palFunc);
 #else
 
 
 #if FULL_SYSTEM
 
-template <class Impl>
-Fault
-OzoneDynInst<Impl>::hwrei()
-{
-    if (!(this->readPC() & 0x3))
-        return new AlphaISA::UnimplementedOpcodeFault;
-
-    this->setNextPC(this->thread->readMiscRegNoEffect(AlphaISA::IPR_EXC_ADDR));
-
-    this->cpu->hwrei();
-
-    // FIXME: XXX check for interrupts? XXX
-    return NoFault;
-}
-
 template <class Impl>
 void
 OzoneDynInst<Impl>::trap(Fault fault)
 
     //Fault CacheOp(uint8_t Op, Addr EA);
 
 #if FULL_SYSTEM
-    Fault hwrei() { return thread->hwrei(); }
     void ev5_trap(Fault fault) { fault->invoke(tc); }
     bool simPalCheck(int palFunc) { return thread->simPalCheck(palFunc); }
 #else
 
 
     void dumpFuncProfile();
 
-    Fault hwrei();
-
     bool simPalCheck(int palFunc);
 
 #endif