From patchwork Thu Aug 3 18:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13340746 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 13016EB64DD for ; Thu, 3 Aug 2023 18:43:27 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X0FxTidUWkKOBaNFrbFE1sHBAvfIqO+WFrpOrdC+lzM=; b=1RBYJm6EgszCg+ 8Wr0n/+EL1IX9dDk/mbueHRvI9LeU4lFZRG/ThuxYVAXozmTDgRKCFdbG8mww66vYT7Wu7x4YnoTs ZBF4ukQig+C9qBh7NDunEIdv8xr1JJmJ4tIhbiAh4i/iui67yomzz1bgACZZ4YbthvYS7FlY5WQo1 x4XUzKL7gd3v8y7i5dzDID5qPkNKuBZwtWX9aZ1/HeiSGX1Y5E0qnVK7GDI76KeUfDT6Q51OHpWVt ScyXhOU1y1PomRPNYs+LCr6kRlQ76NqNKaDcT/wVqp2bxYYvVRJsjIdOyIEJnkYTphgqum26SePUv 55pezc2oIgs2nrVYNuIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRdHs-00AeG8-1R; Thu, 03 Aug 2023 18:43:04 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRdHA-00AdRK-36 for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 18:42:22 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33B7561E7D; Thu, 3 Aug 2023 18:42:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D220BC433C9; Thu, 3 Aug 2023 18:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691088139; bh=Q6O8ubzpvyVkC7Ej05HHTMDmMzaSvsK+JutbFIX5e0s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kbZKyYeaOPPCdZwv7ubKCh30NYJEYWQwYEs4BlcmwX/AG14B7B6ct/NmSi0zbpqsx OVyotPmnROQN6BVOA3z8VZId3WESsSfGApoeqc+H7yJ/sHo5AiFx9k5QeyRfZt+EyF hlGi0RfK8daFyAL1olp5gPwXJavKRZ5KPaT451qbPWWSjaV37nLiMluN3KQojMhAQg ZCIgjjxr1vO+6suD9s6qPMcql75EfBIgE2Z+8/QjiuNUiU99XryURAkW1R200TDTaT pf91yjzszWJCzttRb+YnST1bQtYopbzyfT4MXlXvEloW8Ja3GM6hl/FpYVgaz6te20 AdlVJ3tGizmlA== From: Mark Brown Date: Thu, 03 Aug 2023 19:33:21 +0100 Subject: [PATCH 1/3] arm64/ptrace: Don't enable SVE when setting streaming SVE MIME-Version: 1.0 Message-Id: <20230803-arm64-fix-ptrace-ssve-no-sve-v1-1-49df214bfb3e@kernel.org> References: <20230803-arm64-fix-ptrace-ssve-no-sve-v1-0-49df214bfb3e@kernel.org> In-Reply-To: <20230803-arm64-fix-ptrace-ssve-no-sve-v1-0-49df214bfb3e@kernel.org> To: Oleg Nesterov , Catalin Marinas , Will Deacon Cc: David Spickett , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown , stable@vger.kernel.org X-Mailer: b4 0.13-dev-034f2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2249; i=broonie@kernel.org; h=from:subject:message-id; bh=Q6O8ubzpvyVkC7Ej05HHTMDmMzaSvsK+JutbFIX5e0s=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBky/UEmwKiFjTRvpTlHWMHkQ3ykgHly+u9CiYxdtUF dR5Ms1GJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZMv1BAAKCRAk1otyXVSH0FFnB/ oDTbLZARptJWnKqqaplgnHepLKSsvOpQBNaEbXDpncgv2gLndEkIFNdsoOtoTlVUZ913ZFKFS47HsY rnG7oslf0LQHCR9yaGudN08M//nV399/8H6ScITDlRnBzZ10LSiPQDTlO6GQuChG5hGYRCpxXIjAqA aT4TQHHiEuesDQhMN0TkwVvc6qcVCZY/dtUvtE3k7yrs7REHhQgaWtaBAxBWO9VGiKVFUjq3bPohsW xu28lbFnYprLSi0sWEdIya02W/YR+7lzsVcwqXyr44JRusdNUDN6j0/WbgTgjrMpeRAmkkYOeAwy7H V7tFlkiySYs7gDWDM3uzOHoPVxHjNu 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-20230803_114221_137165_B762F64E X-CRM114-Status: GOOD ( 16.55 ) 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 Systems which implement SME without also implementing SVE are architecturally valid but were not initially supported by the kernel, unfortunately we missed one issue in the ptrace code. The SVE register setting code is shared between SVE and streaming mode SVE. When we set full SVE register state we currently enable TIF_SVE unconditionally, in the case where streaming SVE is being configured on a system that supports vanilla SVE this is not an issue since we always initialise enough state for both vector lengths but on a system which only support SME it will result in us attempting to restore the SVE vector length after having set streaming SVE registers. Fix this by making the enabling of SVE conditional on setting SVE vector state. If we set streaming SVE state and SVE was not already enabled this will result in a SVE access trap on next use of normal SVE, this will cause us to flush our register state but this is fine since the only way to trigger a SVE access trap would be to exit streaming mode which will cause the in register state to be flushed anyway. Fixes: e12310a0d30 ("arm64/sme: Implement ptrace support for streaming mode SVE registers") Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- arch/arm64/kernel/ptrace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index d7f4f0d1ae12..8a85dcc66597 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -932,11 +932,13 @@ static int sve_set_common(struct task_struct *target, /* * Ensure target->thread.sve_state is up to date with target's * FPSIMD regs, so that a short copyin leaves trailing - * registers unmodified. Always enable SVE even if going into - * streaming mode. + * registers unmodified. Only enable SVE if we are + * configuring normal SVE, a system with streaming SVE may not + * have normal SVE. */ fpsimd_sync_to_sve(target); - set_tsk_thread_flag(target, TIF_SVE); + if (type == ARM64_VEC_SVE) + set_tsk_thread_flag(target, TIF_SVE); target->thread.fp_type = FP_STATE_SVE; BUILD_BUG_ON(SVE_PT_SVE_OFFSET != sizeof(header));