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

x86: make get_cpu_vendor() accessible from Xen code

In order to be able to differentiate between AMD and Intel based
systems for very early hypercalls without having to rely on the Xen
hypercall page, make get_cpu_vendor() non-static.

Refactor early_cpu_init() for the same reason by splitting out the
loop initializing cpu_devs() into an externally callable function.

This is part of XSA-466 / CVE-2024-53241.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

+24 -16
+2
arch/x86/include/asm/processor.h
··· 230 230 return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT); 231 231 } 232 232 233 + void init_cpu_devs(void); 234 + void get_cpu_vendor(struct cpuinfo_x86 *c); 233 235 extern void early_cpu_init(void); 234 236 extern void identify_secondary_cpu(struct cpuinfo_x86 *); 235 237 extern void print_cpu_info(struct cpuinfo_x86 *);
+22 -16
arch/x86/kernel/cpu/common.c
··· 867 867 tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]); 868 868 } 869 869 870 - static void get_cpu_vendor(struct cpuinfo_x86 *c) 870 + void get_cpu_vendor(struct cpuinfo_x86 *c) 871 871 { 872 872 char *v = c->x86_vendor_id; 873 873 int i; ··· 1649 1649 detect_nopl(); 1650 1650 } 1651 1651 1652 - void __init early_cpu_init(void) 1652 + void __init init_cpu_devs(void) 1653 1653 { 1654 1654 const struct cpu_dev *const *cdev; 1655 1655 int count = 0; 1656 - 1657 - #ifdef CONFIG_PROCESSOR_SELECT 1658 - pr_info("KERNEL supported cpus:\n"); 1659 - #endif 1660 1656 1661 1657 for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) { 1662 1658 const struct cpu_dev *cpudev = *cdev; ··· 1661 1665 break; 1662 1666 cpu_devs[count] = cpudev; 1663 1667 count++; 1668 + } 1669 + } 1670 + 1671 + void __init early_cpu_init(void) 1672 + { 1673 + #ifdef CONFIG_PROCESSOR_SELECT 1674 + unsigned int i, j; 1675 + 1676 + pr_info("KERNEL supported cpus:\n"); 1677 + #endif 1678 + 1679 + init_cpu_devs(); 1664 1680 1665 1681 #ifdef CONFIG_PROCESSOR_SELECT 1666 - { 1667 - unsigned int j; 1668 - 1669 - for (j = 0; j < 2; j++) { 1670 - if (!cpudev->c_ident[j]) 1671 - continue; 1672 - pr_info(" %s %s\n", cpudev->c_vendor, 1673 - cpudev->c_ident[j]); 1674 - } 1682 + for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) { 1683 + for (j = 0; j < 2; j++) { 1684 + if (!cpu_devs[i]->c_ident[j]) 1685 + continue; 1686 + pr_info(" %s %s\n", cpu_devs[i]->c_vendor, 1687 + cpu_devs[i]->c_ident[j]); 1675 1688 } 1676 - #endif 1677 1689 } 1690 + #endif 1691 + 1678 1692 early_identify_cpu(&boot_cpu_data); 1679 1693 } 1680 1694