Author: cem
Date: Mon Sep 11 20:41:25 2017
New Revision: 323462
URL: https://svnweb.freebsd.org/changeset/base/323462

Log:
  x86 MCA: Extract CMCI support predicate into function
  
  On AMD, the MCG_CAP feature bit is reserved -- not explicitly zero.  Do not
  use it to determine CMCI support.
  
  Reviewed by:  avg, markj
  Sponsored by: Dell EMC Isilon
  Differential Revision:        https://reviews.freebsd.org/D12320

Modified:
  head/sys/x86/x86/mca.c

Modified: head/sys/x86/x86/mca.c
==============================================================================
--- head/sys/x86/x86/mca.c      Mon Sep 11 20:33:20 2017        (r323461)
+++ head/sys/x86/x86/mca.c      Mon Sep 11 20:41:25 2017        (r323462)
@@ -149,6 +149,18 @@ amd_thresholding_supported(void)
 }
 #endif
 
+static inline bool
+cmci_supported(uint64_t mcg_cap)
+{
+       /*
+        * MCG_CAP_CMCI_P bit is reserved in AMD documentation.  Until
+        * it is defined, do not use it to check for CMCI support.
+        */
+       if (cpu_vendor_id != CPU_VENDOR_INTEL)
+               return (false);
+       return ((mcg_cap & MCG_CAP_CMCI_P) != 0);
+}
+
 static int
 sysctl_positive_int(SYSCTL_HANDLER_ARGS)
 {
@@ -322,7 +334,7 @@ mca_log(const struct mca_record *rec)
                printf("UNCOR ");
        else {
                printf("COR ");
-               if (rec->mr_mcg_cap & MCG_CAP_CMCI_P)
+               if (cmci_supported(rec->mr_mcg_cap))
                        printf("(%lld) ", ((long long)rec->mr_status &
                            MC_STATUS_COR_COUNT) >> 38);
        }
@@ -873,7 +885,7 @@ mca_setup(uint64_t mcg_cap)
            "force_scan", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0,
            sysctl_mca_scan, "I", "Force an immediate scan for machine checks");
 #ifdef DEV_APIC
-       if (mcg_cap & MCG_CAP_CMCI_P)
+       if (cmci_supported(mcg_cap))
                cmci_setup();
        else if (amd_thresholding_supported())
                amd_thresholding_setup();
@@ -1104,7 +1116,7 @@ _mca_init(int boot)
                                wrmsr(MSR_MC_CTL(i), ctl);
 
 #ifdef DEV_APIC
-                       if (mcg_cap & MCG_CAP_CMCI_P) {
+                       if (cmci_supported(mcg_cap)) {
                                if (boot)
                                        cmci_monitor(i);
                                else
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to