From patchwork Thu Aug 20 10:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11726029 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0493F17C5 for ; Thu, 20 Aug 2020 10:36:49 +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 B3B1C20639 for ; Thu, 20 Aug 2020 10:36:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dMMpWGKR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="dnVyOT5y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3B1C20639 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qpFOz0mFRuQstKKYIPRAVud8ersTseaIOGPXD0F16Ys=; b=dMMpWGKRMvWOxKdrACUVrCoLH Z1nvoEvhWSQgX/cZsYj3MOxovPxz8wX7l4t/U0O639CFg1pc0Q4vhAXBE0RHqCQquRbnN/hSOqW8V RL4PDhM9fGmv83ixhmB/cLfKbeMGwtW+sz4PWVsGbM6pYlVuiEndBQsTNcNiSuFtupIoYMd3qMDgB PWC/dSFQ4NVOU/lpEjYp1n4lOHNi7DsY67xCqKh1gwFL1KWSizroC0DVURAhmcmVXYbrEKYiENuQp kA2II/CnDAYOjHgGGSU5uCf252W7bjvxYv/8EIu8xuXLCTMJpFpJX/usbV4jePlyWz0XTV0TLVSh7 AO9Qs/I+g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8hvn-0002Kl-1b; Thu, 20 Aug 2020 10:36:27 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8hv3-00021G-KT for linux-arm-kernel@lists.infradead.org; Thu, 20 Aug 2020 10:35:42 +0000 Received: by mail-qt1-x849.google.com with SMTP id n12so1224789qtr.6 for ; Thu, 20 Aug 2020 03:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=BmbAKV/m7ypqUR0lW+5iQoAhiw2axY9TAu1aTPaDE28=; b=dnVyOT5yZ/CbAgWsodXttzOq3jwrI+1rpZm8LfTGlXqGQU4VYJ6C6Lch+WjQBjhAFq h6t5WD0QDGyWnVLu5vdxGS4swfEgpusX+On71Wl6l549i6kT0Iu+KmrvVElWM3oc2OqJ KN5ccer+ntMN27vddRgGpBXwUZwMy7UeVoFBf+cVCreb74ZoHl9WURk6wL88rQsH1pc9 dAvU2biHq6iGz0dtUYi9PDZQbSH61EWkGqQJFyiXQE53fxeNStNor7kcQ6J499KitvmB A5nD9CcemrqUscqv/cFq35t7/TtgOmLwlYkqfJZ7ztEQg6McPMJ8IEmu8TpTlDv2r/FO hexQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BmbAKV/m7ypqUR0lW+5iQoAhiw2axY9TAu1aTPaDE28=; b=QYXD9XYtoGaxeF6y0IpHDOdoo/HY6D/CAyhThqoJ6lSy33ODV2gUfM/50eIjGFoNku ieAV8AyI5QTWo5QQsCzgAMTBrlt1Ea7sOFLtGXs050PpxSh46KfYKjO+814XhohQ4qxl wnFRTIv+7EoOKr2R5eFQwHvYTG2MMPwOZ68t/IE0mA4VP3GPrwIYNZPEKwbKK0JgGphY tEKceedPGrt/7ne5luMx7I/L9FWw8MdEVtD7CwVK0MYCWE+9VFFj6xczm3VXF20vEYIS e9Wr4e60aGmW8Ksz/Li3JDNe1DTqggnq5hwLmVz+aKK45rOjpb6tE34u6pCGvMMbu2jZ anMA== X-Gm-Message-State: AOAM530QSFOMt04l1FJIn0Zx69OtUn1jwGxmB6uftERhAGP1R0smFYE3 jxTFGHBV+Nf4sCWiXMJ6wiH+8gp2Ddo= X-Google-Smtp-Source: ABdhPJxS8aMsiew65YygRuhFkrEdWeDneRoOb3pQVcpupjRzP3AM3yLOnGQyhHExIhvvZqrepsO7702zqfM= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a0c:8d4a:: with SMTP id s10mr2337167qvb.34.1597919737610; Thu, 20 Aug 2020 03:35:37 -0700 (PDT) Date: Thu, 20 Aug 2020 11:34:34 +0100 In-Reply-To: <20200820103446.959000-1-ascull@google.com> Message-Id: <20200820103446.959000-9-ascull@google.com> Mime-Version: 1.0 References: <20200820103446.959000-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 08/20] KVM: arm64: Preserve host DISR_EL1 From: Andrew Scull To: kvmarm@lists.cs.columbia.edu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200820_063541_761090_74268DE6 X-CRM114-Status: GOOD ( 12.44 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:849 listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender 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: linux-arm-kernel@lists.infradead.org, kernel-team@android.com, suzuki.poulose@arm.com, maz@kernel.org, Sudeep Holla , james.morse@arm.com, Andrew Scull , catalin.marinas@arm.com, will@kernel.org, julien.thierry.kdev@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org With the RAS extension available, guest exits can overwrite DISR_EL1 after checking for any guest SErrors. If the host was using DISR_EL1 to track a deferred SError, it would be lost so save and restore DISR_EL1 for the host. Cc: James Morse Signed-off-by: Andrew Scull --- This may not be necessary if it is a safe assumption that the host doesn't mind that DISR_EL1 is clobbered across the kvm_vcpu_run call. --- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h index 7a986030145f..a549f8698bd4 100644 --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h @@ -56,8 +56,12 @@ static inline void __sysreg_save_el2_return_state(struct kvm_cpu_context *ctxt) ctxt->regs.pc = read_sysreg_el2(SYS_ELR); ctxt->regs.pstate = read_sysreg_el2(SYS_SPSR); - if (cpus_have_final_cap(ARM64_HAS_RAS_EXTN)) - ctxt_sys_reg(ctxt, DISR_EL1) = read_sysreg_s(SYS_VDISR_EL2); + if (cpus_have_final_cap(ARM64_HAS_RAS_EXTN)) { + if (ctxt->__hyp_running_vcpu) + ctxt_sys_reg(ctxt, DISR_EL1) = read_sysreg_s(SYS_DISR_EL1); + else + ctxt_sys_reg(ctxt, DISR_EL1) = read_sysreg_s(SYS_VDISR_EL2); + } } static inline void __sysreg_restore_common_state(struct kvm_cpu_context *ctxt) @@ -152,8 +156,12 @@ static inline void __sysreg_restore_el2_return_state(struct kvm_cpu_context *ctx write_sysreg_el2(ctxt->regs.pc, SYS_ELR); write_sysreg_el2(pstate, SYS_SPSR); - if (cpus_have_final_cap(ARM64_HAS_RAS_EXTN)) - write_sysreg_s(ctxt_sys_reg(ctxt, DISR_EL1), SYS_VDISR_EL2); + if (cpus_have_final_cap(ARM64_HAS_RAS_EXTN)) { + if (ctxt->__hyp_running_vcpu) + write_sysreg_s(ctxt_sys_reg(ctxt, DISR_EL1), SYS_DISR_EL1); + else + write_sysreg_s(ctxt_sys_reg(ctxt, DISR_EL1), SYS_VDISR_EL2); + } } static inline void __sysreg32_save_state(struct kvm_vcpu *vcpu)