Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2973737imm; Sun, 19 Aug 2018 09:13:07 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyY2LL8kejh/HDZ10mereynCmdwsg85SYydrxSS+MUlvZunUk6xAVg933Z/CcZhTnXWQc+y X-Received: by 2002:a17:902:9687:: with SMTP id n7-v6mr41275893plp.33.1534695187108; Sun, 19 Aug 2018 09:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534695187; cv=none; d=google.com; s=arc-20160816; b=xitPqdQ2GOEjCMt4J2ALzFjNoNzVWIgBmOx1Xugz3gSw5YfEKnDtVw7nTDRFNPYT7t U94RpyP+i7rJjG0PPIIXzEEs8S5cvGRe2AZ9I+PvmvItuK2Br2LtZaqBeNKNj9wWm+/P 3CMZbQjC9OaRri4xbLYCr6TF1QwpYI9/53yXMnNKgfKSg/tTWyxZyG5yVBo2vuk6UL4E gv2qsPflzuW1aLUPHw1mQ/gvz9+BbSdbplTDvhn4QsYMqGYyWMmenULLOYlCY4h9llff rdphH8CFE8EiI8H9j8vrdw+ERYJvBiG136OyXgTTlEnxIcP6wKioVP8OOBQb8ARWmX/9 hPHw== 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=1R6RtytU6rxbaGuhjMnA1iz8UyKBymJvx8YFUnlclxs=; b=HlIHXImfBU0otitUBonIPptJh5IWqT8e2UdlSiVcgt2fyyLrDU4kaYUtMmkKcAUCk8 COfwgRPXK07ou+xPAjV1CCHa2zbpyAVzhQ9EgwnEWan1TFAsBcmwHlgYoZBOVTENY6qw r+Va1fLZJENe8d/vpCyu2ZfKv4ht/krj9DIFVEQwCE32He+b8qWjAaVZhHb7MKhz9Cee CaCL/yfqpqf5f3D2F3ZyvsJZIwunAZoqGdfdYPk/x0sukf8r/MJwu+vy/YDniyxv8s8d yOg5d5qKam/fNSMWm0Pv4tfMCy6fkKAKv3kiS2tmULg9a/bXka/amzpsf9rfigQfPEe+ 7Zew== 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 p3-v6si7261121plk.295.2018.08.19.09.12.27; Sun, 19 Aug 2018 09:13:07 -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 S1726729AbeHSTVn (ORCPT + 99 others); Sun, 19 Aug 2018 15:21:43 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:46333 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726637AbeHSTVn (ORCPT ); Sun, 19 Aug 2018 15:21:43 -0400 Received: from localhost.localdomain (unknown [110.184.154.248]) by APP-10 (Coremail) with SMTP id tACowAAHDsY6lnlbWn6wAg--.565S2; Mon, 20 Aug 2018 00:09:35 +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 Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Pu Wen Subject: [PATCH v4 03/16] x86/mtrr: get MTRR number and support TOP_MEM2 Date: Mon, 20 Aug 2018 00:09:24 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: tACowAAHDsY6lnlbWn6wAg--.565S2 X-Coremail-Ant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SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hygon CPU have a special magic MSR way to force WB for memory >4GB, and also support TOP_MEM2. Therefore, it is necessary to add Hygon support in amd_special_default_mtrr(). The MtrrFixDramModEn bit on Hygon platform should also be set to 1 during BIOS initialization of the fixed MTRRs, then cleared to 0 for operation. The number of variable MTRRs for Hygon is 2 as AMD's. Signed-off-by: Pu Wen --- arch/x86/kernel/cpu/mtrr/cleanup.c | 3 ++- arch/x86/kernel/cpu/mtrr/generic.c | 5 +++-- arch/x86/kernel/cpu/mtrr/mtrr.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/mtrr/cleanup.c b/arch/x86/kernel/cpu/mtrr/cleanup.c index 765afd5..3668c5d 100644 --- a/arch/x86/kernel/cpu/mtrr/cleanup.c +++ b/arch/x86/kernel/cpu/mtrr/cleanup.c @@ -831,7 +831,8 @@ int __init amd_special_default_mtrr(void) { u32 l, h; - 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) return 0; if (boot_cpu_data.x86 < 0xf) return 0; diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index e12ee86..77c3eaa 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c @@ -49,8 +49,9 @@ static inline void k8_check_syscfg_dram_mod_en(void) { u32 lo, hi; - if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && - (boot_cpu_data.x86 >= 0x0f))) + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD && + boot_cpu_data.x86 >= 0x0f) || + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)) return; rdmsr(MSR_K8_SYSCFG, lo, hi); diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 9a19c80..507039c 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -127,7 +127,7 @@ static void __init set_num_var_ranges(void) if (use_intel()) rdmsr(MSR_MTRRcap, config, dummy); - else if (is_cpu(AMD)) + else if (is_cpu(AMD) || is_cpu(HYGON)) config = 2; else if (is_cpu(CYRIX) || is_cpu(CENTAUR)) config = 8; -- 2.7.4