VirtualBox

Changeset 92449 in vbox


Ignore:
Timestamp:
Nov 16, 2021 10:37:10 AM (3 years ago)
Author:
vboxsync
Message:

VMM/NEM: Add NEMHCGetFeatures() to return a bitmask of features supported by the native NEM backend and make use of it in CPUMR3CpuId to determine whether to pass through xsave/xrstor support to the guest, bugref:9044

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/nem.h

    r92170 r92449  
    187187 */
    188188VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVMCC pVM);
     189VMM_INT_DECL(uint32_t) NEMHCGetFeatures(PVMCC pVM);
    189190VMM_INT_DECL(int)  NEMImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat);
     191
     192/** @name NEM_FEAT_F_XXX - Features supported by the NEM backend
     193 * @{ */
     194/** NEM backend uses nested paging for the guest. */
     195#define NEM_FEAT_F_NESTED_PAGING    RT_BIT(0)
     196/** NEM backend uses full (unrestricted) guest execution. */
     197#define NEM_FEAT_F_FULL_GST_EXEC    RT_BIT(1)
     198/** NEM backend offers an xsave/xrstor interface. */
     199#define NEM_FEAT_F_XSAVE_XRSTOR     RT_BIT(2)
     200/** @} */
    190201
    191202VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
  • trunk/src/VBox/VMM/VMMAll/NEMAll.cpp

    r91848 r92449  
    8989
    9090#ifndef VBOX_WITH_NATIVE_NEM
     91VMM_INT_DECL(uint32_t) NEMHCGetFeatures(PVMCC pVM)
     92{
     93    RT_NOREF(pVM);
     94    return 0;
     95}
     96#endif
     97
     98
     99#ifndef VBOX_WITH_NATIVE_NEM
    91100VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat)
    92101{
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r92170 r92449  
    51185118}
    51195119
     5120
     5121/**
     5122 * Returns features supported by the NEM backend.
     5123 *
     5124 * @returns Flags of features supported by the native NEM backend.
     5125 * @param   pVM             The cross context VM structure.
     5126 */
     5127VMM_INT_DECL(uint32_t) NEMHCGetFeatures(PVMCC pVM)
     5128{
     5129    RT_NOREF(pVM);
     5130    /** @todo Make use of the WHvGetVirtualProcessorXsaveState/WHvSetVirtualProcessorXsaveState
     5131     * interface added in 2019 to enable passthrough of xsave/xrstor (and depending) features to the guest. */
     5132    /** @todo Is NEM_FEAT_F_FULL_GST_EXEC always true? */
     5133    return NEM_FEAT_F_NESTED_PAGING | NEM_FEAT_F_FULL_GST_EXEC;
     5134}
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r91710 r92449  
    43244324    bool const fMayHaveXSave = fNestedPagingAndFullGuestExec
    43254325                            && pVM->cpum.s.HostFeatures.fXSaveRstor
    4326                             && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor;
     4326                            && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor
     4327                            && (   !VM_IS_NEM_ENABLED(pVM)
     4328                                || (NEMHCGetFeatures(pVM) & NEM_FEAT_F_XSAVE_XRSTOR));
    43274329    uint64_t const fXStateHostMask = pVM->cpum.s.fXStateHostMask;
    43284330
     
    45254527    RT_ZERO(Config);
    45264528
    4527     int rc = cpumR3CpuIdReadConfig(pVM, &Config, pCpumCfg, HMAreNestedPagingAndFullGuestExecEnabled(pVM));
     4529    bool const fNestedPagingAndFullGuestExec =   VM_IS_NEM_ENABLED(pVM)
     4530                                               ?     ((NEMHCGetFeatures(pVM) & (NEM_FEAT_F_NESTED_PAGING | NEM_FEAT_F_FULL_GST_EXEC))
     4531                                                  == (NEM_FEAT_F_NESTED_PAGING | NEM_FEAT_F_FULL_GST_EXEC))
     4532                                               : HMAreNestedPagingAndFullGuestExecEnabled(pVM);
     4533    int rc = cpumR3CpuIdReadConfig(pVM, &Config, pCpumCfg, fNestedPagingAndFullGuestExec);
    45284534    AssertRCReturn(rc, rc);
    45294535
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