From ed32cf6328c42c03098d40b725ed769adfe733e1 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Sun, 9 May 2021 03:15:25 +0900 Subject: [PATCH] hv_exc: Add a hacky STEP feature to interrupt guest after a while This should eventually be a proper single step feature or something, but for now... Signed-off-by: Hector Martin --- proxyclient/proxy.py | 1 + src/hv_exc.c | 5 +++++ src/uartproxy.h | 1 + 3 files changed, 7 insertions(+) diff --git a/proxyclient/proxy.py b/proxyclient/proxy.py index b2a35f5c..269b41ba 100755 --- a/proxyclient/proxy.py +++ b/proxyclient/proxy.py @@ -91,6 +91,7 @@ class EXC_RET(IntEnum): UNHANDLED = 1 HANDLED = 2 EXIT_GUEST = 3 + STEP = 4 ExcInfo = Struct( "spsr" / RegAdapter(SPSR), diff --git a/src/hv_exc.c b/src/hv_exc.c index ea4cf7b6..1bee983d 100644 --- a/src/hv_exc.c +++ b/src/hv_exc.c @@ -35,12 +35,17 @@ static void hv_exc_proxy(u64 *regs, uartproxy_exc_code_t type) int ret = uartproxy_run(&start); switch (ret) { + case EXC_RET_STEP: case EXC_RET_HANDLED: memcpy(regs, exc_info.regs, sizeof(exc_info.regs)); msr(SPSR_EL2, exc_info.spsr); msr(ELR_EL2, exc_info.elr); msr(SP_EL0, exc_info.sp[0]); msr(SP_EL1, exc_info.sp[1]); + if (ret == EXC_RET_STEP) { + msr(CNTV_TVAL_EL0, 256); + msr(CNTV_CTL_EL0, 1); + } return; case EXC_EXIT_GUEST: hv_exit_guest(); diff --git a/src/uartproxy.h b/src/uartproxy.h index 65121d25..f19ce4ef 100644 --- a/src/uartproxy.h +++ b/src/uartproxy.h @@ -24,6 +24,7 @@ typedef enum _uartproxy_exc_ret_t { EXC_RET_UNHANDLED = 1, EXC_RET_HANDLED = 2, EXC_EXIT_GUEST = 3, + EXC_RET_STEP = 4, } uartproxy_exc_ret_t; struct uartproxy_exc_info {