diff options
author | Adam Lessnau <adam.lessnau@intel.com> | 2017-06-01 12:21:50 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-06-28 01:38:34 +0300 |
commit | edbdabc62328ec0ac98d83ca384bf9fd5251ade6 (patch) | |
tree | a689a149912e0efc6a87a1d83ec24cccf4a3bb68 /drivers/powercap | |
parent | c0bc126f97fb929b3ae02c1c62322645d70eb408 (diff) | |
download | linux-edbdabc62328ec0ac98d83ca384bf9fd5251ade6.tar.xz |
powercap/RAPL: prevent overridding bits outside of the mask
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>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/powercap')
-rw-r--r-- | drivers/powercap/intel_rapl.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index 9ddad0815ba9..d1694f1def72 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c @@ -874,7 +874,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]; |