]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
microcode/amd: call svm_host_osvw_init() in common code
authorChao Gao <chao.gao@intel.com>
Fri, 13 Sep 2019 10:31:01 +0000 (12:31 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 13 Sep 2019 10:31:01 +0000 (12:31 +0200)
Introduce a vendor hook, .end_update_percpu, for svm_host_osvw_init().
The hook function is called on each cpu after loading an update.
It is a preparation for spliting out apply_microcode() from
cpu_request_microcode().

Note that svm_host_osvm_init() should be called regardless of the
result of loading an update.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/microcode.c
xen/arch/x86/microcode_amd.c
xen/include/asm-x86/microcode.h

index 89a8d2b9e50b026257b7ee9eb0c315592394facc..5c82a2d4408656882a7a7b51d5c6abed7f0eb9e2 100644 (file)
@@ -276,6 +276,9 @@ static long do_microcode_update(void *_info)
     if ( error )
         info->error = error;
 
+    if ( microcode_ops->end_update_percpu )
+        microcode_ops->end_update_percpu();
+
     info->cpu = cpumask_next(info->cpu, &cpu_online_map);
     if ( info->cpu < nr_cpu_ids )
         return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info);
@@ -376,7 +379,12 @@ int __init early_microcode_update_cpu(bool start_update)
         if ( rc )
             return rc;
 
-        return microcode_update_cpu(data, len);
+        rc = microcode_update_cpu(data, len);
+
+        if ( microcode_ops->end_update_percpu )
+            microcode_ops->end_update_percpu();
+
+        return rc;
     }
     else
         return -ENOMEM;
index 1d27c7145f435ac0e544f89113a423cbf7dd6abd..b7812e848eda8f1d5a4a08a08e5e42934d39ab2c 100644 (file)
@@ -600,10 +600,6 @@ static int cpu_request_microcode(const void *buf, size_t bufsize)
     free_patch(mc_amd);
 
   out:
-#if CONFIG_HVM
-    svm_host_osvw_init();
-#endif
-
     /*
      * In some cases we may return an error even if processor's microcode has
      * been updated. For example, the first patch in a container file is loaded
@@ -613,29 +609,27 @@ static int cpu_request_microcode(const void *buf, size_t bufsize)
     return error;
 }
 
+#ifdef CONFIG_HVM
 static int start_update(void)
 {
-#if CONFIG_HVM
     /*
-     * We assume here that svm_host_osvw_init() will be called on each cpu (from
-     * cpu_request_microcode()).
-     *
-     * Note that if collect_cpu_info() returns an error then
-     * cpu_request_microcode() will not invoked thus leaving OSVW bits not
-     * updated. Currently though collect_cpu_info() will not fail on processors
-     * supporting OSVW so we will not deal with this possibility.
+     * svm_host_osvw_init() will be called on each cpu by calling '.end_update'
+     * in common code.
      */
     svm_host_osvw_reset();
-#endif
 
     return 0;
 }
+#endif
 
 static const struct microcode_ops microcode_amd_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
     .free_patch                       = free_patch,
     .compare_patch                    = compare_patch,
     .match_cpu                        = match_cpu,
index f2a5ea40399f135f32861d7dba257ef640f6ae7c..b0eee0ec02613bb74b2b800d9cb1e62643c7f59e 100644 (file)
@@ -24,6 +24,7 @@ struct microcode_ops {
     int (*collect_cpu_info)(struct cpu_signature *csig);
     int (*apply_microcode)(void);
     int (*start_update)(void);
+    void (*end_update_percpu)(void);
     void (*free_patch)(void *mc);
     bool (*match_cpu)(const struct microcode_patch *patch);
     enum microcode_match_result (*compare_patch)(