From mboxrd@z Thu Jan 1 00:00:00 1970 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 B6D091CF284 for ; Mon, 10 Feb 2025 10:53:03 +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=1739184783; cv=none; b=k0o+9Jo+3aTk2ibuO4RNrZ8VVPSdXaZVHmgnxB2VliMqBJXH0zW5xIEaTkDx4YC1fludBhK6E95kdyqMjsPPNQUY8TvzWA06nXbWArfnmAknnr7o8Sgq+3AXVjDihwC7XIiHSNZwx3hOHZhOR3uplT5tlANH2qfxS7X8BEuMYv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739184783; c=relaxed/simple; bh=vgTPE3xe46V2x7gdz7fa9olKRfCjrvhdK4blayLK5PY=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=PdG+tJrC0O+i1uDTzpnRXfZvhPkBbvvxIsGgxfqWfiwp2mu/BDil0es1lj3E7pimmXx14zPEpYKpUYqHnlaFKFBG+++hJuImNx10wP72gWq62JDREahG2QXwsWffrCCDsLHCI7SX6EdfYfGDXgvq7gS4gJA/UnjC0Utm1vWIo0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KchrQEqe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KchrQEqe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F8F2C4CEE4; Mon, 10 Feb 2025 10:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739184783; bh=vgTPE3xe46V2x7gdz7fa9olKRfCjrvhdK4blayLK5PY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KchrQEqezA5QGPzloKV80L0+UL1QJMyW4sL20PSTV76V6wiRstbZWePRB7YIY5/uF +qIPiIl8/vSX85V29qAENTivUog4zhF42Hu5Yrl4OZJgULiDtZha1EsNhMBHu+l6Uy gfO4odDj1CCezpxwX7bbrLfaSze/ObInfM9VycbSPwViSEg6cQuQDQ2pcdtoQ4VXav uuEos/JwhlkTrYHq2OFv7wLF6p3UMZqqz32UD2QRIXUVrnjUYw8gnb3rI6d63XoFYP BTIU2DCGGUQGyNTvz39LUCN0DHJXBeUBEv8dTvBzjoL1MBhAqSmW7I7gDBymvaUQ84 fhBSCI7nV2bcg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1thRPQ-002Vh5-Rp; Mon, 10 Feb 2025 10:53:01 +0000 Date: Mon, 10 Feb 2025 10:53:00 +0000 Message-ID: <865xlit6k3.wl-maz@kernel.org> From: Marc Zyngier To: Mark Rutland Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, broonie@kernel.org, catalin.marinas@arm.com, eauger@redhat.com, eric.auger@redhat.com, fweimer@redhat.com, jeremy.linton@arm.com, oliver.upton@linux.dev, pbonzini@redhat.com, stable@vger.kernel.org, tabba@google.com, wilco.dijkstra@arm.com Subject: Re: [PATCH v2 1/8] KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state In-Reply-To: References: <20250206141102.954688-1-mark.rutland@arm.com> <20250206141102.954688-2-mark.rutland@arm.com> <20250207122748.GA4839@willie-the-truck> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mark.rutland@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, broonie@kernel.org, catalin.marinas@arm.com, eauger@redhat.com, eric.auger@redhat.com, fweimer@redhat.com, jeremy.linton@arm.com, oliver.upton@linux.dev, pbonzini@redhat.com, stable@vger.kernel.org, tabba@google.com, wilco.dijkstra@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 07 Feb 2025 13:21:44 +0000, Mark Rutland wrote: > > On Fri, Feb 07, 2025 at 12:27:51PM +0000, Will Deacon wrote: > > On Thu, Feb 06, 2025 at 02:10:55PM +0000, Mark Rutland wrote: > > > There are several problems with the way hyp code lazily saves the host's > > > FPSIMD/SVE state, including: > > > > > > * Host SVE being discarded unexpectedly due to inconsistent > > > configuration of TIF_SVE and CPACR_ELx.ZEN. This has been seen to > > > result in QEMU crashes where SVE is used by memmove(), as reported by > > > Eric Auger: > > > > > > https://issues.redhat.com/browse/RHEL-68997 > > > > > > * Host SVE state is discarded *after* modification by ptrace, which was an > > > unintentional ptrace ABI change introduced with lazy discarding of SVE state. > > > > > > * The host FPMR value can be discarded when running a non-protected VM, > > > where FPMR support is not exposed to a VM, and that VM uses > > > FPSIMD/SVE. In these cases the hyp code does not save the host's FPMR > > > before unbinding the host's FPSIMD/SVE/SME state, leaving a stale > > > value in memory. > > > > How hard would it be to write tests for these three scenarios? If we > > had something to exercise the relevant paths then... > > > > > ... and so this eager save+flush probably needs to be backported to ALL > > > stable trees. > > > > ... this backporting might be a little easier to be sure about? > > For the first case I have a quick and dirty test, which I've pushed to > my arm64/kvm/fpsimd-tests branch in my kernel.org repo: > > https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/ > git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git > > For the last case it should be possible to do something similar, but I > hadn't had the time to dig in to the KVM selftests infrastructure and > figure out how to confiugre the guest appropriately. > > For the ptrace case, the same symptoms can be provoked outside of KVM > (and I'm currently working to fix that). From my PoV the important thing > is that this fix happens to remove KVM from the set of cases the other > fixes need to care about. > > FWIW I was assuming that I'd be handling the upstream backports, and I'd > be testing with the test above and some additional assertions hacked > into the kernel for testing. I agree that having the tests around would be great, if only to catch potential repressions. However, I really don't want to gate the fixes on these tests. So unless someone shouts, I intend to take this series in very shortly. We can always merge the tests as a subsequent improvement. Thanks, M. -- Without deviation from the norm, progress is not possible.