Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1031024rdb; Tue, 30 Jan 2024 06:09:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmasV1masitxOmXoonVV6+nxmAAE9KDYmWwKWr8YzWYzW4RcVIeQaxyLDcN2VsT9/A5wTn X-Received: by 2002:a05:620a:4d2:b0:783:e9ba:7d33 with SMTP id 18-20020a05620a04d200b00783e9ba7d33mr6527681qks.60.1706623786009; Tue, 30 Jan 2024 06:09:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706623785; cv=pass; d=google.com; s=arc-20160816; b=1G6PIfHXXPCSkGQYyGXSwYkI7QCb4Fjp/BycBmevZOZc5nueTjfIetQ+CXl4aRq3Mb OoCz4qDFrfY/DDJ7jocev3HPE6igHA/t50ZO6eYvGbqYnfdEiod7eQXmd/3ZjHNcR6D4 sGb9Cpzp2WvEShO4bvADlsO3XkrZocUQcsWK/OuYGhpt0kleElOH4eGIkhaw6/2uJLyd FqTO75y4IaZpp1dlFhCJcACq6CVbR9k+IfmT0CUiWqlPSpUsBXOhrHNP1q76nm2D46Xc s+kp1voThtRd9k6nKjfG0MT0JE4m9T9VUY5wd+1GQArzgZD8LKIP0XmBFYx71j3FX/om tQkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cTtHG2jpiyCa/YwSqZT9ctRk+mMrb2Cat8ShVND6HYI=; fh=dpfMQzPaKaRzEhJ7aUqrYCqGzirsTuE7UNoPwDGIj/g=; b=imV8sWlNt4PTbQJpwbrKmGuU/E5bCgZ5yHFRYjEf4zd4FxdIvqm8mK/0a4aux46wIl 25+9NounnODdGMq0NiRfCYyPVORyOveMssOWTJ941q2qwqDsPrhndMXdm6340ulwwzkX bTJlA3Yn19arqzjgswCy5ze0vvszUOwVd/W93z0g3Mj7byccJGOMqCmtl6DFeu7Z3N53 HWz7AXTerMUpUk3NBuNfRG673DlFQgdKEKBVdXFqMOEPa1LgwsAl/yXjdDVpKJFggLvu eSKJlny5JEEGD3HptT7Bk6Svn8rrYMkj1D/ihDYUqu8UuTZm/tB0VlQDbFHG3wyW0Nzl 8QvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lQNym423; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-44731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j23-20020ae9c217000000b007830ac5d3f0si10129026qkg.438.2024.01.30.06.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 06:09:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lQNym423; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-44731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A6F811C24170 for ; Tue, 30 Jan 2024 14:09:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6490421105; Tue, 30 Jan 2024 14:09:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lQNym423" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87CD86D1BC; Tue, 30 Jan 2024 14:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706623778; cv=none; b=iLkZFOKqS2KqIFGldMUT5Yk4VoX/biKxvQEIEzmZ9reGxv255SEC5U811Y7BZdxxtpAr5MGOgrOGYGxJOX9ksQHxIOTV2nIShu91LD62hG/yJydkCTRrrNa+6ZE/GBuaLjrst71mBGV2TAtqTb1zQN5CxKcSRo8kW6dxI4gxKww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706623778; c=relaxed/simple; bh=HTB7rybbrmbLBHLUmBY3wflc1iO/bGggajnCBCZ837A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l5ABP7YH8zJZ61IWx8hOW6We3UjZzoK+MdJMPT7+gFtPHuBluZG3qMW6Do5OZgQnBEP2MtZIWsrTmLJoZE3SfysY2rmL6fiv8oF8nuuK1psAG0000qbsAN4R5NNULmlDUiVQ3we+2gjb6Zbl1xa4TibzCYnM7AKIRB3bDP0OHvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lQNym423; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06E09C433F1; Tue, 30 Jan 2024 14:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706623778; bh=HTB7rybbrmbLBHLUmBY3wflc1iO/bGggajnCBCZ837A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lQNym423x0kFxEl0MW3XhtBx7QDJJ5CHG5jvHw0Flo0cVYOBwwfgcmF3nV8HPFRvG XSZT/Aq72o9Qh92ICo0aMrIUZ1YMIaGlNomY6F3QMPQRQ0GLiEQa2MGgSd2Th7kaPY s1Xr5td2sIOY8TQjFArxHam5BnqTMYITDjpOA+owhOSJtRPWamC/smU/Cti6IhUvSA Eg8SVqNZkw5BcDyB74LVjOMhy5JI/MYstSJkGCEjb5TRnZBE30NgbWSB2RaNdV9B9L tKsPW2OjS+dBsLOZBIaC5nWsb6Gm8JEA1WJB/oYh8Q2LfwjLDC+sy0PHON5fn1fkIh AntSKyLFcct7A== Date: Tue, 30 Jan 2024 14:09:34 +0000 From: Mark Brown To: Will Deacon Cc: Catalin Marinas , Dave Martin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved SVE state Message-ID: References: <20240119-arm64-sve-signal-regs-v1-1-b9fd61b0289a@kernel.org> <20240130115107.GB13551@willie-the-truck> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="uWPAAXNST8xADQkB" Content-Disposition: inline In-Reply-To: <20240130115107.GB13551@willie-the-truck> X-Cookie: 1 bulls, 3 cows. --uWPAAXNST8xADQkB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 30, 2024 at 11:51:07AM +0000, Will Deacon wrote: > On Fri, Jan 19, 2024 at 12:29:13PM +0000, Mark Brown wrote: > > - if (test_thread_flag(TIF_SVE)) > > + if (current->thread.fp_type == FP_STATE_SVE) > > sve_to_fpsimd(current); > > } > I don't think this hunk applies on -rc2 ^^. Hrm, git seemed to figure out a rebase with no intervention - I've thrown it at my CI and will resend assuming no changes from the rest of the discussion. > > - if (add_all || test_thread_flag(TIF_SVE) || > > + if (add_all || current->thread.fp_type == FP_STATE_SVE || > > thread_sm_enabled(¤t->thread)) { > > int vl = max(sve_max_vl(), sme_max_vl()); > I think this code is preemptible, so I'm struggling to understand what > happens if the fp_type changes under our feet as a result of a context > switch. We are relying here on having forced a flush of the floating point register state prior to this code running, simple preemption won't change the state from what was already saved. The same consideration also applies to the check for streaming mode here. That said if this is preempted ptrace *could* come in and rewrite the data or at worst change the vector length (which could leave us with sve_state deallocated or a different size, possibly while we're in the middle of accessing it). This could also happen with the existing check for TIF_SVE so I don't think there's anything new here - AFAICT this has always been an issue with the vector code, unless I'm missing some bigger thing which excludes ptrace. I think any change that's needed there won't overlap with this one, I'm looking. --uWPAAXNST8xADQkB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmW5Ax0ACgkQJNaLcl1U h9CV/Qf+M+B80WOMZNgHU9dCZZG69Aykjj55IozuDVFkd5exazmMfTEW34Ojr6Ab Oqj5DCHsru08tlJPGg1fgUKbx/g2vRP/rwLathQOZVwHKomcbc9P56EzHduVn43a fXecMSex+3LDm85+En5p2pCDrDyHEthdHdLALVM1QhEVbKGtsV/UpAH8OmQaPL7m L6fMUh8qdP8gRZSFyXfCRhJDbmAy1Y2wVxiX1wAuee2UcFF0e8h6W8zamC6h9Lf7 PlwmVqT3NKan89/f61Fhckh//vw6/B9y/MFTthhCUz9W8m07AZ27xqd+ZNsF1Vsm i/eugtrfijoSaHKnYWMVE8ZuILjNzA== =7Na8 -----END PGP SIGNATURE----- --uWPAAXNST8xADQkB--