mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: AlanSong-oc <AlanSong-oc@zhaoxin.com>
To: herbert@gondor.apana.org.au, davem@davemloft.net,
	ebiggers@kernel.org, Jason@zx2c4.com, ardb@kernel.org,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	x86@kernel.org
Cc: CobeChen@zhaoxin.com, TonyWWang-oc@zhaoxin.com,
	YunShen@zhaoxin.com, GeorgeXue@zhaoxin.com, LeoLiu@zhaoxin.com,
	HansHu@zhaoxin.com, AlanSong-oc <AlanSong-oc@zhaoxin.com>,
	stable@vger.kernel.org
Subject: [PATCH v4 1/2] crypto: padlock-sha - Disable for Zhaoxin processor
Date: Fri, 13 Mar 2026 16:01:49 +0800	[thread overview]
Message-ID: <20260313080150.9393-2-AlanSong-oc@zhaoxin.com> (raw)
In-Reply-To: <20260313080150.9393-1-AlanSong-oc@zhaoxin.com>

For Zhaoxin processors, the XSHA1 instruction requires the total memory
allocated at %rdi register must be 32 bytes, while the XSHA1 and
XSHA256 instruction doesn't perform any operation when %ecx is zero.

Due to these requirements, the current padlock-sha driver does not work
correctly with Zhaoxin processors. It cannot pass the self-tests and
therefore does not activate the driver on Zhaoxin processors. This issue
has been reported in Debian [1]. The self-tests fail with the
following messages [2]:

alg: shash: sha1-padlock-nano test failed (wrong result) on test vector 0, cfg="init+update+final aligned buffer"
alg: self-tests for sha1 using sha1-padlock-nano failed (rc=-22)
------------[ cut here ]------------

alg: shash: sha256-padlock-nano test failed (wrong result) on test vector 0, cfg="init+update+final aligned buffer"
alg: self-tests for sha256 using sha256-padlock-nano failed (rc=-22)
------------[ cut here ]------------

Disable the padlock-sha driver on Zhaoxin processors with the CPU family
0x07 and newer. Following the suggestion in [3], add support for the PHE
extensions to lib/crypto. Only XSHA256 support for SHA-256 is included,
since SHA-1 has been cryptographically broken, as recommended in [4].

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103397
[2] https://linux-hardware.org/?probe=271fabb7a4&log=dmesg
[3] https://lore.kernel.org/linux-crypto/aUI4CGp6kK7mxgEr@gondor.apana.org.au/
[4] https://lore.kernel.org/linux-crypto/20260116071513.12134-1-AlanSong-oc@zhaoxin.com/T/#m49436c4849dd64454b3554c105197ef9c61db23e

Fixes: 63dc06cd12f9 ("crypto: padlock-sha - Use API partial block handling")
Cc: stable@vger.kernel.org
Signed-off-by: AlanSong-oc <AlanSong-oc@zhaoxin.com>
---
 drivers/crypto/padlock-sha.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index 329f60ad4..9214bbfc8 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -332,6 +332,13 @@ static int __init padlock_init(void)
 	if (!x86_match_cpu(padlock_sha_ids) || !boot_cpu_has(X86_FEATURE_PHE_EN))
 		return -ENODEV;
 
+	/*
+	 * Skip family 0x07 and newer used by Zhaoxin processors,
+	 * as the driver's self-tests fail on these CPUs.
+	 */
+	if (c->x86 >= 0x07)
+		return -ENODEV;
+
 	/* Register the newly added algorithm module if on *
 	* VIA Nano processor, or else just do as before */
 	if (c->x86_model < 0x0f) {
-- 
2.34.1


  reply	other threads:[~2026-03-13  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13  8:01 [PATCH v4 0/2] lib/crypto: x86/sha: Add PHE Extensions support AlanSong-oc
2026-03-13  8:01 ` AlanSong-oc [this message]
2026-03-14 18:40   ` [PATCH v4 1/2] crypto: padlock-sha - Disable for Zhaoxin processor Eric Biggers
2026-03-13  8:01 ` [PATCH v4 2/2] lib/crypto: x86/sha256: PHE Extensions optimized SHA256 transform function AlanSong-oc
2026-03-14 18:50   ` Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260313080150.9393-2-AlanSong-oc@zhaoxin.com \
    --to=alansong-oc@zhaoxin.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=GeorgeXue@zhaoxin.com \
    --cc=HansHu@zhaoxin.com \
    --cc=Jason@zx2c4.com \
    --cc=LeoLiu@zhaoxin.com \
    --cc=TonyWWang-oc@zhaoxin.com \
    --cc=YunShen@zhaoxin.com \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®