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