VirtualBox

Changeset 57074 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 24, 2015 2:40:47 PM (9 years ago)
Author:
vboxsync
Message:

r0drv/darwin: Added a whole bunch of EFLAGS.AC save and restores when calling into the kernel to see if it helps with our SMAP issue during init.

Location:
trunk/src/VBox/Runtime/r0drv/darwin
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp

    r56290 r57074  
    8989    {
    9090
     91        IPRT_DARWIN_SAVE_EFL_AC();
    9192        pHdr = (PRTMEMHDR)IOMalloc(cb + sizeof(*pHdr));
     93        IPRT_DARWIN_RESTORE_EFL_AC();
    9294        if (RT_UNLIKELY(!pHdr))
    9395        {
     
    119121    }
    120122    else
     123    {
     124        IPRT_DARWIN_SAVE_EFL_AC();
    121125        IOFree(pHdr, pHdr->cb + sizeof(*pHdr));
     126        IPRT_DARWIN_RESTORE_EFL_AC();
     127    }
    122128}
    123129
     
    131137    Assert(cb > 0);
    132138    RT_ASSERT_PREEMPTIBLE();
     139    IPRT_DARWIN_SAVE_EFL_AC();
    133140
    134141    /*
     
    146153            {
    147154                *pPhys = PhysAddr;
     155                IPRT_DARWIN_RESTORE_EFL_AC();
    148156                return pv;
    149157            }
     
    154162        IOFreeContiguous(pv, cb);
    155163    }
     164
     165    IPRT_DARWIN_RESTORE_EFL_AC();
    156166    return NULL;
    157167}
     
    165175        Assert(cb > 0);
    166176        AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
     177        IPRT_DARWIN_SAVE_EFL_AC();
    167178
    168179        cb = RT_ALIGN_Z(cb, PAGE_SIZE);
    169180        IOFreeContiguous(pv, cb);
     181
     182        IPRT_DARWIN_RESTORE_EFL_AC();
    170183    }
    171184}
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r56290 r57074  
    355355{
    356356    PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)pMem;
     357    IPRT_DARWIN_SAVE_EFL_AC();
    357358
    358359    /*
     
    405406        case RTR0MEMOBJTYPE_PHYS_NC:
    406407            AssertMsgFailed(("RTR0MEMOBJTYPE_PHYS_NC\n"));
     408            IPRT_DARWIN_RESTORE_EFL_AC();
    407409            return VERR_INTERNAL_ERROR;
    408410
    409411        case RTR0MEMOBJTYPE_RES_VIRT:
    410412            AssertMsgFailed(("RTR0MEMOBJTYPE_RES_VIRT\n"));
     413            IPRT_DARWIN_RESTORE_EFL_AC();
    411414            return VERR_INTERNAL_ERROR;
    412415
     
    417420        default:
    418421            AssertMsgFailed(("enmType=%d\n", pMemDarwin->Core.enmType));
     422            IPRT_DARWIN_RESTORE_EFL_AC();
    419423            return VERR_INTERNAL_ERROR;
    420424    }
    421425
     426    IPRT_DARWIN_RESTORE_EFL_AC();
    422427    return VINF_SUCCESS;
    423428}
     
    610615DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
    611616{
    612     return rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, false /* fContiguous */,
    613                                        0 /* PhysMask */, UINT64_MAX, RTR0MEMOBJTYPE_PAGE);
     617    IPRT_DARWIN_SAVE_EFL_AC();
     618
     619    int rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, false /* fContiguous */,
     620                                         0 /* PhysMask */, UINT64_MAX, RTR0MEMOBJTYPE_PAGE);
     621
     622    IPRT_DARWIN_RESTORE_EFL_AC();
     623    return rc;
    614624}
    615625
     
    617627DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
    618628{
     629    IPRT_DARWIN_SAVE_EFL_AC();
     630
    619631    /*
    620632     * Try IOMallocPhysical/IOMallocAligned first.
     
    629641        rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, false /* fContiguous */,
    630642                                         0 /* PhysMask */, _4G - PAGE_SIZE, RTR0MEMOBJTYPE_LOW);
     643
     644    IPRT_DARWIN_RESTORE_EFL_AC();
    631645    return rc;
    632646}
     
    635649DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
    636650{
     651    IPRT_DARWIN_SAVE_EFL_AC();
     652
    637653    int rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, true /* fContiguous */,
    638654                                         ~(uint32_t)PAGE_OFFSET_MASK, _4G - PAGE_SIZE,
     
    647663                                         ~(uint32_t)PAGE_OFFSET_MASK, _4G - PAGE_SIZE,
    648664                                         RTR0MEMOBJTYPE_CONT);
     665    IPRT_DARWIN_RESTORE_EFL_AC();
    649666    return rc;
    650667}
     
    656673    if (uAlignment != PAGE_SIZE)
    657674        return VERR_NOT_SUPPORTED;
     675
     676    IPRT_DARWIN_SAVE_EFL_AC();
    658677
    659678    /*
     
    676695                                         PhysMask, PhysHighest, RTR0MEMOBJTYPE_PHYS);
    677696    }
     697
     698    IPRT_DARWIN_RESTORE_EFL_AC();
    678699    return rc;
    679700}
     
    694715{
    695716    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_SUPPORTED);
     717    IPRT_DARWIN_SAVE_EFL_AC();
    696718
    697719    /*
     
    725747                pMemDarwin->pMemDesc = pMemDesc;
    726748                *ppMem = &pMemDarwin->Core;
     749                IPRT_DARWIN_RESTORE_EFL_AC();
    727750                return VINF_SUCCESS;
    728751            }
     
    736759    else
    737760        AssertMsgFailed(("%#llx %llx\n", (unsigned long long)Phys, (unsigned long long)cb));
     761    IPRT_DARWIN_RESTORE_EFL_AC();
    738762    return rc;
    739763}
     
    754778static int rtR0MemObjNativeLock(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess, task_t Task)
    755779{
     780    IPRT_DARWIN_SAVE_EFL_AC();
    756781    NOREF(fAccess);
    757782#ifdef USE_VM_MAP_WIRE
     
    778803            pMemDarwin->Core.u.Lock.R0Process = (RTR0PROCESS)Task;
    779804            *ppMem = &pMemDarwin->Core;
     805
     806            IPRT_DARWIN_RESTORE_EFL_AC();
    780807            return VINF_SUCCESS;
    781808        }
     
    807834                pMemDarwin->pMemDesc = pMemDesc;
    808835                *ppMem = &pMemDarwin->Core;
     836
     837                IPRT_DARWIN_RESTORE_EFL_AC();
    809838                return VINF_SUCCESS;
    810839            }
     
    818847    }
    819848#endif
     849    IPRT_DARWIN_RESTORE_EFL_AC();
    820850    return rc;
    821851}
     
    856886    if (uAlignment > PAGE_SIZE)
    857887        return VERR_NOT_SUPPORTED;
     888
     889    IPRT_DARWIN_SAVE_EFL_AC();
    858890
    859891    /*
     
    927959//                            pMemDarwin->pMemDesc = pMemDesc;
    928960                            *ppMem = &pMemDarwin->Core;
     961
     962                            IPRT_DARWIN_RESTORE_EFL_AC();
    929963                            return VINF_SUCCESS;
    930964                        }
     
    947981            rc = VERR_MAP_FAILED;
    948982    }
     983
     984    IPRT_DARWIN_RESTORE_EFL_AC();
    949985    return rc;
    950986}
     
    959995    if (uAlignment > PAGE_SIZE)
    960996        return VERR_NOT_SUPPORTED;
     997
     998    IPRT_DARWIN_SAVE_EFL_AC();
    961999
    9621000    /*
     
    9941032                    pMemDarwin->pMemMap = pMemMap;
    9951033                    *ppMem = &pMemDarwin->Core;
     1034
     1035                    IPRT_DARWIN_RESTORE_EFL_AC();
    9961036                    return VINF_SUCCESS;
    9971037                }
     
    10061046            rc = VERR_MAP_FAILED;
    10071047    }
     1048
     1049    IPRT_DARWIN_RESTORE_EFL_AC();
    10081050    return rc;
    10091051}
     
    10161058    if (!pVmMap)
    10171059        return VERR_NOT_SUPPORTED;
     1060
     1061    IPRT_DARWIN_SAVE_EFL_AC();
    10181062
    10191063    /*
     
    10771121                   Info.shared, Info.reserved, Info.offset, Info.behavior, Info.user_wired_count);
    10781122        }
     1123        IPRT_DARWIN_RESTORE_EFL_AC();
    10791124        return RTErrConvertFromDarwinKern(krc);
    10801125    }
     
    11001145    }
    11011146
     1147    IPRT_DARWIN_RESTORE_EFL_AC();
    11021148    return VINF_SUCCESS;
    11031149}
  • trunk/src/VBox/Runtime/r0drv/darwin/memuserkernel-r0drv-darwin.cpp

    r56290 r57074  
    4343{
    4444    RT_ASSERT_INTS_ON();
     45    IPRT_DARWIN_SAVE_EFL_AC();
    4546    int rc = copyin((const user_addr_t)R3PtrSrc, pvDst, cb);
     47    IPRT_DARWIN_RESTORE_EFL_AC();
    4648    if (RT_LIKELY(rc == 0))
    4749        return VINF_SUCCESS;
     
    5355{
    5456    RT_ASSERT_INTS_ON();
     57    IPRT_DARWIN_SAVE_EFL_AC();
    5558    int rc = copyout(pvSrc, R3PtrDst, cb);
     59    IPRT_DARWIN_RESTORE_EFL_AC();
    5660    if (RT_LIKELY(rc == 0))
    5761        return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp

    r56290 r57074  
    187187{
    188188    PRTMPARGS pArgs = (PRTMPARGS)pvArg;
     189    IPRT_DARWIN_SAVE_EFL_AC();
    189190    pArgs->pfnWorker(cpu_number(), pArgs->pvUser1, pArgs->pvUser2);
     191    IPRT_DARWIN_RESTORE_EFL_AC();
    190192}
    191193
     
    194196{
    195197    RT_ASSERT_INTS_ON();
     198    IPRT_DARWIN_SAVE_EFL_AC();
    196199
    197200    RTMPARGS Args;
     
    202205    Args.cHits = 0;
    203206    mp_rendezvous_no_intrs(rtmpOnAllDarwinWrapper, &Args);
     207
     208    IPRT_DARWIN_RESTORE_EFL_AC();
    204209    return VINF_SUCCESS;
    205210}
     
    217222    RTCPUID idCpu = cpu_number();
    218223    if (pArgs->idCpu != idCpu)
     224    {
     225        IPRT_DARWIN_SAVE_EFL_AC();
    219226        pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
     227        IPRT_DARWIN_RESTORE_EFL_AC();
     228    }
    220229}
    221230
     
    224233{
    225234    RT_ASSERT_INTS_ON();
     235    IPRT_DARWIN_SAVE_EFL_AC();
    226236
    227237    RTMPARGS Args;
     
    232242    Args.cHits = 0;
    233243    mp_rendezvous_no_intrs(rtmpOnOthersDarwinWrapper, &Args);
     244
     245    IPRT_DARWIN_RESTORE_EFL_AC();
    234246    return VINF_SUCCESS;
    235247}
     
    248260    if (pArgs->idCpu == idCpu)
    249261    {
     262        IPRT_DARWIN_SAVE_EFL_AC();
    250263        pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
    251264        ASMAtomicIncU32(&pArgs->cHits);
     265        IPRT_DARWIN_RESTORE_EFL_AC();
    252266    }
    253267}
     
    257271{
    258272    RT_ASSERT_INTS_ON();
     273    IPRT_DARWIN_SAVE_EFL_AC();
    259274
    260275    RTMPARGS Args;
     
    265280    Args.cHits = 0;
    266281    mp_rendezvous_no_intrs(rtmpOnSpecificDarwinWrapper, &Args);
     282
     283    IPRT_DARWIN_RESTORE_EFL_AC();
    267284    return Args.cHits == 1
    268285         ? VINF_SUCCESS
  • trunk/src/VBox/Runtime/r0drv/darwin/semevent-r0drv-darwin.cpp

    r56290 r57074  
    308308                 */
    309309                ASMAtomicWriteBool(&pThis->fHaveBlockedThreads, true);
     310                IPRT_DARWIN_SAVE_EFL_AC();
    310311                wait_interrupt_t fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE ? THREAD_ABORTSAFE : THREAD_UNINT;
    311312                wait_result_t    rcWait;
     
    319320                                                     (event_t)&Waiter, fInterruptible, u64AbsTime);
    320321                }
     322                IPRT_DARWIN_RESTORE_EFL_AC();
    321323
    322324                /*
  • trunk/src/VBox/Runtime/r0drv/darwin/semeventmulti-r0drv-darwin.cpp

    r56290 r57074  
    323323                 * Do the actual waiting.
    324324                 */
     325                IPRT_DARWIN_SAVE_EFL_AC();
    325326                ASMAtomicWriteBool(&pThis->fHaveBlockedThreads, true);
    326327                wait_interrupt_t fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE ? THREAD_ABORTSAFE : THREAD_UNINT;
     
    335336                                                     (event_t)pThis, fInterruptible, u64AbsTime);
    336337                }
     338                IPRT_DARWIN_RESTORE_EFL_AC();
    337339
    338340                /*
  • trunk/src/VBox/Runtime/r0drv/darwin/semfastmutex-r0drv-darwin.cpp

    r56290 r57074  
    111111    AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
    112112    RT_ASSERT_PREEMPTIBLE();
     113    IPRT_DARWIN_SAVE_EFL_AC();
    113114
    114115    lck_mtx_lock(pThis->pMtx);
     116
     117    IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
    115118    return VINF_SUCCESS;
    116119}
     
    123126    AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
    124127    RT_ASSERT_PREEMPTIBLE();
     128    IPRT_DARWIN_SAVE_EFL_AC();
    125129
    126130    lck_mtx_unlock(pThis->pMtx);
     131
     132    IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
    127133    return VINF_SUCCESS;
    128134}
  • trunk/src/VBox/Runtime/r0drv/darwin/semmutex-r0drv-darwin.cpp

    r56290 r57074  
    171171     * Go to sleep, use the address of the mutex instance as sleep/blocking/event id.
    172172     */
     173    IPRT_DARWIN_SAVE_EFL_AC();
    173174    wait_result_t rcWait;
    174175    if (cMillies == RT_INDEFINITE_WAIT)
     
    183184                                         (event_t)pThis, fInterruptible, u64AbsTime);
    184185    }
     186    IPRT_DARWIN_RESTORE_EFL_AC();
     187
    185188    /*
    186189     * Translate the rc.
  • trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h

    r56290 r57074  
    9191# define kIOMemoryMapperNone UINT32_C(0x800)
    9292#endif
     93
     94/** @name Macros for preserving EFLAGS.AC (despair / paranoid)
     95 * @remarks Unlike linux, we have to restore it unconditionally on darwin.
     96 * @{ */
     97#include <iprt/asm-amd64-x86.h>
     98#include <iprt/x86.h>
     99#define IPRT_DARWIN_SAVE_EFL_AC()           RTCCUINTREG fSavedEfl = ASMGetFlags();
     100#define IPRT_DARWIN_RESTORE_EFL_AC()        ASMSetFlags(fSavedEfl)
     101#define IPRT_DARWIN_RESTORE_EFL_ONLY_AC()   ASMSetFlags((ASMGetFlags() & ~IPRT_X86_EFL_AC) | (fSavedEfl & IPRT_X86_EFL_AC))
     102/** @} */
    93103
    94104
  • trunk/src/VBox/Runtime/r0drv/darwin/thread-r0drv-darwin.cpp

    r56290 r57074  
    4747{
    4848    RT_ASSERT_PREEMPTIBLE();
     49    IPRT_DARWIN_SAVE_EFL_AC();
     50
    4951    uint64_t u64Deadline;
    5052    clock_interval_to_deadline(cMillies, kMillisecondScale, &u64Deadline);
    5153    clock_delay_until(u64Deadline);
     54
     55    IPRT_DARWIN_RESTORE_EFL_AC();
    5256    return VINF_SUCCESS;
    5357}
     
    6973{
    7074    RT_ASSERT_PREEMPTIBLE();
     75    IPRT_DARWIN_SAVE_EFL_AC();
     76
    7177    thread_block(THREAD_CONTINUE_NULL);
     78
     79    IPRT_DARWIN_RESTORE_EFL_AC();
    7280    return true; /* this is fishy */
    7381}
  • trunk/src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp

    r56362 r57074  
    174174            lck_spin_t *pSpinLock = g_aPreemptHacks[idCpu].pSpinLock;
    175175            if (pSpinLock)
     176            {
     177                IPRT_DARWIN_SAVE_EFL_AC();
    176178                lck_spin_unlock(pSpinLock);
     179                IPRT_DARWIN_RESTORE_EFL_AC();
     180            }
    177181            else
    178182                AssertFailed();
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