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

From: Borislav Petkov
Date: Thu Apr 02 2020 - 18:11:27 EST


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?

> + }
> + 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