kernel_samsung_a53x/arch/arm64/mm
Catalin Marinas e720f4eea6 arm64: Ensure bits ASID[15:8] are masked out when the kernel uses 8-bit ASIDs
[ Upstream commit c0900d15d31c2597dd9f634c8be2b71762199890 ]

Linux currently sets the TCR_EL1.AS bit unconditionally during CPU
bring-up. On an 8-bit ASID CPU, this is RES0 and ignored, otherwise
16-bit ASIDs are enabled. However, if running in a VM and the hypervisor
reports 8-bit ASIDs (ID_AA64MMFR0_EL1.ASIDBits == 0) on a 16-bit ASIDs
CPU, Linux uses bits 8 to 63 as a generation number for tracking old
process ASIDs. The bottom 8 bits of this generation end up being written
to TTBR1_EL1 and also used for the ASID-based TLBI operations as the
upper 8 bits of the ASID. Following an ASID roll-over event we can have
threads of the same application with the same 8-bit ASID but different
generation numbers running on separate CPUs. Both TLB caching and the
TLBI operations will end up using different actual 16-bit ASIDs for the
same process.

A similar scenario can happen in a big.LITTLE configuration if the boot
CPU only uses 8-bit ASIDs while secondary CPUs have 16-bit ASIDs.

Ensure that the ASID generation is only tracked by bits 16 and up,
leaving bits 15:8 as 0 if the kernel uses 8-bit ASIDs. Note that
clearing TCR_EL1.AS is not sufficient since the architecture requires
that the top 8 bits of the ASID passed to TLBI instructions are 0 rather
than ignored in such configuration.

Cc: stable@vger.kernel.org
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: James Morse <james.morse@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20241203151941.353796-1-catalin.marinas@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-15 16:29:51 +01:00
..
cache.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
context.c arm64: Ensure bits ASID[15:8] are masked out when the kernel uses 8-bit ASIDs 2025-01-15 16:29:51 +01:00
copypage.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dma-mapping-noalias.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dma-mapping.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
extable.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fault.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
flush.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hugetlbpage.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
init.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ioremap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kasan_init.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mteswap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pageattr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
physaddr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
proc.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ptdump.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ptdump_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00