Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: sun4i-ss - Fix sparse endianness markers

This patch also fixes the incorrect endianness markings in the
sun4i-ss driver. It should have no effect in the genereated code.

Instead of using cpu_to_Xe32 followed by a memcpy, this patch
converts the final hash write to use put_unaligned_X instead.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+9 -8
+9 -8
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c
··· 9 9 * You could find the datasheet in Documentation/arm/sunxi.rst 10 10 */ 11 11 #include "sun4i-ss.h" 12 + #include <asm/unaligned.h> 12 13 #include <linux/scatterlist.h> 13 14 14 15 /* This is a totally arbitrary value */ ··· 197 196 struct sg_mapping_iter mi; 198 197 int in_r, err = 0; 199 198 size_t copied = 0; 200 - __le32 wb = 0; 199 + u32 wb = 0; 201 200 202 201 dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x", 203 202 __func__, crypto_tfm_alg_name(areq->base.tfm), ··· 409 408 410 409 nbw = op->len - 4 * nwait; 411 410 if (nbw) { 412 - wb = cpu_to_le32(*(u32 *)(op->buf + nwait * 4)); 411 + wb = le32_to_cpup((__le32 *)(op->buf + nwait * 4)); 413 412 wb &= GENMASK((nbw * 8) - 1, 0); 414 413 415 414 op->byte_count += nbw; ··· 418 417 419 418 /* write the remaining bytes of the nbw buffer */ 420 419 wb |= ((1 << 7) << (nbw * 8)); 421 - bf[j++] = le32_to_cpu(wb); 420 + ((__le32 *)bf)[j++] = cpu_to_le32(wb); 422 421 423 422 /* 424 423 * number of space to pad to obtain 64o minus 8(size) minus 4 (final 1) ··· 480 479 /* Get the hash from the device */ 481 480 if (op->mode == SS_OP_SHA1) { 482 481 for (i = 0; i < 5; i++) { 482 + v = readl(ss->base + SS_MD0 + i * 4); 483 483 if (ss->variant->sha1_in_be) 484 - v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); 484 + put_unaligned_le32(v, areq->result + i * 4); 485 485 else 486 - v = cpu_to_be32(readl(ss->base + SS_MD0 + i * 4)); 487 - memcpy(areq->result + i * 4, &v, 4); 486 + put_unaligned_be32(v, areq->result + i * 4); 488 487 } 489 488 } else { 490 489 for (i = 0; i < 4; i++) { 491 - v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); 492 - memcpy(areq->result + i * 4, &v, 4); 490 + v = readl(ss->base + SS_MD0 + i * 4); 491 + put_unaligned_le32(v, areq->result + i * 4); 493 492 } 494 493 } 495 494