Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2775615imm; Mon, 10 Sep 2018 06:22:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYxskpMnlaEwRXvben/jE8NmaRsMqbQaGsmmjhgCqJ5KhCO0zSgRovSMRyFCOd7fhT29YnR X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr21574299plu.211.1536585775907; Mon, 10 Sep 2018 06:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536585775; cv=none; d=google.com; s=arc-20160816; b=axWXdaDTkMnwQ6XkHvOmSpVIkoOYNvSBuHHWnn4uQpwuojalnkz2kTKHVPy0poxJyF w9zdciVjAZbqtzPdjDvGyTCa5s5apIhJC7MDddoZMuOXeCoERDLT8+w7fIxJMgp2nKu+ svKgRnVsPnQ1obDzljo7qdbQVh3zRloayw1491p7UtIyfunTVXHo63EOfj7CelGo+/g9 XarLbvkNabSeoEIOZIl59ZTP8w/qQL88a2pLiGDOPxFrvtYL3X5KwKiAN8rhMQI9ROAz Bb3t+ws2vWD36UtNuj7L3n7wKRlwV3P5g+kRqd/+5qxzsfUtVIgjQcnyA8xSf7OT9s33 vU2g== 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=RbQWun1hrVWNawK5mCYz9Qp2sv23dlKjrAKIQA6FaG0=; b=d+B30oakcouBXFiOctOX7t3gw5kQI31vmmetwpeqFJXuN1y7vlI3+0nqfry/FrcjVy WAb7KcKOQXC4fwKP+TPCbFdV+5HeP7qiWCBPDijn8zHfId9xDMtWcgY4x8M29wLKUc9G pnzt/GVk9eWbA63QwBXGrApmwaPayCcXDFT7OKXH5XLJfWASMXMoUgdXnVghVapvYFCb m62V6FXgef0vNRNLCOyxYt1CJSgxOIccI12vX5wk0iccqtXTzs46ia1qJWTdsfOyn2DF v6B5oo59FvkhLnSMm4ZDH8J1oLxJq5KLNLkqyTVFlbrIrWi0829y69htyqoX03B16ybN avVQ== 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 z11-v6si15186357pgv.138.2018.09.10.06.22.39; Mon, 10 Sep 2018 06:22:55 -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 S1728727AbeIJSOF (ORCPT + 99 others); Mon, 10 Sep 2018 14:14:05 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:53025 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728365AbeIJSOE (ORCPT ); Mon, 10 Sep 2018 14:14:04 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-10 (Coremail) with SMTP id tACowAC3je9sb5ZbRSCaCQ--.1735S2; Mon, 10 Sep 2018 21:19:46 +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, boris.ostrovsky@oracle.com, jgross@suse.com, JBeulich@suse.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, Pu Wen Subject: [PATCH v6 12/16] x86/xen: Add Hygon Dhyana support to Xen Date: Mon, 10 Sep 2018 21:19:37 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: tACowAC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Fpf9x0JULTmhUUUUU= 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 To make Xen works functionally on Hygon platforms, 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(0-5). Also there are four legacy PMC MSRs, they are alias of the counters(0-3). In this version of kernel Hygon use the lagacy and safe versions of MSR access. It works fine when VPMU enabled in Xen on Hygon platforms by testing with perf. Reviewed-by: Boris Ostrovsky Signed-off-by: Pu Wen --- 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 7d00d4a..9403854 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); -- 2.7.4