Received: by 10.192.165.148 with SMTP id m20csp428754imm; Fri, 20 Apr 2018 01:31:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Lb421xIuczM5WKmiXXkhIkDePI2JIPgbfBVVZXUdh+6VFoziMHGk5GAS+E/lc7uXIHgkr X-Received: by 10.99.43.70 with SMTP id r67mr5377220pgr.89.1524213069781; Fri, 20 Apr 2018 01:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524213069; cv=none; d=google.com; s=arc-20160816; b=jC00mF/cefHJak4JB8aOfcjQ6Zknowh9IpVjjXS38dQSdDEhrY7ihveVjqBSCWo77I ONJQ1SdEyQNgn71c7MVOib+k+l3d32AhM9YzJRBLQQAd+CkrxY/btYjetj/Cbk4WZklo /VSLFyjOJ6EDJlI7QbRfaElgR+TPBbCu7nEZyUx6IjGQ73AZNvAf2MZiPE9cVZm/tRLj MwL52PVkUm7i6hPskbmnG+nSbil50QwlbJm9LOVfxZoN6eKqrpWRaEpgqDToKt6msI94 r1jM2lkLiUeKpBWFCoAnvXiBKCoAli+QIbeYD+IPu5W0KwIk2dKnoddOg/RDVfLDgYWc cb1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=VcYtKiNvVf9x69v8XVPmyo5uwEZZkBhPqMCLZqBrrbk=; b=TSfUjIId7XggHiQDnUm8oqRbQp35pNy/vczSu+5Zuk3Qfq4saLbMwuVSrsI4rXBzrp ls/+thj9boahMwjU7x3gfYlSH6pYVNn5CoFGscD+28cdofFWgYJTP29joZ3QwrgomASy SgF3PX6K5g5tGgFUs5WGJg+hFOCggMseKmaEC5JfYi5FV21lN8/gF6np8xKG5swP2S0U WI/jiV6UPVIXnODsWiW5SCmcbS5weK6kVoTHgUY7X0gdZ/3mWY/E7uK2/kTWd6bYCPFu iZpqibooSoQQ99a5ya9lzpy3I5GXTMAu8H2Gs51lyuVLllgbGcCdyaFEPPbybbU770FH EkzQ== 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 u9-v6si5475140plz.10.2018.04.20.01.30.55; Fri, 20 Apr 2018 01:31:09 -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 S1754168AbeDTI3p (ORCPT + 99 others); Fri, 20 Apr 2018 04:29:45 -0400 Received: from zxshcas1.zhaoxin.com ([180.169.121.91]:31184 "EHLO ZXSHCAS1.zhaoxin.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754070AbeDTI3o (ORCPT ); Fri, 20 Apr 2018 04:29:44 -0400 Received: from zxbjmbx3.zhaoxin.com (10.29.252.165) by ZXSHCAS1.zhaoxin.com (10.28.252.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Fri, 20 Apr 2018 16:29:39 +0800 Received: from timguo-System-Product-Name.zhaoxin.com (10.29.8.54) by zxbjmbx3.zhaoxin.com (10.29.252.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Fri, 20 Apr 2018 16:29:38 +0800 From: David Wang To: , , , , , CC: , , , , , , David Wang Subject: [PATCH v2] x86/Centaur: show more HW features in /proc/cpuinfo Date: Fri, 20 Apr 2018 16:29:28 +0800 Message-ID: <1524212968-28998-1-git-send-email-davidwang@zhaoxin.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.29.8.54] X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To zxbjmbx3.zhaoxin.com (10.29.252.165) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Centaur CPU has some intel compatible capabilities,include PMC and some CPU virtualization capabilities. These capabilities should be initialized in the centaur init function. Signed-off-by: David Wang Changes from v1 to v2: *1, move some defines outside the centaur_detect_vmx_virtcap; *2, Delete some unuseful cap clear operaions in centaur_detect_vmx_virtcap; *3, other little changes according to sugesstions from tglx; --- arch/x86/kernel/cpu/centaur.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index e5ec0f1..80d5110 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -18,6 +18,13 @@ #define RNG_ENABLED (1 << 3) #define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */ +#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000 +#define X86_VMX_FEATURE_PROC_CTLS_VNMI 0x00400000 +#define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS 0x80000000 +#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC 0x00000001 +#define X86_VMX_FEATURE_PROC_CTLS2_EPT 0x00000002 +#define X86_VMX_FEATURE_PROC_CTLS2_VPID 0x00000020 + static void init_c3(struct cpuinfo_x86 *c) { u32 lo, hi; @@ -112,6 +119,31 @@ static void early_init_centaur(struct cpuinfo_x86 *c) } } +static void centaur_detect_vmx_virtcap(struct cpuinfo_x86 *c) +{ + u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2; + + rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high); + msr_ctl = vmx_msr_high | vmx_msr_low; + + if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW) + set_cpu_cap(c, X86_FEATURE_TPR_SHADOW); + if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI) + set_cpu_cap(c, X86_FEATURE_VNMI); + if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) { + rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2, + vmx_msr_low, vmx_msr_high); + msr_ctl2 = vmx_msr_high | vmx_msr_low; + if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) && + (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)) + set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY); + if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT) + set_cpu_cap(c, X86_FEATURE_EPT); + if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID) + set_cpu_cap(c, X86_FEATURE_VPID); + } +} + static void init_centaur(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_32 @@ -128,6 +160,19 @@ static void init_centaur(struct cpuinfo_x86 *c) clear_cpu_cap(c, 0*32+31); #endif early_init_centaur(c); + + if (c->cpuid_level > 9) { + unsigned int eax = cpuid_eax(10); + + /* + * Check for version and the number of counters + * Version(eax[7:0]) can't be 0; + * Counters(eax[15:8]) should be greater than 1; + */ + if ((eax & 0xff) && (((eax >> 8) & 0xff) > 1)) + set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON); + } + switch (c->x86) { #ifdef CONFIG_X86_32 case 5: @@ -199,6 +244,9 @@ static void init_centaur(struct cpuinfo_x86 *c) #ifdef CONFIG_X86_64 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); #endif + + if (cpu_has(c, X86_FEATURE_VMX)) + centaur_detect_vmx_virtcap(c); } #ifdef CONFIG_X86_32 -- 1.9.1