From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 50C993C343D for ; Thu, 11 Jun 2026 09:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781171171; cv=none; b=h1arobikvkLq64mIpi7Kjku4p5irLc1uKyBAsdXbCl63aL6nlCtYb/6TGpYSKae2TGpGK4YRsv65qNK2fcUjvG21ImB+7rq5jO//KXOgvjR12BZlL0YggxOyOFD1S2mBRoFDGH4k5givfGUp19MNYPdO9fIJA88bgJ+tkJvacjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781171171; c=relaxed/simple; bh=oYrwKPXFNZ0ScqQrR/5KgKcm0e527VCHipAbmxHtOUg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nvfCOp+7af5ggI4joCyyXF7erDqjJRLCuBs0pwD24TGpZ0eXKGEt+KVneJqz8UyPEIyvxOfq6SXFUKDs5jajroW51QkovE52qkPVNFwvB2cHkKW9X1TjjPQMLOcvbrKrX+//jky27M7TSZ6+Ac0bfpuou/XmdXmjO8cKe48EIOQ= 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=EJmmAptH; arc=none smtp.client-ip=209.85.208.41 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="EJmmAptH" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-68d22476e88so9967a12.0 for ; Thu, 11 Jun 2026 02:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781171168; x=1781775968; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=caoKMgRrh781zMJjCERxNdYYkromYU4iEkGrg3oyQos=; b=EJmmAptHrlPUKs8WlVeVzyuSUIFBAugKOFhoXMltt8OD9VO+SMEH3T9ccCzGz04J/n zT+Xd/a1xxxEfy68ePpiHEazy2+AxghoyWzQIv6XStUnfOMetaPJzEATMgr3lFxvBtmx yqAXow3ugfWMfuBjPEJdJArBc3fkBgd33wZYcXBsk31tF5ySxLK8LDEQT9T4NL9h78Ln 1ptLITS4aRof0JbD/J1T7sYO92q3QUc543OiVrHmqPiFpqhwUXcOozPxhng4K+XmLmWA pbKKQ1xjXf3yCUmCCOmrRbD2kpe/+gzvrP4xhbu/4R4TsztUkgaPJaf+n2gTYoChQMWb CZXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781171168; x=1781775968; h=in-reply-to:content-disposition: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; bh=caoKMgRrh781zMJjCERxNdYYkromYU4iEkGrg3oyQos=; b=Kx/37T3Hl5A9uhcSCRGfgMQAkk2CK7CzdLklHtUOy1YXntb/TfV9QtC7HbRJDLgH/D JEmOu6+Ve6CjcQc6KOO9sdb4RotsqqXDx/nainaD1eS1Bx3a5/lY0sLQQq96Fy5PO80J p2Lf36UWp6rUMK46u2DhRR93wa20WRKlNSoFhRw61uCNvKUr744bix9H8+RYe29HPLYW 2T1I6I2ybyWZ7xljjPLOAHp3yvnKH3L6Y8KRChzRJzjZsHZGzBPm+ETdAAaqR40R+VhH Ke2tsHXWvkzvGFz6gsVp7Fe4l4eQ5T4SKlAs/WjhE27BxtfhxkW4yadd2bsdOk8yewfA 7A3w== X-Forwarded-Encrypted: i=1; AFNElJ8K8GBI/WaVGCtp16Dd/wRrQcMIy68g/ON0GxT9NR7fotDH1oN2QSqF0r/mAl5FxQiFKWPfZU/1pWmiF8Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4moq+O5fDQVJ70P2MAzdpTJ3QgLE3KIyQsRWZvm0LO5mudgJs G/AJxRh51xc/nnDSsXPZwqp3CfNpZ/gaEii+MB9XA6IPlySn+mtCaO3rKcdviXPIDw== X-Gm-Gg: Acq92OF7IpjNfUmsmbjgY1xi8cGZGxBrFXrwt5kD3+SuQDU/fadyOq/35aIEyIwwSgu G95MCftWI0kj+6CUK7vSZ1Lxr9zr8JuIbkyZakECH5t5DESK1yWTpGdqlZsWHOw8TPUzPCa9U1b 27Ky2KOUS3Vvq2qb7roaAqzHHX0csQcuBePdsNo4xTCQiy/75GOUVf7kzO2YajfZrPkByKBLsW3 vBEWN/eWg3oEMveKcvs81DiJ4KlYvat95oKLwLIvFT6Jm80+kBs/+8vaQAbbt4LikjPxzmDgqhY B8DqZoRw8LpHpmHZGlHxqYhuN7X86IzCDQryYAfMOuUXs3eedp0AzywbWWIdUeLtzykXpozk50a rPU7/97xFTZGAYAo8RgwSIHipAskVGxZyxAdrhNKNq7iWH6jiGbhOJCChQSIx8+CGvL9citgLdO L6x7AX1ku9tL+2zeQA/siGXaDpBww2TVG6pmd4b5FvCH3lRdDJ44oYjV4vZmQ92HmOkwOntn+HE SpfrJsc X-Received: by 2002:a05:6402:a545:20b0:68f:d41d:ca5d with SMTP id 4fb4d7f45d1cf-6930e145acdmr20838a12.11.1781171167189; Thu, 11 Jun 2026 02:46:07 -0700 (PDT) Received: from google.com (143.11.148.146.bc.googleusercontent.com. [146.148.11.143]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bfcb0f14edbsm40206466b.3.2026.06.11.02.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 02:46:06 -0700 (PDT) Date: Thu, 11 Jun 2026 09:46:02 +0000 From: Sebastian Ene To: Vincent Donnefort Cc: catalin.marinas@arm.com, maz@kernel.org, oupton@kernel.org, will@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, yuzenghui@huawei.com Subject: Re: [PATCH v2 1/7] KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler Message-ID: References: <20260608165549.1479409-1-sebastianene@google.com> <20260608165549.1479409-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 Wed, Jun 10, 2026 at 09:51:55AM +0100, Vincent Donnefort wrote: > Hi Seb, > > On Mon, Jun 08, 2026 at 04:55:43PM +0000, Sebastian Ene wrote: > > Allow FF-A notification bitmap creation messages to be forwarded to > > Trustzone from the host and introduce a helper to check for SBZ > > register fields. > > > > Signed-off-by: Sebastian Ene > > --- > > arch/arm64/kvm/hyp/nvhe/ffa.c | 36 ++++++++++++++++++++++++++++++++++- > > 1 file changed, 35 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c > > index 1af722771178..c20d45191085 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/ffa.c > > +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c > > @@ -71,6 +71,18 @@ 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) > > +{ > > + int reg; > > + > > + for (reg = first_reg; reg < 17; reg++) { > > The upper limit should probably be something like ARRAY_SIZE(ctx->regs.regs) - first_reg? > The upper limit is 17 since the smc64 uses x1-x17 as arguments and w0 as a function identifier. ARRAY_SIZE(ctx->regs.regs) is 31 > > + if (cpu_reg(ctxt, reg)) > > + return true; > > + } > > + > > + return false; > > +} > > + > > static void ffa_to_smccc_error(struct arm_smccc_1_2_regs *res, u64 ffa_errno) > > { > > *res = (struct arm_smccc_1_2_regs) { > > @@ -676,7 +688,6 @@ static bool ffa_call_supported(u64 func_id) > > case FFA_MEM_DONATE: > > case FFA_MEM_RETRIEVE_REQ: > > /* Optional notification interfaces added in FF-A 1.1 */ > > - case FFA_NOTIFICATION_BITMAP_CREATE: > > case FFA_NOTIFICATION_BITMAP_DESTROY: > > case FFA_NOTIFICATION_BIND: > > case FFA_NOTIFICATION_UNBIND: > > @@ -862,6 +873,26 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, > > hyp_spin_unlock(&host_buffers.lock); > > } > > > > +static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res, > > + struct kvm_cpu_context *ctxt) > > +{ > > + DECLARE_REG(u32, vmid, ctxt, 1); > > + struct arm_smccc_1_2_regs *args; > > + > > + if (ffa_check_unused_args_sbz(ctxt, 3)) { > > Is that expected we start at 3 but only read 0 and 1? > That's what they are saying in the ffa doc (16.1 FFA_NOTIFICATION_BITMAP_CREATE). They use w2 to hold the number of vcpus, that's why they start at 3. > > + ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS); > > + return; > > + } > > + > > + if (vmid != HOST_FFA_ID) { > > + ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS); > > + return; > > + } > > + > > + args = (void *)&ctxt->regs.regs[0]; > > + arm_smccc_1_2_smc(args, res); > > Should be hyp_smccc_1_2_smc() > Yes, replaced it with this. > > +} > > + > > bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) > > { > > struct arm_smccc_1_2_regs res; > > @@ -920,6 +951,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) > > case FFA_PARTITION_INFO_GET: > > do_ffa_part_get(&res, host_ctxt); > > goto out_handled; > > + case FFA_NOTIFICATION_BITMAP_CREATE: > > + do_ffa_notif_bitmap_create(&res, host_ctxt); > > + goto out_handled; > > } > > > > if (ffa_call_supported(func_id)) > > -- > > 2.54.0.1064.gd145956f57-goog > > Thanks, Sebastian