mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-29 08:47:24 +00:00
hv: vcpu: operation in vcpu_create don't need to be atomic
For pre-launched VMs and SOS, vCPUs are created on BSP one by one; For post-launched VMs, vCPUs are created under vmm_hypercall_lock protection. So vcpu_create is called sequentially. Operation in vcpu_create don't need to be atomic. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
540841ac5d
commit
8af334cbb2
@ -362,7 +362,7 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
|
|||||||
* vcpu->vcpu_id = vm->hw.created_vcpus;
|
* vcpu->vcpu_id = vm->hw.created_vcpus;
|
||||||
* vm->hw.created_vcpus++;
|
* vm->hw.created_vcpus++;
|
||||||
*/
|
*/
|
||||||
vcpu_id = atomic_xadd16(&vm->hw.created_vcpus, 1U);
|
vcpu_id = vm->hw.created_vcpus;
|
||||||
if (vcpu_id < CONFIG_MAX_VCPUS_PER_VM) {
|
if (vcpu_id < CONFIG_MAX_VCPUS_PER_VM) {
|
||||||
/* Allocate memory for VCPU */
|
/* Allocate memory for VCPU */
|
||||||
vcpu = &(vm->hw.vcpu_array[vcpu_id]);
|
vcpu = &(vm->hw.vcpu_array[vcpu_id]);
|
||||||
@ -422,9 +422,9 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
|
|||||||
|
|
||||||
reset_vcpu_regs(vcpu);
|
reset_vcpu_regs(vcpu);
|
||||||
(void)memset((void *)&vcpu->req, 0U, sizeof(struct io_request));
|
(void)memset((void *)&vcpu->req, 0U, sizeof(struct io_request));
|
||||||
|
vm->hw.created_vcpus++;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
vm->hw.created_vcpus -= 1U;
|
|
||||||
pr_err("%s, vcpu id is invalid!\n", __func__);
|
pr_err("%s, vcpu id is invalid!\n", __func__);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user