Changeset 97374 in vbox for trunk/src/VBox/VMM/VMMR3
- Timestamp:
- Nov 2, 2022 9:46:33 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/NEMR3Native-darwin.cpp
r97295 r97374 36 36 #define LOG_GROUP LOG_GROUP_NEM 37 37 #define VMCPU_INCL_CPUM_GST_CTX 38 #define CPUM_WITH_NONCONST_HOST_FEATURES /* required for initializing parts of the g_CpumHostFeatures structure here. */ 38 39 #include <VBox/vmm/nem.h> 39 40 #include <VBox/vmm/iem.h> … … 166 167 HV_VMX_CAP_PREEMPTION_TIMER = 32 167 168 } hv_vmx_capability_t; 169 170 171 /** 172 * MSR information. 173 */ 174 typedef enum 175 { 176 HV_VMX_INFO_MSR_IA32_ARCH_CAPABILITIES = 0, 177 HV_VMX_INFO_MSR_IA32_PERF_CAPABILITIES, 178 HV_VMX_VALID_MSR_IA32_PERFEVNTSEL, 179 HV_VMX_VALID_MSR_IA32_FIXED_CTR_CTRL, 180 HV_VMX_VALID_MSR_IA32_PERF_GLOBAL_CTRL, 181 HV_VMX_VALID_MSR_IA32_PERF_GLOBAL_STATUS, 182 HV_VMX_VALID_MSR_IA32_DEBUGCTL, 183 HV_VMX_VALID_MSR_IA32_SPEC_CTRL, 184 HV_VMX_NEED_MSR_IA32_SPEC_CTRL 185 } hv_vmx_msr_info_t; 168 186 169 187 … … 279 297 280 298 /* Since 11.0 */ 299 typedef hv_return_t FN_HV_VMX_GET_MSR_INFO(hv_vmx_msr_info_t field, uint64_t *value); 281 300 typedef hv_return_t FN_HV_VMX_VCPU_GET_CAP_WRITE_VMCS(hv_vcpuid_t vcpu, uint32_t field, uint64_t *allowed_0, uint64_t *allowed_1); 282 301 typedef hv_return_t FN_HV_VCPU_ENABLE_MANAGED_MSR(hv_vcpuid_t vcpu, uint32_t msr, bool enable); … … 335 354 static FN_HV_VMX_VCPU_SET_APIC_ADDRESS *g_pfnHvVmxVCpuSetApicAddress = NULL; /* Since 10.10 */ 336 355 356 static FN_HV_VMX_GET_MSR_INFO *g_pfnHvVmxGetMsrInfo = NULL; /* Since 11.0 */ 337 357 static FN_HV_VMX_VCPU_GET_CAP_WRITE_VMCS *g_pfnHvVmxVCpuGetCapWriteVmcs = NULL; /* Since 11.0 */ 338 358 static FN_HV_VCPU_ENABLE_MANAGED_MSR *g_pfnHvVCpuEnableManagedMsr = NULL; /* Since 11.0 */ … … 388 408 NEM_DARWIN_IMPORT(true, g_pfnHvVmxVCpuSetShadowAccess, hv_vmx_vcpu_set_shadow_access), 389 409 NEM_DARWIN_IMPORT(false, g_pfnHvVmxVCpuSetApicAddress, hv_vmx_vcpu_set_apic_address), 410 NEM_DARWIN_IMPORT(true, g_pfnHvVmxGetMsrInfo, hv_vmx_get_msr_info), 390 411 NEM_DARWIN_IMPORT(true, g_pfnHvVmxVCpuGetCapWriteVmcs, hv_vmx_vcpu_get_cap_write_vmcs), 391 412 NEM_DARWIN_IMPORT(true, g_pfnHvVCpuEnableManagedMsr, hv_vcpu_enable_managed_msr), … … 437 458 # define hv_vmx_vcpu_set_apic_address g_pfnHvVmxVCpuSetApicAddress 438 459 460 # define hv_vmx_get_msr_info g_pfnHvVmxGetMsrInfo 439 461 # define hv_vmx_vcpu_get_cap_write_vmcs g_pfnHvVmxVCpuGetCapWriteVmcs 440 462 # define hv_vcpu_enable_managed_msr g_pfnHvVCpuEnableManagedMsr … … 2123 2145 //&& (g_HmMsrs.u.vmx.ExitCtls.n.allowed1 & VMX_EXIT_CTLS_LOAD_EFER_MSR) 2124 2146 //&& (g_HmMsrs.u.vmx.ExitCtls.n.allowed1 & VMX_EXIT_CTLS_SAVE_EFER_MSR); 2147 } 2148 2149 /* 2150 * Get MSR_IA32_ARCH_CAPABILITIES and expand it into the host feature structure. 2151 * This is only available with 11.0+ (BigSur) as the required API is only available there, 2152 * we could in theory initialize this when creating the EMTs using hv_vcpu_read_msr() but 2153 * the required vCPU handle is created after CPUM was initialized which is too late. 2154 * Given that the majority of users is on 11.0 and later we don't care for now. 2155 */ 2156 if ( hrc == HV_SUCCESS 2157 && hv_vmx_get_msr_info) 2158 { 2159 g_CpumHostFeatures.s.fArchRdclNo = 0; 2160 g_CpumHostFeatures.s.fArchIbrsAll = 0; 2161 g_CpumHostFeatures.s.fArchRsbOverride = 0; 2162 g_CpumHostFeatures.s.fArchVmmNeedNotFlushL1d = 0; 2163 g_CpumHostFeatures.s.fArchMdsNo = 0; 2164 uint32_t const cStdRange = ASMCpuId_EAX(0); 2165 if ( RTX86IsValidStdRange(cStdRange) 2166 && cStdRange >= 7) 2167 { 2168 uint32_t const fStdFeaturesEdx = ASMCpuId_EDX(1); 2169 uint32_t fStdExtFeaturesEdx; 2170 ASMCpuIdExSlow(7, 0, 0, 0, NULL, NULL, NULL, &fStdExtFeaturesEdx); 2171 if ( (fStdExtFeaturesEdx & X86_CPUID_STEXT_FEATURE_EDX_ARCHCAP) 2172 && (fStdFeaturesEdx & X86_CPUID_FEATURE_EDX_MSR)) 2173 { 2174 uint64_t fArchVal; 2175 hrc = hv_vmx_get_msr_info(HV_VMX_INFO_MSR_IA32_ARCH_CAPABILITIES, &fArchVal); 2176 if (hrc == HV_SUCCESS) 2177 { 2178 g_CpumHostFeatures.s.fArchRdclNo = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_RDCL_NO); 2179 g_CpumHostFeatures.s.fArchIbrsAll = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_IBRS_ALL); 2180 g_CpumHostFeatures.s.fArchRsbOverride = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_RSBO); 2181 g_CpumHostFeatures.s.fArchVmmNeedNotFlushL1d = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_VMM_NEED_NOT_FLUSH_L1D); 2182 g_CpumHostFeatures.s.fArchMdsNo = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_MDS_NO); 2183 } 2184 } 2185 else 2186 g_CpumHostFeatures.s.fArchCap = 0; 2187 } 2125 2188 } 2126 2189
Note:
See TracChangeset
for help on using the changeset viewer.