From patchwork Tue Aug 20 13:17:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13770100 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 BB503C3DA4A for ; Tue, 20 Aug 2024 13:25:25 +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: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:In-Reply-To:References:List-Owner; bh=+rs4u6BlPn7EVU5wIf5+fr27KTdEWieJ7g49zT+qBfs=; b=rkjQ29nXC94y8L3nT6t+j9A1RZ 8yu0JmwK7BhfNk3N2DsChwQym6fwpnlPx7sZR/ZDBscR9vaR5dHYltFKTqrmDRcveDO8yqPdtGSrV J6RQk4yE9RL+OFbwclvfm8zerdXWSz6ICMsSoZsuu8WKIj8JyYljipJGj44Y97z/s4/VYJS52fLnh 3FEbXxSiayCxF+/d2GmKDNR3pB0Ky0ryIWK4NAs6jflcURkiRw0U4EZ0XAI+C2+oiLA0gQUcNqSt0 1Duk8ifAjPmXlvcjCOwEZ5c+3wyb9yae8zfg/muE5zE7sDCiPEMOm3t0tezCYTeNEL03FAPW/Ycfx vlwg4M7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgOrL-00000005LXK-2YbZ; Tue, 20 Aug 2024 13:25:15 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgOkV-00000005JiQ-2DPM for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 13:18:13 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 44312CE0A1D; Tue, 20 Aug 2024 13:18:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02C9AC4AF10; Tue, 20 Aug 2024 13:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724159888; bh=w66lr3+fWgepBhO+Q8813/VtQfHj20xrCsLXmI3bW6M=; h=From:To:Cc:Subject:Date:From; b=gYjJQoS/JlQ57qP/qoqHQrvHgHuROkqDRoZLKpK5ymiqdRO8TrybmbFgITU1R48bX RnUCq15ehC2D1VHfL3QlGS1M+8f0cj4tN2h0Uf1zBLEFHYVw6QWd2A1YVJNtJvn9m3 l3GJrswoIO26nqN/Xe6ZiHbfB0A2ix3qXMzGxB8psqHvqoSuFgkXnuARDtitLGJ96+ +rCEmOJd0xI/Z+9l0e6gHScBpVHZlaTFcy365K9GupYey9qae4GFATlRMmJDoH77Yy h1p3uVBgO3LygW09xvIwkQaCBwWitUMqmwxecIvpi/cx+8TawvxU9misNXUs+OuTl3 degyNHG4XA1pw== 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 1sgOkP-005HMQ-Qf; Tue, 20 Aug 2024 14:18:05 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Fuad Tabba , Joey Gouly , Mark Brown Subject: [PATCH v4 0/8] KVM: arm64: Add support for FP8 Date: Tue, 20 Aug 2024 14:17:54 +0100 Message-Id: <20240820131802.3547589-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 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, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, tabba@google.com, joey.gouly@arm.com, broonie@kernel.org 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-20240820_061812_004637_8DC72752 X-CRM114-Status: GOOD ( 13.95 ) 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 Although FP8 support was merged in 6.9, the KVM side was dropped, with no sign of it being picked up again. Given that its absence is getting in the way of NV upstreaming (HCRX_EL2 needs fleshing out), here's a small series addressing it. The support is following the save/restore model established for the rest of the FP code, with FPMR being tied to it. The sole additions are the handling of traps in a nested context, and the corresponding ID registers being made writable. As an extra cleanup, SVCR and FPMR are moved into the sysreg array. Patches are on top of v6.11-rc1. Note that this is compile-tested only, as I have no access to FP8 HW or model (and running NV in a model is not something I wish to entertain ever again). * From v3 [3] - Simplify handling of SYS_ID_AA64PFR2_EL1 * From v2 [2] - Add missing kern_hyp_va() when dereferencing vcpu->kvm on nVHE setups * From v1 [1] - Correctly save/restore the guest state (duh), including pKVM (double duh) - Add a predicate for FPMR support in a VM, as this gets used more than twice... [1] https://lore.kernel.org/r/20240708154438.1218186-1-maz@kernel.org [2] https://lore.kernel.org/r/20240708154438.1218186-1-maz@kernel.org [3] https://lore.kernel.org/r/20240813104400.1956132-1-maz@kernel.org Marc Zyngier (8): KVM: arm64: Move SVCR into the sysreg array KVM: arm64: Add predicate for FPMR support in a VM KVM: arm64: Move FPMR into the sysreg array KVM: arm64: Add save/restore support for FPMR KVM: arm64: Honor trap routing for FPMR KVM: arm64: Expose ID_AA64FPFR0_EL1 as a writable ID reg KVM: arm64: Enable FP8 support when available and configured KVM: arm64: Expose ID_AA64PFR2_EL1 to userspace and guests arch/arm64/include/asm/kvm_host.h | 20 ++++++++++++++-- arch/arm64/kvm/emulate-nested.c | 8 +++++++ arch/arm64/kvm/fpsimd.c | 5 ++-- arch/arm64/kvm/hyp/include/hyp/switch.h | 3 +++ arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++ arch/arm64/kvm/hyp/nvhe/switch.c | 9 +++++++ arch/arm64/kvm/hyp/vhe/switch.c | 3 +++ arch/arm64/kvm/sys_regs.c | 32 ++++++++++++++++++++++--- 8 files changed, 82 insertions(+), 7 deletions(-) Reviewed-by: Mark Brown Tested-by: Mark Brown