diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index f197275bc..4a60f8326 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -213,6 +213,16 @@ bool is_static_configured_vm(const struct acrn_vm *vm) return ((vm_config->guest_flags & GUEST_FLAG_STATIC_VM) != 0U); } +/** + * @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM + */ +bool is_vhwp_configured(const struct acrn_vm *vm) +{ + struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id); + + return ((vm_config->guest_flags & GUEST_FLAG_VHWP) != 0U); +} + /** * @brief VT-d PI posted mode can possibly be used for PTDEVs assigned * to this VM if platform supports VT-d PI AND lapic passthru is not configured diff --git a/hypervisor/include/arch/x86/asm/guest/vm.h b/hypervisor/include/arch/x86/asm/guest/vm.h index d26869bb9..de7cd090c 100644 --- a/hypervisor/include/arch/x86/asm/guest/vm.h +++ b/hypervisor/include/arch/x86/asm/guest/vm.h @@ -274,6 +274,7 @@ struct acrn_vm *get_highest_severity_vm(bool runtime); bool vm_hide_mtrr(const struct acrn_vm *vm); void update_vm_vlapic_state(struct acrn_vm *vm); enum vm_vlapic_mode check_vm_vlapic_mode(const struct acrn_vm *vm); +bool is_vhwp_configured(const struct acrn_vm *vm); /* * @pre vm != NULL */ diff --git a/hypervisor/include/public/acrn_common.h b/hypervisor/include/public/acrn_common.h index 736e3c891..3c6e4e87a 100644 --- a/hypervisor/include/public/acrn_common.h +++ b/hypervisor/include/public/acrn_common.h @@ -63,7 +63,7 @@ #define GUEST_FLAG_TEE (1UL << 9U) /* Whether the VM is TEE VM */ #define GUEST_FLAG_REE (1UL << 10U) /* Whether the VM is REE VM */ #define GUEST_FLAG_PMU_PASSTHROUGH (1UL << 11U) /* Whether PMU is passed through */ - +#define GUEST_FLAG_VHWP (1UL << 12U) /* Whether the VM supports vHWP */ /* TODO: We may need to get this addr from guest ACPI instead of hardcode here */ #define VIRTUAL_SLEEP_CTL_ADDR 0x400U /* Pre-launched VM uses ACPI reduced HW mode and sleep control register */