linux-stable/arch/arm64/mm
Mark Rutland 621619f626 arm64: mm: fix VA-range sanity check
[ Upstream commit ab9b400809 ]

Both create_mapping_noalloc() and update_mapping_prot() sanity-check
their 'virt' parameter, but the check itself doesn't make much sense.
The condition used today appears to be a historical accident.

The sanity-check condition:

	if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
		[ ... warning here ... ]
		return;
	}

... can only be true for the KASAN shadow region or the module region,
and there's no reason to exclude these specifically for creating and
updateing mappings.

When arm64 support was first upstreamed in commit:

  c1cc155261 ("arm64: MMU initialisation")

... the condition was:

	if (virt < VMALLOC_START) {
		[ ... warning here ... ]
		return;
	}

At the time, VMALLOC_START was the lowest kernel address, and this was
checking whether 'virt' would be translated via TTBR1.

Subsequently in commit:

  14c127c957 ("arm64: mm: Flip kernel VA space")

... the condition was changed to:

	if ((virt >= VA_START) && (virt < VMALLOC_START)) {
		[ ... warning here ... ]
		return;
	}

This appear to have been a thinko. The commit moved the linear map to
the bottom of the kernel address space, with VMALLOC_START being at the
halfway point. The old condition would warn for changes to the linear
map below this, and at the time VA_START was the end of the linear map.

Subsequently we cleaned up the naming of VA_START in commit:

  77ad4ce693 ("arm64: memory: rename VA_START to PAGE_END")

... keeping the erroneous condition as:

	if ((virt >= PAGE_END) && (virt < VMALLOC_START)) {
		[ ... warning here ... ]
		return;
	}

Correct the condition to check against the start of the TTBR1 address
space, which is currently PAGE_OFFSET. This simplifies the logic, and
more clearly matches the "outside kernel range" message in the warning.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Steve Capper <steve.capper@arm.com>
Cc: Will Deacon <will@kernel.org>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20230615102628.1052103-1-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-01 13:21:55 +01:00
..
cache.S arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer 2022-06-25 15:18:40 +02:00
context.c arm64: mm: Use better bitmap_zalloc() 2021-06-01 18:52:05 +01:00
copypage.c arm64: Also reset KASAN tag if page is not PG_mte_tagged 2023-05-30 13:55:29 +01:00
dma-mapping.c iommu/dma: Pass address limit rather than size to iommu_setup_dma_ops() 2021-06-25 15:02:43 +02:00
extable.c arm64/bpf: Remove 128MB limit for BPF JIT programs 2022-01-29 10:58:25 +01:00
fault.c arm64/mm: mark private VM_FAULT_X defines as vm_fault_t 2023-06-09 10:32:25 +02:00
flush.c arm64: Rename arm64-internal cache maintenance functions 2021-05-25 19:27:49 +01:00
hugetlbpage.c arm64/hugetlb: fix CMA gigantic page order for non-4K PAGE_SIZE 2021-10-11 18:45:19 +01:00
init.c arm64/mm: drop HAVE_ARCH_PFN_VALID 2022-04-27 14:38:50 +02:00
ioremap.c arm[64]/memremap: don't abuse pfn_valid() to ensure presence of linear map 2022-05-18 10:26:56 +02:00
kasan_init.c Merge branches 'for-next/misc', 'for-next/kselftest', 'for-next/xntable', 'for-next/vdso', 'for-next/fiq', 'for-next/epan', 'for-next/kasan-vmalloc', 'for-next/fgt-boot-init', 'for-next/vhe-only' and 'for-next/neon-softirqs-disabled', remote-tracking branch 'arm64/for-next/perf' into for-next/core 2021-04-15 14:00:38 +01:00
Makefile RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
mmap.c arm64: Ensure execute-only permissions are not allowed without EPAN 2022-03-16 14:23:43 +01:00
mmu.c arm64: mm: fix VA-range sanity check 2024-03-01 13:21:55 +01:00
mteswap.c arm64: mte: Avoid setting PG_mte_tagged if no tags cleared or restored 2022-12-08 11:28:37 +01:00
pageattr.c set_memory: allow querying whether set_direct_map_*() is actually enabled 2021-07-08 11:48:20 -07:00
pgd.c
physaddr.c arm64: Do not pass tagged addresses to __is_lm_address() 2021-02-02 17:44:47 +00:00
proc.S arm64: mte: move register initialization to C 2022-10-29 10:12:57 +02:00
ptdump.c arm64/bpf: Remove 128MB limit for BPF JIT programs 2022-01-29 10:58:25 +01:00
ptdump_debugfs.c arm64: Add __init section marker to some functions 2021-04-08 17:45:10 +01:00
trans_pgd.c