From: Will Deacon Date: Thu, 12 Sep 2024 12:44:03 +0000 (+0100) Subject: Merge branch 'for-next/timers' into for-next/core X-Git-Tag: v6.12-rc1~221^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75078ba2b38a38d94017bd334f71aaed205e30a4;p=thirdparty%2Fkernel%2Flinux.git Merge branch 'for-next/timers' into for-next/core * for-next/timers: arm64: Implement prctl(PR_{G,S}ET_TSC) --- 75078ba2b38a38d94017bd334f71aaed205e30a4 diff --cc arch/arm64/kernel/process.c index f365b033a6495,1b6bbf839bb5e..0540653fbf382 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@@ -500,24 -492,35 +504,46 @@@ static void update_cntkctl_el1(struct t sysreg_clear_set(cntkctl_el1, 0, ARCH_TIMER_USR_VCT_ACCESS_EN); } - static void erratum_1418040_new_exec(void) + static void cntkctl_thread_switch(struct task_struct *prev, + struct task_struct *next) + { + if ((read_ti_thread_flags(task_thread_info(prev)) & + (_TIF_32BIT | _TIF_TSC_SIGSEGV)) != + (read_ti_thread_flags(task_thread_info(next)) & + (_TIF_32BIT | _TIF_TSC_SIGSEGV))) + update_cntkctl_el1(next); + } + + static int do_set_tsc_mode(unsigned int val) { + bool tsc_sigsegv; + + if (val == PR_TSC_SIGSEGV) + tsc_sigsegv = true; + else if (val == PR_TSC_ENABLE) + tsc_sigsegv = false; + else + return -EINVAL; + preempt_disable(); - erratum_1418040_thread_switch(current); + update_thread_flag(TIF_TSC_SIGSEGV, tsc_sigsegv); + update_cntkctl_el1(current); preempt_enable(); + + return 0; } +static void permission_overlay_switch(struct task_struct *next) +{ + if (!system_supports_poe()) + return; + + current->thread.por_el0 = read_sysreg_s(SYS_POR_EL0); + if (current->thread.por_el0 != next->thread.por_el0) { + write_sysreg_s(next->thread.por_el0, SYS_POR_EL0); + } +} + /* * __switch_to() checks current->thread.sctlr_user as an optimisation. Therefore * this function must be called with preemption disabled and the update to @@@ -551,9 -554,8 +577,9 @@@ struct task_struct *__switch_to(struct contextidr_thread_switch(next); entry_task_switch(next); ssbs_thread_switch(next); - erratum_1418040_thread_switch(next); + cntkctl_thread_switch(prev, next); ptrauth_thread_switch_user(next); + permission_overlay_switch(next); /* * Complete any pending TLB or cache maintenance on this CPU in case