Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4289509pxb; Mon, 8 Feb 2021 12:33:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxI26xO+Sx+eZ2fTU5M5LCdN0amPlaX/Hr59McR39HNLVyU4kLFyGo684s85KnOzTRYhGuz X-Received: by 2002:a17:906:7e49:: with SMTP id z9mr18456961ejr.293.1612816396979; Mon, 08 Feb 2021 12:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612816396; cv=none; d=google.com; s=arc-20160816; b=JMSDTSUrXWRau9nrEMRWX+/7QwdNp/HU3lVpYi95w/x8usIusAqEV5BfOdCX1P2pkE R1ueaOfBRtMZ7dyscJqHsWJ0M8PLuThBIRnQ48sFVhbnQHgv7dbXQeKIo6L3kB4H150k 5DSplroIuC/vlANhJRDHKDC+HWo7BwgJhVPyjmhWFPlkTIeSfBbbU6h3eyy0/V/4iLpO XskkdVokQkqKwN1v/k7mIuHKNvjOAvT+Zup7itMwsTsQ01uHQ/NRoobRkQST4stSqy0s o272jJn4UrncIIBH0jk9GaWy0I+vF6gRK42gMgxTHBRdA6PnJchTwT81Wq+THo59s7iU OrAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=2HUGvs5px+r1uBMmLlVURNR9FYLkIgoV6d+o5vBtTJA=; b=by9G/WDTnZkOzjqWTRG3pKq2xAHD+VtxOQfot6Z1Oi1RmuhLWQJRWLMy/2gunzP6ly lYy9hj4DtQyD4ts0ld7ls/2aJqtF8Ac7Tgk/phbuOOtvj8Ht4CaydHjVogMB6KT0lzKS uFis2H4I7WHY2yM/0qrQO7vElgrkx85t5U4/xW/yR3KBeMFFj/F20/43hpN1sxSNGID0 6Kp0Qj8zSpcrYuQp+eQOMGkgeY89Gp+dYhkVobR5J3gj55OuLlnaY0gBOBTxdUQmj1n+ BsDYDFO7Tntr3MU2CB9Y9dN/siPeHVvQe1Wuq9GpKkxi4WtfqJzAhQ8/b6ymenirOYX+ M3ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs7si13739089ejc.147.2021.02.08.12.32.51; Mon, 08 Feb 2021 12:33:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235329AbhBHU3q (ORCPT + 99 others); Mon, 8 Feb 2021 15:29:46 -0500 Received: from mga05.intel.com ([192.55.52.43]:54721 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236028AbhBHTG1 (ORCPT ); Mon, 8 Feb 2021 14:06:27 -0500 IronPort-SDR: FLtx/Uo0TKmgpRs8REt6uoJYD14gnkSu+DcdxGN1Bx12QD2EmiR6AWTIMhLJzk7iXibapHe0na SJHAAPjiJ6jg== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="266597679" X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="266597679" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 11:04:29 -0800 IronPort-SDR: U11Fj0FVC8pr92M/O5i2/+Qyw1XG4JcwB7u6TrOG4syTpu8p4xAjMX5hLB4TZyHsQ1nVUmSLrY EH5kWVOby33Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="377901719" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 08 Feb 2021 11:04:28 -0800 Received: from [10.255.228.220] (kliang2-MOBL.ccr.corp.intel.com [10.255.228.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 41D475808A1; Mon, 8 Feb 2021 11:04:26 -0800 (PST) Subject: Re: [PATCH 02/49] x86/cpu: Describe hybrid CPUs in cpuinfo_x86 To: Borislav Petkov Cc: peterz@infradead.org, acme@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, yao.jin@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, Ricardo Neri , Andy Lutomirski , Dave Hansen , "Rafael J. Wysocki" , "Ravi V. Shankar" , Sean Christopherson , Srinivas Pandruvada , Len Brown , Tony Luck References: <1612797946-18784-1-git-send-email-kan.liang@linux.intel.com> <1612797946-18784-3-git-send-email-kan.liang@linux.intel.com> <20210208175640.GD18227@zn.tnic> From: "Liang, Kan" Message-ID: Date: Mon, 8 Feb 2021 14:04:24 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210208175640.GD18227@zn.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/8/2021 12:56 PM, Borislav Petkov wrote: > On Mon, Feb 08, 2021 at 07:24:59AM -0800, kan.liang@linux.intel.com wrote: >> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h >> index c20a52b..1f25ac9 100644 >> --- a/arch/x86/include/asm/processor.h >> +++ b/arch/x86/include/asm/processor.h >> @@ -139,6 +139,16 @@ struct cpuinfo_x86 { >> u32 microcode; >> /* Address space bits used by the cache internally */ >> u8 x86_cache_bits; >> + /* >> + * In hybrid processors, there is a CPU type and a native model ID. The >> + * CPU type (x86_cpu_type[31:24]) describes the type of micro- >> + * architecture families. The native model ID (x86_cpu_type[23:0]) >> + * describes a specific microarchitecture version. Combining both >> + * allows to uniquely identify a CPU. >> + * >> + * Please note that the native model ID is not related to x86_model. >> + */ >> + u32 x86_cpu_type; > > Why are you adding it here instead of simply using > X86_FEATURE_HYBRID_CPU at the call site? > > How many uses in this patchset? > > /me searches... > > Exactly one. > > Just query X86_FEATURE_HYBRID_CPU at the call site and read what you > need from CPUID and use it there - no need for this. > I think it's good enough for perf, but I'm not sure whether other codes need the CPU type information. Ricardo, do you know? Maybe we should implement a generic function as below for this? (Not test. Just use as an example.) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index a66c1fd..679f5fe 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2056,3 +2056,11 @@ void arch_smt_update(void) /* Check whether IPI broadcasting can be enabled */ apic_smt_update(); } + +u32 x86_read_hybrid_type(void) +{ + if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) + return cpuid_eax(0x0000001a); + + return 0; +} Thanks, Kan