From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1172E3E3C73 for ; Fri, 26 Jun 2026 07:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782460132; cv=none; b=WTin+o+AI/2M6s0UTTdeoQ+SQJFtOYrHRNqUGYpj7CQ/q1gRFun0qbCKdbkLc8blQ9QPeucKa/dT1YVNKj3xPEcRbcC57zBd24BQn475+7UZ0xUZWG4sqWC0F8XGDQQUZgJGVetWHbuFE6cOsTwitAgytFdBhu0ONu2p+W92jNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782460132; c=relaxed/simple; bh=+eNgUr5YUqNfYwGiirS2Nnl3zVmfu1/bLUCX16l3Okg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qp/Wcrsiv1L78IS+mjyaE3u3xisnFgUR+WMUEGOelY4vJWcWybNfbDNZEufucuVtTQrFzgLCB7rAHWyaFXlZJjvyaj9+8AFhVOyjuhT28TRKauXE9MRk2Ef0SRqWkdy2V154UNqRerWs3fgvvHMnqzfi5P69t1SQAq+ka86ypbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fBOtbHrz; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fBOtbHrz" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49245a7a018so30955e9.1 for ; Fri, 26 Jun 2026 00:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782460129; x=1783064929; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=sviuXWEudL4Lc2OsPUzpYG5n9t6uIjHNaWvGJZaU1Ew=; b=fBOtbHrzAjJmvxrS8lu94UYQVTxLzLcWsrliPYb/j+/Q/rbifgB1y446MZhWoH+JyT BIaqgGrd+iOR0v1tp9hlI734kyggO/NULXAgfXZduH+gymOv/NiwlL34l5HyIM3PSXdt d7N66Vzw1Xz6vgsrOq3j1vu9rowyW5UgaceQaejdoU6e/3eblUjLRSjCqLYVFW0wh0DJ O4pKBSCVtVgBLG6ujmBH8MK/Id4o/SMPYUty0SMjy0pi+JdNN+o6Gbbk1p1yei1NKlhU ur1jrvF0rKuHC2cSAAGdmeSz7xSosANYhO9ma0elSLVTJujhBS4OGpYuDqASKKW+Xf54 41nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782460129; x=1783064929; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=sviuXWEudL4Lc2OsPUzpYG5n9t6uIjHNaWvGJZaU1Ew=; b=WsvN/ecHhwjFOafxJMGC0J1ADbR2p0P+hrJbZrMgrsI9x4J6XoFQ/0AEUJj1bfOjKV ZrZWORUONynXECYIQYVzA5a3MnkPc0RxTvVzd4kBfO4bpwaGraVrlW/zOHFVShPk7Aza 0MqlcNrDrw25psVsclu6iNLN3zMi4nc+dnz1DDZFfDoFnbd2lf7NewsjJUS/PFuNhMMb NsoIDfz58G5sdzU8LCXqjh+b5+gkQjCfn41MFgpXDSGaPZ6+bMBCkbZQPn1QVDMbYuRR VproerxXikmukpRorDLytTPI1pHk4exKPYHcH3dvQS5WsPk7N1iHG0zBG0Fe4nU3YaWB 9FTA== X-Forwarded-Encrypted: i=1; AFNElJ+4BygiHNrAu/exI+uBaoi4Z0/yMyJozGftXHUsJtYDqRUDa+jiFpIVpWiOLXoEOevT/zp6nZ5aHcWBse0=@vger.kernel.org X-Gm-Message-State: AOJu0YxDunlnDDKQ8TOSALShv7iSn67Yx+PVhFEhSokPRkwqSmf3pPFl hmRMcW3HTidKlDsHkP9e0vTSPuvOwN33//A1WweCIs0HeVh3ZJnmvtkgvGhIDOq83A== X-Gm-Gg: AfdE7cnoFKKF1ZZaky8xI/pd3yI4CTrXiz0QUF6gW6J8tLRyEYsUihs7j57xrU56Az0 re0vnldGsxDv0ZN0FVmSfzgQZr35ZrZMX+yKq0EyoE8OJRmvg1YX8f392xjAaOjAdl5+1g4EfW8 fxGDF3BAL0Zi4BQtauyB7E85AoT3yLSTVy1Ut0p5wYRhYCMtqMXTwwDXLY2IRCloLcvhfetMAJJ S2o8tENjWTmXGWmLWUrITNrmBIs+vei/O+ffXsSICFiLNy95GALP4SWYZKQARIO2QgRYBPfdpEo S28aHCz1kkf2EU/oBqE2yF0BrPELz4D+bF22o18POtCTlVyw/ZM8+KX1cYBuK8OIFw8sCxxy5ug b+B40NHjDAPq4GBHdaRxWNyqOxmc4Mp8c9e+ahJEnku7CDBuughp6YX5yv7ZEHqVtHQRDQpa3Pn z6FgXuwHBSy6PogoefcGIJx5yp7YiS3xoMROiRFSHu/gcTLajmo7Cz1v3KmTM= X-Received: by 2002:a7b:ce17:0:b0:492:43a3:2fd7 with SMTP id 5b1f17b1804b1-49269ed6ba1mr786145e9.0.1782460129056; Fri, 26 Jun 2026 00:48:49 -0700 (PDT) Received: from google.com (143.11.148.146.bc.googleusercontent.com. [146.148.11.143]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268ff9f40sm57920045e9.6.2026.06.26.00.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 00:48:48 -0700 (PDT) Date: Fri, 26 Jun 2026 07:48:44 +0000 From: Sebastian Ene To: Will Deacon Cc: catalin.marinas@arm.com, maz@kernel.org, oupton@kernel.org, joey.gouly@arm.com, korneld@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, mrigendra.chaubey@gmail.com, perlarsen@google.com, suzuki.poulose@arm.com, vdonnefort@google.com, yuzenghui@huawei.com Subject: Re: [PATCH v5 1/7] KVM: arm64: Enforce strict SBZ checks in the FF-A proxy Message-ID: References: <20260623115354.632361-1-sebastianene@google.com> <20260623115354.632361-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 25, 2026 at 02:16:40PM +0100, Will Deacon wrote: > Hi all, > > On Tue, Jun 23, 2026 at 11:53:48AM +0000, Sebastian Ene wrote: > > Introduce a helper method ffa_check_unused_args_sbz to enforce strict > > arguments checking when the hypervisor acts as a relayer between the > > host and Trustzone. > > > > Signed-off-by: Sebastian Ene > > Reviewed-by: Vincent Donnefort > > --- > > arch/arm64/kvm/hyp/nvhe/ffa.c | 54 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 54 insertions(+) > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c > > index 1af722771178..78bb043b33ee 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/ffa.c > > +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c > > @@ -71,6 +71,20 @@ static u32 hyp_ffa_version; > > static bool has_version_negotiated; > > static hyp_spinlock_t version_lock; > > > > +static bool ffa_check_unused_args_sbz(struct kvm_cpu_context *ctxt, int first_reg) > > +{ > > + DECLARE_REG(u32, func_id, ctxt, 0); > > + int reg, end_reg; > > + > > + end_reg = ARM_SMCCC_IS_64(func_id) ? 17 : 7; > > + for (reg = first_reg; reg <= end_reg; reg++) { > > + if (cpu_reg(ctxt, reg)) > > + return true; > > + } > > + > > + return false; > > +} Hello Will, > > Seb and I tried taking this for a spin on some Android devices and, sadly, > it leads to fireworks. The reason is that the FF-A spec quietly changed > the list of unused parameter registers for 64-bit SMCs from v1.1 to v1.2 > of the spec so that pre-existing calls were affected. > > For example, in v1.1 a 64-bit RXTX_MAP only has x4-x7 as MBZ, whereas in > v1.2 the same call has x4-x17 as SBZ. > > We can follow the spec by predicating the additional check on the FF-A > version being >= 1.2, but I'm not hopeful that existing drivers are > compliant. I also suggest moving this patch to the end of the series in > case we need to revert it. I spinned up a new series (v6) which moves the check at the end of the series and I made it so that it takes the ff-a version into account. https://lore.kernel.org/all/20260626074545.433234-1-sebastianene@google.com/ > > Cheers, > > Will Thanks Sebastian