History

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

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

Linus Torvalds committed 2 years ago

Commit 8f2c0572 parents 678e14c e3ba51a1 file · +11 −9Browse files

Unified · Split

arch/arm64/include/asm/tlbflush.h+11−9
@@ -161,12 +161,18 @@ static inline unsigned long get_trans_granule(void) · 160 unmodified lines
161161 #define MAX_TLBI_RANGE_PAGES __TLBI_RANGE_PAGES(31, 3)
162162
163163 /*
164− * Generate 'num' values from -1 to 30 with -1 rejected by the
165− * __flush_tlb_range() loop below.
164+ * Generate 'num' values from -1 to 31 with -1 rejected by the
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.
166169 */
167−#define TLBI_RANGE_MASK GENMASK_ULL(4, 0)
168−#define __TLBI_RANGE_NUM(pages, scale) \
169− ((((pages) >> (5 * (scale) + 1)) & TLBI_RANGE_MASK) - 1)
170+#define __TLBI_RANGE_NUM(pages, scale) \
171+ ({ \
172+ int __pages = min((pages), \
173+ __TLBI_RANGE_PAGES(31, (scale))); \
174+ (__pages >> (5 * (scale) + 1)) - 1; \
175+ })
170176
171177 /*
172178 * TLB Invalidation
@@ -379,10 +385,6 @@ static inline void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch) · 206 unmodified lines
379385 * 3. If there is 1 page remaining, flush it through non-range operations. Range
380386 * operations can only span an even number of pages. We save this for last to
381387 * 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.
386388 */
387389 #define __flush_tlb_range_op(op, start, pages, stride, \
388390 asid, tlb_level, tlbi_user, lpa2) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t