]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86: make get_cpu_vendor() accessible from Xen code
authorJuergen Gross <jgross@suse.com>
Thu, 17 Oct 2024 06:29:48 +0000 (08:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Dec 2024 17:13:23 +0000 (18:13 +0100)
commit efbcd61d9bebb771c836a3b8bfced8165633db7c upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/common.c

index 4a686f0e5dbf6d906ed38276148b186e920927b3..2d776635aa539eb0b8537d495588c8873ac1c7eb 100644 (file)
@@ -212,6 +212,8 @@ static inline unsigned long long l1tf_pfn_limit(void)
        return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT);
 }
 
+void init_cpu_devs(void);
+void get_cpu_vendor(struct cpuinfo_x86 *c);
 extern void early_cpu_init(void);
 extern void identify_secondary_cpu(struct cpuinfo_x86 *);
 extern void print_cpu_info(struct cpuinfo_x86 *);
index b17bcf9b67eed470c59dad6a002902ff097ad033..f439763f45ae6fdc473cfe1e00eddcb105fecbdc 100644 (file)
@@ -868,7 +868,7 @@ static void cpu_detect_tlb(struct cpuinfo_x86 *c)
                tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]);
 }
 
-static void get_cpu_vendor(struct cpuinfo_x86 *c)
+void get_cpu_vendor(struct cpuinfo_x86 *c)
 {
        char *v = c->x86_vendor_id;
        int i;
@@ -1652,15 +1652,11 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
        detect_nopl();
 }
 
-void __init early_cpu_init(void)
+void __init init_cpu_devs(void)
 {
        const struct cpu_dev *const *cdev;
        int count = 0;
 
-#ifdef CONFIG_PROCESSOR_SELECT
-       pr_info("KERNEL supported cpus:\n");
-#endif
-
        for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
                const struct cpu_dev *cpudev = *cdev;
 
@@ -1668,20 +1664,30 @@ void __init early_cpu_init(void)
                        break;
                cpu_devs[count] = cpudev;
                count++;
+       }
+}
 
+void __init early_cpu_init(void)
+{
 #ifdef CONFIG_PROCESSOR_SELECT
-               {
-                       unsigned int j;
-
-                       for (j = 0; j < 2; j++) {
-                               if (!cpudev->c_ident[j])
-                                       continue;
-                               pr_info("  %s %s\n", cpudev->c_vendor,
-                                       cpudev->c_ident[j]);
-                       }
-               }
+       unsigned int i, j;
+
+       pr_info("KERNEL supported cpus:\n");
 #endif
+
+       init_cpu_devs();
+
+#ifdef CONFIG_PROCESSOR_SELECT
+       for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) {
+               for (j = 0; j < 2; j++) {
+                       if (!cpu_devs[i]->c_ident[j])
+                               continue;
+                       pr_info("  %s %s\n", cpu_devs[i]->c_vendor,
+                               cpu_devs[i]->c_ident[j]);
+               }
        }
+#endif
+
        early_identify_cpu(&boot_cpu_data);
 }