]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/ast.c
xnu-2422.1.72.tar.gz
[apple/xnu.git] / osfmk / kern / ast.c
index e7b895598ecbaf01560420bece5f61b29d5e2e37..ee197f7f65effeb5f636c5ff46a86f2751ca7cbd 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 #include <kern/thread.h>
 #include <kern/processor.h>
 #include <kern/spl.h>
 #include <kern/thread.h>
 #include <kern/processor.h>
 #include <kern/spl.h>
+#if CONFIG_TELEMETRY
+#include <kern/telemetry.h>
+#endif
 #include <kern/wait_queue.h>
 #include <kern/wait_queue.h>
+#include <kern/ledger.h>
 #include <mach/policy.h>
 #include <machine/trap.h> // for CHUD AST hook
 #include <machine/pal_routines.h>
 #include <mach/policy.h>
 #include <machine/trap.h> // for CHUD AST hook
 #include <machine/pal_routines.h>
-
+#include <security/mac_mach_internal.h> // for MACF AST hook
 
 volatile perfASTCallback perfASTHook;
 
 
 volatile perfASTCallback perfASTHook;
 
@@ -91,6 +95,8 @@ ast_init(void)
 {
 }
 
 {
 }
 
+extern void chudxnu_thread_ast(thread_t); // XXX this should probably be in a header...
+
 /*
  * Called at splsched.
  */
 /*
  * Called at splsched.
  */
@@ -157,12 +163,49 @@ ast_taken(
                                bsd_ast(thread);
                        }
 #endif
                                bsd_ast(thread);
                        }
 #endif
-
+#if CONFIG_MACF
+                       /*
+                        * Handle MACF hook.
+                        */
+                       if (reasons & AST_MACF) {
+                               thread_ast_clear(thread, AST_MACF);
+                               mac_thread_userret(thread);
+                       }
+#endif
                        /* 
                         * Thread APC hook.
                         */
                        if (reasons & AST_APC)
                                act_execute_returnhandlers();
                        /* 
                         * Thread APC hook.
                         */
                        if (reasons & AST_APC)
                                act_execute_returnhandlers();
+                       
+                       if (reasons & AST_GUARD) {
+                               thread_ast_clear(thread, AST_GUARD);
+                               guard_ast(thread);
+                       }
+                       
+                       if (reasons & AST_LEDGER) {
+                               thread_ast_clear(thread, AST_LEDGER);
+                               ledger_ast(thread);
+                       }
+
+                       /*
+                        * Kernel Profiling Hook
+                        */
+                       if (reasons & AST_KPERF) {
+                               thread_ast_clear(thread, AST_KPERF);
+                               chudxnu_thread_ast(thread);
+                       }
+
+#if CONFIG_TELEMETRY
+                       if (reasons & AST_TELEMETRY_ALL) {
+                               boolean_t interrupted_userspace;
+
+                               assert((reasons & AST_TELEMETRY_ALL) != AST_TELEMETRY_ALL); /* only one is valid at a time */
+                               interrupted_userspace = (reasons & AST_TELEMETRY_USER) ? TRUE : FALSE;
+                               thread_ast_clear(thread, AST_TELEMETRY_ALL);
+                               telemetry_ast(thread, interrupted_userspace);
+                       }
+#endif
 
                        ml_set_interrupts_enabled(FALSE);
 
 
                        ml_set_interrupts_enabled(FALSE);