Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1130103imp; Thu, 21 Feb 2019 19:41:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IYCfij6q2W9k+TytboCWS/uGqwA1UffNZWvtCOL66xPBTeldNM97w1tA2m7yc2ldh1cQh/r X-Received: by 2002:aa7:82d5:: with SMTP id f21mr2057891pfn.50.1550806890056; Thu, 21 Feb 2019 19:41:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550806890; cv=none; d=google.com; s=arc-20160816; b=VDCJXQXBzoXT+t1FG4lT+g9QtN4WmaHtrUfP/MMhq7Ks6eYDDaRuEO4r9aO4KW9gtW LnFtyv7vBflyIrlBArpuSplRU6HZypXZ8Sz/iDObmx+dYvQ7lzrxKZlWvvACfX0ysXra uLA1QlsHZOBSAdMhuDOxjGIDQ3CtKuwuvoQnK8+jOfAvNzjK6oCaptL29BNKw9gAeIhU lLiWszfRbowRNV0mIga6x28UvDrEGwzP2ZLRa05o3F+Xl28z1XcXdhE2tjsECiZRPRiD VyEytxWlN44lXqYBQftZVQHAMqyQUAQfPjMzuEwi/4T4kG3j3qUCpYG2bik38KQ3Rs1f rjQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=TxKLYrKeZLAVE0nF2WLOcvUFZKvVYb6fWVmkd3itCDY=; b=ZstIyGIS/A4ZEVoNtpo6QNOfsvqV2jKIGoSs5YuRxFq3QRp2efQQLIklDwIYGR+VLb CA+J2eb1X2BNrVm6+zRfCWavuKtA6bqDkT5xzFKDV3MCpckKNHK0+315LMhbvZpSCHyt N3FwIZhxY+9sqYcB7eIzzEFIwjg5NStysj8dnfkaMpy7tzlAPsp8qD9QaSyRgb8tBGYg R38pEU1PVIG/bmwrdFpdRpMhHsOyO331y+Np0Pt74F9EzOJcv+ZkCw1nnW/+eKCGb5zl FWqQwinog2GeibnhhwQ9t6+konqTs3s3rLHE6Co/0UxMmYYWYTws82WDAdI5tgw1SJGl gDgQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t135si327688pgb.467.2019.02.21.19.41.14; Thu, 21 Feb 2019 19:41:30 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726418AbfBVDkg (ORCPT + 99 others); Thu, 21 Feb 2019 22:40:36 -0500 Received: from mga18.intel.com ([134.134.136.126]:43029 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbfBVDkg (ORCPT ); Thu, 21 Feb 2019 22:40:36 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2019 19:40:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,397,1544515200"; d="scan'208";a="126321256" Received: from sgdharne-mobl2.gar.corp.intel.com (HELO [10.252.84.57]) ([10.252.84.57]) by fmsmga008.fm.intel.com with ESMTP; 21 Feb 2019 19:40:32 -0800 Subject: Re: [PATCH] platform/x86: intel_pmc_core: Avoid a u32 overflow To: Rajat Jain , Rajneesh Bhardwaj , Vishwanath Somayaji , Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rajatxjain@gmail.com References: <20190216001920.178053-1-rajatja@google.com> From: "Bhardwaj, Rajneesh" Message-ID: <6dc61237-5424-506c-2d31-11658cc52caf@linux.intel.com> Date: Fri, 22 Feb 2019 09:10:27 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190216001920.178053-1-rajatja@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16-Feb-19 5:49 AM, Rajat Jain wrote: > The register (SLP_S0_RES) at offset slp_s0_offset is a 32 bit register. > The pmc_core_adjust_slp_s0_step() could overflow the u32 value while > returning it after adjusting the step. Thus change to u64, this is > already accounted for in debugfs attribute (that wants to output a > 64 bit value). > > Signed-off-by: Rajat Jain Acked-by: Rajneesh Bhardwaj > --- > drivers/platform/x86/intel_pmc_core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c > index 22dbf115782e..f90f4dd25151 100644 > --- a/drivers/platform/x86/intel_pmc_core.c > +++ b/drivers/platform/x86/intel_pmc_core.c > @@ -328,9 +328,9 @@ static inline void pmc_core_reg_write(struct pmc_dev *pmcdev, int > writel(val, pmcdev->regbase + reg_offset); > } > > -static inline u32 pmc_core_adjust_slp_s0_step(u32 value) > +static inline u64 pmc_core_adjust_slp_s0_step(u32 value) > { > - return value * SPT_PMC_SLP_S0_RES_COUNTER_STEP; > + return (u64)value * SPT_PMC_SLP_S0_RES_COUNTER_STEP; > } > > static int pmc_core_dev_state_get(void *data, u64 *val) > >