ARM: 7487/1: mm: avoid setting nG bit for user mappings that aren't present
authorWill Deacon <will.deacon@arm.com>
Fri, 10 Aug 2012 16:51:18 +0000 (17:51 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Sep 2012 14:05:01 +0000 (15:05 +0100)
commited756add374b0742f00fae8ff74db2e0186c0c70
tree4c022ccd0be2a394f9875e05e775d856dec634bc
parent2543c104ef7f41d32e7f985a826f04d0d98e295d
ARM: 7487/1: mm: avoid setting nG bit for user mappings that aren't present

commit 47f1204329237a0f8655f5a9f14a38ac81946ca1 upstream.

Swap entries are encoding in ptes such that !pte_present(pte) and
pte_file(pte). The remaining bits of the descriptor are used to identify
the swapfile and offset within it to the swap entry.

When writing such a pte for a user virtual address, set_pte_at
unconditionally sets the nG bit, which (in the case of LPAE) will
corrupt the swapfile offset and lead to a BUG:

[  140.494067] swap_free: Unused swap offset entry 000763b4
[  140.509989] BUG: Bad page map in process rs:main Q:Reg  pte:0ec76800 pmd:8f92e003

This patch fixes the problem by only setting the nG bit for user
mappings that are actually present.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/arm/include/asm/pgtable.h
arch/arm/mm/flush.c