Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 1 | /* |
| 2 | * TLB flush routines for radix kernels. |
| 3 | * |
| 4 | * Copyright 2015-2016, Aneesh Kumar K.V, IBM Corporation. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/mm.h> |
| 13 | #include <linux/hugetlb.h> |
| 14 | #include <linux/memblock.h> |
| 15 | |
Benjamin Herrenschmidt | a25bd72 | 2017-07-24 14:26:06 +1000 | [diff] [blame] | 16 | #include <asm/ppc-opcode.h> |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 17 | #include <asm/tlb.h> |
| 18 | #include <asm/tlbflush.h> |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 19 | #include <asm/trace.h> |
Benjamin Herrenschmidt | a25bd72 | 2017-07-24 14:26:06 +1000 | [diff] [blame] | 20 | #include <asm/cputhreads.h> |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 21 | |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 22 | #define RIC_FLUSH_TLB 0 |
| 23 | #define RIC_FLUSH_PWC 1 |
| 24 | #define RIC_FLUSH_ALL 2 |
| 25 | |
| 26 | static inline void __tlbiel_pid(unsigned long pid, int set, |
| 27 | unsigned long ric) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 28 | { |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 29 | unsigned long rb,rs,prs,r; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 30 | |
| 31 | rb = PPC_BIT(53); /* IS = 1 */ |
| 32 | rb |= set << PPC_BITLSHIFT(51); |
| 33 | rs = ((unsigned long)pid) << PPC_BITLSHIFT(31); |
| 34 | prs = 1; /* process scoped */ |
| 35 | r = 1; /* raidx format */ |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 36 | |
Balbir Singh | 8cd6d3c | 2016-07-13 15:05:20 +0530 | [diff] [blame] | 37 | asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 38 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 39 | trace_tlbie(0, 1, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | /* |
| 43 | * We use 128 set in radix mode and 256 set in hpt mode. |
| 44 | */ |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 45 | static inline void _tlbiel_pid(unsigned long pid, unsigned long ric) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 46 | { |
| 47 | int set; |
| 48 | |
Aneesh Kumar K.V | f7327e0 | 2017-04-01 20:11:48 +0530 | [diff] [blame] | 49 | asm volatile("ptesync": : :"memory"); |
Aneesh Kumar K.V | a5998fc | 2017-04-26 21:38:17 +1000 | [diff] [blame] | 50 | |
| 51 | /* |
| 52 | * Flush the first set of the TLB, and if we're doing a RIC_FLUSH_ALL, |
| 53 | * also flush the entire Page Walk Cache. |
| 54 | */ |
| 55 | __tlbiel_pid(pid, 0, ric); |
| 56 | |
Benjamin Herrenschmidt | 5ce5fe1 | 2017-07-19 14:49:04 +1000 | [diff] [blame] | 57 | /* For PWC, only one flush is needed */ |
| 58 | if (ric == RIC_FLUSH_PWC) { |
| 59 | asm volatile("ptesync": : :"memory"); |
| 60 | return; |
| 61 | } |
Aneesh Kumar K.V | a5998fc | 2017-04-26 21:38:17 +1000 | [diff] [blame] | 62 | |
Benjamin Herrenschmidt | 5ce5fe1 | 2017-07-19 14:49:04 +1000 | [diff] [blame] | 63 | /* For the remaining sets, just flush the TLB */ |
Aneesh Kumar K.V | a5998fc | 2017-04-26 21:38:17 +1000 | [diff] [blame] | 64 | for (set = 1; set < POWER9_TLB_SETS_RADIX ; set++) |
Benjamin Herrenschmidt | 5ce5fe1 | 2017-07-19 14:49:04 +1000 | [diff] [blame] | 65 | __tlbiel_pid(pid, set, RIC_FLUSH_TLB); |
Aneesh Kumar K.V | a5998fc | 2017-04-26 21:38:17 +1000 | [diff] [blame] | 66 | |
Aneesh Kumar K.V | f7327e0 | 2017-04-01 20:11:48 +0530 | [diff] [blame] | 67 | asm volatile("ptesync": : :"memory"); |
Benjamin Herrenschmidt | 90c1e3c | 2017-02-06 13:05:16 +1100 | [diff] [blame] | 68 | asm volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory"); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 69 | } |
| 70 | |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 71 | static inline void _tlbie_pid(unsigned long pid, unsigned long ric) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 72 | { |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 73 | unsigned long rb,rs,prs,r; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 74 | |
| 75 | rb = PPC_BIT(53); /* IS = 1 */ |
| 76 | rs = pid << PPC_BITLSHIFT(31); |
| 77 | prs = 1; /* process scoped */ |
| 78 | r = 1; /* raidx format */ |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 79 | |
| 80 | asm volatile("ptesync": : :"memory"); |
Balbir Singh | 8cd6d3c | 2016-07-13 15:05:20 +0530 | [diff] [blame] | 81 | asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 82 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); |
| 83 | asm volatile("eieio; tlbsync; ptesync": : :"memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 84 | trace_tlbie(0, 0, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 85 | } |
| 86 | |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 87 | static inline void __tlbiel_va(unsigned long va, unsigned long pid, |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 88 | unsigned long ap, unsigned long ric) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 89 | { |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 90 | unsigned long rb,rs,prs,r; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 91 | |
| 92 | rb = va & ~(PPC_BITMASK(52, 63)); |
| 93 | rb |= ap << PPC_BITLSHIFT(58); |
| 94 | rs = pid << PPC_BITLSHIFT(31); |
| 95 | prs = 1; /* process scoped */ |
| 96 | r = 1; /* raidx format */ |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 97 | |
Balbir Singh | 8cd6d3c | 2016-07-13 15:05:20 +0530 | [diff] [blame] | 98 | asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 99 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 100 | trace_tlbie(0, 1, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 101 | } |
| 102 | |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 103 | static inline void _tlbiel_va(unsigned long va, unsigned long pid, |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 104 | unsigned long psize, unsigned long ric) |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 105 | { |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 106 | unsigned long ap = mmu_get_ap(psize); |
| 107 | |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 108 | asm volatile("ptesync": : :"memory"); |
| 109 | __tlbiel_va(va, pid, ap, ric); |
| 110 | asm volatile("ptesync": : :"memory"); |
| 111 | } |
| 112 | |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 113 | static inline void _tlbiel_va_range(unsigned long start, unsigned long end, |
| 114 | unsigned long pid, unsigned long page_size, |
| 115 | unsigned long psize) |
| 116 | { |
| 117 | unsigned long addr; |
| 118 | unsigned long ap = mmu_get_ap(psize); |
| 119 | |
| 120 | asm volatile("ptesync": : :"memory"); |
| 121 | for (addr = start; addr < end; addr += page_size) |
| 122 | __tlbiel_va(addr, pid, ap, RIC_FLUSH_TLB); |
| 123 | asm volatile("ptesync": : :"memory"); |
| 124 | } |
| 125 | |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 126 | static inline void __tlbie_va(unsigned long va, unsigned long pid, |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 127 | unsigned long ap, unsigned long ric) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 128 | { |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 129 | unsigned long rb,rs,prs,r; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 130 | |
| 131 | rb = va & ~(PPC_BITMASK(52, 63)); |
| 132 | rb |= ap << PPC_BITLSHIFT(58); |
| 133 | rs = pid << PPC_BITLSHIFT(31); |
| 134 | prs = 1; /* process scoped */ |
| 135 | r = 1; /* raidx format */ |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 136 | |
Balbir Singh | 8cd6d3c | 2016-07-13 15:05:20 +0530 | [diff] [blame] | 137 | asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 138 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 139 | trace_tlbie(0, 0, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 140 | } |
| 141 | |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 142 | static inline void _tlbie_va(unsigned long va, unsigned long pid, |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 143 | unsigned long psize, unsigned long ric) |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 144 | { |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 145 | unsigned long ap = mmu_get_ap(psize); |
| 146 | |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 147 | asm volatile("ptesync": : :"memory"); |
| 148 | __tlbie_va(va, pid, ap, ric); |
| 149 | asm volatile("eieio; tlbsync; ptesync": : :"memory"); |
| 150 | } |
| 151 | |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 152 | static inline void _tlbie_va_range(unsigned long start, unsigned long end, |
| 153 | unsigned long pid, unsigned long page_size, |
| 154 | unsigned long psize) |
| 155 | { |
| 156 | unsigned long addr; |
| 157 | unsigned long ap = mmu_get_ap(psize); |
| 158 | |
| 159 | asm volatile("ptesync": : :"memory"); |
| 160 | for (addr = start; addr < end; addr += page_size) |
| 161 | __tlbie_va(addr, pid, ap, RIC_FLUSH_TLB); |
| 162 | asm volatile("eieio; tlbsync; ptesync": : :"memory"); |
| 163 | } |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 164 | |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 165 | /* |
| 166 | * Base TLB flushing operations: |
| 167 | * |
| 168 | * - flush_tlb_mm(mm) flushes the specified mm context TLB's |
| 169 | * - flush_tlb_page(vma, vmaddr) flushes one page |
| 170 | * - flush_tlb_range(vma, start, end) flushes a range of pages |
| 171 | * - flush_tlb_kernel_range(start, end) flushes kernel pages |
| 172 | * |
| 173 | * - local_* variants of page and mm only apply to the current |
| 174 | * processor |
| 175 | */ |
| 176 | void radix__local_flush_tlb_mm(struct mm_struct *mm) |
| 177 | { |
Aneesh Kumar K.V | 9690c15 | 2016-06-02 15:14:48 +0530 | [diff] [blame] | 178 | unsigned long pid; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 179 | |
| 180 | preempt_disable(); |
| 181 | pid = mm->context.id; |
| 182 | if (pid != MMU_NO_CONTEXT) |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 183 | _tlbiel_pid(pid, RIC_FLUSH_TLB); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 184 | preempt_enable(); |
| 185 | } |
| 186 | EXPORT_SYMBOL(radix__local_flush_tlb_mm); |
| 187 | |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 188 | #ifndef CONFIG_SMP |
Frederic Barrat | 6110236 | 2017-09-03 20:15:12 +0200 | [diff] [blame] | 189 | void radix__local_flush_all_mm(struct mm_struct *mm) |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 190 | { |
| 191 | unsigned long pid; |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 192 | |
| 193 | preempt_disable(); |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 194 | pid = mm->context.id; |
| 195 | if (pid != MMU_NO_CONTEXT) |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 196 | _tlbiel_pid(pid, RIC_FLUSH_ALL); |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 197 | preempt_enable(); |
| 198 | } |
Frederic Barrat | 6110236 | 2017-09-03 20:15:12 +0200 | [diff] [blame] | 199 | EXPORT_SYMBOL(radix__local_flush_all_mm); |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 200 | #endif /* CONFIG_SMP */ |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 201 | |
Aneesh Kumar K.V | f22dfc9 | 2016-07-13 15:06:41 +0530 | [diff] [blame] | 202 | void radix__local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr, |
Aneesh Kumar K.V | fbfa26d | 2016-07-13 15:06:42 +0530 | [diff] [blame] | 203 | int psize) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 204 | { |
Aneesh Kumar K.V | 9690c15 | 2016-06-02 15:14:48 +0530 | [diff] [blame] | 205 | unsigned long pid; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 206 | |
| 207 | preempt_disable(); |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 208 | pid = mm->context.id; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 209 | if (pid != MMU_NO_CONTEXT) |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 210 | _tlbiel_va(vmaddr, pid, psize, RIC_FLUSH_TLB); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 211 | preempt_enable(); |
| 212 | } |
| 213 | |
| 214 | void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr) |
| 215 | { |
Aneesh Kumar K.V | 4848376 | 2016-04-29 23:26:25 +1000 | [diff] [blame] | 216 | #ifdef CONFIG_HUGETLB_PAGE |
| 217 | /* need the return fix for nohash.c */ |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 218 | if (is_vm_hugetlb_page(vma)) |
| 219 | return radix__local_flush_hugetlb_page(vma, vmaddr); |
Aneesh Kumar K.V | 4848376 | 2016-04-29 23:26:25 +1000 | [diff] [blame] | 220 | #endif |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 221 | radix__local_flush_tlb_page_psize(vma->vm_mm, vmaddr, mmu_virtual_psize); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 222 | } |
| 223 | EXPORT_SYMBOL(radix__local_flush_tlb_page); |
| 224 | |
| 225 | #ifdef CONFIG_SMP |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 226 | void radix__flush_tlb_mm(struct mm_struct *mm) |
| 227 | { |
Aneesh Kumar K.V | 9690c15 | 2016-06-02 15:14:48 +0530 | [diff] [blame] | 228 | unsigned long pid; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 229 | |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 230 | pid = mm->context.id; |
| 231 | if (unlikely(pid == MMU_NO_CONTEXT)) |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 232 | return; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 233 | |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 234 | preempt_disable(); |
Michael Ellerman | 3c9ac2b | 2017-05-02 21:00:14 +1000 | [diff] [blame] | 235 | if (!mm_is_thread_local(mm)) |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 236 | _tlbie_pid(pid, RIC_FLUSH_TLB); |
| 237 | else |
| 238 | _tlbiel_pid(pid, RIC_FLUSH_TLB); |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 239 | preempt_enable(); |
| 240 | } |
| 241 | EXPORT_SYMBOL(radix__flush_tlb_mm); |
| 242 | |
Frederic Barrat | 6110236 | 2017-09-03 20:15:12 +0200 | [diff] [blame] | 243 | void radix__flush_all_mm(struct mm_struct *mm) |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 244 | { |
| 245 | unsigned long pid; |
| 246 | |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 247 | pid = mm->context.id; |
| 248 | if (unlikely(pid == MMU_NO_CONTEXT)) |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 249 | return; |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 250 | |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 251 | preempt_disable(); |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 252 | if (!mm_is_thread_local(mm)) |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 253 | _tlbie_pid(pid, RIC_FLUSH_ALL); |
Michael Ellerman | 3c9ac2b | 2017-05-02 21:00:14 +1000 | [diff] [blame] | 254 | else |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 255 | _tlbiel_pid(pid, RIC_FLUSH_ALL); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 256 | preempt_enable(); |
| 257 | } |
Frederic Barrat | 6110236 | 2017-09-03 20:15:12 +0200 | [diff] [blame] | 258 | EXPORT_SYMBOL(radix__flush_all_mm); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 259 | |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 260 | void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr) |
| 261 | { |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 262 | tlb->need_flush_all = 1; |
Aneesh Kumar K.V | a145abf | 2016-06-08 19:55:51 +0530 | [diff] [blame] | 263 | } |
| 264 | EXPORT_SYMBOL(radix__flush_tlb_pwc); |
| 265 | |
Aneesh Kumar K.V | f22dfc9 | 2016-07-13 15:06:41 +0530 | [diff] [blame] | 266 | void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr, |
Aneesh Kumar K.V | fbfa26d | 2016-07-13 15:06:42 +0530 | [diff] [blame] | 267 | int psize) |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 268 | { |
Aneesh Kumar K.V | 9690c15 | 2016-06-02 15:14:48 +0530 | [diff] [blame] | 269 | unsigned long pid; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 270 | |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 271 | pid = mm->context.id; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 272 | if (unlikely(pid == MMU_NO_CONTEXT)) |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 273 | return; |
| 274 | |
| 275 | preempt_disable(); |
Michael Ellerman | 3c9ac2b | 2017-05-02 21:00:14 +1000 | [diff] [blame] | 276 | if (!mm_is_thread_local(mm)) |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 277 | _tlbie_va(vmaddr, pid, psize, RIC_FLUSH_TLB); |
Michael Ellerman | 3c9ac2b | 2017-05-02 21:00:14 +1000 | [diff] [blame] | 278 | else |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 279 | _tlbiel_va(vmaddr, pid, psize, RIC_FLUSH_TLB); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 280 | preempt_enable(); |
| 281 | } |
| 282 | |
| 283 | void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr) |
| 284 | { |
Aneesh Kumar K.V | 4848376 | 2016-04-29 23:26:25 +1000 | [diff] [blame] | 285 | #ifdef CONFIG_HUGETLB_PAGE |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 286 | if (is_vm_hugetlb_page(vma)) |
| 287 | return radix__flush_hugetlb_page(vma, vmaddr); |
Aneesh Kumar K.V | 4848376 | 2016-04-29 23:26:25 +1000 | [diff] [blame] | 288 | #endif |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 289 | radix__flush_tlb_page_psize(vma->vm_mm, vmaddr, mmu_virtual_psize); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 290 | } |
| 291 | EXPORT_SYMBOL(radix__flush_tlb_page); |
| 292 | |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 293 | #else /* CONFIG_SMP */ |
| 294 | #define radix__flush_all_mm radix__local_flush_all_mm |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 295 | #endif /* CONFIG_SMP */ |
| 296 | |
| 297 | void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end) |
| 298 | { |
Aneesh Kumar K.V | 3619481 | 2016-06-08 19:55:50 +0530 | [diff] [blame] | 299 | _tlbie_pid(0, RIC_FLUSH_ALL); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 300 | } |
| 301 | EXPORT_SYMBOL(radix__flush_tlb_kernel_range); |
| 302 | |
| 303 | /* |
| 304 | * Currently, for range flushing, we just do a full mm flush. Because |
| 305 | * we use this in code path where we don' track the page size. |
| 306 | */ |
| 307 | void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, |
| 308 | unsigned long end) |
| 309 | |
| 310 | { |
| 311 | struct mm_struct *mm = vma->vm_mm; |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 312 | |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 313 | radix__flush_tlb_mm(mm); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 314 | } |
| 315 | EXPORT_SYMBOL(radix__flush_tlb_range); |
| 316 | |
Aneesh Kumar K.V | 912cc87 | 2016-07-13 15:05:29 +0530 | [diff] [blame] | 317 | static int radix_get_mmu_psize(int page_size) |
| 318 | { |
| 319 | int psize; |
| 320 | |
| 321 | if (page_size == (1UL << mmu_psize_defs[mmu_virtual_psize].shift)) |
| 322 | psize = mmu_virtual_psize; |
| 323 | else if (page_size == (1UL << mmu_psize_defs[MMU_PAGE_2M].shift)) |
| 324 | psize = MMU_PAGE_2M; |
| 325 | else if (page_size == (1UL << mmu_psize_defs[MMU_PAGE_1G].shift)) |
| 326 | psize = MMU_PAGE_1G; |
| 327 | else |
| 328 | return -1; |
| 329 | return psize; |
| 330 | } |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 331 | |
| 332 | void radix__tlb_flush(struct mmu_gather *tlb) |
| 333 | { |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 334 | int psize = 0; |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 335 | struct mm_struct *mm = tlb->mm; |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 336 | int page_size = tlb->page_size; |
| 337 | |
| 338 | psize = radix_get_mmu_psize(page_size); |
| 339 | /* |
| 340 | * if page size is not something we understand, do a full mm flush |
Nicholas Piggin | 30b49ec | 2017-10-24 23:06:54 +1000 | [diff] [blame] | 341 | * |
| 342 | * A "fullmm" flush must always do a flush_all_mm (RIC=2) flush |
| 343 | * that flushes the process table entry cache upon process teardown. |
| 344 | * See the comment for radix in arch_exit_mmap(). |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 345 | */ |
| 346 | if (psize != -1 && !tlb->fullmm && !tlb->need_flush_all) |
| 347 | radix__flush_tlb_range_psize(mm, tlb->start, tlb->end, psize); |
Nicholas Piggin | 30b49ec | 2017-10-24 23:06:54 +1000 | [diff] [blame] | 348 | else if (tlb->fullmm || tlb->need_flush_all) { |
Benjamin Herrenschmidt | a46cc7a | 2017-07-19 14:49:05 +1000 | [diff] [blame] | 349 | tlb->need_flush_all = 0; |
| 350 | radix__flush_all_mm(mm); |
| 351 | } else |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 352 | radix__flush_tlb_mm(mm); |
| 353 | } |
| 354 | |
| 355 | #define TLB_FLUSH_ALL -1UL |
| 356 | /* |
| 357 | * Number of pages above which we will do a bcast tlbie. Just a |
| 358 | * number at this point copied from x86 |
| 359 | */ |
| 360 | static unsigned long tlb_single_page_flush_ceiling __read_mostly = 33; |
| 361 | |
| 362 | void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start, |
| 363 | unsigned long end, int psize) |
| 364 | { |
| 365 | unsigned long pid; |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 366 | bool local; |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 367 | unsigned long page_size = 1UL << mmu_psize_defs[psize].shift; |
| 368 | |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 369 | pid = mm->context.id; |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 370 | if (unlikely(pid == MMU_NO_CONTEXT)) |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 371 | return; |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 372 | |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 373 | preempt_disable(); |
| 374 | local = mm_is_thread_local(mm); |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 375 | if (end == TLB_FLUSH_ALL || |
| 376 | (end - start) > tlb_single_page_flush_ceiling * page_size) { |
| 377 | if (local) |
| 378 | _tlbiel_pid(pid, RIC_FLUSH_TLB); |
| 379 | else |
| 380 | _tlbie_pid(pid, RIC_FLUSH_TLB); |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 381 | } else { |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 382 | if (local) |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 383 | _tlbiel_va_range(start, end, pid, page_size, psize); |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 384 | else |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 385 | _tlbie_va_range(start, end, pid, page_size, psize); |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 386 | } |
Aneesh Kumar K.V | 8cb8140 | 2016-07-13 15:06:35 +0530 | [diff] [blame] | 387 | preempt_enable(); |
Aneesh Kumar K.V | 1a472c9 | 2016-04-29 23:26:05 +1000 | [diff] [blame] | 388 | } |
Aneesh Kumar K.V | 912cc87 | 2016-07-13 15:05:29 +0530 | [diff] [blame] | 389 | |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 390 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
| 391 | void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr) |
| 392 | { |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 393 | unsigned long pid, end; |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 394 | bool local; |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 395 | |
Michael Ellerman | 6773027 | 2017-10-16 12:41:00 +0530 | [diff] [blame] | 396 | pid = mm->context.id; |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 397 | if (unlikely(pid == MMU_NO_CONTEXT)) |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 398 | return; |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 399 | |
| 400 | /* 4k page size, just blow the world */ |
| 401 | if (PAGE_SIZE == 0x1000) { |
| 402 | radix__flush_all_mm(mm); |
| 403 | return; |
| 404 | } |
| 405 | |
Nicholas Piggin | dffe844 | 2017-10-24 23:06:53 +1000 | [diff] [blame] | 406 | preempt_disable(); |
| 407 | local = mm_is_thread_local(mm); |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 408 | /* Otherwise first do the PWC */ |
| 409 | if (local) |
| 410 | _tlbiel_pid(pid, RIC_FLUSH_PWC); |
| 411 | else |
| 412 | _tlbie_pid(pid, RIC_FLUSH_PWC); |
| 413 | |
| 414 | /* Then iterate the pages */ |
| 415 | end = addr + HPAGE_PMD_SIZE; |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 416 | if (local) |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 417 | _tlbiel_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize); |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 418 | else |
Nicholas Piggin | d665767 | 2017-11-07 18:53:06 +1100 | [diff] [blame^] | 419 | _tlbie_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize); |
Nicholas Piggin | 14001c6 | 2017-11-07 18:53:05 +1100 | [diff] [blame] | 420 | |
Benjamin Herrenschmidt | 424de9c | 2017-07-19 14:49:06 +1000 | [diff] [blame] | 421 | preempt_enable(); |
| 422 | } |
| 423 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |
| 424 | |
Aneesh Kumar K.V | 912cc87 | 2016-07-13 15:05:29 +0530 | [diff] [blame] | 425 | void radix__flush_tlb_lpid_va(unsigned long lpid, unsigned long gpa, |
| 426 | unsigned long page_size) |
| 427 | { |
| 428 | unsigned long rb,rs,prs,r; |
| 429 | unsigned long ap; |
| 430 | unsigned long ric = RIC_FLUSH_TLB; |
| 431 | |
| 432 | ap = mmu_get_ap(radix_get_mmu_psize(page_size)); |
| 433 | rb = gpa & ~(PPC_BITMASK(52, 63)); |
| 434 | rb |= ap << PPC_BITLSHIFT(58); |
| 435 | rs = lpid & ((1UL << 32) - 1); |
| 436 | prs = 0; /* process scoped */ |
| 437 | r = 1; /* raidx format */ |
| 438 | |
| 439 | asm volatile("ptesync": : :"memory"); |
| 440 | asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) |
| 441 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); |
| 442 | asm volatile("eieio; tlbsync; ptesync": : :"memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 443 | trace_tlbie(lpid, 0, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | 912cc87 | 2016-07-13 15:05:29 +0530 | [diff] [blame] | 444 | } |
| 445 | EXPORT_SYMBOL(radix__flush_tlb_lpid_va); |
| 446 | |
| 447 | void radix__flush_tlb_lpid(unsigned long lpid) |
| 448 | { |
| 449 | unsigned long rb,rs,prs,r; |
| 450 | unsigned long ric = RIC_FLUSH_ALL; |
| 451 | |
| 452 | rb = 0x2 << PPC_BITLSHIFT(53); /* IS = 2 */ |
| 453 | rs = lpid & ((1UL << 32) - 1); |
| 454 | prs = 0; /* partition scoped */ |
| 455 | r = 1; /* raidx format */ |
| 456 | |
| 457 | asm volatile("ptesync": : :"memory"); |
| 458 | asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) |
| 459 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); |
| 460 | asm volatile("eieio; tlbsync; ptesync": : :"memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 461 | trace_tlbie(lpid, 0, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | 912cc87 | 2016-07-13 15:05:29 +0530 | [diff] [blame] | 462 | } |
| 463 | EXPORT_SYMBOL(radix__flush_tlb_lpid); |
Aneesh Kumar K.V | d8e91e9 | 2016-07-13 15:06:40 +0530 | [diff] [blame] | 464 | |
| 465 | void radix__flush_pmd_tlb_range(struct vm_area_struct *vma, |
| 466 | unsigned long start, unsigned long end) |
| 467 | { |
| 468 | radix__flush_tlb_range_psize(vma->vm_mm, start, end, MMU_PAGE_2M); |
| 469 | } |
| 470 | EXPORT_SYMBOL(radix__flush_pmd_tlb_range); |
Aneesh Kumar K.V | be34d30 | 2016-08-23 16:27:48 +0530 | [diff] [blame] | 471 | |
| 472 | void radix__flush_tlb_all(void) |
| 473 | { |
| 474 | unsigned long rb,prs,r,rs; |
| 475 | unsigned long ric = RIC_FLUSH_ALL; |
| 476 | |
| 477 | rb = 0x3 << PPC_BITLSHIFT(53); /* IS = 3 */ |
| 478 | prs = 0; /* partition scoped */ |
| 479 | r = 1; /* raidx format */ |
| 480 | rs = 1 & ((1UL << 32) - 1); /* any LPID value to flush guest mappings */ |
| 481 | |
| 482 | asm volatile("ptesync": : :"memory"); |
| 483 | /* |
| 484 | * now flush guest entries by passing PRS = 1 and LPID != 0 |
| 485 | */ |
| 486 | asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) |
| 487 | : : "r"(rb), "i"(r), "i"(1), "i"(ric), "r"(rs) : "memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 488 | trace_tlbie(0, 0, rb, rs, ric, prs, r); |
Aneesh Kumar K.V | be34d30 | 2016-08-23 16:27:48 +0530 | [diff] [blame] | 489 | /* |
| 490 | * now flush host entires by passing PRS = 0 and LPID == 0 |
| 491 | */ |
| 492 | asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1) |
| 493 | : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(0) : "memory"); |
| 494 | asm volatile("eieio; tlbsync; ptesync": : :"memory"); |
Balbir Singh | 0428491 | 2017-04-11 15:23:25 +1000 | [diff] [blame] | 495 | trace_tlbie(0, 0, rb, 0, ric, prs, r); |
Aneesh Kumar K.V | be34d30 | 2016-08-23 16:27:48 +0530 | [diff] [blame] | 496 | } |
Aneesh Kumar K.V | 6d3a037 | 2016-11-28 11:47:01 +0530 | [diff] [blame] | 497 | |
| 498 | void radix__flush_tlb_pte_p9_dd1(unsigned long old_pte, struct mm_struct *mm, |
| 499 | unsigned long address) |
| 500 | { |
| 501 | /* |
| 502 | * We track page size in pte only for DD1, So we can |
| 503 | * call this only on DD1. |
| 504 | */ |
| 505 | if (!cpu_has_feature(CPU_FTR_POWER9_DD1)) { |
| 506 | VM_WARN_ON(1); |
| 507 | return; |
| 508 | } |
| 509 | |
Aneesh Kumar K.V | ddb014b | 2017-03-21 22:59:54 +0530 | [diff] [blame] | 510 | if (old_pte & R_PAGE_LARGE) |
Aneesh Kumar K.V | 6d3a037 | 2016-11-28 11:47:01 +0530 | [diff] [blame] | 511 | radix__flush_tlb_page_psize(mm, address, MMU_PAGE_2M); |
| 512 | else |
| 513 | radix__flush_tlb_page_psize(mm, address, mmu_virtual_psize); |
| 514 | } |
Benjamin Herrenschmidt | a25bd72 | 2017-07-24 14:26:06 +1000 | [diff] [blame] | 515 | |
| 516 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
| 517 | extern void radix_kvm_prefetch_workaround(struct mm_struct *mm) |
| 518 | { |
| 519 | unsigned int pid = mm->context.id; |
| 520 | |
| 521 | if (unlikely(pid == MMU_NO_CONTEXT)) |
| 522 | return; |
| 523 | |
| 524 | /* |
| 525 | * If this context hasn't run on that CPU before and KVM is |
| 526 | * around, there's a slim chance that the guest on another |
| 527 | * CPU just brought in obsolete translation into the TLB of |
| 528 | * this CPU due to a bad prefetch using the guest PID on |
| 529 | * the way into the hypervisor. |
| 530 | * |
| 531 | * We work around this here. If KVM is possible, we check if |
| 532 | * any sibling thread is in KVM. If it is, the window may exist |
| 533 | * and thus we flush that PID from the core. |
| 534 | * |
| 535 | * A potential future improvement would be to mark which PIDs |
| 536 | * have never been used on the system and avoid it if the PID |
| 537 | * is new and the process has no other cpumask bit set. |
| 538 | */ |
| 539 | if (cpu_has_feature(CPU_FTR_HVMODE) && radix_enabled()) { |
| 540 | int cpu = smp_processor_id(); |
| 541 | int sib = cpu_first_thread_sibling(cpu); |
| 542 | bool flush = false; |
| 543 | |
| 544 | for (; sib <= cpu_last_thread_sibling(cpu) && !flush; sib++) { |
| 545 | if (sib == cpu) |
| 546 | continue; |
| 547 | if (paca[sib].kvm_hstate.kvm_vcpu) |
| 548 | flush = true; |
| 549 | } |
| 550 | if (flush) |
| 551 | _tlbiel_pid(pid, RIC_FLUSH_ALL); |
| 552 | } |
| 553 | } |
| 554 | EXPORT_SYMBOL_GPL(radix_kvm_prefetch_workaround); |
| 555 | #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ |