From cb10dc7e73b7874bd7cf8e6b0d7794e8c7156a29 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Tue, 9 Apr 2019 15:40:24 +0800 Subject: [PATCH] HV: return bool in sanitize_vm_config Return true if vm configs is sanitized successfully, otherwise return false; Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/arch/x86/configs/vm_config.c | 16 ++++++++-------- hypervisor/arch/x86/cpu.c | 2 +- hypervisor/include/arch/x86/vm_config.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) 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];