mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Currently, LPA2 kernel support implies support for up to 52 bits of
physical addressing, and this is reflected in global definitions such as
PHYS_MASK_SHIFT and MAX_PHYSMEM_BITS.
This is potentially problematic, given that LPA2 hardware support is
modeled as a CPU feature which can be overridden, and with LPA2 hardware
support turned off, attempting to map physical regions with address bits
[51:48] set (which may exist on LPA2 capable systems booting with
arm64.nolva) will result in corrupted mappings with a truncated output
address and bogus shareability attributes.
This means that the accepted physical address range in the mapping
routines should be at most 48 bits wide when LPA2 support is configured
but not enabled at runtime.
Fixes: 352b0395b5
("arm64: Enable 52-bit virtual addressing for 4k and 16k granule configs")
Cc: stable@vger.kernel.org
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20241212081841.2168124-9-ardb+git@google.com
Signed-off-by: Will Deacon <will@kernel.org>
32 lines
747 B
C
32 lines
747 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
*/
|
|
#ifndef __ASM_SPARSEMEM_H
|
|
#define __ASM_SPARSEMEM_H
|
|
|
|
#include <asm/pgtable-prot.h>
|
|
|
|
#define MAX_PHYSMEM_BITS PHYS_MASK_SHIFT
|
|
#define MAX_POSSIBLE_PHYSMEM_BITS (52)
|
|
|
|
/*
|
|
* Section size must be at least 512MB for 64K base
|
|
* page size config. Otherwise it will be less than
|
|
* MAX_PAGE_ORDER and the build process will fail.
|
|
*/
|
|
#ifdef CONFIG_ARM64_64K_PAGES
|
|
#define SECTION_SIZE_BITS 29
|
|
|
|
#else
|
|
|
|
/*
|
|
* Section size must be at least 128MB for 4K base
|
|
* page size config. Otherwise PMD based huge page
|
|
* entries could not be created for vmemmap mappings.
|
|
* 16K follows 4K for simplicity.
|
|
*/
|
|
#define SECTION_SIZE_BITS 27
|
|
#endif /* CONFIG_ARM64_64K_PAGES */
|
|
|
|
#endif
|