mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nikolay Borisov <nik.borisov@suse.com>
To: bp@alien8.de
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Nikolay Borisov <nik.borisov@suse.com>
Subject: [PATCH 2/3] x86/microcode/AMD: Make __verify_patch_size() return bool
Date: Fri, 18 Oct 2024 18:51:50 +0300	[thread overview]
Message-ID: <20241018155151.702350-3-nik.borisov@suse.com> (raw)
In-Reply-To: <20241018155151.702350-1-nik.borisov@suse.com>

The result of that function is in essence boolean, so simplify to return
the result of the relevant expression. It also makes it follow the
convetion used by __verify_patch_section(). No functional changes.

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
---
 arch/x86/kernel/cpu/microcode/amd.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 9986cb85c951..37a428b109a2 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -282,7 +282,7 @@ __verify_patch_section(const u8 *buf, size_t buf_size, u32 *sh_psize)
  * exceed the per-family maximum). @sh_psize is the size read from the section
  * header.
  */
-static unsigned int __verify_patch_size(u32 sh_psize, size_t buf_size)
+static bool __verify_patch_size(u32 sh_psize, size_t buf_size)
 {
 	u8 family = x86_family(bsp_cpuid_1_eax);
 	u32 max_size;
@@ -305,10 +305,7 @@ static unsigned int __verify_patch_size(u32 sh_psize, size_t buf_size)
 		return 0;
 	}
 
-	if (sh_psize > min_t(u32, buf_size, max_size))
-		return 0;
-
-	return sh_psize;
+	return sh_psize <= min_t(u32, buf_size, max_size);
 }
 
 /*
@@ -323,7 +320,6 @@ static int verify_patch(const u8 *buf, size_t buf_size, u32 *patch_size)
 {
 	u8 family = x86_family(bsp_cpuid_1_eax);
 	struct microcode_header_amd *mc_hdr;
-	unsigned int ret;
 	u32 sh_psize;
 	u16 proc_id;
 	u8 patch_fam;
@@ -347,8 +343,7 @@ static int verify_patch(const u8 *buf, size_t buf_size, u32 *patch_size)
 		return -1;
 	}
 
-	ret = __verify_patch_size(sh_psize, buf_size);
-	if (!ret) {
+	if (!__verify_patch_size(sh_psize, buf_size)) {
 		pr_debug("Per-family patch size mismatch.\n");
 		return -1;
 	}
-- 
2.34.1


  parent reply	other threads:[~2024-10-18 15:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 15:51 [PATCH 0/3] Minor cleanups in AMD microcode loader Nikolay Borisov
2024-10-18 15:51 ` [PATCH 1/3] x86/microcode/AMD: Return bool from find_blobs_in_containers() Nikolay Borisov
2024-11-14 10:16   ` Borislav Petkov
2025-01-01 12:14   ` [tip: x86/microcode] " tip-bot2 for Nikolay Borisov
2024-10-18 15:51 ` Nikolay Borisov [this message]
2024-11-14 12:58   ` [PATCH 2/3] x86/microcode/AMD: Make __verify_patch_size() return bool Borislav Petkov
2024-11-14 13:19     ` Nikolay Borisov
2024-11-14 14:01       ` Borislav Petkov
2024-11-14 14:13         ` Nikolay Borisov
2024-11-14 14:26           ` Borislav Petkov
2024-11-14 14:40             ` Nikolay Borisov
2024-11-14 15:47               ` Borislav Petkov
2024-11-15 16:43                 ` Borislav Petkov
2025-01-01 12:14   ` [tip: x86/microcode] " tip-bot2 for Nikolay Borisov
2024-10-18 15:51 ` [PATCH 3/3] x86/microcode/AMD: Remove bogus comment from parse_container() Nikolay Borisov
2025-01-01 12:14   ` [tip: x86/microcode] " tip-bot2 for Nikolay Borisov

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=20241018155151.702350-3-nik.borisov@suse.com \
    --to=nik.borisov@suse.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@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®