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:Yang Yingliang <yangyingliang@huawei.com> Reviewed-by:
Xuefeng Wang <wxf.wang@hisilicon.com> Signed-off-by:
Yang Yingliang <yangyingliang@huawei.com>
Please register or sign in to comment