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=-5.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 E2E5DC433DF for ; Wed, 17 Jun 2020 14:06:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AB4602071A for ; Wed, 17 Jun 2020 14:06:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pMjRGSMV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB4602071A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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=bombadil.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=VJE3txa6cBfxsIxLvJ5HCljO48jBnk6XaqQMssP0Ms8=; b=pMjRGSMVsa0Jr6 Ui56sBCeTrWAk02V4hCAxb0kY6aIDs9jS+GTjnFEgdLXAWEvACeLC0GhpwevVVI3ySmIp3Q8Pf4Ct X+T26b5Dyd1jrkGVYr4t9buR3XWgjz0UZXVHKUWRqnYLE2ngCpyIX56LZaQ3+FkYQgxLusOkRCX3R ZCp9WMYcABVqtyLUBAVKy7pocFiVpZHftvaSf3JNY7Uxzn2l0N38XqAK4K/HBYdth9rHfSN3WxXbh uLS0iZe/kS8bxJ6E31BD/USn0dU56uUPdHZYeCEhJj/PYOsvcjM1sKqqeWLCkErVY1cJow0zTmlyy 6k/6XnneRFl06U5MTAXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlYhW-0005HQ-2C; Wed, 17 Jun 2020 14:06:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlYhS-0005GV-Ft for linux-arm-kernel@lists.infradead.org; Wed, 17 Jun 2020 14:05:59 +0000 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 9DC9E31B; Wed, 17 Jun 2020 07:05:55 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA5563F73C; Wed, 17 Jun 2020 07:05:53 -0700 (PDT) Date: Wed, 17 Jun 2020 15:05:47 +0100 From: Catalin Marinas To: Steven Price Subject: Re: [RFC PATCH 1/2] arm64: kvm: Save/restore MTE registers Message-ID: <20200617140546.GE5388@gaia> References: <20200617123844.29960-1-steven.price@arm.com> <20200617123844.29960-2-steven.price@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200617123844.29960-2-steven.price@arm.com> 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-20200617_070558_572319_0446DEA1 X-CRM114-Status: GOOD ( 13.86 ) 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 , Suzuki K Poulose , Marc Zyngier , 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 17, 2020 at 01:38:43PM +0100, Steven Price wrote: > diff --git a/arch/arm64/kvm/hyp/sysreg-sr.c b/arch/arm64/kvm/hyp/sysreg-sr.c > index 75b1925763f1..6ecee1528566 100644 > --- a/arch/arm64/kvm/hyp/sysreg-sr.c > +++ b/arch/arm64/kvm/hyp/sysreg-sr.c > @@ -26,6 +26,12 @@ > static void __hyp_text __sysreg_save_common_state(struct kvm_cpu_context *ctxt) > { > ctxt->sys_regs[MDSCR_EL1] = read_sysreg(mdscr_el1); > + if (system_supports_mte()) { > + ctxt->sys_regs[RGSR_EL1] = read_sysreg_s(SYS_RGSR_EL1); > + ctxt->sys_regs[GCR_EL1] = read_sysreg_s(SYS_GCR_EL1); > + ctxt->sys_regs[TFSRE0_EL1] = read_sysreg_s(SYS_TFSRE0_EL1); > + ctxt->sys_regs[TFSR_EL1] = read_sysreg_s(SYS_TFSR_EL1); > + } TFSR_EL1 is not a common register as we have the TFSR_EL2 as well. So you'd have to access it as read_sysreg_el1(SYS_TFSR) so that, in the VHE case, it generates TFSR_EL12, otherwise you just save the host register. Also, since TFSR*_EL1 can be set asynchronously, I think we need to set the SCTLR_EL2.ITFSB bit so that the register update is synchronised on entry to EL2. With VHE we get this automatically as part of SCTLR_EL1_SET but it turns out that we have another SCTLR_ELx_FLAGS macro for the non-VHE case (why not calling this SCTLR_EL2_* I have no idea). > /* > * The host arm64 Linux uses sp_el0 to point to 'current' and it must > @@ -99,6 +105,12 @@ NOKPROBE_SYMBOL(sysreg_save_guest_state_vhe); > static void __hyp_text __sysreg_restore_common_state(struct kvm_cpu_context *ctxt) > { > write_sysreg(ctxt->sys_regs[MDSCR_EL1], mdscr_el1); > + if (system_supports_mte()) { > + write_sysreg_s(ctxt->sys_regs[RGSR_EL1], SYS_RGSR_EL1); > + write_sysreg_s(ctxt->sys_regs[GCR_EL1], SYS_GCR_EL1); > + write_sysreg_s(ctxt->sys_regs[TFSRE0_EL1], SYS_TFSRE0_EL1); > + write_sysreg_s(ctxt->sys_regs[TFSR_EL1], SYS_TFSR_EL1); > + } Similarly here, you override the TFSR_EL2 with VHE enabled. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel