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

[PATCH 2/5] x86/ucode: Fold early_update_cache() into microcode_init_cache()


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 27 Mar 2023 20:41:23 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
  • Delivery-date: Mon, 27 Mar 2023 19:41:58 +0000
  • Ironport-data: A9a23:T2PxKa/qUbeyCuyvy2XTDrUDjX6TJUtcMsCJ2f8bNWPcYEJGY0x3n GQZDDvUOfuCNmP8c48iPt639k0GscSBnddhSwNopCw8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kI/1BjOkGlA5AdmPqoU5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklf3 6AzMC4yaSyxvN+ay66nddBgtPsaeZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUqGOkcUUrsUIMtWcOOAr3/zaTBH7nmSorI6+TP7xw1tyrn9dtHSf7RmQO0Mxh3A/ jKZrj+R7hcyOO2Ylgil3mKXr7HjoQW4f7MgFJmo6as/6LGU7jNKU0BHPbehmtGph0j7V99BJ kg8/is1sbN05EGtVsP6XRCzvDiDpBF0c/h6HvA+6QqN4rHJ+AvfDW8BJhZebPQ2uclwQiYlv mJlhPuwW2Yp6ufMDyvAqPHN92ja1TUpwXEqdAVYZhMb3N7fkroOohnTUulaHJyKt4igcd3v+ AxmvBTSlp1K05Faifvmpwuf696/jsOXF1Bov207Skrgt1okP9D9OuRE/HCBtZ59wJClok5tV ZTus+yX96gwAJ6Ej0Rhq81dTejyt55p3NAx6GOD/qXNFBz3oRZPhagKvFlDyL1VGsgFYyT1R 0TYpBlc4pReVFPzM/AmMt7oW591l/a4fTgAahwyRoAWCnSWXFHvwc2TTRTIgzCFfLYEyMnTx qt3ge7zVC1HWMyLPRK9RvsH0K9D+x3SMVj7HMihpzz+iOr2WZJgYetdWHOUcPsD5b+JyC2Mt Y432z2il08OD4UTo0D/reYuELz9BSFiXMus95UHJ7frz8gPMDhJNsI9CIgJI+RN95m5XM+Rl p1hcie0EGbCuEA=
  • Ironport-hdrordr: A9a23:Ss6r4qMpffVyZcBcTgajsMiBIKoaSvp037Eqv3oBLyC9E/b5qy nKpp8mPHDP6Qr5NEtQ/OxoW5PwOE80l6QFmbX5VI3KNGaJhILBFvAY0WKI+UyFJ8SRzJ876Y 5QN4VFJZnXK3MSt6rHCQ+DeeoI8Z283Jrtr8H44FdCcTpDVoFHyENCJjvzKDwUeCB2QZU4EZ aH5tlKvVObFEg/ZNigG38AU/PiirTw5fDbXSI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

It is not valid to retain a bootstrap_map() across returning back to
__start_xen(), but various pointers get stashed across calls.

Begin to address this by folding early_update_cache() into it's single caller,
rearranging the exit path to always invalidate the mapping.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
---
 xen/arch/x86/cpu/microcode/core.c | 54 +++++++++++++++++--------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c 
b/xen/arch/x86/cpu/microcode/core.c
index 11c471cc3f83..3d23e3ed7ee4 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -755,47 +755,51 @@ int microcode_update_one(void)
     return microcode_update_cpu(NULL);
 }
 
-static int __init early_update_cache(const void *data, size_t len)
+int __init microcode_init_cache(unsigned long *module_map,
+                                const struct multiboot_info *mbi)
 {
     int rc = 0;
     struct microcode_patch *patch;
+    struct ucode_mod_blob blob = {};
 
-    if ( !data )
-        return -ENOMEM;
+    if ( ucode_scan )
+        /* Need to rescan the modules because they might have been relocated */
+        microcode_scan_module(module_map, mbi);
+
+    if ( ucode_mod.mod_end )
+    {
+        blob.data = bootstrap_map(&ucode_mod);
+        blob.size = ucode_mod.mod_end;
+    }
+    else if ( ucode_blob.size )
+    {
+        blob = ucode_blob;
+    }
 
-    patch = parse_blob(data, len);
+    if ( !blob.data )
+        return 0;
+
+    patch = parse_blob(blob.data, blob.size);
     if ( IS_ERR(patch) )
     {
-        printk(XENLOG_WARNING "Parsing microcode blob error %ld\n",
-               PTR_ERR(patch));
-        return PTR_ERR(patch);
+        rc = PTR_ERR(patch);
+        printk(XENLOG_WARNING "Parsing microcode blob error %d\n", rc);
+        goto out;
     }
 
     if ( !patch )
-        return -ENOENT;
+    {
+        rc = -ENOENT;
+        goto out;
+    }
 
     spin_lock(&microcode_mutex);
     rc = microcode_update_cache(patch);
     spin_unlock(&microcode_mutex);
     ASSERT(rc);
 
-    return rc;
-}
-
-int __init microcode_init_cache(unsigned long *module_map,
-                                const struct multiboot_info *mbi)
-{
-    int rc = 0;
-
-    if ( ucode_scan )
-        /* Need to rescan the modules because they might have been relocated */
-        microcode_scan_module(module_map, mbi);
-
-    if ( ucode_mod.mod_end )
-        rc = early_update_cache(bootstrap_map(&ucode_mod),
-                                ucode_mod.mod_end);
-    else if ( ucode_blob.size )
-        rc = early_update_cache(ucode_blob.data, ucode_blob.size);
+ out:
+    bootstrap_map(NULL);
 
     return rc;
 }
-- 
2.30.2




 


Rackspace

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