VirtualBox

Changeset 101115 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 13, 2023 3:37:25 PM (16 months ago)
Author:
vboxsync
Message:

VMM/NEMR3Native-darwin-armv8: Query the guest ID registers and set them when setting up the vCPUs, bugref:10525 bugref:10390

File:
1 edited

Legend:

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

    r101104 r101115  
    812812
    813813        /* Query ID registers and hand them to CPUM. */
    814         CPUMIDREGS IdRegs;
     814        CPUMIDREGS IdRegs; RT_ZERO(IdRegs);
    815815        for (uint32_t i = 0; i < RT_ELEMENTS(s_aIdRegs); i++)
    816816        {
     
    836836        return VMSetError(pVM, VERR_NEM_VM_CREATE_FAILED, RT_SRC_POS,
    837837                          "Setting MPIDR_EL1 failed on vCPU %u: %#x (%Rrc)", idCpu, hrc, nemR3DarwinHvSts2Rc(hrc));
     838
     839    /*
     840     * The guest ID registers are populated after the call to CPUMR3PopulateFeaturesByIdRegisters() so
     841     * query the guest ID registers now and sync them to the vCPU once as they are constant during guest lifetime.
     842     */
     843    static const struct
     844    {
     845        const char       *pszIdReg;
     846        hv_sys_reg_t     enmHvReg;
     847        uint32_t         offIdStruct;
     848    } s_aSysIdRegs[] =
     849    {
     850#define ID_SYS_REG_CREATE(a_IdReg, a_CpumIdReg) { #a_IdReg, HV_SYS_REG_##a_IdReg,     RT_UOFFSETOF(CPUMIDREGS, a_CpumIdReg) }
     851        ID_SYS_REG_CREATE(ID_AA64DFR0_EL1,  u64RegIdAa64Dfr0El1),
     852        ID_SYS_REG_CREATE(ID_AA64DFR1_EL1,  u64RegIdAa64Dfr1El1),
     853        ID_SYS_REG_CREATE(ID_AA64ISAR0_EL1, u64RegIdAa64Isar0El1),
     854        ID_SYS_REG_CREATE(ID_AA64ISAR1_EL1, u64RegIdAa64Isar1El1),
     855        ID_SYS_REG_CREATE(ID_AA64MMFR0_EL1, u64RegIdAa64Mmfr0El1),
     856        ID_SYS_REG_CREATE(ID_AA64MMFR1_EL1, u64RegIdAa64Mmfr1El1),
     857        ID_SYS_REG_CREATE(ID_AA64MMFR2_EL1, u64RegIdAa64Mmfr2El1),
     858        ID_SYS_REG_CREATE(ID_AA64PFR0_EL1,  u64RegIdAa64Pfr0El1),
     859        ID_SYS_REG_CREATE(ID_AA64PFR1_EL1,  u64RegIdAa64Pfr1El1),
     860#undef ID_SYS_REG_CREATE
     861    };
     862
     863    PCCPUMIDREGS pIdRegsGst = NULL;
     864    int rc = CPUMR3QueryGuestIdRegs(pVM, &pIdRegsGst);
     865    AssertRCReturn(rc, rc);
     866
     867    for (uint32_t i = 0; i < RT_ELEMENTS(s_aSysIdRegs); i++)
     868    {
     869        uint64_t *pu64 = (uint64_t *)((uint8_t *)pIdRegsGst + s_aSysIdRegs[i].offIdStruct);
     870        hrc = hv_vcpu_set_sys_reg(pVCpu->nem.s.hVCpu, s_aSysIdRegs[i].enmHvReg, *pu64);
     871        if (hrc != HV_SUCCESS)
     872            return VMSetError(pVM, VERR_NEM_VM_CREATE_FAILED, RT_SRC_POS,
     873                              "Setting %s failed on vCPU %u: %#x (%Rrc)", s_aSysIdRegs[i].pszIdReg, idCpu, hrc, nemR3DarwinHvSts2Rc(hrc));
     874    }
    838875
    839876    return VINF_SUCCESS;
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