mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yeoreum Yun <yeoreum.yun@arm.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, sudeep.holla@arm.com,
	stuart.yoder@arm.com, sgarzare@redhat.com,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] tpm_ffa_crb: access tpm service over FF-A direct message request v2
Date: Tue, 15 Apr 2025 08:32:40 +0100	[thread overview]
Message-ID: <Z/4LmB4iOFbHB5Sq@e129823.arm.com> (raw)
In-Reply-To: <Z_0aBHJ16l-Vw72p@kernel.org>

Hi,

> On Sat, Apr 12, 2025 at 06:47:21AM +0100, Yeoreum Yun wrote:
> > For secure partition with multi service, tpm_ffa_crb can access tpm
> > service with direct message request v2 interface according to chapter 3.3,
> > TPM Service Command Response Buffer Interface Over FF-A specification, v1.0 BET.
> >
> > This patch reflects this spec to access tpm service over
> > FF-A direct message request v2 ABI.
> >
> > Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> > Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> > ---
> > Since v2:
> >     - rewokring commit message
> >     - https://lore.kernel.org/all/20250411090856.1417021-1-yeoreum.yun@arm.com/
> >
> > Since v1:
> >     - Fix indentation.
> >     - https://lore.kernel.org/all/20250410110701.1244965-1-yeoreum.yun@arm.com/
> > ---
> >  drivers/char/tpm/tpm_crb_ffa.c | 55 ++++++++++++++++++++++++----------
> >  1 file changed, 40 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/char/tpm/tpm_crb_ffa.c b/drivers/char/tpm/tpm_crb_ffa.c
> > index 3169a87a56b6..fed775cf53ab 100644
> > --- a/drivers/char/tpm/tpm_crb_ffa.c
> > +++ b/drivers/char/tpm/tpm_crb_ffa.c
> > @@ -105,7 +105,10 @@ struct tpm_crb_ffa {
> >  	u16 minor_version;
> >  	/* lock to protect sending of FF-A messages: */
> >  	struct mutex msg_data_lock;
> > -	struct ffa_send_direct_data direct_msg_data;
> > +	union {
> > +		struct ffa_send_direct_data direct_msg_data;
> > +		struct ffa_send_direct_data2 direct_msg_data2;
> > +	};
> >  };
> >
> >  static struct tpm_crb_ffa *tpm_crb_ffa;
> > @@ -185,18 +188,34 @@ static int __tpm_crb_ffa_send_recieve(unsigned long func_id,
> >
> >  	msg_ops = tpm_crb_ffa->ffa_dev->ops->msg_ops;
> >
> > -	memset(&tpm_crb_ffa->direct_msg_data, 0x00,
> > -	       sizeof(struct ffa_send_direct_data));
> > -
> > -	tpm_crb_ffa->direct_msg_data.data1 = func_id;
> > -	tpm_crb_ffa->direct_msg_data.data2 = a0;
> > -	tpm_crb_ffa->direct_msg_data.data3 = a1;
> > -	tpm_crb_ffa->direct_msg_data.data4 = a2;
> > +	if (ffa_partition_supports_direct_req2_recv(tpm_crb_ffa->ffa_dev)) {
> > +		memset(&tpm_crb_ffa->direct_msg_data2, 0x00,
> > +		       sizeof(struct ffa_send_direct_data2));
> > +
> > +		tpm_crb_ffa->direct_msg_data2.data[0] = func_id;
> > +		tpm_crb_ffa->direct_msg_data2.data[1] = a0;
> > +		tpm_crb_ffa->direct_msg_data2.data[2] = a1;
> > +		tpm_crb_ffa->direct_msg_data2.data[3] = a2;
> > +
> > +		ret = msg_ops->sync_send_receive2(tpm_crb_ffa->ffa_dev,
> > +				&tpm_crb_ffa->direct_msg_data2);
> > +		if (!ret)
> > +			ret = tpm_crb_ffa_to_linux_errno(tpm_crb_ffa->direct_msg_data2.data[0]);
> > +	} else {
> > +		memset(&tpm_crb_ffa->direct_msg_data, 0x00,
> > +		       sizeof(struct ffa_send_direct_data));
> > +
> > +		tpm_crb_ffa->direct_msg_data.data1 = func_id;
> > +		tpm_crb_ffa->direct_msg_data.data2 = a0;
> > +		tpm_crb_ffa->direct_msg_data.data3 = a1;
> > +		tpm_crb_ffa->direct_msg_data.data4 = a2;
> > +
> > +		ret = msg_ops->sync_send_receive(tpm_crb_ffa->ffa_dev,
> > +				&tpm_crb_ffa->direct_msg_data);
> > +		if (!ret)
> > +			ret = tpm_crb_ffa_to_linux_errno(tpm_crb_ffa->direct_msg_data.data1);
> > +	}
> >
> > -	ret = msg_ops->sync_send_receive(tpm_crb_ffa->ffa_dev,
> > -			&tpm_crb_ffa->direct_msg_data);
> > -	if (!ret)
> > -		ret = tpm_crb_ffa_to_linux_errno(tpm_crb_ffa->direct_msg_data.data1);
> >
> >  	return ret;
> >  }
> > @@ -231,8 +250,13 @@ int tpm_crb_ffa_get_interface_version(u16 *major, u16 *minor)
> >
> >  	rc = __tpm_crb_ffa_send_recieve(CRB_FFA_GET_INTERFACE_VERSION, 0x00, 0x00, 0x00);
> >  	if (!rc) {
> > -		*major = CRB_FFA_MAJOR_VERSION(tpm_crb_ffa->direct_msg_data.data2);
> > -		*minor = CRB_FFA_MINOR_VERSION(tpm_crb_ffa->direct_msg_data.data2);
> > +		if (ffa_partition_supports_direct_req2_recv(tpm_crb_ffa->ffa_dev)) {
> > +			*major = CRB_FFA_MAJOR_VERSION(tpm_crb_ffa->direct_msg_data2.data[1]);
> > +			*minor = CRB_FFA_MINOR_VERSION(tpm_crb_ffa->direct_msg_data2.data[1]);
> > +		} else {
> > +			*major = CRB_FFA_MAJOR_VERSION(tpm_crb_ffa->direct_msg_data.data2);
> > +			*minor = CRB_FFA_MINOR_VERSION(tpm_crb_ffa->direct_msg_data.data2);
> > +		}
> >  	}
> >
> >  	return rc;
> > @@ -277,7 +301,8 @@ static int tpm_crb_ffa_probe(struct ffa_device *ffa_dev)
> >
> >  	tpm_crb_ffa = ERR_PTR(-ENODEV); // set tpm_crb_ffa so we can detect probe failure
> >
> > -	if (!ffa_partition_supports_direct_recv(ffa_dev)) {
> > +	if (!ffa_partition_supports_direct_recv(ffa_dev) &&
> > +	    !ffa_partition_supports_direct_req2_recv(ffa_dev)) {
> >  		pr_err("TPM partition doesn't support direct message receive.\n");
>
> did not notice but there's couple of things:
>
> 1. It should be probably warn. Driver is working incorrectly, isn't it?
> 2. dev_warn()
>
> So along the lines of would summarize all this:
>
> dev_warn(&ffa_dev->dev, "partition doesn't support direct message receive.\n");
>
> "TPM" was removed because this gives the device info.
>
>
> >  		return -EINVAL;
> >  	}
> > --
> > LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
> >
>

Agree. thou it seems not related for this patch, it's simple one,
I'll include this modification in next version.

Thanks.

--
Sincerely,
Yeoreum Yun

      reply	other threads:[~2025-04-15  7:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-12  5:47 Yeoreum Yun
2025-04-14 14:22 ` Jarkko Sakkinen
2025-04-15  7:32   ` Yeoreum Yun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z/4LmB4iOFbHB5Sq@e129823.arm.com \
    --to=yeoreum.yun@arm.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=sgarzare@redhat.com \
    --cc=stuart.yoder@arm.com \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®