1 /* 2 * Copyright (C) 2018-2022 Intel Corporation. 3 * SPDX-License-Identifier: BSD-3-Clause 4 */ 5 /** 6 * @file vmtrr.h 7 * 8 * @brief MTRR Virtualization 9 */ 10 #ifndef VMTRR_H 11 #define VMTRR_H 12 /** 13 * @brief MTRR Virtualization 14 * 15 * @addtogroup acrn_mem ACRN Memory Management 16 * @{ 17 */ 18 #define FIXED_RANGE_MTRR_NUM 11U 19 #define MTRR_SUB_RANGE_NUM 8U 20 21 union mtrr_cap_reg { 22 uint64_t value; 23 struct { 24 uint32_t vcnt:8; 25 uint32_t fix:1; 26 uint32_t res0:1; 27 uint32_t wc:1; 28 uint32_t res1:21; 29 uint32_t res2:32; 30 } bits; 31 }; 32 33 union mtrr_def_type_reg { 34 uint64_t value; 35 struct { 36 uint32_t type:8; 37 uint32_t res0:2; 38 uint32_t fixed_enable:1; 39 uint32_t enable:1; 40 uint32_t res1:20; 41 uint32_t res2:32; 42 } bits; 43 }; 44 45 union mtrr_fixed_range_reg { 46 uint64_t value; 47 uint8_t type[MTRR_SUB_RANGE_NUM]; 48 }; 49 50 struct acrn_vmtrr { 51 union mtrr_cap_reg cap; 52 union mtrr_def_type_reg def_type; 53 union mtrr_fixed_range_reg fixed_range[FIXED_RANGE_MTRR_NUM]; 54 }; 55 56 struct acrn_vcpu; 57 /** 58 * @brief Virtual MTRR MSR write 59 * 60 * @param[inout] vcpu The pointer that points VCPU data structure 61 * @param[in] msr Virtual MTRR MSR Address 62 * @param[in] value The value that will be writen into virtual MTRR MSR 63 */ 64 void write_vmtrr(struct acrn_vcpu *vcpu, uint32_t msr, uint64_t value); 65 /** 66 * @brief Virtual MTRR MSR read 67 * 68 * @param[in] vcpu The pointer that points VCPU data structure 69 * @param[in] msr Virtual MTRR MSR Address 70 * 71 * @return The specified virtual MTRR MSR value 72 */ 73 uint64_t read_vmtrr(const struct acrn_vcpu *vcpu, uint32_t msr); 74 /** 75 * @brief Virtual MTRR initialization 76 * 77 * @param[inout] vcpu The pointer that points VCPU data structure 78 */ 79 void init_vmtrr(struct acrn_vcpu *vcpu); 80 /** 81 * @} 82 */ 83 #endif /* VMTRR_H */ 84