Subject: Re: linux-next: manual merge of the akpm-current tree with the tip tree

From: Stephen Rothwell <[email-masked]>
Date: Wed, 3 Jun 2020 14:43:39 +1000

Hi all,

On Mon, 25 May 2020 21:04:43 +1000 Stephen Rothwell <[email-masked]> wrote:
>
> Today's linux-next merge of the akpm-current tree got a conflict in:
> 
>   arch/x86/mm/tlb.c
> 
> between commit:
> 
>   83ce56f712af ("x86/mm: Refactor cond_ibpb() to support other use cases")
> 
> from the tip tree and commit:
> 
>   36c8e34d03a1 ("x86/mm: remove vmalloc faulting")
> 
> from the akpm-current tree.
> 
> diff --cc arch/x86/mm/tlb.c
> index c8524c506ab0,f3fe261e5936..000000000000
> --- a/arch/x86/mm/tlb.c
> +++ b/arch/x86/mm/tlb.c
> @@@ -345,48 -161,16 +345,20 @@@ void switch_mm(struct mm_struct *prev, 
>   	local_irq_restore(flags);
>   }
>   
> - static void sync_current_stack_to_mm(struct mm_struct *mm)
> - {
> - 	unsigned long sp = current_stack_pointer;
> - 	pgd_t *pgd = pgd_offset(mm, sp);
> - 
> - 	if (pgtable_l5_enabled()) {
> - 		if (unlikely(pgd_none(*pgd))) {
> - 			pgd_t *pgd_ref = pgd_offset_k(sp);
> - 
> - 			set_pgd(pgd, *pgd_ref);
> - 		}
> - 	} else {
> - 		/*
> - 		 * "pgd" is faked.  The top level entries are "p4d"s, so sync
> - 		 * the p4d.  This compiles to approximately the same code as
> - 		 * the 5-level case.
> - 		 */
> - 		p4d_t *p4d = p4d_offset(pgd, sp);
> - 
> - 		if (unlikely(p4d_none(*p4d))) {
> - 			pgd_t *pgd_ref = pgd_offset_k(sp);
> - 			p4d_t *p4d_ref = p4d_offset(pgd_ref, sp);
> - 
> - 			set_p4d(p4d, *p4d_ref);
> - 		}
> - 	}
> - }
> - 
>  -static inline unsigned long mm_mangle_tif_spec_ib(struct task_struct *next)
>  +static inline unsigned long mm_mangle_tif_spec_bits(struct task_struct *next)
>   {
>   	unsigned long next_tif = task_thread_info(next)->flags;
>  -	unsigned long ibpb = (next_tif >> TIF_SPEC_IB) & LAST_USER_MM_IBPB;
>  +	unsigned long spec_bits = (next_tif >> TIF_SPEC_IB) & LAST_USER_MM_SPEC_MASK;
>   
>  -	return (unsigned long)next->mm | ibpb;
>  +	BUILD_BUG_ON(TIF_SPEC_L1D_FLUSH != TIF_SPEC_IB + 1);
>  +
>  +	return (unsigned long)next->mm | spec_bits;
>   }
>   
>  -static void cond_ibpb(struct task_struct *next)
>  +static void cond_mitigation(struct task_struct *next)
>   {
>  +	unsigned long prev_mm, next_mm;
>  +
>   	if (!next || !next->mm)
>   		return;
>   
> @@@ -587,20 -343,12 +559,11 @@@ void switch_mm_irqs_off(struct mm_struc
>   		need_flush = true;
>   	} else {
>   		/*
>  -		 * Avoid user/user BTB poisoning by flushing the branch
>  -		 * predictor when switching between processes. This stops
>  -		 * one process from doing Spectre-v2 attacks on another.
>  +		 * Apply process to process speculation vulnerability
>  +		 * mitigations if applicable.
>   		 */
>  -		cond_ibpb(tsk);
>  +		cond_mitigation(tsk);
>   
> - 		if (IS_ENABLED(CONFIG_VMAP_STACK)) {
> - 			/*
> - 			 * If our current stack is in vmalloc space and isn't
> - 			 * mapped in the new pgd, we'll double-fault.  Forcibly
> - 			 * map it.
> - 			 */
> - 			sync_current_stack_to_mm(next);
> - 		}
> - 
>   		/*
>   		 * Stop remote flushes for the previous mm.
>   		 * Skip kernel threads; we never send init_mm TLB flushing IPIs,

This is now a conflict between commit

  94709049fb84 ("Merge branch 'akpm' (patches from Andrew)")

from Linus' tree and the above tip tree commit.

-- 
Cheers,
Stephen Rothwell