Pull arm64 fix from Catalin Marinas: "Fix the TLBI RANGE operand calculation causing live migration under KVM/arm64 to miss dirty pages due to stale TLB entries" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: tlb: Fix TLBI RANGE operand
Unified · Split
| @@ -161,12 +161,18 @@ static inline unsigned long get_trans_granule(void) · 160 unmodified lines | |||
| 161 | #define MAX_TLBI_RANGE_PAGES __TLBI_RANGE_PAGES(31, 3) | 161 | #define MAX_TLBI_RANGE_PAGES __TLBI_RANGE_PAGES(31, 3) |
| 162 | 162 | ||
| 163 | /* | 163 | /* |
| 164 | * Generate 'num' values from -1 to 30 with -1 rejected by the | 164 | * Generate 'num' values from -1 to 31 with -1 rejected by the |
| 165 | * __flush_tlb_range() loop below. | 165 | * __flush_tlb_range() loop below. Its return value is only |
| 166 | * significant for a maximum of MAX_TLBI_RANGE_PAGES pages. If | ||
| 167 | * 'pages' is more than that, you must iterate over the overall | ||
| 168 | * range. | ||
| 166 | */ | 169 | */ |
| 167 | #define TLBI_RANGE_MASK GENMASK_ULL(4, 0) | 170 | #define __TLBI_RANGE_NUM(pages, scale) \ |
| 168 | #define __TLBI_RANGE_NUM(pages, scale) \ | 171 | ({ \ |
| 169 | ((((pages) >> (5 * (scale) + 1)) & TLBI_RANGE_MASK) - 1) | 172 | int __pages = min((pages), \ |
| 173 | __TLBI_RANGE_PAGES(31, (scale))); \ | ||
| 174 | (__pages >> (5 * (scale) + 1)) - 1; \ | ||
| 175 | }) | ||
| 170 | 176 | ||
| 171 | /* | 177 | /* |
| 172 | * TLB Invalidation | 178 | * TLB Invalidation |
| @@ -379,10 +385,6 @@ static inline void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch) · 206 unmodified lines | |||
| 379 | * 3. If there is 1 page remaining, flush it through non-range operations. Range | 385 | * 3. If there is 1 page remaining, flush it through non-range operations. Range |
| 380 | * operations can only span an even number of pages. We save this for last to | 386 | * operations can only span an even number of pages. We save this for last to |
| 381 | * ensure 64KB start alignment is maintained for the LPA2 case. | 387 | * ensure 64KB start alignment is maintained for the LPA2 case. |
| 382 | * | ||
| 383 | * Note that certain ranges can be represented by either num = 31 and | ||
| 384 | * scale or num = 0 and scale + 1. The loop below favours the latter | ||
| 385 | * since num is limited to 30 by the __TLBI_RANGE_NUM() macro. | ||
| 386 | */ | 388 | */ |
| 387 | #define __flush_tlb_range_op(op, start, pages, stride, \ | 389 | #define __flush_tlb_range_op(op, start, pages, stride, \ |
| 388 | asid, tlb_level, tlbi_user, lpa2) \ | 390 | asid, tlb_level, tlbi_user, lpa2) \ |