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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6D09C433EF for ; Fri, 7 Jan 2022 19:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbiAGTEw (ORCPT ); Fri, 7 Jan 2022 14:04:52 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:60776 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbiAGTEv (ORCPT ); Fri, 7 Jan 2022 14:04:51 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F2B561FF1 for ; Fri, 7 Jan 2022 19:04:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFF6FC36AF3; Fri, 7 Jan 2022 19:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641582290; bh=8YAA2g6Na70NFQk9OYCoG61rxL4WyW01KMd7dTW9UO8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HFPw5SqU2Qrle6qgM0hUT8ydTvurD5V1inuaERw4YKcMqMX8cMjeO46BU4h2Lhw8F Nd3rU3rdqKXhGbQPqpiViWTXPK4+H/9lK4llL4HTRkzs6KpSHRHZvYl2U7pRAgRZE8 iTGpQNEsxTcj0en1bBal5Z44TM423Jgnho0c22HaRkeayryZJYW+5Q+W+Lz06iimm/ 0do/5QzTTrRaz62n8TsMShfwnlrd1//cvFk/ga0Rf9U32TRse+X4KMUtAXHvKTjFFV 7eHzx9qQGgP5XD+ScqqG6rJ9D7N4jZunO2xMQKPw9gACW4LSuNFHs0pj6JahG9FfoA EcDXIhKeNtrIA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n5uXg-00GdT6-O6; Fri, 07 Jan 2022 19:04:48 +0000 Date: Fri, 07 Jan 2022 19:04:48 +0000 Message-ID: <87v8yvtlin.wl-maz@kernel.org> From: Marc Zyngier To: Peter Maydell Cc: eric.auger@redhat.com, qemu-devel@nongnu.org, Andrew Jones , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v3 3/5] hw/arm/virt: Honor highmem setting when computing the memory map In-Reply-To: References: <20211227211642.994461-1-maz@kernel.org> <20211227211642.994461-4-maz@kernel.org> <871r1kzhbp.wl-maz@kernel.org> <87y23rtnny.wl-maz@kernel.org> 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/27.1 (x86_64-pc-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: 185.219.108.64 X-SA-Exim-Rcpt-To: peter.maydell@linaro.org, eric.auger@redhat.com, qemu-devel@nongnu.org, drjones@redhat.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 07 Jan 2022 18:48:16 +0000, Peter Maydell wrote: > > On Fri, 7 Jan 2022 at 18:18, Marc Zyngier wrote: > > This is a chicken and egg problem: you need the IPA size to compute > > the memory map, and you need the memory map to compute the IPA > > size. Fun, isn't it? > > > > At the moment, virt_set_memmap() doesn't know about the IPA space, > > generates a highest_gpa that may not work, and we end-up failing > > because the resulting VM type is out of bound. > > > > My solution to that is to feed the *maximum* IPA size to > > virt_set_memmap(), compute the memory map there, and then use > > highest_gpa to compute the actual IPA size that is used to create the > > VM. By knowing the IPA limit in virt_set_memmap(), I'm able to keep it > > in check and avoid generating an unusable memory map. > > Is there any reason not to just always create the VM with the > maximum supported IPA size, rather than trying to create it > with the smallest IPA size that will work? (ie skip the last > step of computing the IPA size to create the VM with) That gives KVM the opportunity to reduce the depth of the S2 page tables. On HW that supports a large PA space, there is a real advantage in keeping these shallow if at all possible. Thanks, M. -- Without deviation from the norm, progress is not possible.