x86/microcode/AMD: Use sha256() instead of init/update/final
Subsystems (3)
PATCH 1/1 x86/microcode/AMD: Use sha256() instead of init/update/final
From: Eric Biggers <[email protected]>
Just call sha256() instead of doing the init/update/final sequence.
Signed-off-by Eric Biggers <[email protected]>
---
This patch is targeting the x86 tree.
arch/x86/kernel/cpu/microcode/amd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +1 -4
@@ -215,11 +215,10 @@ static bool need_sha_check(u32 cur_rev)static bool verify_sha256_digest (u32 patch_id,u32 cur_rev,const u8 *data,unsigned int len) {struct patch_digest *pd =NULL ;u8 digest[SHA256_DIGEST_SIZE ]; -struct sha256_state s;int i;if (x86_family (bsp_cpuid_1_eax) <0x17 )return true;
@@ -233,13 +232,11 @@ static bool verify_sha256_digest(u32 patch_id, u32 cur_rev, const u8 *data, unsiif (!pd) {pr_err ("No sha256 digest for patch ID: 0x%x found\n" , patch_id);return false; } -sha256_init (&s); -sha256_update (&s, data, len); -sha256_final (&s, digest); +sha256 (data, len, digest);if (memcmp (digest, pd->sha256,sizeof (digest))) {pr_err ("Patch 0x%x SHA256 digest mismatch!\n" , patch_id);for (i =0 ; i <SHA256_DIGEST_SIZE ; i++)
base-commit: 33035b665157558254b3c21c3f049fd728e72368
Signature · 1 line
2.49.0
The following commit has been merged into the x86/microcode branch of tip:
The following commit has been merged into the x86/microcode branch of tip:
Commit-ID: c0a62eadb6fd158e4d6d4d47d806109e7ae32e8b Gitweb: https://git.kernel.org/tip/c0a62eadb6fd158e4d6d4d47d806109e7ae32e8b Author: Eric Biggers <[email protected]> AuthorDate: Mon, 28 Apr 2025 11:30:06 -07:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Mon, 28 Apr 2025 21:03:58 +02:00
x86/microcode/AMD: Use sha256() instead of init/update/final
Just call sha256() instead of doing the init/update/final sequence.
No functional changes.
Signed-off-by Eric Biggers <[email protected]>
Signed-off-by Borislav Petkov (AMD) <[email protected]>
--- arch/x86/kernel/cpu/microcode/amd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +1 -4
@@ -211,7 +211,6 @@ static bool verify_sha256_digest(u32 patch_id, u32 cur_rev, const u8 *data, unsi {struct patch_digest *pd =NULL ;u8 digest[SHA256_DIGEST_SIZE ]; -struct sha256_state s;int i; if (x86_family(bsp_cpuid_1_eax) < 0x17 ||
@@ -230,9 +229,7 @@ static bool verify_sha256_digest(u32 patch_id, u32 cur_rev, const u8 *data, unsireturn false; } -sha256_init (&s); -sha256_update (&s, data, len); -sha256_final (&s, digest); +sha256 (data, len, digest);if (memcmp (digest, pd->sha256,sizeof (digest))) {pr_err ("Patch 0x%x SHA256 digest mismatch!\n" , patch_id);