VirtualBox

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


Ignore:
Timestamp:
Aug 7, 2015 7:51:45 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102000
Message:

iprt/darwin/r0drv: More saving of EFLAGS/AC, seems anything that may block is evil (not a surprise).

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

Legend:

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

    r57074 r57246  
    101101    AssertPtrReturn(phEventSem, VERR_INVALID_POINTER);
    102102    RT_ASSERT_PREEMPTIBLE();
     103    IPRT_DARWIN_SAVE_EFL_AC();
    103104
    104105    PRTSEMEVENTINTERNAL pThis = (PRTSEMEVENTINTERNAL)RTMemAlloc(sizeof(*pThis));
     
    115116        {
    116117            *phEventSem = pThis;
     118            IPRT_DARWIN_RESTORE_EFL_AC();
    117119            return VINF_SUCCESS;
    118120        }
     
    121123        RTMemFree(pThis);
    122124    }
     125    IPRT_DARWIN_RESTORE_EFL_AC();
    123126    return VERR_NO_MEMORY;
    124127}
     
    147150    {
    148151        Assert(pThis->u32Magic != RTSEMEVENT_MAGIC);
     152        IPRT_DARWIN_SAVE_EFL_AC();
     153
    149154        lck_spin_destroy(pThis->pSpinlock, g_pDarwinLockGroup);
    150155        RTMemFree(pThis);
     156
     157        IPRT_DARWIN_RESTORE_EFL_AC();
    151158    }
    152159}
     
    160167    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
    161168    RT_ASSERT_INTS_ON();
     169    IPRT_DARWIN_SAVE_EFL_AC();
    162170
    163171    lck_spin_lock(pThis->pSpinlock);
     
    177185    rtR0SemEventDarwinRelease(pThis);
    178186
     187    IPRT_DARWIN_RESTORE_EFL_AC();
    179188    return VINF_SUCCESS;
    180189}
     
    190199    RT_ASSERT_PREEMPT_CPUID_VAR();
    191200    RT_ASSERT_INTS_ON();
     201    IPRT_DARWIN_SAVE_EFL_AC();
    192202
    193203    rtR0SemEventDarwinRetain(pThis);
     
    218228
    219229    RT_ASSERT_PREEMPT_CPUID();
     230    IPRT_DARWIN_RESTORE_EFL_AC();
    220231    return VINF_SUCCESS;
    221232}
     
    240251    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
    241252    AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);
     253    IPRT_DARWIN_SAVE_EFL_AC();
    242254
    243255    rtR0SemEventDarwinRetain(pThis);
     
    308320                 */
    309321                ASMAtomicWriteBool(&pThis->fHaveBlockedThreads, true);
    310                 IPRT_DARWIN_SAVE_EFL_AC();
    311322                wait_interrupt_t fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE ? THREAD_ABORTSAFE : THREAD_UNINT;
    312323                wait_result_t    rcWait;
     
    320331                                                     (event_t)&Waiter, fInterruptible, u64AbsTime);
    321332                }
    322                 IPRT_DARWIN_RESTORE_EFL_AC();
    323333
    324334                /*
     
    370380    lck_spin_unlock(pThis->pSpinlock);
    371381    rtR0SemEventDarwinRelease(pThis);
     382    IPRT_DARWIN_RESTORE_EFL_AC();
    372383    return rc;
    373384}
  • trunk/src/VBox/Runtime/r0drv/darwin/semeventmulti-r0drv-darwin.cpp

    r57074 r57246  
    104104    AssertPtrReturn(phEventMultiSem, VERR_INVALID_POINTER);
    105105    RT_ASSERT_PREEMPTIBLE();
     106    IPRT_DARWIN_SAVE_EFL_AC();
    106107
    107108    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pThis));
     
    117118        {
    118119            *phEventMultiSem = pThis;
     120            IPRT_DARWIN_RESTORE_EFL_AC();
    119121            return VINF_SUCCESS;
    120122        }
     
    123125        RTMemFree(pThis);
    124126    }
     127    IPRT_DARWIN_RESTORE_EFL_AC();
    125128    return VERR_NO_MEMORY;
    126129}
     
    148151    if (RT_UNLIKELY(ASMAtomicDecU32(&pThis->cRefs) == 0))
    149152    {
     153        IPRT_DARWIN_SAVE_EFL_AC();
    150154        Assert(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC);
     155
    151156        lck_spin_destroy(pThis->pSpinlock, g_pDarwinLockGroup);
    152157        RTMemFree(pThis);
     158
     159        IPRT_DARWIN_RESTORE_EFL_AC();
    153160    }
    154161}
     
    164171    Assert(pThis->cRefs > 0);
    165172    RT_ASSERT_INTS_ON();
     173    IPRT_DARWIN_SAVE_EFL_AC();
    166174
    167175    lck_spin_lock(pThis->pSpinlock);
     
    178186    rtR0SemEventMultiDarwinRelease(pThis);
    179187
     188    IPRT_DARWIN_RESTORE_EFL_AC();
    180189    return VINF_SUCCESS;
    181190}
     
    189198    RT_ASSERT_PREEMPT_CPUID_VAR();
    190199    RT_ASSERT_INTS_ON();
     200    IPRT_DARWIN_SAVE_EFL_AC();
    191201
    192202    rtR0SemEventMultiDarwinRetain(pThis);
     
    214224
    215225    RT_ASSERT_PREEMPT_CPUID();
     226    IPRT_DARWIN_RESTORE_EFL_AC();
    216227    return VINF_SUCCESS;
    217228}
     
    225236    RT_ASSERT_PREEMPT_CPUID_VAR();
    226237    RT_ASSERT_INTS_ON();
     238    IPRT_DARWIN_SAVE_EFL_AC();
    227239
    228240    rtR0SemEventMultiDarwinRetain(pThis);
     
    235247
    236248    RT_ASSERT_PREEMPT_CPUID();
     249    IPRT_DARWIN_RESTORE_EFL_AC();
    237250    return VINF_SUCCESS;
    238251}
     
    259272    if (uTimeout != 0 || (fFlags & RTSEMWAIT_FLAGS_INDEFINITE))
    260273        RT_ASSERT_PREEMPTIBLE();
     274    IPRT_DARWIN_SAVE_EFL_AC();
    261275
    262276    rtR0SemEventMultiDarwinRetain(pThis);
     
    323337                 * Do the actual waiting.
    324338                 */
    325                 IPRT_DARWIN_SAVE_EFL_AC();
    326339                ASMAtomicWriteBool(&pThis->fHaveBlockedThreads, true);
    327340                wait_interrupt_t fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE ? THREAD_ABORTSAFE : THREAD_UNINT;
     
    336349                                                     (event_t)pThis, fInterruptible, u64AbsTime);
    337350                }
    338                 IPRT_DARWIN_RESTORE_EFL_AC();
    339351
    340352                /*
     
    384396    lck_spin_unlock(pThis->pSpinlock);
    385397    rtR0SemEventMultiDarwinRelease(pThis);
     398
     399    IPRT_DARWIN_RESTORE_EFL_AC();
    386400    return rc;
    387401}
  • trunk/src/VBox/Runtime/r0drv/darwin/semfastmutex-r0drv-darwin.cpp

    r57074 r57246  
    6767    AssertPtrReturn(phFastMtx, VERR_INVALID_POINTER);
    6868    RT_ASSERT_PREEMPTIBLE();
     69    IPRT_DARWIN_SAVE_EFL_AC();
    6970
    7071    PRTSEMFASTMUTEXINTERNAL pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAlloc(sizeof(*pThis));
     
    7778        {
    7879            *phFastMtx = pThis;
     80            IPRT_DARWIN_RESTORE_EFL_AC();
    7981            return VINF_SUCCESS;
    8082        }
     
    8284        RTMemFree(pThis);
    8385    }
     86    IPRT_DARWIN_RESTORE_EFL_AC();
    8487    return VERR_NO_MEMORY;
    8588}
     
    9497    AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
    9598    RT_ASSERT_INTS_ON();
     99    IPRT_DARWIN_SAVE_EFL_AC();
    96100
    97101    ASMAtomicWriteU32(&pThis->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD);
     
    101105    RTMemFree(pThis);
    102106
     107    IPRT_DARWIN_RESTORE_EFL_AC();
    103108    return VINF_SUCCESS;
    104109}
  • trunk/src/VBox/Runtime/r0drv/darwin/semmutex-r0drv-darwin.cpp

    r57074 r57246  
    8181    AssertReturn(!(fFlags & ~RTSEMMUTEX_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
    8282    RT_ASSERT_PREEMPTIBLE();
     83    IPRT_DARWIN_SAVE_EFL_AC();
    8384
    8485    AssertCompile(sizeof(RTSEMMUTEXINTERNAL) > sizeof(void *));
     
    9697        {
    9798            *phMutexSem = pThis;
     99            IPRT_DARWIN_RESTORE_EFL_AC();
    98100            return VINF_SUCCESS;
    99101        }
     
    101103        RTMemFree(pThis);
    102104    }
     105    IPRT_DARWIN_RESTORE_EFL_AC();
    103106    return VERR_NO_MEMORY;
    104107}
     
    110113static void rtSemMutexDarwinFree(PRTSEMMUTEXINTERNAL pThis)
    111114{
     115    IPRT_DARWIN_SAVE_EFL_AC();
     116
    112117    lck_spin_unlock(pThis->pSpinlock);
    113118    lck_spin_destroy(pThis->pSpinlock, g_pDarwinLockGroup);
    114119    RTMemFree(pThis);
     120
     121    IPRT_DARWIN_RESTORE_EFL_AC();
    115122}
    116123
     
    127134    AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
    128135    RT_ASSERT_INTS_ON();
     136    IPRT_DARWIN_SAVE_EFL_AC();
    129137
    130138    /*
     
    142150        lck_spin_unlock(pThis->pSpinlock);
    143151
     152    IPRT_DARWIN_RESTORE_EFL_AC();
    144153    return VINF_SUCCESS;
    145154}
     
    171180     * Go to sleep, use the address of the mutex instance as sleep/blocking/event id.
    172181     */
    173     IPRT_DARWIN_SAVE_EFL_AC();
    174182    wait_result_t rcWait;
    175183    if (cMillies == RT_INDEFINITE_WAIT)
     
    184192                                         (event_t)pThis, fInterruptible, u64AbsTime);
    185193    }
    186     IPRT_DARWIN_RESTORE_EFL_AC();
    187194
    188195    /*
     
    268275    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, VERR_INVALID_HANDLE);
    269276    RT_ASSERT_PREEMPTIBLE();
     277    IPRT_DARWIN_SAVE_EFL_AC();
    270278
    271279    /*
     
    298306    /* Yawn, time for a nap... */
    299307    else
    300         return rtR0SemMutexDarwinRequestSleep(pThis, cMillies, fInterruptible, hNativeSelf);
     308    {
     309        rc = rtR0SemMutexDarwinRequestSleep(pThis, cMillies, fInterruptible, hNativeSelf);
     310        IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
     311        return rc;
     312    }
    301313
    302314    lck_spin_unlock(pThis->pSpinlock);
     315    IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
    303316    return rc;
    304317}
     
    338351    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, VERR_INVALID_HANDLE);
    339352    RT_ASSERT_PREEMPTIBLE();
     353    IPRT_DARWIN_SAVE_EFL_AC();
    340354
    341355    /*
     
    353367            pThis->hNativeOwner = NIL_RTNATIVETHREAD;
    354368            if (pThis->cWaiters > 0)
    355             {
    356                 int rc2=thread_wakeup_prim((event_t)pThis, TRUE /* one_thread */, THREAD_AWAKENED);
    357             }
     369                thread_wakeup_prim((event_t)pThis, TRUE /* one_thread */, THREAD_AWAKENED);
    358370
    359371        }
     
    365377
    366378    AssertRC(rc);
     379    IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
    367380    return VINF_SUCCESS;
    368381}
     
    377390    AssertPtrReturn(pThis, false);
    378391    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, false);
     392    IPRT_DARWIN_SAVE_EFL_AC();
    379393
    380394    /*
     
    385399    lck_spin_unlock(pThis->pSpinlock);
    386400
     401    IPRT_DARWIN_RESTORE_EFL_AC();
    387402    return fRc;
    388403}
  • trunk/src/VBox/Runtime/r0drv/darwin/spinlock-r0drv-darwin.cpp

    r57230 r57246  
    7070{
    7171    RT_ASSERT_PREEMPTIBLE();
     72    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
    7273    IPRT_DARWIN_SAVE_EFL_AC();
    73     AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
    7474
    7575    /*
  • trunk/src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp

    r57074 r57246  
    6969{
    7070    Assert(g_pDarwinLockGroup);
     71    IPRT_DARWIN_SAVE_EFL_AC();
    7172
    7273    for (size_t i = 0; i < RT_ELEMENTS(g_aPreemptHacks); i++)
     
    7677            return VERR_NO_MEMORY; /* (The caller will invoke rtThreadPreemptDarwinTerm) */
    7778    }
     79    IPRT_DARWIN_RESTORE_EFL_AC();
    7880    return VINF_SUCCESS;
    7981}
     
    8789void rtThreadPreemptDarwinTerm(void)
    8890{
     91    IPRT_DARWIN_SAVE_EFL_AC();
     92
    8993    for (size_t i = 0; i < RT_ELEMENTS(g_aPreemptHacks); i++)
    9094        if (g_aPreemptHacks[i].pSpinLock)
     
    9397            g_aPreemptHacks[i].pSpinLock = NULL;
    9498        }
     99
     100    IPRT_DARWIN_RESTORE_EFL_AC();
    95101}
    96102
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette