Skip to content

Commit 505b352

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 <andrew.cooper3@citrix.com> Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7728e97 commit 505b352

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

arch/x86/include/asm/processor.h

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

215+
void init_cpu_devs(void);
216+
void get_cpu_vendor(struct cpuinfo_x86 *c);
215217
extern void early_cpu_init(void);
216218
extern void identify_secondary_cpu(struct cpuinfo_x86 *);
217219
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
@@ -868,7 +868,7 @@ static void cpu_detect_tlb(struct cpuinfo_x86 *c)
868868
tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]);
869869
}
870870

871-
static void get_cpu_vendor(struct cpuinfo_x86 *c)
871+
void get_cpu_vendor(struct cpuinfo_x86 *c)
872872
{
873873
char *v = c->x86_vendor_id;
874874
int i;
@@ -1652,36 +1652,42 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16521652
detect_nopl();
16531653
}
16541654

1655-
void __init early_cpu_init(void)
1655+
void __init init_cpu_devs(void)
16561656
{
16571657
const struct cpu_dev *const *cdev;
16581658
int count = 0;
16591659

1660-
#ifdef CONFIG_PROCESSOR_SELECT
1661-
pr_info("KERNEL supported cpus:\n");
1662-
#endif
1663-
16641660
for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
16651661
const struct cpu_dev *cpudev = *cdev;
16661662

16671663
if (count >= X86_VENDOR_NUM)
16681664
break;
16691665
cpu_devs[count] = cpudev;
16701666
count++;
1667+
}
1668+
}
16711669

1670+
void __init early_cpu_init(void)
1671+
{
16721672
#ifdef CONFIG_PROCESSOR_SELECT
1673-
{
1674-
unsigned int j;
1675-
1676-
for (j = 0; j < 2; j++) {
1677-
if (!cpudev->c_ident[j])
1678-
continue;
1679-
pr_info(" %s %s\n", cpudev->c_vendor,
1680-
cpudev->c_ident[j]);
1681-
}
1682-
}
1673+
unsigned int i, j;
1674+
1675+
pr_info("KERNEL supported cpus:\n");
16831676
#endif
1677+
1678+
init_cpu_devs();
1679+
1680+
#ifdef CONFIG_PROCESSOR_SELECT
1681+
for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) {
1682+
for (j = 0; j < 2; j++) {
1683+
if (!cpu_devs[i]->c_ident[j])
1684+
continue;
1685+
pr_info(" %s %s\n", cpu_devs[i]->c_vendor,
1686+
cpu_devs[i]->c_ident[j]);
1687+
}
16841688
}
1689+
#endif
1690+
16851691
early_identify_cpu(&boot_cpu_data);
16861692
}
16871693

0 commit comments

Comments
 (0)