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