Skip to content

Commit

Permalink
arm64: arm_generic: prevent reading stale time
Browse files Browse the repository at this point in the history
Currently arch_counter_get_cnt{p,v}ct can be speculated, allowing for
stale time values to be read. This could be problematic for the delay
loop and other sensitive functions, as the time delta could jump around
unexpectedly.

This patch adds isbs to arch_counter_get_cnt{p,v}ct, preventing this
possibility.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
  • Loading branch information
Mark Rutland committed Jan 31, 2013
1 parent 8a4da6e commit 1dac0dd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/arm64/include/asm/arm_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static inline cycle_t arch_counter_get_cntpct(void)
{
cycle_t cval;

isb();
asm volatile("mrs %0, cntpct_el0" : "=r" (cval));

return cval;
Expand All @@ -92,6 +93,7 @@ static inline cycle_t arch_counter_get_cntvct(void)
{
cycle_t cval;

isb();
asm volatile("mrs %0, cntvct_el0" : "=r" (cval));

return cval;
Expand Down

0 comments on commit 1dac0dd

Please sign in to comment.