提交 1dac0dd7 编写于 作者: M Mark Rutland

arm64: arm_generic: prevent reading stale time

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: NMark Rutland <mark.rutland@arm.com>
Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
上级 8a4da6e3
...@@ -83,6 +83,7 @@ static inline cycle_t arch_counter_get_cntpct(void) ...@@ -83,6 +83,7 @@ static inline cycle_t arch_counter_get_cntpct(void)
{ {
cycle_t cval; cycle_t cval;
isb();
asm volatile("mrs %0, cntpct_el0" : "=r" (cval)); asm volatile("mrs %0, cntpct_el0" : "=r" (cval));
return cval; return cval;
...@@ -92,6 +93,7 @@ static inline cycle_t arch_counter_get_cntvct(void) ...@@ -92,6 +93,7 @@ static inline cycle_t arch_counter_get_cntvct(void)
{ {
cycle_t cval; cycle_t cval;
isb();
asm volatile("mrs %0, cntvct_el0" : "=r" (cval)); asm volatile("mrs %0, cntvct_el0" : "=r" (cval));
return cval; return cval;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册