devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: kexec@lists.infradead.org, devicetree@vger.kernel.org,
	nayna@linux.ibm.com, nasastry@in.ibm.com,
	Jason Gunthorpe <jgg@ziepe.ca>
Subject: Re: [PATCH 3/3] tpm: of: Call of_tpm_get_sml_parameters() to get base and size of log
Date: Thu, 16 Jun 2022 00:25:04 +0300	[thread overview]
Message-ID: <YqpOMPVZwx1pb2mp@iki.fi> (raw)
In-Reply-To: <20220614161258.1741427-4-stefanb@linux.ibm.com>

On Tue, Jun 14, 2022 at 12:12:58PM -0400, Stefan Berger wrote:
> Simplify tpm_read_log_of() and call of_tpm_get_sml_parameters() to get
> the base and size of the TPM log.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> Cc: Jarkko Sakkinen <jarkko@kernel.org>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> ---
>  drivers/char/tpm/eventlog/of.c | 31 +++++--------------------------
>  1 file changed, 5 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/char/tpm/eventlog/of.c b/drivers/char/tpm/eventlog/of.c
> index a9ce66d09a75..e272c7a0765f 100644
> --- a/drivers/char/tpm/eventlog/of.c
> +++ b/drivers/char/tpm/eventlog/of.c
> @@ -12,6 +12,7 @@
>  
>  #include <linux/slab.h>
>  #include <linux/of.h>
> +#include <linux/of_device.h>
>  #include <linux/tpm_eventlog.h>
>  
>  #include "../tpm.h"
> @@ -20,11 +21,10 @@
>  int tpm_read_log_of(struct tpm_chip *chip)
>  {
>  	struct device_node *np;
> -	const u32 *sizep;
> -	const u64 *basep;
>  	struct tpm_bios_log *log;
>  	u32 size;
>  	u64 base;
> +	int ret;
>  
>  	log = &chip->log;
>  	if (chip->dev.parent && chip->dev.parent->of_node)
> @@ -35,30 +35,9 @@ int tpm_read_log_of(struct tpm_chip *chip)
>  	if (of_property_read_bool(np, "powered-while-suspended"))
>  		chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
>  
> -	sizep = of_get_property(np, "linux,sml-size", NULL);
> -	basep = of_get_property(np, "linux,sml-base", NULL);
> -	if (sizep == NULL && basep == NULL)
> -		return -ENODEV;
> -	if (sizep == NULL || basep == NULL)
> -		return -EIO;
> -
> -	/*
> -	 * For both vtpm/tpm, firmware has log addr and log size in big
> -	 * endian format. But in case of vtpm, there is a method called
> -	 * sml-handover which is run during kernel init even before
> -	 * device tree is setup. This sml-handover function takes care
> -	 * of endianness and writes to sml-base and sml-size in little
> -	 * endian format. For this reason, vtpm doesn't need conversion
> -	 * but physical tpm needs the conversion.
> -	 */
> -	if (of_property_match_string(np, "compatible", "IBM,vtpm") < 0 &&
> -	    of_property_match_string(np, "compatible", "IBM,vtpm20") < 0) {
> -		size = be32_to_cpup((__force __be32 *)sizep);
> -		base = be64_to_cpup((__force __be64 *)basep);
> -	} else {
> -		size = *sizep;
> -		base = *basep;
> -	}
> +	ret = of_tpm_get_sml_parameters(np, &base, &size);
> +	if (ret < 0)
> +		return ret;
>  
>  	if (size == 0) {
>  		dev_warn(&chip->dev, "%s: Event log area empty\n", __func__);
> -- 
> 2.35.1
> 

Looks good to me.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

      parent reply	other threads:[~2022-06-15 21:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 16:12 [PATCH 0/3] tpm: Preserve TPM measurement log across kexec Stefan Berger
2022-06-14 16:12 ` [PATCH 1/3] of: kexec: Refactor IMA buffer related functions to make them reusable Stefan Berger
2022-06-14 16:35   ` Nageswara R Sastry
2022-06-14 16:12 ` [PATCH 2/3] tpm/kexec: Duplicate TPM measurement log in of-tree for kexec Stefan Berger
2022-06-14 16:46   ` Nageswara R Sastry
2022-06-14 17:48   ` Rob Herring
2022-06-15 13:08     ` Stefan Berger
2022-06-15 20:14       ` Rob Herring
2022-06-15 21:45         ` Stefan Berger
2022-06-15 20:18     ` Rob Herring
2022-06-14 18:58   ` kernel test robot
2022-06-15  0:54   ` kernel test robot
2022-06-15  9:42   ` kernel test robot
2022-06-14 16:12 ` [PATCH 3/3] tpm: of: Call of_tpm_get_sml_parameters() to get base and size of log Stefan Berger
2022-06-14 16:47   ` Nageswara R Sastry
2022-06-15 21:25   ` Jarkko Sakkinen [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=YqpOMPVZwx1pb2mp@iki.fi \
    --to=jarkko@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kexec@lists.infradead.org \
    --cc=nasastry@in.ibm.com \
    --cc=nayna@linux.ibm.com \
    --cc=stefanb@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).