1 #ifndef _ASM_X86_INVPCID_H_
2 #define _ASM_X86_INVPCID_H_
3
4 #include <xen/types.h>
5
6 extern bool use_invpcid;
7
invpcid(unsigned int pcid,unsigned long addr,unsigned int type)8 static inline void invpcid(unsigned int pcid, unsigned long addr,
9 unsigned int type)
10 {
11 struct {
12 uint64_t pcid:12;
13 uint64_t reserved:52;
14 uint64_t addr;
15 } desc = { .pcid = pcid, .addr = addr };
16
17 asm volatile ( "invpcid %[desc], %q[type]"
18 :
19 : [desc] "m" (desc), [type] "r" (type)
20 : "memory" );
21 }
22
23 /* Flush all mappings for a given PCID and addr, not including globals */
invpcid_flush_one(unsigned int pcid,unsigned long addr)24 static inline void invpcid_flush_one(unsigned int pcid, unsigned long addr)
25 {
26 invpcid(pcid, addr, X86_INVPCID_INDIV_ADDR);
27 }
28
29 /* Flush all mappings for a given PCID, not including globals */
invpcid_flush_single_context(unsigned int pcid)30 static inline void invpcid_flush_single_context(unsigned int pcid)
31 {
32 invpcid(pcid, 0, X86_INVPCID_SINGLE_CTXT);
33 }
34
35 /* Flush all mappings, including globals, for all PCIDs */
invpcid_flush_all(void)36 static inline void invpcid_flush_all(void)
37 {
38 invpcid(0, 0, X86_INVPCID_ALL_INCL_GLOBAL);
39 }
40
41 /* Flush all mappings for all PCIDs, excluding globals */
invpcid_flush_all_nonglobals(void)42 static inline void invpcid_flush_all_nonglobals(void)
43 {
44 invpcid(0, 0, X86_INVPCID_ALL_NON_GLOBAL);
45 }
46
47 #endif /* _ASM_X86_INVPCID_H_ */
48
49 /*
50 * Local variables:
51 * mode: C
52 * c-file-style: "BSD"
53 * c-basic-offset: 4
54 * tab-width: 4
55 * indent-tabs-mode: nil
56 * End:
57 */
58