tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Jason Gunthorpe
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Jerry Snitselaar
	<jsnitsel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	open list <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	gang.wei-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH v2] tpm_crb: request and relinquish locality 0
Date: Mon, 13 Mar 2017 22:12:35 +0200	[thread overview]
Message-ID: <20170313201235.tvcyugdh7awqfrfq@intel.com> (raw)
In-Reply-To: <20170313163452.GD22997-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

On Mon, Mar 13, 2017 at 10:34:52AM -0600, Jason Gunthorpe wrote:
> On Sat, Mar 11, 2017 at 03:02:14PM +0200, Jarkko Sakkinen wrote:
> > Added two new callbacks to struct tpm_class_ops:
> > 
> > - request_locality
> > - relinquish_locality
> > 
> > These are called before sending and receiving data from the TPM.  We
> > update also tpm_tis_core to use these callbacks. Small modification to
> > request_locality() is done so that it returns -EBUSY instead of locality
> > number when check_locality() fails.
> 
> Make sense
> 
> I think you may as well do the other two drivers, even though you
> can't run them the transformation looks safe enough to me.
> 
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> >  drivers/char/tpm/tpm-interface.c |  9 +++++++++
> >  drivers/char/tpm/tpm_crb.c       | 41 +++++++++++++++++++++++++++++++++++++++-
> >  drivers/char/tpm/tpm_tis_core.c  | 12 ++++--------
> >  include/linux/tpm.h              |  3 ++-
> >  4 files changed, 55 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > index e38c792..9c56581 100644
> > +++ b/drivers/char/tpm/tpm-interface.c
> > @@ -407,6 +407,12 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
> >  	if (chip->dev.parent)
> >  		pm_runtime_get_sync(chip->dev.parent);
> >  
> > +	if (chip->ops->request_locality)  {
> > +		rc = chip->ops->request_locality(chip, 0);
> > +		if (rc)
> > +			goto out;
> 
> If request_locality fails we probably shouldn't call
> relinquish_locality on the unwind path..
> 
> I think you should also put a relinquish_locality inside tpm_remove ?

Right. I was wondering why release_locality is called inside
tpm_tis_remove().

So is the idea of checking pendingRequest such that the release
part is "lazy" and not like what I'm doing in tpm_crb (always
relinquish).

Is that done for performance reasons? Should I do the same (pr
similar in tpm_crb?

> > +	int (*request_locality)(struct tpm_chip *chip, int loc);
> > +	void (*relinquish_locality)(struct tpm_chip *chip, int loc,
> > bool force);
> 
> Let us document what force is supposed to do...
> 
> I'm not sure why we have it?
> 
> Jason

I guess since it is lazy in tpm_tis_core the force is done in
tpm_tis_remove so that you always relinquish the locality even
if someone is not requesting it, right?

Where should this be documented, to the header?

/Jarkko

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

  parent reply	other threads:[~2017-03-13 20:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-11 13:02 [PATCH v2] tpm_crb: request and relinquish locality 0 Jarkko Sakkinen
     [not found] ` <20170311130216.21419-1-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-03-12 19:47   ` Jerry Snitselaar
2017-03-13 11:58     ` Jarkko Sakkinen
2017-03-13 16:34   ` Jason Gunthorpe
     [not found]     ` <20170313163452.GD22997-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-13 20:12       ` Jarkko Sakkinen [this message]
     [not found]         ` <20170313201235.tvcyugdh7awqfrfq-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-13 20:43           ` Jason Gunthorpe

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=20170313201235.tvcyugdh7awqfrfq@intel.com \
    --to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=gang.wei-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
    --cc=jsnitsel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).