From patchwork Thu Mar 21 15:53:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13599046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A91CAC54E58 for ; Thu, 21 Mar 2024 15:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sW0SAXFbhugP5pRKPyPwLwSBDeDaTFar5ty9VqCoOHc=; b=QOoxoVvQ9P/x4w hvX/Y2yx2VIrDr+LZU1fU5MyTXDxiDYhhuR9xCHLpRChKeKV1dIE/5pLvrzfHSpmuPrChHDVvR4lB CoVg4IWP14YenNSExQ8YAtIl1emOv6pwUeMMKMo4CRgd5r3lrfqrvpJWJuLVLi/2Lzj89wL5t0Vm9 nDU7X8DMUPotXJ7YmSrh+fEGRUMJ+bVa3hj+Y8XABfN6UhPT5L0T3H8YtXi6/gjPBwRA/ecglPFtU Cg+kaNxialJ8MWMHHze0GNhDk3GnOypUTQc6O5rsKLBqMX+WRgQekFl2ZX8OXHkYBoEZiogzsdiWT ZgDdrjRLvqMtOSGJUyNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnKko-00000003e9m-1NXr; Thu, 21 Mar 2024 15:54:54 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnKkU-00000003duU-1RLF for linux-arm-kernel@lists.infradead.org; Thu, 21 Mar 2024 15:54:37 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 20BD0611A9; Thu, 21 Mar 2024 15:54:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6CCBC43394; Thu, 21 Mar 2024 15:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711036472; bh=O958mgtn9nV4TgPjJ6Mafj249lAxQx44+60Sd2GqF7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evdSs+RyNulD+ZIws5QaJlzu1Fg3cYGAhvLNEtnyqzDpDCoQBhcWiOwDblewHWx5c c7jZMR+KZU5cu9bBNANQ7F5X877W+Cdoqot7o5TnWBsl/b5lkB0I6JuLu5L43PSzwM HRTwGf/8oK7Xz83AHqGeQ1FhwhSc4/brU2Jyo2TnilFrZgSVDC2JctBUNv1BVmD/M+ i/i8X3VkFZ7H+BAt/IA/7GQIMpSRkbBK8WWO/XyM828+7vErPeinxmfDCgjd7j4JYc erz8bySAEsOARkeI2lLq0utpBOmPdOA64kkNI4aXAP5vPG1enEhgf5vseFxDshOzFU q+FMBw350Qi/A== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rnKkR-00EEqz-0s; Thu, 21 Mar 2024 15:54:31 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Joey Gouly , Will Deacon , Catalin Marinas Subject: [PATCH v3 08/15] KVM: arm64: nv: Honor HFGITR_EL2.ERET being set Date: Thu, 21 Mar 2024 15:53:49 +0000 Message-Id: <20240321155356.3236459-9-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240321155356.3236459-1-maz@kernel.org> References: <20240321155356.3236459-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, joey.gouly@arm.com, will@kernel.org, catalin.marinas@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240321_085435_020608_49364573 X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the L1 hypervisor decides to trap ERETs while running L2, make sure we don't try to emulate it, just like we wouldn't if it had its NV bit set. The exception will be reinjected from the core handler. Reviewed-by: Joey Gouly Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/vhe/switch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index eaf242b8e0cf..3ea9bdf6b555 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -220,7 +220,8 @@ static bool kvm_hyp_handle_eret(struct kvm_vcpu *vcpu, u64 *exit_code) * Unless the trap has to be forwarded further down the line, * of course... */ - if (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_NV) + if ((__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_NV) || + (__vcpu_sys_reg(vcpu, HFGITR_EL2) & HFGITR_EL2_ERET)) return false; spsr = read_sysreg_el1(SYS_SPSR);