From fb82f3b931f8947eceabca201dc1dbab01f2e886 Mon Sep 17 00:00:00 2001 From: Haicheng Li Date: Tue, 2 Sep 2025 10:35:25 +0800 Subject: [PATCH] hv: implement cpu dead and cpu idle for riscv implement arch_cpu_dead and arch_cpu_do_idle for riscv, arch_cpu_dead and arch_cpu_do_idle will be called by common module. Tracked-On: #8812 Signed-off-by: Haicheng Li Signed-off-by: Xue Bosheng Acked-by: Wang, Yu1 --- hypervisor/arch/riscv/cpu.c | 14 ++++++++++++++ hypervisor/include/arch/riscv/asm/cpu.h | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hypervisor/arch/riscv/cpu.c b/hypervisor/arch/riscv/cpu.c index af7be2c5a..10ee0477c 100644 --- a/hypervisor/arch/riscv/cpu.c +++ b/hypervisor/arch/riscv/cpu.c @@ -15,6 +15,7 @@ #include #include #include +#include /* * This array contains the hart IDs for each physial cpu. @@ -114,3 +115,16 @@ void arch_start_pcpu(uint16_t pcpu_id) pr_fatal("Failed to start cpu%hu by SBI HSM", pcpu_id); } } + +void arch_cpu_do_idle(void) +{ + asm volatile ("wfi"::); +} + +/** + * FIXME: This is a temp solution for now. The formal solution should clear up and put pcpu into a low power state. + */ +void arch_cpu_dead(void) +{ + while (true) {}; +} diff --git a/hypervisor/include/arch/riscv/asm/cpu.h b/hypervisor/include/arch/riscv/asm/cpu.h index cb2c75e1b..fdfe908cc 100644 --- a/hypervisor/include/arch/riscv/asm/cpu.h +++ b/hypervisor/include/arch/riscv/asm/cpu.h @@ -108,14 +108,6 @@ struct stack_frame { /* Define CPU stack alignment */ #define CPU_STACK_ALIGN 16UL -/** - * FIXME: This is a temp solution for now. The formal solution should clear up and put pcpu into a low power state. - */ -static inline void cpu_dead(void) -{ - while (true) {}; -} - /* In ACRN, struct per_cpu_region is a critical data structure * containing key per-CPU data frequently accessed via get_cpu_var(). * We use the tp register to store the current logical pCPU ID to