From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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_SANE_1 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 95AF1C433FE for ; Tue, 8 Dec 2020 17:50:35 +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 58D6C23B7E for ; Tue, 8 Dec 2020 17:50:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58D6C23B7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nGRmcyOm6P8Z01RXdZ5TMC/pgp63/dDyfwbBNGq4T98=; b=SVI4/mNZh6ciLp/C1a4T4L6Lg PBHCHGqMyvVNzpudGiOA8UjMmfgxOvitlipG90Q3A8lx6VzRxpq9H0OCoJHmD5PPXbBIvW2WlUb5j hU5buevGchcDxtP6fHww42lpYuyLDUMYWSbR6I8LAG9fJG7gaaTwtVkTfONrbes6SI6DJhd2QRML4 bvu6g4CxvwGjmuV6SbypobD/fNTPXBKbWZnjyswQUZV5f8zXmpsoPgRI1/OcHFzvSObUYNh7CXYL/ ES6aq2ehAmqt6B8FYxtFdHT4hDo8AdKi8GZ3gSIsEuu0Q9tJGqfXkrngLEqJZ/EztJr8MCHBfnTzT O8SbTtPtQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmh6x-0007Ap-6p; Tue, 08 Dec 2020 17:49:15 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmh6u-0007AG-Kc for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 17:49:13 +0000 Date: Tue, 8 Dec 2020 17:49:07 +0000 From: Catalin Marinas To: Peter Collingbourne Subject: Re: [PATCH v3 3/3] kasan: arm64: support specialized outlined tag mismatch checks Message-ID: <20201208174906.GD13960@gaia> References: <01b1819ec213797c9cd44bc23a9e9641f3bb64b2.1606972188.git.pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_124912_804878_20A103E5 X-CRM114-Status: GOOD ( 26.53 ) 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: Mark Rutland , Andrey Konovalov , Mark Brown , Linux ARM , Will Deacon , Ard Biesheuvel , Evgenii Stepanov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Dec 02, 2020 at 09:12:24PM -0800, Peter Collingbourne wrote: > By using outlined checks we can achieve a significant code size > improvement by moving the tag-based ASAN checks into separate > functions. Unlike the existing CONFIG_KASAN_OUTLINE mode these > functions have a custom calling convention that preserves most > registers and is specialized to the register containing the address > and the type of access, and as a result we can eliminate the code > size and performance overhead of a standard calling convention such > as AAPCS for these functions. > > This change depends on a separate series of changes to Clang [1] to > support outlined checks in the kernel, although the change works fine > without them (we just don't get outlined checks). This is because the > flag -mllvm -hwasan-inline-all-checks=0 has no effect until the Clang > changes land. The flag was introduced in the Clang 9.0 timeframe as > part of the support for outlined checks in userspace and because our > minimum Clang version is 10.0 we can pass it unconditionally. > > Outlined checks require a new runtime function with a custom calling > convention. Add this function to arch/arm64/lib. > > I measured the code size of defconfig + tag-based KASAN, as well > as boot time (i.e. time to init launch) on a DragonBoard 845c with > an Android arm64 GKI kernel. The results are below: > > code size boot time > CONFIG_KASAN_INLINE=y before 92824064 6.18s > CONFIG_KASAN_INLINE=y after 38822400 6.65s > CONFIG_KASAN_OUTLINE=y 39215616 11.48s > > We can see straight away that specialized outlined checks beat the > existing CONFIG_KASAN_OUTLINE=y on both code size and boot time > for tag-based ASAN. > > As for the comparison between CONFIG_KASAN_INLINE=y before and after > we saw similar performance numbers in userspace [2] and decided > that since the performance overhead is minimal compared to the > overhead of tag-based ASAN itself as well as compared to the code > size improvements we would just replace the inlined checks with the > specialized outlined checks without the option to select between them, > and that is what I have implemented in this patch. But we may make a > different decision for the kernel such as having CONFIG_KASAN_OUTLINE=y > turn on specialized outlined checks if Clang is new enough. > > Signed-off-by: Peter Collingbourne > Link: https://linux-review.googlesource.com/id/I1a30036c70ab3c3ee78d75ed9b87ef7cdc3fdb76 > Link: [1] https://reviews.llvm.org/D90426 > Link: [2] https://reviews.llvm.org/D56954 > --- > v3: > - adopt Mark Rutland's suggested changes > - move frame record alignment patches behind this one > > v2: > - use calculations in the stack spills and restores > - improve the comment at the top of the function > - add a BTI instruction > > arch/arm64/include/asm/asm-prototypes.h | 6 ++ > arch/arm64/include/asm/module.lds.h | 17 +++++- > arch/arm64/lib/Makefile | 2 + > arch/arm64/lib/kasan_sw_tags.S | 76 +++++++++++++++++++++++++ > mm/kasan/tags.c | 7 +++ > scripts/Makefile.kasan | 1 + I can try to queue the series but this patch would need an ack on the kasan changes. (also, it may conflict with linux-next which renames tags.c to sw_tags.c but that's trivial) -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel