Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2b9c1f03 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Greg Kroah-Hartman
Browse files

x86: align x86 arch with generic CPU modalias handling



The x86 CPU feature modalias handling existed before it was reimplemented
generically. This patch aligns the x86 handling so that it
(a) reuses some more code that is now generic;
(b) uses the generic format for the modalias module metadata entry, i.e., it
    now uses 'cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:,XXXX,YYYY' instead of
    the 'x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:,XXXX,YYYY' that was
    used before.

Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 67bad2fd
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ config X86
	select HAVE_DEBUG_STACKOVERFLOW
	select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
	select HAVE_CC_STACKPROTECTOR
	select GENERIC_CPU_AUTOPROBE

config INSTRUCTION_DECODER
	def_bool y
@@ -195,9 +196,6 @@ config ARCH_HAS_CPU_RELAX
config ARCH_HAS_CACHE_LINE_SIZE
	def_bool y

config ARCH_HAS_CPU_AUTOPROBE
	def_bool y

config HAVE_SETUP_PER_CPU_AREA
	def_bool y

+7 −0
Original line number Diff line number Diff line
@@ -541,6 +541,13 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
#define static_cpu_has_bug(bit)	static_cpu_has((bit))
#define boot_cpu_has_bug(bit)	cpu_has_bug(&boot_cpu_data, (bit))

#define MAX_CPU_FEATURES	(NCAPINTS * 32)
#define cpu_have_feature	boot_cpu_has

#define CPU_FEATURE_TYPEFMT	"x86,ven%04Xfam%04Xmod%04X"
#define CPU_FEATURE_TYPEVAL	boot_cpu_data.x86_vendor, boot_cpu_data.x86, \
				boot_cpu_data.x86_model

#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */

#endif /* _ASM_X86_CPUFEATURE_H */
+0 −42
Original line number Diff line number Diff line
@@ -47,45 +47,3 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
	return NULL;
}
EXPORT_SYMBOL(x86_match_cpu);

ssize_t arch_print_cpu_modalias(struct device *dev,
				struct device_attribute *attr,
				char *bufptr)
{
	int size = PAGE_SIZE;
	int i, n;
	char *buf = bufptr;

	n = snprintf(buf, size, "x86cpu:vendor:%04X:family:%04X:"
		     "model:%04X:feature:",
		boot_cpu_data.x86_vendor,
		boot_cpu_data.x86,
		boot_cpu_data.x86_model);
	size -= n;
	buf += n;
	size -= 1;
	for (i = 0; i < NCAPINTS*32; i++) {
		if (boot_cpu_has(i)) {
			n = snprintf(buf, size, ",%04X", i);
			if (n >= size) {
				WARN(1, "x86 features overflow page\n");
				break;
			}
			size -= n;
			buf += n;
		}
	}
	*buf++ = '\n';
	return buf - bufptr;
}

int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
{
	char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
	if (buf) {
		arch_print_cpu_modalias(NULL, NULL, buf);
		add_uevent_var(env, "MODALIAS=%s", buf);
		kfree(buf);
	}
	return 0;
}
+0 −5
Original line number Diff line number Diff line
@@ -185,13 +185,8 @@ config GENERIC_CPU_DEVICES
	bool
	default n

config HAVE_CPU_AUTOPROBE
	def_bool ARCH_HAS_CPU_AUTOPROBE

config GENERIC_CPU_AUTOPROBE
	bool
	depends on !ARCH_HAS_CPU_AUTOPROBE
	select HAVE_CPU_AUTOPROBE

config SOC_BUS
	bool
+3 −7
Original line number Diff line number Diff line
@@ -287,7 +287,6 @@ static void cpu_device_release(struct device *dev)
	 */
}

#ifdef CONFIG_HAVE_CPU_AUTOPROBE
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
static ssize_t print_cpu_modalias(struct device *dev,
				  struct device_attribute *attr,
@@ -310,9 +309,6 @@ static ssize_t print_cpu_modalias(struct device *dev,
	buf[n++] = '\n';
	return n;
}
#else
#define print_cpu_modalias	arch_print_cpu_modalias
#endif

static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
{
@@ -346,7 +342,7 @@ int register_cpu(struct cpu *cpu, int num)
	cpu->dev.offline_disabled = !cpu->hotpluggable;
	cpu->dev.offline = !cpu_online(num);
	cpu->dev.of_node = of_get_cpu_node(num, NULL);
#ifdef CONFIG_HAVE_CPU_AUTOPROBE
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
	cpu->dev.bus->uevent = cpu_uevent;
#endif
	cpu->dev.groups = common_cpu_attr_groups;
@@ -370,7 +366,7 @@ struct device *get_cpu_device(unsigned cpu)
}
EXPORT_SYMBOL_GPL(get_cpu_device);

#ifdef CONFIG_HAVE_CPU_AUTOPROBE
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
static DEVICE_ATTR(modalias, 0444, print_cpu_modalias, NULL);
#endif

@@ -384,7 +380,7 @@ static struct attribute *cpu_root_attrs[] = {
	&cpu_attrs[2].attr.attr,
	&dev_attr_kernel_max.attr,
	&dev_attr_offline.attr,
#ifdef CONFIG_HAVE_CPU_AUTOPROBE
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
	&dev_attr_modalias.attr,
#endif
	NULL
Loading