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=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 CD36BC43461 for ; Tue, 8 Sep 2020 14:52:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 47AC021D91 for ; Tue, 8 Sep 2020 14:52:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47AC021D91 Authentication-Results: mail.kernel.org; dmarc=none (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 DD0F76B0003; Tue, 8 Sep 2020 10:52:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5F386B0037; Tue, 8 Sep 2020 10:52:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4A2E6B006C; Tue, 8 Sep 2020 10:52:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id AECB66B0003 for ; Tue, 8 Sep 2020 10:52:44 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6C0F0181AC9BF for ; Tue, 8 Sep 2020 14:52:44 +0000 (UTC) X-FDA: 77240185848.28.turn21_5b029db270d5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 306D06C11 for ; Tue, 8 Sep 2020 14:52:44 +0000 (UTC) X-HE-Tag: turn21_5b029db270d5 X-Filterd-Recvd-Size: 4289 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Sep 2020 14:52:43 +0000 (UTC) Received: from gaia (unknown [46.69.195.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E3942074D; Tue, 8 Sep 2020 14:52:40 +0000 (UTC) Date: Tue, 8 Sep 2020 15:52:37 +0100 From: Catalin Marinas To: Andrey Konovalov Cc: Vincenzo Frascino , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Elena Petrova , Branislav Rankov , Kevin Brodsky , Will Deacon , Andrew Morton , Linux ARM , Linux Memory Management List , LKML , Dmitry Vyukov , kasan-dev Subject: Re: [PATCH 22/35] arm64: mte: Enable in-kernel MTE Message-ID: <20200908145237.GI25591@gaia> References: <6a83a47d9954935d37a654978e96c951cc56a2f6.1597425745.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 306D06C11 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Tue, Sep 08, 2020 at 04:39:35PM +0200, Andrey Konovalov wrote: > On Fri, Aug 14, 2020 at 7:28 PM Andrey Konovalov wrote: > > From: Vincenzo Frascino > > > > The Tag Checking operation causes a synchronous data abort as > > a consequence of a tag check fault when MTE is configured in > > synchronous mode. > > > > Enable MTE in Synchronous mode in EL1 to provide a more immediate > > way of tag check failure detection in the kernel. > > > > As part of this change enable match-all tag for EL1 to allow the > > kernel to access user pages without faulting. This is required because > > the kernel does not have knowledge of the tags set by the user in a > > page. > > > > Note: For MTE, the TCF bit field in SCTLR_EL1 affects only EL1 in a > > similar way as TCF0 affects EL0. > > > > Signed-off-by: Vincenzo Frascino > > --- > > arch/arm64/kernel/cpufeature.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > index 4d3abb51f7d4..4d94af19d8f6 100644 > > --- a/arch/arm64/kernel/cpufeature.c > > +++ b/arch/arm64/kernel/cpufeature.c > > @@ -1670,6 +1670,9 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap) > > write_sysreg_s(0, SYS_TFSR_EL1); > > write_sysreg_s(0, SYS_TFSRE0_EL1); > > > > + /* Enable Match-All at EL1 */ > > + sysreg_clear_set(tcr_el1, 0, SYS_TCR_EL1_TCMA1); > > + > > /* > > * CnP must be enabled only after the MAIR_EL1 register has been set > > * up. Inconsistent MAIR_EL1 between CPUs sharing the same TLB may > > @@ -1687,6 +1690,9 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap) > > mair &= ~MAIR_ATTRIDX(MAIR_ATTR_MASK, MT_NORMAL_TAGGED); > > mair |= MAIR_ATTRIDX(MAIR_ATTR_NORMAL_TAGGED, MT_NORMAL_TAGGED); > > write_sysreg_s(mair, SYS_MAIR_EL1); > > + > > + /* Enable MTE Sync Mode for EL1 */ > > + sysreg_clear_set(sctlr_el1, SCTLR_ELx_TCF_MASK, SCTLR_ELx_TCF_SYNC); > > isb(); > > > > local_flush_tlb_all(); > > -- > > 2.28.0.220.ged08abb693-goog > > > > Should we change this commit to enable in-kernel MTE only if > KASAN_HW_TAGS is enabled? I think so. We don't currently have any patchset decoupling MTE from KASAN. See my other comment on TCR_EL1.TBI1, you'd need to set TCMA1 as well in the same proc.S file. -- Catalin