VirtualBox

Changeset 65792 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Feb 15, 2017 7:23:46 PM (8 years ago)
Author:
vboxsync
Message:

EM,GIM: Let EM be the only one to mess with VMCPU_FF_UNHALT and related waking up.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r64655 r65792  
    259259        return !!VMCPU_FF_IS_PENDING(pVCpu, (VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC));
    260260    return false;
     261}
     262
     263
     264/**
     265 * Unhalts and wakes up the given CPU.
     266 *
     267 * This is an API for assisting the KVM hypercall API in implementing KICK_CPU.
     268 * It sets VMCPU_FF_UNHALT for @a pVCpuDst and makes sure it is woken up.   If
     269 * the CPU isn't currently in a halt, the next HLT instruction it executes will
     270 * be affected.
     271 *
     272 * @returns GVMMR0SchedWakeUpEx result or VINF_SUCCESS depending on context.
     273 * @param   pVM             The cross context VM structure.
     274 * @param   pVCpuDst        The cross context virtual CPU structure of the
     275 *                          CPU to unhalt and wake up.  This is usually not the
     276 *                          same as the caller.
     277 * @thread  EMT
     278 */
     279VMM_INT_DECL(int) EMUnhaltAndWakeUp(PVM pVM, PVMCPU pVCpuDst)
     280{
     281    /*
     282     * Flag the current(/next) HLT to unhalt immediately.
     283     */
     284    VMCPU_FF_SET(pVCpuDst, VMCPU_FF_UNHALT);
     285
     286    /*
     287     * Wake up the EMT (technically should be abstracted by VMM/VMEmt, but
     288     * just do it here for now).
     289     */
     290#ifdef IN_RING0
     291    /* We might be here with preemption disabled or enabled (i.e. depending on
     292       thread-context hooks being used), so don't try obtaining the GVMMR0 used
     293       lock here. See @bugref{7270#c148}. */
     294    int rc = GVMMR0SchedWakeUpEx(pVM, pVCpuDst->idCpu, false /* fTakeUsedLock */);
     295    AssertRC(rc);
     296
     297#elif defined(IN_RING3)
     298    int rc = SUPR3CallVMMR0(pVM->pVMR0, pVCpuDst->idCpu, VMMR0_DO_GVMM_SCHED_WAKE_UP, NULL /* pvArg */);
     299    AssertRC(rc);
     300
     301#else
     302    /* Nothing to do for raw-mode, shouldn't really be used by raw-mode guests anyway. */
     303    Assert(pVM->cCpus == 1); NOREF(pVM);
     304    int rc = VINF_SUCCESS;
     305#endif
     306    return rc;
    261307}
    262308
  • trunk/src/VBox/VMM/VMMAll/GIMAllKvm.cpp

    r64310 r65792  
    103103            if (uHyperArg1 < pVM->cCpus)
    104104            {
    105                 PVMCPU pVCpuTarget = &pVM->aCpus[uHyperArg1];   /** ASSUMES pVCpu index == ApicId of the VCPU. */
    106                 VMCPU_FF_SET(pVCpuTarget, VMCPU_FF_UNHALT);
    107 #ifdef IN_RING0
    108                 /*
    109                  * We might be here with preemption disabled or enabled (i.e. depending on thread-context hooks
    110                  * being used), so don't try obtaining the GVMMR0 used lock here. See @bugref{7270#c148}.
    111                  */
    112                 GVMMR0SchedWakeUpEx(pVM, pVCpuTarget->idCpu, false /* fTakeUsedLock */);
    113 #elif defined(IN_RING3)
    114                 int rc2 = SUPR3CallVMMR0(pVM->pVMR0, pVCpuTarget->idCpu, VMMR0_DO_GVMM_SCHED_WAKE_UP, NULL /* pvArg */);
    115                 AssertRC(rc2);
    116 #elif defined(IN_RC)
    117                 /* Nothing to do for raw-mode, shouldn't really be used by raw-mode guests anyway. */
    118                 Assert(pVM->cCpus == 1);
    119 #endif
     105                PVMCPU pVCpuDst = &pVM->aCpus[uHyperArg1];   /* ASSUMES pVCpu index == ApicId of the VCPU. */
     106                EMUnhaltAndWakeUp(pVM, pVCpuDst);
    120107                uHyperRet = KVM_HYPERCALL_RET_SUCCESS;
    121108            }
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