lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241025134727.GOZxuhb0MSVESR5juz@fat_crate.local>
Date: Fri, 25 Oct 2024 15:47:27 +0200
From: Borislav Petkov <bp@...en8.de>
To: Mario Limonciello <mario.limonciello@....com>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
	"H . Peter Anvin" <hpa@...or.com>,
	"Rafael J . Wysocki" <rafael@...nel.org>,
	"Gautham R . Shenoy" <gautham.shenoy@....com>,
	Perry Yuan <perry.yuan@....com>,
	Peter Zijlstra <peterz@...radead.org>,
	Li RongQing <lirongqing@...du.com>,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <linux-kernel@...r.kernel.org>,
	"open list:ACPI" <linux-acpi@...r.kernel.org>,
	"open list:AMD PSTATE DRIVER" <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v3 4/5] x86/cpu: Add CPU type to struct cpuinfo_topology

On Wed, Oct 23, 2024 at 12:43:56PM -0500, Mario Limonciello wrote:
> From: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
> 
> Sometimes it is required to take actions based on if a CPU is a performance
> or efficiency core. As an example, intel_pstate driver uses the Intel
> core-type to determine CPU scaling. Also, some CPU vulnerabilities only
> affect a specific CPU type, like RFDS only affects Intel Atom. Hybrid
> systems that have variants P+E, P-only(Core) and E-only(Atom), it is not
> straightforward to identify which variant is affected by a type specific
> vulnerability.
> 
> Such processors do have CPUID field that can uniquely identify them. Like,
> P+E, P-only and E-only enumerates CPUID.1A.CORE_TYPE identification, while
> P+E additionally enumerates CPUID.7.HYBRID. Based on this information, it
> is possible for boot CPU to identify if a system has mixed CPU types.
> 
> Add a new field hw_cpu_type to struct cpuinfo_topology that stores the
> hardware specific CPU type. This saves the overhead of IPIs to get the CPU
> type of a different CPU. CPU type is populated early in the boot process,
> before vulnerabilities are enumerated.
> 
> Signed-off-by: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
> Co-developed-by: Mario Limonciello <mario.limonciello@....com>
> Signed-off-by: Mario Limonciello <mario.limonciello@....com>
> ---
> v2->v3:
>  * Remove a bunch of boilerplate code
>  * Convert to showing string in debugfs
>  * Rename to get_topology_generic_cpu_type/get_topology_cpu_type_name
>  * Add Intel definitions to intel-family.h
> ---
>  arch/x86/include/asm/intel-family.h   |  6 +++++
>  arch/x86/include/asm/processor.h      | 18 ++++++++++++++
>  arch/x86/include/asm/topology.h       |  9 +++++++
>  arch/x86/kernel/cpu/debugfs.c         |  1 +
>  arch/x86/kernel/cpu/topology_amd.c    |  3 +++
>  arch/x86/kernel/cpu/topology_common.c | 34 +++++++++++++++++++++++++++
>  6 files changed, 71 insertions(+)

Except the minor touchup below, I don't have any complaints about this
anymore.

Intel folks?

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 795619ea1334..9f9376db64e3 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -156,7 +156,7 @@ extern unsigned int __num_threads_per_package;
 extern unsigned int __num_cores_per_package;
 
 const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c);
-enum x86_topology_cpu_type get_topology_generic_cpu_type(struct cpuinfo_x86 *c);
+enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c);
 
 static inline unsigned int topology_max_packages(void)
 {
diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c
index 60d5d74189a3..8277c64f88db 100644
--- a/arch/x86/kernel/cpu/topology_common.c
+++ b/arch/x86/kernel/cpu/topology_common.c
@@ -28,7 +28,7 @@ void topology_set_dom(struct topo_scan *tscan, enum x86_topology_domains dom,
 	}
 }
 
-enum x86_topology_cpu_type get_topology_generic_cpu_type(struct cpuinfo_x86 *c)
+enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c)
 {
 	if (c->x86_vendor == X86_VENDOR_INTEL) {
 		switch (c->topo.intel_type) {
@@ -48,7 +48,7 @@ enum x86_topology_cpu_type get_topology_generic_cpu_type(struct cpuinfo_x86 *c)
 
 const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c)
 {
-	switch (get_topology_generic_cpu_type(c)) {
+	switch (get_topology_cpu_type(c)) {
 	case TOPO_CPU_TYPE_PERFORMANCE:
 		return "performance";
 	case TOPO_CPU_TYPE_EFFICIENCY:

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ