Re: [PATCH 21/23] x86, pcid, kaiser: allow flushing for future ASID switches
From: Andy Lutomirski
Date: Wed Nov 01 2017 - 04:04:16 EST
On Tue, Oct 31, 2017 at 3:32 PM, Dave Hansen
<dave.hansen@xxxxxxxxxxxxxxx> wrote:
>
> If we change the page tables in such a way that we need an
> invalidation of all contexts (aka. PCIDs / ASIDs) we can
> actively invalidate them by:
> 1. INVPCID for each PCID (works for single pages too).
> 2. Load CR3 with each PCID without the NOFLUSH bit set
> 3. Load CR3 with the NOFLUSH bit set for each and do
> INVLPG for each address.
>
> But, none of these are really feasible since we have ~6 ASIDs (12 with
> KAISER) at the time that we need to do an invalidation. So, we just
> invalidate the *current* context and then mark the cpu_tlbstate
> _quickly_.
>
> Then, at the next context-switch, we notice that we had
> 'all_other_ctxs_invalid' marked, and go invalidate all of the
> cpu_tlbstate.ctxs[] entries.
>
> This ensures that any futuee context switches will do a full flush
> of the TLB so they pick up the changes.
I'm convuced. What was wrong with the old code? I guess I just don't
see what the problem is that is solved by this patch.