]> www.infradead.org Git - users/hch/dma-mapping.git/commit
KVM: arm64: Constrain the host to the maximum shared SVE VL with pKVM
authorMark Brown <broonie@kernel.org>
Thu, 12 Sep 2024 11:39:35 +0000 (12:39 +0100)
committerMarc Zyngier <maz@kernel.org>
Tue, 1 Oct 2024 14:25:23 +0000 (15:25 +0100)
commita9f41588a902f386b48f021f56a4c14735cd9371
treef9c271c6868f9fbfdde8bd2fcf51dcdce8dd1c83
parent78fee4198bb4d29cf82c457086d07e009955a682
KVM: arm64: Constrain the host to the maximum shared SVE VL with pKVM

When pKVM saves and restores the host floating point state on a SVE system,
it programs the vector length in ZCR_EL2.LEN to be whatever the maximum VL
for the PE is. But it uses a buffer allocated with kvm_host_sve_max_vl, the
maximum VL shared by all PEs in the system. This means that if we run on a
system where the maximum VLs are not consistent, we will overflow the buffer
on PEs which support larger VLs.

Since the host will not currently attempt to make use of non-shared VLs, fix
this by explicitly setting the EL2 VL to be the maximum shared VL when we
save and restore. This will enforce the limit on host VL usage. Should we
wish to support asymmetric VLs, this code will need to be updated along with
the required changes for the host:

  https://lore.kernel.org/r/20240730-kvm-arm64-fix-pkvm-sve-vl-v6-0-cae8a2e0bd66@kernel.org

Fixes: b5b9955617bc ("KVM: arm64: Eagerly restore host fpsimd/sve state in pKVM")
Signed-off-by: Mark Brown <broonie@kernel.org>
Tested-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20240912-kvm-arm64-limit-guest-vl-v2-1-dd2c29cb2ac9@kernel.org
[maz: added punctuation to the commit message]
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/include/hyp/switch.h
arch/arm64/kvm/hyp/nvhe/hyp-main.c