Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1370750imm; Sun, 23 Sep 2018 02:37:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UljhGf0sNrZspggLJPifHKks3oI5CSA5JwJcSYkFdMdZNmttGnLhoh/XVtoYNmYDh1ghE X-Received: by 2002:a17:902:59dd:: with SMTP id d29-v6mr5945861plj.34.1537695473036; Sun, 23 Sep 2018 02:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537695473; cv=none; d=google.com; s=arc-20160816; b=xmj6a4nyKwHGEJ/E6WbMeKRcN/akqV487tlk1MSMlvkW9VpIZyD5lmY46HQPV+hXqb HfbczZ3gpKIYLh70pSk1U7SqQeYs0Vcd+tyBwIbkHbSY3vfbcGwmebFXpS8abHl7PBV5 VF1CMv55WA6gtnI+7hFhLQ51E5mEbpSKwgEPdd7fC1uUGzQJIL/lJldt8YPwbVBNAsmu 5f4DrbOGj9OidXmBvfNSm/hSAjCL+bHQNZnZRtdC7TTzulbuHgmeGbzKG8FXVjOtflUY s+ITugbvsYmLGg3Q3wKOgvMe5bkyjyGTvBCIbp+vGXJWFXjd35YvoR5X2sGZFLNUxnUV BC5A== 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=7l7ECI7CtThJLlylAVNSos1cWJWz/BMsFnR18MvlVhU=; b=Am3GDwq8Kw5GuMjEpuCJp2CyRDWjKLXpOiya3U20qnapXHgUpkvoeEelMMFhgkum41 hb8k4KCt//jk+6lOE9EWHQg8mWcr2pL1F1Rr/p0E5nN1sHMiT/sx93Xk1wqjOleGBDFq v6xkKdF/mnLzMQilufq0cv9HHQ2U+r0n4Re3rRolr9yT0r19U1sg9PPtz34qc1NL7Kwr 8CBRpZdxVgg66+yXjFGAAvVjgaNhMgnG8Pwa8FQOeMaTYzqS8NWXwbFti3mithnqoMuR Ut9qKPrVE+mu0wbqogpCO9shAckRmUD9zvXOLxw3zkH3Cg9eizuJiAeygOV+klnZt1pr Sskw== 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 34-v6si31655421plz.492.2018.09.23.02.37.38; Sun, 23 Sep 2018 02:37:53 -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 S1726507AbeIWPeA (ORCPT + 99 others); Sun, 23 Sep 2018 11:34:00 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:49912 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726139AbeIWPeA (ORCPT ); Sun, 23 Sep 2018 11:34:00 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-01 (Coremail) with SMTP id qwCowADn77+xXqdbt2CzDA--.97S2; Sun, 23 Sep 2018 17:36:53 +0800 (CST) From: Pu Wen To: boris.ostrovsky@oracle.com, jgross@suse.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, Pu Wen Subject: [PATCH v8 12/16] x86/xen: Add Hygon Dhyana support to Xen Date: Sun, 23 Sep 2018 17:36:46 +0800 Message-Id: <311bf41f08f24550aa6c5da3f1e03a68d3b89dac.1537533369.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: qwCowADn77+xXqdbt2CzDA--.97S2 X-Coremail-Antispam: 1UD129KBjvJXoWxJryftF1ftw1fKFyfJF1fZwb_yoW8tFW7pr W3AF4IqFWvqwn7X3s5X3yxXryrZw1qqa15KrZxKa1fXa1rZ3Z8XrWjk3WrXr1fu348ur10 va40ga1UCFZYvFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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: [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 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(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 legacy and safe version of MSR access. It works fine when VPMU enabled in Xen on Hygon platform by testing with perf. Signed-off-by: Pu Wen Reviewed-by: Boris Ostrovsky --- 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