[PATCH 0/1] KVM: arm64: Fix hyp VA size between layout and MMU

Petteri Kangaslampi posted 1 patch 1 month, 2 weeks ago
arch/arm64/kvm/va_layout.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
[PATCH 0/1] KVM: arm64: Fix hyp VA size between layout and MMU
Posted by Petteri Kangaslampi 1 month, 2 weeks ago
All,

In the KVM initialization code, kvm_mmu_init() and
kvm_compute_layout() use different logic when determining the
hypervisor's virtual address space size. Specifically, the MMU code
uses the larger of vabits_actual (the kernel's VA size) and
IDMAP_VA_BITS (48 bits), while the VA layout code just uses the
kernel's VA size.

This means that if the kernel is configured with a VA size of less
than 48 bits (like happens in our environment), the assumptions used
to calculate hyp_physvirt_offset and the code that determines VA
ranges to use for mappings in hyp/nvhe/mm.c get out of sync, which can
results in mapping failures.

The immediate fix is pretty obvious and attached here. This is against
6.12 but I don't think this code has changed recently. I think longer
term refactoring knowledge of the hypervisor's address space into one
place might be helpful; currently it is a bit spread out.

Petteri Kangaslampi (1):
  KVM: arm64: Fix hyp VA size between layout and MMU

 arch/arm64/kvm/va_layout.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

-- 
2.52.0.351.gbe84eed79e-goog
Re: [PATCH 0/1] KVM: arm64: Fix hyp VA size between layout and MMU
Posted by Marc Zyngier 1 month, 1 week ago
On Tue, 23 Dec 2025 19:34:39 +0000,
Petteri Kangaslampi <pekangas@google.com> wrote:
> 
> All,
> 
> In the KVM initialization code, kvm_mmu_init() and
> kvm_compute_layout() use different logic when determining the
> hypervisor's virtual address space size. Specifically, the MMU code
> uses the larger of vabits_actual (the kernel's VA size) and
> IDMAP_VA_BITS (48 bits), while the VA layout code just uses the
> kernel's VA size.
> 
> This means that if the kernel is configured with a VA size of less
> than 48 bits (like happens in our environment), the assumptions used
> to calculate hyp_physvirt_offset and the code that determines VA
> ranges to use for mappings in hyp/nvhe/mm.c get out of sync, which can
> results in mapping failures.
> 
> The immediate fix is pretty obvious and attached here. This is against
> 6.12 but I don't think this code has changed recently. I think longer
> term refactoring knowledge of the hypervisor's address space into one
> place might be helpful; currently it is a bit spread out.

I'm sorry, but posting a patch against a kernel that is over a year
old doesn't help. It may apply, but it doesn't mean it works. Please
post a tested patch against the latest released kernel, or even
better, the latest -rc.

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.