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=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 B2594C433DF for ; Wed, 17 Jun 2020 14:06:00 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 371B42071A for ; Wed, 17 Jun 2020 14:06:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 371B42071A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A53BA4B248; Wed, 17 Jun 2020 10:05:59 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Ib7F3iEXSP7; Wed, 17 Jun 2020 10:05:58 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7C47D4B224; Wed, 17 Jun 2020 10:05:58 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 475214B23F for ; Wed, 17 Jun 2020 10:05:57 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DAHPGUNAZN+k for ; Wed, 17 Jun 2020 10:05:56 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 282A64B20E for ; Wed, 17 Jun 2020 10:05:56 -0400 (EDT) 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) Cc: Marc Zyngier , linux-kernel@vger.kernel.org, Dave Martin , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Will Deacon , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm