#include <kern/page_decrypt.h>
#include <kern/processor.h>
+#include <sys/kdebug.h>
+
/* the lists of commpage routines are in commpage_asm.s */
extern commpage_descriptor* commpage_32_routines[];
extern commpage_descriptor* commpage_64_routines[];
CPUID_LEAF7_FEATURE_HLE);
setif(bits, kHasAVX2_0, cpuid_leaf7_features() &
CPUID_LEAF7_FEATURE_AVX2);
+ setif(bits, kHasRDSEED, cpuid_features() &
+ CPUID_LEAF7_FEATURE_RDSEED);
+ setif(bits, kHasADX, cpuid_features() &
+ CPUID_LEAF7_FEATURE_ADX);
uint64_t misc_enable = rdmsr64(MSR_IA32_MISC_ENABLE);
setif(bits, kHasENFSTRG, (misc_enable & 1ULL) &&
simple_lock_init(&commpage_active_cpus_lock, 0);
commpage_update_active_cpus();
- commpage_mach_approximate_time_init();
+ commpage_mach_approximate_time_init();
rtc_nanotime_init_commpage();
+ commpage_update_kdebug_enable();
}
/* Fill in the common routines during kernel initialization.
simple_unlock(&commpage_active_cpus_lock);
}
+/*
+ * Update the commpage data with the value of the "kdebug_enable"
+ * global so that userspace can avoid trapping into the kernel
+ * for kdebug_trace() calls. Serialization is handled
+ * by the caller in bsd/kern/kdebug.c.
+ */
+void
+commpage_update_kdebug_enable(void)
+{
+ volatile uint32_t *saved_data_ptr;
+ char *cp;
+
+ cp = commPagePtr32;
+ if (cp) {
+ cp += (_COMM_PAGE_KDEBUG_ENABLE - _COMM_PAGE32_BASE_ADDRESS);
+ saved_data_ptr = (volatile uint32_t *)cp;
+ *saved_data_ptr = kdebug_enable;
+ }
+
+ cp = commPagePtr64;
+ if ( cp ) {
+ cp += (_COMM_PAGE_KDEBUG_ENABLE - _COMM_PAGE32_START_ADDRESS);
+ saved_data_ptr = (volatile uint32_t *)cp;
+ *saved_data_ptr = kdebug_enable;
+ }
+}
+
+
/*
* update the commpage data for last known value of mach_absolute_time()
*/
{
#ifdef CONFIG_MACH_APPROXIMATE_TIME
uint64_t saved_data;
- char *cp;
-
- cp = commPagePtr32;
+ char *cp;
+
+ cp = commPagePtr32;
if ( cp ) {
- cp += (_COMM_PAGE_APPROX_TIME - _COMM_PAGE32_BASE_ADDRESS);
+ cp += (_COMM_PAGE_APPROX_TIME - _COMM_PAGE32_BASE_ADDRESS);
saved_data = *(uint64_t *)cp;
if (saved_data < abstime) {
/* ignoring the success/fail return value assuming that
OSCompareAndSwap64(saved_data, abstime, (uint64_t *)cp);
}
}
- cp = commPagePtr64;
+ cp = commPagePtr64;
if ( cp ) {
- cp += (_COMM_PAGE_APPROX_TIME - _COMM_PAGE32_START_ADDRESS);
+ cp += (_COMM_PAGE_APPROX_TIME - _COMM_PAGE32_START_ADDRESS);
saved_data = *(uint64_t *)cp;
if (saved_data < abstime) {
/* ignoring the success/fail return value assuming that