Skip to content

Commit aac984c

Browse files
jgross1gregkh
authored andcommitted
x86: make get_cpu_vendor() accessible from Xen code
commit efbcd61 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 <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fe9a8f5 commit aac984c

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ static inline unsigned long long l1tf_pfn_limit(void)
190190
return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT);
191191
}
192192

193+
void init_cpu_devs(void);
194+
void get_cpu_vendor(struct cpuinfo_x86 *c);
193195
extern void early_cpu_init(void);
194196
extern void identify_secondary_cpu(struct cpuinfo_x86 *);
195197
extern void print_cpu_info(struct cpuinfo_x86 *);

arch/x86/kernel/cpu/common.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void detect_ht(struct cpuinfo_x86 *c)
927927
#endif
928928
}
929929

930-
static void get_cpu_vendor(struct cpuinfo_x86 *c)
930+
void get_cpu_vendor(struct cpuinfo_x86 *c)
931931
{
932932
char *v = c->x86_vendor_id;
933933
int i;
@@ -1692,36 +1692,42 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16921692
detect_nopl();
16931693
}
16941694

1695-
void __init early_cpu_init(void)
1695+
void __init init_cpu_devs(void)
16961696
{
16971697
const struct cpu_dev *const *cdev;
16981698
int count = 0;
16991699

1700-
#ifdef CONFIG_PROCESSOR_SELECT
1701-
pr_info("KERNEL supported cpus:\n");
1702-
#endif
1703-
17041700
for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
17051701
const struct cpu_dev *cpudev = *cdev;
17061702

17071703
if (count >= X86_VENDOR_NUM)
17081704
break;
17091705
cpu_devs[count] = cpudev;
17101706
count++;
1707+
}
1708+
}
17111709

1710+
void __init early_cpu_init(void)
1711+
{
17121712
#ifdef CONFIG_PROCESSOR_SELECT
1713-
{
1714-
unsigned int j;
1715-
1716-
for (j = 0; j < 2; j++) {
1717-
if (!cpudev->c_ident[j])
1718-
continue;
1719-
pr_info(" %s %s\n", cpudev->c_vendor,
1720-
cpudev->c_ident[j]);
1721-
}
1722-
}
1713+
unsigned int i, j;
1714+
1715+
pr_info("KERNEL supported cpus:\n");
17231716
#endif
1717+
1718+
init_cpu_devs();
1719+
1720+
#ifdef CONFIG_PROCESSOR_SELECT
1721+
for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) {
1722+
for (j = 0; j < 2; j++) {
1723+
if (!cpu_devs[i]->c_ident[j])
1724+
continue;
1725+
pr_info(" %s %s\n", cpu_devs[i]->c_vendor,
1726+
cpu_devs[i]->c_ident[j]);
1727+
}
17241728
}
1729+
#endif
1730+
17251731
early_identify_cpu(&boot_cpu_data);
17261732
}
17271733

0 commit comments

Comments
 (0)