]> xenbits.xensource.com Git - xen.git/commitdiff
x86/spec-ctrl: Use a taint for CET without MSR_SPEC_CTRL
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Jun 2023 10:09:11 +0000 (11:09 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 3 Aug 2023 18:14:19 +0000 (19:14 +0100)
Reword the comment for 'S' to include an incompatible set of features on the
same core.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(cherry picked from commit 3f63f4510422c29fda7ba238b880cbb53eca34fe)

Also minimal fragments from:

  c/s 0bf9efb9ee4c ("xen/arm: Sanitize cpuinfo ID registers fields")

to introduce TAINT_CPU_OUT_OF_SPEC.

xen/arch/x86/spec_ctrl.c
xen/common/kernel.c
xen/include/xen/lib.h

index 9efc49ace7603a3618eb94cf5b28074b619699a3..44fb4c9d451eb82af868c729b390bb18513a7db1 100644 (file)
@@ -1112,7 +1112,10 @@ void __init init_speculation_mitigations(void)
     if ( read_cr4() & X86_CR4_CET )
     {
         if ( !has_spec_ctrl )
+        {
             printk(XENLOG_WARNING "?!? CET active, but no MSR_SPEC_CTRL?\n");
+            add_taint(TAINT_CPU_OUT_OF_SPEC);
+        }
         else if ( opt_ibrs == -1 )
             opt_ibrs = ibrs = true;
 
index f07ff41d881eedfa4a8b4860d6fd016b8d15162d..35c9489929adbef52befb3447826672e2a099ce1 100644 (file)
@@ -338,6 +338,7 @@ unsigned int tainted;
  *  'E' - An error (e.g. a machine check exceptions) has been injected.
  *  'H' - HVM forced emulation prefix is permitted.
  *  'M' - Machine had a machine check experience.
+ *  'S' - Out of spec CPU (Incompatible features on one or more cores).
  *
  *      The string is overwritten by the next call to print_taint().
  */
@@ -345,11 +346,12 @@ char *print_tainted(char *str)
 {
     if ( tainted )
     {
-        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c",
+        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c%c",
                  tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
                  tainted & TAINT_SYNC_CONSOLE ? 'C' : ' ',
                  tainted & TAINT_ERROR_INJECT ? 'E' : ' ',
-                 tainted & TAINT_HVM_FEP ? 'H' : ' ');
+                 tainted & TAINT_HVM_FEP ? 'H' : ' ',
+                 tainted & TAINT_CPU_OUT_OF_SPEC ? 'S' : ' ');
     }
     else
     {
index 900c0ce3e46658f2f7d4ecdf457b3f3b24ab8b82..c072d5a597a9f1dd6121b21bede473ec64f0a10a 100644 (file)
@@ -183,6 +183,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
 #define TAINT_MACHINE_CHECK             (1u << 1)
 #define TAINT_ERROR_INJECT              (1u << 2)
 #define TAINT_HVM_FEP                   (1u << 3)
+#define TAINT_CPU_OUT_OF_SPEC           (1u << 5)
 extern unsigned int tainted;
 #define TAINT_STRING_MAX_LEN            20
 extern char *print_tainted(char *str);