From f3b87e3d02aaac272299b5773637c17d10935ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Peixoto?= Date: Thu, 19 Sep 2024 14:31:12 +0100 Subject: [PATCH] feat(arch/exception_handler): enable exception handlers to suspend vCPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented support for abort and exception handlers to suspend the current vCPU based on the vCPU active flag. Signed-off-by: João Peixoto --- src/arch/armv8/aborts.c | 3 +++ src/arch/riscv/sync_exceptions.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/arch/armv8/aborts.c b/src/arch/armv8/aborts.c index 2bf440c2a..857396966 100644 --- a/src/arch/armv8/aborts.c +++ b/src/arch/armv8/aborts.c @@ -195,6 +195,9 @@ void aborts_sync_handler(void) abort_handler_t handler = abort_handlers[ec]; if (handler) { handler(iss, ipa_fault_addr, il, ec); + if (cpu()->vcpu->active == false) { + cpu_idle(); + } } else { ERROR("no handler for abort ec = 0x%x", ec); // unknown guest exception } diff --git a/src/arch/riscv/sync_exceptions.c b/src/arch/riscv/sync_exceptions.c index d685f3490..36d8a60f8 100644 --- a/src/arch/riscv/sync_exceptions.c +++ b/src/arch/riscv/sync_exceptions.c @@ -153,4 +153,7 @@ void sync_exception_handler(void) } vcpu_writepc(cpu()->vcpu, vcpu_readpc(cpu()->vcpu) + pc_step); + if (cpu()->vcpu->active == false) { + cpu_idle(); + } }