Skip to content
Snippets Groups Projects
Commit 02db49aa authored by Yang Yingliang's avatar Yang Yingliang Committed by 谢秀奇
Browse files

arm64: vdso: do cntvct workaround in the VDSO


hulk inclusion
category: performance
bugzilla: 16082
CVE: NA

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

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

Test code:

static unsigned long long getcycle(void)
{
    unsigned long long cval;
    asm volatile("isb" : : : "memory");
    asm volatile("mrs %0, cntvct_el0" : "=r" (cval));
}

int main(void)
{
    int i;
    struct  timeval tv;
    struct  timezone tz;
    unsigned long long s = getcycle();

    for (i = 0; i < 100000000; i++) {
            gettimeofday(&tv,&tz);
    }
    printf("cost:%lld\n", getcycle() - s);

    return 0;
}

Before this patchset, it costs 75.78s:
[root@localhost yang]# ./gettime
cost:3789000522 (20ns per cycle)

After this patchset, it costs 3.58s:
[root@localhost yang]# ./gettime
cost:183208254 (20ns per cycle)

Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarXuefeng Wang <wxf.wang@hisilicon.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent bb6a8bef
No related branches found
No related tags found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment