]> xenbits.xensource.com Git - xen.git/commitdiff
x86/ucode: Introduce ucode=allow-same for testing purposes
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 26 Oct 2020 15:32:12 +0000 (15:32 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 Jan 2021 20:29:43 +0000 (20:29 +0000)
Many CPUs will actually reload microcode when offered the same version as
currently loaded.  This allows for easy testing of the late microcode loading
path.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
docs/misc/xen-command-line.pandoc
xen/arch/x86/cpu/microcode/amd.c
xen/arch/x86/cpu/microcode/core.c
xen/arch/x86/cpu/microcode/intel.c
xen/arch/x86/cpu/microcode/private.h

index a713a0535c219665c231e61e9bae71b14c42d27b..4737c92bfecdea7742a1007c987080924295ee35 100644 (file)
@@ -2269,7 +2269,7 @@ logic applies:
    active by default.
 
 ### ucode
-> `= List of [ <integer> | scan=<bool>, nmi=<bool> ]`
+> `= List of [ <integer> | scan=<bool>, nmi=<bool>, allow-same=<bool> ]`
 
     Applicability: x86
     Default: `nmi`
@@ -2301,6 +2301,11 @@ precedence over `scan`.
 stop_machine context. In NMI handler, even NMIs are blocked, which is
 considered safer. The default value is `true`.
 
+'allow-same' alters the default acceptance policy for new microcode to permit
+trying to reload the same version.  Many CPUs will actually reload microcode
+of the same version, and this allows for easy testing of the late microcode
+loading path.
+
 ### unrestricted_guest (Intel)
 > `= <boolean>`
 
index 7d2f57c4cbac5a947c7a7c8c759bccb30c019021..5255028af7136602073ab2df6b0bd50be1058127 100644 (file)
@@ -174,6 +174,9 @@ static enum microcode_match_result compare_revisions(
     if ( new_rev > old_rev )
         return NEW_UCODE;
 
+    if ( opt_ucode_allow_same && new_rev == old_rev )
+        return NEW_UCODE;
+
     return OLD_UCODE;
 }
 
index 18ebc07b13e1b98eb74b6b8ef09548c1928ce8dc..ac3ceb567c4188ef391d807ad012f07cc3db8b41 100644 (file)
@@ -95,6 +95,8 @@ static bool_t __initdata ucode_scan;
 /* By default, ucode loading is done in NMI handler */
 static bool ucode_in_nmi = true;
 
+bool __read_mostly opt_ucode_allow_same;
+
 /* Protected by microcode_mutex */
 static struct microcode_patch *microcode_cache;
 
@@ -121,6 +123,8 @@ static int __init parse_ucode(const char *s)
 
         if ( (val = parse_boolean("nmi", s, ss)) >= 0 )
             ucode_in_nmi = val;
+        else if ( (val = parse_boolean("allow-same", s, ss)) >= 0 )
+            opt_ucode_allow_same = val;
         else if ( !ucode_mod_forced ) /* Not forced by EFI */
         {
             if ( (val = parse_boolean("scan", s, ss)) >= 0 )
index 5fa2821cdbc640b8bfa4b66eb5d158febccd2c8b..f6d01490e0abe01854c90834903a5748035d4c0f 100644 (file)
@@ -232,6 +232,9 @@ static enum microcode_match_result compare_revisions(
     if ( new_rev > old_rev )
         return NEW_UCODE;
 
+    if ( opt_ucode_allow_same && new_rev == old_rev )
+        return NEW_UCODE;
+
     /*
      * Treat pre-production as always applicable - anyone using pre-production
      * microcode knows what they are doing, and can keep any resulting pieces.
index 9a15cdc8790e84a79974f5909dfa74066f248beb..c085a10268471869ba2369de935433cfbdc996fc 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <asm/microcode.h>
 
+extern bool opt_ucode_allow_same;
+
 enum microcode_match_result {
     OLD_UCODE, /* signature matched, but revision id is older or equal */
     NEW_UCODE, /* signature matched, but revision id is newer */