]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
crypto: nx - Fix numerous sparse byte-order warnings
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 17 Jun 2021 08:00:12 +0000 (16:00 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 24 Jun 2021 06:51:35 +0000 (14:51 +0800)
The nx driver started out its life as a BE-only driver.  However,
somewhere along the way LE support was partially added.  This never
seems to have been extended all the way but it does trigger numerous
warnings during build.

This patch fixes all those warnings, but it doesn't mean that the
driver will work on LE.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/nx/nx-aes-cbc.c
drivers/crypto/nx/nx-aes-ccm.c
drivers/crypto/nx/nx-aes-ctr.c
drivers/crypto/nx/nx-aes-ecb.c
drivers/crypto/nx/nx-aes-gcm.c
drivers/crypto/nx/nx-sha256.c
drivers/crypto/nx/nx-sha512.c
drivers/crypto/nx/nx_csbcpb.h

index d6314ea9ae896ed4255f122c18defe0ae64737ef..0e440f704a8f95b73ef18fda92b09d46ad3bf0b2 100644 (file)
@@ -88,7 +88,7 @@ static int cbc_aes_nx_crypt(struct skcipher_request *req,
 
                memcpy(req->iv, csbcpb->cpb.aes_cbc.cv, AES_BLOCK_SIZE);
                atomic_inc(&(nx_ctx->stats->aes_ops));
-               atomic64_add(csbcpb->csb.processed_byte_count,
+               atomic64_add(be32_to_cpu(csbcpb->csb.processed_byte_count),
                             &(nx_ctx->stats->aes_bytes));
 
                processed += to_process;
index e7384d1075739b08960fdc27efeee4735a7509df..3793885f928dd33e8fa25b6f9fa2ee5aa1ef3ced 100644 (file)
@@ -391,7 +391,7 @@ static int ccm_nx_decrypt(struct aead_request   *req,
 
                /* update stats */
                atomic_inc(&(nx_ctx->stats->aes_ops));
-               atomic64_add(csbcpb->csb.processed_byte_count,
+               atomic64_add(be32_to_cpu(csbcpb->csb.processed_byte_count),
                             &(nx_ctx->stats->aes_bytes));
 
                processed += to_process;
@@ -460,7 +460,7 @@ static int ccm_nx_encrypt(struct aead_request   *req,
 
                /* update stats */
                atomic_inc(&(nx_ctx->stats->aes_ops));
-               atomic64_add(csbcpb->csb.processed_byte_count,
+               atomic64_add(be32_to_cpu(csbcpb->csb.processed_byte_count),
                             &(nx_ctx->stats->aes_bytes));
 
                processed += to_process;
index 6120e350ff71d12e28e32f47eae18077d60446d2..dfa3ad1a12f281b37c84c482be9344606490d64b 100644 (file)
@@ -102,7 +102,7 @@ static int ctr_aes_nx_crypt(struct skcipher_request *req, u8 *iv)
                memcpy(iv, csbcpb->cpb.aes_cbc.cv, AES_BLOCK_SIZE);
 
                atomic_inc(&(nx_ctx->stats->aes_ops));
-               atomic64_add(csbcpb->csb.processed_byte_count,
+               atomic64_add(be32_to_cpu(csbcpb->csb.processed_byte_count),
                             &(nx_ctx->stats->aes_bytes));
 
                processed += to_process;
index 7a729dc2bc17a3342f0a53cf1e0d3b96bb173ace..502a565074e9806cc962a44f10694128548b771e 100644 (file)
@@ -86,7 +86,7 @@ static int ecb_aes_nx_crypt(struct skcipher_request *req,
                        goto out;
 
                atomic_inc(&(nx_ctx->stats->aes_ops));
-               atomic64_add(csbcpb->csb.processed_byte_count,
+               atomic64_add(be32_to_cpu(csbcpb->csb.processed_byte_count),
                             &(nx_ctx->stats->aes_bytes));
 
                processed += to_process;
index fc9baca13920cf0771fb27ef456134fa880837e7..4a796318b4306f2c53fb670645459b75c91dcbf9 100644 (file)
@@ -382,7 +382,7 @@ static int gcm_aes_nx_crypt(struct aead_request *req, int enc,
                NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
 
                atomic_inc(&(nx_ctx->stats->aes_ops));
-               atomic64_add(csbcpb->csb.processed_byte_count,
+               atomic64_add(be32_to_cpu(csbcpb->csb.processed_byte_count),
                             &(nx_ctx->stats->aes_bytes));
 
                processed += to_process;
index b0ad665e4bda81936c8941198d8f50e2677c49a0..c3bebf0feabe1bfbdf83c6afec4cf65f57d1536f 100644 (file)
 #include "nx_csbcpb.h"
 #include "nx.h"
 
+struct sha256_state_be {
+       __be32 state[SHA256_DIGEST_SIZE / 4];
+       u64 count;
+       u8 buf[SHA256_BLOCK_SIZE];
+};
 
 static int nx_crypto_ctx_sha256_init(struct crypto_tfm *tfm)
 {
@@ -36,7 +41,7 @@ static int nx_crypto_ctx_sha256_init(struct crypto_tfm *tfm)
 }
 
 static int nx_sha256_init(struct shash_desc *desc) {
-       struct sha256_state *sctx = shash_desc_ctx(desc);
+       struct sha256_state_be *sctx = shash_desc_ctx(desc);
 
        memset(sctx, 0, sizeof *sctx);
 
@@ -56,7 +61,7 @@ static int nx_sha256_init(struct shash_desc *desc) {
 static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
                            unsigned int len)
 {
-       struct sha256_state *sctx = shash_desc_ctx(desc);
+       struct sha256_state_be *sctx = shash_desc_ctx(desc);
        struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
        struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
        struct nx_sg *out_sg;
@@ -175,7 +180,7 @@ out:
 
 static int nx_sha256_final(struct shash_desc *desc, u8 *out)
 {
-       struct sha256_state *sctx = shash_desc_ctx(desc);
+       struct sha256_state_be *sctx = shash_desc_ctx(desc);
        struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
        struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
        struct nx_sg *in_sg, *out_sg;
@@ -245,7 +250,7 @@ out:
 
 static int nx_sha256_export(struct shash_desc *desc, void *out)
 {
-       struct sha256_state *sctx = shash_desc_ctx(desc);
+       struct sha256_state_be *sctx = shash_desc_ctx(desc);
 
        memcpy(out, sctx, sizeof(*sctx));
 
@@ -254,7 +259,7 @@ static int nx_sha256_export(struct shash_desc *desc, void *out)
 
 static int nx_sha256_import(struct shash_desc *desc, const void *in)
 {
-       struct sha256_state *sctx = shash_desc_ctx(desc);
+       struct sha256_state_be *sctx = shash_desc_ctx(desc);
 
        memcpy(sctx, in, sizeof(*sctx));
 
@@ -268,8 +273,8 @@ struct shash_alg nx_shash_sha256_alg = {
        .final      = nx_sha256_final,
        .export     = nx_sha256_export,
        .import     = nx_sha256_import,
-       .descsize   = sizeof(struct sha256_state),
-       .statesize  = sizeof(struct sha256_state),
+       .descsize   = sizeof(struct sha256_state_be),
+       .statesize  = sizeof(struct sha256_state_be),
        .base       = {
                .cra_name        = "sha256",
                .cra_driver_name = "sha256-nx",
index c29103a1a0b6c93858c28eecf7d7535dde9f80d1..1ffb40d2c32453d01a2486f2c962e6189a9d0acc 100644 (file)
 #include "nx_csbcpb.h"
 #include "nx.h"
 
+struct sha512_state_be {
+       __be64 state[SHA512_DIGEST_SIZE / 8];
+       u64 count[2];
+       u8 buf[SHA512_BLOCK_SIZE];
+};
 
 static int nx_crypto_ctx_sha512_init(struct crypto_tfm *tfm)
 {
@@ -36,7 +41,7 @@ static int nx_crypto_ctx_sha512_init(struct crypto_tfm *tfm)
 
 static int nx_sha512_init(struct shash_desc *desc)
 {
-       struct sha512_state *sctx = shash_desc_ctx(desc);
+       struct sha512_state_be *sctx = shash_desc_ctx(desc);
 
        memset(sctx, 0, sizeof *sctx);
 
@@ -56,7 +61,7 @@ static int nx_sha512_init(struct shash_desc *desc)
 static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
                            unsigned int len)
 {
-       struct sha512_state *sctx = shash_desc_ctx(desc);
+       struct sha512_state_be *sctx = shash_desc_ctx(desc);
        struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
        struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
        struct nx_sg *out_sg;
@@ -178,7 +183,7 @@ out:
 
 static int nx_sha512_final(struct shash_desc *desc, u8 *out)
 {
-       struct sha512_state *sctx = shash_desc_ctx(desc);
+       struct sha512_state_be *sctx = shash_desc_ctx(desc);
        struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
        struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
        struct nx_sg *in_sg, *out_sg;
@@ -251,7 +256,7 @@ out:
 
 static int nx_sha512_export(struct shash_desc *desc, void *out)
 {
-       struct sha512_state *sctx = shash_desc_ctx(desc);
+       struct sha512_state_be *sctx = shash_desc_ctx(desc);
 
        memcpy(out, sctx, sizeof(*sctx));
 
@@ -260,7 +265,7 @@ static int nx_sha512_export(struct shash_desc *desc, void *out)
 
 static int nx_sha512_import(struct shash_desc *desc, const void *in)
 {
-       struct sha512_state *sctx = shash_desc_ctx(desc);
+       struct sha512_state_be *sctx = shash_desc_ctx(desc);
 
        memcpy(sctx, in, sizeof(*sctx));
 
@@ -274,8 +279,8 @@ struct shash_alg nx_shash_sha512_alg = {
        .final      = nx_sha512_final,
        .export     = nx_sha512_export,
        .import     = nx_sha512_import,
-       .descsize   = sizeof(struct sha512_state),
-       .statesize  = sizeof(struct sha512_state),
+       .descsize   = sizeof(struct sha512_state_be),
+       .statesize  = sizeof(struct sha512_state_be),
        .base       = {
                .cra_name        = "sha512",
                .cra_driver_name = "sha512-nx",
index 493f8490ff942d3a6a2d8255be91acca5cf5a1da..e64f7e36fb9295f538f19253b5b3d10b4035baf9 100644 (file)
@@ -140,8 +140,8 @@ struct cop_status_block {
        u8 crb_seq_number;
        u8 completion_code;
        u8 completion_extension;
-       u32 processed_byte_count;
-       u64 address;
+       __be32 processed_byte_count;
+       __be64 address;
 } __packed;
 
 /* Nest accelerator workbook section 4.4 */