提交 89d94b6b 编写于 作者: Y Yang Yingliang 提交者: Zheng Zengkai

vdso: do cntvct workaround in the VDSO

hulk inclusion
category: feature
bugzilla: 47984
CVE: NA

--------------------------------------------------

If a cntvct workaround is enabled, read CNTVCT_EL0 twice
in VDSO to avoid the clock bug.

Without this patch on Kunpeng916:
./gettimeofday -E -C 200 -L -S -W -N "gettimeofday"
Running:        gettimeofday# ./gettimeofday -E -C 200 -L -S -W -N gettimeofday
             prc thr   usecs/call      samples   errors cnt/samp
gettimeofday   1   1      0.31753          198        0    20000

With this patch on Kunpeng916:
./gettimeofday -E -C 200 -L -S -W -N "gettimeofday"
Running:        gettimeofday# ./gettimeofday -E -C 200 -L -S -W -N gettimeofday
             prc thr   usecs/call      samples   errors cnt/samp
gettimeofday   1   1      0.05244          198        0    20000
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 609a81be
......@@ -83,6 +83,17 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
*/
isb();
asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
if (vd->vdso_fix) {
u64 new;
int retries = 50;
asm volatile("mrs %0, cntvct_el0" : "=r" (new) :: "memory");
while (unlikely((new - res) >> vd->vdso_shift) && retries) {
asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
asm volatile("mrs %0, cntvct_el0" : "=r" (new) :: "memory");
retries--;
}
}
/*
* This isb() is required to prevent that the seq lock is
* speculated.#
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部