Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3487578imu; Sun, 11 Nov 2018 16:12:55 -0800 (PST) X-Google-Smtp-Source: AJdET5dE0WTtLk/mqJh8xieXkAYJXUf0JJuboOSIBBQg9NntA1vUBW410xlEldIRyR8X3WaRzEGh X-Received: by 2002:a17:902:b03:: with SMTP id 3-v6mr18073231plq.233.1541981575579; Sun, 11 Nov 2018 16:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981575; cv=none; d=google.com; s=arc-20160816; b=D5w5T0g9HEjeDDecDil2EA7qzuHPKK6LavfCiz4Ed3BbX5GliruKbBGCuHd+rlj3cM t3kX7PfGJHC0RKlSwMp9+FA5RHt/QmeWJaFoj+0fi3snVDA1yK/JDkIwgS46Ksnvl4fk hr7DQ2F2EBc5U9gx9xK3AnPYJ1AJkDBRmVxNcPg96nm/bNV01xARNFax9Axc88Yw70hF FCmFowA98pf2pqQfQhNoXA+Ovs0tFb9FmD/fXdEOoJuVXbmIzELraLDwi9DnVzSyrOJ0 RkPfajrc6iEVGN3EAj0GXNcorcs2KJkLvVnMMNCvneu6tgW1Pw9LEJBIaRgLGWvm5k3o KwMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mh8fDOXrQjsVJHlvnCCSt3k5T1lFHUuFU6lv/tZxTlI=; b=OQV+cl1s8BwUjTqVlk6U8WsKD2/PIW+H9a40XQp6tHKf8jrW3+zd1z2SE2xitlvHvE Dpb04B51a2EZP161GEcfb0JbWDi1Yhi8jcjyfbzq1Snwjvdo6jtvWsgTtIUeWpO1MVmm 2AP6Z7xxibaoBCOOPrZQ6EoMSoK3+a/Pdg2StYmBM5LYdVQCKSNR08j3F1FlNOw9wLuS H3I0HJuG65jnx84BAcXqjFRI10yJEBROmFC21dZTT/ms1gaaYIMQJlqijVRjdE29Rke4 JGtygif+kXRLzUao1FPOGBuBI8zGWliD/IFUnvmdn2P1BaIb2IxQtX7qPP6jAoYMBd4w 8BOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yna1Vbxy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69si14095431pgb.365.2018.11.11.16.12.40; Sun, 11 Nov 2018 16:12:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yna1Vbxy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730760AbeKLIRX (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:60776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730696AbeKLIRW (ORCPT ); Mon, 12 Nov 2018 03:17:22 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6F0121527; Sun, 11 Nov 2018 22:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975246; bh=v83EpvcOBRw3Ok8a/wZEcQcUGJ2P/qFi3CDfaBwlUEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yna1VbxycMpZAQa7cOzhr0lGLFJiCXKUW8uMVolybTSJjHezv2sO7EId2bCKWakVu V+4NyOa0pYPU0c0eQ93QcaeEJBmknM00Eq0PZgU2dMrgOKxiqR8fiUerK+SUEWF56m NOwXWNigmqymiYkUH4f1kKONPODgGGEy2gdgPDUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Prarit Bhargava , Shuah Khan , Stafford Horne , Sasha Levin Subject: [PATCH 4.19 068/361] cpupower: Fix coredump on VMWare Date: Sun, 11 Nov 2018 14:16:55 -0800 Message-Id: <20181111221629.611668869@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Prarit Bhargava [ Upstream commit f69ffc5d3db8f1f03fd6d1df5930f9a1fbd787b6 ] 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 Cc: Shuah Khan Cc: Stafford Horne Signed-off-by: Shuah Khan (Samsung OSG) Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/power/cpupower/utils/cpufreq-info.c | 2 ++ tools/power/cpupower/utils/helpers/amd.c | 5 +++++ 2 files changed, 7 insertions(+) --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -200,6 +200,8 @@ static int get_boost_mode(unsigned int c 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]); --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -119,6 +119,11 @@ int decode_pstates(unsigned int cpu, uns } 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;