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