From patchwork Fri Mar 3 06:56:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 9602109 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5F77604E2 for ; Fri, 3 Mar 2017 06:57:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9DC62860C for ; Fri, 3 Mar 2017 06:57:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE64628614; Fri, 3 Mar 2017 06:57:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19B152860E for ; Fri, 3 Mar 2017 06:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751269AbdCCG5j (ORCPT ); Fri, 3 Mar 2017 01:57:39 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36003 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbdCCG5i (ORCPT ); Fri, 3 Mar 2017 01:57:38 -0500 Received: by mail-pf0-f196.google.com with SMTP id j5so9070892pfb.3 for ; Thu, 02 Mar 2017 22:57:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id; bh=Dma8OA1xXQx6aQpmJOvZ1f3aJD6giQu64gChDw9lAI0=; b=kIF2I6wJuAmVZlZ9yz5/UJG2ZHWID2EW2/2O1xJUfrSZngrKRdHdyeX/LpHlA5/7hM h3w5ZzfQ9C7BJcFCd7WQunGKsnOqP0QwtZDim1rJIAgB4TraBZymseuBU5EzzVZSQY/V ar/x66WEY7LvGJy2+0ltX+R8vsFF5kEiPSNjI= 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; bh=Dma8OA1xXQx6aQpmJOvZ1f3aJD6giQu64gChDw9lAI0=; b=OyKP9d7a3X446B+L+d3eWQfkZ5f4jfZ2qZePUPdaLnR+/Y34AzGSqJY7xzg3OyZPsv /CXyQSgNgzpW5CI8tT7yg/4ODIzWdp66yyQ1+ylgoDjVrlO7ahvVbDCHxoRHvgI605Gi IY1tAZZ2TOp3BKfFemgeJjhgtDnfv7U9KOBAaiy1xTakz8a6FLIzUDVqGY2c/MxHOXMl B4AqavupH4qF4tr/srMC8xu5s/TMT0GFf7whIgE6e4rvsDSks1rSQBewLG0KUU5ocFmi 0Bgf2ROo/oNPkbQssmwIcbjA4XpVb9zSxZhnGYbVPQxxJwR0Vno/kqSfJ/hG4UaTwQy1 kalw== X-Gm-Message-State: AMke39kQRF3Uj2GtI2Bwq2GOCq36bqKuM2EETu9PzYoN6HXVSRDoZxgSaY6i3S74A1Pn+w== X-Received: by 10.98.10.202 with SMTP id 71mr1625738pfk.54.1488524225615; Thu, 02 Mar 2017 22:57:05 -0800 (PST) Received: from connectitude.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id h25sm14169739pfk.119.2017.03.02.22.57.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 22:57:05 -0800 (PST) From: Daniel Axtens To: linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org Cc: anton@samba.org, Daniel Axtens Subject: [PATCH] crypto: powerpc - Fix initialisation of crc32c context Date: Fri, 3 Mar 2017 17:56:55 +1100 Message-Id: <20170303065655.7317-1-dja@axtens.net> X-Mailer: git-send-email 2.9.3 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Turning on crypto self-tests on a POWER8 shows: alg: hash: Test 1 failed for crc32c-vpmsum 00000000: ff ff ff ff Comparing the code with the Intel CRC32c implementation on which ours is based shows that we are doing an init with 0, not ~0 as CRC32c requires. This probably wasn't caught because btrfs does its own weird open-coded initialisation. Initialise our internal context to ~0 on init. This makes the self-tests pass, and btrfs continues to work. Fixes: 6dd7a82cc54e ("crypto: powerpc - Add POWER8 optimised crc32c") Cc: Anton Blanchard Cc: stable@vger.kernel.org Signed-off-by: Daniel Axtens Acked-by: Anton Blanchard --- arch/powerpc/crypto/crc32c-vpmsum_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/crypto/crc32c-vpmsum_glue.c b/arch/powerpc/crypto/crc32c-vpmsum_glue.c index 9fa046d56eba..411994551afc 100644 --- a/arch/powerpc/crypto/crc32c-vpmsum_glue.c +++ b/arch/powerpc/crypto/crc32c-vpmsum_glue.c @@ -52,7 +52,7 @@ static int crc32c_vpmsum_cra_init(struct crypto_tfm *tfm) { u32 *key = crypto_tfm_ctx(tfm); - *key = 0; + *key = ~0; return 0; }