1 |
From 25dd5993b21f8837351f5a9bbb1e8ff3e51b9839 Mon Sep 17 00:00:00 2001 |
2 |
From: Prarit Bhargava <prarit@redhat.com> |
3 |
Date: Mon, 8 Oct 2018 11:06:19 -0400 |
4 |
Subject: [PATCH 022/145] cpupower: Fix coredump on VMWare |
5 |
|
6 |
[ Upstream commit f69ffc5d3db8f1f03fd6d1df5930f9a1fbd787b6 ] |
7 |
|
8 |
cpupower crashes on VMWare guests. The guests have the AMD PStateDef MSR |
9 |
(0xC0010064 + state number) set to zero. As a result fid and did are zero |
10 |
and the crash occurs because of a divide by zero (cof = fid/did). This |
11 |
can be prevented by checking the enable bit in the PStateDef MSR before |
12 |
calculating cof. By doing this the value of pstate[i] remains zero and |
13 |
the value can be tested before displaying the active Pstates. |
14 |
|
15 |
Check the enable bit in the PstateDef register for all supported families |
16 |
and only print out enabled Pstates. |
17 |
|
18 |
Signed-off-by: Prarit Bhargava <prarit@redhat.com> |
19 |
Cc: Shuah Khan <shuah@kernel.org> |
20 |
Cc: Stafford Horne <shorne@gmail.com> |
21 |
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org> |
22 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
23 |
--- |
24 |
tools/power/cpupower/utils/cpufreq-info.c | 2 ++ |
25 |
tools/power/cpupower/utils/helpers/amd.c | 5 +++++ |
26 |
2 files changed, 7 insertions(+) |
27 |
|
28 |
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c |
29 |
index df43cd45d810..ccd08dd00996 100644 |
30 |
--- a/tools/power/cpupower/utils/cpufreq-info.c |
31 |
+++ b/tools/power/cpupower/utils/cpufreq-info.c |
32 |
@@ -200,6 +200,8 @@ static int get_boost_mode(unsigned int cpu) |
33 |
printf(_(" Boost States: %d\n"), b_states); |
34 |
printf(_(" Total States: %d\n"), pstate_no); |
35 |
for (i = 0; i < pstate_no; i++) { |
36 |
+ if (!pstates[i]) |
37 |
+ continue; |
38 |
if (i < b_states) |
39 |
printf(_(" Pstate-Pb%d: %luMHz (boost state)" |
40 |
"\n"), i, pstates[i]); |
41 |
diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c |
42 |
index bb41cdd0df6b..58d23997424d 100644 |
43 |
--- a/tools/power/cpupower/utils/helpers/amd.c |
44 |
+++ b/tools/power/cpupower/utils/helpers/amd.c |
45 |
@@ -119,6 +119,11 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, |
46 |
} |
47 |
if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val)) |
48 |
return -1; |
49 |
+ if ((cpu_family == 0x17) && (!pstate.fam17h_bits.en)) |
50 |
+ continue; |
51 |
+ else if (!pstate.bits.en) |
52 |
+ continue; |
53 |
+ |
54 |
pstates[i] = get_cof(cpu_family, pstate); |
55 |
} |
56 |
*no = i; |
57 |
-- |
58 |
2.19.1 |
59 |
|