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: 12070347 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_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,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 B5984C433E0 for ; Fri, 5 Feb 2021 15:40:51 +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 53B0F650ED for ; Fri, 5 Feb 2021 15:40:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53B0F650ED 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=IqPiSMOlBGZCziMwpa49j+GDtNbC2nPef2PIkSeC+Ow=; b=fluykqIB0cF7mzbqXsOniK0Ps9 qYs2JegbGhrrDp9cuUlmvQcy0IfpETHAv07Gd09i7tJcZEC6PsyCw1lRWFLkuYKc6VUpyDmF29jx2 ao/4haIxczt7igUp2v3EzoC02RR4mDaZb75NF1vujIagZPkQZLcAJCt3Aiv6eP5uwJozCpzkuUsgv HhZcfVOST/fS+Ft2zk/NUYdCuQNDM9UJ2/LreBxi6D2pfWW2N3oLV3DPdo9Ub1CyJJRhwjyl3Oxjv +YOIV86W19UrSQxe4i8G7GhPgh2OET3vSBjDNzGQhgF2MSQarUYwf7zZ067qpBTWoGJVrqzLsOVUZ E2bkt4yw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l83Ce-0007jw-Hv; Fri, 05 Feb 2021 15:39:24 +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 1l83Cc-0007ij-8Y for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 15:39:23 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id j13so5240067qvy.19 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=WLrI5cMhVfzuKX0qGwCBRsjSG20tsFuUqX2kD+njT6yjuatuAqbKTjnWFQ90oLraF6 qTIdsmiorNbGtIsai9okTA3a7YGbz/yRmV7qDopEVLZt57PHowQOEm39OALC5a3NNmpK jiJVXRWMCGnBhPk9nXghNPLLrSz1/yE7Sl6E1SSNVSRZJT8MSnyCmml1UH4/afaDzqU6 rbbqktf8d9hW7s7i9KbDWARaDq9uT7BYzwrHm3Kimwpl5QERZD6ChVKGyB3SUWcaEI5Z niaKVesaicK2qOjnKIS69GJTtiIC4FwVJndMQ9IVoODL/+hHVlESZpMWOOyIldwiMy6q Frgw== X-Gm-Message-State: AOAM531mp9NWgiFwyGUERvMcx6RhNA2hjWYssZN1fYHrRLmLORhp6Esl JI96BCnqpXk3dYDPEC8ExKBe06N6MO6IIIPZ 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_103922_310036_E9636294 X-CRM114-Status: GOOD ( 11.88 ) 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 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(-)