xref: /xnu-10063.101.15/tests/vm/retired_pages.c (revision 94d3b452840153a99b38a3a9659680b2a006908e)
1*94d3b452SApple OSS Distributions #include <sys/sysctl.h>
2*94d3b452SApple OSS Distributions #include <time.h>
3*94d3b452SApple OSS Distributions 
4*94d3b452SApple OSS Distributions #include <darwintest.h>
5*94d3b452SApple OSS Distributions 
6*94d3b452SApple OSS Distributions T_GLOBAL_META(
7*94d3b452SApple OSS Distributions 	T_META_NAMESPACE("xnu.vm"),
8*94d3b452SApple OSS Distributions 	T_META_RADAR_COMPONENT_NAME("xnu"),
9*94d3b452SApple OSS Distributions 	T_META_RADAR_COMPONENT_VERSION("VM"));
10*94d3b452SApple OSS Distributions 
11*94d3b452SApple OSS Distributions /*
12*94d3b452SApple OSS Distributions  * trying phys offsets from start of dram of:
13*94d3b452SApple OSS Distributions  * macOS 3Gig
14*94d3b452SApple OSS Distributions  */
15*94d3b452SApple OSS Distributions #define USEBOOTARG "ecc_bad_pages=3221225472 bad_static_mfree=1"
16*94d3b452SApple OSS Distributions 
17*94d3b452SApple OSS Distributions T_DECL(retired_pages_test,
18*94d3b452SApple OSS Distributions     "Test retiring pages at boot",
19*94d3b452SApple OSS Distributions     T_META_BOOTARGS_SET(USEBOOTARG),
20*94d3b452SApple OSS Distributions     T_META_ASROOT(true),
21*94d3b452SApple OSS Distributions     T_META_CHECK_LEAKS(false),
22*94d3b452SApple OSS Distributions     T_META_ENABLED(0))
23*94d3b452SApple OSS Distributions {
24*94d3b452SApple OSS Distributions 	/* TODO: Joe will update/enable test in rdar://70008487 */
25*94d3b452SApple OSS Distributions 
26*94d3b452SApple OSS Distributions 	int err;
27*94d3b452SApple OSS Distributions 	unsigned int count = 0;
28*94d3b452SApple OSS Distributions 	size_t s = sizeof(count);
29*94d3b452SApple OSS Distributions 
30*94d3b452SApple OSS Distributions 	/*
31*94d3b452SApple OSS Distributions 	 * Get the number of pages retired from the kernel
32*94d3b452SApple OSS Distributions 	 */
33*94d3b452SApple OSS Distributions 	err = sysctlbyname("vm.retired_pages_count", &count, &s, NULL, 0);
34*94d3b452SApple OSS Distributions 
35*94d3b452SApple OSS Distributions 	/* If the sysctl isn't supported, test succeeds */
36*94d3b452SApple OSS Distributions 	if (err == ENOENT) {
37*94d3b452SApple OSS Distributions 		T_SKIP("sysctl vm.retired_pages_count not found, skipping test");
38*94d3b452SApple OSS Distributions 	}
39*94d3b452SApple OSS Distributions 	T_ASSERT_POSIX_SUCCESS(err, "sysctl vm.retired_pages_count");
40*94d3b452SApple OSS Distributions 
41*94d3b452SApple OSS Distributions 	T_ASSERT_GT_INT(count, 0, "Expect retired pages");
42*94d3b452SApple OSS Distributions }
43