From patchwork Thu Jul 4 17:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13724130 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 C71FEC30653 for ; Thu, 4 Jul 2024 17:30:28 +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:Cc:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wPG6LzXPCVw0+0ZaPP/Sdz/UU+I70osPdEsDqUjM6JA=; b=oKazOUEKZ8XapZ IFrgg766wNZi+VrnfBAYWYmswyDF05Z5nHGp7FVEfGGWFt3jcwu8kTHu3zXgBIzoAyFM7nLAbLFW5 8GqL6rbHZasUxazrSiKHgME+wf8Mr1uTmNau7ZcvJH7P1x0jDcBLivngtzAMXKVGWDmu/yYs8MF+n IKV69iw5sfn1MyYcL/vwy5hRtyL8ICsrEBpNZdTWpCt4SwOlstXQndEfeT1wsyFkzn9lbQJyDR6Jc JwrKpGuHtK2X1a6Hrw461poQKHwk/MJbMVmil/m/hswg8/o3lW9w5zMib2+MWkeSvlYRP++W9TLFT OIe0V8TSNqptmSk9pg1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPQHh-0000000E1SN-03Dq; Thu, 04 Jul 2024 17:30:17 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPQGC-0000000E0pI-0Krb for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2024 17:28:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 153706283D; Thu, 4 Jul 2024 17:28:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5E9CC3277B; Thu, 4 Jul 2024 17:28:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720114122; bh=tAfv1BaL1iUUqXnX9Z5FvigYgE4xYEQucoc/CaZ1L6k=; h=From:Subject:Date:To:Cc:From; b=ixopY0S8I3pDbvaHEwwlvybyzT7wY8SOEyc03XGKGvSSqyyKIZN13TNL8vL+J6AXU jC/N6/zsV81jQBLUkWkor9eFCGqz+cgZd84mVZziThOJHK/X+hfv6rTsJM8XN9QXRj pvOK8kjcs23VYIy6NFChLSP2Ncstcw7F1kemtsXmMz55rdWVFRPn0c82a21xqOcDTS QBf1WjnF0PXl9nkRTRvqx9io4UKh/02aarx2J4GyIsx2eCQJiuvanpFHtdC0HIId5z /Gap+LDt+KfWJg+cHVAtDHJLCSSzV7F0/iIV13wX9BPabmiTOF8799tSFKwDwPPnDm z3BwMVt7i8DnA== From: Mark Brown Subject: [PATCH v4 0/4] KVM: arm64: Fix underallocation of storage for SVE state Date: Thu, 04 Jul 2024 18:28:15 +0100 Message-Id: <20240704-kvm-arm64-fix-pkvm-sve-vl-v4-0-b6898ab23dc4@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALDbhmYC/33NzQrCMAzA8VcZPRtpu6ydnnwP8WDXbCv7pJWiy N7dThAUYcd/SH55skDeUWDH7Mk8RRfcNKbAXcaq9jo2BM6mZpJL5IojdHGAqx8UQu3uMK8ZIkH sQeSV1aK22hrO0v3sKa287fMldevCbfKP96so1+lHVRtqlMChKssayaARaE4d+ZH6/eQbtrJRf FPFFiUSpUpulcHcYCX+qPyb0ltUnqjiQLoUmiurih9qWZYXCmQaqVkBAAA= To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Fuad Tabba Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Mark Brown X-Mailer: b4 0.14-dev-d4707 X-Developer-Signature: v=1; a=openpgp-sha256; l=1908; i=broonie@kernel.org; h=from:subject:message-id; bh=tAfv1BaL1iUUqXnX9Z5FvigYgE4xYEQucoc/CaZ1L6k=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmhtvE5jQaTpD8ZhDPn8DqiYalF5DszeadfNNtlx+f foCRQCmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZobbxAAKCRAk1otyXVSH0B+1B/ 9rJLpd/MmNXdmbQYsLI2+RCatIbty19wmYGq6fYC7YOCwE7WuhCXUDOCqlX5W/2FzQDHqQBmDALnIE EYYYQ7nBIE129bO9I3iQUrJz0wJP0hpkXm/ywCjjGujTPNe/+jE5477w7jaoN+thvcfwTfYybHyKno oxykg8ddVmYxKJ9YJwB6Oe7oNeJbHD22a5DcAPfCz+olj7eypIX5dada+7ongd/X4/HVnIDbcNxDFV UqWKekxNN38yRf4OvtNHfRSaf48c+MnIUnTf6XZwR3gx4padpJyZX83wKlWbhmcwgAxbItbs6sX1vs zQAJdT+iSOXfVcToIQqx56L/y8Bwb9 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240704_102844_261321_6AC01E70 X-CRM114-Status: UNSURE ( 9.04 ) X-CRM114-Notice: Please train this message. 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 As observed during review the pKVM support for saving host SVE state is broken if an asymmetric system has VLs larger than the maximum shared VL, fix this by discovering then using the maximum VL for allocations and using RDVL during the save/restore process. Signed-off-by: Mark Brown --- Changes in v4: - Roll in Catalin's acks. - Link to v3: https://lore.kernel.org/r/20240607-kvm-arm64-fix-pkvm-sve-vl-v3-0-59e781706d65@kernel.org Changes in v3: - Replace %u with %lu in late CPU error message. Changes in v2: - Downgrade check for a late CPU increasing maximum VL to a warning only but do it unconditionally since pKVM prevents late CPUs anyway. - Commit log tweaks. - Link to v1: https://lore.kernel.org/r/20240605-kvm-arm64-fix-pkvm-sve-vl-v1-0-680d6b43b4c1@kernel.org --- Mark Brown (4): arm64/fpsimd: Introduce __bit_to_vl() helper arm64/fpsimd: Discover maximum vector length implemented by any CPU KVM: arm64: Fix FFR offset calculation for pKVM host state save and restore KVM: arm64: Avoid underallocating storage for host SVE state arch/arm64/include/asm/fpsimd.h | 17 +++++++++++++++ arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_hyp.h | 3 ++- arch/arm64/include/asm/kvm_pkvm.h | 2 +- arch/arm64/kernel/fpsimd.c | 38 +++++++++++++++++++++++++++------ arch/arm64/kvm/hyp/fpsimd.S | 5 +++++ arch/arm64/kvm/hyp/include/hyp/switch.h | 2 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 6 +++--- arch/arm64/kvm/hyp/nvhe/pkvm.c | 2 +- arch/arm64/kvm/reset.c | 6 +++--- 10 files changed, 65 insertions(+), 18 deletions(-) --- base-commit: afb91f5f8ad7af172d993a34fde1947892408f53 change-id: 20240604-kvm-arm64-fix-pkvm-sve-vl-13cd71fd7db0 Best regards,