Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2776600imm; Mon, 10 Sep 2018 06:23:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYapaI+Gwz796VptgouynyKjaXKLEmDeGOPPuGbjQY4A5NGD2I2CUKeNmrjB88B4r4hOhSA X-Received: by 2002:a62:2e02:: with SMTP id u2-v6mr23977589pfu.134.1536585827344; Mon, 10 Sep 2018 06:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536585827; cv=none; d=google.com; s=arc-20160816; b=e6x41wi7sZZOdQ9Qpsvgnc4m86xBvHL797QfrnFOulUZYlaAgWKQzPL7Lx1xLscgyS GQFKUO07UIc26BtbBMas43X2XYoUSwD3m2teQ0kTFunlJ6JsQOHJWH1KZGZG7myHuxgn 3HLPwvaHmXRFjbkIKct6tl0lDXchZT5lMNy5G9R88C3rMY4n987pIOoce2nGKILDD/yM fZtm61AEEksG42c0OQK+Bb/WkSl39hxFSZWO+p5zcLqqdfjGtOV3/ngdM1g47T5mrqD7 GdYwBrnB3+cIlIGiU4uJxm6vUV3WM1fR0J0948UxcD+yYVmx9NuY3lrTq+xXMAzDbyQ8 anzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=vqpSKzkwDuJTkKRTiGTn1ORmbLWvJW7wGPODgEg+5VI=; b=ToM+T91DcPT+j5TRwrs/3NM7Pbbj5P1PDdn6f6fBNCRGAKlFvZfwZ+ME2fm0DD62nW gEkOIL+wUrg9bTFiSe+oOapc8ROtO16VlcxokFqp3VHHbck+E7F8c+lHg+24d0uLvcYY xZWu9LPzY6hw2dxyiREFiHEp8cCbrbpKsk/7h78kOO6A2FJ8d9hWsrekhXPvVzpiOgw5 IypB+UCnM0zW9TD7d3vkY1njbYjOL5sp/+xdu+U1Qd+AdKQ0PKxVgLkmEdnXv8WP2vLZ 7BMJYj5Oqsq2bvJybMZERoHs980DTMf6s69ev2Rud8ZxixxnBIOFqw5nLmGoh1sFaFn8 MnxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si16456400pld.281.2018.09.10.06.23.01; Mon, 10 Sep 2018 06:23:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728844AbeIJSMQ (ORCPT + 99 others); Mon, 10 Sep 2018 14:12:16 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:52286 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728020AbeIJSMP (ORCPT ); Mon, 10 Sep 2018 14:12:15 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-10 (Coremail) with SMTP id tACowACnfe8Eb5ZbIgqaCQ--.1803S2; Mon, 10 Sep 2018 21:18:01 +0800 (CST) From: Pu Wen To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, bp@alien8.de, pbonzini@redhat.com, tony.luck@intel.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-edac@vger.kernel.org, Pu Wen Subject: [PATCH v6 10/16] x86/mce: Add Hygon Dhyana support to MCE infrastructure Date: Mon, 10 Sep 2018 21:17:54 +0800 Message-Id: <08410d871a1165d994265f20c2b979268de773be.1536550550.git.puwen@hygon.cn> X-Mail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E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43 ZEXa7VUbKLvtUUUUU== X-Originating-IP: [182.150.46.145] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The machine check architecture for Hygon Dhyana CPU is similar to the AMD family 17h one. To make MCE working on Hygon platforms, add vendor checking for Hygon Dhyana to share the code path of AMD family 17h. Signed-off-by: Pu Wen --- arch/x86/include/asm/mce.h | 2 ++ arch/x86/kernel/cpu/mcheck/mce-severity.c | 3 ++- arch/x86/kernel/cpu/mcheck/mce.c | 20 +++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 3a17107..550f2c9 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -214,6 +214,8 @@ static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { } static inline int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { return -EINVAL; }; #endif +static inline void mce_hygon_feature_init(struct cpuinfo_x86 *c) { return mce_amd_feature_init(c); } + int mce_available(struct cpuinfo_x86 *c); bool mce_is_memory_error(struct mce *m); diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c index f34d89c..44396d5 100644 --- a/arch/x86/kernel/cpu/mcheck/mce-severity.c +++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c @@ -336,7 +336,8 @@ int (*mce_severity)(struct mce *m, int tolerant, char **msg, bool is_excp) = void __init mcheck_vendor_init_severity(void) { - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) mce_severity = mce_severity_amd; } diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 953b3ce..909f1d7 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -270,7 +270,7 @@ static void print_mce(struct mce *m) { __print_mce(m); - if (m->cpuvendor != X86_VENDOR_AMD) + if (m->cpuvendor != X86_VENDOR_AMD && m->cpuvendor != X86_VENDOR_HYGON) pr_emerg_ratelimited(HW_ERR "Run the above through 'mcelog --ascii'\n"); } @@ -508,9 +508,9 @@ static int mce_usable_address(struct mce *m) bool mce_is_memory_error(struct mce *m) { - if (m->cpuvendor == X86_VENDOR_AMD) { + if (m->cpuvendor == X86_VENDOR_AMD || + m->cpuvendor == X86_VENDOR_HYGON) { return amd_mce_is_memory_error(m); - } else if (m->cpuvendor == X86_VENDOR_INTEL) { /* * Intel SDM Volume 3B - 15.9.2 Compound Error Codes @@ -539,6 +539,9 @@ static bool mce_is_correctable(struct mce *m) if (m->cpuvendor == X86_VENDOR_AMD && m->status & MCI_STATUS_DEFERRED) return false; + if (m->cpuvendor == X86_VENDOR_HYGON && m->status & MCI_STATUS_DEFERRED) + return false; + if (m->status & MCI_STATUS_UC) return false; @@ -1705,7 +1708,7 @@ static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c) */ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c) { - if (c->x86_vendor == X86_VENDOR_AMD) { + if (c->x86_vendor == X86_VENDOR_AMD || c->x86_vendor == X86_VENDOR_HYGON) { mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV); mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR); mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA); @@ -1746,6 +1749,11 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c) mce_amd_feature_init(c); break; } + + case X86_VENDOR_HYGON: + mce_hygon_feature_init(c); + break; + case X86_VENDOR_CENTAUR: mce_centaur_feature_init(c); break; @@ -1971,12 +1979,14 @@ static void mce_disable_error_reporting(void) static void vendor_disable_error_reporting(void) { /* - * Don't clear on Intel or AMD CPUs. Some of these MSRs are socket-wide. + * Don't clear on Intel or AMD or Hygon CPUs. Some of these MSRs + * are socket-wide. * Disabling them for just a single offlined CPU is bad, since it will * inhibit reporting for all shared resources on the socket like the * last level cache (LLC), the integrated memory controller (iMC), etc. */ if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL || + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON || boot_cpu_data.x86_vendor == X86_VENDOR_AMD) return; -- 2.7.4