]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
x86/ucode: Fix errors with start/end_update()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 1 Jun 2020 14:37:20 +0000 (15:37 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 2 Jun 2020 18:18:44 +0000 (19:18 +0100)
c/s 9267a439c "x86/ucode: Document the behaviour of the microcode_ops hooks"
identified several poor behaviours of the start_update()/end_update_percpu()
hooks.

AMD have subsequently confirmed that OSVW don't, and are not expected to,
change across a microcode load, rendering all of this complexity unecessary.

Instead of fixing up the logic to not leave the OSVW state reset in a number
of corner cases, delete the logic entirely.

This in turn allows for the removal of the poorly-named 'start_update'
parameter to microcode_update_one(), and for svm_host_osvw_{init,reset}() to
become static.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Paul Durrant <paul@xen.org>
xen/arch/x86/acpi/power.c
xen/arch/x86/cpu/microcode/amd.c
xen/arch/x86/cpu/microcode/core.c
xen/arch/x86/cpu/microcode/private.h
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/smpboot.c
xen/include/asm-x86/hvm/svm/svm.h
xen/include/asm-x86/microcode.h

index 0cda362045fe6f0d431587dda50fe9858964305b..dfffe08e18fd7a5655def95bdf988259f4346c56 100644 (file)
@@ -287,7 +287,7 @@ static int enter_state(u32 state)
     console_end_sync();
     watchdog_enable();
 
-    microcode_update_one(true);
+    microcode_update_one();
 
     if ( !recheck_cpu_features(0) )
         panic("Missing previously available feature(s)\n");
index 3f0969e70dc6691483247880509ee746bb91b437..cd532321e8ca9b631a2d8a746e216bdeb3411775 100644 (file)
@@ -18,7 +18,6 @@
 #include <xen/init.h>
 #include <xen/mm.h> /* TODO: Fix asm/tlbflush.h breakage */
 
-#include <asm/hvm/svm/svm.h>
 #include <asm/msr.h>
 
 #include "private.h"
@@ -395,26 +394,9 @@ static struct microcode_patch *cpu_request_microcode(const void *buf, size_t siz
     return patch;
 }
 
-#ifdef CONFIG_HVM
-static int start_update(void)
-{
-    /*
-     * svm_host_osvw_init() will be called on each cpu by calling '.end_update'
-     * in common code.
-     */
-    svm_host_osvw_reset();
-
-    return 0;
-}
-#endif
-
 const struct microcode_ops amd_ucode_ops = {
     .cpu_request_microcode            = cpu_request_microcode,
     .collect_cpu_info                 = collect_cpu_info,
     .apply_microcode                  = apply_microcode,
-#ifdef CONFIG_HVM
-    .start_update                     = start_update,
-    .end_update_percpu                = svm_host_osvw_init,
-#endif
     .compare_patch                    = compare_patch,
 };
index d879d287873f73a688f064a47d56a26176d37fd8..18ebc07b13e1b98eb74b6b8ef09548c1928ce8dc 100644 (file)
@@ -546,9 +546,6 @@ static int do_microcode_update(void *patch)
     else
         ret = secondary_thread_fn();
 
-    if ( microcode_ops->end_update_percpu )
-        microcode_ops->end_update_percpu();
-
     return ret;
 }
 
@@ -620,16 +617,6 @@ static long microcode_update_helper(void *data)
     }
     spin_unlock(&microcode_mutex);
 
-    if ( microcode_ops->start_update )
-    {
-        ret = microcode_ops->start_update();
-        if ( ret )
-        {
-            microcode_free_patch(patch);
-            goto put;
-        }
-    }
-
     cpumask_clear(&cpu_callin_map);
     atomic_set(&cpu_out, 0);
     atomic_set(&cpu_updated, 0);
@@ -728,28 +715,14 @@ static int __init microcode_init(void)
 __initcall(microcode_init);
 
 /* Load a cached update to current cpu */
-int microcode_update_one(bool start_update)
+int microcode_update_one(void)
 {
-    int err;
-
     if ( !microcode_ops )
         return -EOPNOTSUPP;
 
     microcode_ops->collect_cpu_info();
 
-    if ( start_update && microcode_ops->start_update )
-    {
-        err = microcode_ops->start_update();
-        if ( err )
-            return err;
-    }
-
-    err = microcode_update_cpu(NULL);
-
-    if ( microcode_ops->end_update_percpu )
-        microcode_ops->end_update_percpu();
-
-    return err;
+    return microcode_update_cpu(NULL);
 }
 
 /* BSP calls this function to parse ucode blob and then apply an update. */
@@ -790,7 +763,7 @@ static int __init early_microcode_update_cpu(void)
     spin_unlock(&microcode_mutex);
     ASSERT(rc);
 
-    return microcode_update_one(true);
+    return microcode_update_one();
 }
 
 int __init early_microcode_init(void)
index dc5c7a81ae00a6b5ba1e3ef6243000e00ab75dde..c00ba590d193dc7105412edbdc33a15cb0b57404 100644 (file)
@@ -45,20 +45,6 @@ struct microcode_ops {
      */
     int (*apply_microcode)(const struct microcode_patch *patch);
 
-    /*
-     * Optional.  If provided and applicable to the specific update attempt,
-     * is run once by the initiating CPU.  Returning an error will abort the
-     * load attempt.
-     */
-    int (*start_update)(void);
-
-    /*
-     * Optional.  If provided, called on every CPU which completes a microcode
-     * load.  May be called in the case of some errors, and not others.  May
-     * be called even if start_update() wasn't.
-     */
-    void (*end_update_percpu)(void);
-
     /*
      * Given two patches, are they both applicable to the current CPU, and is
      * new a higher revision than old?
index 46a1aac94948c289de8306c86f7a30be08c7d5ef..44ff9d0c6b476ed0baa23f14c768ce54bcfaa4aa 100644 (file)
@@ -1084,7 +1084,7 @@ static void svm_guest_osvw_init(struct domain *d)
     spin_unlock(&osvw_lock);
 }
 
-void svm_host_osvw_reset()
+static void svm_host_osvw_reset(void)
 {
     spin_lock(&osvw_lock);
 
@@ -1094,7 +1094,7 @@ void svm_host_osvw_reset()
     spin_unlock(&osvw_lock);
 }
 
-void svm_host_osvw_init()
+static void svm_host_osvw_init(void)
 {
     spin_lock(&osvw_lock);
 
index 13b3dade9c3f7419d1d57ea8ada1a726f3ffbda9..f878a00760ee166bff36d5ea2ce04fa74d1fff60 100644 (file)
@@ -369,7 +369,7 @@ void start_secondary(void *unused)
 
     initialize_cpu_data(cpu);
 
-    microcode_update_one(false);
+    microcode_update_one();
 
     /*
      * If MSR_SPEC_CTRL is available, apply Xen's default setting and discard
index cd71402cbb8bd57ad2ea96760ca4731397e61169..d568e86db99139dcf7996f43da0c35302786b979 100644 (file)
@@ -94,9 +94,6 @@ extern u32 svm_feature_flags;
 #define DEFAULT_TSC_RATIO       0x0000000100000000ULL
 #define TSC_RATIO_RSVD_BITS     0xffffff0000000000ULL
 
-extern void svm_host_osvw_reset(void);
-extern void svm_host_osvw_init(void);
-
 /* EXITINFO1 fields on NPT faults */
 #define _NPT_PFEC_with_gla     32
 #define NPT_PFEC_with_gla      (1UL<<_NPT_PFEC_with_gla)
index 9da63f992e1aa5fec55f04b635c0f110d130c168..3b0234e9fa03d0a145a9597dac58aaaae8a7aaf3 100644 (file)
@@ -22,6 +22,6 @@ DECLARE_PER_CPU(struct cpu_signature, cpu_sig);
 void microcode_set_module(unsigned int idx);
 int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len);
 int early_microcode_init(void);
-int microcode_update_one(bool start_update);
+int microcode_update_one(void);
 
 #endif /* ASM_X86__MICROCODE_H */