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 0A161C433EF for ; Mon, 27 Dec 2021 16:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbhL0QjH (ORCPT ); Mon, 27 Dec 2021 11:39:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbhL0QjG (ORCPT ); Mon, 27 Dec 2021 11:39:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D461C06173E for ; Mon, 27 Dec 2021 08:39:06 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 18EF8B81022 for ; Mon, 27 Dec 2021 16:39:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BFADC36AE7; Mon, 27 Dec 2021 16:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640623143; bh=WEDbpEQhjoWaU0eAWyDEdcLhrsSzaMog2S29Lw9qtmk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NtLNIGGxRyIizvSbAaIfsLpFFs/rZX6VaeFRLPoqcQqoMazJzKHgAkEBmEfX4h491 jTvy1DxYyM2mmJt1LIo0dTQ7fsEXlEIcZ+cWs4XW8SCtKtUtN3KFWcX6XR6pw4dDUr Uwg95qbwCJXplo+VqWkimps3L39YkXhn4tbna1elGeNwuC42TGY8I+W1AneODx26w5 /e6ysrQ5PREY8d+RzpLtC8sVYw9oF4tAntYhPky5gYHFM2bpcxGtEg5/yRI57rIDv6 4P74lzUbWSUfq0VsOdLATkkHCF85UIGt5h6ALEtAnkYNLiWhNo0vM7/LqDlIrt25SK TW1iF35u2M6bQ== Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=wait-a-minute.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 1n1t1Z-00Eawq-JP; Mon, 27 Dec 2021 16:39:01 +0000 Date: Mon, 27 Dec 2021 16:39:01 +0000 Message-ID: <87o852ypcq.wl-maz@kernel.org> From: Marc Zyngier To: eric.auger@redhat.com Cc: qemu-devel@nongnu.org, Andrew Jones , Peter Maydell , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v2 3/5] hw/arm/virt: Honor highmem setting when computing the memory map In-Reply-To: References: <20211003164605.3116450-1-maz@kernel.org> <20211003164605.3116450-4-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=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: eric.auger@redhat.com, qemu-devel@nongnu.org, drjones@redhat.com, peter.maydell@linaro.org, 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 Mon, 04 Oct 2021 13:23:41 +0100, Eric Auger wrote: >=20 > Hi Marc, >=20 > On 10/3/21 6:46 PM, Marc Zyngier wrote: > > Even when the VM is configured with highmem=3Doff, the highest_gpa > > field includes devices that are above the 4GiB limit. > > Similarily, nothing seem to check that the memory is within > > the limit set by the highmem=3Doff option. > > > > This leads to failures in virt_kvm_type() on systems that have > > a crippled IPA range, as the reported IPA space is larger than > > what it should be. > > > > Instead, honor the user-specified limit to only use the devices > > at the lowest end of the spectrum, and fail if we have memory > > crossing the 4GiB limit. > > > > Signed-off-by: Marc Zyngier > > --- > > hw/arm/virt.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > > index bcf58f677d..9d2abdbd5f 100644 > > --- a/hw/arm/virt.c > > +++ b/hw/arm/virt.c > > @@ -1628,6 +1628,11 @@ static void virt_set_memmap(VirtMachineState *vm= s) > > exit(EXIT_FAILURE); > > } > > =20 > > + if (!vms->highmem && > > + vms->memmap[VIRT_MEM].base + ms->maxram_size > 4 * GiB) { > > + error_report("highmem=3Doff, but memory crosses the 4GiB limit= \n"); > > + exit(EXIT_FAILURE); > > + } > > /* > > * We compute the base of the high IO region depending on the > > * amount of initial and device memory. The device memory start/si= ze > > @@ -1657,7 +1662,9 @@ static void virt_set_memmap(VirtMachineState *vms) > > vms->memmap[i].size =3D size; > > base +=3D size; > > } > > - vms->highest_gpa =3D base - 1; > > + vms->highest_gpa =3D (vms->highmem ? > > + base : > > + vms->memmap[VIRT_MEM].base + ms->maxram_size) = - 1; > I think I would have preferred to have >=20 > if (vms->highmem) { > =C2=A0=C2=A0 for (i =3D VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memm= ap); i++) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hwaddr size =3D extended_memma= p[i].size; >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base =3D ROUND_UP(base, size); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vms->memmap[i].base =3D base; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vms->memmap[i].size =3D size; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base +=3D size; > =C2=A0=C2=A0=C2=A0 } > } > as it is useless to execute that code and create new memmap entries in > case of !highmem. I agree that it is a bit useless when we only have highmem. But we really want to deal with arbitrary IPA spaces (see how this changes in the follow-up patches), and we need to check that everything fits in the IPA space (and fix things up if they don't). >=20 > But nevertheless, this looks correct Thanks, M. --=20 Without deviation from the norm, progress is not possible.