android_kernel_xiaomi_sm8450/arch
Mark Rutland 32020fc2a8 arm64: mm: fix VA-range sanity check
[ Upstream commit ab9b4008092c86dc12497af155a0901cc1156999 ]

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>
2023-07-27 08:44:37 +02:00
..
alpha mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t * 2023-07-27 08:43:58 +02:00
arc ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-07-27 08:44:00 +02:00
arm ARM: orion5x: fix d2net gpio initialization 2023-07-27 08:44:14 +02:00
arm64 arm64: mm: fix VA-range sanity check 2023-07-27 08:44:37 +02:00
c6x c6x: add support for TIF_NOTIFY_SIGNAL 2023-01-04 11:39:21 +01:00
csky csky: Fix function name in csky_alignment() and die() 2023-02-01 08:23:20 +01:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-01 08:23:19 +01:00
hexagon hexagon: Fix function name in die() 2023-02-01 08:23:19 +01:00
ia64 mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t * 2023-07-27 08:43:58 +02:00
m68k mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t * 2023-07-27 08:43:58 +02:00
microblaze exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
mips MIPS: Loongson: Fix cpu_probe_loongson() again 2023-07-27 08:44:26 +02:00
nds32 exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:45:37 +02:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-17 11:48:03 +02:00
parisc mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t * 2023-07-27 08:43:58 +02:00
powerpc powerpc: Fail build if using recordmcount with binutils v2.37 2023-07-27 08:44:26 +02:00
riscv riscv, bpf: Fix inconsistent JIT image generation 2023-07-27 08:44:23 +02:00
s390 s390/decompressor: fix misaligned symbol build error 2023-07-27 08:44:31 +02:00
sh sh: pgtable-3level: Fix cast to pointer from integer of different size 2023-07-27 08:44:15 +02:00
sparc mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t * 2023-07-27 08:43:58 +02:00
um um: Use HOST_DIR for mrproper 2023-07-27 08:44:12 +02:00
x86 mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t * 2023-07-27 08:43:58 +02:00
xtensa xtensa: ISS: fix call to split_if_spec 2023-07-27 08:44:32 +02:00
.gitignore
Kconfig arch/cc: Introduce a function to check for confidential computing features 2021-11-18 14:04:32 +01:00