From patchwork Thu Nov 14 12:58:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 179406 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp11022727ilf; Thu, 14 Nov 2019 04:59:00 -0800 (PST) X-Google-Smtp-Source: APXvYqy+ffRCsb3aCrLq0UmytyuebVv/PHy88i9VkD9So+uJZdyfQLErBrQt82az8zEuvHLDAF2X X-Received: by 2002:a17:906:2786:: with SMTP id j6mr8245657ejc.206.1573736340358; Thu, 14 Nov 2019 04:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573736340; cv=none; d=google.com; s=arc-20160816; b=hYA5drYnP6zRxTuSU8VNdza3whX2osdvSQ5JyVwXyYnehkwaXH1mJNtDfqtbAQwARA 7/JOCfn6pr5aIwB00gmsHjkXn1ieG5jBwrVTVdqPfMGpDi8Qu+ESBagc8WMcEsD8UPTK GmpDtyzYdd35p4gefjbGnDhFevBR6dvP6pKktjrCAZaj+AvS4fv9fsQqJm3JzMC06TkW icxhNIqp7zS53JtVIC6noY6BHy5Xr5NL3kvoj6hHnS2lc1w/bRDp+sKlPRbPCKafi7gG Sa/GzJBJJWY3Gcpak3eiLvkHqWSlXFKCTfOvogPfDm6iwYsTCCDjOB4cwij08nBMJUdt yDYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5/yZewMOwSUNa5I83y+T0aelSU0qIk8Vc3mk35F3rOY=; b=o7b6P/Lyr1whuso+9V0RAJWesk2CwnLz9Kc0PHLlDa5LKngETF78txY7pOU+z8vGpY 26dmrOJLhjSY29T0/pNvCtkaU8uRLfNZvYQp6Kj7HpuzvXomRra74zmwaQlT/PWun7b6 5svMGE0SlxsaKsGf7xQz6VmAXJnZjPtUg9E1zWuBizY+C4HHlLabvjjq/d6Ew2Uz7vGx UAGaXYbhu944oRkmsqqABsH5YZqvThwY3ajVEAONZikiNzPlh/oM4uNwBZsM8+zGdgFz c8dAXia+NcijPOZw9dxS3ItuhU1/3UitLwWdacq1xzALh/mBLKVF8cwTSLl2RCeVmyA4 BZJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a5edst1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si3399952ejd.369.2019.11.14.04.59.00; Thu, 14 Nov 2019 04:59:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a5edst1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbfKNM66 (ORCPT + 26 others); Thu, 14 Nov 2019 07:58:58 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45889 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbfKNM64 (ORCPT ); Thu, 14 Nov 2019 07:58:56 -0500 Received: by mail-wr1-f65.google.com with SMTP id z10so6328460wrs.12; Thu, 14 Nov 2019 04:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5/yZewMOwSUNa5I83y+T0aelSU0qIk8Vc3mk35F3rOY=; b=a5edst1XV+upr79EpSARNH1rcJkMpsPeGN84GGciH7M7yuP8Ervh7VUSJYq+WVKxLl x3ofgMaRe2fgA/pSIFcPQbQ670Tr5EWECXLBtgWD3St5nKubOs1Z53ELy/18R/pYV4e1 fsjOb2T7iMRnEyix3y5GwW+XFZDVO62MUDXuN4ZHA8R5qXIEO9/F25XYYCTlJohA6Cls kjsPKGSBO7QO36AlDPM7Rfsx0Cs2PvqDoaNC428RZ0buJODbIDvC3OtbO4Y3CgrEiDJs yX2h1uoiMg4Qw6tPkAXQzFg0bc/AhzAU1fnKWTpEuiS3sFHGOQCmtsYrQphr59MTUSEb AXZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5/yZewMOwSUNa5I83y+T0aelSU0qIk8Vc3mk35F3rOY=; b=lclJhkgjRFvObiSu+gcPGiCa4CWbcX1E4payv4qvE1aEq6hd8DIG0LTKsBUPQV84jZ j9/fLPJEJUmdc43xOYgVaahx3LaGwOT59hzZ6z/CIZP7MJ80p+9LgMKa8sDaUfYS8iTe IShWy9IJaXBFUDR9/3EtUBxVTAkcFsOVRdiHRfX6OoNciNKyLBwfueH1M5q7XVlqWdOM KRyO3L2lSTbbHuhbgV1zqo5lvmg4Dq0Ht3p2CwEo0nPxqlG8yWWI6Fk4qoEHr6kgOr7a 7qkaj/KdtuNerB2w1NGa56rzntzkT1puCQx37qzLbD7QGiAC8l105jrwEcPHU1pzMiZq C1wQ== X-Gm-Message-State: APjAAAXaNU+Ju1EbeI5Vv7kyzFneET+L3rkTRx8mcvdp1qYrrDzDVLeb svBLVMuXmtFiQKtuxtngM2w= X-Received: by 2002:adf:f18e:: with SMTP id h14mr8497661wro.348.1573736332664; Thu, 14 Nov 2019 04:58:52 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id z6sm7540220wro.18.2019.11.14.04.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 04:58:51 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH] crypto: sun4i-ss: fix big endian issues Date: Thu, 14 Nov 2019 13:58:49 +0100 Message-Id: <20191114125849.22829-1-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When testing BigEndian kernel, the sun4i-ss was failling all crypto tests. This patch fix endian issues with it. Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator") Signed-off-by: Corentin Labbe --- .../crypto/allwinner/sun4i-ss/sun4i-ss-hash.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.23.0 diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c index ec5d9ce24bb8..b233f67f491f 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-hash.c @@ -187,7 +187,7 @@ static int sun4i_hash(struct ahash_request *areq) */ unsigned int i = 0, end, fill, min_fill, nwait, nbw = 0, j = 0, todo; unsigned int in_i = 0; - u32 spaces, rx_cnt = SS_RX_DEFAULT, bf[32] = {0}, wb = 0, v, ivmode = 0; + u32 spaces, rx_cnt = SS_RX_DEFAULT, bf[32] = {0}, v, ivmode = 0; struct sun4i_req_ctx *op = ahash_request_ctx(areq); struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct sun4i_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); @@ -196,6 +196,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; dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x", __func__, crypto_tfm_alg_name(areq->base.tfm), @@ -407,7 +408,7 @@ static int sun4i_hash(struct ahash_request *areq) nbw = op->len - 4 * nwait; if (nbw) { - wb = *(u32 *)(op->buf + nwait * 4); + wb = cpu_to_le32(*(u32 *)(op->buf + nwait * 4)); wb &= GENMASK((nbw * 8) - 1, 0); op->byte_count += nbw; @@ -416,7 +417,7 @@ static int sun4i_hash(struct ahash_request *areq) /* write the remaining bytes of the nbw buffer */ wb |= ((1 << 7) << (nbw * 8)); - bf[j++] = wb; + bf[j++] = le32_to_cpu(wb); /* * number of space to pad to obtain 64o minus 8(size) minus 4 (final 1) @@ -435,13 +436,13 @@ static int sun4i_hash(struct ahash_request *areq) /* write the length of data */ if (op->mode == SS_OP_SHA1) { - __be64 bits = cpu_to_be64(op->byte_count << 3); - bf[j++] = lower_32_bits(bits); - bf[j++] = upper_32_bits(bits); + __be64 *bits = (__be64 *)&bf[j]; + *bits = cpu_to_be64(op->byte_count << 3); + j += 2; } else { - __le64 bits = op->byte_count << 3; - bf[j++] = lower_32_bits(bits); - bf[j++] = upper_32_bits(bits); + __le64 *bits = (__le64 *)&bf[j]; + *bits = cpu_to_le64(op->byte_count << 3); + j += 2; } writesl(ss->base + SS_RXFIFO, bf, j); @@ -487,7 +488,7 @@ static int sun4i_hash(struct ahash_request *areq) } } else { for (i = 0; i < 4; i++) { - v = readl(ss->base + SS_MD0 + i * 4); + v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); memcpy(areq->result + i * 4, &v, 4); } }