zap_pte_range: update addr when forcing flush after TLB batching faiure
authorWill Deacon <will.deacon@arm.com>
Tue, 28 Oct 2014 20:16:28 +0000 (13:16 -0700)
committerZefan Li <lizefan@huawei.com>
Mon, 2 Feb 2015 09:05:06 +0000 (17:05 +0800)
commit00d495a36788a4ad50295a93fafa82905f8f7aef
tree527a79f45b29db84918529acf233025c95789f9c
parentd309bea3dc968c2bb976abcd16c86f05107daa38
zap_pte_range: update addr when forcing flush after TLB batching faiure

commit ce9ec37bddb633404a0c23e1acb181a264e7f7f2 upstream.

When unmapping a range of pages in zap_pte_range, the page being
unmapped is added to an mmu_gather_batch structure for asynchronous
freeing. If we run out of space in the batch structure before the range
has been completely unmapped, then we break out of the loop, force a
TLB flush and free the pages that we have batched so far. If there are
further pages to unmap, then we resume the loop where we left off.

Unfortunately, we forget to update addr when we break out of the loop,
which causes us to truncate the range being invalidated as the end
address is exclusive. When we re-enter the loop at the same address, the
page has already been freed and the pte_present test will fail, meaning
that we do not reconsider the address for invalidation.

This patch fixes the problem by incrementing addr by the PAGE_SIZE
before breaking out of the loop on batch failure.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
mm/memory.c