Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edbdabc6 authored by Adam Lessnau's avatar Adam Lessnau Committed by Rafael J. Wysocki
Browse files

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: default avatarAdam Lessnau <adam.lessnau@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c0bc126f
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -874,7 +874,9 @@ static int rapl_write_data_raw(struct rapl_domain *rd,


	cpu = rd->rp->lead_cpu;
	cpu = rd->rp->lead_cpu;
	bits = rapl_unit_xlate(rd, rp->unit, value, 1);
	bits = rapl_unit_xlate(rd, rp->unit, value, 1);
	bits |= bits << rp->shift;
	bits <<= rp->shift;
	bits &= rp->mask;

	memset(&ma, 0, sizeof(ma));
	memset(&ma, 0, sizeof(ma));


	ma.msr_no = rd->msrs[rp->id];
	ma.msr_no = rd->msrs[rp->id];