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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FCADC433EF for ; Mon, 6 Jun 2022 11:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbiFFL2h (ORCPT ); Mon, 6 Jun 2022 07:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235313AbiFFL2g (ORCPT ); Mon, 6 Jun 2022 07:28:36 -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 158711C285B; Mon, 6 Jun 2022 04:28:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A416D60F68; Mon, 6 Jun 2022 11:28:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D41CC3411C; Mon, 6 Jun 2022 11:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654514915; bh=HSh91ZCaHITLmr5CLlS3fmJvhr48sqOQOlQ7C/p/ovo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dvw7wTF9FyzkRSe9OpuincqtO0+GGsyTHD5SbKOeaWsNUQyeZ15YjhoTxtE4AatCq L2+C6gDa633fgc7vNN+YB0tIepMpmuhGOYRRyCMahqmUpg8lfuuUjsMeTHFrA6JICu OWNLqx1dN2+0fmV5uw4cDRFpQmD1csMI1WXJ+kUTo+2piteHQT1sCfMcAMI+8B7tPU oYYazMeoJlXQKF2G5jjj+fA7FSgn37rwXzqEfC72bKimq5zAYmJsua2WwZtFlq22KN CYI0iebzkXuRpZ/Wy8RTk368AS72nhWmVIzQL+hiukbdfK8w2WCDQyLtDJaa1hPSep G4mWSMNmm99dg== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nyAuO-00Fsyh-Ha; Mon, 06 Jun 2022 12:28:32 +0100 Date: Mon, 06 Jun 2022 12:28:32 +0100 Message-ID: <87y1ya3uan.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Alexandru Elisei , Oliver Upton , Will Deacon , Fuad Tabba , Quentin Perret , kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH 01/18] KVM: arm64: Always start with clearing SVE flag on load In-Reply-To: References: <20220528113829.1043361-1-maz@kernel.org> <20220528113829.1043361-2-maz@kernel.org> 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/27.1 (x86_64-pc-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: broonie@kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, oupton@google.com, will@kernel.org, tabba@google.com, qperret@google.com, kernel-team@android.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, 30 May 2022 15:41:54 +0100, Mark Brown wrote: > > [1 ] > On Sat, May 28, 2022 at 12:38:11PM +0100, Marc Zyngier wrote: > > On each vcpu load, we set the KVM_ARM64_HOST_SVE_ENABLED > > flag if SVE is enabled for EL0 on the host. This is used to restore > > the correct state on vpcu put. > > > > However, it appears that nothing ever clears this flag. Once > > set, it will stick until the vcpu is destroyed, which has the > > potential to spuriously enable SVE for userspace. > > Oh dear. > > Reviewed-by: Mark Brown > > > We probably never saw the issue because no VMM uses SVE, but > > that's still pretty bad. Unconditionally clearing the flag > > on vcpu load addresses the issue. > > Unless I'm missing something since we currently always disable > SVE on syscall even if the VMM were using SVE for some reason > (SVE memcpy()?) we should already have disabled SVE for EL0 in > sve_user_discard() during kernel entry so EL0 access to SVE > should be disabled in the system register by the time we get > here. Indeed. And this begs the question: what is this code actually doing? Is there any way we can end-up running a guest with any valid host SVE state? I remember being >this< close to removing that code some time ago, and only stopped because I vaguely remembered Dave Martin convincing me at some point that it was necessary. I'm unable to piece the argument together again though. M. -- Without deviation from the norm, progress is not possible.