Changeset 57074 in vbox for trunk/src/VBox
- Timestamp:
- Jul 24, 2015 2:40:47 PM (9 years ago)
- 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 89 89 { 90 90 91 IPRT_DARWIN_SAVE_EFL_AC(); 91 92 pHdr = (PRTMEMHDR)IOMalloc(cb + sizeof(*pHdr)); 93 IPRT_DARWIN_RESTORE_EFL_AC(); 92 94 if (RT_UNLIKELY(!pHdr)) 93 95 { … … 119 121 } 120 122 else 123 { 124 IPRT_DARWIN_SAVE_EFL_AC(); 121 125 IOFree(pHdr, pHdr->cb + sizeof(*pHdr)); 126 IPRT_DARWIN_RESTORE_EFL_AC(); 127 } 122 128 } 123 129 … … 131 137 Assert(cb > 0); 132 138 RT_ASSERT_PREEMPTIBLE(); 139 IPRT_DARWIN_SAVE_EFL_AC(); 133 140 134 141 /* … … 146 153 { 147 154 *pPhys = PhysAddr; 155 IPRT_DARWIN_RESTORE_EFL_AC(); 148 156 return pv; 149 157 } … … 154 162 IOFreeContiguous(pv, cb); 155 163 } 164 165 IPRT_DARWIN_RESTORE_EFL_AC(); 156 166 return NULL; 157 167 } … … 165 175 Assert(cb > 0); 166 176 AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv)); 177 IPRT_DARWIN_SAVE_EFL_AC(); 167 178 168 179 cb = RT_ALIGN_Z(cb, PAGE_SIZE); 169 180 IOFreeContiguous(pv, cb); 181 182 IPRT_DARWIN_RESTORE_EFL_AC(); 170 183 } 171 184 } -
trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
r56290 r57074 355 355 { 356 356 PRTR0MEMOBJDARWIN pMemDarwin = (PRTR0MEMOBJDARWIN)pMem; 357 IPRT_DARWIN_SAVE_EFL_AC(); 357 358 358 359 /* … … 405 406 case RTR0MEMOBJTYPE_PHYS_NC: 406 407 AssertMsgFailed(("RTR0MEMOBJTYPE_PHYS_NC\n")); 408 IPRT_DARWIN_RESTORE_EFL_AC(); 407 409 return VERR_INTERNAL_ERROR; 408 410 409 411 case RTR0MEMOBJTYPE_RES_VIRT: 410 412 AssertMsgFailed(("RTR0MEMOBJTYPE_RES_VIRT\n")); 413 IPRT_DARWIN_RESTORE_EFL_AC(); 411 414 return VERR_INTERNAL_ERROR; 412 415 … … 417 420 default: 418 421 AssertMsgFailed(("enmType=%d\n", pMemDarwin->Core.enmType)); 422 IPRT_DARWIN_RESTORE_EFL_AC(); 419 423 return VERR_INTERNAL_ERROR; 420 424 } 421 425 426 IPRT_DARWIN_RESTORE_EFL_AC(); 422 427 return VINF_SUCCESS; 423 428 } … … 610 615 DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 611 616 { 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; 614 624 } 615 625 … … 617 627 DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 618 628 { 629 IPRT_DARWIN_SAVE_EFL_AC(); 630 619 631 /* 620 632 * Try IOMallocPhysical/IOMallocAligned first. … … 629 641 rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, false /* fContiguous */, 630 642 0 /* PhysMask */, _4G - PAGE_SIZE, RTR0MEMOBJTYPE_LOW); 643 644 IPRT_DARWIN_RESTORE_EFL_AC(); 631 645 return rc; 632 646 } … … 635 649 DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable) 636 650 { 651 IPRT_DARWIN_SAVE_EFL_AC(); 652 637 653 int rc = rtR0MemObjNativeAllocWorker(ppMem, cb, fExecutable, true /* fContiguous */, 638 654 ~(uint32_t)PAGE_OFFSET_MASK, _4G - PAGE_SIZE, … … 647 663 ~(uint32_t)PAGE_OFFSET_MASK, _4G - PAGE_SIZE, 648 664 RTR0MEMOBJTYPE_CONT); 665 IPRT_DARWIN_RESTORE_EFL_AC(); 649 666 return rc; 650 667 } … … 656 673 if (uAlignment != PAGE_SIZE) 657 674 return VERR_NOT_SUPPORTED; 675 676 IPRT_DARWIN_SAVE_EFL_AC(); 658 677 659 678 /* … … 676 695 PhysMask, PhysHighest, RTR0MEMOBJTYPE_PHYS); 677 696 } 697 698 IPRT_DARWIN_RESTORE_EFL_AC(); 678 699 return rc; 679 700 } … … 694 715 { 695 716 AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_SUPPORTED); 717 IPRT_DARWIN_SAVE_EFL_AC(); 696 718 697 719 /* … … 725 747 pMemDarwin->pMemDesc = pMemDesc; 726 748 *ppMem = &pMemDarwin->Core; 749 IPRT_DARWIN_RESTORE_EFL_AC(); 727 750 return VINF_SUCCESS; 728 751 } … … 736 759 else 737 760 AssertMsgFailed(("%#llx %llx\n", (unsigned long long)Phys, (unsigned long long)cb)); 761 IPRT_DARWIN_RESTORE_EFL_AC(); 738 762 return rc; 739 763 } … … 754 778 static int rtR0MemObjNativeLock(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess, task_t Task) 755 779 { 780 IPRT_DARWIN_SAVE_EFL_AC(); 756 781 NOREF(fAccess); 757 782 #ifdef USE_VM_MAP_WIRE … … 778 803 pMemDarwin->Core.u.Lock.R0Process = (RTR0PROCESS)Task; 779 804 *ppMem = &pMemDarwin->Core; 805 806 IPRT_DARWIN_RESTORE_EFL_AC(); 780 807 return VINF_SUCCESS; 781 808 } … … 807 834 pMemDarwin->pMemDesc = pMemDesc; 808 835 *ppMem = &pMemDarwin->Core; 836 837 IPRT_DARWIN_RESTORE_EFL_AC(); 809 838 return VINF_SUCCESS; 810 839 } … … 818 847 } 819 848 #endif 849 IPRT_DARWIN_RESTORE_EFL_AC(); 820 850 return rc; 821 851 } … … 856 886 if (uAlignment > PAGE_SIZE) 857 887 return VERR_NOT_SUPPORTED; 888 889 IPRT_DARWIN_SAVE_EFL_AC(); 858 890 859 891 /* … … 927 959 // pMemDarwin->pMemDesc = pMemDesc; 928 960 *ppMem = &pMemDarwin->Core; 961 962 IPRT_DARWIN_RESTORE_EFL_AC(); 929 963 return VINF_SUCCESS; 930 964 } … … 947 981 rc = VERR_MAP_FAILED; 948 982 } 983 984 IPRT_DARWIN_RESTORE_EFL_AC(); 949 985 return rc; 950 986 } … … 959 995 if (uAlignment > PAGE_SIZE) 960 996 return VERR_NOT_SUPPORTED; 997 998 IPRT_DARWIN_SAVE_EFL_AC(); 961 999 962 1000 /* … … 994 1032 pMemDarwin->pMemMap = pMemMap; 995 1033 *ppMem = &pMemDarwin->Core; 1034 1035 IPRT_DARWIN_RESTORE_EFL_AC(); 996 1036 return VINF_SUCCESS; 997 1037 } … … 1006 1046 rc = VERR_MAP_FAILED; 1007 1047 } 1048 1049 IPRT_DARWIN_RESTORE_EFL_AC(); 1008 1050 return rc; 1009 1051 } … … 1016 1058 if (!pVmMap) 1017 1059 return VERR_NOT_SUPPORTED; 1060 1061 IPRT_DARWIN_SAVE_EFL_AC(); 1018 1062 1019 1063 /* … … 1077 1121 Info.shared, Info.reserved, Info.offset, Info.behavior, Info.user_wired_count); 1078 1122 } 1123 IPRT_DARWIN_RESTORE_EFL_AC(); 1079 1124 return RTErrConvertFromDarwinKern(krc); 1080 1125 } … … 1100 1145 } 1101 1146 1147 IPRT_DARWIN_RESTORE_EFL_AC(); 1102 1148 return VINF_SUCCESS; 1103 1149 } -
trunk/src/VBox/Runtime/r0drv/darwin/memuserkernel-r0drv-darwin.cpp
r56290 r57074 43 43 { 44 44 RT_ASSERT_INTS_ON(); 45 IPRT_DARWIN_SAVE_EFL_AC(); 45 46 int rc = copyin((const user_addr_t)R3PtrSrc, pvDst, cb); 47 IPRT_DARWIN_RESTORE_EFL_AC(); 46 48 if (RT_LIKELY(rc == 0)) 47 49 return VINF_SUCCESS; … … 53 55 { 54 56 RT_ASSERT_INTS_ON(); 57 IPRT_DARWIN_SAVE_EFL_AC(); 55 58 int rc = copyout(pvSrc, R3PtrDst, cb); 59 IPRT_DARWIN_RESTORE_EFL_AC(); 56 60 if (RT_LIKELY(rc == 0)) 57 61 return VINF_SUCCESS; -
trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp
r56290 r57074 187 187 { 188 188 PRTMPARGS pArgs = (PRTMPARGS)pvArg; 189 IPRT_DARWIN_SAVE_EFL_AC(); 189 190 pArgs->pfnWorker(cpu_number(), pArgs->pvUser1, pArgs->pvUser2); 191 IPRT_DARWIN_RESTORE_EFL_AC(); 190 192 } 191 193 … … 194 196 { 195 197 RT_ASSERT_INTS_ON(); 198 IPRT_DARWIN_SAVE_EFL_AC(); 196 199 197 200 RTMPARGS Args; … … 202 205 Args.cHits = 0; 203 206 mp_rendezvous_no_intrs(rtmpOnAllDarwinWrapper, &Args); 207 208 IPRT_DARWIN_RESTORE_EFL_AC(); 204 209 return VINF_SUCCESS; 205 210 } … … 217 222 RTCPUID idCpu = cpu_number(); 218 223 if (pArgs->idCpu != idCpu) 224 { 225 IPRT_DARWIN_SAVE_EFL_AC(); 219 226 pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2); 227 IPRT_DARWIN_RESTORE_EFL_AC(); 228 } 220 229 } 221 230 … … 224 233 { 225 234 RT_ASSERT_INTS_ON(); 235 IPRT_DARWIN_SAVE_EFL_AC(); 226 236 227 237 RTMPARGS Args; … … 232 242 Args.cHits = 0; 233 243 mp_rendezvous_no_intrs(rtmpOnOthersDarwinWrapper, &Args); 244 245 IPRT_DARWIN_RESTORE_EFL_AC(); 234 246 return VINF_SUCCESS; 235 247 } … … 248 260 if (pArgs->idCpu == idCpu) 249 261 { 262 IPRT_DARWIN_SAVE_EFL_AC(); 250 263 pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2); 251 264 ASMAtomicIncU32(&pArgs->cHits); 265 IPRT_DARWIN_RESTORE_EFL_AC(); 252 266 } 253 267 } … … 257 271 { 258 272 RT_ASSERT_INTS_ON(); 273 IPRT_DARWIN_SAVE_EFL_AC(); 259 274 260 275 RTMPARGS Args; … … 265 280 Args.cHits = 0; 266 281 mp_rendezvous_no_intrs(rtmpOnSpecificDarwinWrapper, &Args); 282 283 IPRT_DARWIN_RESTORE_EFL_AC(); 267 284 return Args.cHits == 1 268 285 ? VINF_SUCCESS -
trunk/src/VBox/Runtime/r0drv/darwin/semevent-r0drv-darwin.cpp
r56290 r57074 308 308 */ 309 309 ASMAtomicWriteBool(&pThis->fHaveBlockedThreads, true); 310 IPRT_DARWIN_SAVE_EFL_AC(); 310 311 wait_interrupt_t fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE ? THREAD_ABORTSAFE : THREAD_UNINT; 311 312 wait_result_t rcWait; … … 319 320 (event_t)&Waiter, fInterruptible, u64AbsTime); 320 321 } 322 IPRT_DARWIN_RESTORE_EFL_AC(); 321 323 322 324 /* -
trunk/src/VBox/Runtime/r0drv/darwin/semeventmulti-r0drv-darwin.cpp
r56290 r57074 323 323 * Do the actual waiting. 324 324 */ 325 IPRT_DARWIN_SAVE_EFL_AC(); 325 326 ASMAtomicWriteBool(&pThis->fHaveBlockedThreads, true); 326 327 wait_interrupt_t fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE ? THREAD_ABORTSAFE : THREAD_UNINT; … … 335 336 (event_t)pThis, fInterruptible, u64AbsTime); 336 337 } 338 IPRT_DARWIN_RESTORE_EFL_AC(); 337 339 338 340 /* -
trunk/src/VBox/Runtime/r0drv/darwin/semfastmutex-r0drv-darwin.cpp
r56290 r57074 111 111 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 112 112 RT_ASSERT_PREEMPTIBLE(); 113 IPRT_DARWIN_SAVE_EFL_AC(); 113 114 114 115 lck_mtx_lock(pThis->pMtx); 116 117 IPRT_DARWIN_RESTORE_EFL_ONLY_AC(); 115 118 return VINF_SUCCESS; 116 119 } … … 123 126 AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE); 124 127 RT_ASSERT_PREEMPTIBLE(); 128 IPRT_DARWIN_SAVE_EFL_AC(); 125 129 126 130 lck_mtx_unlock(pThis->pMtx); 131 132 IPRT_DARWIN_RESTORE_EFL_ONLY_AC(); 127 133 return VINF_SUCCESS; 128 134 } -
trunk/src/VBox/Runtime/r0drv/darwin/semmutex-r0drv-darwin.cpp
r56290 r57074 171 171 * Go to sleep, use the address of the mutex instance as sleep/blocking/event id. 172 172 */ 173 IPRT_DARWIN_SAVE_EFL_AC(); 173 174 wait_result_t rcWait; 174 175 if (cMillies == RT_INDEFINITE_WAIT) … … 183 184 (event_t)pThis, fInterruptible, u64AbsTime); 184 185 } 186 IPRT_DARWIN_RESTORE_EFL_AC(); 187 185 188 /* 186 189 * Translate the rc. -
trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h
r56290 r57074 91 91 # define kIOMemoryMapperNone UINT32_C(0x800) 92 92 #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 /** @} */ 93 103 94 104 -
trunk/src/VBox/Runtime/r0drv/darwin/thread-r0drv-darwin.cpp
r56290 r57074 47 47 { 48 48 RT_ASSERT_PREEMPTIBLE(); 49 IPRT_DARWIN_SAVE_EFL_AC(); 50 49 51 uint64_t u64Deadline; 50 52 clock_interval_to_deadline(cMillies, kMillisecondScale, &u64Deadline); 51 53 clock_delay_until(u64Deadline); 54 55 IPRT_DARWIN_RESTORE_EFL_AC(); 52 56 return VINF_SUCCESS; 53 57 } … … 69 73 { 70 74 RT_ASSERT_PREEMPTIBLE(); 75 IPRT_DARWIN_SAVE_EFL_AC(); 76 71 77 thread_block(THREAD_CONTINUE_NULL); 78 79 IPRT_DARWIN_RESTORE_EFL_AC(); 72 80 return true; /* this is fishy */ 73 81 } -
trunk/src/VBox/Runtime/r0drv/darwin/threadpreempt-r0drv-darwin.cpp
r56362 r57074 174 174 lck_spin_t *pSpinLock = g_aPreemptHacks[idCpu].pSpinLock; 175 175 if (pSpinLock) 176 { 177 IPRT_DARWIN_SAVE_EFL_AC(); 176 178 lck_spin_unlock(pSpinLock); 179 IPRT_DARWIN_RESTORE_EFL_AC(); 180 } 177 181 else 178 182 AssertFailed();
Note:
See TracChangeset
for help on using the changeset viewer.