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 33D62C433EF for ; Thu, 2 Jun 2022 12:42:56 +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: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:In-Reply-To:References: List-Owner; bh=+zsKAGDTWJ33lxbktZSLO+t3qs9OaKd4zOh3RBsZq/E=; b=O9lwN+mn7Lkd2f tdgqbFUfKCP2dlrm8BN7qj8DudNh+PnZ96VKgkmLtCU7hEkBUljHMdGsyC6L81KYR/LtNa6xCSYHF xyOItLvImPXO9Zg9dW3t5xpzOe35pylmS1G33z8M9WbiJbfN2nej2iiqMJczoUkCv1BduCjS8f8bL GY/6HRG+/OJ/c2xTzHsH/hcpBqWmBAl4+BWYZvzGhd7DQvF4ke/8exHpN3KtS5d97fv0qOD3b3KQ+ ALkPaIwTi6f6QNFvw1c7SK4C+qYk3mA+TnYfJUEN002Zoq7Jegsr64m6PAsFL3rBwLooHZxiwka49 f2lVeZDipGS2uUdQTo9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwk9A-003F57-KE; Thu, 02 Jun 2022 12:41:52 +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 1nwk98-003F4T-1Y for linux-arm-kernel@lists.infradead.org; Thu, 02 Jun 2022 12:41:51 +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 2E84FB80DB5; Thu, 2 Jun 2022 12:41:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD478C385A5; Thu, 2 Jun 2022 12:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654173704; bh=uCwV3zgnEsE3gfVAu+k4qrVDUV053mcpCveL0SGw54I=; h=From:To:Cc:Subject:Date:From; b=gksC/y+SHfACJX4eeC1YweOtAwXF7LHSMevBNg+C/td4ygheQoUYbkQDgbk9K5/li 4vgOnBWjrN8FzJBIXez9V/L9CTMqszDDBSTRlLK5NIIKQzXkYk/eCkccwZE9bx6skf 0IaOa7GAm+NWW9j7Hsb0255RTqTHhqiyEv8GZK2KE4XOMaZjrbnT4mLXU6F5Xvw8ud UP2An1h2m8d3lwN4k9wPMscABFXWxJrkNefg9NZvLhWBeFf3gLwfuqh1nxfQfM03+7 hCkCjaGPVQWYUAXsA3X3FefyVt76VG+w7w9FbgHWC6d0Tce4UKi4DdWx/siUZ0odSV VIDKGOqOj0P3w== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown , kernel test robot Subject: [PATCH v2] arm64/sme: Fix EFI save/restore Date: Thu, 2 Jun 2022 14:41:32 +0200 Message-Id: <20220602124132.3528951-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1890; h=from:subject; bh=uCwV3zgnEsE3gfVAu+k4qrVDUV053mcpCveL0SGw54I=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBimK9X5fo6aeljEAi/ZfHMZMhJSskURnLV5DDLJ9YC DPNAY92JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYpivVwAKCRAk1otyXVSH0JiqB/ 9zElTGA0omP98Vgij1YTdMxDIcptHL1fFIRqojh4H3hlCoO3k9VdPKc5+0aXiSdZeB6ocl7tzelAyJ T/XSPugxNIp6wKEGvSfi0wl2xJWmV66sa8Tt4Lstz9DP8V0nUNdvfNbupBphpR6V01YASUzKCpRKYv u4T5XiQRkN3hxWYFHj1k8EVQRTRLI/ekjC8kIJ/k8m55HEbCXuvK70BWo5wy0eg4XEg6uBwHf/ZBlW iJNXHqwQpAros9a6xRftv0YnpnRk4jfS7r3bYet2ukyzaalLXTiVQ+MqdKakQLIaM8py9kAcWmCqF/ GxhPkWgnzdD59wshrvtbVlnj0DLnaG 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-20220602_054150_268757_4352EBDB X-CRM114-Status: GOOD ( 13.85 ) 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 The EFI save/restore code is confused. When saving the check for saving FFR is inverted due to confusion with the streaming mode check, and when restoring we check if we need to restore FFR by checking the percpu efi_sm_state without the required wrapper rather than based on the combination of FA64 support and streaming mode. Fixes: e0838f6373e5 ("arm64/sme: Save and restore streaming mode over EFI runtime calls") Reported-by: kernel test robot Reviewed-by: Catalin Marinas Signed-off-by: Mark Brown --- Still not tested, that won't happen till next week. v2: - Add comments saying when we need to save/restore FFR. arch/arm64/kernel/fpsimd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 819979398127..b93985a33bed 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1916,10 +1916,15 @@ void __efi_fpsimd_begin(void) if (system_supports_sme()) { svcr = read_sysreg_s(SYS_SVCR); - if (!system_supports_fa64()) - ffr = svcr & SVCR_SM_MASK; + __this_cpu_write(efi_sm_state, + svcr & SVCR_SM_MASK); - __this_cpu_write(efi_sm_state, ffr); + /* + * Unless we have FA64 FFR does not + * exist in streaming mode. + */ + if (!system_supports_fa64()) + ffr = !(svcr & SVCR_SM_MASK); } sve_save_state(sve_state + sve_ffr_offset(sve_max_vl()), @@ -1964,8 +1969,13 @@ void __efi_fpsimd_end(void) sysreg_clear_set_s(SYS_SVCR, 0, SVCR_SM_MASK); + + /* + * Unless we have FA64 FFR does not + * exist in streaming mode. + */ if (!system_supports_fa64()) - ffr = efi_sm_state; + ffr = false; } } -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel