xref: /xnu-10002.81.5/tests/cpu_counters/cpc_security_tests.c (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions // Copyright 2023 (c) Apple Inc.  All rights reserved.
2*5e3eaea3SApple OSS Distributions 
3*5e3eaea3SApple OSS Distributions #include <darwintest.h>
4*5e3eaea3SApple OSS Distributions #include <darwintest_utils.h>
5*5e3eaea3SApple OSS Distributions #include <dirent.h>
6*5e3eaea3SApple OSS Distributions #include <kperf/kpc.h>
7*5e3eaea3SApple OSS Distributions #include <kperfdata/kpep.h>
8*5e3eaea3SApple OSS Distributions #include <stdarg.h>
9*5e3eaea3SApple OSS Distributions #include <stdbool.h>
10*5e3eaea3SApple OSS Distributions #include <string.h>
11*5e3eaea3SApple OSS Distributions #include <sys/guarded.h>
12*5e3eaea3SApple OSS Distributions #include <sys/ioctl.h>
13*5e3eaea3SApple OSS Distributions #include <sys/monotonic.h>
14*5e3eaea3SApple OSS Distributions 
15*5e3eaea3SApple OSS Distributions #include "test_utils.h"
16*5e3eaea3SApple OSS Distributions 
17*5e3eaea3SApple OSS Distributions #if __arm64__
18*5e3eaea3SApple OSS Distributions #define HAS_CPC_SECURITY true
19*5e3eaea3SApple OSS Distributions #else // __arm64__
20*5e3eaea3SApple OSS Distributions #define HAS_CPC_SECURITY false
21*5e3eaea3SApple OSS Distributions #endif // !__arm64__
22*5e3eaea3SApple OSS Distributions 
23*5e3eaea3SApple OSS Distributions #define _T_META_REQUIRES_CPC_SUPPORT \
24*5e3eaea3SApple OSS Distributions 	T_META_REQUIRES_SYSCTL_EQ("kern.monotonic.supported", "1")
25*5e3eaea3SApple OSS Distributions 
26*5e3eaea3SApple OSS Distributions T_GLOBAL_META(
27*5e3eaea3SApple OSS Distributions 	T_META_NAMESPACE("xnu.cpc"),
28*5e3eaea3SApple OSS Distributions 	T_META_RADAR_COMPONENT_NAME("xnu"),
29*5e3eaea3SApple OSS Distributions 	T_META_RADAR_COMPONENT_VERSION("cpu counters"),
30*5e3eaea3SApple OSS Distributions 	T_META_OWNER("mwidmann"),
31*5e3eaea3SApple OSS Distributions 	T_META_CHECK_LEAKS(false),
32*5e3eaea3SApple OSS Distributions 	XNU_T_META_SOC_SPECIFIC,
33*5e3eaea3SApple OSS Distributions 	T_META_ENABLED(HAS_CPC_SECURITY),
34*5e3eaea3SApple OSS Distributions 	_T_META_REQUIRES_CPC_SUPPORT);
35*5e3eaea3SApple OSS Distributions 
36*5e3eaea3SApple OSS Distributions // Several of these tests have two variants to support running on development and release kernels.
37*5e3eaea3SApple OSS Distributions // Tests prefixed with `secure_` put the development kernel into a secure CPC mode while tests prefixed with `release_` can run on the RELEASE build variant.
38*5e3eaea3SApple OSS Distributions 
39*5e3eaea3SApple OSS Distributions // Metadata for running on a development kernel in CPC secure mode.
40*5e3eaea3SApple OSS Distributions #define _T_META_CPC_SECURE_ON_DEV \
41*5e3eaea3SApple OSS Distributions 	XNU_T_META_REQUIRES_DEVELOPMENT_KERNEL, T_META_SYSCTL_INT("kern.cpc.secure=1")
42*5e3eaea3SApple OSS Distributions 
43*5e3eaea3SApple OSS Distributions static void
_assert_kpep_ok(int kpep_err,const char * fmt,...)44*5e3eaea3SApple OSS Distributions _assert_kpep_ok(int kpep_err, const char *fmt, ...)
45*5e3eaea3SApple OSS Distributions {
46*5e3eaea3SApple OSS Distributions 	char msg[1024] = "";
47*5e3eaea3SApple OSS Distributions 	va_list args;
48*5e3eaea3SApple OSS Distributions 	va_start(args, fmt);
49*5e3eaea3SApple OSS Distributions 	vsnprintf(msg, sizeof(msg), fmt, args);
50*5e3eaea3SApple OSS Distributions 	va_end(args);
51*5e3eaea3SApple OSS Distributions 	T_QUIET;
52*5e3eaea3SApple OSS Distributions 	T_ASSERT_EQ(kpep_err, KPEP_ERR_NONE, "%s: %s", msg, kpep_strerror(kpep_err));
53*5e3eaea3SApple OSS Distributions }
54*5e3eaea3SApple OSS Distributions 
55*5e3eaea3SApple OSS Distributions static void
_skip_for_db(const char * kind,int kpep_err)56*5e3eaea3SApple OSS Distributions _skip_for_db(const char *kind, int kpep_err)
57*5e3eaea3SApple OSS Distributions {
58*5e3eaea3SApple OSS Distributions 	const char * const public_kpep_path = "/usr/share/kpep";
59*5e3eaea3SApple OSS Distributions 	const char * const internal_kpep_path = "/usr/local/share/kpep";
60*5e3eaea3SApple OSS Distributions 	const char * const paths[2] = { public_kpep_path, internal_kpep_path, };
61*5e3eaea3SApple OSS Distributions 	for (int i = 0; i < 2; i++) {
62*5e3eaea3SApple OSS Distributions 		const char * const path = paths[i];
63*5e3eaea3SApple OSS Distributions 		T_LOG("contents of %s:", path);
64*5e3eaea3SApple OSS Distributions 		DIR *dir = opendir(path);
65*5e3eaea3SApple OSS Distributions 		if (dir) {
66*5e3eaea3SApple OSS Distributions 			struct dirent *entry = NULL;
67*5e3eaea3SApple OSS Distributions 			while ((entry = readdir(dir)) != NULL) {
68*5e3eaea3SApple OSS Distributions 				T_LOG("    %s", entry->d_name);
69*5e3eaea3SApple OSS Distributions 			}
70*5e3eaea3SApple OSS Distributions 			(void)closedir(dir);
71*5e3eaea3SApple OSS Distributions 		} else {
72*5e3eaea3SApple OSS Distributions 			T_LOG("failed to open directory: %s", strerror(errno));
73*5e3eaea3SApple OSS Distributions 		}
74*5e3eaea3SApple OSS Distributions 	}
75*5e3eaea3SApple OSS Distributions 	int cpu_family = 0;
76*5e3eaea3SApple OSS Distributions 	size_t family_size = sizeof(cpu_family);
77*5e3eaea3SApple OSS Distributions 	int ret = sysctlbyname("hw.cpufamily", &cpu_family, &family_size, NULL, 0);
78*5e3eaea3SApple OSS Distributions 	if (ret != 0) {
79*5e3eaea3SApple OSS Distributions 		T_LOG("HW CPU family: 0x%8x", cpu_family);
80*5e3eaea3SApple OSS Distributions 	} else {
81*5e3eaea3SApple OSS Distributions 		T_LOG("failed to get hw.cpufamily: %s", strerror(errno));
82*5e3eaea3SApple OSS Distributions 	}
83*5e3eaea3SApple OSS Distributions 	T_SKIP("cannot open %s event database: %s", kind, kpep_strerror(kpep_err));
84*5e3eaea3SApple OSS Distributions }
85*5e3eaea3SApple OSS Distributions 
86*5e3eaea3SApple OSS Distributions // Check that a secure kernel disallows restricted events.
87*5e3eaea3SApple OSS Distributions 
88*5e3eaea3SApple OSS Distributions static void
check_secure_cpmu(void)89*5e3eaea3SApple OSS Distributions check_secure_cpmu(void)
90*5e3eaea3SApple OSS Distributions {
91*5e3eaea3SApple OSS Distributions 	kpep_db_t public_db = NULL;
92*5e3eaea3SApple OSS Distributions 	int ret = kpep_db_createx(NULL, KPEP_DB_FLAG_PUBLIC_ONLY, &public_db);
93*5e3eaea3SApple OSS Distributions 	if (ret != KPEP_ERR_NONE) {
94*5e3eaea3SApple OSS Distributions 		_skip_for_db("public", ret);
95*5e3eaea3SApple OSS Distributions 	}
96*5e3eaea3SApple OSS Distributions 	kpep_db_t internal_db = NULL;
97*5e3eaea3SApple OSS Distributions 	ret = kpep_db_createx(NULL, KPEP_DB_FLAG_INTERNAL_ONLY, &internal_db);
98*5e3eaea3SApple OSS Distributions 	if (ret != KPEP_ERR_NONE) {
99*5e3eaea3SApple OSS Distributions 		_skip_for_db("internal", ret);
100*5e3eaea3SApple OSS Distributions 	}
101*5e3eaea3SApple OSS Distributions 	const char *na = NULL;
102*5e3eaea3SApple OSS Distributions 	kpep_db_name(public_db, &na);
103*5e3eaea3SApple OSS Distributions 
104*5e3eaea3SApple OSS Distributions 	size_t internal_event_count = 0;
105*5e3eaea3SApple OSS Distributions 	ret = kpep_db_events_count(internal_db, &internal_event_count);
106*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "getting internal event count");
107*5e3eaea3SApple OSS Distributions 
108*5e3eaea3SApple OSS Distributions 	kpep_event_t *internal_events = calloc(internal_event_count,
109*5e3eaea3SApple OSS Distributions 	    sizeof(internal_events[0]));
110*5e3eaea3SApple OSS Distributions 	T_QUIET; T_WITH_ERRNO;
111*5e3eaea3SApple OSS Distributions 	T_ASSERT_NOTNULL(internal_events, "allocate space for internal events");
112*5e3eaea3SApple OSS Distributions 
113*5e3eaea3SApple OSS Distributions 	ret = kpep_db_events(internal_db, internal_events,
114*5e3eaea3SApple OSS Distributions 	    internal_event_count * sizeof(internal_events[0]));
115*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "getting internal events");
116*5e3eaea3SApple OSS Distributions 
117*5e3eaea3SApple OSS Distributions 	kpep_config_t config = NULL;
118*5e3eaea3SApple OSS Distributions 	ret = kpep_config_create(internal_db, &config);
119*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "creating event configuration");
120*5e3eaea3SApple OSS Distributions 	ret = kpep_config_force_counters(config);
121*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "forcing counters with configuration");
122*5e3eaea3SApple OSS Distributions 
123*5e3eaea3SApple OSS Distributions 	unsigned int tested = 0;
124*5e3eaea3SApple OSS Distributions 	unsigned int filtered = 0;
125*5e3eaea3SApple OSS Distributions 	unsigned int public_tested = 0;
126*5e3eaea3SApple OSS Distributions 	for (size_t i = 0; i < internal_event_count; i++) {
127*5e3eaea3SApple OSS Distributions 		kpep_event_t event = internal_events[i];
128*5e3eaea3SApple OSS Distributions 		const char *name = NULL;
129*5e3eaea3SApple OSS Distributions 		ret = kpep_event_alias(event, &name);
130*5e3eaea3SApple OSS Distributions 		if (!name) {
131*5e3eaea3SApple OSS Distributions 			ret = kpep_event_name(event, &name);
132*5e3eaea3SApple OSS Distributions 		}
133*5e3eaea3SApple OSS Distributions 		_assert_kpep_ok(ret, "getting event name");
134*5e3eaea3SApple OSS Distributions 		if (strncmp(name, "FIXED", strlen("FIXED")) == 0) {
135*5e3eaea3SApple OSS Distributions 			T_LOG("skipping non-configurable %s event", name);
136*5e3eaea3SApple OSS Distributions 			continue;
137*5e3eaea3SApple OSS Distributions 		}
138*5e3eaea3SApple OSS Distributions 		bool empty_event = strcmp(name, "NO_EVNT") == 0;
139*5e3eaea3SApple OSS Distributions 		if (empty_event) {
140*5e3eaea3SApple OSS Distributions 			continue;
141*5e3eaea3SApple OSS Distributions 		}
142*5e3eaea3SApple OSS Distributions 
143*5e3eaea3SApple OSS Distributions 		kpep_event_t public_event = NULL;
144*5e3eaea3SApple OSS Distributions 		ret = kpep_db_event(public_db, name, &public_event);
145*5e3eaea3SApple OSS Distributions 		bool internal_only = ret == KPEP_ERR_EVENT_NOT_FOUND;
146*5e3eaea3SApple OSS Distributions 		ret = kpep_config_add_event(config, &event, 0, NULL);
147*5e3eaea3SApple OSS Distributions 		_assert_kpep_ok(ret, "adding event %s to configuration", name);
148*5e3eaea3SApple OSS Distributions 
149*5e3eaea3SApple OSS Distributions 		ret = kpep_config_apply(config);
150*5e3eaea3SApple OSS Distributions 		bool not_permitted = ret == KPEP_ERR_ERRNO && errno == EPERM;
151*5e3eaea3SApple OSS Distributions 		if (not_permitted) {
152*5e3eaea3SApple OSS Distributions 			if (!internal_only) {
153*5e3eaea3SApple OSS Distributions 				T_LOG("failed to configure public event %s", name);
154*5e3eaea3SApple OSS Distributions 			}
155*5e3eaea3SApple OSS Distributions 			filtered++;
156*5e3eaea3SApple OSS Distributions 		} else if (internal_only) {
157*5e3eaea3SApple OSS Distributions 			T_FAIL("configured internal-only event %s with secure CPC", name);
158*5e3eaea3SApple OSS Distributions 		} else {
159*5e3eaea3SApple OSS Distributions 			public_tested++;
160*5e3eaea3SApple OSS Distributions 		}
161*5e3eaea3SApple OSS Distributions 		ret = kpep_config_remove_event(config, 0);
162*5e3eaea3SApple OSS Distributions 		_assert_kpep_ok(ret, "removing event %s from configuration", name);
163*5e3eaea3SApple OSS Distributions 		tested++;
164*5e3eaea3SApple OSS Distributions 	}
165*5e3eaea3SApple OSS Distributions 
166*5e3eaea3SApple OSS Distributions 	T_LOG("tested %u internal/public events", tested);
167*5e3eaea3SApple OSS Distributions 	T_LOG("correctly permitted to configure %u public events", public_tested);
168*5e3eaea3SApple OSS Distributions 	T_LOG("correctly not permitted to configure %u internal-only events",
169*5e3eaea3SApple OSS Distributions 	    filtered);
170*5e3eaea3SApple OSS Distributions 	kpep_config_free(config);
171*5e3eaea3SApple OSS Distributions 	kpep_db_free(public_db);
172*5e3eaea3SApple OSS Distributions 	kpep_db_free(internal_db);
173*5e3eaea3SApple OSS Distributions }
174*5e3eaea3SApple OSS Distributions 
175*5e3eaea3SApple OSS Distributions T_DECL(secure_cpmu_event_restrictions, "secured CPMU should be restricted to known events",
176*5e3eaea3SApple OSS Distributions     _T_META_CPC_SECURE_ON_DEV)
177*5e3eaea3SApple OSS Distributions {
178*5e3eaea3SApple OSS Distributions 	check_secure_cpmu();
179*5e3eaea3SApple OSS Distributions }
180*5e3eaea3SApple OSS Distributions 
181*5e3eaea3SApple OSS Distributions T_DECL(release_cpmu_event_restrictions, "release CPMU should be restricted to known events",
182*5e3eaea3SApple OSS Distributions     XNU_T_META_REQUIRES_RELEASE_KERNEL)
183*5e3eaea3SApple OSS Distributions {
184*5e3eaea3SApple OSS Distributions 	check_secure_cpmu();
185*5e3eaea3SApple OSS Distributions }
186*5e3eaea3SApple OSS Distributions 
187*5e3eaea3SApple OSS Distributions #define UNCORE_DEV_PATH "/dev/monotonic/uncore"
188*5e3eaea3SApple OSS Distributions #define UPMU_REF_CYCLES 0x02
189*5e3eaea3SApple OSS Distributions 
190*5e3eaea3SApple OSS Distributions static void
check_secure_upmu(void)191*5e3eaea3SApple OSS Distributions check_secure_upmu(void)
192*5e3eaea3SApple OSS Distributions {
193*5e3eaea3SApple OSS Distributions 	guardid_t guard;
194*5e3eaea3SApple OSS Distributions 	int fd;
195*5e3eaea3SApple OSS Distributions 
196*5e3eaea3SApple OSS Distributions 	guard = 0xa5adcafe;
197*5e3eaea3SApple OSS Distributions 
198*5e3eaea3SApple OSS Distributions 	T_SETUPBEGIN;
199*5e3eaea3SApple OSS Distributions 
200*5e3eaea3SApple OSS Distributions 	fd = guarded_open_np(UNCORE_DEV_PATH, &guard,
201*5e3eaea3SApple OSS Distributions 	    GUARD_CLOSE | GUARD_DUP | GUARD_WRITE, O_CLOEXEC | O_EXCL);
202*5e3eaea3SApple OSS Distributions 	if (fd < 0 && errno == ENOENT) {
203*5e3eaea3SApple OSS Distributions 		T_SKIP("uncore counters are unsupported");
204*5e3eaea3SApple OSS Distributions 	}
205*5e3eaea3SApple OSS Distributions 
206*5e3eaea3SApple OSS Distributions 	union monotonic_ctl_add add_ctl = {
207*5e3eaea3SApple OSS Distributions 		.in.config.event = UPMU_REF_CYCLES,
208*5e3eaea3SApple OSS Distributions 		.in.config.allowed_ctr_mask = 0xffff,
209*5e3eaea3SApple OSS Distributions 	};
210*5e3eaea3SApple OSS Distributions 
211*5e3eaea3SApple OSS Distributions 	T_SETUPEND;
212*5e3eaea3SApple OSS Distributions 
213*5e3eaea3SApple OSS Distributions 	int ret = ioctl(fd, MT_IOC_ADD, &add_ctl);
214*5e3eaea3SApple OSS Distributions 	T_EXPECT_POSIX_FAILURE(ret, EPERM,
215*5e3eaea3SApple OSS Distributions 	    "should not be allowed to count any events on UPMU");
216*5e3eaea3SApple OSS Distributions }
217*5e3eaea3SApple OSS Distributions 
218*5e3eaea3SApple OSS Distributions T_DECL(secure_upmu_event_restrictions, "secured UPMU should be restricted to no events",
219*5e3eaea3SApple OSS Distributions     _T_META_CPC_SECURE_ON_DEV)
220*5e3eaea3SApple OSS Distributions {
221*5e3eaea3SApple OSS Distributions 	check_secure_upmu();
222*5e3eaea3SApple OSS Distributions }
223*5e3eaea3SApple OSS Distributions 
224*5e3eaea3SApple OSS Distributions T_DECL(release_upmu_event_restrictions, "release UPMU should be restricted to no events",
225*5e3eaea3SApple OSS Distributions     XNU_T_META_REQUIRES_RELEASE_KERNEL)
226*5e3eaea3SApple OSS Distributions {
227*5e3eaea3SApple OSS Distributions 	check_secure_upmu();
228*5e3eaea3SApple OSS Distributions }
229*5e3eaea3SApple OSS Distributions 
230*5e3eaea3SApple OSS Distributions // Check that events which are exposed publicly are allowed to be configured.
231*5e3eaea3SApple OSS Distributions 
232*5e3eaea3SApple OSS Distributions static void
check_event_coverage(kpep_db_flags_t flag,const char * kind)233*5e3eaea3SApple OSS Distributions check_event_coverage(kpep_db_flags_t flag, const char *kind)
234*5e3eaea3SApple OSS Distributions {
235*5e3eaea3SApple OSS Distributions 	kpep_db_t db = NULL;
236*5e3eaea3SApple OSS Distributions 	int ret = kpep_db_createx(NULL, flag, &db);
237*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "creating %s event database", kind);
238*5e3eaea3SApple OSS Distributions 
239*5e3eaea3SApple OSS Distributions 	size_t event_count = 0;
240*5e3eaea3SApple OSS Distributions 	ret = kpep_db_events_count(db, &event_count);
241*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "getting %s event count", kind);
242*5e3eaea3SApple OSS Distributions 
243*5e3eaea3SApple OSS Distributions 	kpep_event_t *events = calloc(event_count, sizeof(events[0]));
244*5e3eaea3SApple OSS Distributions 	T_QUIET; T_WITH_ERRNO;
245*5e3eaea3SApple OSS Distributions 	T_ASSERT_NOTNULL(events, "allocate space for events");
246*5e3eaea3SApple OSS Distributions 
247*5e3eaea3SApple OSS Distributions 	ret = kpep_db_events(db, events, event_count * sizeof(events[0]));
248*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "getting public events");
249*5e3eaea3SApple OSS Distributions 
250*5e3eaea3SApple OSS Distributions 	kpep_config_t config = NULL;
251*5e3eaea3SApple OSS Distributions 	ret = kpep_config_create(db, &config);
252*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "creating event configuration");
253*5e3eaea3SApple OSS Distributions 	ret = kpep_config_force_counters(config);
254*5e3eaea3SApple OSS Distributions 	_assert_kpep_ok(ret, "forcing counters with configuration");
255*5e3eaea3SApple OSS Distributions 
256*5e3eaea3SApple OSS Distributions 	unsigned int tested = 0;
257*5e3eaea3SApple OSS Distributions 	for (size_t i = 0; i < event_count; i++) {
258*5e3eaea3SApple OSS Distributions 		kpep_event_t event = events[i];
259*5e3eaea3SApple OSS Distributions 		const char *name = NULL;
260*5e3eaea3SApple OSS Distributions 		ret = kpep_event_name(event, &name);
261*5e3eaea3SApple OSS Distributions 		_assert_kpep_ok(ret, "getting event name");
262*5e3eaea3SApple OSS Distributions 		if (strncmp(name, "FIXED", strlen("FIXED")) == 0) {
263*5e3eaea3SApple OSS Distributions 			T_LOG("skipping non-configurable %s event", name);
264*5e3eaea3SApple OSS Distributions 			continue;
265*5e3eaea3SApple OSS Distributions 		}
266*5e3eaea3SApple OSS Distributions 
267*5e3eaea3SApple OSS Distributions 		ret = kpep_config_add_event(config, &event, 0, NULL);
268*5e3eaea3SApple OSS Distributions 		_assert_kpep_ok(ret, "adding event %s to configuration", name);
269*5e3eaea3SApple OSS Distributions 
270*5e3eaea3SApple OSS Distributions 		ret = kpep_config_apply(config);
271*5e3eaea3SApple OSS Distributions 		if (ret == KPEP_ERR_ERRNO && errno == EPERM) {
272*5e3eaea3SApple OSS Distributions 			T_FAIL("failed to configure %s event %s with secure CPC", kind, name);
273*5e3eaea3SApple OSS Distributions 		} else {
274*5e3eaea3SApple OSS Distributions 			_assert_kpep_ok(ret, "applying configuration with event %s", name);
275*5e3eaea3SApple OSS Distributions 		}
276*5e3eaea3SApple OSS Distributions 		ret = kpep_config_remove_event(config, 0);
277*5e3eaea3SApple OSS Distributions 		_assert_kpep_ok(ret, "removing event %s from configuration", name);
278*5e3eaea3SApple OSS Distributions 		tested++;
279*5e3eaea3SApple OSS Distributions 	}
280*5e3eaea3SApple OSS Distributions 
281*5e3eaea3SApple OSS Distributions 	T_LOG("successfully configured %u %s events", tested, kind);
282*5e3eaea3SApple OSS Distributions 	kpep_config_free(config);
283*5e3eaea3SApple OSS Distributions 	kpep_db_free(db);
284*5e3eaea3SApple OSS Distributions }
285*5e3eaea3SApple OSS Distributions 
286*5e3eaea3SApple OSS Distributions T_DECL(secure_public_event_coverage, "all public events in kpep should be allowed",
287*5e3eaea3SApple OSS Distributions     _T_META_CPC_SECURE_ON_DEV)
288*5e3eaea3SApple OSS Distributions {
289*5e3eaea3SApple OSS Distributions 	check_event_coverage(KPEP_DB_FLAG_PUBLIC_ONLY, "public");
290*5e3eaea3SApple OSS Distributions }
291*5e3eaea3SApple OSS Distributions 
292*5e3eaea3SApple OSS Distributions T_DECL(release_public_event_coverage, "all public events in kpep should be allowed",
293*5e3eaea3SApple OSS Distributions     XNU_T_META_REQUIRES_RELEASE_KERNEL)
294*5e3eaea3SApple OSS Distributions {
295*5e3eaea3SApple OSS Distributions 	check_event_coverage(KPEP_DB_FLAG_PUBLIC_ONLY, "public");
296*5e3eaea3SApple OSS Distributions }
297*5e3eaea3SApple OSS Distributions 
298*5e3eaea3SApple OSS Distributions // Check for internal development behaviors.
299*5e3eaea3SApple OSS Distributions 
300*5e3eaea3SApple OSS Distributions T_DECL(insecure_cpmu_unrestricted, "insecure CPMU should be unrestricted",
301*5e3eaea3SApple OSS Distributions     XNU_T_META_REQUIRES_DEVELOPMENT_KERNEL, T_META_SYSCTL_INT("kern.cpc.secure=0"))
302*5e3eaea3SApple OSS Distributions {
303*5e3eaea3SApple OSS Distributions 	check_event_coverage(KPEP_DB_FLAG_INTERNAL_ONLY, "internal");
304*5e3eaea3SApple OSS Distributions }
305