Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3009169imu; Mon, 19 Nov 2018 09:17:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/XWk7gYAAJAvaFxlHc4V2Tu+Go3SmsALyQR4UcdkD+Tea/iYYcdEPsCx5SPj2O2KUZJaiia X-Received: by 2002:a17:902:8f97:: with SMTP id z23mr13792053plo.283.1542647874525; Mon, 19 Nov 2018 09:17:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542647874; cv=none; d=google.com; s=arc-20160816; b=PueO+3DoTx3z9pBLt6JmZMGqnWGMcZXOzVWjdFLGw6m+B8GpPVGdf+ciKDGi0KR5nZ Lq61B8oc44rRBc9JuBQ8RVkz4DKyS6pt2aZJibxYovRo5pu8iTFEsS8mJ+WBDmaqu05j VX9lj2UmevSPt/+kBiYVPVWox2ow+vvCdPlBUQdVbSQ6+TR+ACtKJwVWS5nRPdNSOdMR r4VTa3B3EItJMc0Zv9VJWfXkbKr3DQqPWD+A2KpkxWyjJHpLxzVdseS2zzVvgsrLXTEI gscFrIevjDooDtSoEWhBzvbSxZ94mZogWGWPmlcFTml566yyjoHiQNlNZU0bX4HdY/6N U19g== 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=8bQQ+icB1NGlRHLdQYg8R+H0vXKq0C3Pr6gOzhheF+4=; b=mSsM4QkJBvHRnluOzdS+PApjNvxNOV94Tz5tzj11yuuVHYxKWVMVV+nzW+ZTHmKOoy Grrp7OGh1FFveNgn9T2nIyh434UClSJIHEvEhLp0fHHO77re2jrEQopZq1iHz8e9C74q SgclZqG+Mtj5p5lFQrrp8lU9KaJ2aivCDKlVMFe0HmXIa1L/529eGllF9ZKIRwBGYrn/ dTE8JMCo+mwt8RdOqY9QXLZSH7HSu4mXTzcPB3zM0fup4haLZrzK+u8HsHHkX911UQWV fUzglmTN/Uli8sthvUYSWAAIElz6d/iIypFuw9fAVSbYzbuUXcnNFjx2ZWtrDLIsmDnY kYXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jd6soyHe; 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 p22si36652679pgl.340.2018.11.19.09.17.39; Mon, 19 Nov 2018 09:17:54 -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=jd6soyHe; 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 S2406266AbeKTD1q (ORCPT + 99 others); Mon, 19 Nov 2018 22:27:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:41868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405677AbeKTD1q (ORCPT ); Mon, 19 Nov 2018 22:27:46 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 9889A2146D; Mon, 19 Nov 2018 17:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542647009; bh=m5alIWHPpCMpZyPESxfRB5rn398qt+Sx7IQhJ5WL9tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jd6soyHeFx5dzKSuJ/LyX6KHivjYfI5N/Z09jRwnpJDwpVCBf02+gLcw0f9MnC+qm /TBN3N5kpkrKiAyeJ9NdiIp4hvNLtnpxmZY+Pu8tg9izvn+8G+Kymnt5tTO7ldDxza oTpvVnTDl87kXXMZ/uT8LD1ECRenTJ+s4bSKtaW0= 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 3.18 16/90] cpupower: Fix coredump on VMWare Date: Mon, 19 Nov 2018 17:28:58 +0100 Message-Id: <20181119162623.516060898@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162620.585061184@linuxfoundation.org> References: <20181119162620.585061184@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 3.18-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 @@ -103,6 +103,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;