From 1a5bc2aae14cc7668eebe9fd6b98ae0251a0868a Mon Sep 17 00:00:00 2001 From: Yifan Liu Date: Mon, 20 Oct 2025 09:31:31 +0000 Subject: [PATCH] hv: vcpu: Move launch_vcpu to common scope Tracked-On: #8830 Signed-off-by: Yifan Liu Reviewed-by: Fei Li Acked-by: Wang Yu1 --- hypervisor/arch/x86/guest/vcpu.c | 15 --------------- hypervisor/common/vcpu.c | 11 +++++++++++ hypervisor/include/arch/x86/asm/guest/vcpu.h | 11 ----------- hypervisor/include/common/vcpu.h | 11 +++++++++++ 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index 6529a1522..980ef5030 100755 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -910,21 +910,6 @@ void arch_context_switch_in(struct thread_object *next) rstore_xsave_area(vcpu, ectx); } - -/** - * @pre vcpu != NULL - * @pre vcpu->state == VCPU_INIT - */ -void launch_vcpu(struct acrn_vcpu *vcpu) -{ - uint16_t pcpu_id = pcpuid_from_vcpu(vcpu); - - pr_dbg("vcpu%hu scheduled on pcpu%hu", vcpu->vcpu_id, pcpu_id); - vcpu_set_state(vcpu, VCPU_RUNNING); - wake_thread(&vcpu->thread_obj); - -} - /** * @pre vcpu != NULL */ diff --git a/hypervisor/common/vcpu.c b/hypervisor/common/vcpu.c index 42ea93da0..b60c38832 100644 --- a/hypervisor/common/vcpu.c +++ b/hypervisor/common/vcpu.c @@ -147,3 +147,14 @@ void destroy_vcpu(struct acrn_vcpu *vcpu) vcpu_set_state(vcpu, VCPU_OFFLINE); } + +void launch_vcpu(struct acrn_vcpu *vcpu) +{ + uint16_t pcpu_id = pcpuid_from_vcpu(vcpu); + + pr_dbg("vcpu%hu scheduled on pcpu%hu", vcpu->vcpu_id, pcpu_id); + + vcpu_set_state(vcpu, VCPU_RUNNING); + + wake_thread(&vcpu->thread_obj); +} diff --git a/hypervisor/include/arch/x86/asm/guest/vcpu.h b/hypervisor/include/arch/x86/asm/guest/vcpu.h index 8a6c6993e..2653e2f11 100644 --- a/hypervisor/include/arch/x86/asm/guest/vcpu.h +++ b/hypervisor/include/arch/x86/asm/guest/vcpu.h @@ -571,17 +571,6 @@ void reset_vcpu(struct acrn_vcpu *vcpu, enum reset_mode mode); */ void zombie_vcpu(struct acrn_vcpu *vcpu, enum vcpu_state new_state); -/** - * @brief set the vcpu to running state, then it will be scheculed. - * - * Adds a vCPU into the run queue and make a reschedule request for it. It sets the vCPU state to VCPU_RUNNING. - * - * @param[inout] vcpu pointer to vcpu data structure - * @pre vcpu != NULL - * @pre vcpu->state == VCPU_INIT - */ -void launch_vcpu(struct acrn_vcpu *vcpu); - /** * @brief kick the vcpu and let it handle pending events * diff --git a/hypervisor/include/common/vcpu.h b/hypervisor/include/common/vcpu.h index 0ddeb26a5..9908c4841 100644 --- a/hypervisor/include/common/vcpu.h +++ b/hypervisor/include/common/vcpu.h @@ -129,6 +129,17 @@ int32_t create_vcpu(struct acrn_vm *vm, uint16_t pcpu_id); */ void destroy_vcpu(struct acrn_vcpu *vcpu); +/** + * @brief set the vcpu to running state, then it will be scheculed. + * + * Adds a vCPU into the run queue and make a reschedule request for it. It sets the vCPU state to VCPU_RUNNING. + * + * @param[inout] vcpu pointer to vcpu data structure + * @pre vcpu != NULL + * @pre vcpu->state == VCPU_INIT + */ +void launch_vcpu(struct acrn_vcpu *vcpu); + /** * @} */