[PATCH 2/2] arm64/arch_timer: replace arch_counter_enforce_ordering() with isb
Will Deacon
will at kernel.org
Tue Mar 30 12:05:53 BST 2021
On Tue, Mar 30, 2021 at 06:57:19PM +0800, Pingfan Liu wrote:
> The description of getting counter value is not very clear. [1]
> 'mrs Xt, cntpct' may execute out of program order, either forward or
> backward.
>
> Now taking a look at this group of getting counter routines. All of them
> are called from sched_clock(). And there is an isb to protect forward
> speculation. But there is no isb for the backward speculation.
>
> The current code enforces read dependency instructions anchored on
> getting counter. But it is not enough to protect against other no
> dependency instructions, and even function call can not prevent the
> speculation between getting counter and them.
Which "no dependency instructions"?
>
> Replacing arch_counter_enforce_ordering() with isb to achieve the aim.
>
> [1]: AArch64 Programmer's Guides Generic Timer: 3.1. Count and frequency
I wouldn't trust that guide as far as I can throw it.
Please describe the problem you're trying to solve, and hopefully I can
help. ISB is an expensive instruction so we need a good justification to
add it here (i.e. an example of why the current scheme is not correct).
Thanks,
Will
More information about the linux-arm-kernel
mailing list