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 4E873C636D4 for ; Thu, 9 Feb 2023 18:12:23 +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=7dJlWMG+0iZNGVxa0MAqJkgzvkdUcqk+p1LfNWPB6AA=; b=wUmQi6qL2GZPUj 9Kz+KhmWuEzzir1qsEOHlvIperRueL/U/6RGKz0xGMeNIw3yljC0KA2tuFiV+Z2M3I05toEGMX4zm AwiKdw47i1R5VpfSNOgqLh1yafRGekPaoekJkp4lEWNwOHOlUk2vdT6RtafObTHhYzbEkxdRArwLf wxbFic1HHVL0qfCjUMGHqA2J4iJ4/00Nn7iNAIiCGnmnYsC50Ld/xA+OTfqt9VEXK7nJa3TRbwuup p8BHOoNofTlGXxiD7Bx08HTEaCKKfTAOhLrKjWORmKZLeED3tt//MSbquC9EfYYTlAh34a4enMPNT DaJKT9pW+VkGBS/vr2qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQBOG-002jqq-Aw; Thu, 09 Feb 2023 18:11:24 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQBNm-002jcb-0u for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 18:10:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 72741B8228A; Thu, 9 Feb 2023 18:10:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19077C433D2; Thu, 9 Feb 2023 18:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675966251; bh=ycJQTa90vNc+zMPsmHdkSUMnSh/e/B8/iWuzQP1sK/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olK/T/x8piJxWVB/RdLQlesw68G3DMsLyeWdavMzB1xp1eejOVqh+Sblx0PKtnlZD jmgf+0H1Z/4pc7XMFrlYwEWnioO8wAGacnKFxqD04W7dmx9CT5znlLnHpVJwuHmAiS RC35OvTkK2Jyq6HbdyTDXjwtMS+3LSnRATbpkleekJBJlHHauLnD2N20JvGAlkm0XM DXpymplMTUXYVn7ovgIOUHMs+5fp03PWyymloDE9qWXTcRX3/yHB12Evte9M7vF8XQ BVtpoYb4bmdhjje0YSQUCvqAv5DjyZitaDmUIuiDJh/DlD5/Ykn8SZl45srpimHOBQ 7EH1aP/aJgUjA== 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 1pQBC4-0093r7-8S; Thu, 09 Feb 2023 17:58:48 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Alexandru Elisei , Andre Przywara , Catalin Marinas , Christoffer Dall , Ganapatrao Kulkarni , Russell King , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: [PATCH 10/18] KVM: arm64: nv: Inject HVC exceptions to the virtual EL2 Date: Thu, 9 Feb 2023 17:58:12 +0000 Message-Id: <20230209175820.1939006-11-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209175820.1939006-1-maz@kernel.org> References: <20230209175820.1939006-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, alexandru.elisei@arm.com, andre.przywara@arm.com, catalin.marinas@arm.com, christoffer.dall@arm.com, gankulkarni@os.amperecomputing.com, rmk+kernel@armlinux.org.uk, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.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-20230209_101054_384251_B5E321E4 X-CRM114-Status: GOOD ( 15.55 ) 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 From: Jintack Lim As we expect all PSCI calls from the L1 hypervisor to be performed using SMC when nested virtualization is enabled, it is clear that all HVC instruction from the VM (including from the virtual EL2) are supposed to handled in the virtual EL2. Forward these to EL2 as required. Reviewed-by: Russell King (Oracle) Reviewed-by: Alexandru Elisei Signed-off-by: Jintack Lim [maz: add handling of HCR_EL2.HCD] Signed-off-by: Marc Zyngier --- arch/arm64/kvm/handle_exit.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index e778eefcf214..2d8c09cf3e49 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,16 @@ static int handle_hvc(struct kvm_vcpu *vcpu) kvm_vcpu_hvc_get_imm(vcpu)); vcpu->stat.hvc_exit_stat++; + /* Forward hvc instructions to the virtual EL2 if the guest has EL2. */ + if (vcpu_has_nv(vcpu)) { + if (vcpu_read_sys_reg(vcpu, HCR_EL2) & HCR_HCD) + kvm_inject_undefined(vcpu); + else + kvm_inject_nested_sync(vcpu, kvm_vcpu_get_esr(vcpu)); + + return 1; + } + ret = kvm_hvc_call_handler(vcpu); if (ret < 0) { vcpu_set_reg(vcpu, 0, ~0UL); -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel