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