]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/x86_64/kpc_x86.c
xnu-7195.60.75.tar.gz
[apple/xnu.git] / osfmk / x86_64 / kpc_x86.c
index 5dc8518019986572d370083dee3a65c9481f55c1..fcd3a54c704e1002493c0060225d4848fddf7ddc 100644 (file)
@@ -631,9 +631,9 @@ get_interrupted_pc(bool *kernel_out)
 }
 
 static void
-kpc_sample_kperf_x86(uint32_t ctr, uint64_t count, uint64_t config)
+kpc_sample_kperf_x86(uint32_t ctr, uint32_t actionid, uint64_t count,
+    uint64_t config)
 {
-       uint32_t actionid = FIXED_ACTIONID(ctr);
        bool kernel = false;
        uintptr_t pc = get_interrupted_pc(&kernel);
        kperf_kpc_flags_t flags = kernel ? KPC_KERNEL_PC : 0;
@@ -666,14 +666,15 @@ kpc_pmi_handler(void)
                        FIXED_SHADOW(ctr)
                                += (kpc_fixed_max() - FIXED_RELOAD(ctr) + 1 /* Wrap */) + extra;
 
-                       BUF_INFO(PERF_KPC_FCOUNTER, ctr, FIXED_SHADOW(ctr), extra, FIXED_ACTIONID(ctr));
+                       uint32_t actionid = FIXED_ACTIONID(ctr);
+                       BUF_INFO(PERF_KPC_FCOUNTER, ctr, FIXED_SHADOW(ctr), extra, actionid);
 
-                       if (FIXED_ACTIONID(ctr)) {
-                               kpc_sample_kperf_x86(ctr, FIXED_SHADOW(ctr) + extra, 0);
+                       if (actionid != 0) {
+                               kpc_sample_kperf_x86(ctr, actionid, FIXED_SHADOW(ctr) + extra, 0);
                        }
                }
        }
-#endif
+#endif // FIXED_COUNTER_SHADOW
 
        for (ctr = 0; ctr < kpc_configurable_count(); ctr++) {
                if ((1ULL << ctr) & status) {
@@ -686,11 +687,12 @@ kpc_pmi_handler(void)
                         * bits are in the correct state before the call to kperf_sample */
                        wrmsr64(MSR_IA32_PERF_GLOBAL_OVF_CTRL, 1ull << ctr);
 
-                       BUF_INFO(PERF_KPC_COUNTER, ctr, CONFIGURABLE_SHADOW(ctr), extra, CONFIGURABLE_ACTIONID(ctr));
+                       unsigned int actionid = CONFIGURABLE_ACTIONID(ctr);
+                       BUF_INFO(PERF_KPC_COUNTER, ctr, CONFIGURABLE_SHADOW(ctr), extra, actionid);
 
-                       if (CONFIGURABLE_ACTIONID(ctr)) {
+                       if (actionid != 0) {
                                uint64_t config = IA32_PERFEVTSELx(ctr);
-                               kpc_sample_kperf_x86(ctr + kpc_configurable_count(),
+                               kpc_sample_kperf_x86(ctr + kpc_fixed_count(), actionid,
                                    CONFIGURABLE_SHADOW(ctr) + extra, config);
                        }
                }