VirtualBox

Changeset 7352 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Mar 7, 2008 12:12:31 PM (17 years ago)
Author:
vboxsync
Message:

smp_call_function_single only exists starting 2.6.19. Added missing idCpu validation in RTMpOnSpecific.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c

    r7347 r7352  
    176176    PRTMPARGS pArgs = (PRTMPARGS)pvInfo;
    177177    ASMAtomicIncU32(&pArgs->cHits);
    178     pArgs->pfnWorker(smp_processor_id(), pArgs->pvUser1, pArgs->pvUser2);
     178    pArgs->pfnWorker(RTMpCpuId(), pArgs->pvUser1, pArgs->pvUser2);
    179179}
    180180
     
    184184    int rc;
    185185    RTMPARGS Args;
     186
    186187    Args.pfnWorker = pfnWorker;
    187188    Args.pvUser1 = pvUser1;
     
    215216    int rc;
    216217    RTMPARGS Args;
     218
    217219    Args.pfnWorker = pfnWorker;
    218220    Args.pvUser1 = pvUser1;
     
    234236
    235237
     238#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
     239/**
     240 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER
     241 * employed by RTMpOnSpecific on older kernels that lacks smp_call_function_single.
     242 *
     243 * @param   pvInfo      Pointer to the RTMPARGS package.
     244 */
     245static void rtmpOnSpecificLinuxWrapper(void *pvInfo)
     246{
     247    PRTMPARGS pArgs = (PRTMPARGS)pvInfo;
     248    RTCPUID idCpu = RTMpCpuId();
     249
     250    if (idCpu == pArgs->idCpu)
     251    {
     252        pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
     253        ASMAtomicIncU32(&pArgs->cHits);
     254    }
     255}
     256#endif
     257
     258
    236259RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
    237260{
    238261    int rc;
    239262    RTMPARGS Args;
     263
    240264    Args.pfnWorker = pfnWorker;
    241265    Args.pvUser1 = pvUser1;
     
    244268    Args.cHits = 0;
    245269
    246     /** @todo validate idCpu . */
     270    if (!RTMpDoesCpuExist(idCpu))
     271        return VERR_CPU_NOT_FOUND;
    247272
    248273# ifdef preempt_disable
     
    250275# endif
    251276    if (idCpu != RTMpCpuId())
    252         rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
     277    {
     278        if (RTMpIsCpuOnline(idCpu))
     279        {
     280#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     281            rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
     282#else
     283            rc = smp_call_function(rtmpOnSpecificLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
     284#endif
     285            Assert(rc == 0);
     286            rc = Args.cHits ? VINF_SUCCESS : VERR_CPU_OFFLINE;
     287        }
     288        else
     289            rc = VERR_CPU_OFFLINE;
     290    }
    253291    else
    254292    {
    255293        rtmpLinuxWrapper(&Args);
    256         rc = 0;
     294        rc = VINF_SUCCESS;
    257295    }
    258296# ifdef preempt_enable
     
    260298# endif
    261299
    262     Assert(rc == 0); NOREF(rc);
    263     return VINF_SUCCESS;
    264 }
    265 
     300    NOREF(rc);
     301    return rc;
     302}
     303
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