]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
arm64/kvm: Configure HYP TCR.PS/DS based on host stage1
authorArd Biesheuvel <ardb@kernel.org>
Thu, 12 Dec 2024 08:18:45 +0000 (09:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Feb 2025 09:05:05 +0000 (10:05 +0100)
commit5a6520493c41834f548d0f2cda52b24deca78003
tree27100737e71cc4b68f95acc318711fb98a682880
parent1b705df8ecdbc61b93381e35ab7a378e996170e7
arm64/kvm: Configure HYP TCR.PS/DS based on host stage1

commit f0da16992aef7e246b2f3bba1492e3a52c38ca0e upstream.

When the host stage1 is configured for LPA2, the value currently being
programmed into TCR_EL2.T0SZ may be invalid unless LPA2 is configured
at HYP as well.  This means kvm_lpa2_is_enabled() is not the right
condition to test when setting TCR_EL2.DS, as it will return false if
LPA2 is only available for stage 1 but not for stage 2.

Similary, programming TCR_EL2.PS based on a limited IPA range due to
lack of stage2 LPA2 support could potentially result in problems.

So use lpa2_is_enabled() instead, and set the PS field according to the
host's IPS, which is capped at 48 bits if LPA2 support is absent or
disabled. Whether or not we can make meaningful use of such a
configuration is a different question.

Cc: stable@vger.kernel.org
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20241212081841.2168124-11-ardb+git@google.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kvm/arm.c