From patchwork Sat Feb 19 01:29:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12752126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 849FFC433EF for ; Sat, 19 Feb 2022 01:30:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 103896B0074; Fri, 18 Feb 2022 20:30:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B29D6B0075; Fri, 18 Feb 2022 20:30:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBD906B0078; Fri, 18 Feb 2022 20:30:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id D8FE36B0074 for ; Fri, 18 Feb 2022 20:30:03 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A0A3B9F84A for ; Sat, 19 Feb 2022 01:30:03 +0000 (UTC) X-FDA: 79157798286.15.EFA6C66 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf26.hostedemail.com (Postfix) with ESMTP id 32A41140009 for ; Sat, 19 Feb 2022 01:30:03 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id a32-20020a25ae20000000b0061db8f89e46so15389229ybj.14 for ; Fri, 18 Feb 2022 17:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=LT74mKv2CuVbvl4vyPNFOnmSsHHTWc1G9caXFZDMFU4=; b=BSQKKgJp+12HKmJcDDDpaXjmHzF8isdWVVKq/SwjpuR/clvMo/6E4BB4s/rbVWsUBd YLsqbAJe3FE/5qRoljf6nSaXzvsLteBuzE3gyJXkGFbbAlPIT2DQreFQi36bY9+FiRz1 UbuR2fPmsJg/JRue1608d6/b5nG0yoO8ImkaHLuF50tT3bZfPXHB6p9J5kgH/chx7ILb gnPHhTEtnWrKTD09O7TrXZxVp4t1/SPOjlRVlJHgQTZi8JaqEg/+jdC+J+9Khl/0FBoR 0S3cgto7Z0B07Fi+V5SSgU5LFBwTFa9KyJ893qT4AEQPkpdHw3mTxukviKmDEcp3yS8m TE0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=LT74mKv2CuVbvl4vyPNFOnmSsHHTWc1G9caXFZDMFU4=; b=25pGf6Gfcyno5AUwFMHqp9Bm5EIJqQzaGXix9Jw7cvSgH2DjX1ThxlGQjnmD+jGHV4 fEWSkHuRedyvmAo5go8LEV71vubGiZd+Dh83s4qhn6CgXP55eDNCvAFQ5Cg9uzp587F0 OBl/RdLexsWqNAbNdawD5UVBo08f/ECkKXmD2nTH3KYf6ovBIay51y759goTiceUbhaQ ob8pppAfFp7DynZTMMgNU4LzIDPbJXqaBNNZFQhUusp6JVfo2tG+oAXIh3+a0oxxzOKu ROfGiw8tDwYOgCDAeClksAOPP4onG+nrlc/tdkLvj62qkcW8kwGe1Ysc/M0QfRl888+2 rpMw== X-Gm-Message-State: AOAM533V6JHpWw3yPz/pKshcig1R40KOST2a6gxWSCvFfl6UO+U6lf8X yLqlxv6hErPJs0Yd1vBmM/ukFxs= X-Google-Smtp-Source: ABdhPJxkxlmq25NnWuXThpI8Z0zOfcD4KPBeX+t1AUKrftXlgLsv/SRY27p189/PuYwk9MchPbVRz0I= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:4926:4660:7cdf:2d]) (user=pcc job=sendgmr) by 2002:a25:296:0:b0:623:a267:ab94 with SMTP id 144-20020a250296000000b00623a267ab94mr10306408ybc.430.1645234202497; Fri, 18 Feb 2022 17:30:02 -0800 (PST) Date: Fri, 18 Feb 2022 17:29:44 -0800 Message-Id: <20220219012945.894950-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [PATCH v5 1/2] kasan: split kasan_*enabled() functions into a separate header From: Peter Collingbourne To: Catalin Marinas , Vincenzo Frascino , Will Deacon , Andrey Konovalov , Mark Rutland Cc: Peter Collingbourne , Evgenii Stepanov , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BSQKKgJp; spf=pass (imf26.hostedemail.com: domain of 3GkgQYgMKCAMsffjrrjoh.frpolqx0-ppnydfn.ruj@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3GkgQYgMKCAMsffjrrjoh.frpolqx0-ppnydfn.ruj@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 32A41140009 X-Stat-Signature: dzwmizqqx8ghdp3y6nde64zeyguubgha X-HE-Tag: 1645234203-118122 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In an upcoming commit we are going to need to call kasan_hw_tags_enabled() from arch/arm64/include/asm/mte.h. This would create a circular dependency between headers if KASAN_GENERIC or KASAN_SW_TAGS is enabled: linux/kasan.h -> linux/pgtable.h -> asm/pgtable.h -> asm/mte.h -> linux/kasan.h. Break the cycle by introducing a new header linux/kasan-enabled.h with the kasan_*enabled() functions that can be included from asm/mte.h. Link: https://linux-review.googlesource.com/id/I5b0d96c6ed0026fc790899e14d42b2fac6ab568e Signed-off-by: Peter Collingbourne Reviewed-by: Andrey Konovalov --- include/linux/kasan-enabled.h | 33 +++++++++++++++++++++++++++++++++ include/linux/kasan.h | 23 +---------------------- 2 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 include/linux/kasan-enabled.h diff --git a/include/linux/kasan-enabled.h b/include/linux/kasan-enabled.h new file mode 100644 index 000000000000..4b6615375022 --- /dev/null +++ b/include/linux/kasan-enabled.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_KASAN_ENABLED_H +#define _LINUX_KASAN_ENABLED_H + +#ifdef CONFIG_KASAN_HW_TAGS + +DECLARE_STATIC_KEY_FALSE(kasan_flag_enabled); + +static __always_inline bool kasan_enabled(void) +{ + return static_branch_likely(&kasan_flag_enabled); +} + +static inline bool kasan_hw_tags_enabled(void) +{ + return kasan_enabled(); +} + +#else /* CONFIG_KASAN_HW_TAGS */ + +static inline bool kasan_enabled(void) +{ + return IS_ENABLED(CONFIG_KASAN); +} + +static inline bool kasan_hw_tags_enabled(void) +{ + return false; +} + +#endif /* CONFIG_KASAN_HW_TAGS */ + +#endif /* LINUX_KASAN_ENABLED_H */ diff --git a/include/linux/kasan.h b/include/linux/kasan.h index 4a45562d8893..b6a93261c92a 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -3,6 +3,7 @@ #define _LINUX_KASAN_H #include +#include #include #include #include @@ -83,33 +84,11 @@ static inline void kasan_disable_current(void) {} #ifdef CONFIG_KASAN_HW_TAGS -DECLARE_STATIC_KEY_FALSE(kasan_flag_enabled); - -static __always_inline bool kasan_enabled(void) -{ - return static_branch_likely(&kasan_flag_enabled); -} - -static inline bool kasan_hw_tags_enabled(void) -{ - return kasan_enabled(); -} - void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags); void kasan_free_pages(struct page *page, unsigned int order); #else /* CONFIG_KASAN_HW_TAGS */ -static inline bool kasan_enabled(void) -{ - return IS_ENABLED(CONFIG_KASAN); -} - -static inline bool kasan_hw_tags_enabled(void) -{ - return false; -} - static __always_inline void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags) {