All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 07/11] x86/ucode/amd: Alter API for microcode_fits()
Date: Tue, 31 Mar 2020 11:05:27 +0100	[thread overview]
Message-ID: <20200331100531.4294-8-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20200331100531.4294-1-andrew.cooper3@citrix.com>

Although it is logically a step in the wrong direction overall, it simplifies
the rearranging of cpu_request_microcode() substantially for microcode_fits()
to take struct microcode_header_amd directly, and not require an intermediate
struct microcode_amd pointing at it.

Make this change (taking time to rename 'mc_amd' to its eventual 'patch' to
reduce the churn in the series), and a later cleanup will make it uniformly
take a struct microcode_patch.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/cpu/microcode/amd.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/amd.c
index 8318664f85..254f3dd4d7 100644
--- a/xen/arch/x86/cpu/microcode/amd.c
+++ b/xen/arch/x86/cpu/microcode/amd.c
@@ -173,31 +173,30 @@ static bool check_final_patch_levels(const struct cpu_signature *sig)
 }
 
 static enum microcode_match_result microcode_fits(
-    const struct microcode_amd *mc_amd)
+    const struct microcode_header_amd *patch)
 {
     unsigned int cpu = smp_processor_id();
     const struct cpu_signature *sig = &per_cpu(cpu_sig, cpu);
-    const struct microcode_header_amd *mc_header = mc_amd->mpb;
 
     if ( equiv.sig != sig->sig ||
-         equiv.id  != mc_header->processor_rev_id )
+         equiv.id  != patch->processor_rev_id )
         return MIS_UCODE;
 
-    if ( mc_header->patch_id <= sig->rev )
+    if ( patch->patch_id <= sig->rev )
     {
         pr_debug("microcode: patch is already at required level or greater.\n");
         return OLD_UCODE;
     }
 
     pr_debug("microcode: CPU%d found a matching microcode update with version %#x (current=%#x)\n",
-             cpu, mc_header->patch_id, sig->rev);
+             cpu, patch->patch_id, sig->rev);
 
     return NEW_UCODE;
 }
 
 static bool match_cpu(const struct microcode_patch *patch)
 {
-    return patch && (microcode_fits(patch) == NEW_UCODE);
+    return patch && (microcode_fits(patch->mpb) == NEW_UCODE);
 }
 
 static void free_patch(struct microcode_patch *mc_amd)
@@ -223,14 +222,11 @@ static enum microcode_match_result compare_header(
 static enum microcode_match_result compare_patch(
     const struct microcode_patch *new, const struct microcode_patch *old)
 {
-    const struct microcode_header_amd *new_header = new->mpb;
-    const struct microcode_header_amd *old_header = old->mpb;
-
     /* Both patches to compare are supposed to be applicable to local CPU. */
-    ASSERT(microcode_fits(new) != MIS_UCODE);
-    ASSERT(microcode_fits(old) != MIS_UCODE);
+    ASSERT(microcode_fits(new->mpb) != MIS_UCODE);
+    ASSERT(microcode_fits(old->mpb) != MIS_UCODE);
 
-    return compare_header(new_header, old_header);
+    return compare_header(new->mpb, old->mpb);
 }
 
 static int apply_microcode(const struct microcode_patch *patch)
@@ -509,7 +505,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf,
          * If the new ucode covers current CPU, compare ucodes and store the
          * one with higher revision.
          */
-        if ( (microcode_fits(mc_amd) != MIS_UCODE) &&
+        if ( (microcode_fits(mc_amd->mpb) != MIS_UCODE) &&
              (!saved || (compare_header(mc_amd->mpb, saved) == NEW_UCODE)) )
         {
             xfree(saved);
-- 
2.11.0



  parent reply	other threads:[~2020-03-31 10:06 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 10:05 [PATCH 00/11] x86/ucode: Cleanup and fixes - Part 4/n (AMD) Andrew Cooper
2020-03-31 10:05 ` [PATCH 01/11] x86/ucode/amd: Fix more potential buffer overruns with microcode parsing Andrew Cooper
2020-03-31 10:05 ` [PATCH 02/11] x86/ucode/amd: Move check_final_patch_levels() to apply_microcode() Andrew Cooper
2020-03-31 14:27   ` Jan Beulich
2020-03-31 10:05 ` [PATCH 03/11] x86/ucode/amd: Don't use void * for microcode_patch->mpb Andrew Cooper
2020-03-31 14:28   ` Jan Beulich
2020-03-31 10:05 ` [PATCH 04/11] x86/ucode/amd: Collect CPUID.1.EAX in collect_cpu_info() Andrew Cooper
2020-03-31 14:29   ` Jan Beulich
2020-03-31 10:05 ` [PATCH 05/11] x86/ucode/amd: Overhaul the equivalent cpu table handling completely Andrew Cooper
2020-03-31 14:36   ` Jan Beulich
2020-03-31 10:05 ` [PATCH 06/11] x86/ucode/amd: Move verify_patch_size() into get_ucode_from_buffer_amd() Andrew Cooper
2020-03-31 14:38   ` Jan Beulich
2020-03-31 10:05 ` Andrew Cooper [this message]
2020-03-31 14:39   ` [PATCH 07/11] x86/ucode/amd: Alter API for microcode_fits() Jan Beulich
2020-03-31 10:05 ` [PATCH 08/11] x86/ucode/amd: Rename bufsize to size in cpu_request_microcode() Andrew Cooper
2020-03-31 14:41   ` Jan Beulich
2020-03-31 14:43     ` Andrew Cooper
2020-03-31 10:05 ` [PATCH 09/11] x86/ucode/amd: Remove gratuitous memory allocations from cpu_request_microcode() Andrew Cooper
2020-03-31 14:51   ` Jan Beulich
2020-03-31 14:55     ` Andrew Cooper
2020-03-31 15:13       ` Jan Beulich
2020-03-31 15:47         ` Andrew Cooper
2020-03-31 15:52           ` Jan Beulich
2020-03-31 10:05 ` [PATCH 10/11] x86/ucode/amd: Fold structures together Andrew Cooper
2020-03-31 14:53   ` Jan Beulich
2020-03-31 10:05 ` [PATCH 11/11] x86/ucode/amd: Rework parsing logic in cpu_request_microcode() Andrew Cooper
2020-03-31 15:07   ` Jan Beulich
2020-03-31 15:19     ` Andrew Cooper
2020-03-31 15:27       ` Jan Beulich
2020-03-31 15:55         ` Andrew Cooper
2020-03-31 16:00           ` Jan Beulich

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=20200331100531.4294-8-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.