Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ard Biesheuvel and committed by
Greg Kroah-Hartman
2b9c1f03 67bad2fd

+16 -69
+1 -3
arch/x86/Kconfig
··· 127 127 select HAVE_DEBUG_STACKOVERFLOW 128 128 select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 129 129 select HAVE_CC_STACKPROTECTOR 130 + select GENERIC_CPU_AUTOPROBE 130 131 131 132 config INSTRUCTION_DECODER 132 133 def_bool y ··· 194 193 def_bool y 195 194 196 195 config ARCH_HAS_CACHE_LINE_SIZE 197 - def_bool y 198 - 199 - config ARCH_HAS_CPU_AUTOPROBE 200 196 def_bool y 201 197 202 198 config HAVE_SETUP_PER_CPU_AREA
+7
arch/x86/include/asm/cpufeature.h
··· 541 541 #define static_cpu_has_bug(bit) static_cpu_has((bit)) 542 542 #define boot_cpu_has_bug(bit) cpu_has_bug(&boot_cpu_data, (bit)) 543 543 544 + #define MAX_CPU_FEATURES (NCAPINTS * 32) 545 + #define cpu_have_feature boot_cpu_has 546 + 547 + #define CPU_FEATURE_TYPEFMT "x86,ven%04Xfam%04Xmod%04X" 548 + #define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \ 549 + boot_cpu_data.x86_model 550 + 544 551 #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ 545 552 546 553 #endif /* _ASM_X86_CPUFEATURE_H */
-42
arch/x86/kernel/cpu/match.c
··· 47 47 return NULL; 48 48 } 49 49 EXPORT_SYMBOL(x86_match_cpu); 50 - 51 - ssize_t arch_print_cpu_modalias(struct device *dev, 52 - struct device_attribute *attr, 53 - char *bufptr) 54 - { 55 - int size = PAGE_SIZE; 56 - int i, n; 57 - char *buf = bufptr; 58 - 59 - n = snprintf(buf, size, "x86cpu:vendor:%04X:family:%04X:" 60 - "model:%04X:feature:", 61 - boot_cpu_data.x86_vendor, 62 - boot_cpu_data.x86, 63 - boot_cpu_data.x86_model); 64 - size -= n; 65 - buf += n; 66 - size -= 1; 67 - for (i = 0; i < NCAPINTS*32; i++) { 68 - if (boot_cpu_has(i)) { 69 - n = snprintf(buf, size, ",%04X", i); 70 - if (n >= size) { 71 - WARN(1, "x86 features overflow page\n"); 72 - break; 73 - } 74 - size -= n; 75 - buf += n; 76 - } 77 - } 78 - *buf++ = '\n'; 79 - return buf - bufptr; 80 - } 81 - 82 - int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env) 83 - { 84 - char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL); 85 - if (buf) { 86 - arch_print_cpu_modalias(NULL, NULL, buf); 87 - add_uevent_var(env, "MODALIAS=%s", buf); 88 - kfree(buf); 89 - } 90 - return 0; 91 - }
-5
drivers/base/Kconfig
··· 185 185 bool 186 186 default n 187 187 188 - config HAVE_CPU_AUTOPROBE 189 - def_bool ARCH_HAS_CPU_AUTOPROBE 190 - 191 188 config GENERIC_CPU_AUTOPROBE 192 189 bool 193 - depends on !ARCH_HAS_CPU_AUTOPROBE 194 - select HAVE_CPU_AUTOPROBE 195 190 196 191 config SOC_BUS 197 192 bool
+3 -7
drivers/base/cpu.c
··· 287 287 */ 288 288 } 289 289 290 - #ifdef CONFIG_HAVE_CPU_AUTOPROBE 291 290 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE 292 291 static ssize_t print_cpu_modalias(struct device *dev, 293 292 struct device_attribute *attr, ··· 309 310 buf[n++] = '\n'; 310 311 return n; 311 312 } 312 - #else 313 - #define print_cpu_modalias arch_print_cpu_modalias 314 - #endif 315 313 316 314 static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env) 317 315 { ··· 342 346 cpu->dev.offline_disabled = !cpu->hotpluggable; 343 347 cpu->dev.offline = !cpu_online(num); 344 348 cpu->dev.of_node = of_get_cpu_node(num, NULL); 345 - #ifdef CONFIG_HAVE_CPU_AUTOPROBE 349 + #ifdef CONFIG_GENERIC_CPU_AUTOPROBE 346 350 cpu->dev.bus->uevent = cpu_uevent; 347 351 #endif 348 352 cpu->dev.groups = common_cpu_attr_groups; ··· 366 370 } 367 371 EXPORT_SYMBOL_GPL(get_cpu_device); 368 372 369 - #ifdef CONFIG_HAVE_CPU_AUTOPROBE 373 + #ifdef CONFIG_GENERIC_CPU_AUTOPROBE 370 374 static DEVICE_ATTR(modalias, 0444, print_cpu_modalias, NULL); 371 375 #endif 372 376 ··· 380 384 &cpu_attrs[2].attr.attr, 381 385 &dev_attr_kernel_max.attr, 382 386 &dev_attr_offline.attr, 383 - #ifdef CONFIG_HAVE_CPU_AUTOPROBE 387 + #ifdef CONFIG_GENERIC_CPU_AUTOPROBE 384 388 &dev_attr_modalias.attr, 385 389 #endif 386 390 NULL
-7
include/linux/cpu.h
··· 46 46 #endif 47 47 struct notifier_block; 48 48 49 - #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE 50 - extern int arch_cpu_uevent(struct device *dev, struct kobj_uevent_env *env); 51 - extern ssize_t arch_print_cpu_modalias(struct device *dev, 52 - struct device_attribute *attr, 53 - char *bufptr); 54 - #endif 55 - 56 49 /* 57 50 * CPU notifier priorities. 58 51 */
+5 -5
scripts/mod/file2alias.c
··· 1110 1110 } 1111 1111 ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); 1112 1112 1113 - /* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,* 1113 + /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* 1114 1114 * All fields are numbers. It would be nicer to use strings for vendor 1115 1115 * and feature, but getting those out of the build system here is too 1116 1116 * complicated. ··· 1124 1124 DEF_FIELD(symval, x86_cpu_id, model); 1125 1125 DEF_FIELD(symval, x86_cpu_id, vendor); 1126 1126 1127 - strcpy(alias, "x86cpu:"); 1128 - ADD(alias, "vendor:", vendor != X86_VENDOR_ANY, vendor); 1129 - ADD(alias, ":family:", family != X86_FAMILY_ANY, family); 1130 - ADD(alias, ":model:", model != X86_MODEL_ANY, model); 1127 + strcpy(alias, "cpu:type:x86,"); 1128 + ADD(alias, "ven", vendor != X86_VENDOR_ANY, vendor); 1129 + ADD(alias, "fam", family != X86_FAMILY_ANY, family); 1130 + ADD(alias, "mod", model != X86_MODEL_ANY, model); 1131 1131 strcat(alias, ":feature:*"); 1132 1132 if (feature != X86_FEATURE_ANY) 1133 1133 sprintf(alias + strlen(alias), "%04X*", feature);