All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - Check for CCP before registering crypto algs
@ 2014-09-05 15:31 Tom Lendacky
  2014-09-05 23:49 ` Scot Doyle
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Lendacky @ 2014-09-05 15:31 UTC (permalink / raw)
  To: linux-crypto; +Cc: lkml14, herbert, davem

If the ccp is built as a built-in module, then ccp-crypto (whether
built as a module or a built-in module) will be able to load and
it will register its crypto algorithms.  If the system does not have
a CCP this will result in -ENODEV being returned whenever a command
is attempted to be queued by the registered crypto algorithms.

Add an API, ccp_present(), that checks for the presence of a CCP
on the system.  The ccp-crypto module can use this to determine if it
should register it's crypto alogorithms.

Reported-by: Scot Doyle <lkml14@scotdoyle.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/ccp-crypto-main.c |    4 ++++
 drivers/crypto/ccp/ccp-dev.c         |   14 ++++++++++++++
 include/linux/ccp.h                  |   12 ++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c
index 20dc848..4d4e016 100644
--- a/drivers/crypto/ccp/ccp-crypto-main.c
+++ b/drivers/crypto/ccp/ccp-crypto-main.c
@@ -367,6 +367,10 @@ static int ccp_crypto_init(void)
 {
 	int ret;
 
+	ret = ccp_present();
+	if (ret)
+		return ret;
+
 	spin_lock_init(&req_queue_lock);
 	INIT_LIST_HEAD(&req_queue.cmds);
 	req_queue.backlog = &req_queue.cmds;
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index a7d1106..c6e6171 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -55,6 +55,20 @@ static inline void ccp_del_device(struct ccp_device *ccp)
 }
 
 /**
+ * ccp_present - check if a CCP device is present
+ *
+ * Returns zero if a CCP device is present, -ENODEV otherwise.
+ */
+int ccp_present(void)
+{
+	if (ccp_get_device())
+		return 0;
+
+	return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(ccp_present);
+
+/**
  * ccp_enqueue_cmd - queue an operation for processing by the CCP
  *
  * @cmd: ccp_cmd struct to be processed
diff --git a/include/linux/ccp.h b/include/linux/ccp.h
index ebcc9d1..7f43703 100644
--- a/include/linux/ccp.h
+++ b/include/linux/ccp.h
@@ -27,6 +27,13 @@ struct ccp_cmd;
 	defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE)
 
 /**
+ * ccp_present - check if a CCP device is present
+ *
+ * Returns zero if a CCP device is present, -ENODEV otherwise.
+ */
+int ccp_present(void);
+
+/**
  * ccp_enqueue_cmd - queue an operation for processing by the CCP
  *
  * @cmd: ccp_cmd struct to be processed
@@ -53,6 +60,11 @@ int ccp_enqueue_cmd(struct ccp_cmd *cmd);
 
 #else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */
 
+static inline int ccp_present(void)
+{
+	return -ENODEV;
+}
+
 static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
 {
 	return -ENODEV;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: ccp - Check for CCP before registering crypto algs
  2014-09-05 15:31 [PATCH] crypto: ccp - Check for CCP before registering crypto algs Tom Lendacky
@ 2014-09-05 23:49 ` Scot Doyle
  2014-09-15 11:47   ` Herbert Xu
  0 siblings, 1 reply; 5+ messages in thread
From: Scot Doyle @ 2014-09-05 23:49 UTC (permalink / raw)
  To: Tom Lendacky, herbert, davem; +Cc: linux-crypto


On Fri, 5 Sep 2014, Tom Lendacky wrote:

> If the ccp is built as a built-in module, then ccp-crypto (whether
> built as a module or a built-in module) will be able to load and
> it will register its crypto algorithms.  If the system does not have
> a CCP this will result in -ENODEV being returned whenever a command
> is attempted to be queued by the registered crypto algorithms.
>
> Add an API, ccp_present(), that checks for the presence of a CCP
> on the system.  The ccp-crypto module can use this to determine if it
> should register it's crypto alogorithms.
>
> Reported-by: Scot Doyle <lkml14@scotdoyle.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> drivers/crypto/ccp/ccp-crypto-main.c |    4 ++++
> drivers/crypto/ccp/ccp-dev.c         |   14 ++++++++++++++
> include/linux/ccp.h                  |   12 ++++++++++++
> 3 files changed, 30 insertions(+)
>
> diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c
> index 20dc848..4d4e016 100644
> --- a/drivers/crypto/ccp/ccp-crypto-main.c
> +++ b/drivers/crypto/ccp/ccp-crypto-main.c
> @@ -367,6 +367,10 @@ static int ccp_crypto_init(void)
> {
> 	int ret;
>
> +	ret = ccp_present();
> +	if (ret)
> +		return ret;
> +
> 	spin_lock_init(&req_queue_lock);
> 	INIT_LIST_HEAD(&req_queue.cmds);
> 	req_queue.backlog = &req_queue.cmds;
> diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
> index a7d1106..c6e6171 100644
> --- a/drivers/crypto/ccp/ccp-dev.c
> +++ b/drivers/crypto/ccp/ccp-dev.c
> @@ -55,6 +55,20 @@ static inline void ccp_del_device(struct ccp_device *ccp)
> }
>
> /**
> + * ccp_present - check if a CCP device is present
> + *
> + * Returns zero if a CCP device is present, -ENODEV otherwise.
> + */
> +int ccp_present(void)
> +{
> +	if (ccp_get_device())
> +		return 0;
> +
> +	return -ENODEV;
> +}
> +EXPORT_SYMBOL_GPL(ccp_present);
> +
> +/**
>  * ccp_enqueue_cmd - queue an operation for processing by the CCP
>  *
>  * @cmd: ccp_cmd struct to be processed
> diff --git a/include/linux/ccp.h b/include/linux/ccp.h
> index ebcc9d1..7f43703 100644
> --- a/include/linux/ccp.h
> +++ b/include/linux/ccp.h
> @@ -27,6 +27,13 @@ struct ccp_cmd;
> 	defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE)
>
> /**
> + * ccp_present - check if a CCP device is present
> + *
> + * Returns zero if a CCP device is present, -ENODEV otherwise.
> + */
> +int ccp_present(void);
> +
> +/**
>  * ccp_enqueue_cmd - queue an operation for processing by the CCP
>  *
>  * @cmd: ccp_cmd struct to be processed
> @@ -53,6 +60,11 @@ int ccp_enqueue_cmd(struct ccp_cmd *cmd);
>
> #else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */
>
> +static inline int ccp_present(void)
> +{
> +	return -ENODEV;
> +}
> +
> static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
> {
> 	return -ENODEV;

Thanks Tom!

Tested-by: Scot Doyle <lkml14@scotdoyle.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: ccp - Check for CCP before registering crypto algs
  2014-09-05 23:49 ` Scot Doyle
@ 2014-09-15 11:47   ` Herbert Xu
  2014-09-22 15:07     ` Tom Lendacky
  0 siblings, 1 reply; 5+ messages in thread
From: Herbert Xu @ 2014-09-15 11:47 UTC (permalink / raw)
  To: Scot Doyle; +Cc: Tom Lendacky, davem, linux-crypto

On Fri, Sep 05, 2014 at 11:49:38PM +0000, Scot Doyle wrote:
> 
> On Fri, 5 Sep 2014, Tom Lendacky wrote:
> 
> > If the ccp is built as a built-in module, then ccp-crypto (whether
> > built as a module or a built-in module) will be able to load and
> > it will register its crypto algorithms.  If the system does not have
> > a CCP this will result in -ENODEV being returned whenever a command
> > is attempted to be queued by the registered crypto algorithms.
> >
> > Add an API, ccp_present(), that checks for the presence of a CCP
> > on the system.  The ccp-crypto module can use this to determine if it
> > should register it's crypto alogorithms.
> >
> > Reported-by: Scot Doyle <lkml14@scotdoyle.com>
> > Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> 
> Tested-by: Scot Doyle <lkml14@scotdoyle.com>

Patch applied.  Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: ccp - Check for CCP before registering crypto algs
  2014-09-15 11:47   ` Herbert Xu
@ 2014-09-22 15:07     ` Tom Lendacky
  2014-09-24  6:22       ` Herbert Xu
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Lendacky @ 2014-09-22 15:07 UTC (permalink / raw)
  To: Herbert Xu, Scot Doyle; +Cc: davem, linux-crypto

On 09/15/2014 06:47 AM, Herbert Xu wrote:
> On Fri, Sep 05, 2014 at 11:49:38PM +0000, Scot Doyle wrote:
>>
>> On Fri, 5 Sep 2014, Tom Lendacky wrote:
>>
>>> If the ccp is built as a built-in module, then ccp-crypto (whether
>>> built as a module or a built-in module) will be able to load and
>>> it will register its crypto algorithms.  If the system does not have
>>> a CCP this will result in -ENODEV being returned whenever a command
>>> is attempted to be queued by the registered crypto algorithms.
>>>
>>> Add an API, ccp_present(), that checks for the presence of a CCP
>>> on the system.  The ccp-crypto module can use this to determine if it
>>> should register it's crypto alogorithms.
>>>
>>> Reported-by: Scot Doyle <lkml14@scotdoyle.com>
>>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>>
>> Tested-by: Scot Doyle <lkml14@scotdoyle.com>
>
> Patch applied.  Thanks!
>

Hi Herbert,

Can you push this patch into the 3.17 release?

Also, it should probably go into to the stable releases.  Is this
something that you request or should I take care of that?

Thanks,
Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: ccp - Check for CCP before registering crypto algs
  2014-09-22 15:07     ` Tom Lendacky
@ 2014-09-24  6:22       ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2014-09-24  6:22 UTC (permalink / raw)
  To: Tom Lendacky; +Cc: Scot Doyle, davem, linux-crypto

On Mon, Sep 22, 2014 at 10:07:39AM -0500, Tom Lendacky wrote:
> On 09/15/2014 06:47 AM, Herbert Xu wrote:
> >On Fri, Sep 05, 2014 at 11:49:38PM +0000, Scot Doyle wrote:
> >>
> >>On Fri, 5 Sep 2014, Tom Lendacky wrote:
> >>
> >>>If the ccp is built as a built-in module, then ccp-crypto (whether
> >>>built as a module or a built-in module) will be able to load and
> >>>it will register its crypto algorithms.  If the system does not have
> >>>a CCP this will result in -ENODEV being returned whenever a command
> >>>is attempted to be queued by the registered crypto algorithms.
> >>>
> >>>Add an API, ccp_present(), that checks for the presence of a CCP
> >>>on the system.  The ccp-crypto module can use this to determine if it
> >>>should register it's crypto alogorithms.
> >>>
> >>>Reported-by: Scot Doyle <lkml14@scotdoyle.com>
> >>>Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> >>
> >>Tested-by: Scot Doyle <lkml14@scotdoyle.com>
> >
> >Patch applied.  Thanks!
> >
> 
> Hi Herbert,
> 
> Can you push this patch into the 3.17 release?

Thanks for the note, I've moved the patch to the crypto tree.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-24  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-05 15:31 [PATCH] crypto: ccp - Check for CCP before registering crypto algs Tom Lendacky
2014-09-05 23:49 ` Scot Doyle
2014-09-15 11:47   ` Herbert Xu
2014-09-22 15:07     ` Tom Lendacky
2014-09-24  6:22       ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.