Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp535844imp; Thu, 21 Feb 2019 06:25:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IYMrR5ctLHoyqB9Q3BvEviVNeUrInmjbf6EuVBHlvfxzi66WqjrSNT8w5ralcmcXdl2PBUJ X-Received: by 2002:a63:ce4a:: with SMTP id r10mr18957120pgi.336.1550759149339; Thu, 21 Feb 2019 06:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550759149; cv=none; d=google.com; s=arc-20160816; b=VLqwTY1wn9nw5B0ajcJjg8v2iaf0Y06ileiLen5R1dn+1qSPppCXv4VY9pemuDAoUZ 4KZBqF44ZGLNNrGMCCbneF/3u2h4FQP556+WlVIu55Mr2TRfz7PNUClQE7PVlEYSqCIS F2M6NxbfZv9hOzsnDE0vcZfVYRAOjnVMEhe+yRU6nlhUAr2toQ7kUkPT6GoWyb9SUb6e IqtOtseaBpo4CCWzKHWUljGVkaGhcJ0gDhupMitaRgJTeTUK8sWUJ98UD1cM4W1MoFI8 w5KR3tyUCwVF7B/Uj1NqgaJFYXr7nrysECNAz1tuuxtaw6ofaLeICLCS1VY3K9DA1JY3 SPfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ACf3sZZ6JUpwwGnJCICtvZluxz8TE6VNlska+mK+xxg=; b=mI+aOrVl3xcNALCpIR5eGS2wgK9X7ZxUamTD5rmeADlSW1Dv59uVvjULdNlwcty7iu LDlAGUBcHvmgh8DGIyOMSHRDpygaAcSEAH2eCOzuGaZfCrkbb6JeFU/NUhXUOZVe6cpx DcTzblUvU/S/XgLpg0+krfsoUvoapZujUW0cVwFX6FvH9xlxu+78GnKRUjsFYy/0dd3A aPsHuTCxBGWA/9egLM3ESSTjkZX6wHYM8AMATz5dVdg+7YFISALpr32ohJ7EwEjgd9Rt 6QzCVuXjjMzeDcOLkun1uPOfXf23xX47WbNRUNhhu7l9FQyZ6dOa6Rdoo2Muv1Zcz0lX Lc6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Tez/Q0XB"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e67si18879128pfh.212.2019.02.21.06.25.33; Thu, 21 Feb 2019 06:25:49 -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=@gmail.com header.s=20161025 header.b="Tez/Q0XB"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727610AbfBUOZE (ORCPT + 99 others); Thu, 21 Feb 2019 09:25:04 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33069 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725891AbfBUOZD (ORCPT ); Thu, 21 Feb 2019 09:25:03 -0500 Received: by mail-pf1-f194.google.com with SMTP id i19so898459pfd.0; Thu, 21 Feb 2019 06:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ACf3sZZ6JUpwwGnJCICtvZluxz8TE6VNlska+mK+xxg=; b=Tez/Q0XB7GLm/fR0cdhhL1SS/QY+qWDbdg7pZpy7j7z6Y+MTcqZXfg4g+JOK3DWh9i GKCC6B+NjsUzBROR5vc75ytEa6vBxItoKofX72G2TZxuZ8Bxk411+Ef0YR39aP4WCz6U 4c/vYxO7excPDlgJkk5Rc8uXsZAy2T1LNvLYgH0/4ZjafdLIoLbscFuGdfWS/wt21IPM kCtJLu/DrhHxFlwm25uf17MXSkGu3DvECmWUSnsb0wh0/iMI68iRExFTCa5KW7ODt0c+ JJv9bKWkPaMCvyve1WudJOIlQROv0oa/pRoNgtMlLzDi7hKx2py5RF0c+sPLp1mnyQIV jUxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ACf3sZZ6JUpwwGnJCICtvZluxz8TE6VNlska+mK+xxg=; b=CLtccek+XMgF9ikG0UqFpV+dRFRTMzUQ7o6SdMfsGMXcifPl8327b4GA+h48BrJhUH jmDr2GTHprR/aD4nE8WGEwpFHTg7qQIIBgn454ReRlyqq6KjsAknXNUVV5HwzIT8ivsb +CSRgwWfaNSwAcsWxFFmsZ35Hwxa2JcTlGfDsjaXKmAPaFzeI0z3N5tjPQphvgS6AYPa zHSvn8z2Tfs0IAHuHHBvrgsxSOfXWl6sjBqDeDWU8Y/eykluxxEGCl3Flimk1LZHJfIz +zdnhkaklggagkQ+iGqYIMUr7RfgkdtAY2aksaVseWCL354D6vXauOgccYng7FJqY7Ml 0UTQ== X-Gm-Message-State: AHQUAuaex8+YNQIdLDbocMFcaJlyHlkjJxVctGMIQ9w/CA76SNxzVpnO INS1WmAt/SPorYcK5R+9f4/D32dARLRxRuVnqGU= X-Received: by 2002:a62:864c:: with SMTP id x73mr40782724pfd.49.1550759103168; Thu, 21 Feb 2019 06:25:03 -0800 (PST) MIME-Version: 1.0 References: <20190216001920.178053-1-rajatja@google.com> In-Reply-To: <20190216001920.178053-1-rajatja@google.com> From: Andy Shevchenko Date: Thu, 21 Feb 2019 16:24:52 +0200 Message-ID: Subject: Re: [PATCH] platform/x86: intel_pmc_core: Avoid a u32 overflow To: Rajat Jain Cc: Rajneesh Bhardwaj , Vishwanath Somayaji , Darren Hart , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List , Rajat Jain Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 16, 2019 at 2:19 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). > Pushed to my review and testing queue, thanks! > Signed-off-by: Rajat Jain > --- > 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) > -- > 2.21.0.rc0.258.g878e2cd30e-goog > -- With Best Regards, Andy Shevchenko