From 2f54a1862e527e369930cb921526aa07780d44ef Mon Sep 17 00:00:00 2001 From: Helmut Buchsbaum Date: Fri, 25 Sep 2020 08:56:11 +0200 Subject: [PATCH] hv: hypercall: return 0 for empty PX or CX tables Avoid failing hypercalls by returning 0 for empty PX and CX tables on HC_PM_GET_CPU_STATE/PMCMD_GET_PX_CNT and HC_PM_GET_CPU_STATE/PMCMD_GET_CX_CNT. Tracked-On: #6848 Signed-off-by: Helmut Buchsbaum Acked-by: Anthony Xu Acked-by: Eddie Dong --- hypervisor/common/hypercall.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 6fc18a671..f2b6cc92c 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -1096,9 +1096,7 @@ int32_t hcall_get_cpu_pm_state(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm if (is_created_vm(target_vm)) { switch (cmd & PMCMD_TYPE_MASK) { case ACRN_PMCMD_GET_PX_CNT: { - if (target_vm->pm.px_cnt != 0U) { - ret = copy_to_gpa(vm, &(target_vm->pm.px_cnt), param2, sizeof(target_vm->pm.px_cnt)); - } + ret = copy_to_gpa(vm, &(target_vm->pm.px_cnt), param2, sizeof(target_vm->pm.px_cnt)); break; } case ACRN_PMCMD_GET_PX_DATA: { @@ -1123,9 +1121,7 @@ int32_t hcall_get_cpu_pm_state(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm break; } case ACRN_PMCMD_GET_CX_CNT: { - if (target_vm->pm.cx_cnt != 0U) { - ret = copy_to_gpa(vm, &(target_vm->pm.cx_cnt), param2, sizeof(target_vm->pm.cx_cnt)); - } + ret = copy_to_gpa(vm, &(target_vm->pm.cx_cnt), param2, sizeof(target_vm->pm.cx_cnt)); break; } case ACRN_PMCMD_GET_CX_DATA: {