--- src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h.orig 2020-07-09 16:57:38 UTC +++ src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h @@ -60,6 +60,7 @@ #include #include #include +#include /* vm_cnt */ #include #include /* for vtophys */ #include @@ -67,10 +68,10 @@ #include #include /* KERN_SUCCESS ++ */ #include +#include #include /* vm_phys_alloc_* */ #include /* kmem_alloc_attr */ #include /* vm_contig_grow_cache */ -#include /* cnt */ #include #include @@ -114,6 +115,24 @@ */ #if 0 /** @todo Not available yet. */ # define USE_KMEM_ALLOC_PROT +#endif + +/** + * Macros for preserving EFLAGS.AC (despair / paranoid) + */ +#if __FreeBSD_version >= 1200076 && defined(RT_ARCH_AMD64) +# include +# include +# define IPRT_FREEBSD_SAVE_EFL_AC() RTCCUINTREG const fSavedEfl = ASMGetFlags() +# define IPRT_FREEBSD_RESTORE_EFL_AC() ASMSetFlags(fSavedEfl) +# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC() ASMChangeFlags(~X86_EFL_AC, fSavedEfl & X86_EFL_AC) +# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC_EX(f) ASMChangeFlags(~X86_EFL_AC, (f) & X86_EFL_AC) +# define VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV +#else +# define IPRT_FREEBSD_SAVE_EFL_AC() do { } while (0) +# define IPRT_FREEBSD_RESTORE_EFL_AC() do { } while (0) +# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC() do { } while (0) +# define IPRT_FREEBSD_RESTORE_EFL_ONLY_AC_EX(f) do { } while (0) #endif #endif