]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
cpupower: Fix coredump on VMWare
authorPrarit Bhargava <prarit@redhat.com>
Mon, 8 Oct 2018 15:06:19 +0000 (11:06 -0400)
committerShuah Khan (Samsung OSG) <shuah@kernel.org>
Mon, 8 Oct 2018 15:19:15 +0000 (09:19 -0600)
cpupower crashes on VMWare guests.  The guests have the AMD PStateDef MSR
(0xC0010064 + state number) set to zero.  As a result fid and did are zero
and the crash occurs because of a divide by zero (cof = fid/did).  This
can be prevented by checking the enable bit in the PStateDef MSR before
calculating cof.  By doing this the value of pstate[i] remains zero and
the value can be tested before displaying the active Pstates.

Check the enable bit in the PstateDef register for all supported families
and only print out enabled Pstates.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stafford Horne <shorne@gmail.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
tools/power/cpupower/utils/cpufreq-info.c
tools/power/cpupower/utils/helpers/amd.c

index df43cd45d810447a50787c58964515ee79ea226d..ccd08dd009962de64d09ce1ceacf38ca9bfed6c2 100644 (file)
@@ -200,6 +200,8 @@ static int get_boost_mode(unsigned int cpu)
                printf(_("    Boost States: %d\n"), b_states);
                printf(_("    Total States: %d\n"), pstate_no);
                for (i = 0; i < pstate_no; i++) {
+                       if (!pstates[i])
+                               continue;
                        if (i < b_states)
                                printf(_("    Pstate-Pb%d: %luMHz (boost state)"
                                         "\n"), i, pstates[i]);
index eed31b27909b9aab333d3371a775f55bab22caa4..9607ada5b29a6a5e50825c267aadbe441c3cc426 100644 (file)
@@ -119,6 +119,11 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family,
                }
                if (read_msr(cpu, MSR_AMD_PSTATE + i, &pstate.val))
                        return -1;
+               if ((cpu_family == 0x17) && (!pstate.fam17h_bits.en))
+                       continue;
+               else if (!pstate.bits.en)
+                       continue;
+
                pstates[i] = get_cof(cpu_family, pstate);
        }
        *no = i;