]> www.infradead.org Git - users/jedix/linux-maple.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)
committerWill Deacon <will@kernel.org>
Thu, 19 Dec 2024 17:23:53 +0000 (17:23 +0000)
commitf0da16992aef7e246b2f3bba1492e3a52c38ca0e
treededd072f58432a733196bee2950cafb01e2e8a5e
parent62cffa496aac0c2c4eeca00d080058affd7a0172
arm64/kvm: Configure HYP TCR.PS/DS based on host stage1

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>
arch/arm64/kvm/arm.c