diff --git a/hypervisor/arch/x86/configs/vm_config.c b/hypervisor/arch/x86/configs/vm_config.c index 77a96a621..b357e9d73 100644 --- a/hypervisor/arch/x86/configs/vm_config.c +++ b/hypervisor/arch/x86/configs/vm_config.c @@ -23,9 +23,9 @@ struct acrn_vm_config *get_vm_config(uint16_t vm_id) /** * @pre vm_config != NULL */ -int32_t sanitize_vm_config(void) +bool sanitize_vm_config(void) { - int32_t ret = 0; + bool ret = true; uint16_t vm_id; uint64_t sos_pcpu_bitmap, pre_launch_pcpu_bitmap; struct acrn_vm_config *vm_config; @@ -43,11 +43,11 @@ int32_t sanitize_vm_config(void) switch (vm_config->type) { case PRE_LAUNCHED_VM: if (vm_config->pcpu_bitmap == 0U) { - ret = -EINVAL; + ret = false; /* GUEST_FLAG_RT must be set if we have GUEST_FLAG_LAPIC_PASSTHROUGH set in guest_flags */ } else if (((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U) && ((vm_config->guest_flags & GUEST_FLAG_RT) == 0U)) { - ret = -EINVAL; + ret = false; } else { pre_launch_pcpu_bitmap |= vm_config->pcpu_bitmap; } @@ -56,13 +56,13 @@ int32_t sanitize_vm_config(void) /* Deduct pcpus of PRE_LAUNCHED_VMs */ sos_pcpu_bitmap ^= pre_launch_pcpu_bitmap; if ((sos_pcpu_bitmap == 0U) || ((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)) { - ret = -EINVAL; + ret = false; } else { vm_config->pcpu_bitmap = sos_pcpu_bitmap; } break; case NORMAL_VM: - ret = -EINVAL; + ret = false; break; default: /* Nothing to do for a UNDEFINED_VM, break directly. */ @@ -74,11 +74,11 @@ int32_t sanitize_vm_config(void) cat_cap_info.enabled = true; } else { pr_err("%s set wrong CLOS or CAT is not supported\n", __func__); - ret = -EINVAL; + ret = false; } } - if (ret != 0) { + if (!ret) { break; } } diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 1a4966e87..d6546419f 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -198,7 +198,7 @@ void init_cpu_post(uint16_t pcpu_id) panic("hardware not support!"); } - if (sanitize_vm_config() != 0) { + if (!sanitize_vm_config()) { panic("VM Configuration Error!"); } diff --git a/hypervisor/include/arch/x86/vm_config.h b/hypervisor/include/arch/x86/vm_config.h index faa8728a5..d97f74c6e 100644 --- a/hypervisor/include/arch/x86/vm_config.h +++ b/hypervisor/include/arch/x86/vm_config.h @@ -63,7 +63,7 @@ struct acrn_vm_config { } __aligned(8); struct acrn_vm_config *get_vm_config(uint16_t vm_id); -int32_t sanitize_vm_config(void); +bool sanitize_vm_config(void); extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM];