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 96484C3ABC0 for ; Thu, 8 May 2025 09:32:33 +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:Message-ID:Date:From: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=W6kl3HtQJeEUM1tcBExwIbaHkyuZepPMFWQHMJDxL7Y=; b=vwMI1CobMmO3hkdIV9x8jxzp7a AUw08zyshSFr49Ln3GKsKw8vv1it88d4mHwgCBroOibPPaEUBrC/wN0SvflsrIjwpkmLOnukNYGxM y2AAZBLlaIEDgltSJI9F0obQ8F+gAsd2kgCGL7s8aSu046DfetEEmyMJ1iig28cUoZrAXR9YKtHsO R/5vRO6fNbGw+lUo8oFq7yp2gd+ECZEbF3rfbT0BzNVH8unvJCeHULKpyc2rZp/PrAZgSdrzxYxxC NL3HkmoKcAZSCleSJNqtyzTVo9aBBiplaxMV+Bw8r/C2Cutj88N1JEGng5P1XiLZbPHUULAqyUgoM DpLNHo1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uCxc7-00000000GfP-1gP4; Thu, 08 May 2025 09:32:23 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uCx25-00000000BGG-3lHV for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2025 08:55:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A56F9A4AFCE; Thu, 8 May 2025 08:55:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D6ADC4CEE7; Thu, 8 May 2025 08:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746694508; bh=UFEexb2wQ4VfbaBPjbBUtzh7EapVioSw3lWphbIeH08=; h=From:Date:To:Cc:Subject:In-Reply-To:References:From; b=n6R8bauIp46ZLLCPVuJlQfBGsEY5sBWEdFp8l3zG4jt0xPxD7q7pPOFvzRGvDXrZs seVOiPtrklHsvTgKnlyBs1Bk/ZQJQoVa+1FS6huyxtjVTIaq3sJ0828NRyOhpHRtok 4pTGj10m2fbJrYwoQw0xnMQyLIIaqeCtII8dvsqctOZtAg5BXWFkmj/hRyoosnGRKI ANDs8fsOUMhQbO2yC7fp49EkKJFn2uiEhJS1NTuqxewrwRv2qKNO+oA6jcr2Zc1ezn E2N8II9Tgi+ZPyndvtLFUnqzRX37K4cW8gDR3HdggM+jatxaDQ40iJzerTSs5xINgp GytsSqOJeRTeg== 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 1uCx21-00CwQo-UV; Thu, 08 May 2025 09:55:06 +0100 From: Marc Zyngier Date: Thu, 08 May 2025 09:55:05 +0100 Message-ID: <8634dfh47q.wl-maz@kernel.org> >From: Marc Zyngier To: Per Larsen Cc: armellel@google.com, arve@android.com, catalin.marinas@arm.com, kernel-team@android.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, qperret@google.com, sebastianene@google.com, sudeep.holla@arm.com, will@kernel.org, yuzenghui@huawei.com, Per Larsen Subject: Re: [PATCH 1/3] KVM: arm64: Restrict FF-A host version renegotiation In-Reply-To: References: <86r017h00e.wl-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/30.1 (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: perl@immunant.com, armellel@google.com, arve@android.com, catalin.marinas@arm.com, kernel-team@android.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, qperret@google.com, sebastianene@google.com, sudeep.holla@arm.com, will@kernel.org, yuzenghui@huawei.com, perlarsen@google.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-20250508_015510_067501_ED285358 X-CRM114-Status: GOOD ( 46.86 ) 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 Tue, 06 May 2025 10:29:41 +0100, Per Larsen wrote: > > From: Per Larsen > > On Fri, May 02, 2025 at 09:47:45AM +0100, Marc Zyngier wrote: > > On Fri, 02 May 2025 04:52:39 +0100, > > Per Larsen wrote: > > > > > > FF-A implementations with the same major version must interoperate with > > > earlier minor versions per DEN0077A 1.2 REL0 13.2.1 but FF-A version 1.1 > > > broke the ABI on several structures and 1.2 relies on SMCCC 1.2 is not > > > backwards compatible with SMCCC 1.2 (see DEN0028 1.6 G BET0 Appendix F). > > > > > > If we return the negotiated hypervisor version when the host requests a > > > lesser minor version, the host will rely on the FF-A interoperability > > > rules. Since the hypervisor does not currently have the necessary > > > compatibility paths (e.g. to handle breaking changes to the SMC calling > > > convention), return NOT_SUPPORTED. > > > > > > Signed-off-by: Per Larsen > > > Signed-off-by: Per Larsen > > > --- > > > arch/arm64/kvm/hyp/nvhe/ffa.c | 19 ++++++++++++++++++- > > > 1 file changed, 18 insertions(+), 1 deletion(-) > > > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c > > > index 3369dd0c4009..10e88207b78e 100644 > > > --- a/arch/arm64/kvm/hyp/nvhe/ffa.c > > > +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c > > > @@ -712,7 +712,24 @@ static void do_ffa_version(struct arm_smccc_res *res, > > > > > > hyp_spin_lock(&version_lock); > > > if (has_version_negotiated) { > > > - res->a0 = hyp_ffa_version; > > > + /* > > > + * FF-A implementations with the same major version must > > > + * interoperate with earlier minor versions per DEN0077A 1.2 > > > + * REL0 13.2.1 but FF-A version 1.1 broke the ABI on several > > > + * structures and 1.2 relies on SMCCC 1.2 is not backwards > > > + * compatible with SMCCC 1.2 (see DEN0028 1.6 G BET0 Appendix F). > > > > I can't parse this sentence. Missing words? > > > > Yes, I will fix this in v2. > > > > + * > > > + * If we return the negotiated hypervisor version when the host > > > + * requests a lesser minor version, the host will rely on the > > > + * aforementioned FF-A interoperability rules. Since the > > > + * hypervisor does not currently have the necessary compatibility > > > + * paths (e.g. to paper over the above-mentioned calling > > > + * convention changes), return NOT_SUPPORTED. > > > + */ > > > + if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_version)) > > > + res->a0 = FFA_RET_NOT_SUPPORTED; > > > + else > > > + res->a0 = hyp_ffa_version; > > > goto unlock; > > > } > > > > > > > Something has gone seriously wrong with your email, and the patches > > are badly mangled and unusable. They are also sent as individual > > patches and not as a thread, which is a sign that you didn't send them > > using git. Please fix this for your next posting. > > > > Yes, my apologies. I will use git send-email to post v2. > > > More to the meat of the patches: why should the hypervisor paper over > > anything if the spec is broken? Why can't the host just as well decide > > for itself what to do? > > > > Asssuming we drop this patch from the series and apply the rest, the > hypervisor and host can negotiate FF-A 1.2. If the host then calls > FFA_VERSION a second time to request FF-A 1.1, the hypervisor would > return version 1.2 (without this patch). Why would it do that? Once a particular version has been negotiated, I expect to be immutable. > Per the spec, that means the > host is can use the compatibility rules (DEN0077A Sec 13.2.1) to go > ahead and use FF-A 1.1 (every function in 1.A must work in a compatible > way in 1.B if B>A). I don't interpret this as "you can switch between versions" after the initial negotiation. > However, the hypervisor negotiated version stays at 1.2 so it will use > SMCCC 1.2 for 64-bit interfaces. The host has no way of knowing this and > might as well assume that the hypervisor was implemented to fall back to > SMCCC 1.1 in this particular case. > > I don't even know that the host will ever try to renegotiate as it is > explicitly not allowed by the FF-A spec. There is no way for the > hypervisor to say, "stay at the negotiated version" so we must return > NOT_SUPPORTED. If it is not allowed, why should we do *anything*? And if the host is broken, let's fix the host rather than adding pointless validation code to EL2. Thanks, M. -- Without deviation from the norm, progress is not possible.