From patchwork Fri Feb 5 15:39:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12070367 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=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 BB9BFC433E0 for ; Fri, 5 Feb 2021 15:39:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31012650F0 for ; Fri, 5 Feb 2021 15:39:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31012650F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7D84D6B006E; Fri, 5 Feb 2021 10:39:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AFF76B0070; Fri, 5 Feb 2021 10:39:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69EC96B0073; Fri, 5 Feb 2021 10:39:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 53C256B006E for ; Fri, 5 Feb 2021 10:39:20 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1AA4D3621 for ; Fri, 5 Feb 2021 15:39:20 +0000 (UTC) X-FDA: 77784623280.25.quill67_190592f275e5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id E77981804E3A0 for ; Fri, 5 Feb 2021 15:39:19 +0000 (UTC) X-HE-Tag: quill67_190592f275e5 X-Filterd-Recvd-Size: 5324 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 15:39:19 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id e5so6157920qkn.2 for ; Fri, 05 Feb 2021 07:39:19 -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=PJe3Rz3EeSdJQyMwgR6n+MLd+6qUSUTULfhGZkHnlC0=; b=GLpv906g70oyvKfx1lT8SRlfZX2GptMlW62xAuuPrNcN5zEhH2h3cLKrfSCDjRMFmU u4PksceHe87HdqGH5yoTD8mj36rlwfetF+aaiHsU0z6CWtT3Ek0ktXZ3ZXLWRnbeRz+t MSbUY+sjHlx+0um5/NpwJr+RE7EzMFWL0gF64teWSuITRQL0gQSnDU85jJv2OP85+G2r SgNt+Szam3Q4/rRxSSQ8joLWgA/dbIyBEz6IbVeaY77h/JmVlXLcEzq9Sqawa5rQSGkq 9En+9QURKs1MSdqNAup9OsWlAS7XkoN2apB1AowPfwA42QdwnhAIvQ1gSagLgJoWQIrz +Yng== 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=PJe3Rz3EeSdJQyMwgR6n+MLd+6qUSUTULfhGZkHnlC0=; b=qboc5rBCXDHNFfLAj7q8BBzlhoOY34mVoATnqq16f2baV696I4fi3uDuQlitSaooIJ kSfuGSglZSju4tsmr2M1XS8etV6PG5571A1ViRc5VMJQ97RiYKJFqdpQmlbfKtNUgC37 3/VrPZ4ntf0u6YnmpyOuY5Ctb/zzDk2/BOnH3BPnmshHqPYVo4sLov+39JV0qZP+sPoh 8JVjpWdnxe8Wm5VOolCbpzJAYQr4bcJsCKZIwbk0s9RG1JQqcOrR9ZRBSTOC34aH64Cd zwJWa0V9g8OJITSLj8eX1YIYIS0LHT3vkpOhCkN6dFxnMN9xyLB62foe0fk0mvrl3A8J BxYQ== X-Gm-Message-State: AOAM532IwaLV/8VibVtXtdxJ2qtHBw6BIjwhVm0byQMIuZVOGGgf5Fex MegvZkn4nDf7QyCboNm8wCh3jFj3nk79TacC X-Google-Smtp-Source: ABdhPJzslOGVJmt8BToaF+8002Gc6wGSVe80ou5CaX5bVJOBaYQOullRpF7SC/hcnNqvALzxl6/B1Gm2DaOADJ/b X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:edb8:b79c:2e20:e531]) (user=andreyknvl job=sendgmr) by 2002:a0c:a692:: with SMTP id t18mr5040489qva.18.1612539558216; Fri, 05 Feb 2021 07:39:18 -0800 (PST) Date: Fri, 5 Feb 2021 16:39:01 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v2 00/12] kasan: optimizations and fixes for HW_TAGS From: Andrey Konovalov To: Andrew Morton , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov 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: This patchset goes on top of: 1. Vincenzo's async support patches [1], and 2. "kasan: untag addresses for KFENCE" fix [2] (already in mm). [1] https://lore.kernel.org/linux-arm-kernel/20210130165225.54047-1-vincenzo.frascino@arm.com/ [2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=akpm&id=dec4728fab910da0c86cf9a97e980f4244ebae9f 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%. Andrey Konovalov (12): 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 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/kasan.h | 72 +++++++++-- mm/kasan/shadow.c | 53 ++++---- mm/slab_common.c | 18 ++- mm/slub.c | 3 +- 14 files changed, 418 insertions(+), 186 deletions(-)