From nobody Sat Feb 7 07:11:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 154939000590123.358574479416347; Tue, 5 Feb 2019 10:06:45 -0800 (PST) Received: from localhost ([127.0.0.1]:36212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr57I-0001vR-UT for importer@patchew.org; Tue, 05 Feb 2019 13:06:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr4cQ-0000sE-Mr for qemu-devel@nongnu.org; Tue, 05 Feb 2019 12:34:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gr4cM-0004dj-C7 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 12:34:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34542) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gr4c2-0004XT-6g; Tue, 05 Feb 2019 12:34:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DAA781138; Tue, 5 Feb 2019 17:34:21 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7B16183EA; Tue, 5 Feb 2019 17:34:18 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, imammedo@redhat.com, david@redhat.com Date: Tue, 5 Feb 2019 18:33:02 +0100 Message-Id: <20190205173306.20483-15-eric.auger@redhat.com> In-Reply-To: <20190205173306.20483-1-eric.auger@redhat.com> References: <20190205173306.20483-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Feb 2019 17:34:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 14/18] hw/arm/virt: Allocate device_memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, dgilbert@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The device memory region is located after the initial RAM. its start/size are 1GB aligned. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee --- v4 -> v5: - device memory set after the initial RAM v3 -> v4: - remove bootinfo.device_memory_start/device_memory_size - rename VIRT_HOTPLUG_MEM into VIRT_DEVICE_MEM --- hw/arm/virt.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 783468ba77..b683902991 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -61,6 +61,7 @@ #include "hw/arm/smmuv3.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/acpi.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1260,6 +1261,37 @@ static void create_secure_ram(VirtMachineState *vms, g_free(nodename); } =20 +static void create_device_memory(VirtMachineState *vms, MemoryRegion *sysm= em) +{ + MachineState *ms =3D MACHINE(vms); + uint64_t device_memory_size =3D ms->maxram_size - ms->ram_size; + uint64_t align =3D GiB; + + if (!device_memory_size) { + return; + } + + if (ms->ram_slots > ACPI_MAX_RAM_SLOTS) { + error_report("unsupported number of memory slots: %"PRIu64, + ms->ram_slots); + exit(EXIT_FAILURE); + } + + if (QEMU_ALIGN_UP(ms->maxram_size, align) !=3D ms->maxram_size) { + error_report("maximum memory size must be aligned to multiple of 0= x%" + PRIx64, align); + exit(EXIT_FAILURE); + } + + ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); + ms->device_memory->base =3D QEMU_ALIGN_UP(GiB + ms->ram_size, GiB); + + memory_region_init(&ms->device_memory->mr, OBJECT(vms), + "device-memory", device_memory_size); + memory_region_add_subregion(sysmem, ms->device_memory->base, + &ms->device_memory->mr); +} + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) { const VirtMachineState *board =3D container_of(binfo, VirtMachineState, @@ -1569,6 +1601,10 @@ static void machvirt_init(MachineState *machine) machine->ram_size); memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); =20 + if (vms->extended_memmap) { + create_device_memory(vms, sysmem); + } + create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); =20 create_gic(vms, pic); --=20 2.20.1