From patchwork Fri Feb 5 17:34:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12070539 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=-12.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, 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 5E45BC433DB for ; Fri, 5 Feb 2021 17:36:23 +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 054AE60C3F for ; Fri, 5 Feb 2021 17:36:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 054AE60C3F 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:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=iZwDHB0+jNtPNbvq8HHZDgEAlllqHnVfvUN/+wVd8YA=; b=v1Y9mysR1B/CpsIF5mtOBS/4iI OBxn986AFY/9nZDWnV31OSC/w1aw0MfoneV8cxnNJsa9Zs8Igw3dcpZDgHtILPxX3mgI/xyozMRpL eetVh3LBbaICfd2EwxaSIWnZyFQUE8m0dzUM1cORTVLpNUJqF+vIJl70PumXZDtViSKyFyMVgsNFS +/0BxZDY2IZtfKbAFWxNkUr68ZJ+c7g6p49n7cZk0VgFntBi/+sULH54sT7V4SVALlZrQeI5+/l6u BXWeI5LRm9m56qfuwEsMmrN9xg3B2dtq7tYFe+idpDKeuv23Roj0MesC65vXSmyiKF3JZNjtY1wyD uZfhyxJg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l850T-0004op-88; Fri, 05 Feb 2021 17:34:57 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l850Q-0004m0-4j for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 17:34:55 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id t18so5527536qva.6 for ; Fri, 05 Feb 2021 09:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=uW4XwdDsDqPZKdJsjSNV/lvgiACDWFIJBYlg/yy/ua8=; b=gREtjvrNU/DL/BB5f0NB+H4mklQaYOxi0xqMR54soyojmd5TpblFukPUVRrIbkIdkd hfABx4PHO1ExToVFCxYaWggl0Nz2GFYGPoMq70828isVXaPRjrE4zpGUF/CgEn6Ky/kg t9foBh6L2WHIEQMPmljuLensxPBFII4zfY7I7FAE1CiQrxMtplU9KLRf1p2WFcpkVmhB XfqhiYJZbIULXBdzmX58JxPik9yU9xSWmtQr+1Gapmzot2SOKyvfuRtgoetvYxIBe4+V v4ZU9xlOx9HdQNEtUwffl7d/VtaLFIlxv6Ld1fYCJ98jg/1zudsVC2jlTN4SNXGP15ZA xV8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=uW4XwdDsDqPZKdJsjSNV/lvgiACDWFIJBYlg/yy/ua8=; b=cFjG5yzRIs+0HKGW0OUS1Aey1MmilfWEssPz21pvwvZy2KfhmCplTg2xNqeSjey+Im cQDYin3im3v8n8y1g83UNfp57GinGuBuTIFcaxlood0zBlDrzVPt07iezBF7nWsnw0Eq tNMNfBy9Dc++2E1OWUulWXfUbqp0m8OHYDvFkU7VMYPyiWBDyC7BLzVS0cs815pPlXvr 5xxdC4POvCaPMmqp7P7IKIgKR73mPcuXhfIvnLZGr4MMgkUKA4zdCCKu6Oxu8pUfQIge k26nKMXsBC+Mh8z9Pc6CPmhpQSeX0gcKVGzMfRQYZzcmVIc3RGWroiGIS6Mc29thdx5J o3Qg== X-Gm-Message-State: AOAM530x0NAb6lgUhAo7eUQ1i+VncjmWdvM9BXM6Wue195pEt3hoJ8ah YA1Rm71v4SFdQq0OSr9c+XLeWvCdaoOpnPA1 X-Google-Smtp-Source: ABdhPJzuQv6b7CvA7ADc4i5f9Vgssq9E+uX168n5SbxDe6+yK6EQLRrOkgWeNI0WZVCe58w78UzylPBPDFpwROPs X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:edb8:b79c:2e20:e531]) (user=andreyknvl job=sendgmr) by 2002:a0c:9b9e:: with SMTP id o30mr5523277qve.62.1612546490248; Fri, 05 Feb 2021 09:34:50 -0800 (PST) Date: Fri, 5 Feb 2021 18:34:34 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v3 mm 00/13] kasan: optimizations and fixes for HW_TAGS From: Andrey Konovalov To: Andrew Morton , 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-20210205_123454_210397_B527CC73 X-CRM114-Status: GOOD ( 13.79 ) 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 , Peter Collingbourne , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patchset makes the HW_TAGS mode more efficient, mostly by reworking poisoning approaches and simplifying/inlining some internal helpers. With this change, the overhead of HW_TAGS annotations excluding setting and checking memory tags is ~3%. The performance impact caused by tags will be unknown until we have hardware that supports MTE. As a side-effect, this patchset speeds up generic KASAN by ~15%. Changes v2->v3: - Rebased onto mm. - Add documentation update patch. Changes v1->v2: - Use EXPORT_SYMBOL_GPL() for arm64 symbols. - Rename kmalloc bool flag argument to is_kmalloc. - Make empty mte_set_mem_tag_range() return void. - Fix build warning in 32-bit systems by using unsigned long instead of u64 in WARN_ON() checks. - Minor changes in comments and commit descriptions. - Use kfence_ksize() before __ksize() to avoid crashes with KFENCE. - Use inline instead of __always_inline. Andrey Konovalov (13): kasan, mm: don't save alloc stacks twice kasan, mm: optimize kmalloc poisoning kasan: optimize large kmalloc poisoning kasan: clean up setting free info in kasan_slab_free kasan: unify large kfree checks kasan: rework krealloc tests kasan, mm: fail krealloc on freed objects kasan, mm: optimize krealloc poisoning kasan: ensure poisoning size alignment arm64: kasan: simplify and inline MTE functions kasan: inline HW_TAGS helper functions arm64: kasan: export MTE symbols for KASAN tests kasan: clarify that only first bug is reported in HW_TAGS Documentation/dev-tools/kasan.rst | 8 +- arch/arm64/include/asm/cache.h | 1 - arch/arm64/include/asm/kasan.h | 1 + arch/arm64/include/asm/mte-def.h | 2 + arch/arm64/include/asm/mte-kasan.h | 65 ++++++++-- arch/arm64/include/asm/mte.h | 2 - arch/arm64/kernel/mte.c | 48 +------- arch/arm64/lib/mte.S | 16 --- include/linux/kasan.h | 25 ++-- lib/test_kasan.c | 111 +++++++++++++++-- mm/kasan/common.c | 187 ++++++++++++++++++++--------- mm/kasan/hw_tags.c | 2 +- mm/kasan/kasan.h | 72 +++++++++-- mm/kasan/shadow.c | 53 ++++---- mm/slab_common.c | 18 ++- mm/slub.c | 3 +- 16 files changed, 425 insertions(+), 189 deletions(-)