Revert "FROMGIT: kasan, arm64: allow using KUnit tests with HW_TAGS mode"

This reverts commit a599a4e3b9.

The upstream version of this patch has been updated. Revert the FROMGIT
version before applying the UPSTREAM one.

Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Change-Id: I423a68e2a3e55b97b04180fedd7160c704ae0972
This commit is contained in:
Andrey Konovalov
2021-03-05 16:29:21 +01:00
committed by Will Deacon
parent c0a166c983
commit 9f925b293d
7 changed files with 9 additions and 67 deletions

View File

@@ -41,9 +41,7 @@ static bool multishot;
/*
* Temporarily enable multi-shot mode. Otherwise, KASAN would only report the
* first detected bug and panic the kernel if panic_on_warn is enabled. For
* hardware tag-based KASAN also allow tag checking to be reenabled for each
* test, see the comment for KUNIT_EXPECT_KASAN_FAIL().
* first detected bug and panic the kernel if panic_on_warn is enabled.
*/
static int kasan_test_init(struct kunit *test)
{
@@ -53,13 +51,11 @@ static int kasan_test_init(struct kunit *test)
}
multishot = kasan_save_enable_multi_shot();
hw_set_tagging_report_once(false);
return 0;
}
static void kasan_test_exit(struct kunit *test)
{
hw_set_tagging_report_once(true);
kasan_restore_multi_shot(multishot);
}
@@ -69,19 +65,12 @@ static void kasan_test_exit(struct kunit *test)
* resource named "kasan_data". Do not use this name for KUnit resources
* outside of KASAN tests.
*
* For hardware tag-based KASAN, when a tag fault happens, tag checking is
* normally auto-disabled. When this happens, this test handler reenables
* tag checking. As tag checking can be only disabled or enabled per CPU, this
* handler disables migration (preemption).
*
* Since the compiler doesn't see that the expression can change the fail_data
* fields, it can reorder or optimize away the accesses to those fields.
* Use READ/WRITE_ONCE() for the accesses and compiler barriers around the
* expression to prevent that.
*/
#define KUNIT_EXPECT_KASAN_FAIL(test, expression) do { \
if (IS_ENABLED(CONFIG_KASAN_HW_TAGS)) \
migrate_disable(); \
WRITE_ONCE(fail_data.report_expected, true); \
WRITE_ONCE(fail_data.report_found, false); \
kunit_add_named_resource(test, \
@@ -95,11 +84,6 @@ static void kasan_test_exit(struct kunit *test)
KUNIT_EXPECT_EQ(test, \
READ_ONCE(fail_data.report_expected), \
READ_ONCE(fail_data.report_found)); \
if (IS_ENABLED(CONFIG_KASAN_HW_TAGS)) { \
if (READ_ONCE(fail_data.report_found)) \
hw_enable_tagging(); \
migrate_enable(); \
} \
} while (0)
#define KASAN_TEST_NEEDS_CONFIG_ON(test, config) do { \