]>
Commit | Line | Data |
---|---|---|
a15a8890 SL |
1 | From 5787b250603accfa2870606eb63628b9a252b324 Mon Sep 17 00:00:00 2001 |
2 | From: Frank van der Linden <fllinden@amazon.com> | |
3 | Date: Wed, 22 May 2019 22:17:45 +0000 | |
4 | Subject: x86/CPU/AMD: Don't force the CPB cap when running under a hypervisor | |
5 | ||
6 | [ Upstream commit 2ac44ab608705948564791ce1d15d43ba81a1e38 ] | |
7 | ||
8 | For F17h AMD CPUs, the CPB capability ('Core Performance Boost') is forcibly set, | |
9 | because some versions of that chip incorrectly report that they do not have it. | |
10 | ||
11 | However, a hypervisor may filter out the CPB capability, for good | |
12 | reasons. For example, KVM currently does not emulate setting the CPB | |
13 | bit in MSR_K7_HWCR, and unchecked MSR access errors will be thrown | |
14 | when trying to set it as a guest: | |
15 | ||
16 | unchecked MSR access error: WRMSR to 0xc0010015 (tried to write 0x0000000001000011) at rIP: 0xffffffff890638f4 (native_write_msr+0x4/0x20) | |
17 | ||
18 | Call Trace: | |
19 | boost_set_msr+0x50/0x80 [acpi_cpufreq] | |
20 | cpuhp_invoke_callback+0x86/0x560 | |
21 | sort_range+0x20/0x20 | |
22 | cpuhp_thread_fun+0xb0/0x110 | |
23 | smpboot_thread_fn+0xef/0x160 | |
24 | kthread+0x113/0x130 | |
25 | kthread_create_worker_on_cpu+0x70/0x70 | |
26 | ret_from_fork+0x35/0x40 | |
27 | ||
28 | To avoid this issue, don't forcibly set the CPB capability for a CPU | |
29 | when running under a hypervisor. | |
30 | ||
31 | Signed-off-by: Frank van der Linden <fllinden@amazon.com> | |
32 | Acked-by: Borislav Petkov <bp@suse.de> | |
33 | Cc: Andy Lutomirski <luto@kernel.org> | |
34 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
35 | Cc: Peter Zijlstra <peterz@infradead.org> | |
36 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
37 | Cc: bp@alien8.de | |
38 | Cc: jiaxun.yang@flygoat.com | |
39 | Fixes: 0237199186e7 ("x86/CPU/AMD: Set the CPB bit unconditionally on F17h") | |
40 | Link: http://lkml.kernel.org/r/20190522221745.GA15789@dev-dsk-fllinden-2c-c1893d73.us-west-2.amazon.com | |
41 | [ Minor edits to the changelog. ] | |
42 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
43 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
44 | --- | |
45 | arch/x86/kernel/cpu/amd.c | 7 +++++-- | |
46 | 1 file changed, 5 insertions(+), 2 deletions(-) | |
47 | ||
48 | diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c | |
49 | index 6a25278e0092..da1f5e78363e 100644 | |
50 | --- a/arch/x86/kernel/cpu/amd.c | |
51 | +++ b/arch/x86/kernel/cpu/amd.c | |
52 | @@ -819,8 +819,11 @@ static void init_amd_zn(struct cpuinfo_x86 *c) | |
53 | { | |
54 | set_cpu_cap(c, X86_FEATURE_ZEN); | |
55 | ||
56 | - /* Fix erratum 1076: CPB feature bit not being set in CPUID. */ | |
57 | - if (!cpu_has(c, X86_FEATURE_CPB)) | |
58 | + /* | |
59 | + * Fix erratum 1076: CPB feature bit not being set in CPUID. | |
60 | + * Always set it, except when running under a hypervisor. | |
61 | + */ | |
62 | + if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_CPB)) | |
63 | set_cpu_cap(c, X86_FEATURE_CPB); | |
64 | } | |
65 | ||
66 | -- | |
67 | 2.20.1 | |
68 |