Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp361406lqb; Tue, 4 Jun 2024 13:42:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvPBiYMp8LWAUshNbS9rrNWdYwRf/pufc5pPoLHfMxohFLKiBmKBI9boSJfAcByNtWfVSXQFem5AGJ1PerIrRAby9CWa58iCjzqnReUg== X-Google-Smtp-Source: AGHT+IHwmutDszI0YKWCu5z+KLMkMvO9kBaAHUZ+M2veAj1K6u1fjL3GuZjCns9DZWINp+NubM6j X-Received: by 2002:a50:9b03:0:b0:572:cfa4:3ccb with SMTP id 4fb4d7f45d1cf-57a8b673eb8mr419723a12.8.1717533765812; Tue, 04 Jun 2024 13:42:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717533765; cv=pass; d=google.com; s=arc-20160816; b=Cpx9ztK3HsIU/Ryr97lxv6Pt0ebmadZiF1MRKPrBQnhAd5RTzLISvYiNVoj1LXSgt9 I45T8hit9XeFUNhgap+A/EMtPYiDE+UTEP2EODR0dFOuPU+SeMTJGQv2/1A4xlVzjLgH PjVrCKhNHDNeVXtwbQ7/g0emNGg1geIE2/Jg0dQmYhBylHGltTwpp0m0PvYzIgK45+N9 cLhrsSMInwzW9SUBWtUji1Hlz+gjmAvVQx2+6QE7ZuEOV7SDZkiRhj4BJSHT6LckPf2D c8YldvaE42q1d60XUZmE40Z9SgyNQwIOr67ArWO8OZgCD22BGikABf8NgHTRmeGsAFoA R7tw== 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=EGm1RnlMSE2ykV6QTyTCvcF76GMzhbqbniHLvj/dO0s=; fh=ORmtW8DBk0nea1FwkCB0oUTGfdH7/8R+w7LAvvpntHE=; b=LQf8uDBgEiJAa5avl1GyNcVfuRdkZykXNgruf7mbSUMLfNlvGds1295W5ToS28I74B C8q6oMtgJ+kzFEeiLejl8zDcAEeCJokwuV1SEZQFgR2TDJkK/R7i53vEhye7NuBY5F8V bhIE6B+1fc+CyzgUZGQmA+xwVYtG2gsXoe5Do0gHv4QfcC/SxH+J7enNXaX+RWYmAm4N 6ICeNniR1wBtSztPq9x1TcgCis94RzYU5TAFV86mILxWMBokpe2+WWfnPfxoE4JP86eW ERj7aKf8rUyR4YTQMsaxeWO3eAG0Rk7dWPBYNYVism+QBRT4b/0jk4imGB9U7QgRO3ES Ov4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYUkD4Us; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201357-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201357-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ccad5bsi5349029a12.660.2024.06.04.13.42.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 13:42:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201357-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYUkD4Us; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201357-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201357-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 892201F26153 for ; Tue, 4 Jun 2024 20:42:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E38E14B972; Tue, 4 Jun 2024 20:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OYUkD4Us" 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 755E717C96; Tue, 4 Jun 2024 20:42:37 +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=1717533757; cv=none; b=n/ebQ5E5Mau9bzSfr3esnRfro+PWm9JBB9QltVHY03M2cVF4cSh8FX9cU3Rnz16hhfQx1oj84bxi8qZz8h9SxwGhdHtYLKLNRZ//kp1xxj5nhNVI88+/L4szJ13gJql+oUkgJECfWVcrmmaB3cXvhbN2hlnuCTQ4chN115JOzwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717533757; c=relaxed/simple; bh=uQLOOzbWqSKTADuADTiMo4MekQ86BWWGFWy1aSoS7xQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Yr0bD/FfU6jjjjdROtDYe3TBYG17JQ+c6p7isdwRWPmRe8L+8751C+Zj3VBF/jNhASsud1W9CfGHMpy4eO2AtRvP4DtmnyQKmypO1RGk9/uoGzOZQMK83vjJE4wzOEAeYeQn2Eo3u/PfN5MUYDY+GYjxoBj78h8/R0Ae/oowJhQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OYUkD4Us; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA435C2BBFC; Tue, 4 Jun 2024 20:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717533757; bh=uQLOOzbWqSKTADuADTiMo4MekQ86BWWGFWy1aSoS7xQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OYUkD4Usqn60C9R0lp44HfgE+h1mDo/yoEBsBIJcUlLvoY5rom3AxalWO2O5Eqo5Z 5ZJnN4EKNnZvEklMlJhgclPLHS4aGSSJJAE/U6sNUUG0CYnaO+P7pqeHAuPHhZhEwx nCeZepAhMjTgd5a3yBV7XYXk9R3U02rzSm90Q2QSdKmb0Ls4HocmtluAF/AEjbdRR/ zwWif3NWxk+ZQMRLo0YZgWblL/TBYEbbU23hT1AyeBOcYKGY/SEVp8wuwln5udszDN 8z+Z/jZJuA4ndvxwPaBuhcqvn3QtWBNreVmC9gtC2cAd2x/QB8AI9vvC94Q7BFEXyX YbAoTwaE8h/Vw== Date: Tue, 4 Jun 2024 21:42:31 +0100 From: Mark Brown To: Oliver Upton Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Fix confusion in documentation for pKVM SME assert Message-ID: <97fab321-21fb-40cd-b90e-daf42b5db62e@sirena.org.uk> References: <20240604-kvm-arm64-sme-assert-v1-1-5d98348d00f8@kernel.org> 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="OssUhU3cRSMRch4o" Content-Disposition: inline In-Reply-To: X-Cookie: Is it clean in other dimensions? --OssUhU3cRSMRch4o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jun 04, 2024 at 12:17:41PM -0700, Oliver Upton wrote: > On Tue, Jun 04, 2024 at 07:47:01PM +0100, Mark Brown wrote: > > As raised in the review comments for the original patch the assert and > > comment added in afb91f5f8ad7 ("KVM: arm64: Ensure that SME controls are > > disabled in protected mode") are bogus. The comments says that we check > > that we do not have SME enabled for a pKVM guest but the assert actually > > checks to see if the host has anything set in SVCR which is unrelated to > > the guest features or state, regardless of if those guests are protected > > or not. > > What I believe the check is actually intended to validate is that we do > > not enter the pKVM hypervisor with SME enabled since the pKVM hypervisor > > does not yet understand SME and is therefore unable to save or restore > > host state with SME enabled, indeed attempting to save SVE state would > > fault if streaming mode is enabled on a system without FA64 due to FFR. > > Update the comment to reflect this. > The added context likely isn't necessary in what winds up getting > applied. Can this just directly state the WARN_ON() exists b/c the > protected mode hypervisor doesn't know how to manage SME state? It could definitely be briefer, I was being super detailed because I was guessing between the intent being what the comment says or what the code says, or if we want an assert here at all for that matter. It seemed better to be verbose. > > WARN_ON(is_protected_kvm_enabled() && system_supports_sme() && > > read_sysreg_s(SYS_SVCR)); > While we're here, this should be WARN_ON_ONCE() or WARN_RATELIMIT() if > we _really_ want some spam. But a single WARN ought to be enough. Good point, and I agree that WARN_ON_ONCE is the better option. > It'd be a good idea to also document why we're testing for SME state > twice on the KVM_RUN path, as any WARN() in the hyp code is currently > fatal. I'm guessing Fuad meant to have a non-fatal way of getting some > debug information out. Yes, this was one of the reasons I was unclear if the check or the comment was the intention. Possibly it's due to getting much better diagnostics for a warning generated in the host kernel than an error returned from the hypervisor when we try to run the guest? --OssUhU3cRSMRch4o Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmZffDcACgkQJNaLcl1U h9DSkQf8CCVg3xupmEhXxr52ob2JwQvQsUfHWim7KvttAq/EtITOJlK3tovzZyv1 cIVLi8HGI0tgfLFUL5GEXj14V47etBLAWBJrMJWYTS6830EWjAr5nPKk3tMkDlke 9PpdWP4rKZcpD1G6Lw4MUobCOE1tkrLq9AI/y9ZNidpF9iGkB0+gr2NZWZk0uikR hoZ06Dr3pNLzFVzBBehURrPVvWIk1ZaZnCQX/XlKrpAItMEiaNn1rNnStzC6hzbe K0ap59Tu6icxcgRHjzAVTU8eRKhKa2+0pT95RFZWaJFfFnpkgeUvq61shLeV18Mo ICb6001h8LqRoHRV44uEYU9fudLyag== =r54Z -----END PGP SIGNATURE----- --OssUhU3cRSMRch4o--