[PATCH v2] arm64: errata: Fix exec handling in erratum 1418040 workaround

Marc Zyngier maz at kernel.org
Thu Dec 16 11:52:44 PST 2021


On 2021-12-16 19:16, D Scott Phillips wrote:
> The erratum 1418040 workaround changes vct access trapping when 
> switching
> between compat and non-compat threads. The workaround logic assumes 
> that
> the hardware vct trapping state matches the previous task's 
> compat-ness.
> However, when a non-compat task execs a compat binary or vice versa, 
> the
> cntkctl state and task compat-ness get out of sync. Keep the hardware
> trapping state in sync with the task personality.
> 
> Fixes: d49f7d7376d0 ("arm64: Move handling of erratum 1418040 into C 
> code")
> Signed-off-by: D Scott Phillips <scott at os.amperecomputing.com>
> Reviewed-by: Marc Zyngier <maz at kernel.org>
> Cc: <stable at vger.kernel.org> # 5.4.x
> ---
> 
>  v2: - Use sysreg_clear_set instead of open coding (Marc)
>      - guard this_cpu_has_cap() check under IS_ENABLED() to avoid tons 
> of
>        WARN_ON(preemptible()) when built with 
> !CONFIG_ARM64_ERRATUM_1418040

Indeed.

>  arch/arm64/include/asm/elf.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/elf.h 
> b/arch/arm64/include/asm/elf.h
> index 97932fbf973d..24036b914226 100644
> --- a/arch/arm64/include/asm/elf.h
> +++ b/arch/arm64/include/asm/elf.h
> @@ -160,8 +160,16 @@ typedef struct user_fpsimd_state elf_fpregset_t;
> 
>  #define SET_PERSONALITY(ex)						\
>  ({									\
> +	if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040))			\
> +		preempt_disable();					\
>  	clear_thread_flag(TIF_32BIT);					\
>  	current->personality &= ~READ_IMPLIES_EXEC;			\
> +	if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040)) {			\
> +		if (this_cpu_has_cap(ARM64_WORKAROUND_1418040))		\

Probably better written as:

         if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
             this_cpu_has_cap(ARM64_WORKAROUND_1418040))
                 sysreg_clear_set(...);

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...



More information about the linux-arm-kernel mailing list