1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/arch
Will Deacon 102c51c50d KVM: arm64: Fix tcr_el2 initialisation in hVHE mode
When not running in VHE mode, cpu_prepare_hyp_mode() computes the value
of TCR_EL2 using the host's TCR_EL1 settings as a starting point. For
nVHE, this amounts to masking out everything apart from the TG0, SH0,
ORGN0, IRGN0 and T0SZ fields before setting the RES1 bits, shifting the
IPS field down to the PS field and setting DS if LPA2 is enabled.

Unfortunately, for hVHE, things go slightly wonky: EPD1 is correctly set
to disable walks via TTBR1_EL2 but then the T1SZ and IPS fields are
corrupted when we mistakenly attempt to initialise the PS and DS fields
in their E2H=0 positions. Furthermore, many fields are retained from
TCR_EL1 which should not be propagated to TCR_EL2. Notably, this means
we can end up with A1 set despite not initialising TTBR1_EL2 at all.
This has been shown to cause unexpected translation faults at EL2 with
pKVM due to TLB invalidation not taking effect when running with a
non-zero ASID.

Fix the TCR_EL2 initialisation code to set PS and DS only when E2H=0,
masking out HD, HA and A1 when E2H=1.

Cc: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oliver.upton@linux.dev>
Fixes: ad744e8cb3 ("arm64: Allow arm64_sw.hvhe on command line")
Signed-off-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250214133724.13179-1-will@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
2025-02-19 22:09:24 +00:00
..
alpha alpha: Use str_yes_no() helper in pci_dac_dma_supported() 2025-02-14 14:06:41 -05:00
arc Kbuild updates for v6.14 2025-01-31 12:07:07 -08:00
arm Summary: 2025-01-29 10:35:40 -08:00
arm64 KVM: arm64: Fix tcr_el2 initialisation in hVHE mode 2025-02-19 22:09:24 +00:00
csky asm-generic: pgalloc: provide generic __pgd_{alloc,free} 2025-01-25 20:22:24 -08:00
hexagon hexagon: Fix unbalanced spinlock in die() 2025-01-30 18:46:06 -08:00
loongarch LoongArch: KVM: Set host with kernel mode when switch to VM mode 2025-02-13 12:02:56 +08:00
m68k revert "xarray: port tests to kunit" 2025-02-01 03:53:28 -08:00
microblaze asm-generic: pgalloc: provide generic __pgd_{alloc,free} 2025-01-25 20:22:24 -08:00
mips MIPS: fix mips_get_syscall_arg() for o32 2025-02-13 12:41:29 +01:00
nios2 asm-generic: pgalloc: provide generic __pgd_{alloc,free} 2025-01-25 20:22:24 -08:00
openrisc The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
parisc The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
powerpc genirq: Remove leading space from irq_chip::irq_print_chip() callbacks 2025-02-07 08:56:01 +01:00
riscv RISC-V Patches for the 6.14 Merge Window, Part 1 2025-01-31 15:13:25 -08:00
s390 s390/pci: Fix handling of isolated VFs 2025-02-11 19:35:08 +01:00
sh sh updates for v6.14 2025-02-02 10:40:27 -08:00
sparc Driver core and debugfs updates 2025-01-28 12:25:12 -08:00
um um: convert irq_lock to raw spinlock 2025-02-12 23:40:59 +01:00
x86 - Explicitly clear DEBUGCTL.LBR to prevent LBRs continuing being enabled after 2025-02-16 10:41:50 -08:00
xtensa Xtensa updates for v6.14 2025-01-27 08:16:33 -08:00
.gitignore
Kconfig m68k: Use kernel's generic muldi3 libgcc function 2024-12-09 13:29:17 +01:00