Re: [PATCH 3/3] arch/x86: Optionally flush L1D on context switch

From: Singh, Balbir
Date: Thu Apr 02 2020 - 18:19:03 EST


On Fri, 2020-04-03 at 00:11 +0200, Borislav Petkov wrote:
> CAUTION: This email originated from outside of the organization. Do not
> click links or open attachments unless you can confirm the sender and know
> the content is safe.
>
>
>
> On Thu, Apr 02, 2020 at 05:24:01PM +1100, Balbir Singh wrote:
> > +int enable_l1d_flush_for_task(struct task_struct *tsk)
> > +{
> > + struct page *page;
> > + int ret = 0;
> > +
> > + if (static_cpu_has(X86_FEATURE_FLUSH_L1D))
> > + goto done;
> > +
> > + page = READ_ONCE(l1d_flush_pages);
> > + if (unlikely(!page)) {
> > + mutex_lock(&l1d_flush_mutex);
> > + if (!l1d_flush_pages) {
> > + l1d_flush_pages = alloc_l1d_flush_pages();
> > + if (!l1d_flush_pages)
> > + return -ENOMEM;
>
> Do I see it correctly that you'll return here with l1d_flush_mutex still
> held?

Darn.. :(

I had goto done to release the mutex earlier, let me fix that :)

Thanks,
Balbir Singh

>
> > + }
> > + mutex_unlock(&l1d_flush_mutex);
> > + }
> > + /* I don't think we need to worry about KSM */
>
> Pls use passive voice: no "we" or "I", etc.
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette