@@ -163,119 +163,32 @@ static ALWAYS_INLINE void xtensa_itlb_entry_write_sync(uint32_t pte, uint32_t en
163
163
}
164
164
165
165
/**
166
- * @brief Invalidate all ITLB entries.
166
+ * @brief Invalidate all autorefill DTLB and ITLB entries.
167
167
*
168
- * This should be used carefully since all entries in the instruction TLB
169
- * will be erased and the only way to find lookup a physical address will be
170
- * through the page tables.
171
- */
172
- static inline void xtensa_itlb_invalidate_sync (void )
173
- {
174
- uint8_t way , i ;
175
-
176
- for (way = 0 ; way < Z_XTENSA_ITLB_WAYS ; way ++ ) {
177
- for (i = 0 ; i < (1 << XCHAL_ITLB_ARF_ENTRIES_LOG2 ); i ++ ) {
178
- uint32_t entry = way + (i << Z_XTENSA_PPN_SHIFT );
179
-
180
- xtensa_itlb_entry_invalidate (entry );
181
- }
182
- }
183
- __asm__ volatile ("isync" );
184
- }
185
-
186
- /**
187
- * @brief Invalidate all DTLB entries.
168
+ * This should be used carefully since all refill entries in the data
169
+ * and instruction TLB. At least two pages, the current code page and
170
+ * the current stack, will be repopulated by this code as it returns.
188
171
*
189
- * This should be used carefully since all entries in the data TLB will be
190
- * erased and the only way to find lookup a physical address will be through
191
- * the page tables .
172
+ * This needs to be called in any circumstance where the mappings for
173
+ * a previously-used page table change. It does not need to be called
174
+ * on context switch, where ASID tagging isolates entries for us .
192
175
*/
193
- static inline void xtensa_dtlb_invalidate_sync (void )
176
+ static inline void xtensa_tlb_autorefill_invalidate (void )
194
177
{
195
- uint8_t way , i ;
196
-
197
- for (way = 0 ; way < Z_XTENSA_DTLB_WAYS ; way ++ ) {
198
- for (i = 0 ; i < (1 << XCHAL_DTLB_ARF_ENTRIES_LOG2 ); i ++ ) {
199
- uint32_t entry = way + (i << Z_XTENSA_PPN_SHIFT );
200
-
201
- xtensa_dtlb_entry_invalidate (entry );
202
- }
203
- }
204
- __asm__ volatile ("isync" );
205
- }
178
+ uint8_t way , i , entries ;
206
179
207
- /**
208
- * @brief Invalidates an autorefill DTLB entry.
209
- *
210
- * Invalidates the page table enrty that maps a given virtual address.
211
- */
212
- static inline void xtensa_dtlb_autorefill_invalidate_sync (void * vaddr )
213
- {
214
- uint8_t way ;
180
+ entries = BIT (MAX (XCHAL_ITLB_ARF_ENTRIES_LOG2 ,
181
+ XCHAL_DTLB_ARF_ENTRIES_LOG2 ));
215
182
216
183
for (way = 0 ; way < Z_XTENSA_TLB_AUTOREFILL_WAYS ; way ++ ) {
217
- xtensa_dtlb_entry_invalidate (Z_XTENSA_TLB_ENTRY ((uint32_t )vaddr , way ));
218
- }
219
- __asm__ volatile ("dsync" );
220
- }
221
-
222
- /**
223
- * @brief Invalidates an autorefill ITLB entry.
224
- *
225
- * Invalidates the page table enrty that maps a given virtual address.
226
- */
227
- static inline void xtensa_itlb_autorefill_invalidate_sync (void * vaddr )
228
- {
229
- uint8_t way ;
230
-
231
- for (way = 0 ; way < Z_XTENSA_TLB_AUTOREFILL_WAYS ; way ++ ) {
232
- xtensa_itlb_entry_invalidate (Z_XTENSA_TLB_ENTRY ((uint32_t )vaddr , way ));
233
- }
234
- __asm__ volatile ("isync" );
235
- }
236
- /**
237
- * @brief Invalidate all autorefill ITLB entries.
238
- *
239
- * This should be used carefully since all entries in the instruction TLB
240
- * will be erased and the only way to find lookup a physical address will be
241
- * through the page tables.
242
- */
243
- static inline void xtensa_itlb_autorefill_invalidate_all_sync (void )
244
- {
245
- uint8_t way , i ;
246
-
247
- for (way = 0 ; way < Z_XTENSA_TLB_AUTOREFILL_WAYS ; way ++ ) {
248
- for (i = 0 ; i < (1 << XCHAL_ITLB_ARF_ENTRIES_LOG2 ); i ++ ) {
184
+ for (i = 0 ; i < entries ; i ++ ) {
249
185
uint32_t entry = way + (i << Z_XTENSA_PPN_SHIFT );
250
-
251
- xtensa_itlb_entry_invalidate (entry );
186
+ xtensa_dtlb_entry_invalidate_sync ( entry );
187
+ xtensa_itlb_entry_invalidate_sync (entry );
252
188
}
253
189
}
254
- __asm__ volatile ("isync" );
255
190
}
256
191
257
- /**
258
- * @brief Invalidate all autorefill DTLB entries.
259
- *
260
- * This should be used carefully since all entries in the data TLB will be
261
- * erased and the only way to find lookup a physical address will be through
262
- * the page tables.
263
- */
264
- static inline void xtensa_dtlb_autorefill_invalidate_all_sync (void )
265
- {
266
- uint8_t way , i ;
267
-
268
- for (way = 0 ; way < Z_XTENSA_TLB_AUTOREFILL_WAYS ; way ++ ) {
269
- for (i = 0 ; i < (1 << XCHAL_DTLB_ARF_ENTRIES_LOG2 ); i ++ ) {
270
- uint32_t entry = way + (i << Z_XTENSA_PPN_SHIFT );
271
-
272
- xtensa_dtlb_entry_invalidate (entry );
273
- }
274
- }
275
- __asm__ volatile ("isync" );
276
- }
277
-
278
-
279
192
/**
280
193
* @brief Set the page tables.
281
194
*
0 commit comments