mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 09:47:44 +00:00
hv: use vcpu_affinity[] in vm_config to support vcpu assignment
Add this vcpu_affinity[] for each VM to indicate the assignment policy. With it, pcpu_bitmap is not needed, so remove it from vm_config. Instead, vcpu_affinity is a must for each VM. This patch also add some sanitize check of vcpu_affinity[]. Here are some rules: 1) only one bit can be set for each vcpu_affinity of vcpu. 2) two vcpus in same VM cannot be set with same vcpu_affinity. 3) vcpu_affinity cannot be set to the pcpu which used by pre-launched VM. v4: config SDC with CONFIG_MAX_KATA_VM_NUM v5: config SDC with CONFIG_MAX_PCPU_NUM Tracked-On: #3663 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Signed-off-by: Yu Wang <yu1.wang@intel.com> Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
committed by
ACRN System Integration
parent
ca2540fe8c
commit
1c526e6d16
@@ -187,7 +187,6 @@ static inline void wait_for_other_vm_shutdown(const struct acrn_vm *self_vm)
|
||||
static inline void enter_s5(const struct acrn_vm *vm, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val)
|
||||
{
|
||||
wait_for_other_vm_shutdown(vm);
|
||||
pr_err("yfwyfw: before enter s5");
|
||||
host_enter_s5(vm->pm.sx_state_data, pm1a_cnt_val, pm1b_cnt_val);
|
||||
}
|
||||
|
||||
|
@@ -177,7 +177,7 @@ static inline uint16_t get_vm_bsp_pcpu_id(const struct acrn_vm_config *vm_config
|
||||
{
|
||||
uint16_t cpu_id = INVALID_CPU_ID;
|
||||
|
||||
cpu_id = ffs64(vm_config->pcpu_bitmap);
|
||||
cpu_id = ffs64(vm_config->vcpu_affinity[0]);
|
||||
|
||||
return (cpu_id < get_pcpu_nums()) ? cpu_id : INVALID_CPU_ID;
|
||||
}
|
||||
@@ -724,18 +724,17 @@ void resume_vm_from_s3(struct acrn_vm *vm, uint32_t wakeup_vec)
|
||||
void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
|
||||
{
|
||||
int32_t err = 0;
|
||||
uint16_t i;
|
||||
uint16_t i, pcpu_id;
|
||||
struct acrn_vm *vm = NULL;
|
||||
|
||||
err = create_vm(vm_id, vm_config, &vm);
|
||||
|
||||
if (err == 0) {
|
||||
for (i = 0U; i < get_pcpu_nums(); i++) {
|
||||
if (bitmap_test(i, &vm_config->pcpu_bitmap)) {
|
||||
err = prepare_vcpu(vm, i);
|
||||
if (err != 0) {
|
||||
break;
|
||||
}
|
||||
for (i = 0U; i < vm_config->vcpu_num; i++) {
|
||||
pcpu_id = ffs64(vm_config->vcpu_affinity[i]);
|
||||
err = prepare_vcpu(vm, pcpu_id);
|
||||
if (err != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user