tegra-profiler: fix UBSAN shift_out_of_bound error
Igor Nabirushkin [Wed, 7 Jun 2017 11:54:47 +0000 (14:54 +0300)]
The UBSAN reports the following error in armv8_pmu.c:

[.../lib/ubsan.c:421>] __ubsan_handle_shift_out_of_bounds
[.../drivers/misc/tegra-profiler/armv8_pmu.c:273>] pmu_start
[.../drivers/misc/tegra-profiler/hrt.c:594>] __quadd_task_sched_in

The reason for this error is wrong value for PMOVSCLR_EL0 register.
This commit fixes this problem.

Bug 1932645

Change-Id: I589587b0d30e1c84a6c27d2f6b06cb2ced742655
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/1497591
(cherry picked from commit 96ca19ae7cdceae82ff3e96cae247334775e30c5)

drivers/misc/tegra-profiler/armv8_pmu.c

index c42adb8..da96932 100644 (file)
@@ -271,10 +271,10 @@ armv8_pmu_pmovsclr_read(void)
 }
 
 static inline void
-armv8_pmu_pmovsclr_write(int idx)
+armv8_pmu_pmovsclr_write(u32 val)
 {
        /* Write Performance Monitors Overflow Flag Status Register */
-       asm volatile("msr pmovsclr_el0, %0" : : "r" (BIT(idx)));
+       asm volatile("msr pmovsclr_el0, %0" : : "r" (val));
 }
 
 static inline u32