powercap/rapl: prevent overridding bits outside of the mask
PATCH 1/1 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.
--- drivers/powercap/intel_rapl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/powercap/intel_rapl.c +3 -1
@@ -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];
Signature · 1 line
2.13.0
Quoted 6 lines · Adam Lessnau
Fixes wrong bits shift operation in the
rapl_write_data_rawfunction, which might cause overridding bits outside of the mask.For example, writing new
TIME_WINDOW1value can overridePOWER_LIMIT1.Signed-off-by Adam Lessnau <[email protected]>
Jacob, any comments?
Quoted 20 lines
--- drivers/powercap/intel_rapl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/powercap/intel_rapl.c +3
-1@@ -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];
Quoted 11 lines · On Tue, 27 Jun 2017 02:17:32 +0200 "Rafael J. Wysocki" <[email protected]>…
Quoted 7 lines · Adam Lessnau
Fixes wrong bits shift operation in the
rapl_write_data_rawfunction, which might cause overridding bits outside of the mask.For example, writing new
TIME_WINDOW1value can overridePOWER_LIMIT1.Signed-off-by Adam Lessnau <[email protected]>Jacob, any comments?
Looks like a good fix. Thanks.
Quoted 18 lines
Quoted 18 lines
--- drivers/powercap/intel_rapl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/powercap/intel_rapl.cindex3c71f608b444..6dc27afb8527100644 ---a/drivers/powercap/intel_rapl.c
+++b/drivers/powercap/intel_rapl.cdrivers/powercap/intel_rapl.c +3
-1@@ -887,7 +887,9 @@ static int rapl_write_data_raw(structrapl_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));
Quoted 3 lines
drivers/powercap/intel_rapl.c static int rapl_write_data_raw(struct rapl_domain *rd, · line 895
Quoted 2 lines
drivers/powercap/intel_rapl.c +0
-0ma.msr_no = rd->msrs[rp->id];
[Jacob Pan]