VirtualBox

Ignore:
Timestamp:
Jan 11, 2025 10:55:53 PM (3 weeks ago)
Author:
vboxsync
Message:

VMM/CPUM: Try consolidate the MSR_IA32_ARCH_CAPABILITIES handling in CPUM and do better sanitizing of what's exposed to the guest. jiraref:VBP-947

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-darwin.cpp

    r107115 r107703  
    22032203    /*
    22042204     * Get MSR_IA32_ARCH_CAPABILITIES and expand it into the host feature structure.
     2205     *
    22052206     * This is only available with 11.0+ (BigSur) as the required API is only available there,
    22062207     * we could in theory initialize this when creating the EMTs using hv_vcpu_read_msr() but
    22072208     * the required vCPU handle is created after CPUM was initialized which is too late.
    22082209     * Given that the majority of users is on 11.0 and later we don't care for now.
     2210     *
     2211     * (Yes, this is done after CPUM init.)
    22092212     */
     2213    uint64_t fHostArchVal = 0;
     2214    bool     fHasArchCap  = false;
    22102215    if (   hrc == HV_SUCCESS
    22112216        && hv_vmx_get_msr_info)
    22122217    {
    2213         g_CpumHostFeatures.s.fArchRdclNo             = 0;
    2214         g_CpumHostFeatures.s.fArchIbrsAll            = 0;
    2215         g_CpumHostFeatures.s.fArchRsbOverride        = 0;
    2216         g_CpumHostFeatures.s.fArchVmmNeedNotFlushL1d = 0;
    2217         g_CpumHostFeatures.s.fArchMdsNo              = 0;
    22182218        uint32_t const cStdRange = ASMCpuId_EAX(0);
    22192219        if (   RTX86IsValidStdRange(cStdRange)
     
    22262226                && (fStdFeaturesEdx    & X86_CPUID_FEATURE_EDX_MSR))
    22272227            {
    2228                 uint64_t fArchVal;
    2229                 hrc = hv_vmx_get_msr_info(HV_VMX_INFO_MSR_IA32_ARCH_CAPABILITIES, &fArchVal);
    2230                 if (hrc == HV_SUCCESS)
    2231                 {
    2232                     g_CpumHostFeatures.s.fArchRdclNo             = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_RDCL_NO);
    2233                     g_CpumHostFeatures.s.fArchIbrsAll            = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_IBRS_ALL);
    2234                     g_CpumHostFeatures.s.fArchRsbOverride        = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_RSBO);
    2235                     g_CpumHostFeatures.s.fArchVmmNeedNotFlushL1d = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_VMM_NEED_NOT_FLUSH_L1D);
    2236                     g_CpumHostFeatures.s.fArchMdsNo              = RT_BOOL(fArchVal & MSR_IA32_ARCH_CAP_F_MDS_NO);
    2237                 }
     2228                fHasArchCap = true;
     2229                hrc = hv_vmx_get_msr_info(HV_VMX_INFO_MSR_IA32_ARCH_CAPABILITIES, &fHostArchVal);
     2230                if (hrc != HV_SUCCESS)
     2231                    fHostArchVal = 0;
    22382232            }
    2239             else
    2240                 g_CpumHostFeatures.s.fArchCap = 0;
    2241         }
    2242     }
     2233        }
     2234    }
     2235    CPUMCpuIdApplyX86HostArchCapabilities(pVM, fHasArchCap, fHostArchVal);
    22432236
    22442237    return nemR3DarwinHvSts2Rc(hrc);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette