Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2655360rwo; Thu, 3 Aug 2023 12:45:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlEg3JL96bZwuDe7lwj+EvuRKx3JTWOac86GN32o5PEUJuZkhNYOInYLCoRwLKVYSICrzlj5 X-Received: by 2002:a17:906:217:b0:99b:eecb:275b with SMTP id 23-20020a170906021700b0099beecb275bmr7848695ejd.19.1691091901086; Thu, 03 Aug 2023 12:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691091901; cv=none; d=google.com; s=arc-20160816; b=VspP5q1J+XlcqAWlgbaatCR0e7WkXZ265vTgIqZLGkKSDoUnpoEJknw9m6LAygKMyZ CbjW6GNozlCLGjP3nZlxRcoBx6IWsNyNyr459kK3NSBrBLI+zDeqYfNqkB3kBoRnk4AQ slie5KISgE/Mz1k5wWQ8KkeXKvpqqQh1UehL3LvymRF8oxLidsouon8bWMZpCLkayz7/ XrMl3NtTIah7b3T9T8e7O4h2naBBl/rzGcKEzhGgvvnBLC8GUGLgb1V+nG00q5vOJUrY hUzab7mxW/9eTOnlfSq2jVYj+MIqzSJ7/fCS5RgH4D2duN9muWcl3na9HAT3H0udhmwQ +bQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=HdaNpJZtd6cO8r1Py4Gy0b0c1PGcCQ+j1tVLlmOIZgc=; fh=y1YNzMTa0VBjj3s8pV4LY81EkGsSKa5rhSScGuGiy5w=; b=h3Ohhp4JROtFPevtMvRzh7V3cG11d4OQYu/HsNaQLLa90VRnDBKISRRY93lPpHN23i gDx/RnAMZIlQiz3DBZH3urUsfxpLrhJMZE+Yx9FYSyf6ygQZdLPNK8V0YPX8l0FXuDC3 nUiIfUkgpGd0hIGAfv7osfCIuKYQYG/xlyKuyrPn0barT2FXiyiIsn173ZCExkai7x8C pq6woXF0kRXUMARbr0uDiad5VRYn5Ja9FpWFh449wG6QJz3hv15TSWXrPa/BiIMY3jrm K28/t2/zb4+iXTP0EQAY6V3zUKOr+iN/owNwEH/Ita15xsiJNAb2EkpHgUF6aeup+WE/ tf2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kbZKyYea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hh19-20020a170906a95300b0099bcc0b48e4si335937ejb.229.2023.08.03.12.44.35; Thu, 03 Aug 2023 12:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kbZKyYea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232320AbjHCSo5 (ORCPT + 99 others); Thu, 3 Aug 2023 14:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234401AbjHCSop (ORCPT ); Thu, 3 Aug 2023 14:44:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A5E2D71; Thu, 3 Aug 2023 11:44:10 -0700 (PDT) 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 2FADD61D5F; 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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)); -- 2.30.2