[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] x86/ucode: Simplify the ops->collect_cpu_info() API



commit 990b6e38d93c6e60f9d81e8b71ddfd209fca00bd
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed Apr 1 16:18:32 2020 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Apr 3 20:11:46 2020 +0100

    x86/ucode: Simplify the ops->collect_cpu_info() API
    
    All callers pass &this_cpu(cpu_sig) for the cpu_sig parameter, and all
    implementations unconditionally return 0.  Simplify it to be void.
    
    Drop the long-stale comment on the AMD side, whose counterpart in
    start_update() used to be "collect_cpu_info() doesn't fail so we're fine".
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/cpu/microcode/amd.c     |  7 +++----
 xen/arch/x86/cpu/microcode/core.c    | 14 ++++++--------
 xen/arch/x86/cpu/microcode/intel.c   |  5 ++---
 xen/arch/x86/cpu/microcode/private.h |  7 +++++--
 4 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/amd.c
index e23bdef6f2..13bf9f4dee 100644
--- a/xen/arch/x86/cpu/microcode/amd.c
+++ b/xen/arch/x86/cpu/microcode/amd.c
@@ -90,9 +90,10 @@ static struct {
     uint16_t id;
 } equiv __read_mostly;
 
-/* See comment in start_update() for cases when this routine fails */
-static int collect_cpu_info(struct cpu_signature *csig)
+static void collect_cpu_info(void)
 {
+    struct cpu_signature *csig = &this_cpu(cpu_sig);
+
     memset(csig, 0, sizeof(*csig));
 
     csig->sig = cpuid_eax(1);
@@ -100,8 +101,6 @@ static int collect_cpu_info(struct cpu_signature *csig)
 
     pr_debug("microcode: CPU%d collect_cpu_info: patch_id=%#x\n",
              smp_processor_id(), csig->rev);
-
-    return 0;
 }
 
 static bool_t verify_patch_size(uint32_t patch_size)
diff --git a/xen/arch/x86/cpu/microcode/core.c 
b/xen/arch/x86/cpu/microcode/core.c
index 53e447ea9a..a220f908b8 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -237,10 +237,9 @@ static const struct microcode_patch *nmi_patch = 
ZERO_BLOCK_PTR;
  */
 static struct microcode_patch *parse_blob(const char *buf, size_t len)
 {
-    if ( likely(!microcode_ops->collect_cpu_info(&this_cpu(cpu_sig))) )
-        return microcode_ops->cpu_request_microcode(buf, len);
+    microcode_ops->collect_cpu_info();
 
-    return NULL;
+    return microcode_ops->cpu_request_microcode(buf, len);
 }
 
 static void microcode_free_patch(struct microcode_patch *patch)
@@ -306,10 +305,9 @@ static bool wait_cpu_callout(unsigned int nr)
  */
 static int microcode_update_cpu(const struct microcode_patch *patch)
 {
-    int err = microcode_ops->collect_cpu_info(&this_cpu(cpu_sig));
+    int err;
 
-    if ( unlikely(err) )
-        return err;
+    microcode_ops->collect_cpu_info();
 
     spin_lock(&microcode_mutex);
     if ( patch )
@@ -737,7 +735,7 @@ int microcode_update_one(bool start_update)
     if ( !microcode_ops )
         return -EOPNOTSUPP;
 
-    microcode_ops->collect_cpu_info(&this_cpu(cpu_sig));
+    microcode_ops->collect_cpu_info();
 
     if ( start_update && microcode_ops->start_update )
     {
@@ -819,7 +817,7 @@ int __init early_microcode_init(void)
         return -ENODEV;
     }
 
-    microcode_ops->collect_cpu_info(&this_cpu(cpu_sig));
+    microcode_ops->collect_cpu_info();
 
     if ( ucode_mod.mod_end || ucode_blob.size )
         rc = early_microcode_update_cpu();
diff --git a/xen/arch/x86/cpu/microcode/intel.c 
b/xen/arch/x86/cpu/microcode/intel.c
index 29745ed55f..a9f4d6e829 100644
--- a/xen/arch/x86/cpu/microcode/intel.c
+++ b/xen/arch/x86/cpu/microcode/intel.c
@@ -115,8 +115,9 @@ static bool signature_matches(const struct cpu_signature 
*cpu_sig,
     return cpu_sig->pf & ucode_pf;
 }
 
-static int collect_cpu_info(struct cpu_signature *csig)
+static void collect_cpu_info(void)
 {
+    struct cpu_signature *csig = &this_cpu(cpu_sig);
     uint64_t msr_content;
 
     memset(csig, 0, sizeof(*csig));
@@ -133,8 +134,6 @@ static int collect_cpu_info(struct cpu_signature *csig)
     csig->rev = (uint32_t)(msr_content >> 32);
     pr_debug("microcode: collect_cpu_info : sig=%#x, pf=%#x, rev=%#x\n",
              csig->sig, csig->pf, csig->rev);
-
-    return 0;
 }
 
 /*
diff --git a/xen/arch/x86/cpu/microcode/private.h 
b/xen/arch/x86/cpu/microcode/private.h
index 878f8d805f..dc5c7a81ae 100644
--- a/xen/arch/x86/cpu/microcode/private.h
+++ b/xen/arch/x86/cpu/microcode/private.h
@@ -33,8 +33,11 @@ struct microcode_ops {
     struct microcode_patch *(*cpu_request_microcode)(const void *buf,
                                                      size_t size);
 
-    /* Obtain microcode-relevant details for the current CPU. */
-    int (*collect_cpu_info)(struct cpu_signature *csig);
+    /*
+     * Obtain microcode-relevant details for the current CPU.  Results in
+     * per_cpu(cpu_sig).
+     */
+    void (*collect_cpu_info)(void);
 
     /*
      * Attempt to load the provided patch into the CPU.  Returns an error if
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.