From mboxrd@z Thu Jan 1 00:00:00 1970 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 C84B3C02198 for ; Mon, 10 Feb 2025 11:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=T5qFZ/fdam81H3QSgIAXLfc5ZRIkN5R7MNYzd5LYyts=; b=JbBgmz4dSyWK7hwf3lhLZQ1X+e rEv9VEd6DP3S8oI1qRfb1oMy3obIqFDssUSN/w90ZypUXc7xENU2Nf2I9Lg9sCWqKXVqHvubgIeUm 2hqywU4OHT78iBlGQDEzhTv6TZq9n1NPQRR61lntw6GGUYYBL+5MAKdrTp4m2DhJ0cda8jCRydt7X OT3nugS1BweuDS8zZl5L99AaZGLQixjvrBpZI6bOr1OJ+fiZsFZjD/sdlp47PHyqLj80q0BK+35lO 9HCY4FdXkaWzZ0cK8vLyWJi0rKha9bqU8kHyRHx+K82xjHqyrioZdKDFBqjOl8MqiGcLFgWx+MoSb O2DFW0tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1thRc9-0000000H92F-0AjG; Mon, 10 Feb 2025 11:06:09 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1thRPU-0000000H5pI-01M6 for linux-arm-kernel@lists.infradead.org; Mon, 10 Feb 2025 10:53:05 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DBBC85C0384; Mon, 10 Feb 2025 10:52:23 +0000 (UTC) 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250210_025304_129329_75DB2B48 X-CRM114-Status: GOOD ( 33.21 ) 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 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.