Skip to content

Commit 259550d

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

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
@@ -199,6 +199,8 @@ static inline unsigned long long l1tf_pfn_limit(void)
199199
return BIT_ULL(boot_cpu_data.x86_cache_bits - 1 - PAGE_SHIFT);
200200
}
201201

202+
void init_cpu_devs(void);
203+
void get_cpu_vendor(struct cpuinfo_x86 *c);
202204
extern void early_cpu_init(void);
203205
extern void identify_boot_cpu(void);
204206
extern void identify_secondary_cpu(struct cpuinfo_x86 *);

arch/x86/kernel/cpu/common.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ void detect_ht(struct cpuinfo_x86 *c)
906906
#endif
907907
}
908908

909-
static void get_cpu_vendor(struct cpuinfo_x86 *c)
909+
void get_cpu_vendor(struct cpuinfo_x86 *c)
910910
{
911911
char *v = c->x86_vendor_id;
912912
int i;
@@ -1672,36 +1672,42 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16721672
detect_nopl();
16731673
}
16741674

1675-
void __init early_cpu_init(void)
1675+
void __init init_cpu_devs(void)
16761676
{
16771677
const struct cpu_dev *const *cdev;
16781678
int count = 0;
16791679

1680-
#ifdef CONFIG_PROCESSOR_SELECT
1681-
pr_info("KERNEL supported cpus:\n");
1682-
#endif
1683-
16841680
for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
16851681
const struct cpu_dev *cpudev = *cdev;
16861682

16871683
if (count >= X86_VENDOR_NUM)
16881684
break;
16891685
cpu_devs[count] = cpudev;
16901686
count++;
1687+
}
1688+
}
16911689

1690+
void __init early_cpu_init(void)
1691+
{
16921692
#ifdef CONFIG_PROCESSOR_SELECT
1693-
{
1694-
unsigned int j;
1695-
1696-
for (j = 0; j < 2; j++) {
1697-
if (!cpudev->c_ident[j])
1698-
continue;
1699-
pr_info(" %s %s\n", cpudev->c_vendor,
1700-
cpudev->c_ident[j]);
1701-
}
1702-
}
1693+
unsigned int i, j;
1694+
1695+
pr_info("KERNEL supported cpus:\n");
17031696
#endif
1697+
1698+
init_cpu_devs();
1699+
1700+
#ifdef CONFIG_PROCESSOR_SELECT
1701+
for (i = 0; i < X86_VENDOR_NUM && cpu_devs[i]; i++) {
1702+
for (j = 0; j < 2; j++) {
1703+
if (!cpu_devs[i]->c_ident[j])
1704+
continue;
1705+
pr_info(" %s %s\n", cpu_devs[i]->c_vendor,
1706+
cpu_devs[i]->c_ident[j]);
1707+
}
17041708
}
1709+
#endif
1710+
17051711
early_identify_cpu(&boot_cpu_data);
17061712
}
17071713

0 commit comments

Comments
 (0)