Remove the debugfs test command, as it is no longer needed now that we have the KUnit+Torture based kcsan-test module. This is to avoid confusion around how KCSAN should be tested, as only the kcsan-test module is maintained.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -98,66 +98,6 @@ static noinline void microbenchmark(unsigned long iters) · 97 unmodified lines | ||
| 98 | 98 | current->kcsan_ctx = ctx_save; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | −/* | |
| 102 | − * Simple test to create conflicting accesses. Write 'test=<iters>' to KCSAN's | |
| 103 | − * debugfs file from multiple tasks to generate real conflicts and show reports. | |
| 104 | − */ | |
| 105 | −static long test_dummy; | |
| 106 | −static long test_flags; | |
| 107 | −static long test_scoped; | |
| 108 | −static noinline void test_thread(unsigned long iters) | |
| 109 | −{ | |
| 110 | − const long CHANGE_BITS = 0xff00ff00ff00ff00L; | |
| 111 | − const struct kcsan_ctx ctx_save = current->kcsan_ctx; | |
| 112 | − cycles_t cycles; | |
| 113 | − | |
| 114 | − /* We may have been called from an atomic region; reset context. */ | |
| 115 | − memset(¤t->kcsan_ctx, 0, sizeof(current->kcsan_ctx)); | |
| 116 | − | |
| 117 | − pr_info("KCSAN: %s begin | iters: %lu\n", __func__, iters); | |
| 118 | − pr_info("test_dummy@%px, test_flags@%px, test_scoped@%px,\n", | |
| 119 | − &test_dummy, &test_flags, &test_scoped); | |
| 120 | − | |
| 121 | − cycles = get_cycles(); | |
| 122 | − while (iters--) { | |
| 123 | − /* These all should generate reports. */ | |
| 124 | − __kcsan_check_read(&test_dummy, sizeof(test_dummy)); | |
| 125 | − ASSERT_EXCLUSIVE_WRITER(test_dummy); | |
| 126 | − ASSERT_EXCLUSIVE_ACCESS(test_dummy); | |
| 127 | − | |
| 128 | − ASSERT_EXCLUSIVE_BITS(test_flags, ~CHANGE_BITS); /* no report */ | |
| 129 | − __kcsan_check_read(&test_flags, sizeof(test_flags)); /* no report */ | |
| 130 | − | |
| 131 | − ASSERT_EXCLUSIVE_BITS(test_flags, CHANGE_BITS); /* report */ | |
| 132 | − __kcsan_check_read(&test_flags, sizeof(test_flags)); /* no report */ | |
| 133 | − | |
| 134 | − /* not actually instrumented */ | |
| 135 | − WRITE_ONCE(test_dummy, iters); /* to observe value-change */ | |
| 136 | − __kcsan_check_write(&test_dummy, sizeof(test_dummy)); | |
| 137 | − | |
| 138 | − test_flags ^= CHANGE_BITS; /* generate value-change */ | |
| 139 | − __kcsan_check_write(&test_flags, sizeof(test_flags)); | |
| 140 | − | |
| 141 | − BUG_ON(current->kcsan_ctx.scoped_accesses.prev); | |
| 142 | − { | |
| 143 | − /* Should generate reports anywhere in this block. */ | |
| 144 | − ASSERT_EXCLUSIVE_WRITER_SCOPED(test_scoped); | |
| 145 | − ASSERT_EXCLUSIVE_ACCESS_SCOPED(test_scoped); | |
| 146 | − BUG_ON(!current->kcsan_ctx.scoped_accesses.prev); | |
| 147 | − /* Unrelated accesses. */ | |
| 148 | − __kcsan_check_access(&cycles, sizeof(cycles), 0); | |
| 149 | − __kcsan_check_access(&cycles, sizeof(cycles), KCSAN_ACCESS_ATOMIC); | |
| 150 | − } | |
| 151 | − BUG_ON(current->kcsan_ctx.scoped_accesses.prev); | |
| 152 | − } | |
| 153 | − cycles = get_cycles() - cycles; | |
| 154 | − | |
| 155 | − pr_info("KCSAN: %s end | cycles: %llu\n", __func__, cycles); | |
| 156 | − | |
| 157 | − /* restore context */ | |
| 158 | − current->kcsan_ctx = ctx_save; | |
| 159 | −} | |
| 160 | − | |
| 161 | 101 | static int cmp_filterlist_addrs(const void *rhs, const void *lhs) |
| 162 | 102 | { |
| 163 | 103 | const unsigned long a = *(const unsigned long *)rhs; |
| @@ -306,12 +246,6 @@ debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *o · 142 unmodified lines | ||
| 306 | 246 | if (kstrtoul(&arg[strlen("microbench=")], 0, &iters)) |
| 307 | 247 | return -EINVAL; |
| 308 | 248 | microbenchmark(iters); |
| 309 | − } else if (str_has_prefix(arg, "test=")) { | |
| 310 | − unsigned long iters; | |
| 311 | − | |
| 312 | − if (kstrtoul(&arg[strlen("test=")], 0, &iters)) | |
| 313 | − return -EINVAL; | |
| 314 | − test_thread(iters); | |
| 315 | 249 | } else if (!strcmp(arg, "whitelist")) { |
| 316 | 250 | set_report_filterlist_whitelist(true); |
| 317 | 251 | } else if (!strcmp(arg, "blacklist")) { |