VirtualBox

Changeset 101672 in vbox for trunk


Ignore:
Timestamp:
Oct 31, 2023 9:22:10 AM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159763
Message:

ValidationKit/TestBoxHelper: Some fixes for ARM, bugref:10542

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testboxscript/TestBoxHelper.cpp

    r100108 r101672  
    381381    }
    382382    RTPrintf("\n");
     383#else
     384#endif
    383385
    384386    /*
     
    406408    }
    407409    RTPrintf("\n");
    408 
    409 #else
    410 #endif
    411410
    412411    /*
     
    471470}
    472471
    473 typedef enum { HWVIRTTYPE_NONE, HWVIRTTYPE_VTX, HWVIRTTYPE_AMDV } HWVIRTTYPE;
     472typedef enum { HWVIRTTYPE_NONE, HWVIRTTYPE_VTX, HWVIRTTYPE_AMDV, HVIRTTYPE_ARMV8 } HWVIRTTYPE;
    474473static HWVIRTTYPE isHwVirtSupported(void)
    475474{
     
    494493            return HWVIRTTYPE_AMDV;
    495494    }
     495#elif defined(RT_ARCH_ARM64)
     496# if defined(RT_OS_DARWIN)
     497    /*
     498     * The kern.hv_support parameter indicates support for the hypervisor API in the
     499     * kernel, which is the only way for virtualization on macOS on Apple Silicon.
     500     */
     501    int32_t fHvSupport = 0;
     502    size_t  cbOld = sizeof(fHvSupport);
     503    if (sysctlbyname("kern.hv_support", &fHvSupport, &cbOld, NULL, 0) == 0)
     504    {
     505        if (fHvSupport != 0)
     506            return HVIRTTYPE_ARMV8;
     507    }
     508# endif
    496509#endif
    497510
     
    515528    int         fSupported = -1;
    516529
     530    HWVIRTTYPE  enmHwVirt  = isHwVirtSupported();
    517531#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    518     HWVIRTTYPE  enmHwVirt  = isHwVirtSupported();
    519532    if (enmHwVirt == HWVIRTTYPE_AMDV)
    520533    {
     
    595608    }
    596609# endif
     610#elif defined(RT_ARCH_ARM64)
     611    /* On ARM nested paging is always supported if virtualization is there. */
     612    if (enmHwVirt == HVIRTTYPE_ARMV8)
     613        fSupported = 1;
    597614#endif
    598615
     
    648665            }
    649666        }
     667#elif defined(RT_ARCH_ARM64)
     668        fSupported = 1; /** @todo LongMode is a misnomer here but in general means 64-bit guest capable. */
    650669#endif
    651670    }
     
    708727    ASMCpuId(0, &uEax, &uEbx, &uEcx, &uEdx);
    709728    int cch = RTPrintf("%.04s%.04s%.04s\n", &uEbx, &uEdx, &uEcx);
     729#elif defined(RT_ARCH_ARM64) && defined(RT_OS_DARWIN)
     730    /*
     731     * There is machdep.cpu.brand_string we could query but that identifies
     732     * the whole CPU and not just the vendor.
     733     *
     734     * Running on macOS using the arm64 architecture is a pretty safe bet that
     735     * we are also running on Apple Silicon (there is the possibility that
     736     * this runs in a macOS VM on some other hardware but this is highly unlikely).
     737     */
     738    int cch = RTPrintf("Apple\n");
    710739#else
    711740    int cch = RTPrintf("%s\n", RTBldCfgTargetArch());
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