From patchwork Mon Feb 26 10:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13571819 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 21487C48BF6 for ; Mon, 26 Feb 2024 10:08:48 +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=u4LqkDImvW9KAaJKFlzem5CYMdG0TmbA2Dh/4iJ7wP4=; b=TJH3y3sXM0I72q RlO/qENh1Yc0dfgaXK+eIAMzeKCwUokLvPPx3jNBGVPgi8kW0Iv5A7sFsdH2H85MgRjqmtIyKcjaN kFPL5uwpVKKDAkgENzO/d+PkORJPOFoPtOmO7pEYqj4PcKedqyZDVAVup0tXsVLloVRIf2vZu6f6/ snYQQFZVqYj7w86oM2oXbv7aCg8dN9bc+9RpU4Q4pSMLoT1TGz8iQ/KpHDVrcuk3vJgchpqmkYpwX +e+y5ShB7b7F6VdgTPgxHeG5zm5sWofHbvxL+pWnZ8gjqePdE70F57FVBre8+Eq131ji3WUz7NSbE vRMCVgHgVhnbvnXvL78Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reXuR-0000000HXqW-0lHH; Mon, 26 Feb 2024 10:08:31 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reXtz-0000000HXif-1zqW for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Feb 2024 10:08:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=yMKqTBkmivx6XukPcCjH/L9SvEuRyyOBZlSYq8YKu3s=; b=ZIrkyxsxfYwPTqYcbROii51PwX ZEiJQ9N0+C8fBjxfdRwUCWXzOxTMlc5ssNbMaY9dCoM5BW59xT5WYpBNOvVtbkA6hYLq103nkvVls 8uWgN+QjMkel+mVwlPRdXOX8SWhsZsbfIug/mhopEaA6l5Y85gAJdcC+fw2AMxHAiH6vE+JDiwasX 9hEanfSgikjNRyYRQ9C3s2VjaluZMp/LHU4yPupzea2Sg1PYcmtytQRmM4u0zMwSRIaE//g1SZGZM 472+6t+7+x09C0NJPfgJxjipub+z2+CvfIbw1bCr2yQQYdnXc9z4sW9ptkl8o5Wi0o/cUWcCGIrZI 7ApKWKDQ==; Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reXtq-0000000170U-2BCt for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2024 10:08:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 199CCCE1072; Mon, 26 Feb 2024 10:07:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51852C433F1; Mon, 26 Feb 2024 10:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708942058; bh=e0rt2jqp33R9rOCWsHGguQ7HG/9iK0OPh1vPOWqeSSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFCJS0TyqfCLhpMW2xV+cpWRO2HEaw4DJbuWC3gqZTgV7N+8oV3ApH0n6k5sSsCqR 2tcBj2bMbiA2lrWzWMIwZH7W/7BH6Ri4qDx9TQVjBjsCR9pZ74UFatosNdsQOjs9sI /tOd6rlr3084rK8SCTJTa0QyDrtjfOlDrY9QTOp5WG0284zmfC9AbUp/Si4jCC5Goh ZSIgvvuiH5AW2SlXQpnR9/7rCuTLg7MVxKCmuSTgYSL/ZfI4AnR9XIKsfqwNe1mcvY rVX4ZMBR6hZ54PZOW6e5txBs3IhPb3oh5pMj8O8GIP+bmkUZDVweL+Jh9Jkyak5qYx cL2iWCv5RGQtQ== 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 1reXtX-006nQ5-WB; Mon, 26 Feb 2024 10:07:36 +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 v2 07/13] KVM: arm64: nv: Honor HFGITR_EL2.ERET being set Date: Mon, 26 Feb 2024 10:05:55 +0000 Message-Id: <20240226100601.2379693-8-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240226100601.2379693-1-maz@kernel.org> References: <20240226100601.2379693-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-20240226_100755_115202_AECD4411 X-CRM114-Status: GOOD ( 11.22 ) 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. Signed-off-by: Marc Zyngier Reviewed-by: Joey Gouly --- 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);