hv: vCAT: initialize the emulated_guest_msrs array for CAT msrs during platform initialization

Initialize the emulated_guest_msrs[] array at runtime for
MSR_IA32_type_MASK_n and MSR_IA32_PQR_ASSOC msrs, there is no good
way to do this initialization statically at build time

Tracked-On: #5917
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2021-08-19 11:03:13 -07:00
committed by wenlingz
parent cb2bb78b6f
commit 39461ef9dd
4 changed files with 113 additions and 3 deletions

View File

@@ -29,6 +29,7 @@
#include <asm/guest/instr_emul.h>
#include <asm/guest/nested.h>
#include <asm/vmx.h>
#include <asm/vm_config.h>
/**
* @brief vcpu
@@ -173,11 +174,29 @@ enum reset_mode;
#define NUM_WORLD_MSRS 2U
#define NUM_COMMON_MSRS 23U
#ifdef CONFIG_VCAT_ENABLED
#define NUM_VCAT_L2_MSRS MAX_CACHE_CLOS_NUM_ENTRIES
#define NUM_VCAT_L3_MSRS MAX_CACHE_CLOS_NUM_ENTRIES
/* L2/L3 mask MSRs plus MSR_IA32_PQR_ASSOC */
#define NUM_VCAT_MSRS (NUM_VCAT_L2_MSRS + NUM_VCAT_L3_MSRS + 1U)
#ifdef CONFIG_NVMX_ENABLED
#define NUM_GUEST_MSRS (NUM_WORLD_MSRS + NUM_COMMON_MSRS + NUM_VMX_MSRS)
#define CAT_MSR_START_INDEX (NUM_WORLD_MSRS + NUM_COMMON_MSRS + NUM_VMX_MSRS)
#else
#define NUM_GUEST_MSRS (NUM_WORLD_MSRS + NUM_COMMON_MSRS)
#define CAT_MSR_START_INDEX (NUM_WORLD_MSRS + NUM_COMMON_MSRS)
#endif
#else
#define NUM_VCAT_MSRS 0U
#endif
/* For detailed layout of the emulated guest MSRs, see emulated_guest_msrs[NUM_GUEST_MSRS] in vmsr.c */
#ifdef CONFIG_NVMX_ENABLED
#define NUM_GUEST_MSRS (NUM_WORLD_MSRS + NUM_COMMON_MSRS + NUM_VMX_MSRS + NUM_VCAT_MSRS)
#else
#define NUM_GUEST_MSRS (NUM_WORLD_MSRS + NUM_COMMON_MSRS + NUM_VCAT_MSRS)
#endif
#define EOI_EXIT_BITMAP_SIZE 256U

View File

@@ -617,6 +617,7 @@ static inline bool is_x2apic_msr(uint32_t msr)
struct acrn_vcpu;
void init_msr_emulation(struct acrn_vcpu *vcpu);
void init_intercepted_cat_msr_list(void);
uint32_t vmsr_get_guest_msr_index(uint32_t msr);
void update_msr_bitmap_x2apic_apicv(struct acrn_vcpu *vcpu);
void update_msr_bitmap_x2apic_passthru(struct acrn_vcpu *vcpu);