[PATCH v1 24/38] arm64/sme: Implement traps and syscall handling for SME

Jonathan Cameron Jonathan.Cameron at Huawei.com
Mon Oct 11 05:37:59 PDT 2021


On Thu, 30 Sep 2021 19:11:30 +0100
Mark Brown <broonie at kernel.org> wrote:

> By default all SME operations in userspace will trap.  When this happens
> we allocate storage space for the SME register state, set up the SVE
> registers and disable traps.  We do not need to initialize ZA since the
> architecture guarantees that it will be zeroed when enabled and when we
> trap ZA is disabled.
> 
> On syscall we exit streaming mode if we were previously in it and ensure
> that all but the lower 128 bits of the registers are zeroed while
> preserving the state of ZA. This follows the aarch64 PCS for SME, ZA
> state is preserved over a function call and streaming mode is exited.
> Since the traps for SME do not distinguish between streaming mode SVE
> and ZA usage if ZA is in use rather than reenabling traps we instead
> zero the parts of the SVE registers not shared with FPSIMD and leave SME
> enabled, this simplifies handling SME traps. If ZA is not in use then we
> reenable SME traps and fall through to normal handling of SVE.
> 
> Signed-off-by: Mark Brown <broonie at kernel.org>
...  continuing the trivial theme of my review today...


>  
>  	/*
>  	 * task_fpsimd_load() won't be called to update CPACR_EL1 in
> -	 * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which only
> -	 * happens if a context switch or kernel_neon_begin() or context
> -	 * modification (sigreturn, ptrace) intervenes.
> -	 * So, ensure that CPACR_EL1 is already correct for the fast-path case.
> +	 * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which
> +	 * only happens if a context switch or kernel_neon_begin() or

Why the rewrap here?

> +	 * context modification (sigreturn, ptrace) intervenes.  So,
> +	 * ensure that CPACR_EL1 is already correct for the fast-path
> +	 * case.
>  	 */
>  	sve_user_disable();
>  }
>  
>  void do_el0_svc(struct pt_regs *regs)
>  {
> -	sve_user_discard();
> +	fp_user_discard();
>  	el0_svc_common(regs, regs->regs[8], __NR_syscalls, sys_call_table);
>  }
>  




More information about the linux-arm-kernel mailing list