From d9f210a14db5520b08bfb2d1e59ae18d5666e61b Mon Sep 17 00:00:00 2001 From: Shiraz Hashim Date: Mon, 4 Apr 2022 22:37:26 +0530 Subject: [PATCH] ANDROID: kunit: Provision kunit as a vendor module 'kunit_test' member variable in task_struct is defined under CONFIG_KUNIT. Besides there are supportive functions in slub and kasan which gets conditionally compiled out. Allow kunit to be build as vendor module by removing compile time dependencies. Bug: 215096354 Change-Id: If57b1df6e479aa0388aabc53af5ae10e20a844b2 Signed-off-by: Shiraz Hashim --- include/linux/sched.h | 2 -- mm/kasan/report.c | 8 -------- mm/slub.c | 4 ---- 3 files changed, 14 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index a82e5176f6f6..8514ed545e93 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1353,9 +1353,7 @@ struct task_struct { #endif #endif -#if IS_ENABLED(CONFIG_KUNIT) struct kunit *kunit_test; -#endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER /* Index of current stored address in ret_stack: */ diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 5f22ddfa2d7a..f9d07c79831a 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -343,7 +343,6 @@ static bool report_enabled(void) return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); } -#if IS_ENABLED(CONFIG_KUNIT) static void kasan_update_kunit_status(struct kunit *cur_test) { struct kunit_resource *resource; @@ -360,7 +359,6 @@ static void kasan_update_kunit_status(struct kunit *cur_test) WRITE_ONCE(kasan_data->report_found, true); kunit_put_resource(resource); } -#endif /* IS_ENABLED(CONFIG_KUNIT) */ void kasan_report_invalid_free(void *object, unsigned long ip) { @@ -369,10 +367,8 @@ void kasan_report_invalid_free(void *object, unsigned long ip) object = kasan_reset_tag(object); -#if IS_ENABLED(CONFIG_KUNIT) if (current->kunit_test) kasan_update_kunit_status(current->kunit_test); -#endif /* IS_ENABLED(CONFIG_KUNIT) */ start_report(&flags); pr_err("BUG: KASAN: double-free or invalid-free in %pS\n", (void *)ip); @@ -389,10 +385,8 @@ void kasan_report_async(void) { unsigned long flags; -#if IS_ENABLED(CONFIG_KUNIT) if (current->kunit_test) kasan_update_kunit_status(current->kunit_test); -#endif /* IS_ENABLED(CONFIG_KUNIT) */ start_report(&flags); pr_err("BUG: KASAN: invalid-access\n"); @@ -411,10 +405,8 @@ static void __kasan_report(unsigned long addr, size_t size, bool is_write, void *untagged_addr; unsigned long flags; -#if IS_ENABLED(CONFIG_KUNIT) if (current->kunit_test) kasan_update_kunit_status(current->kunit_test); -#endif /* IS_ENABLED(CONFIG_KUNIT) */ disable_trace_on_warning(); diff --git a/mm/slub.c b/mm/slub.c index 9829431bb6ea..39c9c7ac391e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -530,7 +530,6 @@ static void __fill_map(unsigned long *obj_map, struct kmem_cache *s, set_bit(__obj_to_index(s, addr, p), obj_map); } -#if IS_ENABLED(CONFIG_KUNIT) static bool slab_add_kunit_errors(void) { struct kunit_resource *resource; @@ -546,9 +545,6 @@ static bool slab_add_kunit_errors(void) kunit_put_resource(resource); return true; } -#else -static inline bool slab_add_kunit_errors(void) { return false; } -#endif /* * Determine a map of object in use on a page.