Skip to content

Commit efbcd61

Browse files
committed
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 <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent f9244fb commit efbcd61

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
@@ -230,6 +230,8 @@ static inline unsigned long long l1tf_pfn_limit(void)
230230
return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT);
231231
}
232232

233+
void init_cpu_devs(void);
234+
void get_cpu_vendor(struct cpuinfo_x86 *c);
233235
extern void early_cpu_init(void);
234236
extern void identify_secondary_cpu(struct cpuinfo_x86 *);
235237
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
@@ -867,7 +867,7 @@ static void cpu_detect_tlb(struct cpuinfo_x86 *c)
867867
tlb_lld_4m[ENTRIES], tlb_lld_1g[ENTRIES]);
868868
}
869869

870-
static void get_cpu_vendor(struct cpuinfo_x86 *c)
870+
void get_cpu_vendor(struct cpuinfo_x86 *c)
871871
{
872872
char *v = c->x86_vendor_id;
873873
int i;
@@ -1649,36 +1649,42 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16491649
detect_nopl();
16501650
}
16511651

1652-
void __init early_cpu_init(void)
1652+
void __init init_cpu_devs(void)
16531653
{
16541654
const struct cpu_dev *const *cdev;
16551655
int count = 0;
16561656

1657-
#ifdef CONFIG_PROCESSOR_SELECT
1658-
pr_info("KERNEL supported cpus:\n");
1659-
#endif
1660-
16611657
for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
16621658
const struct cpu_dev *cpudev = *cdev;
16631659

16641660
if (count >= X86_VENDOR_NUM)
16651661
break;
16661662
cpu_devs[count] = cpudev;
16671663
count++;
1664+
}
1665+
}
16681666

1667+
void __init early_cpu_init(void)
1668+
{
16691669
#ifdef CONFIG_PROCESSOR_SELECT
1670-
{
1671-
unsigned int j;
1672-
1673-
for (j = 0; j < 2; j++) {
1674-
if (!cpudev->c_ident[j])
1675-
continue;
1676-
pr_info(" %s %s\n", cpudev->c_vendor,
1677-
cpudev->c_ident[j]);
1678-
}
1679-
}
1670+
unsigned int i, j;
1671+
1672+
pr_info("KERNEL supported cpus:\n");
16801673
#endif
1674+
1675+
init_cpu_devs();
1676+
1677+
#ifdef CONFIG_PROCESSOR_SELECT
1678+
for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) {
1679+
for (j = 0; j < 2; j++) {
1680+
if (!cpu_devs[i]->c_ident[j])
1681+
continue;
1682+
pr_info(" %s %s\n", cpu_devs[i]->c_vendor,
1683+
cpu_devs[i]->c_ident[j]);
1684+
}
16811685
}
1686+
#endif
1687+
16821688
early_identify_cpu(&boot_cpu_data);
16831689
}
16841690

0 commit comments

Comments
 (0)