From patchwork Tue Dec 17 14:23:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13911915 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 7B1B0E7717F for ; Tue, 17 Dec 2024 14:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kRaA8QbuuRReYFOYhA5H3YsQUanXbjrfpnfvlWrVcZE=; b=B/lOyrtxNdJ3PiBZc6vJd2QGmU 6rErxZgU9cIyFrgG58+1lwyP3nI0mjKiFCsNk7h/CHj85CArM+u7JBvzh2OumWiFwsCIwC9g3QoMh VMaXco/m50CYsSmaX9DDKQX5GiMIVPQCCmT15/TGeSD5wngmn5F9VvOCRtaBO7pPEO/LHtP/wOjDo adbErj1nVAseGx0lzRkW4hw4cekU3Qo5sOXHqRZvY5R0efDKFi4jL47/gjTRnjLzKdnXgtFAxPbLG Ovfsv7ImDWTchhKL6MIU/D8JRusUNZyccAgIa6IYDvEOWdM+JxFoZkroAjULSez4nE7yLFit1AydW g88b4QHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tNYZE-0000000Dknm-0XNZ; Tue, 17 Dec 2024 14:28:56 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tNYTx-0000000DjY7-1o2W for linux-arm-kernel@lists.infradead.org; Tue, 17 Dec 2024 14:23:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id C9EB9A418DD; Tue, 17 Dec 2024 14:21:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 559B0C4CED3; Tue, 17 Dec 2024 14:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734445408; bh=lF2ax88UUsP94gAzYVqXkXrfXc+/lzun8rESgff8Kw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nkMX7o6aZMQc+YTR90omdLeqJQCyfPFiBboJmkdiDnnC/ilocBahACOwO+fC4JQdV NE6aOtD30XLpOdPnJJ+7ETQYG1jLI8vkFp6aNq0PbO/I17BkLX2azdP3YEIKZO9n/A 1jmMXNUH+Osu8FvJgCcZRWYGVzwCUzBX9DgFGXaywFPyH3QAlLRQbSx0CHceCdiJbe xOM4OXeLix/51wylaTOZSBfYNJkwymn6osQ5FT37p3PMdAfsyyCIV7vy/bow9353Ga 5PLMB5cjEHaRUCq357KJRqhD5O1WEn5yBAP/Hc3WiGU3HpKF5SCqYzlXOg6xk+Kgh3 29pthKxKfujew== 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 1tNYTu-004aJx-CF; Tue, 17 Dec 2024 14:23:26 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Bjorn Andersson , Christoffer Dall , Ganapatrao Kulkarni , Chase Conklin , Eric Auger Subject: [PATCH v2 09/12] KVM: arm64: nv: Propagate CNTHCTL_EL2.EL1NV{P,V}CT bits Date: Tue, 17 Dec 2024 14:23:17 +0000 Message-Id: <20241217142321.763801-10-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241217142321.763801-1-maz@kernel.org> References: <20241217142321.763801-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, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, andersson@kernel.org, christoffer.dall@arm.com, gankulkarni@os.amperecomputing.com, chase.conklin@arm.com, eauger@redhat.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-20241217_062329_534062_D450997A X-CRM114-Status: GOOD ( 11.61 ) 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 Allow a guest hypervisor to trap accesses to CNT{P,V}CT_EL02 by propagating these trap bits to the host trap configuration. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/arch_timer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 6f04f31c0a7f2..e5951e6eaf236 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -824,6 +824,10 @@ static void timer_set_traps(struct kvm_vcpu *vcpu, struct timer_map *map) * Apply the enable bits that the guest hypervisor has requested for * its own guest. We can only add traps that wouldn't have been set * above. + * Implementation choices: we do not support NV when E2H=0 in the + * guest, and we don't support configuration where E2H is writable + * by the guest (either FEAT_VHE or FEAT_E2H0 is implemented, but + * not both). This simplifies the handling of the EL1NV* bits. */ if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) { u64 val = __vcpu_sys_reg(vcpu, CNTHCTL_EL2); @@ -834,6 +838,9 @@ static void timer_set_traps(struct kvm_vcpu *vcpu, struct timer_map *map) tpt |= !(val & (CNTHCTL_EL1PCEN << 10)); tpc |= !(val & (CNTHCTL_EL1PCTEN << 10)); + + tpt02 |= (val & CNTHCTL_EL1NVPCT); + tvt02 |= (val & CNTHCTL_EL1NVVCT); } /*