Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3669746pxk; Mon, 7 Sep 2020 22:02:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf5GJUTC8SVeGMNL2apFkb/OGsLgmDu7j4mVcQ1i8Et4NAft6JJGv1Ad8bHY6nagyIJwuJ X-Received: by 2002:aa7:dbd9:: with SMTP id v25mr26087713edt.78.1599541321113; Mon, 07 Sep 2020 22:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599541321; cv=none; d=google.com; s=arc-20160816; b=rDkOLQkIYMg9whavz4ecqrsY6tNIW+c+eXJuRKPGsYpsxz5GAS9+OapJvhQgbDT61m CKKId8nP2qz9G8p2LqYgklrJZGbY/oiEEaMaRPUMI3jkUjgqjueaZifSsJN3L/vPCgP7 r/r7RHs8013kS9HM1YcrJXNOqpgH6byK+Mml5WqyqfSULQ+Ce1nOn5XowP1vdpekroR6 Gha6bkGWzZGCdx9zUEXVlQsz+DJB2i2PsY7pjN0VHN+vJ3kLw4EtzFTcOXoQDKk3jpl3 Ag/RMhMq18v+TE9WN6WiagrKT1SacfFtuwCWO+lSGm8r732HRbRmixagkLiv8Z5jUrII Kewg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mtInCljRkFyufCtM9YIlJ5HMKuJTRrfIirFobyNO+UM=; b=J7miznsxampPLL8IQ0tQXH6XRp+PdPeMqGYNy/Kry1rC0TCrjeuODfNOekAf3mpCEB fPh2Eut7Qzf/ma7yFWmeAM0wUPiPVgV6ZsEz++rfLe8A4ytLTr0ungVE0T23QmQ4ki5j B4FiSK7shK83ZzCfS+NPsDDtpyfoZWifpvXOlFxIISDxl+aImcPbWxUGqgwzZ5qmYrdC rR9UDuPGq0rSqNytFUUgw3T83u+od3x6VFuJxepZYzo/zzG9wLx2S3/n4SrPqSb4/vLV XlwxrXbTcCf/IUCc+PLhGUd1c4UoDD4bGHQGG9GJv17ChRqxxGu1216n5FOxU29aPca7 Ar6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si11292118eje.588.2020.09.07.22.01.24; Mon, 07 Sep 2020 22:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726801AbgIHFAq (ORCPT + 99 others); Tue, 8 Sep 2020 01:00:46 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:52396 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726639AbgIHFAq (ORCPT ); Tue, 8 Sep 2020 01:00:46 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1kFVkC-0000ag-4X; Tue, 08 Sep 2020 15:00:37 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Tue, 08 Sep 2020 15:00:36 +1000 Date: Tue, 8 Sep 2020 15:00:36 +1000 From: Herbert Xu To: Corentin Labbe Cc: kernel test robot , kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Linux Crypto Mailing List Subject: [v2 PATCH] crypto: sun4i-ss - Fix sparse endianness markers Message-ID: <20200908050036.GA19817@gondor.apana.org.au> References: <202009061621.J89kO43Q%lkp@intel.com> <20200907062400.GA15841@gondor.apana.org.au> <20200907160029.GC11894@Red> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907160029.GC11894@Red> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Sep 07, 2020 at 06:00:29PM +0200, Corentin Labbe wrote: > > The put_unaligned should be _le32. > > This fix the modprobe tcrypt fail. Thanks. Yes the original code was correct. ---8<--- 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 Signed-off-by: Herbert Xu diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c index dc35edd90034..1dff48558f53 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c @@ -9,6 +9,7 @@ * You could find the datasheet in Documentation/arm/sunxi.rst */ #include "sun4i-ss.h" +#include #include /* This is a totally arbitrary value */ @@ -196,7 +197,7 @@ static int sun4i_hash(struct ahash_request *areq) struct sg_mapping_iter mi; int in_r, err = 0; size_t copied = 0; - __le32 wb = 0; + u32 wb = 0; dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x", __func__, crypto_tfm_alg_name(areq->base.tfm), @@ -408,7 +409,7 @@ static int sun4i_hash(struct ahash_request *areq) nbw = op->len - 4 * nwait; if (nbw) { - wb = cpu_to_le32(*(u32 *)(op->buf + nwait * 4)); + wb = le32_to_cpup((__le32 *)(op->buf + nwait * 4)); wb &= GENMASK((nbw * 8) - 1, 0); op->byte_count += nbw; @@ -417,7 +418,7 @@ static int sun4i_hash(struct ahash_request *areq) /* write the remaining bytes of the nbw buffer */ wb |= ((1 << 7) << (nbw * 8)); - bf[j++] = le32_to_cpu(wb); + ((__le32 *)bf)[j++] = cpu_to_le32(wb); /* * number of space to pad to obtain 64o minus 8(size) minus 4 (final 1) @@ -479,16 +480,16 @@ static int sun4i_hash(struct ahash_request *areq) /* Get the hash from the device */ if (op->mode == SS_OP_SHA1) { for (i = 0; i < 5; i++) { + v = readl(ss->base + SS_MD0 + i * 4); if (ss->variant->sha1_in_be) - v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); + put_unaligned_le32(v, areq->result + i * 4); else - v = cpu_to_be32(readl(ss->base + SS_MD0 + i * 4)); - memcpy(areq->result + i * 4, &v, 4); + put_unaligned_be32(v, areq->result + i * 4); } } else { for (i = 0; i < 4; i++) { - v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); - memcpy(areq->result + i * 4, &v, 4); + v = readl(ss->base + SS_MD0 + i * 4); + put_unaligned_le32(v, areq->result + i * 4); } } -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt