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 EF27F46BA for ; Mon, 28 Aug 2023 13:19:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72F6AC433C8; Mon, 28 Aug 2023 13:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693228773; bh=dmmH7p8SvBOaBUFqAbtGZNpMOcvOh+/TRKXaES5Q7JA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZezeQrS/aM9/sfxn0+XJidZw4wtbF2YqxrX0IAtYPS4/PYY/V4CDUAmgEndy1F83L 4RgshfvxUPkq0IpZihHHoVUuhzuFTwMzRZuk21PCf+ChkNrfEJ1Zsmw7ImNpFxsBmq F2pFKqgTC0xXRswD0oFV8484lR1ZV0DnH6i8W3KCapaVJcJZHTnYWyVCD/aGlt/sen mo6UvuTDphQir6LdvbmWtlnNX/aJFJ9mcjsRvj5HJNSGNchLp5Vmibn1ykAAMs101K owXKrLtKvvOglKXwGlaxkFZxJMWtxf98iZAe7Q87XyExYR27xblSL/wtebF/wz/g9w CNqS8mmBX3fTg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qac9S-008jQG-Lk; Mon, 28 Aug 2023 14:19:30 +0100 Date: Mon, 28 Aug 2023 14:19:30 +0100 Message-ID: <861qfnfgnx.wl-maz@kernel.org> From: Marc Zyngier To: Marek Szyprowski Cc: Vincent Donnefort , oliver.upton@linux.dev, kvmarm@lists.linux.dev, qperret@google.com, smostafa@google.com, kaleshsingh@google.com, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, will@kernel.org Subject: Re: [PATCH v2] KVM: arm64: Remove size-order align in the nVHE hyp private VA range In-Reply-To: <79b0ad6e-0c2a-f777-d504-e40e8123d81d@samsung.com> References: <20230811112037.1147863-1-vdonnefort@google.com> <79b0ad6e-0c2a-f777-d504-e40e8123d81d@samsung.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/28.2 (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=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: m.szyprowski@samsung.com, vdonnefort@google.com, oliver.upton@linux.dev, kvmarm@lists.linux.dev, qperret@google.com, smostafa@google.com, kaleshsingh@google.com, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, will@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 Mon, 28 Aug 2023 13:16:51 +0100, Marek Szyprowski wrote: >=20 > On 11.08.2023 13:20, Vincent Donnefort wrote: > > commit f922c13e778d ("KVM: arm64: Introduce > > pkvm_alloc_private_va_range()") and commit 92abe0f81e13 ("KVM: arm64: > > Introduce hyp_alloc_private_va_range()") added an alignment for the > > start address of any allocation into the nVHE hypervisor private VA > > range. > > > > This alignment (order of the size of the allocation) intends to enable > > efficient stack verification (if the PAGE_SHIFT bit is zero, the stack > > pointer is on the guard page and a stack overflow occurred). > > > > But this is only necessary for stack allocation and can waste a lot of > > VA space. So instead make stack-specific functions, handling the guard > > page requirements, while other users (e.g. fixmap) will only get page > > alignment. > > > > Signed-off-by: Vincent Donnefort >=20 > This change, merged to linux-next as f156a7d13fc3 ("KVM: arm64: Remove=20 > size-order align in the nVHE hyp private VA range"), introduced the=20 > following regression on Raspberry Pi4b board. Here is a log observed on=20 > linux next-20230828 release: >=20 > --->8--- >=20 > kvm [1]: IPA Size Limit: 44 bits > ------------[ cut here ]------------ > WARNING: CPU: 0 PID: 1 at arch/arm64/kvm/hyp/pgtable.c:453=20 > hyp_map_walker+0xb0/0x120 > Modules linked in: > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-next-20230828 #13889 > Hardware name: Raspberry Pi 4 Model B (DT) > pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=3D--) > pc : hyp_map_walker+0xb0/0x120 > lr : hyp_map_walker+0x30/0x120 > ... > Call trace: > =C2=A0hyp_map_walker+0xb0/0x120 > =C2=A0kvm_pgtable_visitor_cb.isra.0+0x38/0x5c > =C2=A0__kvm_pgtable_walk+0x1dc/0x32c > =C2=A0__kvm_pgtable_walk+0xd0/0x32c > =C2=A0__kvm_pgtable_walk+0xd0/0x32c > =C2=A0__kvm_pgtable_walk+0xd0/0x32c > =C2=A0kvm_pgtable_walk+0xd0/0x224 > =C2=A0kvm_pgtable_hyp_map+0x8c/0xf0 > =C2=A0__create_hyp_mappings+0x98/0xc0 > =C2=A0__create_hyp_private_mapping+0xf0/0x14c > =C2=A0create_hyp_io_mappings+0x8c/0x118 > =C2=A0vgic_v2_probe+0xbc/0x1ec > =C2=A0kvm_vgic_hyp_init+0xcc/0x210 > =C2=A0kvm_arm_init+0x6a4/0x1040 Ah, wonderful. Can you give the snippet below a go? diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 11c1d786c506..50be51cc40cc 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -652,6 +652,9 @@ int hyp_alloc_private_va_range(size_t size, unsigned lo= ng *haddr) =20 mutex_unlock(&kvm_hyp_pgd_mutex); =20 + if (!ret) + *haddr =3D base; + return ret; } =20 Thanks, M. --=20 Without deviation from the norm, progress is not possible.