Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_INVPCID
0003 #define _ASM_X86_INVPCID
0004 
0005 static inline void __invpcid(unsigned long pcid, unsigned long addr,
0006                  unsigned long type)
0007 {
0008     struct { u64 d[2]; } desc = { { pcid, addr } };
0009 
0010     /*
0011      * The memory clobber is because the whole point is to invalidate
0012      * stale TLB entries and, especially if we're flushing global
0013      * mappings, we don't want the compiler to reorder any subsequent
0014      * memory accesses before the TLB flush.
0015      */
0016     asm volatile("invpcid %[desc], %[type]"
0017              :: [desc] "m" (desc), [type] "r" (type) : "memory");
0018 }
0019 
0020 #define INVPCID_TYPE_INDIV_ADDR     0
0021 #define INVPCID_TYPE_SINGLE_CTXT    1
0022 #define INVPCID_TYPE_ALL_INCL_GLOBAL    2
0023 #define INVPCID_TYPE_ALL_NON_GLOBAL 3
0024 
0025 /* Flush all mappings for a given pcid and addr, not including globals. */
0026 static inline void invpcid_flush_one(unsigned long pcid,
0027                      unsigned long addr)
0028 {
0029     __invpcid(pcid, addr, INVPCID_TYPE_INDIV_ADDR);
0030 }
0031 
0032 /* Flush all mappings for a given PCID, not including globals. */
0033 static inline void invpcid_flush_single_context(unsigned long pcid)
0034 {
0035     __invpcid(pcid, 0, INVPCID_TYPE_SINGLE_CTXT);
0036 }
0037 
0038 /* Flush all mappings, including globals, for all PCIDs. */
0039 static inline void invpcid_flush_all(void)
0040 {
0041     __invpcid(0, 0, INVPCID_TYPE_ALL_INCL_GLOBAL);
0042 }
0043 
0044 /* Flush all mappings for all PCIDs except globals. */
0045 static inline void invpcid_flush_all_nonglobals(void)
0046 {
0047     __invpcid(0, 0, INVPCID_TYPE_ALL_NON_GLOBAL);
0048 }
0049 
0050 #endif /* _ASM_X86_INVPCID */