KVM: arm64: Fix handling of FEAT_GTG for unimplemented granule sizes
authorMarc Zyngier <maz@kernel.org>
Tue, 1 Jul 2025 14:02:58 +0000 (15:02 +0100)
committerMarc Zyngier <maz@kernel.org>
Thu, 3 Jul 2025 09:39:24 +0000 (10:39 +0100)
commit105485a182dc6ba32e55db46839af756c105afae
treea48308ee7f0c7f71686856e474f9b0c73c84aa1f
parent0e02219f9cf4f0c0aa3dbf3c820e6612bf3f0c8c
KVM: arm64: Fix handling of FEAT_GTG for unimplemented granule sizes

Booting an EL2 guest on a system only supporting a subset of the
possible page sizes leads to interesting situations.

For example, on a system that only supports 4kB and 64kB, and is
booted with a 4kB kernel, we end-up advertising 16kB support at
stage-2, which is pretty weird.

That's because we consider that any S2 bigger than our base granule
is fair game, irrespective of what the HW actually supports. While this
is not impossible to support (KVM would happily handle it), it is likely
to be confusing for the guest.

Add new checks that will verify that this granule size is actually
supported before publishing it to the guest.

Fixes: e7ef6ed4583ea ("KVM: arm64: Enforce NV limits on a per-idregs basis")
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/nested.c