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 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 D4216C54E4A for ; Fri, 8 Mar 2024 17:54:41 +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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XRKOyoDSsdmF+LWNpOypd0DiKmqZQQQeMesDtPCaZLU=; b=RuuFRRJK5cwMDV yz99+DXA9qkvMlf6inI0DhVaJzUK5U1f/D6T4VfvpEiurNotc3va19PLE74m7UnqBosrUEXm+aiDl sHTvKtop4Dkn0ES08g0FzdVWdZwRLb7qvqGe8UHV61GbUW7E6kMQwQ7jUrhLJYDD64/TIVmKx4F7a 0rx99qkr/9WnfpAC5jO8LwZIkIubS1Stbt1TaugnLpBpoPXOK2MwzZ/2RGMwCEdCKT5sjsbT+Hpw8 HZ6fsNAwuQGSHRPEFIV/5UdGrC2wmaUEsEbkqODmKvTY9WJV+5qMaUl9Po6IVxleQTvXprJE95art CclKM3My1caFZ2nx4mJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rieQR-0000000AdZX-06LY; Fri, 08 Mar 2024 17:54:31 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rieQN-0000000AdXS-2X5U for linux-arm-kernel@lists.infradead.org; Fri, 08 Mar 2024 17:54:29 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E75B0CE1E7A; Fri, 8 Mar 2024 17:54:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27556C433F1; Fri, 8 Mar 2024 17:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709920464; bh=XTDBgV8u300JsMhzl1J3kH/u694G+TtTR7EwriVVNnY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fxbPq530X418y/lnp+f2Ysg5ehGiPcYvB1590PEmOhg/JgnRwvxDeh1+qS0XE5bYv UXNukxslcG88YyJXAu/G5Aa6s0G0/ap1L8Xbg5zHAqsMDbQ9eZknSM3HDVeY+p4OOB MlAWFNdBRV8iWajZeahsPMFLDVO6BpWwLk6zFjHoONG40w9mqWq4Ecme0FpIsyXZgS hwosj7aMZj4bKbdy9/gWy/XV8mkD/ppH65+TOFD6JHOQgf2LLyTCyj9RgnJ4tDDKPZ ajQ7I/Xfcz+xwjTfmcUq+YMrVO3cdu1oEdCvtAMNk8PpbocVKmiJe+RfmDN13La02L slsIiycvr1ivA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rieQH-00AnhP-Qm; Fri, 08 Mar 2024 17:54:22 +0000 Date: Fri, 08 Mar 2024 17:54:20 +0000 Message-ID: <86h6hg1uer.wl-maz@kernel.org> From: Marc Zyngier To: Joey Gouly Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Catalin Marinas Subject: Re: [PATCH v2 11/13] KVM: arm64: nv: Add emulation for ERETAx instructions In-Reply-To: <20240308172059.GA1052268@e124191.cambridge.arm.com> References: <20240226100601.2379693-1-maz@kernel.org> <20240226100601.2379693-12-maz@kernel.org> <20240308172059.GA1052268@e124191.cambridge.arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: joey.gouly@arm.com, 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, 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-20240308_095428_027933_5B2F1852 X-CRM114-Status: GOOD ( 23.54 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 08 Mar 2024 17:20:59 +0000, Joey Gouly wrote: > > Phew.. [...] > Each function in this file is quite small, but there's certainly a lot of > complexity and background knowledge required to understand them! > > I spent quite some time on each part to see if it matches what I understood > from the Arm ARM. > > Reviewed-by: Joey Gouly Thanks a lot for putting up with it, much appreciated. > A side note / thing I considered. KVM doesn't currently handle ERET exceptions > from EL1. EL1 is ambiguous here. Is that EL1 from the PoV of the guest? > > 1. If an ERETA{A,B} were executed from a nested EL1 guest, that would be > trapped up to Host KVM at EL2. There are two possibilities for that (assuming EL1 from the PoV of a L1 guest): (1) this EL1 guest is itself a guest hypervisor (i.e. we are running an L1 guest which itself is using NV and running an L2 which itself is a hypervisor). In that case, ERET* would have to be trapped to EL2 and re-injected. Note that we do not support NV under NV. Yet... (2) the L2 guest is not a hypervisor (no recursive NV), but the L1 hypervisor has set HFGITR_EL2.ERET==1. We'd have to re-inject the exception into L1, just like in the precedent case. If neither HCR_EL2.NV nor HFGITR_EL2.ERET are set, then no ERET* gets trapped at all. Crucially, when running an L2 guest that doesn't isn't itself a hypervisor (no nested NV), we do not trap ERET* at all. In a way, the NV overhead is mostly when running L1. Once you run L2, the overhead "vanishes", to some extent (as long as you don't exit, because that's where the cost is). > 2. kvm_hyp_handle_eret() returns false since it's not from vEL2. Inside > kvm_handle_eret(), is_hyp_ctxt() is false so the exception is injected into > vEL2 (via kvm_inject_nested_sync()). > > 3. vEL2 gets the exception, kvm_hyp_handle_eret() returns false as before. > Inside kvm_handle_eret(), is_hyp_ctxt() is also false, so > kvm_inject_nested_sync() is called but now errors out since vcpu_has_nv() is > false. > > Is that flow right? Am I missing something? I'm not sure. The cases where ERET gets trapped are really limited to the above two cases. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel