diff --git a/thermosphere/src/exceptions.c b/thermosphere/src/exceptions.c index c92194f29..8d107ff21 100644 --- a/thermosphere/src/exceptions.c +++ b/thermosphere/src/exceptions.c @@ -127,21 +127,24 @@ void exceptionEntryPostprocess(ExceptionStackFrame *frame, bool isLowerEl) // Called on exception return (avoids overflowing a vector section) void exceptionReturnPreprocess(ExceptionStackFrame *frame) { - if (currentCoreCtx->wasPaused && frame == currentCoreCtx->guestFrame) { - // Were we paused & are we about to return to the guest? - exceptionEnterInterruptibleHypervisorCode(); - while (!debugManagerHandlePause()); - fpuCleanInvalidateRegisterCache(); - } - - // Update virtual counter - currentCoreCtx->totalTimeInHypervisor += timerGetSystemTick() - frame->cntpct_el0; - SET_SYSREG(cntvoff_el2, currentCoreCtx->totalTimeInHypervisor); - if (frame == currentCoreCtx->guestFrame) { - // Restore interrupt mask - SET_SYSREG(cntp_ctl_el0, frame->cntp_ctl_el0); - SET_SYSREG(cntv_ctl_el0, frame->cntv_ctl_el0); + if (currentCoreCtx->wasPaused) { + // Were we paused & are we about to return to the guest? + exceptionEnterInterruptibleHypervisorCode(); + while (!debugManagerHandlePause()); + fpuCleanInvalidateRegisterCache(); + } + + // Update virtual counter + u64 ticksNow = timerGetSystemTick(); + currentCoreCtx->totalTimeInHypervisor += ticksNow - frame->cntpct_el0; + SET_SYSREG(cntvoff_el2, currentCoreCtx->totalTimeInHypervisor); + + if (frame == currentCoreCtx->guestFrame) { + // Restore interrupt mask + SET_SYSREG(cntp_ctl_el0, frame->cntp_ctl_el0); + SET_SYSREG(cntv_ctl_el0, frame->cntv_ctl_el0); + } } } diff --git a/thermosphere/src/irq.c b/thermosphere/src/irq.c index bc73f6156..9f1b69141 100644 --- a/thermosphere/src/irq.c +++ b/thermosphere/src/irq.c @@ -206,7 +206,7 @@ void handleIrqException(ExceptionStackFrame *frame, bool isLowerEl, bool isA32) u32 irqId = iar & 0x3FF; u32 srcCore = (iar >> 10) & 7; - DEBUG("EL2 [core %d]: Received irq %x\n", (int)currentCoreCtx->coreId, irqId); + //DEBUG("EL2 [core %d]: Received irq %x\n", (int)currentCoreCtx->coreId, irqId); if (irqId == GIC_IRQID_SPURIOUS) { // Spurious interrupt received