mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-03 01:06:53 +00:00
HV:fix vcpu more than one return entry
ACRN coding guideline requires function shall have only one return entry. Fix it. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
198e01716a
commit
74b788988d
@ -349,11 +349,7 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
|
||||
* vm->hw.created_vcpus++;
|
||||
*/
|
||||
vcpu_id = atomic_xadd16(&vm->hw.created_vcpus, 1U);
|
||||
if (vcpu_id >= CONFIG_MAX_VCPUS_PER_VM) {
|
||||
vm->hw.created_vcpus--;
|
||||
pr_err("%s, vcpu id is invalid!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (vcpu_id < CONFIG_MAX_VCPUS_PER_VM) {
|
||||
/* Allocate memory for VCPU */
|
||||
vcpu = &(vm->hw.vcpu_array[vcpu_id]);
|
||||
(void)memset((void *)vcpu, 0U, sizeof(struct acrn_vcpu));
|
||||
@ -406,14 +402,20 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
|
||||
*rtn_vcpu_handle = vcpu;
|
||||
|
||||
vcpu->launched = false;
|
||||
vcpu->running = 0;
|
||||
vcpu->arch.nr_sipi = 0;
|
||||
vcpu->running = 0U;
|
||||
vcpu->arch.nr_sipi = 0U;
|
||||
vcpu->state = VCPU_INIT;
|
||||
|
||||
reset_vcpu_regs(vcpu);
|
||||
(void)memset(&vcpu->req, 0U, sizeof(struct io_request));
|
||||
(void)memset((void *)&vcpu->req, 0U, sizeof(struct io_request));
|
||||
ret = 0;
|
||||
} else {
|
||||
vm->hw.created_vcpus -= 1U;
|
||||
pr_err("%s, vcpu id is invalid!\n", __func__);
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -561,14 +563,12 @@ void reset_vcpu(struct acrn_vcpu *vcpu)
|
||||
ASSERT(vcpu->state != VCPU_RUNNING,
|
||||
"reset vcpu when it's running");
|
||||
|
||||
if (vcpu->state == VCPU_INIT)
|
||||
return;
|
||||
|
||||
if (vcpu->state != VCPU_INIT) {
|
||||
vcpu->state = VCPU_INIT;
|
||||
|
||||
vcpu->launched = false;
|
||||
vcpu->running = 0;
|
||||
vcpu->arch.nr_sipi = 0;
|
||||
vcpu->running = 0U;
|
||||
vcpu->arch.nr_sipi = 0U;
|
||||
|
||||
vcpu->arch.exception_info.exception = VECTOR_INVALID;
|
||||
vcpu->arch.cur_context = NORMAL_WORLD;
|
||||
@ -586,6 +586,7 @@ void reset_vcpu(struct acrn_vcpu *vcpu)
|
||||
vlapic_reset(vlapic);
|
||||
|
||||
reset_vcpu_regs(vcpu);
|
||||
}
|
||||
}
|
||||
|
||||
void pause_vcpu(struct acrn_vcpu *vcpu, enum vcpu_state new_state)
|
||||
@ -699,17 +700,14 @@ static uint64_t build_stack_frame(struct acrn_vcpu *vcpu)
|
||||
/* help function for vcpu create */
|
||||
int32_t prepare_vcpu(struct acrn_vm *vm, uint16_t pcpu_id)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
int32_t ret;
|
||||
struct acrn_vcpu *vcpu = NULL;
|
||||
char thread_name[16];
|
||||
uint64_t orig_val, final_val;
|
||||
struct acrn_vm_config *conf;
|
||||
|
||||
ret = create_vcpu(pcpu_id, vm, &vcpu);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
set_pcpu_used(pcpu_id);
|
||||
|
||||
/* Update CLOS for this CPU */
|
||||
@ -727,6 +725,7 @@ int32_t prepare_vcpu(struct acrn_vm *vm, uint16_t pcpu_id)
|
||||
vcpu->sched_obj.host_sp = build_stack_frame(vcpu);
|
||||
vcpu->sched_obj.prepare_switch_out = context_switch_out;
|
||||
vcpu->sched_obj.prepare_switch_in = context_switch_in;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user