提交 bb6a8bef 编写于 作者: Y Yang Yingliang 提交者: Xie XiuQi

arm64: arch_timer: Disable CNTVCT_EL0 trap if workaround is enabled

hulk inclusion
category: performance
bugzilla: 16082
CVE: NA

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

It costs very much time to read CNTVCT_EL0, if a cntvct workaround
and CNTVCT_EL0 trap is enabled. To decrease the read time, we disable
CNTVCT_EL0 trap and do the cntvct workaround in the VDSO by adding
vdso_fix.
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NXuefeng Wang <wxf.wang@hisilicon.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 32c9eecb
...@@ -76,6 +76,7 @@ static bool arch_timer_c3stop; ...@@ -76,6 +76,7 @@ static bool arch_timer_c3stop;
static bool arch_timer_mem_use_virtual; static bool arch_timer_mem_use_virtual;
static bool arch_counter_suspend_stop; static bool arch_counter_suspend_stop;
static bool vdso_default = true; static bool vdso_default = true;
DEFINE_STATIC_KEY_FALSE(vdso_fix);
static cpumask_t evtstrm_available = CPU_MASK_NONE; static cpumask_t evtstrm_available = CPU_MASK_NONE;
static bool evtstrm_enable = IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM); static bool evtstrm_enable = IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM);
...@@ -550,8 +551,9 @@ void arch_timer_enable_workaround(const struct arch_timer_erratum_workaround *wa ...@@ -550,8 +551,9 @@ void arch_timer_enable_workaround(const struct arch_timer_erratum_workaround *wa
* change both the default value and the vdso itself. * change both the default value and the vdso itself.
*/ */
if (wa->read_cntvct_el0) { if (wa->read_cntvct_el0) {
clocksource_counter.archdata.vdso_direct = false; clocksource_counter.archdata.vdso_direct = true;
vdso_default = false; vdso_default = true;
static_branch_enable(&vdso_fix);
} }
} }
...@@ -855,7 +857,8 @@ static void arch_counter_set_user_access(void) ...@@ -855,7 +857,8 @@ static void arch_counter_set_user_access(void)
* need to be workaround. The vdso may have been already * need to be workaround. The vdso may have been already
* disabled though. * disabled though.
*/ */
if (arch_timer_this_cpu_has_cntvct_wa()) if (arch_timer_this_cpu_has_cntvct_wa() &&
!static_branch_unlikely(&vdso_fix))
pr_info("CPU%d: Trapping CNTVCT access\n", smp_processor_id()); pr_info("CPU%d: Trapping CNTVCT access\n", smp_processor_id());
else else
cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN; cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册