diff mbox series

x86/MCE: mcequirk stuff is AMD-specific

Message ID 5C8B9EAB020000780021F439@prv1-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show
Series x86/MCE: mcequirk stuff is AMD-specific | expand

Commit Message

Jan Beulich March 15, 2019, 12:46 p.m. UTC
Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper March 15, 2019, 3:43 p.m. UTC | #1
On 15/03/2019 12:46, Jan Beulich wrote:
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/cpu/mcheck/mce_amd.c
> +++ b/xen/arch/x86/cpu/mcheck/mce_amd.c
> @@ -70,12 +70,22 @@
>  #include "x86_mca.h"
>  #include "mce_amd.h"
>  #include "mcaction.h"
> -#include "mce_quirks.h"
>  #include "vmce.h"
>  
> -#define ANY -1
> +#define ANY (~0U)
>  
> -static const struct mce_quirkdata mce_amd_quirks[] = {
> +enum mcequirk_amd_flags {
> +    MCEQUIRK_NONE,
> +    MCEQUIRK_K8_GART,
> +    MCEQUIRK_F10_GART

Seeing as you're modifying this, mind adding a trailing comma just in
case it needs extending in the future?

Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Jan Beulich March 15, 2019, 4:18 p.m. UTC | #2
>>> On 15.03.19 at 16:43, <andrew.cooper3@citrix.com> wrote:
> On 15/03/2019 12:46, Jan Beulich wrote:
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> --- a/xen/arch/x86/cpu/mcheck/mce_amd.c
>> +++ b/xen/arch/x86/cpu/mcheck/mce_amd.c
>> @@ -70,12 +70,22 @@
>>  #include "x86_mca.h"
>>  #include "mce_amd.h"
>>  #include "mcaction.h"
>> -#include "mce_quirks.h"
>>  #include "vmce.h"
>>  
>> -#define ANY -1
>> +#define ANY (~0U)
>>  
>> -static const struct mce_quirkdata mce_amd_quirks[] = {
>> +enum mcequirk_amd_flags {
>> +    MCEQUIRK_NONE,
>> +    MCEQUIRK_K8_GART,
>> +    MCEQUIRK_F10_GART
> 
> Seeing as you're modifying this, mind adding a trailing comma just in
> case it needs extending in the future?

Oh, sure - simply an oversight (or habit from private projects,
where I don't normally do this).

> Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thanks.

Jan
diff mbox series

Patch

--- a/xen/arch/x86/cpu/mcheck/mce_amd.c
+++ b/xen/arch/x86/cpu/mcheck/mce_amd.c
@@ -70,12 +70,22 @@ 
 #include "x86_mca.h"
 #include "mce_amd.h"
 #include "mcaction.h"
-#include "mce_quirks.h"
 #include "vmce.h"
 
-#define ANY -1
+#define ANY (~0U)
 
-static const struct mce_quirkdata mce_amd_quirks[] = {
+enum mcequirk_amd_flags {
+    MCEQUIRK_NONE,
+    MCEQUIRK_K8_GART,
+    MCEQUIRK_F10_GART
+};
+
+static const struct mce_quirkdata {
+    unsigned int cpu_family;
+    unsigned int cpu_model;
+    unsigned int cpu_stepping;
+    enum mcequirk_amd_flags quirk;
+} mce_amd_quirks[] = {
     { 0xf /* cpu family */, ANY /* all models */, ANY /* all steppings */,
       MCEQUIRK_K8_GART },
     { 0x10 /* cpu family */, ANY /* all models */, ANY /* all steppings */,
@@ -157,10 +167,10 @@  bool mc_amd_addrcheck(uint64_t status, u
 }
 
 /* MC quirks */
-enum mcequirk_amd_flags
-mcequirk_lookup_amd_quirkdata(struct cpuinfo_x86 *c)
+static enum mcequirk_amd_flags
+mcequirk_lookup_amd_quirkdata(const struct cpuinfo_x86 *c)
 {
-    int i;
+    unsigned int i;
 
     BUG_ON(c->x86_vendor != X86_VENDOR_AMD);
 
@@ -176,10 +186,11 @@  mcequirk_lookup_amd_quirkdata(struct cpu
                 continue;
         return mce_amd_quirks[i].quirk;
     }
-    return 0;
+
+    return MCEQUIRK_NONE;
 }
 
-int mcequirk_amd_apply(enum mcequirk_amd_flags flags)
+static void mcequirk_amd_apply(enum mcequirk_amd_flags flags)
 {
     uint64_t val;
 
@@ -197,11 +208,12 @@  int mcequirk_amd_apply(enum mcequirk_amd
 
     case MCEQUIRK_F10_GART:
         if ( rdmsr_safe(MSR_AMD64_MCx_MASK(4), val) == 0 )
-                wrmsr_safe(MSR_AMD64_MCx_MASK(4), val | (1 << 10));
+            wrmsr_safe(MSR_AMD64_MCx_MASK(4), val | (1 << 10));
         break;
-    }
 
-    return 0;
+    default:
+        ASSERT(flags == MCEQUIRK_NONE);
+    }
 }
 
 static struct mcinfo_extended *
--- a/xen/arch/x86/cpu/mcheck/mce_quirks.h
+++ /dev/null
@@ -1,53 +0,0 @@ 
-/* * MCA quirks
- * Copyright (c) 2009 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _MCE_QUIRK_H
-#define _MCE_QUIRK_H
-
-#include <xen/types.h>
-
-struct mce_quirkdata {
-	int32_t cpu_family;
-	int16_t cpu_model;
-	int16_t cpu_stepping;
-	uint32_t quirk;
-};
-
-/* use a binary flag if multiple quirks apply
- * to one CPU family/model
- */
-
-enum mcequirk_amd_flags {
-	MCEQUIRK_K8_GART = 2,
-	MCEQUIRK_F10_GART
-};
-
-enum mcequirk_intel_flags {
-	MCEQUIRK_DUMMY = 0x1, /* nothing known yet */
-};
-
-enum mcequirk_amd_flags
-mcequirk_lookup_amd_quirkdata(struct cpuinfo_x86 *c);
-
-int mcequirk_amd_apply(enum mcequirk_amd_flags flags);
-
-enum mcequirk_intel_flags
-mcequirk_lookup_intel_quirkdata(struct cpuinfo_x86 *c);
-
-int mcequirk_intel_apply(enum mcequirk_intel_flags flags);
-
-#endif /* _MCE_QUIRK_H */