linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] arm64: mm: detect bad __create_mapping uses
@ 2015-11-20 15:35 Mark Rutland
  2015-11-20 15:35 ` [PATCH 2/2] arm64: mm: allow sections for unaligned bases Mark Rutland
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mark Rutland @ 2015-11-20 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

If a caller of __create_mapping provides a PA and VA which have
different sub-page offsets, it is not clear which offset they expect to
apply to the mapping, and is indicative of a bad caller.

Disallow calls with differing sub-page offsets, and WARN when they are
encountered, so that we can detect and fix such cases.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <caralin.marinas@arm.com>
Cc: Laura Abbott <labbott@fedoraproject.org>
Cc: Steve Capper <steve.capper@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/mm/mmu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index e3f563c..3b06afa 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -300,6 +300,13 @@ static void  __create_mapping(struct mm_struct *mm, pgd_t *pgd,
 {
 	unsigned long addr, length, end, next;
 
+	/*
+	 * If the virtual and physical address don't have the same offset
+	 * within a page, we cannot map the region as the caller expects.
+	 */
+	if (WARN_ON((phys ^ virt) & ~PAGE_MASK))
+		return;
+
 	addr = virt & PAGE_MASK;
 	length = PAGE_ALIGN(size + (virt & ~PAGE_MASK));
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-11-23 12:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-20 15:35 [PATCH 1/2] arm64: mm: detect bad __create_mapping uses Mark Rutland
2015-11-20 15:35 ` [PATCH 2/2] arm64: mm: allow sections for unaligned bases Mark Rutland
2015-11-23  8:43   ` Ard Biesheuvel
2015-11-20 15:48 ` [PATCH 1/2] arm64: mm: detect bad __create_mapping uses Mark Rutland
2015-11-20 16:13 ` Steve Capper
2015-11-20 17:05   ` Mark Rutland
2015-11-23 11:01     ` Steve Capper
2015-11-23 11:21       ` Mark Rutland
2015-11-23 12:16         ` Steve Capper
2015-11-23  8:40 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).