[RFC v3 20/27] crypto: sha: Load early in boot

alistair23@gmail.com posted 27 patches 1 month, 2 weeks ago
[RFC v3 20/27] crypto: sha: Load early in boot
Posted by alistair23@gmail.com 1 month, 2 weeks ago
From: Alistair Francis <alistair.francis@wdc.com>

Work is ongoing to support PCIe device attestation and authentication.
As part of this probing a PCIe device will require generating hashes via
the SPDM protocol to the kernel.

Linux should verify the device before enabling the device, which means we
need the crypto functions to be ready before arch initilisation (where PCIe
init happens). Move the crypto init to postcore to
ensure it's loaded before PCIe devices.

This allows us to verify the certificate chain provided by a PCIe device
via SPDM before we enable it.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 crypto/sha256.c | 2 +-
 crypto/sha3.c   | 2 +-
 crypto/sha512.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/sha256.c b/crypto/sha256.c
index fb81defe084c..0ebe96f89733 100644
--- a/crypto/sha256.c
+++ b/crypto/sha256.c
@@ -398,7 +398,7 @@ static int __init crypto_sha256_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha256_mod_init);
+postcore_initcall(crypto_sha256_mod_init);
 
 static void __exit crypto_sha256_mod_exit(void)
 {
diff --git a/crypto/sha3.c b/crypto/sha3.c
index 8f364979ec89..d37ce694b50a 100644
--- a/crypto/sha3.c
+++ b/crypto/sha3.c
@@ -145,7 +145,7 @@ static int __init crypto_sha3_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha3_mod_init);
+postcore_initcall(crypto_sha3_mod_init);
 
 static void __exit crypto_sha3_mod_exit(void)
 {
diff --git a/crypto/sha512.c b/crypto/sha512.c
index d320fe53913f..6effa6043b55 100644
--- a/crypto/sha512.c
+++ b/crypto/sha512.c
@@ -404,7 +404,7 @@ static int __init crypto_sha512_mod_init(void)
 {
 	return crypto_register_shashes(algs, ARRAY_SIZE(algs));
 }
-module_init(crypto_sha512_mod_init);
+postcore_initcall(crypto_sha512_mod_init);
 
 static void __exit crypto_sha512_mod_exit(void)
 {
-- 
2.52.0
Re: [RFC v3 20/27] crypto: sha: Load early in boot
Posted by Jonathan Cameron 1 month ago
On Wed, 11 Feb 2026 13:29:27 +1000
alistair23@gmail.com wrote:

> From: Alistair Francis <alistair.francis@wdc.com>
> 
> Work is ongoing to support PCIe device attestation and authentication.
> As part of this probing a PCIe device will require generating hashes via
> the SPDM protocol to the kernel.
> 
> Linux should verify the device before enabling the device, which means we
> need the crypto functions to be ready before arch initilisation (where PCIe
> init happens). Move the crypto init to postcore to
> ensure it's loaded before PCIe devices.
> 
> This allows us to verify the certificate chain provided by a PCIe device
> via SPDM before we enable it.
> 
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>