From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82AE0241665; Tue, 30 Dec 2025 15:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767109069; cv=none; b=BgwgwFDkrTKus3myODDPciKapTG+uiu6WXQYr6EUiN6aCksDcbqeP+oLjPXT7MEHU2Oq8HPxoAvJT6WrxLPd5lqkSWhN8PEw603Ej3ZVyd2kwhnnVpOfrezvK/LMC+5hdr/b6PKEsdxj+ZvFKdf49nx2GQYt9Wr0IdppJyCPM8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767109069; c=relaxed/simple; bh=tIwfl2Yo5eMip565qmwOXZSIPkclnpZAD+5EurUHNVw=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=DoBhmp7xyoNgmspurlD2GOiUAtiUCPsttTFV6R7Ntv1rs0Z8moUa8HA3a/jVTyFt6N4n2jrYFaUmFxGwCOfp6wUlHqbMIuvGYSyH3bmZsKQkuut0/xWaNoDwEM35CTbmNvMg8ZJtn9cxKKcm5fne15baUHKqHooYt01RJdi4vw8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jOvBWjJl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jOvBWjJl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E14FAC4CEFB; Tue, 30 Dec 2025 15:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767109068; bh=tIwfl2Yo5eMip565qmwOXZSIPkclnpZAD+5EurUHNVw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jOvBWjJlBGAthPusa3MDujJmLlYaso7weZf+GtJvANkPCdvYcG7TwslhAmVQIjX9d AXU3EkJ++N4YnAijFojLLxMIXIR1kCNb4pIAhxGiRcIGSa8zwsWH14fZUUquclInZg QFp/qPUVdatEVbH94cQKoXQ7gAdqroACPW2KUR8ET/z+L1z33cE9dlRPItp5irO2AX Rc3gwlx1Rp6ALhLryzPMQ2P11/ImygzBtgxFoMZ1JOOyulC/2+NDaXacKl5bHq+tZG aiOy+FXeg/Y2o030RAE96JJKuRaq+FLPi7hQReRNDpLLZM0I/Lev2m2WM8IdNxXxUB ZfsTwJth2sUJQ== Received: from lfbn-nan-1-2237-32.w92-139.abo.wanadoo.fr ([92.139.188.32] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vabn8-0000000G15P-2bwo; Tue, 30 Dec 2025 15:37:46 +0000 Date: Tue, 30 Dec 2025 15:37:45 +0000 Message-ID: <87pl7wdlpy.wl-maz@kernel.org> From: Marc Zyngier To: Petteri Kangaslampi Cc: kvmarm@lists.linux.dev, Oliver Upton , Vincent Donnefort , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] KVM: arm64: Fix hyp VA size between layout and MMU In-Reply-To: <20251223193440.1441657-2-pekangas@google.com> References: <20251223193440.1441657-1-pekangas@google.com> <20251223193440.1441657-2-pekangas@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 92.139.188.32 X-SA-Exim-Rcpt-To: pekangas@google.com, kvmarm@lists.linux.dev, oliver.upton@linux.dev, vdonnefort@google.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 23 Dec 2025 19:34:40 +0000, Petteri Kangaslampi wrote: > > 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 > --- > 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.