VirtualBox

Changeset 99190 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 28, 2023 8:25:59 AM (22 months ago)
Author:
vboxsync
Message:

VMM/NEMR3Native-darwin-armv8.cpp: Skeleton for handling the trapped MRS, MSR and system instruction exception, bugref:10390

File:
1 edited

Legend:

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

    r99078 r99190  
    10121012
    10131013/**
     1014 * Works on the trapped MRS, MSR and system instruction exception.
     1015 *
     1016 * @returns VBox strict status code.
     1017 * @param   pVM             The cross context VM structure.
     1018 * @param   pVCpu           The cross context virtual CPU structure of the
     1019 *                          calling EMT.
     1020 * @param   uIss            The instruction specific syndrome value.
     1021 * @param   fInsn32Bit      Flag whether the exception was caused by a 32-bit or 16-bit instruction.
     1022 */
     1023static VBOXSTRICTRC nemR3DarwinHandleExitExceptionTrappedSysInsn(PVM pVM, PVMCPU pVCpu, uint32_t uIss, bool fInsn32Bit)
     1024{
     1025    bool fRead   = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_DIRECTION_IS_READ(uIss);
     1026    uint8_t uCRm = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRM_GET(uIss);
     1027    uint8_t uReg = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_RT_GET(uIss);
     1028    uint8_t uCRn = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRN_GET(uIss);
     1029    uint8_t uOp1 = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP1_GET(uIss);
     1030    uint8_t uOp2 = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP2_GET(uIss);
     1031    uint8_t uOp0 = ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP0_GET(uIss);
     1032    uint16_t idSysReg = ARMV8_AARCH64_SYSREG_ID_CREATE(uOp0, uOp1, uCRn, uCRm, uOp2);
     1033    LogFlowFunc(("fRead=%RTbool uCRm=%u uReg=%u uCRn=%u uOp1=%u uOp2=%u uOp0=%u idSysReg=%#x\n",
     1034                 fRead, uCRm, uReg, uCRn, uOp1, uOp2, uOp0, idSysReg));
     1035
     1036    /** @todo EMEXITTYPE_MSR_READ/EMEXITTYPE_MSR_WRITE are misnomers. */
     1037    EMHistoryAddExit(pVCpu,
     1038                     fRead
     1039                     ? EMEXIT_MAKE_FT(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_READ)
     1040                     : EMEXIT_MAKE_FT(EMEXIT_F_KIND_EM, EMEXITTYPE_MSR_WRITE),
     1041                     pVCpu->cpum.GstCtx.Pc.u64, ASMReadTSC());
     1042
     1043    VBOXSTRICTRC rcStrict = VINF_SUCCESS;
     1044    uint64_t u64Val = 0;
     1045    if (fRead)
     1046    {
     1047        RT_NOREF(pVM);
     1048        /** @todo */
     1049        Log4(("SysInsnExit/%u: %08RX64: READ %u:%u:%u:%u:%u -> %#RX64 rcStrict=%Rrc\n",
     1050              pVCpu->idCpu, pVCpu->cpum.GstCtx.Pc.u64, uOp0, uOp1, uCRn, uCRm, uOp2, u64Val,
     1051              VBOXSTRICTRC_VAL(rcStrict) ));
     1052        if (rcStrict == VINF_SUCCESS)
     1053            nemR3DarwinSetGReg(pVCpu, uReg, true /*f64BitReg*/, false /*fSignExtend*/, u64Val);
     1054    }
     1055    else
     1056    {
     1057        u64Val = nemR3DarwinGetGReg(pVCpu, uReg);
     1058        /** @todo */
     1059        Log4(("SysInsnExit/%u: %08RX64: WRITE %u:%u:%u:%u:%u %#RX64 -> rcStrict=%Rrc\n",
     1060              pVCpu->idCpu, pVCpu->cpum.GstCtx.Pc.u64, uOp0, uOp1, uCRn, uCRm, uOp2, u64Val,
     1061              VBOXSTRICTRC_VAL(rcStrict) ));
     1062    }
     1063
     1064    if (rcStrict == VINF_SUCCESS)
     1065        pVCpu->cpum.GstCtx.Pc.u64 += fInsn32Bit ? sizeof(uint32_t) : sizeof(uint16_t);
     1066
     1067    return rcStrict;
     1068}
     1069
     1070
     1071/**
    10141072 * Handles an exception VM exit.
    10151073 *
     
    10341092            return nemR3DarwinHandleExitExceptionDataAbort(pVM, pVCpu, uIss, fInsn32Bit, pExit->exception.virtual_address,
    10351093                                                           pExit->exception.physical_address);
     1094        case ARMV8_ESR_EL2_EC_AARCH64_TRAPPED_SYS_INSN:
     1095            return nemR3DarwinHandleExitExceptionTrappedSysInsn(pVM, pVCpu, uIss, fInsn32Bit);
    10361096        case ARMV8_ESR_EL2_EC_UNKNOWN:
    10371097        default:
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