twx-linux/arch
Marc Zyngier ca88ecdce5 arm64: Revamp HCR_EL2.E2H RES1 detection
We currently have two ways to identify CPUs that only implement FEAT_VHE
and not FEAT_E2H0:

- either they advertise it via ID_AA64MMFR4_EL1.E2H0,
- or the HCR_EL2.E2H bit is RAO/WI

However, there is a third category of "cpus" that fall between these
two cases: on CPUs that do not implement FEAT_FGT, it is IMPDEF whether
an access to ID_AA64MMFR4_EL1 can trap to EL2 when the register value
is zero.

A consequence of this is that on systems such as Neoverse V2, a NV
guest cannot reliably detect that it is in a VHE-only configuration
(E2H is writable, and ID_AA64MMFR0_EL1 is 0), despite the hypervisor's
best effort to repaint the id register.

Replace the RAO/WI test by a sequence that makes use of the VHE
register remnapping between EL1 and EL2 to detect this situation,
and work out whether we get the VHE behaviour even after having
set HCR_EL2.E2H to 0.

This solves the NV problem, and provides a more reliable acid test
for CPUs that do not completely follow the letter of the architecture
while providing a RES1 behaviour for HCR_EL2.E2H.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Tested-by: Jan Kotas <jank@cadence.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/15A85F2B-1A0C-4FA7-9FE4-EEC2203CC09E@global.cadence.com
2025-10-14 08:18:40 +01:00
..
alpha assorted dead code removal around asm/pgtable.h 2025-10-03 11:37:50 -07:00
arc Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
arm ARM development for 6.18-rc1 2025-10-07 16:20:19 -07:00
arm64 arm64: Revamp HCR_EL2.E2H RES1 detection 2025-10-14 08:18:40 +01:00
csky assorted dead code removal around asm/pgtable.h 2025-10-03 11:37:50 -07:00
hexagon Scheduler updates for v6.18: 2025-09-30 10:35:11 -07:00
loongarch hyperv-next for v6.18 2025-10-07 08:40:15 -07:00
m68k pci-v6.18-changes 2025-10-06 10:41:03 -07:00
microblaze assorted dead code removal around asm/pgtable.h 2025-10-03 11:37:50 -07:00
mips pci-v6.18-changes 2025-10-06 10:41:03 -07:00
nios2 Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
openrisc OpenRISC updates for 6.18 2025-10-05 10:02:54 -07:00
parisc parisc architecture updates for kernel v6.18-rc1: 2025-10-10 10:01:55 -07:00
powerpc Generic: 2025-10-06 12:37:34 -07:00
riscv hyperv-next for v6.18 2025-10-07 08:40:15 -07:00
s390 Kbuild fixes for 6.18 #1 2025-10-11 15:47:12 -07:00
sh Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
sparc pci-v6.18-changes 2025-10-06 10:41:03 -07:00
um updates for UML, notably 2025-10-06 12:10:55 -07:00
x86 - Remove a bunch of asm implementing condition flags testing in KVM's 2025-10-11 11:19:16 -07:00
xtensa Xtensa updates for v6.18 2025-10-10 11:20:19 -07:00
.gitignore
Kconfig Kbuild updates for 6.18 2025-10-01 20:58:51 -07:00