Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2977218imm; Sun, 19 Aug 2018 09:16:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwZMsgmtkTk0Qru19wCydgMLDDSocolhtgC3/svA/BZeOWSRuvAuQOJgLN2Pqqm0vWNlONe X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr41633092pll.24.1534695410112; Sun, 19 Aug 2018 09:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534695410; cv=none; d=google.com; s=arc-20160816; b=D2H1VQ8VNU4kZ2VpY5KvnYoTbI73bd3kwYAdh6ZKbZ57/KEXo3Q3O4TOdHaViHOyZo lD4z7hLXNOIAYioXEh8txQsoso2xJ7CsmLFGY6v+MzifPceKlWPOY9L+xcNdJJnV1yWj 4g2rYTFv5DAXxse3UYN7ZSobjg+HDT5yM/GvseUrKAW7a8Vpz78ByB+nJP3aGBZghOoh CmM9vxAxShgYuZR97y+QGbFq6mqV8zX05PvFHW7eBt+vDgQQvEf4uvjlVi7+fK18BT1n ajDlwf+TBbailnqKJewAdDqrAKBx9BNie4XQDPE+Hfymwvhu2TMUTmkn+WZWqgMNXrZg TpMg== 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=Mh6xGetRQc5qLyW9pYGxJ+wUaZ/9m321A38zgf0hqps=; b=R4+F3Zk924G5AC6aiycKOXjUNfJ6/qkeqpWkIkJxERexIAGlldFh8qytxeia5aPQc0 xTQGxwHvyL2ZMvTg+Rn6iSEtCMh4uSkIjFnmwcfAdDA7Ux+EpFL7wNALERtr6qxKBhg9 hBbRK9XboY7bq/nJf6bkNDXGTcI8NYf8VcIEnGb5hCJa4mdMgAYt9+gbdGgtaF1rX+YL oqdJACFBg/bONfJ+YB8y3AY2Ml/6iuTtWJ0FyigLRuFu2eurlGiPKkKnGZ8K+HbyTE69 h+F388hf4rpb8knO8lgKTTToNlDWC5aVHG4XEdZOzABkBymJ96QbKt5iJXtPjQLLVhDu 6bRQ== 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 t10-v6si6495673pgn.370.2018.08.19.09.16.34; Sun, 19 Aug 2018 09:16:50 -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 S1726831AbeHST0X (ORCPT + 99 others); Sun, 19 Aug 2018 15:26:23 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:55245 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726618AbeHST0X (ORCPT ); Sun, 19 Aug 2018 15:26:23 -0400 Received: from localhost.localdomain (unknown [110.184.154.248]) by APP-10 (Coremail) with SMTP id tACowADn72NJl3lbn9GwAg--.152S2; Mon, 20 Aug 2018 00:14:06 +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 v4 12/16] x86/xen: enable Hygon support to Xen Date: Mon, 20 Aug 2018 00:13:41 +0800 Message-Id: <044e5e9082d57c10a36a16a9da6404f976d7ae55.1534599097.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: tACowADn72NJl3lbn9GwAg--.152S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr48XFyfCFW5CrWfJrW7XFb_yoW8tr45pr W3AF40qFWvgwn7X3s5X3y8XryrZw1qqa15Kr9xKa1fXFs5Z3Z8XrWUCw1rJr1I9348ur10 va40gw1UCFZavFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02 628vn2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c 02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_ GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7 CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAF wI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf 9x0JUD-B_UUUUU= X-Originating-IP: [110.184.154.248] 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 functionly on Hygon platforms, reuse AMD's Xen support code path for Hygon. 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. 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