From 972cdeb3184046a0d3ca179617b860fc1254c9b8 Mon Sep 17 00:00:00 2001 From: Wu Zhou Date: Sun, 23 Apr 2023 16:39:02 +0800 Subject: [PATCH] hv: Write _CPC to guests' ACPI when VHWP is enabled When VHWP enabled, return 0 and px_cnt = 0 on ACRN_PMCMD_GET_PX_CNT, so that DM will write _CPC to guests' ACPI. Tracked-On: #8414 Signed-off-by: Wu Zhou Reviewed-by: Junjie Mao --- hypervisor/common/hypercall.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 5e296f710..a998f9044 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -1109,11 +1109,21 @@ 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 (!is_pt_pstate(target_vm)) { + uint8_t px_cnt; + /* If the VM supports vHWP, then the guest is having continuous p-state. Thus it doesn't have a specific + * px_cnt. The hypercall returns success and px_cnt = 0. + * If the VM's p-state is hidden or hv doesn't have its p-state info, the hypercall returns -1. + */ + if (is_vhwp_configured(target_vm)) { + px_cnt = 0U; + } else if (!is_pt_pstate(target_vm)) { break; + } else if (target_vm->pm.px_cnt == 0U) { + break; + } else { + px_cnt = target_vm->pm.px_cnt; } - - ret = copy_to_gpa(vm, &(target_vm->pm.px_cnt), param2, sizeof(target_vm->pm.px_cnt)); + ret = copy_to_gpa(vm, &px_cnt, param2, sizeof(px_cnt)); break; } case ACRN_PMCMD_GET_PX_DATA: {