* Re: [2/2] ath9k: disable RNG by default
From: Kalle Valo @ 2016-09-28 10:00 UTC (permalink / raw)
To: miaoqing pan
Cc: linux-wireless, ath9k-devel, linux-crypto, smueller, jason,
pouyans, Miaoqing Pan
In-Reply-To: <1470726147-30095-2-git-send-email-miaoqing@codeaurora.org>
miaoqing pan <miaoqing@codeaurora.org> wrote:
> From: Miaoqing Pan <miaoqing@codeaurora.org>
>
> ath9k RNG will dominates all the noise sources from the real HW
> RNG, disable it by default. But we strongly recommand to enable
> it if the system without HW RNG, especially on embedded systems.
>
> Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
> Acked-by: Stephan Mueller <smueller@chronox.de>
> Acked-by: Stephan Mueller <smueller@chronox.de>
> Reviewed-by: Jason Cooper <jason@lakedaemon.net>
Patch applied to ath-next branch of ath.git, thanks.
739ccd76b40e ath9k: disable RNG by default
--
https://patchwork.kernel.org/patch/9270467/
Documentation about submitting wireless patches and checking status
from patchwork:
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply
* [PATCH] crypto/caam/jr : Unmap region obtained by of_iomap
From: Arvind Yadav @ 2016-09-28 10:31 UTC (permalink / raw)
To: herbert, davem
Cc: alexandru.porosanu, fabio.estevam, horia.geanta, cata.vasile,
linux-crypto, linux-kernel, Arvind Yadav
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
Free memory mapping, if probe is not successful.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/crypto/caam/jr.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index a81f551..9e7f281 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -513,6 +513,7 @@ static int caam_jr_probe(struct platform_device *pdev)
error = caam_jr_init(jrdev); /* now turn on hardware */
if (error) {
irq_dispose_mapping(jrpriv->irq);
+ iounmap(ctrl);
return error;
}
--
1.7.9.5
^ permalink raw reply related
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Marcelo Cerri @ 2016-09-28 12:28 UTC (permalink / raw)
To: Herbert Xu
Cc: Jan Stancek, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928024549.GB14034@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
Hi Herbert,
On Wed, Sep 28, 2016 at 10:45:49AM +0800, Herbert Xu wrote:
> On Tue, Sep 27, 2016 at 04:46:44PM -0300, Marcelo Cerri wrote:
> >
> > Can you check if the problem occurs with this patch?
>
> In light of the fact that padlock-sha is the correct example
> to follow, you only need to add one line to the init_tfm fucntion
> to update the descsize based on that of the fallback.
>
Not sure if I'm missing something here but p8_ghash already does that:
56 static int p8_ghash_init_tfm(struct crypto_tfm *tfm)
57 {
...
83 shash_tfm->descsize = sizeof(struct p8_ghash_desc_ctx)
84 + crypto_shash_descsize(fallback);
85
86 return 0;
87 }
I think the problem here is that crypto_ahash_statesize uses the
statesize value (that is initialized with the descsize value from
shash_alg) instead of using the value from the tfm that was updated.
For padlock_sha1, it uses the value from alg->statesize since it defines
import and export functions. It doesn't make much difference if it uses
the value from descsize or statesize here, what really matter is that
it uses the value defined in struct shash_alg and not from the tfm.
The big difference between p8_ghash and padlock_sha1 is that
padlock_sha1 defines alg->statesize as sizeof(struct sha1_state), which
is the descsize value used by sha1_generic. This probably works but
it's also wrong because the padlock_sha1 driver does not ensures that
sha1_generic is always used.
So, one solution is to hardcode ghash-generic as the fallback algorithm
and update the descsize direct in its shash_alg structure. There's only
one problem with that. ghash-generic desc type (struct ghash_desc_ctx)
is not available for vmx_crypto at compile type, the type is defined
directly in crypto/ghash-generic.c. That's the reason I added a function
to get the fallback desc size at runtime in the patch I wrote as a prove
of concept.
--
Regards,
Marcelo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Herbert Xu @ 2016-09-28 12:29 UTC (permalink / raw)
To: Jan Stancek
Cc: Marcelo Cerri, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <1597189480.51836.1475048451846.JavaMail.zimbra@redhat.com>
On Wed, Sep 28, 2016 at 03:40:51AM -0400, Jan Stancek wrote:
>
> Thanks for clearing up how this works in padlock-sha, but
> we are not exactly in same situation with p8_ghash.
>
> p8_ghash_init_tfm() already updates descsize. Problem in original report
> is that without custom export/import/statesize p8_ghash_alg.statesize
> gets initialized by shash_prepare_alg() to alg->descsize:
Right.
> so I think we need either:
> 1) make sure p8_ghash_alg.descsize is correct before we register shash,
> this is what Marcelo's last patch is doing
This approach doesn't work because there is no guarantee that
you'll get the same fallback the next time you allocate a tfm.
So relying on the descsize being constant can only work if all
implementations of the fallback use the same desc struct.
> 2) provide custom export/import/statesize for p8_ghash_alg
This works for padlock-sha because every implementation of SHA
uses the same state data structure from sha.h. If we can make
all implementations of ghash agree on the exported state then
we can use the same approach.
Otherwise we can go back to allocating just ghash-generic and
also move its data structure into an exported header file.
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
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Herbert Xu @ 2016-09-28 12:33 UTC (permalink / raw)
To: Marcelo Cerri
Cc: Jan Stancek, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928122844.GC15729@gallifrey>
On Wed, Sep 28, 2016 at 09:28:44AM -0300, Marcelo Cerri wrote:
>
> The big difference between p8_ghash and padlock_sha1 is that
> padlock_sha1 defines alg->statesize as sizeof(struct sha1_state), which
> is the descsize value used by sha1_generic. This probably works but
> it's also wrong because the padlock_sha1 driver does not ensures that
> sha1_generic is always used.
It should work because all our SHA implementations use the same
export format. This is not necessarily the case for GHASH though.
> So, one solution is to hardcode ghash-generic as the fallback algorithm
> and update the descsize direct in its shash_alg structure. There's only
> one problem with that. ghash-generic desc type (struct ghash_desc_ctx)
> is not available for vmx_crypto at compile type, the type is defined
> directly in crypto/ghash-generic.c. That's the reason I added a function
> to get the fallback desc size at runtime in the patch I wrote as a prove
> of concept.
The problem with your patch is that there is no guarantee that
you will get the same algorithm every time you allocate a fallback.
Someone may have loaded a new module for example.
So I think the safe approach is to stick with ghash-generic and
expose its state data structure in a header file.
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
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Marcelo Cerri @ 2016-09-28 12:38 UTC (permalink / raw)
To: Herbert Xu
Cc: Jan Stancek, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928122935.GA20839@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 1944 bytes --]
Hi Hebert,
On Wed, Sep 28, 2016 at 08:29:35PM +0800, Herbert Xu wrote:
> On Wed, Sep 28, 2016 at 03:40:51AM -0400, Jan Stancek wrote:
> >
> > Thanks for clearing up how this works in padlock-sha, but
> > we are not exactly in same situation with p8_ghash.
> >
> > p8_ghash_init_tfm() already updates descsize. Problem in original report
> > is that without custom export/import/statesize p8_ghash_alg.statesize
> > gets initialized by shash_prepare_alg() to alg->descsize:
>
> Right.
>
> > so I think we need either:
> > 1) make sure p8_ghash_alg.descsize is correct before we register shash,
> > this is what Marcelo's last patch is doing
>
> This approach doesn't work because there is no guarantee that
> you'll get the same fallback the next time you allocate a tfm.
> So relying on the descsize being constant can only work if all
> implementations of the fallback use the same desc struct.
The patch forces ghash-generic as the fallback. And I don't think that
is a big problem if we decide to go by this path.
>
> > 2) provide custom export/import/statesize for p8_ghash_alg
>
> This works for padlock-sha because every implementation of SHA
> uses the same state data structure from sha.h. If we can make
> all implementations of ghash agree on the exported state then
> we can use the same approach.
That would be nice because it would allow p8_ghash to keep using a
dynamic fallback, but I'm not that is viable. What do you think?
>
> Otherwise we can go back to allocating just ghash-generic and
> also move its data structure into an exported header file.
>
That would make the fix much more simple and it wouldn't require to get
the fallback descsize at runtime.
> 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
--
Regards,
Marcelo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Herbert Xu @ 2016-09-28 12:44 UTC (permalink / raw)
To: Marcelo Cerri
Cc: Jan Stancek, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928123841.GD15729@gallifrey>
On Wed, Sep 28, 2016 at 09:38:41AM -0300, Marcelo Cerri wrote:
>
> The patch forces ghash-generic as the fallback. And I don't think that
> is a big problem if we decide to go by this path.
Right it should work but could break for example if we ever decide
to change the exported state structure for ghash and someone unloads
the ghash-generic module and reloads a new one.
> That would be nice because it would allow p8_ghash to keep using a
> dynamic fallback, but I'm not that is viable. What do you think?
We did it for SHA because it was desirable to have multiple
fallbacks, i.e., a generic C version plus an assembly-optimised
version.
Not sure whether the same motiviation exists for GHASH.
> > Otherwise we can go back to allocating just ghash-generic and
> > also move its data structure into an exported header file.
> >
>
> That would make the fix much more simple and it wouldn't require to get
> the fallback descsize at runtime.
This is the easiest fix so let's go with this now. If we ever
care enough to have multiple fallbacks for GHASH we can always
revisit this. The exported format is not exposed to user-space
so it can always be changed.
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
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Marcelo Cerri @ 2016-09-28 12:55 UTC (permalink / raw)
To: Herbert Xu
Cc: Jan Stancek, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928124452.GA21011@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]
On Wed, Sep 28, 2016 at 08:44:52PM +0800, Herbert Xu wrote:
> On Wed, Sep 28, 2016 at 09:38:41AM -0300, Marcelo Cerri wrote:
> >
> > The patch forces ghash-generic as the fallback. And I don't think that
> > is a big problem if we decide to go by this path.
>
> Right it should work but could break for example if we ever decide
> to change the exported state structure for ghash and someone unloads
> the ghash-generic module and reloads a new one.
>
Great! If we check the descsize every time a fallback tfm is allocated
that should be enough to prevent bigger problems such as memory
corruptions.
> > That would be nice because it would allow p8_ghash to keep using a
> > dynamic fallback, but I'm not that is viable. What do you think?
>
> We did it for SHA because it was desirable to have multiple
> fallbacks, i.e., a generic C version plus an assembly-optimised
> version.
>
> Not sure whether the same motiviation exists for GHASH.
>
> > > Otherwise we can go back to allocating just ghash-generic and
> > > also move its data structure into an exported header file.
> > >
> >
> > That would make the fix much more simple and it wouldn't require to get
> > the fallback descsize at runtime.
>
> This is the easiest fix so let's go with this now. If we ever
> care enough to have multiple fallbacks for GHASH we can always
> revisit this. The exported format is not exposed to user-space
> so it can always be changed.
Can I move ghash_desc_ctx to a header file under include/crypto/? Or do
you do you prefer to do that?
Maybe include/crypto/internal/hash.h or a new header file
include/crypto/internal/ghash.h ?
>
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Herbert Xu @ 2016-09-28 13:09 UTC (permalink / raw)
To: Marcelo Cerri
Cc: Jan Stancek, rui y wang, mhcerri, leosilva, pfsmorigo,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928125558.GE15729@gallifrey>
On Wed, Sep 28, 2016 at 09:55:58AM -0300, Marcelo Cerri wrote:
>
> Great! If we check the descsize every time a fallback tfm is allocated
> that should be enough to prevent bigger problems such as memory
> corruptions.
Yes a check wouldn't hurt.
> Can I move ghash_desc_ctx to a header file under include/crypto/? Or do
> you do you prefer to do that?
No you can go ahead and do the move.
> Maybe include/crypto/internal/hash.h or a new header file
> include/crypto/internal/ghash.h ?
Let's put it in include/crypto/ghash.h.
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
* Re: [PATCH] crypto: sha1-powerpc: little-endian support
From: Marcelo Cerri @ 2016-09-28 13:15 UTC (permalink / raw)
To: Herbert Xu
Cc: linux-crypto, linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Claudio Carvalho,
Paulo Flabiano Smorigo, joy.latten, David S. Miller
In-Reply-To: <1474659116-4689-1-git-send-email-marcelo.cerri@canonical.com>
[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]
Hi Herbert,
Any thoughts on this one?
--
Regards,
Marcelo
On Fri, Sep 23, 2016 at 04:31:56PM -0300, Marcelo Cerri wrote:
> The driver does not handle endianness properly when loading the input
> data.
>
> Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
> ---
> arch/powerpc/crypto/sha1-powerpc-asm.S | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/crypto/sha1-powerpc-asm.S b/arch/powerpc/crypto/sha1-powerpc-asm.S
> index 125e165..82ddc9b 100644
> --- a/arch/powerpc/crypto/sha1-powerpc-asm.S
> +++ b/arch/powerpc/crypto/sha1-powerpc-asm.S
> @@ -7,6 +7,15 @@
> #include <asm/ppc_asm.h>
> #include <asm/asm-offsets.h>
>
> +#ifdef __BIG_ENDIAN__
> +#define LWZ(rt, d, ra) \
> + lwz rt,d(ra)
> +#else
> +#define LWZ(rt, d, ra) \
> + li rt,d; \
> + lwbrx rt,rt,ra
> +#endif
> +
> /*
> * We roll the registers for T, A, B, C, D, E around on each
> * iteration; T on iteration t is A on iteration t+1, and so on.
> @@ -23,7 +32,7 @@
> #define W(t) (((t)%16)+16)
>
> #define LOADW(t) \
> - lwz W(t),(t)*4(r4)
> + LWZ(W(t),(t)*4,r4)
>
> #define STEPD0_LOAD(t) \
> andc r0,RD(t),RB(t); \
> @@ -33,7 +42,7 @@
> add r0,RE(t),r15; \
> add RT(t),RT(t),r6; \
> add r14,r0,W(t); \
> - lwz W((t)+4),((t)+4)*4(r4); \
> + LWZ(W((t)+4),((t)+4)*4,r4); \
> rotlwi RB(t),RB(t),30; \
> add RT(t),RT(t),r14
>
> --
> 2.7.4
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply
* Re: [PATCH] crypto: sha1-powerpc: little-endian support
From: Herbert Xu @ 2016-09-28 13:20 UTC (permalink / raw)
To: Marcelo Cerri
Cc: linux-crypto, linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Claudio Carvalho,
Paulo Flabiano Smorigo, joy.latten, David S. Miller
In-Reply-To: <20160928131551.GA31082@gallifrey>
On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
> Hi Herbert,
>
> Any thoughts on this one?
Can this patch wait until the next merge window? On the broken
platforms it should just fail the self-test, right?
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
* Re: [bug] crypto/vmx/p8_ghash memory corruption in 4.8-rc7
From: Paulo Flabiano Smorigo @ 2016-09-28 13:22 UTC (permalink / raw)
To: Herbert Xu
Cc: Marcelo Cerri, Jan Stancek, rui y wang, mhcerri, leosilva,
linux-crypto, linuxppc-dev, linux-kernel
In-Reply-To: <20160928123318.GB20839@gondor.apana.org.au>
Wed, Sep 28, 2016 at 08:33:18PM +0800, Herbert Xu wrote:
> On Wed, Sep 28, 2016 at 09:28:44AM -0300, Marcelo Cerri wrote:
> >
> > The big difference between p8_ghash and padlock_sha1 is that
> > padlock_sha1 defines alg->statesize as sizeof(struct sha1_state), which
> > is the descsize value used by sha1_generic. This probably works but
> > it's also wrong because the padlock_sha1 driver does not ensures that
> > sha1_generic is always used.
>
> It should work because all our SHA implementations use the same
> export format. This is not necessarily the case for GHASH though.
>
> > So, one solution is to hardcode ghash-generic as the fallback algorithm
> > and update the descsize direct in its shash_alg structure. There's only
> > one problem with that. ghash-generic desc type (struct ghash_desc_ctx)
> > is not available for vmx_crypto at compile type, the type is defined
> > directly in crypto/ghash-generic.c. That's the reason I added a function
> > to get the fallback desc size at runtime in the patch I wrote as a prove
> > of concept.
>
> The problem with your patch is that there is no guarantee that
> you will get the same algorithm every time you allocate a fallback.
> Someone may have loaded a new module for example.
>
> So I think the safe approach is to stick with ghash-generic and
> expose its state data structure in a header file.
Since generic is the only posible fallback for ppc, I think that's a
good solution. :)
>
> 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
>
--
Paulo Flabiano Smorigo
IBM Linux Technology Center
^ permalink raw reply
* Re: [PATCH] crypto: sha1-powerpc: little-endian support
From: Marcelo Cerri @ 2016-09-28 13:27 UTC (permalink / raw)
To: Herbert Xu
Cc: linux-crypto, linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Claudio Carvalho,
Paulo Flabiano Smorigo, joy.latten, David S. Miller
In-Reply-To: <20160928132015.GA21312@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 586 bytes --]
On Wed, Sep 28, 2016 at 09:20:15PM +0800, Herbert Xu wrote:
> On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
> > Hi Herbert,
> >
> > Any thoughts on this one?
>
> Can this patch wait until the next merge window? On the broken
> platforms it should just fail the self-test, right?
Yes. It fails on any LE platform (including Ubuntu and RHEL 7.1).
>
> 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
--
Regards,
Marcelo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply
* [PATCH] crypto: testmgr - add guard to dst buffer for ahash_export
From: Jan Stancek @ 2016-09-28 14:38 UTC (permalink / raw)
To: linux-crypto, herbert; +Cc: linux-kernel, marcelo.cerri, jstancek
Add a guard to 'state' buffer and warn if its consistency after
call to crypto_ahash_export() changes, so that any write that
goes beyond advertised statesize (and thus causing potential
memory corruption [1]) is more visible.
[1] https://marc.info/?l=linux-crypto-vger&m=147467656516085
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Marcelo Cerri <marcelo.cerri@canonical.com>
---
crypto/testmgr.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 5c9d5a5e7b65..96343bcae01e 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -209,16 +209,19 @@ static int ahash_partial_update(struct ahash_request **preq,
char *state;
struct ahash_request *req;
int statesize, ret = -EINVAL;
+ const char guard[] = { 0x00, 0xba, 0xad, 0x00 };
req = *preq;
statesize = crypto_ahash_statesize(
crypto_ahash_reqtfm(req));
- state = kmalloc(statesize, GFP_KERNEL);
+ state = kmalloc(statesize + sizeof(guard), GFP_KERNEL);
if (!state) {
pr_err("alt: hash: Failed to alloc state for %s\n", algo);
goto out_nostate;
}
+ memcpy(state + statesize, guard, sizeof(guard));
ret = crypto_ahash_export(req, state);
+ WARN_ON(memcmp(state + statesize, guard, sizeof(guard)));
if (ret) {
pr_err("alt: hash: Failed to export() for %s\n", algo);
goto out;
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/2] crypto: ccp - Improve info reported when an error occurs
From: Gary R Hook @ 2016-09-28 15:49 UTC (permalink / raw)
To: linux-crypto; +Cc: thomas.lendacky, herbert, davem
In-Reply-To: <20160928154921.22138.76929.stgit@taos>
Add human readable strings to log messages about CCP errors
Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
drivers/crypto/ccp/ccp-dev-v3.c | 3 ++
drivers/crypto/ccp/ccp-dev-v5.c | 3 ++
drivers/crypto/ccp/ccp-dev.c | 53 +++++++++++++++++++++++++++++++++++++++
drivers/crypto/ccp/ccp-dev.h | 2 +
4 files changed, 61 insertions(+)
diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c
index b6615b1..8d2dbac 100644
--- a/drivers/crypto/ccp/ccp-dev-v3.c
+++ b/drivers/crypto/ccp/ccp-dev-v3.c
@@ -124,6 +124,9 @@ static int ccp_do_cmd(struct ccp_op *op, u32 *cr, unsigned int cr_count)
/* On error delete all related jobs from the queue */
cmd = (cmd_q->id << DEL_Q_ID_SHIFT)
| op->jobid;
+ if (cmd_q->cmd_error)
+ ccp_log_error(cmd_q->ccp,
+ cmd_q->cmd_error);
iowrite32(cmd, ccp->io_regs + DEL_CMD_Q_JOB);
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index a90ca9e..faf3cb3 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -243,6 +243,9 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
ret = wait_event_interruptible(cmd_q->int_queue,
cmd_q->int_rcvd);
if (ret || cmd_q->cmd_error) {
+ if (cmd_q->cmd_error)
+ ccp_log_error(cmd_q->ccp,
+ cmd_q->cmd_error);
/* A version 5 device doesn't use Job IDs... */
if (!ret)
ret = -EIO;
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index 38a98d8..d9885ce 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -40,6 +40,59 @@ struct ccp_tasklet_data {
struct ccp_cmd *cmd;
};
+/* Human-readable error strings */
+char *ccp_error_codes[] = {
+ "",
+ "ERR 01: ILLEGAL_ENGINE",
+ "ERR 02: ILLEGAL_KEY_ID",
+ "ERR 03: ILLEGAL_FUNCTION_TYPE",
+ "ERR 04: ILLEGAL_FUNCTION_MODE",
+ "ERR 05: ILLEGAL_FUNCTION_ENCRYPT",
+ "ERR 06: ILLEGAL_FUNCTION_SIZE",
+ "ERR 07: Zlib_MISSING_INIT_EOM",
+ "ERR 08: ILLEGAL_FUNCTION_RSVD",
+ "ERR 09: ILLEGAL_BUFFER_LENGTH",
+ "ERR 10: VLSB_FAULT",
+ "ERR 11: ILLEGAL_MEM_ADDR",
+ "ERR 12: ILLEGAL_MEM_SEL",
+ "ERR 13: ILLEGAL_CONTEXT_ID",
+ "ERR 14: ILLEGAL_KEY_ADDR",
+ "ERR 15: 0xF Reserved",
+ "ERR 16: Zlib_ILLEGAL_MULTI_QUEUE",
+ "ERR 17: Zlib_ILLEGAL_JOBID_CHANGE",
+ "ERR 18: CMD_TIMEOUT",
+ "ERR 19: IDMA0_AXI_SLVERR",
+ "ERR 20: IDMA0_AXI_DECERR",
+ "ERR 21: 0x15 Reserved",
+ "ERR 22: IDMA1_AXI_SLAVE_FAULT",
+ "ERR 23: IDMA1_AIXI_DECERR",
+ "ERR 24: 0x18 Reserved",
+ "ERR 25: ZLIBVHB_AXI_SLVERR",
+ "ERR 26: ZLIBVHB_AXI_DECERR",
+ "ERR 27: 0x1B Reserved",
+ "ERR 27: ZLIB_UNEXPECTED_EOM",
+ "ERR 27: ZLIB_EXTRA_DATA",
+ "ERR 30: ZLIB_BTYPE",
+ "ERR 31: ZLIB_UNDEFINED_SYMBOL",
+ "ERR 32: ZLIB_UNDEFINED_DISTANCE_S",
+ "ERR 33: ZLIB_CODE_LENGTH_SYMBOL",
+ "ERR 34: ZLIB _VHB_ILLEGAL_FETCH",
+ "ERR 35: ZLIB_UNCOMPRESSED_LEN",
+ "ERR 36: ZLIB_LIMIT_REACHED",
+ "ERR 37: ZLIB_CHECKSUM_MISMATCH0",
+ "ERR 38: ODMA0_AXI_SLVERR",
+ "ERR 39: ODMA0_AXI_DECERR",
+ "ERR 40: 0x28 Reserved",
+ "ERR 41: ODMA1_AXI_SLVERR",
+ "ERR 42: ODMA1_AXI_DECERR",
+ "ERR 43: LSB_PARITY_ERR",
+};
+
+void ccp_log_error(struct ccp_device *d, int e)
+{
+ dev_err(d->dev, "CCP error: %s (0x%x)\n", ccp_error_codes[e], e);
+}
+
/* List of CCPs, CCP count, read-write access lock, and access functions
*
* Lock structure: get ccp_unit_lock for reading whenever we need to
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 08f58b0..da5f4a6 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -601,6 +601,8 @@ void ccp_platform_exit(void);
void ccp_add_device(struct ccp_device *ccp);
void ccp_del_device(struct ccp_device *ccp);
+extern void ccp_log_error(struct ccp_device *, int);
+
struct ccp_device *ccp_alloc_struct(struct device *dev);
bool ccp_queues_suspended(struct ccp_device *ccp);
int ccp_cmd_queue_thread(void *data);
^ permalink raw reply related
* Re: [PATCH 1/2] crypto: ccp - data structure cleanup
From: Tom Lendacky @ 2016-09-28 16:23 UTC (permalink / raw)
To: Gary R Hook, linux-crypto; +Cc: herbert, davem
In-Reply-To: <20160928154921.22138.76929.stgit@taos>
On 09/28/2016 10:49 AM, Gary R Hook wrote:
> Change names of data structure instances; add const
> keyword where appropriate.
>
> Signed-off-by: Gary R Hook <gary.hook@amd.com>
> ---
> drivers/crypto/ccp/ccp-dev-v3.c | 2 +-
> drivers/crypto/ccp/ccp-dev-v5.c | 7 +++++--
> drivers/crypto/ccp/ccp-dev.h | 6 +++---
> drivers/crypto/ccp/ccp-pci.c | 4 ++--
> 4 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c
> index 578522d..b6615b1 100644
> --- a/drivers/crypto/ccp/ccp-dev-v3.c
> +++ b/drivers/crypto/ccp/ccp-dev-v3.c
> @@ -566,7 +566,7 @@ static const struct ccp_actions ccp3_actions = {
> .irqhandler = ccp_irq_handler,
> };
>
> -struct ccp_vdata ccpv3 = {
> +const struct ccp_vdata ccpv3 = {
> .version = CCP_VERSION(3, 0),
> .setup = NULL,
> .perform = &ccp3_actions,
> diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
> index 9df1526..a90ca9e 100644
> --- a/drivers/crypto/ccp/ccp-dev-v5.c
> +++ b/drivers/crypto/ccp/ccp-dev-v5.c
> @@ -839,6 +839,9 @@ static int ccp5_init(struct ccp_device *ccp)
>
> return 0;
>
> +e_hwrng:
> + ccp_unregister_rng(ccp);
> +
This label has been added but is never used. I assume that you wanted
to put a goto e_hwrng if ccp_dmaengine_register() fails.
Thanks,
Tom
> e_kthread:
> for (i = 0; i < ccp->cmd_q_count; i++)
> if (ccp->cmd_q[i].kthread)
> @@ -994,7 +997,7 @@ static const struct ccp_actions ccp5_actions = {
> .irqhandler = ccp5_irq_handler,
> };
>
> -struct ccp_vdata ccpv5 = {
> +const struct ccp_vdata ccpv5a = {
> .version = CCP_VERSION(5, 0),
> .setup = ccp5_config,
> .perform = &ccp5_actions,
> @@ -1002,7 +1005,7 @@ struct ccp_vdata ccpv5 = {
> .offset = 0x0,
> };
>
> -struct ccp_vdata ccpv5other = {
> +const struct ccp_vdata ccpv5b = {
> .version = CCP_VERSION(5, 0),
> .setup = ccp5other_config,
> .perform = &ccp5_actions,
> diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
> index ebc9365..08f58b0 100644
> --- a/drivers/crypto/ccp/ccp-dev.h
> +++ b/drivers/crypto/ccp/ccp-dev.h
> @@ -639,8 +639,8 @@ struct ccp_vdata {
> const unsigned int offset;
> };
>
> -extern struct ccp_vdata ccpv3;
> -extern struct ccp_vdata ccpv5;
> -extern struct ccp_vdata ccpv5other;
> +extern const struct ccp_vdata ccpv3;
> +extern const struct ccp_vdata ccpv5a;
> +extern const struct ccp_vdata ccpv5b;
>
> #endif
> diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c
> index 239cbf2..28a9996 100644
> --- a/drivers/crypto/ccp/ccp-pci.c
> +++ b/drivers/crypto/ccp/ccp-pci.c
> @@ -325,8 +325,8 @@ static int ccp_pci_resume(struct pci_dev *pdev)
>
> static const struct pci_device_id ccp_pci_table[] = {
> { PCI_VDEVICE(AMD, 0x1537), (kernel_ulong_t)&ccpv3 },
> - { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5 },
> - { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5other },
> + { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5a },
> + { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5b },
> /* Last entry must be zero */
> { 0, }
> };
>
^ permalink raw reply
* [PATCH 0/3] Fix crypto/vmx/p8_ghash memory corruption
From: Marcelo Cerri @ 2016-09-28 16:42 UTC (permalink / raw)
To: linux-crypto, Herbert Xu
Cc: David S. Miller, Paulo Flabiano Smorigo, Leonidas S. Barbosa,
linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Marcelo Cerri
This series fixes the memory corruption found by Jan Stancek in 4.8-rc7. The
problem however also affects previous versions of the driver.
Marcelo Cerri (3):
crypto: ghash-generic - move common definitions to a new header file
crypto: vmx - Fix memory corruption caused by p8_ghash
crypto: vmx - Ensure ghash-generic is enabled
crypto/ghash-generic.c | 13 +------------
drivers/crypto/vmx/Kconfig | 2 +-
drivers/crypto/vmx/ghash.c | 31 ++++++++++++++++---------------
include/crypto/ghash.h | 23 +++++++++++++++++++++++
4 files changed, 41 insertions(+), 28 deletions(-)
create mode 100644 include/crypto/ghash.h
--
2.7.4
^ permalink raw reply
* [PATCH 1/3] crypto: ghash-generic - move common definitions to a new header file
From: Marcelo Cerri @ 2016-09-28 16:42 UTC (permalink / raw)
To: linux-crypto, Herbert Xu
Cc: David S. Miller, Paulo Flabiano Smorigo, Leonidas S. Barbosa,
linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Marcelo Cerri
In-Reply-To: <1475080931-7926-1-git-send-email-marcelo.cerri@canonical.com>
Move common values and types used by ghash-generic to a new header file
so drivers can directly use ghash-generic as a fallback implementation.
Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
---
crypto/ghash-generic.c | 13 +------------
include/crypto/ghash.h | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 12 deletions(-)
create mode 100644 include/crypto/ghash.h
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index bac7099..12ad3e3 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -14,24 +14,13 @@
#include <crypto/algapi.h>
#include <crypto/gf128mul.h>
+#include <crypto/ghash.h>
#include <crypto/internal/hash.h>
#include <linux/crypto.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#define GHASH_BLOCK_SIZE 16
-#define GHASH_DIGEST_SIZE 16
-
-struct ghash_ctx {
- struct gf128mul_4k *gf128;
-};
-
-struct ghash_desc_ctx {
- u8 buffer[GHASH_BLOCK_SIZE];
- u32 bytes;
-};
-
static int ghash_init(struct shash_desc *desc)
{
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
diff --git a/include/crypto/ghash.h b/include/crypto/ghash.h
new file mode 100644
index 0000000..2a61c9b
--- /dev/null
+++ b/include/crypto/ghash.h
@@ -0,0 +1,23 @@
+/*
+ * Common values for GHASH algorithms
+ */
+
+#ifndef __CRYPTO_GHASH_H__
+#define __CRYPTO_GHASH_H__
+
+#include <linux/types.h>
+#include <crypto/gf128mul.h>
+
+#define GHASH_BLOCK_SIZE 16
+#define GHASH_DIGEST_SIZE 16
+
+struct ghash_ctx {
+ struct gf128mul_4k *gf128;
+};
+
+struct ghash_desc_ctx {
+ u8 buffer[GHASH_BLOCK_SIZE];
+ u32 bytes;
+};
+
+#endif
--
2.7.4
^ permalink raw reply related
* [PATCH 2/3] crypto: vmx - Fix memory corruption caused by p8_ghash
From: Marcelo Cerri @ 2016-09-28 16:42 UTC (permalink / raw)
To: linux-crypto, Herbert Xu
Cc: David S. Miller, Paulo Flabiano Smorigo, Leonidas S. Barbosa,
linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Marcelo Cerri
In-Reply-To: <1475080931-7926-1-git-send-email-marcelo.cerri@canonical.com>
This patch changes the p8_ghash driver to use ghash-generic as a fixed
fallback implementation. This allows the correct value of descsize to be
defined directly in its shash_alg structure and avoids problems with
incorrect buffer sizes when its state is exported or imported.
Reported-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
---
drivers/crypto/vmx/ghash.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/crypto/vmx/ghash.c b/drivers/crypto/vmx/ghash.c
index 6c999cb0..27a94a1 100644
--- a/drivers/crypto/vmx/ghash.c
+++ b/drivers/crypto/vmx/ghash.c
@@ -26,16 +26,13 @@
#include <linux/hardirq.h>
#include <asm/switch_to.h>
#include <crypto/aes.h>
+#include <crypto/ghash.h>
#include <crypto/scatterwalk.h>
#include <crypto/internal/hash.h>
#include <crypto/b128ops.h>
#define IN_INTERRUPT in_interrupt()
-#define GHASH_BLOCK_SIZE (16)
-#define GHASH_DIGEST_SIZE (16)
-#define GHASH_KEY_LEN (16)
-
void gcm_init_p8(u128 htable[16], const u64 Xi[2]);
void gcm_gmult_p8(u64 Xi[2], const u128 htable[16]);
void gcm_ghash_p8(u64 Xi[2], const u128 htable[16],
@@ -55,16 +52,11 @@ struct p8_ghash_desc_ctx {
static int p8_ghash_init_tfm(struct crypto_tfm *tfm)
{
- const char *alg;
+ const char *alg = "ghash-generic";
struct crypto_shash *fallback;
struct crypto_shash *shash_tfm = __crypto_shash_cast(tfm);
struct p8_ghash_ctx *ctx = crypto_tfm_ctx(tfm);
- if (!(alg = crypto_tfm_alg_name(tfm))) {
- printk(KERN_ERR "Failed to get algorithm name.\n");
- return -ENOENT;
- }
-
fallback = crypto_alloc_shash(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback)) {
printk(KERN_ERR
@@ -78,10 +70,18 @@ static int p8_ghash_init_tfm(struct crypto_tfm *tfm)
crypto_shash_set_flags(fallback,
crypto_shash_get_flags((struct crypto_shash
*) tfm));
- ctx->fallback = fallback;
- shash_tfm->descsize = sizeof(struct p8_ghash_desc_ctx)
- + crypto_shash_descsize(fallback);
+ /* Check if the descsize defined in the algorithm is still enough. */
+ if (shash_tfm->descsize < sizeof(struct p8_ghash_desc_ctx)
+ + crypto_shash_descsize(fallback)) {
+ printk(KERN_ERR
+ "Desc size of the fallback implementation (%s) does not match the expected value: %lu vs %u\n",
+ alg,
+ shash_tfm->descsize - sizeof(struct p8_ghash_desc_ctx),
+ crypto_shash_descsize(fallback));
+ return -EINVAL;
+ }
+ ctx->fallback = fallback;
return 0;
}
@@ -113,7 +113,7 @@ static int p8_ghash_setkey(struct crypto_shash *tfm, const u8 *key,
{
struct p8_ghash_ctx *ctx = crypto_tfm_ctx(crypto_shash_tfm(tfm));
- if (keylen != GHASH_KEY_LEN)
+ if (keylen != GHASH_BLOCK_SIZE)
return -EINVAL;
preempt_disable();
@@ -211,7 +211,8 @@ struct shash_alg p8_ghash_alg = {
.update = p8_ghash_update,
.final = p8_ghash_final,
.setkey = p8_ghash_setkey,
- .descsize = sizeof(struct p8_ghash_desc_ctx),
+ .descsize = sizeof(struct p8_ghash_desc_ctx)
+ + sizeof(struct ghash_desc_ctx),
.base = {
.cra_name = "ghash",
.cra_driver_name = "p8_ghash",
--
2.7.4
^ permalink raw reply related
* [PATCH 3/3] crypto: vmx - Ensure ghash-generic is enabled
From: Marcelo Cerri @ 2016-09-28 16:42 UTC (permalink / raw)
To: linux-crypto, Herbert Xu
Cc: David S. Miller, Paulo Flabiano Smorigo, Leonidas S. Barbosa,
linuxppc-dev, linux-kernel, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, George Wilson, Marcelo Cerri
In-Reply-To: <1475080931-7926-1-git-send-email-marcelo.cerri@canonical.com>
Add CRYPTO_GHASH as a dependency for vmx_crypto since p8_ghash uses it
as the fallback implementation.
Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
---
drivers/crypto/vmx/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/vmx/Kconfig b/drivers/crypto/vmx/Kconfig
index a83ead1..c21b09a 100644
--- a/drivers/crypto/vmx/Kconfig
+++ b/drivers/crypto/vmx/Kconfig
@@ -1,6 +1,6 @@
config CRYPTO_DEV_VMX_ENCRYPT
tristate "Encryption acceleration support on P8 CPU"
- depends on CRYPTO_DEV_VMX
+ depends on CRYPTO_DEV_VMX || CRYPTO_GHASH
default m
help
Support for VMX cryptographic acceleration instructions on Power8 CPU.
--
2.7.4
^ permalink raw reply related
* [PATCH v2 1/2] crypto: ccp - clean up data structure
From: Gary R Hook @ 2016-09-28 16:53 UTC (permalink / raw)
To: linux-crypto; +Cc: thomas.lendacky, herbert, davem
In-Reply-To: <20160928165204.23263.77515.stgit@taos>
Change names of data structure instances. Add const
keyword where appropriate. Add error handling path.
Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
drivers/crypto/ccp/ccp-dev-v3.c | 2 +-
drivers/crypto/ccp/ccp-dev-v5.c | 9 ++++++---
drivers/crypto/ccp/ccp-dev.h | 6 +++---
drivers/crypto/ccp/ccp-pci.c | 4 ++--
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c
index 578522d..b6615b1 100644
--- a/drivers/crypto/ccp/ccp-dev-v3.c
+++ b/drivers/crypto/ccp/ccp-dev-v3.c
@@ -566,7 +566,7 @@ static const struct ccp_actions ccp3_actions = {
.irqhandler = ccp_irq_handler,
};
-struct ccp_vdata ccpv3 = {
+const struct ccp_vdata ccpv3 = {
.version = CCP_VERSION(3, 0),
.setup = NULL,
.perform = &ccp3_actions,
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index f499e34..a90ca9e 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -835,10 +835,13 @@ static int ccp5_init(struct ccp_device *ccp)
/* Register the DMA engine support */
ret = ccp_dmaengine_register(ccp);
if (ret)
- goto e_kthread;
+ goto e_hwrng;
return 0;
+e_hwrng:
+ ccp_unregister_rng(ccp);
+
e_kthread:
for (i = 0; i < ccp->cmd_q_count; i++)
if (ccp->cmd_q[i].kthread)
@@ -994,7 +997,7 @@ static const struct ccp_actions ccp5_actions = {
.irqhandler = ccp5_irq_handler,
};
-struct ccp_vdata ccpv5 = {
+const struct ccp_vdata ccpv5a = {
.version = CCP_VERSION(5, 0),
.setup = ccp5_config,
.perform = &ccp5_actions,
@@ -1002,7 +1005,7 @@ struct ccp_vdata ccpv5 = {
.offset = 0x0,
};
-struct ccp_vdata ccpv5other = {
+const struct ccp_vdata ccpv5b = {
.version = CCP_VERSION(5, 0),
.setup = ccp5other_config,
.perform = &ccp5_actions,
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index ebc9365..08f58b0 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -639,8 +639,8 @@ struct ccp_vdata {
const unsigned int offset;
};
-extern struct ccp_vdata ccpv3;
-extern struct ccp_vdata ccpv5;
-extern struct ccp_vdata ccpv5other;
+extern const struct ccp_vdata ccpv3;
+extern const struct ccp_vdata ccpv5a;
+extern const struct ccp_vdata ccpv5b;
#endif
diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c
index 239cbf2..28a9996 100644
--- a/drivers/crypto/ccp/ccp-pci.c
+++ b/drivers/crypto/ccp/ccp-pci.c
@@ -325,8 +325,8 @@ static int ccp_pci_resume(struct pci_dev *pdev)
static const struct pci_device_id ccp_pci_table[] = {
{ PCI_VDEVICE(AMD, 0x1537), (kernel_ulong_t)&ccpv3 },
- { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5 },
- { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5other },
+ { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5a },
+ { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5b },
/* Last entry must be zero */
{ 0, }
};
^ permalink raw reply related
* [PATCH v2 0/2] Minor CCP driver changes
From: Gary R Hook @ 2016-09-28 16:53 UTC (permalink / raw)
To: linux-crypto; +Cc: thomas.lendacky, herbert, davem
V2: point a goto statement at the correct label
The following series is for miscellaneous small changes.
---
Gary R Hook (2):
crypto: ccp - clean up data structure
crypto: ccp - Make syslog errors human-readable
drivers/crypto/ccp/ccp-dev-v3.c | 5 +++-
drivers/crypto/ccp/ccp-dev-v5.c | 12 +++++++--
drivers/crypto/ccp/ccp-dev.c | 53 +++++++++++++++++++++++++++++++++++++++
drivers/crypto/ccp/ccp-dev.h | 8 ++++--
drivers/crypto/ccp/ccp-pci.c | 4 +--
5 files changed, 73 insertions(+), 9 deletions(-)
--
^ permalink raw reply
* [PATCH v2 2/2] crypto: ccp - Make syslog errors human-readable
From: Gary R Hook @ 2016-09-28 16:53 UTC (permalink / raw)
To: linux-crypto; +Cc: thomas.lendacky, herbert, davem
In-Reply-To: <20160928165204.23263.77515.stgit@taos>
Add human-readable strings to log messages about CCP errors
Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
drivers/crypto/ccp/ccp-dev-v3.c | 3 ++
drivers/crypto/ccp/ccp-dev-v5.c | 3 ++
drivers/crypto/ccp/ccp-dev.c | 53 +++++++++++++++++++++++++++++++++++++++
drivers/crypto/ccp/ccp-dev.h | 2 +
4 files changed, 61 insertions(+)
diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c
index b6615b1..8d2dbac 100644
--- a/drivers/crypto/ccp/ccp-dev-v3.c
+++ b/drivers/crypto/ccp/ccp-dev-v3.c
@@ -124,6 +124,9 @@ static int ccp_do_cmd(struct ccp_op *op, u32 *cr, unsigned int cr_count)
/* On error delete all related jobs from the queue */
cmd = (cmd_q->id << DEL_Q_ID_SHIFT)
| op->jobid;
+ if (cmd_q->cmd_error)
+ ccp_log_error(cmd_q->ccp,
+ cmd_q->cmd_error);
iowrite32(cmd, ccp->io_regs + DEL_CMD_Q_JOB);
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index a90ca9e..faf3cb3 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -243,6 +243,9 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,
ret = wait_event_interruptible(cmd_q->int_queue,
cmd_q->int_rcvd);
if (ret || cmd_q->cmd_error) {
+ if (cmd_q->cmd_error)
+ ccp_log_error(cmd_q->ccp,
+ cmd_q->cmd_error);
/* A version 5 device doesn't use Job IDs... */
if (!ret)
ret = -EIO;
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index 5d36eef..cafa633 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -40,6 +40,59 @@ struct ccp_tasklet_data {
struct ccp_cmd *cmd;
};
+/* Human-readable error strings */
+char *ccp_error_codes[] = {
+ "",
+ "ERR 01: ILLEGAL_ENGINE",
+ "ERR 02: ILLEGAL_KEY_ID",
+ "ERR 03: ILLEGAL_FUNCTION_TYPE",
+ "ERR 04: ILLEGAL_FUNCTION_MODE",
+ "ERR 05: ILLEGAL_FUNCTION_ENCRYPT",
+ "ERR 06: ILLEGAL_FUNCTION_SIZE",
+ "ERR 07: Zlib_MISSING_INIT_EOM",
+ "ERR 08: ILLEGAL_FUNCTION_RSVD",
+ "ERR 09: ILLEGAL_BUFFER_LENGTH",
+ "ERR 10: VLSB_FAULT",
+ "ERR 11: ILLEGAL_MEM_ADDR",
+ "ERR 12: ILLEGAL_MEM_SEL",
+ "ERR 13: ILLEGAL_CONTEXT_ID",
+ "ERR 14: ILLEGAL_KEY_ADDR",
+ "ERR 15: 0xF Reserved",
+ "ERR 16: Zlib_ILLEGAL_MULTI_QUEUE",
+ "ERR 17: Zlib_ILLEGAL_JOBID_CHANGE",
+ "ERR 18: CMD_TIMEOUT",
+ "ERR 19: IDMA0_AXI_SLVERR",
+ "ERR 20: IDMA0_AXI_DECERR",
+ "ERR 21: 0x15 Reserved",
+ "ERR 22: IDMA1_AXI_SLAVE_FAULT",
+ "ERR 23: IDMA1_AIXI_DECERR",
+ "ERR 24: 0x18 Reserved",
+ "ERR 25: ZLIBVHB_AXI_SLVERR",
+ "ERR 26: ZLIBVHB_AXI_DECERR",
+ "ERR 27: 0x1B Reserved",
+ "ERR 27: ZLIB_UNEXPECTED_EOM",
+ "ERR 27: ZLIB_EXTRA_DATA",
+ "ERR 30: ZLIB_BTYPE",
+ "ERR 31: ZLIB_UNDEFINED_SYMBOL",
+ "ERR 32: ZLIB_UNDEFINED_DISTANCE_S",
+ "ERR 33: ZLIB_CODE_LENGTH_SYMBOL",
+ "ERR 34: ZLIB _VHB_ILLEGAL_FETCH",
+ "ERR 35: ZLIB_UNCOMPRESSED_LEN",
+ "ERR 36: ZLIB_LIMIT_REACHED",
+ "ERR 37: ZLIB_CHECKSUM_MISMATCH0",
+ "ERR 38: ODMA0_AXI_SLVERR",
+ "ERR 39: ODMA0_AXI_DECERR",
+ "ERR 40: 0x28 Reserved",
+ "ERR 41: ODMA1_AXI_SLVERR",
+ "ERR 42: ODMA1_AXI_DECERR",
+ "ERR 43: LSB_PARITY_ERR",
+};
+
+void ccp_log_error(struct ccp_device *d, int e)
+{
+ dev_err(d->dev, "CCP error: %s (0x%x)\n", ccp_error_codes[e], e);
+}
+
/* List of CCPs, CCP count, read-write access lock, and access functions
*
* Lock structure: get ccp_unit_lock for reading whenever we need to
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 08f58b0..da5f4a6 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -601,6 +601,8 @@ void ccp_platform_exit(void);
void ccp_add_device(struct ccp_device *ccp);
void ccp_del_device(struct ccp_device *ccp);
+extern void ccp_log_error(struct ccp_device *, int);
+
struct ccp_device *ccp_alloc_struct(struct device *dev);
bool ccp_queues_suspended(struct ccp_device *ccp);
int ccp_cmd_queue_thread(void *data);
^ permalink raw reply related
* [PATCH 1/2] crypto: ccp - data structure cleanup
From: Gary R Hook @ 2016-09-28 15:49 UTC (permalink / raw)
To: linux-crypto; +Cc: thomas.lendacky, herbert, davem
Change names of data structure instances; add const
keyword where appropriate.
Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
drivers/crypto/ccp/ccp-dev-v3.c | 2 +-
drivers/crypto/ccp/ccp-dev-v5.c | 7 +++++--
drivers/crypto/ccp/ccp-dev.h | 6 +++---
drivers/crypto/ccp/ccp-pci.c | 4 ++--
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c
index 578522d..b6615b1 100644
--- a/drivers/crypto/ccp/ccp-dev-v3.c
+++ b/drivers/crypto/ccp/ccp-dev-v3.c
@@ -566,7 +566,7 @@ static const struct ccp_actions ccp3_actions = {
.irqhandler = ccp_irq_handler,
};
-struct ccp_vdata ccpv3 = {
+const struct ccp_vdata ccpv3 = {
.version = CCP_VERSION(3, 0),
.setup = NULL,
.perform = &ccp3_actions,
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index 9df1526..a90ca9e 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -839,6 +839,9 @@ static int ccp5_init(struct ccp_device *ccp)
return 0;
+e_hwrng:
+ ccp_unregister_rng(ccp);
+
e_kthread:
for (i = 0; i < ccp->cmd_q_count; i++)
if (ccp->cmd_q[i].kthread)
@@ -994,7 +997,7 @@ static const struct ccp_actions ccp5_actions = {
.irqhandler = ccp5_irq_handler,
};
-struct ccp_vdata ccpv5 = {
+const struct ccp_vdata ccpv5a = {
.version = CCP_VERSION(5, 0),
.setup = ccp5_config,
.perform = &ccp5_actions,
@@ -1002,7 +1005,7 @@ struct ccp_vdata ccpv5 = {
.offset = 0x0,
};
-struct ccp_vdata ccpv5other = {
+const struct ccp_vdata ccpv5b = {
.version = CCP_VERSION(5, 0),
.setup = ccp5other_config,
.perform = &ccp5_actions,
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index ebc9365..08f58b0 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -639,8 +639,8 @@ struct ccp_vdata {
const unsigned int offset;
};
-extern struct ccp_vdata ccpv3;
-extern struct ccp_vdata ccpv5;
-extern struct ccp_vdata ccpv5other;
+extern const struct ccp_vdata ccpv3;
+extern const struct ccp_vdata ccpv5a;
+extern const struct ccp_vdata ccpv5b;
#endif
diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c
index 239cbf2..28a9996 100644
--- a/drivers/crypto/ccp/ccp-pci.c
+++ b/drivers/crypto/ccp/ccp-pci.c
@@ -325,8 +325,8 @@ static int ccp_pci_resume(struct pci_dev *pdev)
static const struct pci_device_id ccp_pci_table[] = {
{ PCI_VDEVICE(AMD, 0x1537), (kernel_ulong_t)&ccpv3 },
- { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5 },
- { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5other },
+ { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5a },
+ { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5b },
/* Last entry must be zero */
{ 0, }
};
^ permalink raw reply related
* Re: sha1_mb broken
From: Megha Dey @ 2016-09-28 17:58 UTC (permalink / raw)
To: Stephan Mueller; +Cc: linux-crypto
In-Reply-To: <3264980.mGNQ3Qi0fl@positron.chronox.de>
Hi Stephan,
Could you give me more info on how I could reproduce this issue on my
end?
Also was this issue there all along? Which is the first kernel version
where you see this?
Thanks,
Megha
On Mon, 2016-09-26 at 19:32 +0200, Stephan Mueller wrote:
> Am Freitag, 26. August 2016, 03:15:06 CEST schrieb Stephan Mueller:
>
> Hi Megha,
>
> > Hi,
> >
> > I tried to execute tests with sha1_mb.
>
> Have you had a chance to look into this one?
> >
> > The execution simply stalls when invoking a digest operation -- i.e. the
> > digest operation does not finish. After some time after invoking the hashing
> > operation, the following log appears (note, the kccavs_* functions are my
> > test code; that test code works perfectly well with all other hash
> > implementations):
> >
> > [ 140.426026] INFO: rcu_sched detected stalls on CPUs/tasks:
> > [ 140.426719] 2-...: (1 GPs behind) idle=9c3/140000000000000/0
> > softirq=2680/2707 fqs=14762
> > [ 140.427024] (detected by 0, t=60002 jiffies, g=655, c=654, q=35)
> > [ 140.427024] Task dump for CPU 2:
> > [ 140.427024] cavs_driver R running task 0 945 862
> > 0x00000008
> > [ 140.427024] ffffffff9b78d965 ffffa527b8bfa640 ffffa527bb505940
> > ffffa52775c20c50
> > [ 140.427024] ffffa527bc300000 ffffa527b93d2a80 ffffa527bb857e00
> > ffffa527bc2ffd78
> > [ 140.427024] ffffa527b93d2ac8 ffffa527bc2ffcc0 ffffffff9b78dfc8
> > ffffa527bc2ffd70
> > [ 140.427024] Call Trace:
> > [ 140.427024] [<ffffffff9b78d965>] ? __schedule+0x245/0x690
> > [ 140.427024] [<ffffffff9b78dfc8>] ? preempt_schedule_common+0x18/0x30
> > [ 140.427024] [<ffffffff9b791a68>] ? _raw_spin_lock_irq+0x28/0x30
> > [ 140.427024] [<ffffffff9b78ed98>] ? wait_for_completion_interruptible
> > +0x28/0x180
> > [ 140.427024] [<ffffffffc028541c>] ? sha1_mb_async_digest+0x6c/0x70
> > [sha1_mb]
> > [ 140.427024] [<ffffffff9b3b1129>] ? crypto_ahash_op+0x29/0x70
> > [ 140.427024] [<ffffffffc0270148>] ? kccavs_test_ahash+0x198/0x2b0
> > [kcapi_cavs]
> > [ 140.427024] [<ffffffffc026e20a>] ? kccavs_data_read+0xda/0x160
> > [kcapi_cavs]
> > [ 140.427024] [<ffffffff9b370964>] ? full_proxy_read+0x54/0x90
> > [ 140.427024] [<ffffffff9b208088>] ? __vfs_read+0x28/0x110
> > [ 140.427024] [<ffffffff9b38a2c0>] ? security_file_permission+0xa0/0xc0
> > [ 140.427024] [<ffffffff9b20850e>] ? rw_verify_area+0x4e/0xb0
> > [ 140.427024] [<ffffffff9b208606>] ? vfs_read+0x96/0x130
> > [ 140.427024] [<ffffffff9b2099f6>] ? SyS_read+0x46/0xa0
> > [ 140.427024] [<ffffffff9b791cb6>] ? entry_SYSCALL_64_fastpath+0x1e/0xa8
> >
> >
> >
> > Ciao
> > Stephan
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
> Ciao
> Stephan
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox