Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp514518imm; Wed, 29 Aug 2018 05:47:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbfxOC3U0f6fqBcgqd1z81z9YDLw+XqztWeteiGkuKB8tKv6u7EAFN7ii4VK2OzExvX51gl X-Received: by 2002:a17:902:22e:: with SMTP id 43-v6mr5922185plc.118.1535546825967; Wed, 29 Aug 2018 05:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535546825; cv=none; d=google.com; s=arc-20160816; b=iQh/22tL3jRjISFTfZjGA/5/D7lS+Lq3jHT9zoFSqRAE1otXFDGJ9pbxb46LrQU3f6 y+oEXWptDpGdMmBGzkxkVQFT+Y74jkavukoMeeiRK9+FPzHC6FlgO+rZqJdT58MjIv3D LrnCn+xQnVVi0hVuJV/572pUyweYCCZ8n7+NT6s2sH7RMnRCmYzFHNIYrNcxCpExZXwj YCf4KVOL0/SaG7od5t+zzvhCkGPRdyqfG2sMeX4bW9S5BXLkAJ2OoYfi5nwSHwyg9FEv z87wqH0cOG1GMH/eJ4x+ZUaVPhlGhZgFEc7us6PuGkRkFYDNDXEF6hCtAhcMb9J/WH9C r+8g== 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:arc-authentication-results; bh=+/hJXWcMJ8n5X/M1TZqoTUyje2zUGO2Wt4hhcDuy4Hg=; b=X7mO7OpSKsqojB6O8E8KokXYi/zNsqzHedvlG9u7dNvM+INtnjoOjD0rUXVVGwTFop CN84nerx9L9UQHDCYvJMPVuJgp6SKatXxgGtc0th+E940QWn0tYuEP+R503NCKzf7UlO RFvUqnP9KjpIibE3+Zi6X9PwNr/mkkCBsq9gQObh93Dyzf4cBRtE3t0X38PB5Cl0OkZb TRINHEenJ159C5y6GyKmaKRbYxMCml0yvm95gfvCbouAsK8YWnA8MMvEHSS5ZmitqYRU TbRDZLSSXMxBIel3+Ezz4I/RajjaNExyLaggteyDj2TMp3E6JNZ39fl0iDMXfdvZG/e7 xisw== 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 f16-v6si3117131pgf.474.2018.08.29.05.46.50; Wed, 29 Aug 2018 05:47:05 -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 S1728677AbeH2Ql7 (ORCPT + 99 others); Wed, 29 Aug 2018 12:41:59 -0400 Received: from smtp17.cstnet.cn ([159.226.251.17]:49449 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727452AbeH2Ql7 (ORCPT ); Wed, 29 Aug 2018 12:41:59 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-09 (Coremail) with SMTP id swCowAAnCO1HlYZbIZr_BA--.76S2; Wed, 29 Aug 2018 20:44:58 +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 v5 10/16] x86/mce: enable Hygon support to MCE infrastructure Date: Wed, 29 Aug 2018 20:44:54 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: swCowAA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KLvtUUUUU== 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 Hygon machine check arch is similar to AMD family 17h. To enable the MCE infrastructure support, add CPU vendor check for Hygon to share the code path of AMD. Add hygon mce init function mce_hygon_feature_init() to minimize further maintenance effort. Signed-off-by: Pu Wen --- arch/x86/include/asm/mce.h | 5 +++++ arch/x86/kernel/cpu/mcheck/mce-severity.c | 3 ++- arch/x86/kernel/cpu/mcheck/mce.c | 21 +++++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 3a17107..12357aa 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -214,6 +214,11 @@ 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..12408a1 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -270,7 +270,8 @@ 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 +509,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 @@ -536,7 +537,9 @@ EXPORT_SYMBOL_GPL(mce_is_memory_error); static bool mce_is_correctable(struct mce *m) { - if (m->cpuvendor == X86_VENDOR_AMD && m->status & MCI_STATUS_DEFERRED) + if ((m->cpuvendor == X86_VENDOR_AMD || + m->cpuvendor == X86_VENDOR_HYGON) && + (m->status & MCI_STATUS_DEFERRED)) return false; if (m->status & MCI_STATUS_UC) @@ -1705,7 +1708,8 @@ 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 +1750,9 @@ 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 +1978,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