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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 E65DCC5519F for ; Wed, 18 Nov 2020 17:04:19 +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 6579424808 for ; Wed, 18 Nov 2020 17:04:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AtDIHJny" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6579424808 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=OQnuRXWyHy5YStiXl4pqgrmOktGfaFy0LKmY+umc31Q=; b=AtDIHJnyUQ1BYodZ5SZd4fRTB jNPJntgm35NHImOACO4FGIal/F1PKwLx3r+hIAdSzzHYq4L05PfCRO6d54CnxBjiD4reOZaIGkQFL d9FsIn1WKD3j3KHE0aRTkeHtEkz7lM634CAWu0ATM2RlyIuUX2Hc6Yvuk/E6GVhnDh2kL5zymAZZk T1j3Hy+Pitt2ZWdsAp5eBVbC7G+M/qvsQ56p21qVi6vlLri+8sdiSVPeIQInG6RY5bZ/TUcAxzMxu Imm8hzmSdmDrZOa6+itS/8qPtQE9KtD27I30D+bOJClbc2opipYFy1DZPdHNd6vLn3ATJM1DHDaHm HfSdJ5NxA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfQr7-0001A6-4s; Wed, 18 Nov 2020 17:02:53 +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 1kfQr2-00018N-Gz for linux-arm-kernel@lists.infradead.org; Wed, 18 Nov 2020 17:02:50 +0000 Received: from trantor (unknown [2.26.170.190]) (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 846B42487D; Wed, 18 Nov 2020 17:02:44 +0000 (UTC) Date: Wed, 18 Nov 2020 17:02:41 +0000 From: Catalin Marinas To: Steven Price Subject: Re: [PATCH v4 1/2] arm64: kvm: Save/restore MTE registers Message-ID: References: <20201026155727.36685-1-steven.price@arm.com> <20201026155727.36685-2-steven.price@arm.com> <98eaa539-0ae8-ce4c-8886-3040542ede80@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <98eaa539-0ae8-ce4c-8886-3040542ede80@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201118_120248_784018_838B824C X-CRM114-Status: GOOD ( 22.46 ) 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 , Peter Maydell , "Dr. David Alan Gilbert" , Andrew Jones , Haibo Xu , Suzuki K Poulose , qemu-devel@nongnu.org, Marc Zyngier , Juan Quintela , Richard Henderson , linux-kernel@vger.kernel.org, Dave Martin , James Morse , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 18, 2020 at 04:01:18PM +0000, Steven Price wrote: > On 17/11/2020 19:20, Marc Zyngier wrote: > > On 2020-10-26 15:57, Steven Price wrote: > > > diff --git a/arch/arm64/include/asm/sysreg.h > > > b/arch/arm64/include/asm/sysreg.h > > > index d52c1b3ce589..7727df0bc09d 100644 > > > --- a/arch/arm64/include/asm/sysreg.h > > > +++ b/arch/arm64/include/asm/sysreg.h > > > @@ -565,7 +565,8 @@ > > > =A0#define SCTLR_ELx_M=A0=A0=A0 (BIT(0)) > > > = > > > =A0#define SCTLR_ELx_FLAGS=A0=A0=A0 (SCTLR_ELx_M=A0 | SCTLR_ELx_A | S= CTLR_ELx_C | \ > > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SCTLR_ELx_SA | SCTLR_ELx_I | SC= TLR_ELx_IESB) > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SCTLR_ELx_SA | SCTLR_ELx_I | SC= TLR_ELx_IESB | \ > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SCTLR_ELx_ITFSB) > > > = > > > =A0/* SCTLR_EL2 specific flags. */ > > > =A0#define SCTLR_EL2_RES1=A0=A0=A0 ((BIT(4))=A0 | (BIT(5))=A0 | (BIT(= 11)) | > > > (BIT(16)) | \ > > > diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h > > > b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h > > > index 7a986030145f..a124ffa49ba3 100644 > > > --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h > > > +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h > > > @@ -18,6 +18,11 @@ > > > =A0static inline void __sysreg_save_common_state(struct > > > kvm_cpu_context *ctxt) > > > =A0{ > > > =A0=A0=A0=A0 ctxt_sys_reg(ctxt, MDSCR_EL1)=A0=A0=A0 =3D read_sysreg(m= dscr_el1); > > > +=A0=A0=A0 if (system_supports_mte()) { > > > +=A0=A0=A0=A0=A0=A0=A0 ctxt_sys_reg(ctxt, RGSR_EL1)=A0=A0=A0 =3D read= _sysreg_s(SYS_RGSR_EL1); > > > +=A0=A0=A0=A0=A0=A0=A0 ctxt_sys_reg(ctxt, GCR_EL1)=A0=A0=A0 =3D read_= sysreg_s(SYS_GCR_EL1); > > > +=A0=A0=A0=A0=A0=A0=A0 ctxt_sys_reg(ctxt, TFSRE0_EL1)=A0=A0=A0 =3D > > > read_sysreg_s(SYS_TFSRE0_EL1); > > = > > As far as I can tell, HCR_EL2.ATA is still clear when running a guest. > > So why, do we save/restore this state yet? > > = > > Also, I wonder whether we should keep these in the C code. If one day > > we enable MTE in the kernel, we will have to move them to the assembly > > part, much like we do for PAuth. And I fear that "one day" is pretty > > soon: > > = > > https://lore.kernel.org/linux-arm-kernel/cover.1605046192.git.andreyknv= l@google.com/ > = > Good point. Although for MTE we do have the option of setting TCO in PSTA= TE > so this could remain in C if we're not bothered about the 'gap' in KASAN > coverage. I haven't yet got my head around how (or indeed if) that series > handles guests. I think we should be fine with the currently proposed in-kernel MTE support. However, setting GCR_EL1 can get in the way if stack tagging is ever enabled (it breaks single image). The compiler uses GCR_EL1 to generate different colours for variables on the stack and changing it in the middle of a function may cause confusion. You'd have to set PSTATE.TCO for the whole function, either from the caller or, if the compiler gets smarter, some function attribute. -- = Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel