[PATCH v2 2/4] arm64: fpsimd: Preserve/restore kernel mode NEON at context switch

Ard Biesheuvel ardb at kernel.org
Fri Nov 24 00:29:27 PST 2023


On Fri, 24 Nov 2023 at 01:14, Eric Biggers <ebiggers at kernel.org> wrote:
>
> On Thu, Nov 23, 2023 at 06:44:36PM +0100, Ard Biesheuvel wrote:
> > -     /*
> > -      * Fix up TIF_FOREIGN_FPSTATE to correctly describe next's
> > -      * state.  For kernel threads, FPSIMD registers are never loaded
> > -      * and wrong_task and wrong_cpu will always be true.
> > -      */
> > -     wrong_task = __this_cpu_read(fpsimd_last_state.st) !=
> > -                                     &next->thread.uw.fpsimd_state;
> > -     wrong_cpu = next->thread.fpsimd_cpu != smp_processor_id();
> > +     if (test_tsk_thread_flag(next, TIF_USING_KMODE_FPSIMD)) {
> > +             fpsimd_load_kernel_state(next);
> > +             set_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE);
> > +     } else {
> > +             /*
> > +              * Fix up TIF_FOREIGN_FPSTATE to correctly describe next's
> > +              * state.  For kernel threads, FPSIMD registers are never
> > +              * loaded and wrong_task and wrong_cpu will always be true.
> > +              */
> > +             wrong_task = __this_cpu_read(fpsimd_last_state.st) !=
> > +                     &next->thread.uw.fpsimd_state;
> > +             wrong_cpu = next->thread.fpsimd_cpu != smp_processor_id();
>
> The "For kernel threads, FPSIMD registers are never loaded" part is outdated
> now, right?
>

Yeah, this needs a tweak to clarify that it refers to user mode FPSIMD
state, which does not exist for kernel threads.



More information about the linux-arm-kernel mailing list