mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gary R Hook <ghook@amd.com>
To: Rijo Thomas <Rijo-john.Thomas@amd.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	tee-dev@lists.linaro.org
Cc: Nimesh Easow <Nimesh.Easow@amd.com>,
	Devaraj Rangasamy <Devaraj.Rangasamy@amd.com>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Gary Hook <gary.hook@amd.com>
Subject: Re: [PATCH 3/4] tee: amdtee: check TEE status during driver initialization
Date: Fri, 27 Dec 2019 12:37:49 -0600	[thread overview]
Message-ID: <67839c5e-32e5-a69b-5dc6-bbbdf8559bf5@amd.com> (raw)
In-Reply-To: <7510087f2b8cffab083184dfefca183a6b73471a.1577423898.git.Rijo-john.Thomas@amd.com>

On 12/26/19 11:24 PM, Rijo Thomas wrote:
> The AMD-TEE driver should check if TEE is available before
> registering itself with TEE subsystem. This ensures that
> there is a TEE which the driver can talk to before proceeding
> with tee device node allocation.
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
> Co-developed-by: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com>
> Signed-off-by: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com>
> Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>

Reviewed-by: Gary R Hook <gary.hook@amd.com>

> ---
>   drivers/crypto/ccp/tee-dev.c | 11 +++++++++++
>   drivers/tee/amdtee/core.c    |  6 ++++++
>   include/linux/psp-tee.h      | 18 ++++++++++++++++++
>   3 files changed, 35 insertions(+)
> 
> diff --git a/drivers/crypto/ccp/tee-dev.c b/drivers/crypto/ccp/tee-dev.c
> index 555c8a7..5e697a9 100644
> --- a/drivers/crypto/ccp/tee-dev.c
> +++ b/drivers/crypto/ccp/tee-dev.c
> @@ -362,3 +362,14 @@ int psp_tee_process_cmd(enum tee_cmd_id cmd_id, void *buf, size_t len,
>   	return 0;
>   }
>   EXPORT_SYMBOL(psp_tee_process_cmd);
> +
> +int psp_check_tee_status(void)
> +{
> +	struct psp_device *psp = psp_get_master_device();
> +
> +	if (!psp || !psp->tee_data)
> +		return -ENODEV;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(psp_check_tee_status);
> diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c
> index dd360f3..9d0cee1 100644
> --- a/drivers/tee/amdtee/core.c
> +++ b/drivers/tee/amdtee/core.c
> @@ -16,6 +16,7 @@
>   #include <linux/firmware.h>
>   #include "amdtee_private.h"
>   #include "../tee_private.h"
> +#include <linux/psp-tee.h>
>   
>   static struct amdtee_driver_data *drv_data;
>   static DEFINE_MUTEX(session_list_mutex);
> @@ -438,6 +439,10 @@ static int __init amdtee_driver_init(void)
>   	struct tee_shm_pool *pool = ERR_PTR(-EINVAL);
>   	int rc;
>   
> +	rc = psp_check_tee_status();
> +	if (rc)
> +		goto err_fail;
> +
>   	drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
>   	if (IS_ERR(drv_data))
>   		return -ENOMEM;
> @@ -485,6 +490,7 @@ static int __init amdtee_driver_init(void)
>   	kfree(drv_data);
>   	drv_data = NULL;
>   
> +err_fail:
>   	pr_err("amd-tee driver initialization failed\n");
>   	return rc;
>   }
> diff --git a/include/linux/psp-tee.h b/include/linux/psp-tee.h
> index 63bb221..cb0c95d 100644
> --- a/include/linux/psp-tee.h
> +++ b/include/linux/psp-tee.h
> @@ -62,6 +62,19 @@ enum tee_cmd_id {
>   int psp_tee_process_cmd(enum tee_cmd_id cmd_id, void *buf, size_t len,
>   			u32 *status);
>   
> +/**
> + * psp_check_tee_status() - Checks whether there is a TEE which a driver can
> + * talk to.
> + *
> + * This function can be used by AMD-TEE driver to query if there is TEE with
> + * which it can communicate.
> + *
> + * Returns:
> + * 0          if the device has TEE
> + * -%ENODEV   if there is no TEE available
> + */
> +int psp_check_tee_status(void);
> +
>   #else /* !CONFIG_CRYPTO_DEV_SP_PSP */
>   
>   static inline int psp_tee_process_cmd(enum tee_cmd_id cmd_id, void *buf,
> @@ -69,5 +82,10 @@ static inline int psp_tee_process_cmd(enum tee_cmd_id cmd_id, void *buf,
>   {
>   	return -ENODEV;
>   }
> +
> +static inline int psp_check_tee_status(void)
> +{
> +	return -ENODEV;
> +}
>   #endif /* CONFIG_CRYPTO_DEV_SP_PSP */
>   #endif /* __PSP_TEE_H_ */
> 


  reply	other threads:[~2019-12-27 18:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-27  5:23 [PATCH 0/4] TEE driver for AMD APUs Rijo Thomas
2019-12-27  5:24 ` [PATCH 1/4] tee: allow compilation of tee subsystem for AMD CPUs Rijo Thomas
2019-12-27 18:37   ` Gary R Hook
2019-12-27  5:24 ` [PATCH 2/4] tee: add AMD-TEE driver Rijo Thomas
2019-12-27 18:37   ` Gary R Hook
2019-12-27  5:24 ` [PATCH 3/4] tee: amdtee: check TEE status during driver initialization Rijo Thomas
2019-12-27 18:37   ` Gary R Hook [this message]
2019-12-27  5:24 ` [PATCH 4/4] Documentation: tee: add AMD-TEE driver details Rijo Thomas
2019-12-27 18:38   ` Gary R Hook
2020-01-04  5:50 ` [PATCH 0/4] TEE driver for AMD APUs Herbert Xu

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=67839c5e-32e5-a69b-5dc6-bbbdf8559bf5@amd.com \
    --to=ghook@amd.com \
    --cc=Devaraj.Rangasamy@amd.com \
    --cc=Nimesh.Easow@amd.com \
    --cc=Rijo-john.Thomas@amd.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=davem@davemloft.net \
    --cc=gary.hook@amd.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tee-dev@lists.linaro.org \
    --cc=thomas.lendacky@amd.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®