From nobody Sun Feb 8 17:37:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16415734838931.749487700363943; Fri, 7 Jan 2022 08:38:03 -0800 (PST) Received: from localhost ([::1]:45098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5sFe-0000oF-Ow for importer@patchew.org; Fri, 07 Jan 2022 11:38:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5sBz-0006IZ-M5 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 11:34:21 -0500 Received: from [2604:1380:4641:c500::1] (port=41150 helo=dfw.source.kernel.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5sBn-0006ce-64 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 11:34:05 -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 0CF9261F08; Fri, 7 Jan 2022 16:34:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 774BBC36AEB; Fri, 7 Jan 2022 16:34:00 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=hot-poop.lan) 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 1n5sBi-00GbiJ-LG; Fri, 07 Jan 2022 16:33:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641573240; bh=clw1W3Qh5t6xAq4WkKq25xI9sJSNdQrAIyTznjaZIhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R5XmJm6VHZxM6lumkNKO8ZGHprWXCjY5Z4p9hgKvqLqFBt4ZHUPT3s+KTZPudjRJX BffGIrOEm8mDsIQOM6r/q8wqPyyNZry37AbLY8E/PZPPjulvke/Tfm3d08xoLkIuAs yCZ3p98HI06qn4w/AHIzYjmNAUX/Yk7u7HVbOXfl1QUGgFr6+Or0AdYL9+L6H87hzg AGEFxeg5pamqZQNbwfA6ehGt9KzhAy/FQOZW8t2zhACAorUC2zvzXDmfH8t4qBN3EY 5nrA6H7ZzR5lF4dL8sqPyu7tJjg109BEHiBR0YCA1aKeaKgx+ZseFSq3I2BerIeyYS NFhc/YAKZQ8ow== From: Marc Zyngier To: qemu-devel@nongnu.org Subject: [PATCH v4 3/6] hw/arm/virt: Honor highmem setting when computing the memory map Date: Fri, 7 Jan 2022 16:33:21 +0000 Message-Id: <20220107163324.2491209-4-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220107163324.2491209-1-maz@kernel.org> References: <20220107163324.2491209-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qemu-devel@nongnu.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com, drjones@redhat.com, eric.auger@redhat.com, peter.maydell@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Host-Lookup-Failed: Reverse DNS lookup failed for 2604:1380:4641:c500::1 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2604:1380:4641:c500::1; envelope-from=maz@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , kvm@vger.kernel.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641573484318100001 Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier Reviewed-by: Eric Auger --- hw/arm/virt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4d1d629432..57c55e8a37 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1663,7 +1663,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState= *vms, int idx) static void virt_set_memmap(VirtMachineState *vms) { MachineState *ms =3D MACHINE(vms); - hwaddr base, device_memory_base, device_memory_size; + hwaddr base, device_memory_base, device_memory_size, memtop; int i; =20 vms->memmap =3D extended_memmap; @@ -1690,7 +1690,11 @@ static void virt_set_memmap(VirtMachineState *vms) device_memory_size =3D ms->maxram_size - ms->ram_size + ms->ram_slots = * GiB; =20 /* Base address of the high IO region */ - base =3D device_memory_base + ROUND_UP(device_memory_size, GiB); + memtop =3D base =3D device_memory_base + ROUND_UP(device_memory_size, = GiB); + if (!vms->highmem && memtop > 4 * GiB) { + error_report("highmem=3Doff, but memory crosses the 4GiB limit\n"); + exit(EXIT_FAILURE); + } if (base < device_memory_base) { error_report("maxmem/slots too huge"); exit(EXIT_FAILURE); @@ -1707,7 +1711,7 @@ 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 : memtop) - 1; if (device_memory_size > 0) { ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); ms->device_memory->base =3D device_memory_base; --=20 2.30.2