Re: [PATCH RFC v2 5/6] x86: Use global pages when PTI is disabled

From: Nadav Amit
Date: Thu Feb 15 2018 - 12:47:45 EST


Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> wrote:

>> diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
>> index c67ef3fb4f35..979c7ec6baab 100644
>> --- a/arch/x86/mm/tlb.c
>> +++ b/arch/x86/mm/tlb.c
>> @@ -74,7 +74,8 @@ static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen,
>> return;
>> }
>>
>> - if (this_cpu_read(cpu_tlbstate.invalidate_other))
>> + if (this_cpu_read(cpu_tlbstate.invalidate_other) &&
>> + !mm_pti_disable(next))
>> clear_asid_other();
>
> This isn't obviously correct. Don't we still need to invalidate other
> user asids?

I forgot to regard this question: When you reenable PTI (after switching back
to 64-bit process), you flush the global pages, so no kernel mappings for the
32-bit process are left.

As for kernel mappings of 64-bit processes, you will flush them later, when
you switch back to 64-bit process (the indication is left set).