Re: [PATCH v2] arm64: Force SSBS on context switch

Will Deacon
2019-07-22T16:04:46Z

On Mon, Jul 22, 2019 at 08:28:15PM +0530, Neeraj Upadhyay wrote:
> On 7/22/19 7:23 PM, Marc Zyngier wrote:
> > +static void ssbs_thread_switch(struct task_struct *next)
> > +{
> > + if (likely(!(next->flags & PF_KTHREAD)) &&
> > + arm64_get_ssbd_state() != ARM64_SSBD_FORCE_ENABLE &&
> > + !test_tsk_thread_flag(next, TIF_SSBD)) {
> > + struct pt_regs *regs = task_pt_regs(next);
> > +
> > + if (compat_user_mode(regs))
> > + set_compat_ssbs_bit(regs);
> > + else if (user_mode(regs))
> > + set_ssbs_bit(regs);
> > + }
> > +}
> > +
> > /*
> > * We store our current task in sp_el0, which is clobbered by userspace. Keep a
> > * shadow copy so that we can restore this upon entry from userspace.
> > @@ -471,6 +485,7 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
> > entry_task_switch(next);
> > uao_thread_switch(next);
> > ptrauth_thread_switch(next);
> > + ssbs_thread_switch(next);
> > /*
> > * Complete any pending TLB or cache maintenance on this CPU in case
>
> Looks good to me.

I inverted the logic in ssbs_thread_switch() so I could add some comments.
Please double check:

https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?h=for-next/fixes&id=cbdf8a189a66001c36007bf0f5c975d0376c5c3a

Will