• Dave Hansen's avatar
    x86/mm: Allow flushing for future ASID switches · 2ea907c4
    Dave Hansen authored
    If changing the page tables in such a way that an invalidation of all
    contexts (aka. PCIDs / ASIDs) is required, they can be actively invalidated
    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 there are ~6 ASIDs (12 with
    PAGE_TABLE_ISOLATION) at the time that invalidation is required.
    Instead of actively invalidating them, invalidate the *current* context and
    also mark the cpu_tlbstate _quickly_ to indicate future invalidation to be
    required.
    
    At the next context-switch, look for this indicator
    ('invalidate_other' being set) invalidate all of the
    cpu_tlbstate.ctxs[] entries.
    
    This ensures that any future context switches will do a full flush
    of the TLB, picking up the previous changes.
    
    [ tglx: Folded more fixups from Peter ]
    Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: David Laight <David.Laight@aculab.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: Eduardo Valentin <eduval@amazon.com>
    Cc: Greg KH <gregkh@linuxfoundation.org>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Juergen Gross <jgross@suse.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Will Deacon <will.deacon@arm.com>
    Cc: aliguori@amazon.com
    Cc: daniel.gruss@iaik.tugraz.at
    Cc: hughd@google.com
    Cc: keescook@google.com
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    2ea907c4
tlb.c 19.8 KB