Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4190261pxk; Tue, 8 Sep 2020 13:04:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBCUnt5UNacmFnFbyXGM79K+epLC9UrMehJjAe/XdS+ElD5BiIZKzZR1enKzqIzNXIXXli X-Received: by 2002:a17:906:a3d0:: with SMTP id ca16mr93274ejb.455.1599595490260; Tue, 08 Sep 2020 13:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599595490; cv=none; d=google.com; s=arc-20160816; b=bmzxC/vbh9vpGOxkRHC6Z+DYMkuifq2q3cA/ywE2neA7FlFWtFgkNS6E8fHcDv777u HfHGVgVF9CQApe60D3BPw2VztS3y3nwmvRZCHDvyIInFSW9zlcFW63mrq4BBLxuOd4yi x3vcXec9PLezRtX3EnZfQGMGp/1IoNPNEN8vLkCbv2KTvktXeMBTC25rza5TAfrX1FFb V7GQMW9yB5bh7b1QvkbmSWet1lpnbYFPyez152EOLZdILK1cu0iIWjmiFS7TYVaCZAIK gELwV4t7NW4V/j47ZhjkHHD5n0d3OuLWiD+fLHiYe4Ry++L7PvWZ4ZeKSjMLzvmxC7da Od7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=BpqtfenlTX83+6Cjb2uL5fTK+xGqR469d9bEpaF0aWc=; b=sBbSX/6DxSLL/4KM4d7ose0x4OL1qtZih4aCMT/eOlVfxQmlUJ4H32Oar4MthUVNrj /JkNl1M6uueSj8es9eFf2kANC25D1/MhG7Qsm13Dgv76H069aPzHFe6OKp46drSO3efX AvhulWn4tqF1kFSgJnQU0guZaekh+whd9I0ngTwNud58pazJ0t8q4/uUimZBdCN7AHPr gWLxtcl3+Q2woVl/N6n+Nhk3r3R+gXXsF5TXmvB/NuF3YCbDZ+lBadCseM2cJT4V5D6i f4HVcp/T6cDY0+6zKaxCEmsXZNtaOw5tdfshZADs9uqZO9JzG1VGS6sBIaMBapfwUcnA L+nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si47799ejw.176.2020.09.08.13.04.27; Tue, 08 Sep 2020 13:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730434AbgIHUDt (ORCPT + 99 others); Tue, 8 Sep 2020 16:03:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:56616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730447AbgIHPXy (ORCPT ); Tue, 8 Sep 2020 11:23:54 -0400 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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