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, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 0CFF3C64E8A for ; Thu, 3 Dec 2020 10:36:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 55065206E3 for ; Thu, 3 Dec 2020 10:36:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55065206E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8D5DA6B006E; Thu, 3 Dec 2020 05:36:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85F166B0070; Thu, 3 Dec 2020 05:36:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D96B6B0071; Thu, 3 Dec 2020 05:36:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 528266B006E for ; Thu, 3 Dec 2020 05:36:11 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 20FA18249980 for ; Thu, 3 Dec 2020 10:36:11 +0000 (UTC) X-FDA: 77551616142.08.vase93_320b3ec273bb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 034F41819E76F for ; Thu, 3 Dec 2020 10:36:10 +0000 (UTC) X-HE-Tag: vase93_320b3ec273bb X-Filterd-Recvd-Size: 4514 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Dec 2020 10:36:10 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B7987113E; Thu, 3 Dec 2020 02:36:09 -0800 (PST) Received: from [10.37.8.53] (unknown [10.37.8.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54BB33F575; Thu, 3 Dec 2020 02:36:06 -0800 (PST) Subject: Re: [PATCH mm v11 27/42] arm64: mte: Add in-kernel tag fault handler To: Catalin Marinas , Andrey Konovalov Cc: Andrew Morton , Will Deacon , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , 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, Mark Rutland References: <20201203102628.GB2224@gaia> From: Vincenzo Frascino Message-ID: Date: Thu, 3 Dec 2020 10:39:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201203102628.GB2224@gaia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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: On 12/3/20 10:26 AM, Catalin Marinas wrote: >> static inline void uaccess_enable(void) >> { >> + asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(1), >> + ARM64_MTE, CONFIG_KASAN_HW_TAGS)); >> + >> __uaccess_enable(ARM64_HAS_PAN); >> } >=20 > I think that's insufficient if CONFIG_ARM64_PAN is disabled. In the !PA= N > case, the get/put_user() accessors use standard LDR/STR instructions > which would follow the TCF rather than TCF0 mode checking. However, the= y > don't use the above uaccess_disable/enable() functions. >=20 > The current user space support is affected as well but luckily we just > skip tag checking on the uaccess routines if !PAN since the kernel TCF > is 0. With the in-kernel MTE, TCF may be more strict than TCF0. >=20 > My suggestion is to simply make CONFIG_ARM64_MTE depend on (or select) > PAN. Architecturally this should work since PAN is required for ARMv8.1= , > so present with any MTE implementation. This patch is on top of -next, > though it has a Fixes tag in 5.10: >=20 Agreed, since PAN is required for ARMv8.1 we should not find any implemen= tation of MTE that lacks PAN. > --------------------------8<--------------------------- > From ecc819804c1fb1ad498d7ced07e01e3b3e055a3f Mon Sep 17 00:00:00 2001 > From: Catalin Marinas > Date: Thu, 3 Dec 2020 10:15:39 +0000 > Subject: [PATCH] arm64: mte: Ensure CONFIG_ARM64_PAN is enabled with MT= E >=20 > The uaccess routines like get/put_user() rely on the user TCF0 mode > setting for tag checking. However, if CONFIG_ARM64_PAN is disabled, > these routines would use the standard LDR/STR instructions and therefor= e > the kernel TCF mode. In 5.10, the kernel TCF=3D=3D0, so no tag checking= , but > this will change with the in-kernel MTE support. >=20 > Make ARM64_MTE depend on ARM64_PAN. >=20 > Fixes: 89b94df9dfb1 ("arm64: mte: Kconfig entry") > Signed-off-by: Catalin Marinas Reviewed-by: Vincenzo Frascino > --- > arch/arm64/Kconfig | 2 ++ > 1 file changed, 2 insertions(+) >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 844d62df776c..f9eed3a5917e 100644 >=20 > --- a/arch/arm64/Kconfig >=20 > +++ b/arch/arm64/Kconfig >=20 > @@ -1673,6 +1673,8 @@ >=20 > config ARM64_MTE >=20 > =C2=BB default=C2=B7y > =C2=BB depends=C2=B7on=C2=B7ARM64_AS_HAS_MTE=C2=B7&&=C2=B7ARM64_TAGGED_= ADDR_ABI > =C2=BB depends=C2=B7on=C2=B7AS_HAS_ARMV8_5 > +=C2=BB #=C2=B7Required=C2=B7for=C2=B7tag=C2=B7checking=C2=B7in=C2=B7th= e=C2=B7uaccess=C2=B7routines > +=C2=BB depends=C2=B7on=C2=B7ARM64_PAN > =C2=BB select=C2=B7ARCH_USES_HIGH_VMA_FLAGS > =C2=BB help > =C2=BB =C2=B7=C2=B7Memory=C2=B7Tagging=C2=B7(part=C2=B7of=C2=B7the=C2=B7= ARMv8.5=C2=B7Extensions)=C2=B7provides --=20 Regards, Vincenzo