VirtualBox

Changeset 100101 in vbox


Ignore:
Timestamp:
Jun 7, 2023 5:52:38 PM (18 months ago)
Author:
vboxsync
Message:

VMM: Add VMMR3CpuOn() for ARMv8 instead of using the VMMR3SendStartupIpi() API as the code needs to convey the start address where to execute code and a guest defined context ID, bugref:10454

Location:
trunk
Files:
2 edited

Legend:

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

    r98103 r100101  
    559559VMMR3_INT_DECL(void)    VMMR3YieldStop(PVM pVM);
    560560VMMR3_INT_DECL(void)    VMMR3YieldResume(PVM pVM);
     561#if defined(VBOX_VMM_TARGET_ARMV8)
     562VMMR3_INT_DECL(void)    VMMR3CpuOn(PVM pVM, VMCPUID idCpu, RTGCPHYS GCPhysExecAddr, uint64_t u64CtxId);
     563#else
    561564VMMR3_INT_DECL(void)    VMMR3SendStartupIpi(PVM pVM, VMCPUID idCpu, uint32_t uVector);
    562565VMMR3_INT_DECL(void)    VMMR3SendInitIpi(PVM pVM, VMCPUID idCpu);
     566#endif
    563567VMMR3DECL(int)          VMMR3RegisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
    564568VMMR3DECL(int)          VMMR3DeregisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r99576 r100101  
    146146#include <iprt/assert.h>
    147147#include <iprt/alloc.h>
     148#if defined(VBOX_VMM_TARGET_ARMV8)
     149# include <iprt/armv8.h>
     150#endif
    148151#include <iprt/asm.h>
    149152#include <iprt/time.h>
     
    12921295
    12931296
    1294 /**
    1295  * VCPU worker for VMMR3SendStartupIpi.
    1296  *
    1297  * @param   pVM         The cross context VM structure.
    1298  * @param   idCpu       Virtual CPU to perform SIPI on.
    1299  * @param   uVector     The SIPI vector.
    1300  */
    1301 static DECLCALLBACK(int) vmmR3SendStarupIpi(PVM pVM, VMCPUID idCpu, uint32_t uVector)
     1297#if defined(VBOX_VMM_TARGET_ARMV8)
     1298/**
     1299 * VCPU worker for VMMR3CpuOn.
     1300 *
     1301 * @param   pVM             The cross context VM structure.
     1302 * @param   idCpu           Virtual CPU to perform SIPI on.
     1303 * @param   GCPhysExecAddr  The guest physical address to start executing at.
     1304 * @param   u64CtxId        The context ID passed in x0/w0.
     1305 */
     1306static DECLCALLBACK(int) vmmR3CpuOn(PVM pVM, VMCPUID idCpu, RTGCPHYS GCPhysExecAddr, uint64_t u64CtxId)
    13021307{
    13031308    PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
    13041309    VMCPU_ASSERT_EMT(pVCpu);
    13051310
    1306     /*
    1307      * In the INIT state, the target CPU is only responsive to an SIPI.
    1308      * This is also true for when when the CPU is in VMX non-root mode.
    1309      *
    1310      * See AMD spec. 16.5 "Interprocessor Interrupts (IPI)".
    1311      * See Intel spec. 26.6.2 "Activity State".
    1312      */
    13131311    if (EMGetState(pVCpu) != EMSTATE_WAIT_SIPI)
    13141312        return VINF_SUCCESS;
    13151313
    1316 #if defined(VBOX_VMM_TARGET_ARMV8)
    1317     AssertReleaseFailed(); /** @todo */
    1318 #else
    13191314    PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
    1320 # ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    1321     if (CPUMIsGuestInVmxRootMode(pCtx))
    1322     {
    1323         /* If the CPU is in VMX non-root mode we must cause a VM-exit. */
    1324         if (CPUMIsGuestInVmxNonRootMode(pCtx))
    1325             return VBOXSTRICTRC_TODO(IEMExecVmxVmexitStartupIpi(pVCpu, uVector));
    1326 
    1327         /* If the CPU is in VMX root mode (and not in VMX non-root mode) SIPIs are blocked. */
    1328         return VINF_SUCCESS;
    1329     }
    1330 # endif
    1331 
    1332     pCtx->cs.Sel        = uVector << 8;
    1333     pCtx->cs.ValidSel   = uVector << 8;
    1334     pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
    1335     pCtx->cs.u64Base    = uVector << 12;
    1336     pCtx->cs.u32Limit   = UINT32_C(0x0000ffff);
    1337     pCtx->rip           = 0;
    1338 #endif
    1339 
    1340     Log(("vmmR3SendSipi for VCPU %d with vector %x\n", idCpu, uVector));
     1315
     1316    pCtx->aGRegs[ARMV8_AARCH64_REG_X0].x = u64CtxId;
     1317    pCtx->Pc.u64                         = GCPhysExecAddr;
     1318
     1319    Log(("vmmR3CpuOn for VCPU %d with GCPhysExecAddr=%RGp u64CtxId=%#RX64\n", idCpu, GCPhysExecAddr, u64CtxId));
    13411320
    13421321# if 1 /* If we keep the EMSTATE_WAIT_SIPI method, then move this to EM.cpp. */
     
    13521331
    13531332/**
     1333 * Sends a Startup IPI to the virtual CPU by setting CS:EIP into
     1334 * vector-dependent state and unhalting processor.
     1335 *
     1336 * @param   pVM             The cross context VM structure.
     1337 * @param   idCpu           Virtual CPU to perform SIPI on.
     1338 * @param   GCPhysExecAddr  The guest physical address to start executing at.
     1339 * @param   u64CtxId        The context ID passed in x0/w0.
     1340 */
     1341VMMR3_INT_DECL(void)    VMMR3CpuOn(PVM pVM, VMCPUID idCpu, RTGCPHYS GCPhysExecAddr, uint64_t u64CtxId)
     1342{
     1343    AssertReturnVoid(idCpu < pVM->cCpus);
     1344
     1345    int rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)vmmR3CpuOn, 4, pVM, idCpu, GCPhysExecAddr, u64CtxId);
     1346    AssertRC(rc);
     1347}
     1348#else
     1349/**
     1350 * VCPU worker for VMMR3SendStartupIpi.
     1351 *
     1352 * @param   pVM         The cross context VM structure.
     1353 * @param   idCpu       Virtual CPU to perform SIPI on.
     1354 * @param   uVector     The SIPI vector.
     1355 */
     1356static DECLCALLBACK(int) vmmR3SendStartupIpi(PVM pVM, VMCPUID idCpu, uint32_t uVector)
     1357{
     1358    PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
     1359    VMCPU_ASSERT_EMT(pVCpu);
     1360
     1361    /*
     1362     * In the INIT state, the target CPU is only responsive to an SIPI.
     1363     * This is also true for when when the CPU is in VMX non-root mode.
     1364     *
     1365     * See AMD spec. 16.5 "Interprocessor Interrupts (IPI)".
     1366     * See Intel spec. 26.6.2 "Activity State".
     1367     */
     1368    if (EMGetState(pVCpu) != EMSTATE_WAIT_SIPI)
     1369        return VINF_SUCCESS;
     1370
     1371    PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
     1372# ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     1373    if (CPUMIsGuestInVmxRootMode(pCtx))
     1374    {
     1375        /* If the CPU is in VMX non-root mode we must cause a VM-exit. */
     1376        if (CPUMIsGuestInVmxNonRootMode(pCtx))
     1377            return VBOXSTRICTRC_TODO(IEMExecVmxVmexitStartupIpi(pVCpu, uVector));
     1378
     1379        /* If the CPU is in VMX root mode (and not in VMX non-root mode) SIPIs are blocked. */
     1380        return VINF_SUCCESS;
     1381    }
     1382# endif
     1383
     1384    pCtx->cs.Sel        = uVector << 8;
     1385    pCtx->cs.ValidSel   = uVector << 8;
     1386    pCtx->cs.fFlags     = CPUMSELREG_FLAGS_VALID;
     1387    pCtx->cs.u64Base    = uVector << 12;
     1388    pCtx->cs.u32Limit   = UINT32_C(0x0000ffff);
     1389    pCtx->rip           = 0;
     1390
     1391    Log(("vmmR3SendSipi for VCPU %d with vector %x\n", idCpu, uVector));
     1392
     1393# if 1 /* If we keep the EMSTATE_WAIT_SIPI method, then move this to EM.cpp. */
     1394    EMSetState(pVCpu, EMSTATE_HALTED);
     1395    return VINF_EM_RESCHEDULE;
     1396# else /* And if we go the VMCPU::enmState way it can stay here. */
     1397    VMCPU_ASSERT_STATE(pVCpu, VMCPUSTATE_STOPPED);
     1398    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
     1399    return VINF_SUCCESS;
     1400# endif
     1401}
     1402
     1403
     1404/**
    13541405 * VCPU worker for VMMR3SendInitIpi.
    13551406 *
     
    14061457    AssertReturnVoid(idCpu < pVM->cCpus);
    14071458
    1408     int rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)vmmR3SendStarupIpi, 3, pVM, idCpu, uVector);
     1459    int rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)vmmR3SendStartupIpi, 3, pVM, idCpu, uVector);
    14091460    AssertRC(rc);
    14101461}
     
    14241475    AssertRC(rc);
    14251476}
     1477#endif
    14261478
    14271479
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