From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42D61EE0218 for ; Tue, 30 Dec 2025 15:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=e8lLSvrxP7mFJ813c9OQb0bInlODeqzjr+ojNg2Pu+I=; b=nNfjkG2BHrjvbUAsCYZMU6HfZ8 IqwSU1EjdiMyjg/TwC4C9ned5k4chNj1mhgnDWhCsI9aDPxJCLbStn0qNWG7iyKZqHDraWSxhZHeT dm7PCfBlYayiILXct4GoQ2deYcJKdgxdxYVPR5yrm3djMxMW7uhoNa+tKMo1XwPQsjicrgoYyuUxA 3G/zWjNkuEm1cORlTcjzuqC8ioJb7DplyehGZO8NS4/ffed8wo0zlda0lsVv6dupSAoOr8S0IdRJh 1oM+W6UTOo4t/x/7BztpFicdNYW0YfDNl93uO3M7QY9LrHId/l7eyRsZI2HIPfDmwaY72U0bDAnpC ZXoVEhAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vabnE-000000050Ze-1be0; Tue, 30 Dec 2025 15:37:52 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vabnB-000000050ZG-3ajm for linux-arm-kernel@lists.infradead.org; Tue, 30 Dec 2025 15:37:51 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 13A0443EF4; Tue, 30 Dec 2025 15:37:49 +0000 (UTC) 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251230_073749_935453_D0192562 X-CRM114-Status: GOOD ( 22.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.