1 #ifndef __ASM_ARM_ARM64_FLUSHTLB_H__
2 #define __ASM_ARM_ARM64_FLUSHTLB_H__
3 
4 /*
5  * Every invalidation operation use the following patterns:
6  *
7  * DSB ISHST        // Ensure prior page-tables updates have completed
8  * TLBI...          // Invalidate the TLB
9  * DSB ISH          // Ensure the TLB invalidation has completed
10  * ISB              // See explanation below
11  *
12  * For Xen page-tables the ISB will discard any instructions fetched
13  * from the old mappings.
14  *
15  * For the Stage-2 page-tables the ISB ensures the completion of the DSB
16  * (and therefore the TLB invalidation) before continuing. So we know
17  * the TLBs cannot contain an entry for a mapping we may have removed.
18  */
19 #define TLB_HELPER(name, tlbop) \
20 static inline void name(void)   \
21 {                               \
22     asm volatile(               \
23         "dsb  ishst;"           \
24         "tlbi "  # tlbop  ";"   \
25         "dsb  ish;"             \
26         "isb;"                  \
27         : : : "memory");        \
28 }
29 
30 /* Flush local TLBs, current VMID only. */
31 TLB_HELPER(flush_guest_tlb_local, vmalls12e1);
32 
33 /* Flush innershareable TLBs, current VMID only */
34 TLB_HELPER(flush_guest_tlb, vmalls12e1is);
35 
36 /* Flush local TLBs, all VMIDs, non-hypervisor mode */
37 TLB_HELPER(flush_all_guests_tlb_local, alle1);
38 
39 /* Flush innershareable TLBs, all VMIDs, non-hypervisor mode */
40 TLB_HELPER(flush_all_guests_tlb, alle1is);
41 
42 /* Flush all hypervisor mappings from the TLB of the local processor. */
43 TLB_HELPER(flush_xen_tlb_local, alle2);
44 
45 /* Flush TLB of local processor for address va. */
__flush_xen_tlb_one_local(vaddr_t va)46 static inline void  __flush_xen_tlb_one_local(vaddr_t va)
47 {
48     asm volatile("tlbi vae2, %0;" : : "r" (va>>PAGE_SHIFT) : "memory");
49 }
50 
51 /* Flush TLB of all processors in the inner-shareable domain for address va. */
__flush_xen_tlb_one(vaddr_t va)52 static inline void __flush_xen_tlb_one(vaddr_t va)
53 {
54     asm volatile("tlbi vae2is, %0;" : : "r" (va>>PAGE_SHIFT) : "memory");
55 }
56 
57 #endif /* __ASM_ARM_ARM64_FLUSHTLB_H__ */
58 /*
59  * Local variables:
60  * mode: C
61  * c-file-style: "BSD"
62  * c-basic-offset: 4
63  * indent-tabs-mode: nil
64  * End:
65  */
66