From patchwork Mon Feb 1 19:43:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12059861 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=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 F2486C433E0 for ; Mon, 1 Feb 2021 19:45:12 +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 6569F64EAB for ; Mon, 1 Feb 2021 19:45:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6569F64EAB 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=9T/u+KsWGeOsSyy+eZnY3IS+kQm3xlVhEgnH7giwTIM=; b=KL1MKu5+CRcw8M8uOg5VFSc88l FlOiy2x8/84gFLRvA/047JJJl+dgnnDFKRKP7rq3J8mNl4pmBrtj5rPVGf4MW86oTG4J+2tu/B+ME AKCdRDzldXvlTGLFj4SIsn8HZ5KijvFQBmV8lhlgo7Sgd4qQunZ8WTvv4eeJGOgAQLJmqeKw4TFYY m8C6GqrV6y5axy8QYFx3kXvNvoiNLr0+nwVkkqYBTXcY/sOBs6khGuzgxNOLViJf0FwH6CcXluKh6 7hJS5EaamJJ9RVrAH88+7tyzbPxaVOlbqhbqcnz4aN7P8oJpwawu8w6M6AZCWemjuFsQT/y6Q5zlZ buXUvT7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6f6x-0001qb-FZ; Mon, 01 Feb 2021 19:43:47 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6f6t-0001nt-E8 for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 19:43:44 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 5so189876wmq.0 for ; Mon, 01 Feb 2021 11:43:41 -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=rJ16AiwqkpNVRFh+KkU2Ds7vTu96Je2z+5GU1bmSu0w=; b=sCPdWL3Ta0DpJRTYs6YqOedNph2JZBXXN/fK4StwO4OsV7a04cBNEoH089CZSJWqUB iRBZjs2U3hbbgmYqYIyRQo4/lJlthvUzW2iZuFFcgqS37Yf9BEuhiSFvdBJU8/oXNFbk E4v+77CSwMd/ZoYDRDs557B76A0+B0X3oRKAu34bVUiCysdR4Egshk29jdIopw+qWeJl w2rKw3kfRvFogekmwxhQmjW50dPploue1Sfo2fXHusBjbCyFm9UEoxj5PUUpIJh2huVC oSEdjcoh2PtfMA7bJmBZE93yLmhwujoX+aORuN1XU1hUZ/WedkYkl69gOPJFoXQCHE2K YehQ== 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=rJ16AiwqkpNVRFh+KkU2Ds7vTu96Je2z+5GU1bmSu0w=; b=r1BYR9NxO9Tq/6347Sxt5j2GQjTxm2VeLjNoS0+7qNzRj5EchbIbMaoaVPJ2H/wpjG fMO3KKEbkw/UWo5qPeHrr1Lvb9Blhvc/VZVdF2LfH1jgHTMeY3eM81q0jlhZZL45bfpu 3Ha52h/CP7l5oJS6ZhkQBaTocrs5ac5CMHDfBpt3LZQITnLK2JN9E20MHo9/MEWrSnz1 OAteEfdoQ19o5oLZFVpqXiUeTxW7TA3rjv9m7M2AP1n40hBayaSZOiS4k016yVbwxI/U 5RmQvYT3LNiUxM8pIEMOQflpt0aK49vwKUQSde6GOUxbfZVyOPJzAxwLsXayZb+ZpzFg r05g== X-Gm-Message-State: AOAM533LR+at3rn1NPR//gu5SI/sM0W8BkiBnOW9BEtPY1e1XBir5alK uFVCgKEiotXoNQrdQtrkDQo+1OSTiuuCixvr X-Google-Smtp-Source: ABdhPJx0GGA/oYC3Q5vVJSxYh6mDgQG3g7RSK4wThiuyHA7aa0OWsctlY8JNwnGUn/Z8d+sJQ/MjD2ldz3KK5zid X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:356:: with SMTP id 83mr415730wmd.31.1612208620129; Mon, 01 Feb 2021 11:43:40 -0800 (PST) Date: Mon, 1 Feb 2021 20:43:24 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH 00/12] kasan: optimizations and fixes for HW_TAGS 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_144343_535432_11506512 X-CRM114-Status: GOOD ( 11.75 ) 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 This patchset goes on top of: 1. Vincenzo's async support patches, and 2. "kasan: untag addresses for KFENCE" fix. 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: remove krealloc side-effect kasan, mm: optimize krealloc poisoning kasan: ensure poisoning size alignment arm64: kasan: simplify and inline MTE functions kasan: always 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 | 64 ++++++++-- 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 | 74 +++++++++--- mm/kasan/shadow.c | 53 ++++---- mm/slab_common.c | 18 ++- mm/slub.c | 3 +- 14 files changed, 419 insertions(+), 186 deletions(-)