]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/cpu/mce: Add Hygon Dhyana support to the MCA infrastructure
authorPu Wen <puwen@hygon.cn>
Thu, 4 Apr 2019 13:46:23 +0000 (21:46 +0800)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 6 Jun 2019 14:28:21 +0000 (15:28 +0100)
The machine check architecture for Hygon Dhyana CPU is similar to the
AMD family 17h one. Add vendor checking for Hygon Dhyana to share the
code path of AMD family 17h.

Signed-off-by: Pu Wen <puwen@hygon.cn>
Acked-by: Jan Beulich <jbeulich@suse.com>
[Rebase over 0cd074144cb "x86/cpu: Renumber X86_VENDOR_* to form a bitmap"]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/common.c
xen/arch/x86/cpu/mcheck/amd_nonfatal.c
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce_amd.c
xen/arch/x86/cpu/mcheck/non-fatal.c
xen/arch/x86/cpu/mcheck/vmce.c

index 31294927a1a29a5173d61d6df0515b18507eeb3f..4985a4a0ae8d77f1c3263bbe30c0a3804831f519 100644 (file)
@@ -331,7 +331,7 @@ void __init early_cpu_init(void)
                        hap_paddr_bits = PADDR_BITS;
        }
 
-       if (c->x86_vendor != X86_VENDOR_AMD)
+       if (!(c->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)))
                park_offline_cpus = opt_mce;
 
        initialize_cpu_data(0);
index 222f539b1eb909eabec1ff84e92b68997bb7ca7b..6e8901530a6971b0bb0e1873e75a8316455245f3 100644 (file)
@@ -203,10 +203,10 @@ static void mce_amd_work_fn(void *data)
 
 void __init amd_nonfatal_mcheck_init(struct cpuinfo_x86 *c)
 {
-       if (c->x86_vendor != X86_VENDOR_AMD)
+       if (!(c->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)))
                return;
 
-       /* Assume we are on K8 or newer AMD CPU here */
+       /* Assume we are on K8 or newer AMD or Hygon CPU here */
 
        /* The threshold bitfields in MSR_IA32_MC4_MISC has
         * been introduced along with the SVME feature bit. */
index 30cdb0640117cb3d7d4b28eb150c48496ce0a215..2d700036e9bf18ad9a95d5ec06ec4b793a5468c4 100644 (file)
@@ -778,6 +778,7 @@ void mcheck_init(struct cpuinfo_x86 *c, bool bsp)
     switch ( c->x86_vendor )
     {
     case X86_VENDOR_AMD:
+    case X86_VENDOR_HYGON:
         inited = amd_mcheck_init(c);
         break;
 
@@ -1172,10 +1173,10 @@ static bool x86_mc_msrinject_verify(struct xen_mc_msrinject *mci)
 
             /* MSRs that the HV will take care of */
             case MSR_K8_HWCR:
-                if ( c->x86_vendor == X86_VENDOR_AMD )
+                if ( c->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
                     reason = "HV will operate HWCR";
                 else
-                    reason = "only supported on AMD";
+                    reason = "only supported on AMD or Hygon";
                 break;
 
             default:
index ed29fcc312c5b73e2e5ec22ca696b37ced0ed4f2..9b2852cc7e7902845c35932634d40905f3be26ab 100644 (file)
@@ -286,7 +286,10 @@ enum mcheck_type
 amd_mcheck_init(struct cpuinfo_x86 *ci)
 {
     uint32_t i;
-    enum mcequirk_amd_flags quirkflag = mcequirk_lookup_amd_quirkdata(ci);
+    enum mcequirk_amd_flags quirkflag = 0;
+
+    if ( ci->x86_vendor != X86_VENDOR_HYGON )
+        quirkflag = mcequirk_lookup_amd_quirkdata(ci);
 
     /* Assume that machine check support is available.
      * The minimum provided support is at least the K8. */
index d12e8f23ba478335509facb2e6185a639e61745d..77be4185e448bbdbf73cdbb82fb68c6a08b33f53 100644 (file)
@@ -101,7 +101,8 @@ static int __init init_nonfatal_mce_checker(void)
         */
        switch (c->x86_vendor) {
        case X86_VENDOR_AMD:
-               /* Assume we are on K8 or newer AMD CPU here */
+       case X86_VENDOR_HYGON:
+               /* Assume we are on K8 or newer AMD or Hygon CPU here */
                amd_nonfatal_mcheck_init(c);
                break;
 
index f15835e9f60a611bc4eb6f3a13786c982e4c8eba..4f5de07e01bc0ae467b7788260238f3d6a4b32c0 100644 (file)
@@ -154,6 +154,7 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
             break;
 
         case X86_VENDOR_AMD:
+        case X86_VENDOR_HYGON:
             ret = vmce_amd_rdmsr(v, msr, val);
             break;
 
@@ -284,6 +285,7 @@ static int bank_mce_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
             break;
 
         case X86_VENDOR_AMD:
+        case X86_VENDOR_HYGON:
             ret = vmce_amd_wrmsr(v, msr, val);
             break;