From patchwork Tue Jul 30 13:33:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13747407 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 F1939C3DA49 for ; Tue, 30 Jul 2024 13:34:45 +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:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: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=VD2jATJte2QXcbONlRXIdap7n54xnQrB0HokduRi3oo=; b=JbRkJwgT5UpMZ7ZgjhTNH6qRsB 7a2kVMiHBcHQ5ZKUrl8olz0BnQcRTh/FFj2UesVKG+aUmpKhe62N1wVM/vBvribOXTd1Cobr6UWME rW5WhUi0KYESTIQdu0qfqbfar+Vat8vwzRcPhQXCXk+9Lp2yl+XzpjfOQENAxYi5ancLWsoUo5ltW EHGvpU5rie+cJZMXl1wptnPUY7XJ7S1bZhy+aeFCODRL5JKdxFj3Y/Hur04v855vUHWuEyuTstaIE GiBGMEaFKNd13QZwTQwawi8AzZ0Ixa0qW4ft5E/5djnRCUPFShE68Gzd3RDsTPGKWcGb2yUIk9ykq oIwL+jVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYmzr-0000000FIIW-0fO2; Tue, 30 Jul 2024 13:34:35 +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 1sYmyi-0000000FHuK-0jju for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 13:33:35 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 47FCC61EFC; Tue, 30 Jul 2024 13:33:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE728C32782; Tue, 30 Jul 2024 13:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722346403; bh=OzCJBlJRtJE62n4s3JpmBfVWloZEiZIoA/XCH81Aiog=; h=From:Date:Subject:To:Cc:From; b=gMZO/WkWBoJwenk/iVd8EKuGmkkHC0dVVvC+6XjTB6pgjgS4WYnrjZpM/1SAQOcYu Ojw5vJyqQCP4dz2dIcFkbcpkRM3cSReOsyCyFiU4aXpv2L+QmSLNl8e4+kbxqImy4b 0CDY79I3cdcZFMblfZ53cWShw0yObb0S4F/IOQePgtPg3LoAhOduJoWl0HwxPy2+bG 7Zv0d5qE5nS7N0hozi72GEFXHORxLBROMm0ELD1kyfLWkEawmm37vq/tOCARNqgJEf zA5EykYmXKJlWu7GD670IB7xkysWX+uIsy0wLxmqq1qk77Rkinshiv/vaD3he3wZMv nGoBP70pKMNvw== From: Mark Brown Date: Tue, 30 Jul 2024 14:33:03 +0100 Subject: [PATCH v3] KVM: arm64: Fix confusion in documentation for pKVM SME assert MIME-Version: 1.0 Message-Id: <20240730-kvm-arm64-sme-assert-v3-1-8699454e5cb8@kernel.org> X-B4-Tracking: v=1; b=H4sIAI7rqGYC/4XNTQ6CMBCG4auQrh3TnykWV97DuKh2gAYB05JGQ 7i7hZUujMt3ku+ZmUUKniI7FjMLlHz045BD7Qp2a+3QEHiXm0kukZccoUs92NCXCLEnsDHvJ9D WHbR2SMaWLE8fgWr/3NjzJXfr4zSG1/YlifX6B0wCBGhXGYXGcV6bU0dhoPt+DA1bxSQ/Ff1Dk auCqhJXzpWs8UtZluUN/eGRuv8AAAA= To: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2488; i=broonie@kernel.org; h=from:subject:message-id; bh=OzCJBlJRtJE62n4s3JpmBfVWloZEiZIoA/XCH81Aiog=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmqOufdC7tv79b9MVzhVsrXtHEDRlNaY6Xjev9x7yb bsn+o06JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZqjrnwAKCRAk1otyXVSH0Pd5B/ sEc0A3kbk2sDKyyxHoZzXfkXtbf5Xo7CfPJTOquLQ17eBMd9GRvv7ItBTPcRiJALI/43QjZICIgEhK DoxBkeqKyI5n7pe/566ubkwgxa7+q62YipbxNaQhbJ3EFQh+wS7ly+KyKNVUy2oPTG26+5n0LfzbvG 54wv/uIWtNrjdCJnP1imw5P15deAN+FVNChQX3FrxUtKC9cCN4Z92QOl2h7VOQS51Kb4BKdD+EObEj jOL2kkQi16kpzdOIkRIAnqKqYy2+VOpgouvHMgx7H1kRb4Pxm80IyIEBxor8PBYdAZDPzzcXUwPfQU lbIPmdAKJMugiwijHxPOJftI0xPoMh 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-20240730_063324_343498_065EBE2D X-CRM114-Status: GOOD ( 14.58 ) 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 raised in the review comments for the original patch the assert and comment added in afb91f5f8ad7 ("KVM: arm64: Ensure that SME controls are disabled in protected mode") are bogus. The comments says that we check that we do not have SME enabled for a pKVM guest but the assert actually checks to see if the host has anything set in SVCR which is unrelated to the guest features or state, regardless of if those guests are protected or not. This check is also made in the hypervisor, it will refuse to run a guest if the check fails, so it appears that the assert here is intended to improve diagnostics. Update the comment to reflect the check in the code, and to clarify that we do actually enforce this in the hypervisor. While we're here also update to use a WARN_ON_ONCE() to avoid log spam if this triggers. Fixes: afb91f5f8ad7 ("KVM: arm64: Ensure that SME controls are disabled in protected mode") Reviewed-by: Fuad Tabba Signed-off-by: Mark Brown --- Changes in v3: - Rebase onto v6.11-rc1. - Link to v2: https://lore.kernel.org/r/20240605-kvm-arm64-sme-assert-v2-1-54391b0032f4@kernel.org Changes in v2: - Commit message tweaks. - Change the assert to WARN_ON_ONCE(). - Link to v1: https://lore.kernel.org/r/20240604-kvm-arm64-sme-assert-v1-1-5d98348d00f8@kernel.org --- arch/arm64/kvm/fpsimd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b change-id: 20240604-kvm-arm64-sme-assert-5ad755d4e8a6 Best regards, diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index c53e5b14038d..8eca6b338bb2 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -92,11 +92,14 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu) } /* - * If normal guests gain SME support, maintain this behavior for pKVM - * guests, which don't support SME. + * The pKVM hypervisor does not yet understand how to save or + * restore SME state for the host so double check that if we + * are running with pKVM we have disabled SME. The hypervisor + * enforces this when the guest is run, this check is for + * clearer diagnostics. */ - WARN_ON(is_protected_kvm_enabled() && system_supports_sme() && - read_sysreg_s(SYS_SVCR)); + WARN_ON_ONCE(is_protected_kvm_enabled() && system_supports_sme() && + read_sysreg_s(SYS_SVCR)); } /*