VirtualBox

Changeset 106384 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Oct 16, 2024 1:58:41 PM (7 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165197
Message:

Main: Code for configuring and enabling nested virtualization support on ARM (M3 based hardware + macOS 15.0 aka Sequioa), bugref:10747

Location:
trunk/src/VBox/Main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r106218 r106384  
    12211221        setting may slow down workloads causing many VM exits, so it is only
    12221222        recommended for situation where there is a real need to be paranoid.
     1223      </desc>
     1224    </const>
     1225  </enum>
     1226
     1227  <enum
     1228    name="CPUPropertyTypeARM"
     1229    uuid="c84685f6-6bd3-4071-97c6-86f34595648f"
     1230    >
     1231    <desc>
     1232      Virtual CPU property type for ARM-based CPUs. This enumeration represents possible values of the
     1233      IPlatformARM get- and setCPUProperty methods.
     1234    </desc>
     1235    <const name="Null"                  value="0">
     1236      <desc>Null value (never used by the API).</desc>
     1237    </const>
     1238    <const name="HWVirt"                value="1">
     1239      <desc>
     1240        Enables the hardware virtualization feature on the guest CPU.
     1241        This requires the nested virtualization feature on the host CPU.
    12231242      </desc>
    12241243    </const>
     
    73927411  <interface
    73937412    name="IPlatformARM" extends="$unknown"
    7394     uuid="75dff9be-6cb3-4857-bde6-2faf82ed9a8d"
     7413    uuid="002c75fe-3316-4920-aece-7d21ce6f624b"
    73957414    wsmap="managed"
    73967415    rest="managed"
     
    74037422    </desc>
    74047423
    7405     <!-- Currently empty, but that should change before long... -->
    7406     <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/>
     7424    <method name="getCPUProperty" const="yes">
     7425      <rest request="get" path="/vms/{vmid}/configuration/"/>
     7426      <desc>
     7427        Returns the virtual CPU boolean value of the specified property.
     7428
     7429        <result name="E_INVALIDARG">
     7430          Invalid property.
     7431        </result>
     7432
     7433      </desc>
     7434      <param name="property" type="CPUPropertyTypeARM" dir="in">
     7435        <desc>
     7436          Property type to query.
     7437        </desc>
     7438      </param>
     7439      <param name="value" type="boolean" dir="return">
     7440        <desc>
     7441          Property value.
     7442        </desc>
     7443      </param>
     7444    </method>
     7445
     7446    <method name="setCPUProperty">
     7447      <rest request="post" path="/vms/{vmid}/configuration/"/>
     7448      <desc>
     7449        Sets the virtual CPU boolean value of the specified property.
     7450
     7451        <result name="E_INVALIDARG">
     7452          Invalid property.
     7453        </result>
     7454
     7455      </desc>
     7456      <param name="property" type="CPUPropertyTypeARM" dir="in">
     7457        <desc>
     7458          Property type to query.
     7459        </desc>
     7460      </param>
     7461      <param name="value" type="boolean" dir="in">
     7462        <desc>
     7463          Property value.
     7464        </desc>
     7465      </param>
     7466    </method>
    74077467
    74087468  </interface>
  • trunk/src/VBox/Main/include/PlatformARMImpl.h

    r106061 r106384  
    6868    HRESULT i_saveSettings(settings::PlatformARM &data);
    6969    HRESULT i_applyDefaults(GuestOSType *aOsType);
     70
     71private:
     72
     73    // wrapped IPlatformARM methods
     74    HRESULT getCPUProperty(CPUPropertyTypeARM_T aProperty, BOOL *aValue);
     75    HRESULT setCPUProperty(CPUPropertyTypeARM_T aProperty, BOOL aValue);
    7076};
    7177#endif /* !MAIN_INCLUDED_PlatformARMImpl_h */
  • trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp

    r106139 r106384  
    12771277            static const TpmType_T aTpmTypes[] =
    12781278            {
    1279                 TpmType_None
     1279                TpmType_None,
     1280                TpmType_v2_0
    12801281            };
    12811282            aSupportedTpmTypes.assign(aTpmTypes,
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp

    r106361 r106384  
    153153#endif
    154154
     155    /* Get the ARM platform object. */
     156    ComPtr<IPlatformARM> platformARM;
     157    hrc = platform->COMGETTER(ARM)(platformARM.asOutParam());                               H();
     158
    155159    ComPtr<IPlatformProperties> pPlatformProperties;
    156160    hrc = platform->COMGETTER(Properties)(pPlatformProperties.asOutParam());                H();
     
    364368        PCFGMNODE pCpum;
    365369        InsertConfigNode(pRoot, "CPUM", &pCpum);
     370
     371        /* Nested Virtualization. */
     372        BOOL fNestedHWVirt = FALSE;
     373        hrc = platformARM->GetCPUProperty(CPUPropertyTypeARM_HWVirt, &fNestedHWVirt); H();
     374        InsertConfigInteger(pCpum, "NestedHWVirt", fNestedHWVirt ? true : false);
    366375
    367376
  • trunk/src/VBox/Main/src-server/PlatformARMImpl.cpp

    r106061 r106384  
    3131#include "PlatformImpl.h"
    3232#include "LoggingNew.h"
     33
     34#include "AutoStateDep.h"
    3335
    3436#include <VBox/settings.h>
     
    239241HRESULT PlatformARM::i_loadSettings(const settings::PlatformARM &data)
    240242{
    241     RT_NOREF(data);
    242 
    243     /* Nothing here yet. */
     243    AutoCaller autoCaller(this);
     244    AssertComRCReturnRC(autoCaller.hrc());
     245
     246    AutoReadLock mlock(mMachine COMMA_LOCKVAL_SRC_POS);
     247    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     248
     249    // simply copy
     250    m->bd.assignCopy(&data);
    244251    return S_OK;
    245252}
     
    255262HRESULT PlatformARM::i_saveSettings(settings::PlatformARM &data)
    256263{
    257     RT_NOREF(data);
     264    AutoCaller autoCaller(this);
     265    AssertComRCReturnRC(autoCaller.hrc());
     266
     267    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     268
     269    data = *m->bd.data();
     270
     271    return S_OK;
     272}
     273
     274HRESULT PlatformARM::i_applyDefaults(GuestOSType *aOsType)
     275{
     276    RT_NOREF(aOsType);
    258277
    259278    /* Nothing here yet. */
     
    261280}
    262281
    263 HRESULT PlatformARM::i_applyDefaults(GuestOSType *aOsType)
    264 {
    265     RT_NOREF(aOsType);
    266 
    267     /* Nothing here yet. */
    268     return S_OK;
    269 }
     282HRESULT PlatformARM::getCPUProperty(CPUPropertyTypeARM_T aProperty, BOOL *aValue)
     283{
     284    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     285
     286    switch (aProperty)
     287    {
     288        case CPUPropertyTypeARM_HWVirt:
     289            *aValue = m->bd->fNestedHWVirt;
     290            break;
     291
     292        default:
     293            return E_INVALIDARG;
     294    }
     295    return S_OK;
     296}
     297
     298HRESULT PlatformARM::setCPUProperty(CPUPropertyTypeARM_T aProperty, BOOL aValue)
     299{
     300    /* sanity */
     301    AutoCaller autoCaller(this);
     302    AssertComRCReturnRC(autoCaller.hrc());
     303
     304    /* the machine needs to be mutable */
     305    AutoMutableStateDependency adep(mMachine);
     306    if (FAILED(adep.hrc())) return adep.hrc();
     307
     308    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     309
     310    switch (aProperty)
     311    {
     312        case CPUPropertyTypeARM_HWVirt:
     313        {
     314            m->bd.backup();
     315            m->bd->fNestedHWVirt = !!aValue;
     316            break;
     317        }
     318
     319        default:
     320            return E_INVALIDARG;
     321    }
     322
     323    alock.release();
     324
     325    AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);
     326    mMachine->i_setModified(Machine::IsModified_Platform);
     327
     328    return S_OK;
     329}
  • trunk/src/VBox/Main/xml/Settings.cpp

    r106061 r106384  
    39693969
    39703970#ifdef VBOX_WITH_VIRT_ARMV8
    3971 PlatformARM::PlatformARM()
     3971PlatformARM::PlatformARM() :
     3972    fNestedHWVirt(false)
    39723973{
    39733974}
     
    39753976bool PlatformARM::operator==(const PlatformARM& h) const
    39763977{
    3977     RT_NOREF(h);
    3978     return true;
     3978    return (this == &h)
     3979        || (fNestedHWVirt == h.fNestedHWVirt);
    39793980}
    39803981#endif /* VBOX_WITH_VIRT_ARMV8 */
     
    53065307}
    53075308
     5309#ifdef VBOX_WITH_VIRT_ARMV8
     5310/**
     5311 * Reads the ARM platform settings.
     5312 *
     5313 * For settings >= v1.20 these were stored under the "Platform/arm" node.
     5314 *
     5315 * @param elmPlatformARM  Platform/arm node to read from.
     5316 * @param platARM         Where to store the ARM platform settings.
     5317 */
     5318void MachineConfigFile::readPlatformARM(const xml::ElementNode &elmPlatformARM,
     5319                                        PlatformARM &platARM)
     5320{
     5321    xml::NodesLoop nl1(elmPlatformARM);
     5322
     5323    const xml::ElementNode *pelChild;
     5324    while ((pelChild = nl1.forAllNodes()))
     5325    {
     5326        if (pelChild->nameEquals("CPU"))
     5327        {
     5328            const xml::ElementNode *pelmCPUChild;
     5329            if ((pelmCPUChild = pelChild->findChildElement("NestedHWVirt")))
     5330                pelmCPUChild->getAttributeValue("enabled", platARM.fNestedHWVirt);
     5331        }
     5332    }
     5333}
     5334#endif
     5335
    53085336/**
    53095337 * Reads the platform settings.
     
    54435471        case PlatformArchitecture_ARM:
    54445472        {
    5445             /* Nothing here yet -- add ARM-specific stuff as soon as we have it. */
     5473            const xml::ElementNode *pelmPlatformARM;
     5474
     5475            pelmPlatformARM = elmPlatformOrHardware.findChildElement("arm");
     5476            if (pelmPlatformARM)
     5477                readPlatformARM(*pelmPlatformARM, plat.arm);
    54465478            break;
    54475479        }
     
    73507382}
    73517383
     7384#ifdef VBOX_WITH_VIRT_ARMV8
     7385/**
     7386 * Writes ARM-specific platform settings out to the XML.
     7387 *
     7388 * For settings >= v1.20 this creates a \<arm\> node under elmParent.
     7389 * keys under that. Called for both the \<Machine\> node and for snapshots.
     7390 *
     7391 * @param elmParent                         Parent element.
     7392 *                                          For settings >= v1.20 this is the \<Platform\> element.
     7393 * @param elmCPU                            CPU element platform-generic settings.
     7394 *                                          For settings >= v1.20 this is the \<Platform/CPU\> element.
     7395 * @param platARM                           ARM-specific platform settings to use for building the XML.
     7396 */
     7397void MachineConfigFile::buildPlatformARMXML(xml::ElementNode &elmParent, const PlatformARM &platARM)
     7398{
     7399    xml::ElementNode *pelmARMRoot = elmParent.createChild("arm");
     7400    xml::ElementNode *pelmARMCPU  = pelmARMRoot->createChild("CPU");
     7401
     7402    if (platARM.fNestedHWVirt)
     7403        pelmARMCPU->createChild("NestedHWVirt")->setAttribute("enabled", platARM.fNestedHWVirt);
     7404}
     7405#endif /* VBOX_WITH_VIRT_ARMV8 */
     7406
     7407
    73527408/**
    73537409 * Stores platform-generic and platform-specific data and then writes out the XML.
     
    74657521    if (plat.architectureType == PlatformArchitecture_x86)
    74667522        buildPlatformX86XML(*pelmPlatformOrHardware, *pelmCPU, plat.x86);
    7467     /** @todo Put ARM stuff here as soon as we have it. */
     7523#ifdef VBOX_WITH_VIRT_ARMV8
     7524    else if (plat.architectureType == PlatformArchitecture_ARM)
     7525    {
     7526        Assert(m->sv >= SettingsVersion_v1_20);
     7527        buildPlatformARMXML(*pelmPlatformOrHardware, plat.arm);
     7528    }
     7529#endif
    74687530}
    74697531
Note: See TracChangeset for help on using the changeset viewer.

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