1 --- src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c.orig	2018-10-15 14:31:31 UTC
2 +++ src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
3 @@ -54,6 +54,7 @@ MALLOC_DEFINE(M_IPRTCONT, "iprtcont", "IPRT - contiguo
4 
5  DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
6  {
7 +    IPRT_FREEBSD_SAVE_EFL_AC();
8      size_t      cbAllocated = cb;
9      PRTMEMHDR   pHdr        = NULL;
10 
11 @@ -76,8 +77,10 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
12          cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE);
13 
14          pVmObject = vm_object_allocate(OBJT_DEFAULT, cbAllocated >> PAGE_SHIFT);
15 -        if (!pVmObject)
16 +        if (!pVmObject) {
17 +            IPRT_FREEBSD_RESTORE_EFL_AC();
18              return VERR_NO_EXEC_MEMORY;
19 +        }
20 
21          /* Addr contains a start address vm_map_find will start searching for suitable space at. */
22  #if __FreeBSD_version >= 1000055
23 @@ -114,6 +117,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
24                                   fFlags & RTMEMHDR_FLAG_ZEROED ? M_NOWAIT | M_ZERO : M_NOWAIT);
25      }
26 
27 +    IPRT_FREEBSD_RESTORE_EFL_AC();
28 +
29      if (RT_UNLIKELY(!pHdr))
30          return VERR_NO_MEMORY;
31 
32 @@ -129,6 +134,8 @@ DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFl
33 
34  DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
35  {
36 +    IPRT_FREEBSD_SAVE_EFL_AC();
37 +
38      pHdr->u32Magic += 1;
39 
40  #ifdef RT_ARCH_AMD64
41 @@ -141,11 +148,14 @@ DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
42      else
43  #endif
44          free(pHdr, M_IPRTHEAP);
45 +
46 +    IPRT_FREEBSD_RESTORE_EFL_AC();
47  }
48 
49 
50  RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb)
51  {
52 +    IPRT_FREEBSD_SAVE_EFL_AC();
53      void *pv;
54 
55      /*
56 @@ -170,6 +180,7 @@ RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_
57          *pPhys = vtophys(pv);
58          Assert(!(*pPhys & PAGE_OFFSET_MASK));
59      }
60 +    IPRT_FREEBSD_RESTORE_EFL_AC();
61      return pv;
62  }
63 
64 @@ -179,7 +190,9 @@ RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
65      if (pv)
66      {
67          AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
68 +        IPRT_FREEBSD_SAVE_EFL_AC();
69          contigfree(pv, cb, M_IPRTCONT);
70 +        IPRT_FREEBSD_RESTORE_EFL_AC();
71      }
72  }
73 
74