Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3439972imu; Sun, 11 Nov 2018 15:08:26 -0800 (PST) X-Google-Smtp-Source: AJdET5dyru5SUPV2lwLyZMvPQGvApXUUsvH8ymPevdoYV3JaiHmvZs9rIkHS7IgW74OnkPsxKTww X-Received: by 2002:a62:ae06:: with SMTP id q6-v6mr17892591pff.126.1541977705960; Sun, 11 Nov 2018 15:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977705; cv=none; d=google.com; s=arc-20160816; b=iDnjJmUX+TpCnbnrS0s/vV9uEsuLwWyyBAEaNF+ygZnkbQOcrfDETMonAu7qRCVKE4 PDJYgj6tcKUMGOO1uP1ji9K/+UhPV2O/S9bvJuZyxAoeGT0RJ+q04xfskdOS6zqmNL5d jnyahRm0H0F87Cl3N9J9bTWCVVgNu2lwIlmkx/EQpaTJJaDW/5JrmHfpn8ss+GdsC/Rd hDlAeqloi4VWy4R/XkyBC7Ql1/6gqvQcCLtXraiqFh6n/7SBgI3m90Y4JDAYse2CwX/5 NFndrIbwnt7BCTGHwAqKulxyJzd7gTy0F/xXXjsf07WR/VCkjyPZuvDwfzOWAwBnQogd X2SQ== 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=sYmZ3WuaiwfTvnAT8vxV3b/ZOHAPt7rjzc5L6b/7Els=; b=CnpHsP0ZDU9jKv604r5y9lefrAulRaQorUWEeXhJoM6hTXLVrOpNQd5ZdLjaw5IeKp lahNH5s6fhZuhk4L9k3/vIXJyzd3VKwKoeuHoDuFSCjqO5WNOFpE8MkqSPvRLdLqC+I3 XMx11U6O5lvkMJrctuhQH31XKhk5+SCf/nA0kA8z94U/6J9C4C/UHGGF2CvdqOKAlbd5 arV/Bc5/aqn5e5NE6qsSl4l+e5ul7Eq4miyNhgC1n+PN5I+drmYStpFHA2IIc1eOUE7r ZSdRdBiqET2FiZMHANAknEU+cac93RZgVMNWLVWjPbzGpEjGdD978ii3YAz+6Ua5fyMc 06mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rnbS0vnb; 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 g137-v6si18065537pfb.34.2018.11.11.15.08.10; Sun, 11 Nov 2018 15:08:25 -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=rnbS0vnb; 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 S2390385AbeKLI4l (ORCPT + 99 others); Mon, 12 Nov 2018 03:56:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:51248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390367AbeKLIWM (ORCPT ); Mon, 12 Nov 2018 03:22:12 -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 817B5224E3; Sun, 11 Nov 2018 22:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975535; bh=VR14KrgA/pXoj1lndDLRAWU/IGWB3L9nw/htZMPuC5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rnbS0vnbo0SU05N2hUIHd5mgb/tqVzZysrH8gWoqugAy4LJqbKWDsMjMUzz4YKfnD i0kfuKkl50rNzsqzATJKBcJzz763gZJic+Z3IJrV5j4XRGm1oC+zKG29oTQ/9blu4L l/mvEs/ZYo7ew2wacp76j0I7KraqdpG4jLSJs+Zw= 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.14 051/222] cpupower: Fix coredump on VMWare Date: Sun, 11 Nov 2018 14:22:28 -0800 Message-Id: <20181111221652.663159594@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -202,6 +202,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;