Thread (4 messages) 4 messages, 2 authors, 2025-12-30

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

From: Marc Zyngier <maz@kernel.org>
Date: 2025-12-30 15:37:49
Also in: kvmarm, lkml

On Tue, 23 Dec 2025 19:34:40 +0000,
Petteri Kangaslampi [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Use a consistent hypervisor VA size between memory layout and MMU
initialization logic when the kernel is configured for less than
IDMAP_VA_BITS of VA space.

Signed-off-by: Petteri Kangaslampi <redacted>
---
 arch/arm64/kvm/va_layout.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/kvm/va_layout.c b/arch/arm64/kvm/va_layout.c
index f6ca0193a96f..76cdd62550e1 100644
--- a/arch/arm64/kvm/va_layout.c
+++ b/arch/arm64/kvm/va_layout.c
@@ -49,7 +49,7 @@ static void init_hyp_physvirt_offset(void)
 
 /*
  * We want to generate a hyp VA with the following format (with V ==
- * vabits_actual):
+ * hypervisor VA bits):
  *
  *  63 ... V |     V-1    | V-2 .. tag_lsb | tag_lsb - 1 .. 0
  *  ---------------------------------------------------------
@@ -62,10 +62,17 @@ __init void kvm_compute_layout(void)
 {
 	phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start);
 	u64 hyp_va_msb;
+	u32 hyp_va_bits;
+
+	/*
+	 * We use the bigger of IDMAP_VA_BITS and kernel VA size as the
+	 * hypervisor VA address space size. See mmu.c.
+	 */
+	hyp_va_bits = max(IDMAP_VA_BITS, vabits_actual);
Instead of duplicating the logic from kvm_mmu_init(), I'd rather you
make sure there is a single place where the EL2 VA width is computed,
and use that consistently all over the place.

Since you were complaining about the spread of the VA layout handling,
starting with this sort of consolidation seems like a decent starting
point.

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help