From patchwork Mon Feb 1 19:43:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12059957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FC56C433E0 for ; Mon, 1 Feb 2021 19:47:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F4A964EA8 for ; Mon, 1 Feb 2021 19:47:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F4A964EA8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FNChEz5M/FDkg7do34dklzcCPFjHscs+eFnJm0ipucM=; b=ADAdlAsJmb2To87s1WxZhiY0Z 4cFsVrTtLVQvWVt2VxdNA7dVHQxhoUS6DEXWrb6L1eEcTJfn1Tgm0ixSmTpFT0MmiJ3N2rRNYHfTy WU1nKbtjNB/G0TsH1QntB8SzYPDKTomKQWaPWaLJlFJfVn88+305Yc0XsANegn7o0zvPGT67oQANc x1pFFgjyIXcWH1wErlGTWmOG5X3S/ruvwtf2m8FzkacV8bjaBR41980jPza4BRU83TvhTWjKNwtMd +KSIsBZN82GdiUwbUew7sLb5ymkxQjJ7odSmsaGyYe6yQuxetgYWwPuTE+86eSDupjC2PiDJuGZNz u4njcI0Ng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6f8c-0002iG-Ux; Mon, 01 Feb 2021 19:45:31 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6f7K-00021W-G8 for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 19:44:13 +0000 Received: by mail-qt1-x849.google.com with SMTP id i1so3841177qtp.16 for ; Mon, 01 Feb 2021 11:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=NVeqfy8PnyvgWAdKHeCgVfqveCjCMDJegzzrq5UVB6U=; b=b1lXS5TDAM0t8/OObzI88t9G9V6LITLxK5/HlZBBUXX7GfRsMrQIJFL7iZyApowvVV +V+FY2IUUWYkNTWeXZxdzf34OrHTRKwVqQcNL6fICTVHh3TpEujGh1tnocawM4hwAb4b TtuC53IMGp9hqR2Xewo3b/F1Q4iYHl+9mIZ2/lzggJuzIJcI4NBXgM0WrryaLtGR0m2a sq8jarjd69t2LKd1B5QHWJUUseYqkrYYJ/nB6l/GCPk5F1j7V1sJb7Xohp/yNGB1c8xk Doov5OEX30RUucXGXr1esBwDjbnsH9P77ukc8FOoY5A7aAkf1kP4LapMQoBp2hVkGH5G FQ2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NVeqfy8PnyvgWAdKHeCgVfqveCjCMDJegzzrq5UVB6U=; b=NUL34LMzYzij9XtCrpLWV9obJx6izUCPq9CQTibegX1rqz4QoqHkmrzS0H0lSndKpX TjbO3wh+hsZu7h7tMRM2CDFpddgzI/JiSCVh9L6+BdwPdYttmkQFzk6gConbXKwr0/Le KuTdX13JdHx0RYLqiLbvYQ66m1kVuha2M6FF+LQXwxll+9eLo1icknBHZ7sdjYLZc64J 3B72n3PlgFYMvTLZRxT6Wq5nn4WaE2QLQdHLh0RZXAxCL828UitwHFVUqBJnpcCoHIgM WfAr3xT/snCAHKqYeeTWd3kg536ChF+XcTpKyiRi+37Vkt56mal4X3vhXQ8Jh4eyeWAJ QXdQ== X-Gm-Message-State: AOAM5333AjrbmXZK0/R5WX0pA+AOL12CU9RAvBcoXRU1V/ueJ75Du8yU I9/Rznxfkh6eIwADHFEAhDHL58360pcc8EjZ X-Google-Smtp-Source: ABdhPJy3LMcMO1RRr1wTMaZvcYIHJ2lGN1Rm3XmR+DCe/2CyvjEerR8l4ufrmsSLp/ooBcba4JiSkTlvY93N5sqV X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a05:6214:725:: with SMTP id c5mr16904134qvz.27.1612208645795; Mon, 01 Feb 2021 11:44:05 -0800 (PST) Date: Mon, 1 Feb 2021 20:43:35 +0100 In-Reply-To: Message-Id: <05a45017b4cb15344395650e880bbab0fe6ba3e4.1612208222.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH 11/12] kasan: always inline HW_TAGS helper functions From: Andrey Konovalov To: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210201_144410_622479_AC87F26B X-CRM114-Status: GOOD ( 12.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Andrew Morton , Peter Collingbourne , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Mark all static functions in common.c and kasan.h that are used for hardware tag-based KASAN as __always_inline to avoid unnecessary function calls. Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 13 +++++++------ mm/kasan/kasan.h | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 5691cca69397..2004ecd6e43c 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -279,7 +279,8 @@ void __kasan_poison_object_data(struct kmem_cache *cache, void *object) * based on objects indexes, so that objects that are next to each other * get different tags. */ -static u8 assign_tag(struct kmem_cache *cache, const void *object, bool init) +static __always_inline u8 assign_tag(struct kmem_cache *cache, + const void *object, bool init) { if (IS_ENABLED(CONFIG_KASAN_GENERIC)) return 0xff; @@ -321,8 +322,8 @@ void * __must_check __kasan_init_slab_obj(struct kmem_cache *cache, return (void *)object; } -static bool ____kasan_slab_free(struct kmem_cache *cache, void *object, - unsigned long ip, bool quarantine) +static __always_inline bool ____kasan_slab_free(struct kmem_cache *cache, + void *object, unsigned long ip, bool quarantine) { u8 tag; void *tagged_object; @@ -366,7 +367,7 @@ bool __kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip) return ____kasan_slab_free(cache, object, ip, true); } -static bool ____kasan_kfree_large(void *ptr, unsigned long ip) +static __always_inline bool ____kasan_kfree_large(void *ptr, unsigned long ip) { if (ptr != page_address(virt_to_head_page(ptr))) { kasan_report_invalid_free(ptr, ip); @@ -461,8 +462,8 @@ void * __must_check __kasan_slab_alloc(struct kmem_cache *cache, return tagged_object; } -static void *____kasan_kmalloc(struct kmem_cache *cache, const void *object, - size_t size, gfp_t flags) +static __always_inline void *____kasan_kmalloc(struct kmem_cache *cache, + const void *object, size_t size, gfp_t flags) { unsigned long redzone_start; unsigned long redzone_end; diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 2f7400a3412f..d5fe72747a53 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -321,7 +321,7 @@ static inline u8 kasan_random_tag(void) { return 0; } #ifdef CONFIG_KASAN_HW_TAGS -static inline void kasan_poison(const void *addr, size_t size, u8 value) +static __always_inline void kasan_poison(const void *addr, size_t size, u8 value) { addr = kasan_reset_tag(addr); @@ -337,7 +337,7 @@ static inline void kasan_poison(const void *addr, size_t size, u8 value) hw_set_mem_tag_range((void *)addr, size, value); } -static inline void kasan_unpoison(const void *addr, size_t size) +static __always_inline void kasan_unpoison(const void *addr, size_t size) { u8 tag = get_tag(addr); @@ -354,7 +354,7 @@ static inline void kasan_unpoison(const void *addr, size_t size) hw_set_mem_tag_range((void *)addr, size, tag); } -static inline bool kasan_byte_accessible(const void *addr) +static __always_inline bool kasan_byte_accessible(const void *addr) { u8 ptr_tag = get_tag(addr); u8 mem_tag = hw_get_mem_tag((void *)addr);