Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2279744imm; Thu, 27 Sep 2018 10:08:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV621g3scWQDTn/sGRWqgyAsRx1qg6Ue/7wjf8z/mXOf101MrGdIbTEc3w7A+cB+1JNDDf/6t X-Received: by 2002:a17:902:d915:: with SMTP id c21-v6mr12022024plz.134.1538068131735; Thu, 27 Sep 2018 10:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538068131; cv=none; d=google.com; s=arc-20160816; b=WaXmPU/ApAQLxF+c04QwL+S9jNHhWWUcVVuCZMLOEFwesHiC8HGvDbEPV1y8cTYHwz JptqUxZB30wClloVJ+uTUC7aqB4dVLn2M6uurqytRsrsDppKQg2Rn7Sr+KZq/1GIjSHW +VNjug4GcJoV8PYObn2/oclc7APWmDzhoEa2L2KmIGDEk1tlE7nAurAobbGt7XYxoUJe RDTKOzvwTy42w0vQ7K71RPj42FJFQAAgBBklhrePj+fbg9UftSDFkrGf8b9jx9O7x0vH 6vpKLPaMFnhYY54/YYgMpUWQKNSrtqjbC/uN8P4GfaiuLcEq1KmZhkvblePk2Bfuy6mQ NUjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=ohR4fBs33WAgWt+Nr4Bw4EmCn/DkgjCESuyHim1JiY0=; b=BE1Imt9TPaHTVOns9to8/nM00fdpfBPfGpBAAUR8vZzD+Tv5lk8YkHhjLFc2itNgyA btj6t2i2vopJxpvh3jbWWOiNAVuP+9StdHUSGGZ8jro+xNhtW1I4+ZU5XB4nQYpi5TAA 8Hh3dYbANCr///cNdl28AZymj3Gma0kczIWF2HM5+BciFmGkEudKTSyoKHC++cpJ/HyM 4ATWmcBWB4+JwonWPI0gdee5PvNSl9CWwrvRcowcGoF6xpEOlkZDXUS1HGJZr+ptGDcg +iXgQAAbJBt68SZT+Rp8Ux+l8xchxXSyvSULnctSvCeTEG1QXAFpPeSSsoxllFEKDgll n8rQ== 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 q19-v6si2345709pll.72.2018.09.27.10.08.35; Thu, 27 Sep 2018 10:08:51 -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 S1728769AbeI0X1L (ORCPT + 99 others); Thu, 27 Sep 2018 19:27:11 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36403 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728352AbeI0X1K (ORCPT ); Thu, 27 Sep 2018 19:27:10 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8RH7jnu102311 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Sep 2018 10:07:45 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8RH7jxf102308; Thu, 27 Sep 2018 10:07:45 -0700 Date: Thu, 27 Sep 2018 10:07:45 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Pu Wen Message-ID: Cc: linux-kernel@vger.kernel.org, puwen@hygon.cn, boris.ostrovsky@oracle.com, tglx@linutronix.de, mingo@kernel.org, bp@suse.de, hpa@zytor.com Reply-To: hpa@zytor.com, bp@suse.de, mingo@kernel.org, linux-kernel@vger.kernel.org, puwen@hygon.cn, boris.ostrovsky@oracle.com, tglx@linutronix.de In-Reply-To: <311bf41f08f24550aa6c5da3f1e03a68d3b89dac.1537533369.git.puwen@hygon.cn> References: <311bf41f08f24550aa6c5da3f1e03a68d3b89dac.1537533369.git.puwen@hygon.cn> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/xen: Add Hygon Dhyana support to Xen Git-Commit-ID: 4044240365e85ef7ae43a6dc454669b57853124c X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_24_48 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4044240365e85ef7ae43a6dc454669b57853124c Gitweb: https://git.kernel.org/tip/4044240365e85ef7ae43a6dc454669b57853124c Author: Pu Wen AuthorDate: Sun, 23 Sep 2018 17:36:46 +0800 Committer: Borislav Petkov CommitDate: Thu, 27 Sep 2018 18:28:59 +0200 x86/xen: Add Hygon Dhyana support to Xen To make Xen work on the Hygon platform, reuse AMD's Xen support code path for Hygon Dhyana CPU. There are six core performance events counters per thread, so there are six MSRs for these counters. Also there are four legacy PMC MSRs, they are aliases of the counters. In this version, use the legacy and safe version of MSR access. Tested successfully with VPMU enabled in Xen on Hygon platform by testing with perf. Signed-off-by: Pu Wen Signed-off-by: Borislav Petkov Reviewed-by: Boris Ostrovsky Cc: jgross@suse.com Cc: tglx@linutronix.de Cc: mingo@redhat.com Cc: hpa@zytor.com Cc: x86@kernel.org Cc: thomas.lendacky@amd.com Cc: xen-devel@lists.xenproject.org Link: https://lkml.kernel.org/r/311bf41f08f24550aa6c5da3f1e03a68d3b89dac.1537533369.git.puwen@hygon.cn --- arch/x86/xen/pmu.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/pmu.c b/arch/x86/xen/pmu.c index 7d00d4ad44d4..9403854cde31 100644 --- a/arch/x86/xen/pmu.c +++ b/arch/x86/xen/pmu.c @@ -90,6 +90,12 @@ static void xen_pmu_arch_init(void) k7_counters_mirrored = 0; break; } + } else if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { + amd_num_counters = F10H_NUM_COUNTERS; + amd_counters_base = MSR_K7_PERFCTR0; + amd_ctrls_base = MSR_K7_EVNTSEL0; + amd_msr_step = 1; + k7_counters_mirrored = 0; } else { uint32_t eax, ebx, ecx, edx; @@ -285,7 +291,7 @@ static bool xen_amd_pmu_emulate(unsigned int msr, u64 *val, bool is_read) bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err) { - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { + if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) { if (is_amd_pmu_msr(msr)) { if (!xen_amd_pmu_emulate(msr, val, 1)) *val = native_read_msr_safe(msr, err); @@ -308,7 +314,7 @@ bool pmu_msr_write(unsigned int msr, uint32_t low, uint32_t high, int *err) { uint64_t val = ((uint64_t)high << 32) | low; - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { + if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) { if (is_amd_pmu_msr(msr)) { if (!xen_amd_pmu_emulate(msr, &val, 0)) *err = native_write_msr_safe(msr, low, high); @@ -379,7 +385,7 @@ static unsigned long long xen_intel_read_pmc(int counter) unsigned long long xen_read_pmc(int counter) { - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) return xen_amd_read_pmc(counter); else return xen_intel_read_pmc(counter);