Skip to content

Commit cb10dc7

Browse files
jsun26intelacrnsi
authored andcommitted
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 <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 6071234 commit cb10dc7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

hypervisor/arch/x86/configs/vm_config.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ struct acrn_vm_config *get_vm_config(uint16_t vm_id)
2323
/**
2424
* @pre vm_config != NULL
2525
*/
26-
int32_t sanitize_vm_config(void)
26+
bool sanitize_vm_config(void)
2727
{
28-
int32_t ret = 0;
28+
bool ret = true;
2929
uint16_t vm_id;
3030
uint64_t sos_pcpu_bitmap, pre_launch_pcpu_bitmap;
3131
struct acrn_vm_config *vm_config;
@@ -43,11 +43,11 @@ int32_t sanitize_vm_config(void)
4343
switch (vm_config->type) {
4444
case PRE_LAUNCHED_VM:
4545
if (vm_config->pcpu_bitmap == 0U) {
46-
ret = -EINVAL;
46+
ret = false;
4747
/* GUEST_FLAG_RT must be set if we have GUEST_FLAG_LAPIC_PASSTHROUGH set in guest_flags */
4848
} else if (((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)
4949
&& ((vm_config->guest_flags & GUEST_FLAG_RT) == 0U)) {
50-
ret = -EINVAL;
50+
ret = false;
5151
} else {
5252
pre_launch_pcpu_bitmap |= vm_config->pcpu_bitmap;
5353
}
@@ -56,13 +56,13 @@ int32_t sanitize_vm_config(void)
5656
/* Deduct pcpus of PRE_LAUNCHED_VMs */
5757
sos_pcpu_bitmap ^= pre_launch_pcpu_bitmap;
5858
if ((sos_pcpu_bitmap == 0U) || ((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)) {
59-
ret = -EINVAL;
59+
ret = false;
6060
} else {
6161
vm_config->pcpu_bitmap = sos_pcpu_bitmap;
6262
}
6363
break;
6464
case NORMAL_VM:
65-
ret = -EINVAL;
65+
ret = false;
6666
break;
6767
default:
6868
/* Nothing to do for a UNDEFINED_VM, break directly. */
@@ -74,11 +74,11 @@ int32_t sanitize_vm_config(void)
7474
cat_cap_info.enabled = true;
7575
} else {
7676
pr_err("%s set wrong CLOS or CAT is not supported\n", __func__);
77-
ret = -EINVAL;
77+
ret = false;
7878
}
7979
}
8080

81-
if (ret != 0) {
81+
if (!ret) {
8282
break;
8383
}
8484
}

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void init_cpu_post(uint16_t pcpu_id)
198198
panic("hardware not support!");
199199
}
200200

201-
if (sanitize_vm_config() != 0) {
201+
if (!sanitize_vm_config()) {
202202
panic("VM Configuration Error!");
203203
}
204204

hypervisor/include/arch/x86/vm_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct acrn_vm_config {
6363
} __aligned(8);
6464

6565
struct acrn_vm_config *get_vm_config(uint16_t vm_id);
66-
int32_t sanitize_vm_config(void);
66+
bool sanitize_vm_config(void);
6767

6868
extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM];
6969

0 commit comments

Comments
 (0)