]> git.saurik.com Git - apple/xnu.git/blobdiff - libkern/libkern/OSKextLib.h
xnu-4570.1.46.tar.gz
[apple/xnu.git] / libkern / libkern / OSKextLib.h
index 6ecc3548d7f0f7bc7c8595e6e711df5fe56fb14a..a08218c2e75ffe5da18270a84377928931241001 100644 (file)
@@ -35,13 +35,14 @@ __BEGIN_DECLS
 #include <stdint.h>
 #include <mach/kmod.h>
 #include <mach/vm_types.h>
 #include <stdint.h>
 #include <mach/kmod.h>
 #include <mach/vm_types.h>
+#include <uuid/uuid.h>
 
 #ifdef KERNEL
 #include <libkern/OSTypes.h>
 #include <libkern/OSReturn.h>
 #else
 #include <CoreFoundation/CoreFoundation.h>
 
 #ifdef KERNEL
 #include <libkern/OSTypes.h>
 #include <libkern/OSReturn.h>
 #else
 #include <CoreFoundation/CoreFoundation.h>
-#include <System/libkern/OSReturn.h>
+#include <libkern/OSReturn.h>
 #endif /* KERNEL */
 
 /*!
 #endif /* KERNEL */
 
 /*!
@@ -237,6 +238,12 @@ __BEGIN_DECLS
  */
 #define kOSKextReturnStopping                        libkern_kext_err(0x1a)
 
  */
 #define kOSKextReturnStopping                        libkern_kext_err(0x1a)
 
+/*!
+ * @define   kOSKextReturnSystemPolicy
+ * @abstract The kext was prevented from loading due to system policy.
+ */
+#define kOSKextReturnSystemPolicy                    libkern_kext_err(0x1b)
+
 #if PRAGMA_MARK
 #pragma mark -
 /********************************************************************/
 #if PRAGMA_MARK
 #pragma mark -
 /********************************************************************/
@@ -346,6 +353,15 @@ __BEGIN_DECLS
  */
 #define kIOPersonalityPublisherKey              "IOPersonalityPublisher"
 
  */
 #define kIOPersonalityPublisherKey              "IOPersonalityPublisher"
 
+#if CONFIG_KEC_FIPS
+/*
+ * @define   kAppleTextHashesKey
+ * @abstract A dictionary conataining hashes for corecrypto kext.
+ */
+#define kAppleTextHashesKey                     "AppleTextHashes"
+#endif
+
+
 
 #if PRAGMA_MARK
 /********************************************************************/
 
 #if PRAGMA_MARK
 /********************************************************************/
@@ -454,6 +470,7 @@ __BEGIN_DECLS
  * about itself.
  */
 
  * about itself.
  */
 
+#ifdef KERNEL
 /*!
  * @typedef OSKextLoadTag
  *
 /*!
  * @typedef OSKextLoadTag
  *
@@ -473,6 +490,22 @@ __BEGIN_DECLS
  * <code>@link OSKextReleaseKextWithLoadTag
  * OSKextReleaseKextWithLoadTag@/link</code>.
  */
  * <code>@link OSKextReleaseKextWithLoadTag
  * OSKextReleaseKextWithLoadTag@/link</code>.
  */
+#else
+/*!
+ * @typedef OSKextLoadTag
+ *
+ * @abstract
+ * A unique identifier assigned to a loaded instanace of a kext.
+ *
+ * @discussion
+ * If a kext is unloaded and later reloaded, the new instance
+ * has a different load tag.
+ *
+ * A kext can get its own load tag in the <code>kmod_info_t</code>
+ * structure passed into its module start routine, as the
+ * <code>id</code> field (cast to this type).
+ */
+#endif
 typedef uint32_t  OSKextLoadTag;
 
 /*!
 typedef uint32_t  OSKextLoadTag;
 
 /*!
@@ -484,7 +517,6 @@ typedef uint32_t  OSKextLoadTag;
  */
 #define  kOSKextInvalidLoadTag  ((OSKextLoadTag)(-1))
 
  */
 #define  kOSKextInvalidLoadTag  ((OSKextLoadTag)(-1))
 
-
 #ifdef KERNEL
 
 /* Make these visible to kexts only and *not* the kernel.
 #ifdef KERNEL
 
 /* Make these visible to kexts only and *not* the kernel.
@@ -853,6 +885,62 @@ OSReturn OSKextCancelRequest(
     void             ** contextOut);
 
 
     void             ** contextOut);
 
 
+/*!
+ * @function OSKextGrabPgoData
+ *
+ * @abstract
+ * Grab a LLVM profile data buffer from a loaded kext.
+ *
+ * @param   uuid             the uuid identifying the kext to retrieve data from
+ * @param   pSize            pointer of where to store the size of the buffer.   May be NULL.
+ * @param   pBuffer          pointer to the output buffer.   May be NULL.
+ * @param   bufferSize       size of the buffer pointed to by pBuffer
+ * @param   wait_for_unload  (boolean) sleep until the kext is unloaded
+ * @param   metadata         (boolean) include metadata footer
+ *
+ * @result
+ * 0 on success
+ * ENOTSUP if the kext does not have profile data to retrieve.
+ * ENOTSUP if no kext with the given UUID is found
+ * ERRORS  if the provided buffer is too small
+ * EIO     internal error, such as if __llvm_profile_write_buffer_internal fails
+ */
+int
+OSKextGrabPgoData(uuid_t uuid,
+                  uint64_t *pSize,
+                  char *pBuffer,
+                  uint64_t bufferSize,
+                  int wait_for_unload,
+                  int metadata);
+
+/*!
+ * @function OSKextResetPgoCountersLock
+ *
+ * @abstract
+ * Call this function before trapping into the debugger to call OSKextResetPgoCounters.
+ */
+void
+OSKextResetPgoCountersLock(void);
+
+/*!
+ * @function OSKextResetPgoCountersUnlock
+ *
+ * @abstract
+ * Call this function after trapping into the debugger to call OSKextResetPgoCounters.
+ */
+void
+OSKextResetPgoCountersUnlock(void);
+
+/*!
+ * @function OSKextResetPgoCounters
+ *
+ * @abstract Reset the PGO counters for all kexts.  Call only from debugger
+ * context, while holding OSKextResetPgoCountersLock().
+ */
+void
+OSKextResetPgoCounters(void);
+
+
 #if PRAGMA_MARK
 #pragma mark -
 /********************************************************************/
 #if PRAGMA_MARK
 #pragma mark -
 /********************************************************************/
@@ -916,6 +1004,25 @@ extern const void * gOSKextUnresolved;
 #define OSKextSymbolIsResolved(weak_sym)        \
     (&(weak_sym) != gOSKextUnresolved)
 
 #define OSKextSymbolIsResolved(weak_sym)        \
     (&(weak_sym) != gOSKextUnresolved)
 
+
+#if CONFIG_KEC_FIPS
+
+#if PRAGMA_MARK
+#pragma mark -
+/********************************************************************/
+#pragma mark Kernel External Components for FIPS compliance
+/********************************************************************/
+#endif
+
+// Kernel External Components for FIPS compliance (KEC_FIPS)
+// WARNING - ath_hash is owned by the kernel, do not free
+typedef struct AppleTEXTHash {
+    int                ath_version;    // version of this structure (value is 1 or 2)
+    int             ath_length;     // length of hash data
+    void *          ath_hash;       // hash extracted from AppleTextHashes dict 
+} AppleTEXTHash_t;
+#endif // CONFIG_KEC_FIPS
+
 #endif /* KERNEL */
 
 __END_DECLS
 #endif /* KERNEL */
 
 __END_DECLS