diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index b59f7e510..fb699b9f8 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -146,6 +146,17 @@ bool is_lapic_pt_configured(const struct acrn_vm *vm) return ((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U); } +/** + * @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM + */ +bool is_pmu_pt_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_PMU_PASSTHROUGH) != 0U); +} + + /** * @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM */ diff --git a/hypervisor/include/arch/x86/asm/guest/vm.h b/hypervisor/include/arch/x86/asm/guest/vm.h index aa22fc783..e12ec08fc 100644 --- a/hypervisor/include/arch/x86/asm/guest/vm.h +++ b/hypervisor/include/arch/x86/asm/guest/vm.h @@ -255,6 +255,7 @@ int32_t prepare_os_image(struct acrn_vm *vm); void vrtc_init(struct acrn_vm *vm); bool is_lapic_pt_configured(const struct acrn_vm *vm); +bool is_pmu_pt_configured(const struct acrn_vm *vm); bool is_rt_vm(const struct acrn_vm *vm); bool is_stateful_vm(const struct acrn_vm *vm); bool is_nvmx_configured(const struct acrn_vm *vm); diff --git a/hypervisor/include/arch/x86/asm/vm_config.h b/hypervisor/include/arch/x86/asm/vm_config.h index 102e6ac60..8477d02e9 100644 --- a/hypervisor/include/arch/x86/asm/vm_config.h +++ b/hypervisor/include/arch/x86/asm/vm_config.h @@ -59,7 +59,7 @@ #define DM_OWNED_GUEST_FLAG_MASK 0UL #else #define DM_OWNED_GUEST_FLAG_MASK (GUEST_FLAG_SECURE_WORLD_ENABLED | GUEST_FLAG_LAPIC_PASSTHROUGH \ - | GUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING) + | GUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING | GUEST_FLAG_PMU_PASSTHROUGH) #endif /* ACRN guest severity */ diff --git a/hypervisor/include/public/acrn_common.h b/hypervisor/include/public/acrn_common.h index 9961bfc1c..8c1d6c5c1 100644 --- a/hypervisor/include/public/acrn_common.h +++ b/hypervisor/include/public/acrn_common.h @@ -61,6 +61,8 @@ #define GUEST_FLAG_STATIC_VM (1UL << 8U) /* Whether this VM uses static VM configuration */ #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 */ + /* 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 */