Commit-ID:  3974b68114fed3735f623931e673538d8ab92d26
Gitweb:     https://git.kernel.org/tip/3974b68114fed3735f623931e673538d8ab92d26
Author:     Borislav Petkov <b...@suse.de>
AuthorDate: Thu, 28 Jun 2018 19:44:29 +0200
Committer:  Borislav Petkov <b...@suse.de>
CommitDate: Mon, 19 Nov 2018 10:45:08 +0100

x86/microcode/AMD: Move verify_patch_size() up in the file

... to enable later improvements.

No functional changes.

Signed-off-by: Borislav Petkov <b...@suse.de>
Cc: x...@kernel.org
Link: https://lkml.kernel.org/r/20181107170218.7596-4...@alien8.de
---
 arch/x86/kernel/cpu/microcode/amd.c | 82 ++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c 
b/arch/x86/kernel/cpu/microcode/amd.c
index 36aeb01b3ae8..f8d60cb9bb9a 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -174,6 +174,47 @@ static bool verify_patch_section(const u8 *buf, size_t 
buf_size, bool early)
        return true;
 }
 
+/*
+ * Check whether the passed remaining file @size is large enough to contain a
+ * patch of the indicated @patch_size (and also whether this size does not
+ * exceed the per-family maximum).
+ */
+static unsigned int verify_patch_size(u8 family, u32 patch_size, unsigned int 
size)
+{
+       u32 max_size;
+
+#define F1XH_MPB_MAX_SIZE 2048
+#define F14H_MPB_MAX_SIZE 1824
+#define F15H_MPB_MAX_SIZE 4096
+#define F16H_MPB_MAX_SIZE 3458
+#define F17H_MPB_MAX_SIZE 3200
+
+       switch (family) {
+       case 0x14:
+               max_size = F14H_MPB_MAX_SIZE;
+               break;
+       case 0x15:
+               max_size = F15H_MPB_MAX_SIZE;
+               break;
+       case 0x16:
+               max_size = F16H_MPB_MAX_SIZE;
+               break;
+       case 0x17:
+               max_size = F17H_MPB_MAX_SIZE;
+               break;
+       default:
+               max_size = F1XH_MPB_MAX_SIZE;
+               break;
+       }
+
+       if (patch_size > min_t(u32, size, max_size)) {
+               pr_err("patch size mismatch\n");
+               return 0;
+       }
+
+       return patch_size;
+}
+
 /*
  * This scans the ucode blob for the proper container as we can have multiple
  * containers glued together. Returns the equivalence ID from the equivalence
@@ -562,47 +603,6 @@ static int collect_cpu_info_amd(int cpu, struct 
cpu_signature *csig)
        return 0;
 }
 
-/*
- * Check whether the passed remaining file @size is large enough to contain a
- * patch of the indicated @patch_size (and also whether this size does not
- * exceed the per-family maximum).
- */
-static unsigned int verify_patch_size(u8 family, u32 patch_size, unsigned int 
size)
-{
-       u32 max_size;
-
-#define F1XH_MPB_MAX_SIZE 2048
-#define F14H_MPB_MAX_SIZE 1824
-#define F15H_MPB_MAX_SIZE 4096
-#define F16H_MPB_MAX_SIZE 3458
-#define F17H_MPB_MAX_SIZE 3200
-
-       switch (family) {
-       case 0x14:
-               max_size = F14H_MPB_MAX_SIZE;
-               break;
-       case 0x15:
-               max_size = F15H_MPB_MAX_SIZE;
-               break;
-       case 0x16:
-               max_size = F16H_MPB_MAX_SIZE;
-               break;
-       case 0x17:
-               max_size = F17H_MPB_MAX_SIZE;
-               break;
-       default:
-               max_size = F1XH_MPB_MAX_SIZE;
-               break;
-       }
-
-       if (patch_size > min_t(u32, size, max_size)) {
-               pr_err("patch size mismatch\n");
-               return 0;
-       }
-
-       return patch_size;
-}
-
 static enum ucode_state apply_microcode_amd(int cpu)
 {
        struct cpuinfo_x86 *c = &cpu_data(cpu);

Reply via email to