]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.54/x86-cpu-amd-don-t-force-the-cpb-cap-when-running-und.patch
Linux 4.19.54
[thirdparty/kernel/stable-queue.git] / releases / 4.19.54 / x86-cpu-amd-don-t-force-the-cpb-cap-when-running-und.patch
CommitLineData
a15a8890
SL
1From 5787b250603accfa2870606eb63628b9a252b324 Mon Sep 17 00:00:00 2001
2From: Frank van der Linden <fllinden@amazon.com>
3Date: Wed, 22 May 2019 22:17:45 +0000
4Subject: x86/CPU/AMD: Don't force the CPB cap when running under a hypervisor
5
6[ Upstream commit 2ac44ab608705948564791ce1d15d43ba81a1e38 ]
7
8For F17h AMD CPUs, the CPB capability ('Core Performance Boost') is forcibly set,
9because some versions of that chip incorrectly report that they do not have it.
10
11However, a hypervisor may filter out the CPB capability, for good
12reasons. For example, KVM currently does not emulate setting the CPB
13bit in MSR_K7_HWCR, and unchecked MSR access errors will be thrown
14when 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
28To avoid this issue, don't forcibly set the CPB capability for a CPU
29when running under a hypervisor.
30
31Signed-off-by: Frank van der Linden <fllinden@amazon.com>
32Acked-by: Borislav Petkov <bp@suse.de>
33Cc: Andy Lutomirski <luto@kernel.org>
34Cc: Linus Torvalds <torvalds@linux-foundation.org>
35Cc: Peter Zijlstra <peterz@infradead.org>
36Cc: Thomas Gleixner <tglx@linutronix.de>
37Cc: bp@alien8.de
38Cc: jiaxun.yang@flygoat.com
39Fixes: 0237199186e7 ("x86/CPU/AMD: Set the CPB bit unconditionally on F17h")
40Link: http://lkml.kernel.org/r/20190522221745.GA15789@dev-dsk-fllinden-2c-c1893d73.us-west-2.amazon.com
41[ Minor edits to the changelog. ]
42Signed-off-by: Ingo Molnar <mingo@kernel.org>
43Signed-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
48diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
49index 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--
672.20.1
68