From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Adam Lessnau <adam.lessnau@intel.com>,
linux-pm@vger.kernel.org, jacob.jun.pan@linux.intel.com
Subject: Re: [PATCH] powercap/rapl: prevent overridding bits outside of the mask
Date: Tue, 27 Jun 2017 09:25:56 -0700 [thread overview]
Message-ID: <20170627092556.082a58c7@jacob-builder> (raw)
In-Reply-To: <30611930.SfmUctH6tv@aspire.rjw.lan>
On Tue, 27 Jun 2017 02:17:32 +0200
"Rafael J. Wysocki" <rjw@rjwysocki.net> wrote:
> On Thursday, June 01, 2017 11:21:50 AM Adam Lessnau wrote:
> > Fixes wrong bits shift operation in the rapl_write_data_raw
> > function, which might cause overridding bits outside of the mask.
> >
> > For example, writing new TIME_WINDOW1 value can override
> > POWER_LIMIT1.
> >
> > Signed-off-by: Adam Lessnau <adam.lessnau@intel.com>
>
> Jacob, any comments?
>
Looks like a good fix. Thanks.
> > ---
> > drivers/powercap/intel_rapl.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/powercap/intel_rapl.c
> > b/drivers/powercap/intel_rapl.c index 3c71f608b444..6dc27afb8527
> > 100644 --- a/drivers/powercap/intel_rapl.c
> > +++ b/drivers/powercap/intel_rapl.c
> > @@ -887,7 +887,9 @@ static int rapl_write_data_raw(struct
> > rapl_domain *rd,
> > cpu = rd->rp->lead_cpu;
> > bits = rapl_unit_xlate(rd, rp->unit, value, 1);
> > - bits |= bits << rp->shift;
> > + bits <<= rp->shift;
> > + bits &= rp->mask;
> > +
> > memset(&ma, 0, sizeof(ma));
> >
> > ma.msr_no = rd->msrs[rp->id];
> >
>
[Jacob Pan]
prev parent reply other threads:[~2017-06-27 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 9:21 [PATCH] powercap/rapl: prevent overridding bits outside of the mask Adam Lessnau
2017-06-27 0:17 ` Rafael J. Wysocki
2017-06-27 16:25 ` Jacob Pan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170627092556.082a58c7@jacob-builder \
--to=jacob.jun.pan@linux.intel.com \
--cc=adam.lessnau@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).