From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702759982101.85267334424714; Wed, 20 Feb 2019 14:45:59 -0800 (PST) Received: from localhost ([127.0.0.1]:50010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwacm-00088H-Sj for importer@patchew.org; Wed, 20 Feb 2019 17:45:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXM-0003sU-Sn for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXL-0008Q0-Vf for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58752) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXJ-0008Or-Mc; Wed, 20 Feb 2019 17:40:17 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8CB8368D0; Wed, 20 Feb 2019 22:40:16 +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 4ABF15D6B3; Wed, 20 Feb 2019 22:40:14 +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: Wed, 20 Feb 2019 23:39:47 +0100 Message-Id: <20190220224003.4420-2-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 20 Feb 2019 22:40:17 +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 v7 01/17] hw/arm/boot: introduce fdt_add_memory_node helper 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" From: Shameer Kolothum We introduce an helper to create a memory node. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum Reviewed-by: Igor Mammedov --- v6 -> v7: - msg error in the caller - add comment about NUMA ID --- hw/arm/boot.c | 54 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index d90af2f17d..a830655e1a 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -423,6 +423,32 @@ static void set_kernel_args_old(const struct arm_boot_= info *info, } } =20 +static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, + uint32_t scells, hwaddr mem_len, + int numa_node_id) +{ + char *nodename; + int ret; + + nodename =3D g_strdup_printf("/memory@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); + ret =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem= _base, + scells, mem_len); + if (ret < 0) { + goto out; + } + + /* only set the NUMA ID if it is specified */ + if (numa_node_id >=3D 0) { + ret =3D qemu_fdt_setprop_cell(fdt, nodename, + "numa-node-id", numa_node_id); + } +out: + g_free(nodename); + return ret; +} + static void fdt_add_psci_node(void *fdt) { uint32_t cpu_suspend_fn; @@ -502,7 +528,6 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_inf= o *binfo, void *fdt =3D NULL; int size, rc, n =3D 0; uint32_t acells, scells; - char *nodename; unsigned int i; hwaddr mem_base, mem_len; char **node_path; @@ -576,35 +601,24 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_i= nfo *binfo, mem_base =3D binfo->loader_start; for (i =3D 0; i < nb_numa_nodes; i++) { mem_len =3D numa_info[i].node_mem; - nodename =3D g_strdup_printf("/memory@%" PRIx64, mem_base); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"= ); - rc =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, mem_base, - scells, mem_len); + rc =3D fdt_add_memory_node(fdt, acells, mem_base, + scells, mem_len, i); if (rc < 0) { - fprintf(stderr, "couldn't set %s/reg for node %d\n", noden= ame, - i); + fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n", + mem_base); goto fail; } =20 - qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", i); mem_base +=3D mem_len; - g_free(nodename); } } else { - nodename =3D g_strdup_printf("/memory@%" PRIx64, binfo->loader_sta= rt); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); - - rc =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, binfo->loader_start, - scells, binfo->ram_size); + rc =3D fdt_add_memory_node(fdt, acells, binfo->loader_start, + scells, binfo->ram_size, -1); if (rc < 0) { - fprintf(stderr, "couldn't set %s reg\n", nodename); + fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n", + binfo->loader_start); goto fail; } - g_free(nodename); } =20 rc =3D fdt_path_offset(fdt, "/chosen"); --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155070256300159.95867472507575; Wed, 20 Feb 2019 14:42:43 -0800 (PST) Received: from localhost ([127.0.0.1]:49947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaZV-00055t-4h for importer@patchew.org; Wed, 20 Feb 2019 17:42:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXS-0003uw-Tz for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXR-0008Sh-QX for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXM-0008QA-Of; Wed, 20 Feb 2019 17:40:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7FDE3082E5A; Wed, 20 Feb 2019 22:40:19 +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 47EAE5D6AA; Wed, 20 Feb 2019 22:40:17 +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: Wed, 20 Feb 2019 23:39:48 +0100 Message-Id: <20190220224003.4420-3-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 20 Feb 2019 22:40:20 +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 v7 02/17] hw/arm/virt: Rename highmem IO regions 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" In preparation for a split of the memory map into a static part and a dynamic part floating after the RAM, let's rename the regions located after the RAM Signed-off-by: Eric Auger Reviewed-by: Peter Maydell Reviewed-by: Igor Mammedov --- v7: added Peter's R-b v6: creation --- hw/arm/virt-acpi-build.c | 8 ++++---- hw/arm/virt.c | 21 +++++++++++---------- include/hw/arm/virt.h | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 04b62c714d..829d2f0035 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -229,8 +229,8 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapE= ntry *memmap, size_pio)); =20 if (use_highmem) { - hwaddr base_mmio_high =3D memmap[VIRT_PCIE_MMIO_HIGH].base; - hwaddr size_mmio_high =3D memmap[VIRT_PCIE_MMIO_HIGH].size; + hwaddr base_mmio_high =3D memmap[VIRT_HIGH_PCIE_MMIO].base; + hwaddr size_mmio_high =3D memmap[VIRT_HIGH_PCIE_MMIO].size; =20 aml_append(rbuf, aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, @@ -663,8 +663,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) gicr =3D acpi_data_push(table_data, sizeof(*gicr)); gicr->type =3D ACPI_APIC_GENERIC_REDISTRIBUTOR; gicr->length =3D sizeof(*gicr); - gicr->base_address =3D cpu_to_le64(memmap[VIRT_GIC_REDIST2].ba= se); - gicr->range_length =3D cpu_to_le32(memmap[VIRT_GIC_REDIST2].si= ze); + gicr->base_address =3D cpu_to_le64(memmap[VIRT_HIGH_GIC_REDIST= 2].base); + gicr->range_length =3D cpu_to_le32(memmap[VIRT_HIGH_GIC_REDIST= 2].size); } =20 if (its_class_name() && !vmc->no_its) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 99c2b6e60d..a1955e7764 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -150,10 +150,10 @@ static const MemMapEntry a15memmap[] =3D { [VIRT_PCIE_ECAM] =3D { 0x3f000000, 0x01000000 }, [VIRT_MEM] =3D { 0x40000000, RAMLIMIT_BYTES }, /* Additional 64 MB redist region (can contain up to 512 redistributor= s) */ - [VIRT_GIC_REDIST2] =3D { 0x4000000000ULL, 0x4000000 }, - [VIRT_PCIE_ECAM_HIGH] =3D { 0x4010000000ULL, 0x10000000 }, + [VIRT_HIGH_GIC_REDIST2] =3D { 0x4000000000ULL, 0x4000000 }, + [VIRT_HIGH_PCIE_ECAM] =3D { 0x4010000000ULL, 0x10000000 }, /* Second PCIe window, 512GB wide at the 512GB boundary */ - [VIRT_PCIE_MMIO_HIGH] =3D { 0x8000000000ULL, 0x8000000000ULL }, + [VIRT_HIGH_PCIE_MMIO] =3D { 0x8000000000ULL, 0x8000000000ULL }, }; =20 static const int a15irqmap[] =3D { @@ -435,8 +435,8 @@ static void fdt_add_gic_node(VirtMachineState *vms) 2, vms->memmap[VIRT_GIC_DIST].siz= e, 2, vms->memmap[VIRT_GIC_REDIST].b= ase, 2, vms->memmap[VIRT_GIC_REDIST].s= ize, - 2, vms->memmap[VIRT_GIC_REDIST2].= base, - 2, vms->memmap[VIRT_GIC_REDIST2].= size); + 2, vms->memmap[VIRT_HIGH_GIC_REDI= ST2].base, + 2, vms->memmap[VIRT_HIGH_GIC_REDI= ST2].size); } =20 if (vms->virt) { @@ -584,7 +584,7 @@ static void create_gic(VirtMachineState *vms, qemu_irq = *pic) =20 if (nb_redist_regions =3D=3D 2) { uint32_t redist1_capacity =3D - vms->memmap[VIRT_GIC_REDIST2].size / GICV3_REDIST_= SIZE; + vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST= _SIZE; =20 qdev_prop_set_uint32(gicdev, "redist-region-count[1]", MIN(smp_cpus - redist0_count, redist1_capacity)); @@ -601,7 +601,8 @@ static void create_gic(VirtMachineState *vms, qemu_irq = *pic) if (type =3D=3D 3) { sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); if (nb_redist_regions =3D=3D 2) { - sysbus_mmio_map(gicbusdev, 2, vms->memmap[VIRT_GIC_REDIST2].ba= se); + sysbus_mmio_map(gicbusdev, 2, + vms->memmap[VIRT_HIGH_GIC_REDIST2].base); } } else { sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_CPU].base); @@ -1088,8 +1089,8 @@ static void create_pcie(VirtMachineState *vms, qemu_i= rq *pic) { hwaddr base_mmio =3D vms->memmap[VIRT_PCIE_MMIO].base; hwaddr size_mmio =3D vms->memmap[VIRT_PCIE_MMIO].size; - hwaddr base_mmio_high =3D vms->memmap[VIRT_PCIE_MMIO_HIGH].base; - hwaddr size_mmio_high =3D vms->memmap[VIRT_PCIE_MMIO_HIGH].size; + hwaddr base_mmio_high =3D vms->memmap[VIRT_HIGH_PCIE_MMIO].base; + hwaddr size_mmio_high =3D vms->memmap[VIRT_HIGH_PCIE_MMIO].size; hwaddr base_pio =3D vms->memmap[VIRT_PCIE_PIO].base; hwaddr size_pio =3D vms->memmap[VIRT_PCIE_PIO].size; hwaddr base_ecam, size_ecam; @@ -1418,7 +1419,7 @@ static void machvirt_init(MachineState *machine) */ if (vms->gic_version =3D=3D 3) { virt_max_cpus =3D vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST= _SIZE; - virt_max_cpus +=3D vms->memmap[VIRT_GIC_REDIST2].size / GICV3_REDI= ST_SIZE; + virt_max_cpus +=3D vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3= _REDIST_SIZE; } else { virt_max_cpus =3D GIC_NCPU; } diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 4cc57a7ef6..a27086d524 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -64,7 +64,7 @@ enum { VIRT_GIC_VCPU, VIRT_GIC_ITS, VIRT_GIC_REDIST, - VIRT_GIC_REDIST2, + VIRT_HIGH_GIC_REDIST2, VIRT_SMMU, VIRT_UART, VIRT_MMIO, @@ -74,9 +74,9 @@ enum { VIRT_PCIE_MMIO, VIRT_PCIE_PIO, VIRT_PCIE_ECAM, - VIRT_PCIE_ECAM_HIGH, + VIRT_HIGH_PCIE_ECAM, VIRT_PLATFORM_BUS, - VIRT_PCIE_MMIO_HIGH, + VIRT_HIGH_PCIE_MMIO, VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, @@ -128,7 +128,7 @@ typedef struct { int psci_conduit; } VirtMachineState; =20 -#define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) +#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) =20 #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") #define VIRT_MACHINE(obj) \ --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702998612462.3183898674845; Wed, 20 Feb 2019 14:49:58 -0800 (PST) Received: from localhost ([127.0.0.1]:50051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwagc-00030q-Hu for importer@patchew.org; Wed, 20 Feb 2019 17:49:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXW-0003wY-JQ for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXV-0008U0-GA for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59566) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXP-0008Rq-NY; Wed, 20 Feb 2019 17:40:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF27D3086275; Wed, 20 Feb 2019 22:40:22 +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 46B015D6AA; Wed, 20 Feb 2019 22:40:20 +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: Wed, 20 Feb 2019 23:39:49 +0100 Message-Id: <20190220224003.4420-4-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 20 Feb 2019 22:40:23 +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 v7 03/17] hw/arm/virt: Split the memory map description 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" In the prospect to introduce an extended memory map supporting more RAM, let's split the memory map array into two parts: - the former a15memmap contains regions below and including the RAM - extended_memmap, only initialized with entries located after the RAM. Only the size of the region is initialized there since their base address will be dynamically computed, depending on the top of the RAM (initial RAM at the moment), with same alignment as their size. This new split will allow to grow the RAM size without changing the description of the high regions. The patch also moves the memory map setup into machvirt_init(). The rationale is the memory map will be soon affected by the kvm_type() call that happens after virt_instance_init() and before machvirt_init(). The memory map is unchanged (the top of the initial RAM still is 256GiB). Then come the high IO regions with same layout as before. Signed-off-by: Eric Auger Reviewed-by: Peter Maydell --- v6 -> v7: - s/a15memmap/base_memmap - slight rewording of the commit message - add "if there is less than 256GiB of RAM then the floating area starts at the 256GiB mark" in the comment associated to the floating memory map - Added Peter's R-b v5 -> v6 - removal of many macros in units.h - introduce the virt_set_memmap helper - new computation for offsets of high IO regions - add comments --- hw/arm/virt.c | 48 +++++++++++++++++++++++++++++++++++++------ include/hw/arm/virt.h | 14 +++++++++---- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a1955e7764..12039a0367 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -29,6 +29,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "hw/sysbus.h" #include "hw/arm/arm.h" @@ -121,7 +122,7 @@ * Note that devices should generally be placed at multiples of 0x10000, * to accommodate guests using 64K pages. */ -static const MemMapEntry a15memmap[] =3D { +static const MemMapEntry base_memmap[] =3D { /* Space up to 0x8000000 is reserved for a boot ROM */ [VIRT_FLASH] =3D { 0, 0x08000000 }, [VIRT_CPUPERIPHS] =3D { 0x08000000, 0x00020000 }, @@ -149,11 +150,21 @@ static const MemMapEntry a15memmap[] =3D { [VIRT_PCIE_PIO] =3D { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] =3D { 0x3f000000, 0x01000000 }, [VIRT_MEM] =3D { 0x40000000, RAMLIMIT_BYTES }, +}; + +/* + * Highmem IO Regions: This memory map is floating, located after the RAM. + * Each IO region offset will be dynamically computed, depending on the + * top of the RAM, so that its base get the same alignment as the size, + * ie. a 512GiB region will be aligned on a 512GiB boundary. If there is + * less than 256GiB of RAM, the floating area starts at the 256GiB mark. + */ +static MemMapEntry extended_memmap[] =3D { /* Additional 64 MB redist region (can contain up to 512 redistributor= s) */ - [VIRT_HIGH_GIC_REDIST2] =3D { 0x4000000000ULL, 0x4000000 }, - [VIRT_HIGH_PCIE_ECAM] =3D { 0x4010000000ULL, 0x10000000 }, - /* Second PCIe window, 512GB wide at the 512GB boundary */ - [VIRT_HIGH_PCIE_MMIO] =3D { 0x8000000000ULL, 0x8000000000ULL }, + [VIRT_HIGH_GIC_REDIST2] =3D { 0x0, 64 * MiB }, + [VIRT_HIGH_PCIE_ECAM] =3D { 0x0, 256 * MiB }, + /* Second PCIe window */ + [VIRT_HIGH_PCIE_MMIO] =3D { 0x0, 512 * GiB }, }; =20 static const int a15irqmap[] =3D { @@ -1354,6 +1365,30 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineStat= e *vms, int idx) return arm_cpu_mp_affinity(idx, clustersz); } =20 +static void virt_set_memmap(VirtMachineState *vms) +{ + hwaddr base; + int i; + + vms->memmap =3D extended_memmap; + + for (i =3D 0; i < ARRAY_SIZE(base_memmap); i++) { + vms->memmap[i] =3D base_memmap[i]; + } + + vms->high_io_base =3D 256 * GiB; /* Top of the legacy initial RAM regi= on */ + base =3D vms->high_io_base; + + for (i =3D VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { + hwaddr size =3D extended_memmap[i].size; + + base =3D ROUND_UP(base, size); + vms->memmap[i].base =3D base; + vms->memmap[i].size =3D size; + base +=3D size; + } +} + static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); @@ -1368,6 +1403,8 @@ static void machvirt_init(MachineState *machine) bool firmware_loaded =3D bios_name || drive_get(IF_PFLASH, 0, 0); bool aarch64 =3D true; =20 + virt_set_memmap(vms); + /* We can probe only here because during property set * KVM is not available yet */ @@ -1843,7 +1880,6 @@ static void virt_instance_init(Object *obj) "Valid values are none and smmuv3", NULL); =20 - vms->memmap =3D a15memmap; vms->irqmap =3D a15irqmap; } =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index a27086d524..3dc7a6c5d5 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -64,7 +64,6 @@ enum { VIRT_GIC_VCPU, VIRT_GIC_ITS, VIRT_GIC_REDIST, - VIRT_HIGH_GIC_REDIST2, VIRT_SMMU, VIRT_UART, VIRT_MMIO, @@ -74,12 +73,18 @@ enum { VIRT_PCIE_MMIO, VIRT_PCIE_PIO, VIRT_PCIE_ECAM, - VIRT_HIGH_PCIE_ECAM, VIRT_PLATFORM_BUS, - VIRT_HIGH_PCIE_MMIO, VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_LOWMEMMAP_LAST, +}; + +/* indices of IO regions located after the RAM */ +enum { + VIRT_HIGH_GIC_REDIST2 =3D VIRT_LOWMEMMAP_LAST, + VIRT_HIGH_PCIE_ECAM, + VIRT_HIGH_PCIE_MMIO, }; =20 typedef enum VirtIOMMUType { @@ -116,7 +121,7 @@ typedef struct { int32_t gic_version; VirtIOMMUType iommu; struct arm_boot_info bootinfo; - const MemMapEntry *memmap; + MemMapEntry *memmap; const int *irqmap; int smp_cpus; void *fdt; @@ -126,6 +131,7 @@ typedef struct { uint32_t msi_phandle; uint32_t iommu_phandle; int psci_conduit; + hwaddr high_io_base; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702851305481.03255245849016; Wed, 20 Feb 2019 14:47:31 -0800 (PST) Received: from localhost ([127.0.0.1]:50017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaeI-0000kI-8o for importer@patchew.org; Wed, 20 Feb 2019 17:47:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXX-0003xd-GS for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXW-0008UW-Gs for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55254) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXS-0008T2-Tf; Wed, 20 Feb 2019 17:40:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E98C53082E5A; Wed, 20 Feb 2019 22:40:25 +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 554AC5D6AA; Wed, 20 Feb 2019 22:40:23 +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: Wed, 20 Feb 2019 23:39:50 +0100 Message-Id: <20190220224003.4420-5-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 20 Feb 2019 22:40:26 +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 v7 04/17] hw/boards: Add a MachineState parameter to kvm_type callback 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" On ARM, the kvm_type will be resolved by querying the KVMState. Let's add the MachineState handle to the callback so that we can retrieve the KVMState handle. in kvm_init, when the callback is called, the kvm_state variable is not yet set. Signed-off-by: Eric Auger Acked-by: David Gibson [ppc parts] Reviewed-by: Peter Maydell Reviewed-by: Igor Mammedov --- v6 -> v7: - add a comment for kvm_type - use machine instead of ms in the declaration - add Peter's R-b --- accel/kvm/kvm-all.c | 2 +- hw/ppc/mac_newworld.c | 3 +-- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/boards.h | 5 ++++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index fd92b6f375..241db496c3 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1593,7 +1593,7 @@ static int kvm_init(MachineState *ms) =20 kvm_type =3D qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); if (mc->kvm_type) { - type =3D mc->kvm_type(kvm_type); + type =3D mc->kvm_type(ms, kvm_type); } else if (kvm_type) { ret =3D -EINVAL; fprintf(stderr, "Invalid argument kvm-type=3D%s\n", kvm_type); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 98461052ac..97e8817145 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -564,8 +564,7 @@ static char *core99_fw_dev_path(FWPathProvider *p, BusS= tate *bus, =20 return NULL; } - -static int core99_kvm_type(const char *arg) +static int core99_kvm_type(MachineState *machine, const char *arg) { /* Always force PR KVM */ return 2; diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 284431ddd6..cc1e463466 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -420,7 +420,7 @@ static char *heathrow_fw_dev_path(FWPathProvider *p, Bu= sState *bus, return NULL; } =20 -static int heathrow_kvm_type(const char *arg) +static int heathrow_kvm_type(MachineState *machine, const char *arg) { /* Always force PR KVM */ return 2; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index abf9ebce59..3d0811fa81 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2920,7 +2920,7 @@ static void spapr_machine_init(MachineState *machine) } } =20 -static int spapr_kvm_type(const char *vm_type) +static int spapr_kvm_type(MachineState *machine, const char *vm_type) { if (!vm_type) { return 0; diff --git a/include/hw/boards.h b/include/hw/boards.h index 05f9f45c3d..ed2fec82d5 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -156,6 +156,9 @@ typedef struct { * should instead use "unimplemented-device" for all memory ranges where * the guest will attempt to probe for a device that QEMU doesn't * implement and a stub device is required. + * @kvm_type: + * Return the type of KVM corresponding to the kvm-type string option or + * computed based on other criteria such as the host kernel capabilitie= s. */ struct MachineClass { /*< private >*/ @@ -171,7 +174,7 @@ struct MachineClass { void (*init)(MachineState *state); void (*reset)(void); void (*hot_add_cpu)(const int64_t id, Error **errp); - int (*kvm_type)(const char *arg); + int (*kvm_type)(MachineState *machine, const char *arg); =20 BlockInterfaceType block_default_type; int units_per_default_bus; --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703024804464.10041624712994; Wed, 20 Feb 2019 14:50:24 -0800 (PST) Received: from localhost ([127.0.0.1]:50053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwah1-0003Kb-Mm for importer@patchew.org; Wed, 20 Feb 2019 17:50:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXd-00042x-0z for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXc-0008WQ-7y for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58236) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXa-0008VJ-8J; Wed, 20 Feb 2019 17:40:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6C5EC049D67; Wed, 20 Feb 2019 22:40:32 +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 43FF45D6AA; Wed, 20 Feb 2019 22:40:26 +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: Wed, 20 Feb 2019 23:39:51 +0100 Message-Id: <20190220224003.4420-6-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 22:40:32 +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 v7 05/17] kvm: add kvm_arm_get_max_vm_ipa_size 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" Add the kvm_arm_get_max_vm_ipa_size() helper that returns the number of bits in the IPA address space supported by KVM. This capability needs to be known to create the VM with a specific IPA max size (kvm_type passed along KVM_CREATE_VM ioctl. Signed-off-by: Eric Auger --- v6 -> v7: - s/kvm_arm_get_max_vm_phys_shift/kvm_arm_get_max_vm_ipa_size - reword the comment v4 -> v5: - return 40 if the host does not support the capability v3 -> v4: - s/s/ms in kvm_arm_get_max_vm_phys_shift function comment - check KVM_CAP_ARM_VM_IPA_SIZE extension v1 -> v2: - put this in ARM specific code --- target/arm/kvm.c | 10 ++++++++++ target/arm/kvm_arm.h | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index e00ccf9c98..79a79f0190 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" +#include "sysemu/kvm_int.h" #include "kvm_arm.h" #include "cpu.h" #include "trace.h" @@ -162,6 +163,15 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) env->features =3D arm_host_cpu_features.features; } =20 +int kvm_arm_get_max_vm_ipa_size(MachineState *ms) +{ + KVMState *s =3D KVM_STATE(ms->accelerator); + int ret; + + ret =3D kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE); + return ret > 0 ? ret : 40; +} + int kvm_arch_init(MachineState *ms, KVMState *s) { /* For ARM interrupt delivery is always asynchronous, diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 6393455b1d..2a07333c61 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -207,6 +207,14 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures = *ahcf); */ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); =20 +/** + * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the + * IPA address space supported by KVM + * + * @ms: Machine state handle + */ +int kvm_arm_get_max_vm_ipa_size(MachineState *ms); + /** * kvm_arm_sync_mpstate_to_kvm * @cpu: ARMCPU @@ -239,6 +247,11 @@ static inline void kvm_arm_set_cpu_features_from_host(= ARMCPU *cpu) cpu->host_cpu_probe_failed =3D true; } =20 +static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) +{ + return -ENOENT; +} + static inline int kvm_arm_vgic_probe(void) { return 0; --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15507031769201012.5767281156681; Wed, 20 Feb 2019 14:52:56 -0800 (PST) Received: from localhost ([127.0.0.1]:50118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwajX-0005Cu-Ro for importer@patchew.org; Wed, 20 Feb 2019 17:52:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXj-00049n-0e for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXg-00006U-Rd for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXc-0008WJ-T3; Wed, 20 Feb 2019 17:40:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4310C0467D9; Wed, 20 Feb 2019 22:40:35 +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 2C1D25D6AA; Wed, 20 Feb 2019 22:40:32 +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: Wed, 20 Feb 2019 23:39:52 +0100 Message-Id: <20190220224003.4420-7-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 22:40:35 +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 v7 06/17] vl: Set machine ram_size, maxram_size and ram_slots earlier 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 machine RAM attributes will need to be analyzed during the configure_accelerator() process. especially kvm_type() arm64 machine callback will use them to know how many IPA/GPA bits are needed to model the whole RAM range. So let's assign those machine state fields before calling configure_accelerator. Signed-off-by: Eric Auger Reviewed-by: Peter Maydell Reviewed-by: Igor Mammedov --- v6 -> v7: - add Peter's R-b v4: new --- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 502857a176..fd0d51320d 100644 --- a/vl.c +++ b/vl.c @@ -4239,6 +4239,9 @@ int main(int argc, char **argv, char **envp) machine_opts =3D qemu_get_machine_opts(); qemu_opt_foreach(machine_opts, machine_set_property, current_machine, &error_fatal); + current_machine->ram_size =3D ram_size; + current_machine->maxram_size =3D maxram_size; + current_machine->ram_slots =3D ram_slots; =20 configure_accelerator(current_machine, argv[0]); =20 @@ -4434,9 +4437,6 @@ int main(int argc, char **argv, char **envp) replay_checkpoint(CHECKPOINT_INIT); qdev_machine_init(); =20 - current_machine->ram_size =3D ram_size; - current_machine->maxram_size =3D maxram_size; - current_machine->ram_slots =3D ram_slots; current_machine->boot_order =3D boot_order; =20 /* parse features once if machine provides default cpu_type */ --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703187638753.7158644602101; Wed, 20 Feb 2019 14:53:07 -0800 (PST) Received: from localhost ([127.0.0.1]:50120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwajh-0005L9-H6 for importer@patchew.org; Wed, 20 Feb 2019 17:53:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXq-0004FF-5z for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXm-00009v-8L for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXg-00005x-Pv; Wed, 20 Feb 2019 17:40:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0098C049D67; Wed, 20 Feb 2019 22:40:38 +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 27EFB5D6AA; Wed, 20 Feb 2019 22:40:35 +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: Wed, 20 Feb 2019 23:39:53 +0100 Message-Id: <20190220224003.4420-8-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 22:40:38 +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 v7 07/17] hw/arm/virt: Dynamic memory map depending on RAM requirements 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" Up to now the memory map has been static and the high IO region base has always been 256GiB. This patch modifies the virt_set_memmap() function, which freezes the memory map, so that the high IO range base becomes floating, located after the initial RAM and the device memory. The function computes - the base of the device memory, - the size of the device memory and - the highest GPA used in the memory map. The two former will be used when defining the device memory region while the latter will be used at VM creation to choose the requested IPA size. Setting all the existing highmem IO regions beyond the RAM allows to have a single contiguous RAM region (initial RAM and possible hotpluggable device memory). That way we do not need to do invasive changes in the EDK2 FW to support a dynamic RAM base. Still the user cannot request an initial RAM size greater than 255GB. Also we handle the case where maxmem or slots options are passed, although no device memory is usable at the moment. In this case, we just ignore those settings. Signed-off-by: Eric Auger --- hw/arm/virt.c | 47 ++++++++++++++++++++++++++++++++++--------- include/hw/arm/virt.h | 3 +++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 12039a0367..9db602457b 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -107,8 +107,9 @@ * of a terabyte of RAM will be doing it on a host with more than a * terabyte of physical address space.) */ -#define RAMLIMIT_GB 255 -#define RAMLIMIT_BYTES (RAMLIMIT_GB * 1024ULL * 1024 * 1024) +#define RAMBASE GiB +#define LEGACY_RAMLIMIT_GB 255 +#define LEGACY_RAMLIMIT_BYTES (LEGACY_RAMLIMIT_GB * GiB) =20 /* Addresses and sizes of our components. * 0..128MB is space for a flash device so we can run bootrom code such as= UEFI. @@ -149,7 +150,7 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_PCIE_MMIO] =3D { 0x10000000, 0x2eff0000 }, [VIRT_PCIE_PIO] =3D { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] =3D { 0x3f000000, 0x01000000 }, - [VIRT_MEM] =3D { 0x40000000, RAMLIMIT_BYTES }, + [VIRT_MEM] =3D { RAMBASE, LEGACY_RAMLIMIT_BYTES }, }; =20 /* @@ -1367,16 +1368,48 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineSta= te *vms, int idx) =20 static void virt_set_memmap(VirtMachineState *vms) { + MachineState *ms =3D MACHINE(vms); hwaddr base; int i; =20 + if (ms->maxram_size > ms->ram_size || ms->ram_slots > 0) { + error_report("mach-virt: does not support device memory: " + "ignore maxmem and slots options"); + ms->maxram_size =3D ms->ram_size; + ms->ram_slots =3D 0; + } + if (ms->ram_size > (ram_addr_t)LEGACY_RAMLIMIT_BYTES) { + error_report("mach-virt: cannot model more than %dGB RAM", + LEGACY_RAMLIMIT_GB); + exit(1); + } + vms->memmap =3D extended_memmap; =20 for (i =3D 0; i < ARRAY_SIZE(base_memmap); i++) { vms->memmap[i] =3D base_memmap[i]; } =20 - vms->high_io_base =3D 256 * GiB; /* Top of the legacy initial RAM regi= on */ + /* + * We compute the base of the high IO region depending on the + * amount of initial and device memory. The device memory start/size + * is aligned on 1GiB. We never put the high IO region below 256GiB + * so that if maxram_size is < 255GiB we keep the legacy memory map. + * The device region size assumes 1GiB page max alignment per slot. + */ + vms->device_memory_base =3D ROUND_UP(RAMBASE + ms->ram_size, GiB); + vms->device_memory_size =3D ms->maxram_size - ms->ram_size + + ms->ram_slots * GiB; + + vms->high_io_base =3D vms->device_memory_base + + ROUND_UP(vms->device_memory_size, GiB); + if (vms->high_io_base < vms->device_memory_base) { + error_report("maxmem/slots too huge"); + exit(EXIT_FAILURE); + } + if (vms->high_io_base < 256 * GiB) { + vms->high_io_base =3D 256 * GiB; + } base =3D vms->high_io_base; =20 for (i =3D VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { @@ -1387,6 +1420,7 @@ static void virt_set_memmap(VirtMachineState *vms) vms->memmap[i].size =3D size; base +=3D size; } + vms->highest_gpa =3D base - 1; } =20 static void machvirt_init(MachineState *machine) @@ -1470,11 +1504,6 @@ static void machvirt_init(MachineState *machine) =20 vms->smp_cpus =3D smp_cpus; =20 - if (machine->ram_size > vms->memmap[VIRT_MEM].size) { - error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMI= T_GB); - exit(1); - } - if (vms->virt && kvm_enabled()) { error_report("mach-virt: KVM does not support providing " "Virtualization extensions to the guest CPU"); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 3dc7a6c5d5..acad0400d8 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -132,6 +132,9 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr high_io_base; + hwaddr highest_gpa; + hwaddr device_memory_base; + hwaddr device_memory_size; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703325001140.69720016589542; Wed, 20 Feb 2019 14:55:25 -0800 (PST) Received: from localhost ([127.0.0.1]:50148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwalt-0007Ay-R3 for importer@patchew.org; Wed, 20 Feb 2019 17:55:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaXt-0004ID-OT for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaXq-0000BB-Ay for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:40:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXj-00008D-1d; Wed, 20 Feb 2019 17:40:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C20FA85376; Wed, 20 Feb 2019 22:40:41 +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 28BDE5D6AA; Wed, 20 Feb 2019 22:40:38 +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: Wed, 20 Feb 2019 23:39:54 +0100 Message-Id: <20190220224003.4420-9-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Feb 2019 22:40:41 +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 v7 08/17] hw/arm/virt: Implement kvm_type function for 4.0 machine 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" This patch implements the machine class kvm_type() callback. It returns the number of bits requested to implement the whole GPA range including the RAM and IO regions located beyond. The returned value in passed though the KVM_CREATE_VM ioctl and this allows KVM to set the stage2 tables dynamically. Signed-off-by: Eric Auger --- v6 -> v7: - Introduce RAMBASE and rename add LEGACY_ prefix in that patch - use local variables with explicit names in virt_set_memmap: device_memory_base, device_memory_size - add an extended_memmap field in the class v5 -> v6: - add some comments - high IO region cannot start before 256GiB --- hw/arm/virt.c | 50 ++++++++++++++++++++++++++++++++++++++++++- include/hw/arm/virt.h | 2 ++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9db602457b..ad3a0ad73d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1437,7 +1437,14 @@ static void machvirt_init(MachineState *machine) bool firmware_loaded =3D bios_name || drive_get(IF_PFLASH, 0, 0); bool aarch64 =3D true; =20 - virt_set_memmap(vms); + /* + * In accelerated mode, the memory map is computed in kvm_type(), + * if set, to create a VM with the right number of IPA bits. + */ + + if (!mc->kvm_type || !kvm_enabled()) { + virt_set_memmap(vms); + } =20 /* We can probe only here because during property set * KVM is not available yet @@ -1814,6 +1821,36 @@ static HotplugHandler *virt_machine_get_hotplug_hand= ler(MachineState *machine, return NULL; } =20 +/* + * for arm64 kvm_type [7-0] encodes the requested number of bits + * in the IPA address space + */ +static int virt_kvm_type(MachineState *ms, const char *type_str) +{ + VirtMachineState *vms =3D VIRT_MACHINE(ms); + int max_vm_pa_size =3D kvm_arm_get_max_vm_ipa_size(ms); + int requested_pa_size; + + /* we freeze the memory map to compute the highest gpa */ + virt_set_memmap(vms); + + requested_pa_size =3D 64 - clz64(vms->highest_gpa); + + if (requested_pa_size > max_vm_pa_size) { + error_report("-m and ,maxmem option values " + "require an IPA range (%d bits) larger than " + "the one supported by the host (%d bits)", + requested_pa_size, max_vm_pa_size); + exit(1); + } + /* + * By default we return 0 which corresponds to an implicit legacy + * 40b IPA setting. Otherwise we return the actual requested PA + * logsize + */ + return requested_pa_size > 40 ? requested_pa_size : 0; +} + static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1838,6 +1875,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->cpu_index_to_instance_props =3D virt_cpu_index_to_props; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a15"); mc->get_default_cpu_node_id =3D virt_get_default_cpu_node_id; + mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->plug =3D virt_machine_device_plug_cb; @@ -1909,6 +1947,12 @@ static void virt_instance_init(Object *obj) "Valid values are none and smmuv3", NULL); =20 + if (vmc->no_extended_memmap) { + vms->extended_memmap =3D false; + } else { + vms->extended_memmap =3D true; + } + vms->irqmap =3D a15irqmap; } =20 @@ -1939,8 +1983,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 0) =20 static void virt_machine_3_1_options(MachineClass *mc) { + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); virt_machine_4_0_options(mc); compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); + + /* extended memory map is enabled from 4.0 onwards */ + vmc->no_extended_memmap =3D true; } DEFINE_VIRT_MACHINE(3, 1) =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index acad0400d8..7798462cb0 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -106,6 +106,7 @@ typedef struct { bool claim_edge_triggered_timers; bool smbios_old_sys_ver; bool no_highmem_ecam; + bool no_extended_memmap; } VirtMachineClass; =20 typedef struct { @@ -135,6 +136,7 @@ typedef struct { hwaddr highest_gpa; hwaddr device_memory_base; hwaddr device_memory_size; + bool extended_memmap; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702634597872.1664038368784; Wed, 20 Feb 2019 14:43:54 -0800 (PST) Received: from localhost ([127.0.0.1]:49954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaal-00063h-H0 for importer@patchew.org; Wed, 20 Feb 2019 17:43:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaY4-0004Ml-US for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaY3-0000No-Ny for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaXu-00009Q-4K; Wed, 20 Feb 2019 17:40:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5F6583F45; Wed, 20 Feb 2019 22:40:44 +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 28FAA5D6AA; Wed, 20 Feb 2019 22:40:41 +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: Wed, 20 Feb 2019 23:39:55 +0100 Message-Id: <20190220224003.4420-10-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Feb 2019 22:40:44 +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 v7 09/17] hw/arm/virt: Bump the 255GB initial RAM limit 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" Now we have the extended memory map (high IO regions beyond the scalable RAM) and dynamic IPA range support at KVM/ARM level we can bump the legacy 255GB initial RAM limit. The actual maximum RAM size now depends on the physical CPU and host kernel. Signed-off-by: Eric Auger --- v6 -> v7 - handle TCG case - set_memmap modifications moved to previous patches --- hw/arm/virt.c | 54 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ad3a0ad73d..5b656f9db5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -59,6 +59,7 @@ #include "qapi/visitor.h" #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" +#include "target/arm/internals.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -93,21 +94,8 @@ =20 #define PLATFORM_BUS_NUM_IRQS 64 =20 -/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means - * RAM can go up to the 256GB mark, leaving 256GB of the physical - * address space unallocated and free for future use between 256G and 512G. - * If we need to provide more RAM to VMs in the future then we need to: - * * allocate a second bank of RAM starting at 2TB and working up - * * fix the DT and ACPI table generation code in QEMU to correctly - * report two split lumps of RAM to the guest - * * fix KVM in the host kernel to allow guests with >40 bit address spac= es - * (We don't want to fill all the way up to 512GB with RAM because - * we might want it for non-RAM purposes later. Conversely it seems - * reasonable to assume that anybody configuring a VM with a quarter - * of a terabyte of RAM will be doing it on a host with more than a - * terabyte of physical address space.) - */ #define RAMBASE GiB +/* Legacy RAM limit in GB (< version 4.0) */ #define LEGACY_RAMLIMIT_GB 255 #define LEGACY_RAMLIMIT_BYTES (LEGACY_RAMLIMIT_GB * GiB) =20 @@ -1372,16 +1360,18 @@ static void virt_set_memmap(VirtMachineState *vms) hwaddr base; int i; =20 - if (ms->maxram_size > ms->ram_size || ms->ram_slots > 0) { - error_report("mach-virt: does not support device memory: " - "ignore maxmem and slots options"); - ms->maxram_size =3D ms->ram_size; - ms->ram_slots =3D 0; - } - if (ms->ram_size > (ram_addr_t)LEGACY_RAMLIMIT_BYTES) { - error_report("mach-virt: cannot model more than %dGB RAM", - LEGACY_RAMLIMIT_GB); - exit(1); + if (!vms->extended_memmap) { + if (ms->maxram_size > ms->ram_size || ms->ram_slots > 0) { + error_report("mach-virt: does not support device memory: " + "ignore maxmem and slots options"); + ms->maxram_size =3D ms->ram_size; + ms->ram_slots =3D 0; + } + if (ms->ram_size > (ram_addr_t)LEGACY_RAMLIMIT_BYTES) { + error_report("mach-virt: cannot model more than %dGB RAM", + LEGACY_RAMLIMIT_GB); + exit(1); + } } =20 vms->memmap =3D extended_memmap; @@ -1598,6 +1588,22 @@ static void machvirt_init(MachineState *machine) fdt_add_timer_nodes(vms); fdt_add_cpu_nodes(vms); =20 + if (!kvm_enabled()) { + ARMCPU *cpu =3D ARM_CPU(first_cpu); + bool aarch64 =3D object_property_get_bool(OBJECT(cpu), "aarch64", = NULL); + + if (aarch64 && vms->highmem) { + int requested_pa_size, pamax =3D arm_pamax(cpu); + + requested_pa_size =3D 64 - clz64(vms->highest_gpa); + if (pamax < requested_pa_size) { + error_report("VCPU supports less PA bits (%d) than request= ed " + "by the memory map (%d)", pamax, requested_pa_= size); + exit(1); + } + } + } + memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram", machine->ram_size); memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702604344143.21295270837447; Wed, 20 Feb 2019 14:43:24 -0800 (PST) Received: from localhost ([127.0.0.1]:49951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaaH-0005hP-9t for importer@patchew.org; Wed, 20 Feb 2019 17:43:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaYA-0004Py-45 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaY8-0000Vy-Kv for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaY3-0000Bx-UB; Wed, 20 Feb 2019 17:41:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE8C7307D8E2; Wed, 20 Feb 2019 22:40:51 +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 28A0C5D6AA; Wed, 20 Feb 2019 22:40:44 +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: Wed, 20 Feb 2019 23:39:56 +0100 Message-Id: <20190220224003.4420-11-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 20 Feb 2019 22:40:51 +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 v7 10/17] hw/arm/virt: Add memory hotplug framework 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" This patch adds the the memory hot-plug/hot-unplug infrastructure in machvirt. It is still not enabled as no device memory is allocated. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum Signed-off-by: Kwangwoo Lee Reviewed-by: Igor Mammedov --- v4 -> v5: - change in pc_dimm_pre_plug signature - CONFIG_MEM_HOTPLUG replaced by CONFIG_MEM_DEVICE and CONFIG_DIMM v3 -> v4: - check the memory device is not hotplugged v2 -> v3: - change in pc_dimm_plug()'s signature - add pc_dimm_pre_plug call v1 -> v2: - s/virt_dimm_plug|unplug/virt_memory_plug|unplug - s/pc_dimm_memory_plug/pc_dimm_plug - reworded title and commit message - added pre_plug cb - don't handle get_memory_region failure anymore --- default-configs/arm-softmmu.mak | 2 ++ hw/arm/virt.c | 64 ++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.= mak index 734ca721e9..0a78421f72 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -163,3 +163,5 @@ CONFIG_PCI_EXPRESS_DESIGNWARE=3Dy CONFIG_STRONGARM=3Dy CONFIG_HIGHBANK=3Dy CONFIG_MUSICPAL=3Dy +CONFIG_MEM_DEVICE=3Dy +CONFIG_DIMM=3Dy diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5b656f9db5..470ca0ce2d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -60,6 +60,8 @@ #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" #include "target/arm/internals.h" +#include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1804,6 +1806,49 @@ static const CPUArchIdList *virt_possible_cpu_arch_i= ds(MachineState *ms) return ms->possible_cpus; } =20 +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, + Error **errp) +{ + const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + if (dev->hotplugged) { + error_setg(errp, "memory hotplug is not supported"); + } + + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); + return; + } + + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + Error *local_err =3D NULL; + + pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + + error_propagate(errp, local_err); +} + +static void virt_memory_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + pc_dimm_unplug(PC_DIMM(dev), MACHINE(hotplug_dev)); + object_unparent(OBJECT(dev)); +} + +static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_pre_plug(hotplug_dev, dev, errp); + } +} + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1815,12 +1860,27 @@ static void virt_machine_device_plug_cb(HotplugHand= ler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_unplug(hotplug_dev, dev, errp); + } else { + error_setg(errp, "device unplug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } =20 static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } =20 @@ -1884,7 +1944,9 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; + hc->pre_plug =3D virt_machine_device_pre_plug_cb; hc->plug =3D virt_machine_device_plug_cb; + hc->unplug =3D virt_machine_device_unplug_cb; } =20 static void virt_instance_init(Object *obj) --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703587972112.46006798279598; Wed, 20 Feb 2019 14:59:47 -0800 (PST) Received: from localhost ([127.0.0.1]:50223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaq2-0001rZ-Us for importer@patchew.org; Wed, 20 Feb 2019 17:59:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaY9-0004PJ-IJ for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaY8-0000Vl-IF for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58380) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaY1-0000D8-N8; Wed, 20 Feb 2019 17:41:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3F52C049E24; Wed, 20 Feb 2019 22:40:54 +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 3073F5D6AA; Wed, 20 Feb 2019 22:40:52 +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: Wed, 20 Feb 2019 23:39:57 +0100 Message-Id: <20190220224003.4420-12-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 22:40:54 +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 v7 11/17] hw/arm/boot: Expose the PC-DIMM nodes in the DT 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" From: Shameer Kolothum This patch adds memory nodes corresponding to PC-DIMM regions. NV_DIMM and ACPI_NVDIMM configs are not yet set for ARM so we don't need to care about NV-DIMM at this stage. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov --- v6 -> v7: - rework the error messages, use a switch/case v3 -> v4: - git rid of @base and @len in fdt_add_hotpluggable_memory_nodes v1 -> v2: - added qapi_free_MemoryDeviceInfoList and simplify the loop --- hw/arm/boot.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index a830655e1a..255aaca0cf 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -19,6 +19,7 @@ #include "sysemu/numa.h" #include "hw/boards.h" #include "hw/loader.h" +#include "hw/mem/memory-device.h" #include "elf.h" #include "sysemu/device_tree.h" #include "qemu/config-file.h" @@ -522,6 +523,41 @@ static void fdt_add_psci_node(void *fdt) qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); } =20 +static int fdt_add_hotpluggable_memory_nodes(void *fdt, + uint32_t acells, uint32_t sce= lls) { + MemoryDeviceInfoList *info, *info_list =3D qmp_memory_device_list(); + MemoryDeviceInfo *mi; + int ret =3D 0; + + for (info =3D info_list; info !=3D NULL; info =3D info->next) { + mi =3D info->value; + switch (mi->type) { + case MEMORY_DEVICE_INFO_KIND_DIMM: + { + PCDIMMDeviceInfo *di =3D mi->u.dimm.data; + + ret =3D fdt_add_memory_node(fdt, acells, di->addr, + scells, di->size, di->node); + if (ret) { + fprintf(stderr, + "couldn't add PCDIMM /memory@%"PRIx64" node\n", + di->addr); + goto out; + } + break; + } + default: + fprintf(stderr, "%s memory nodes are not yet supported\n", + MemoryDeviceInfoKind_str(mi->type)); + ret =3D -ENOENT; + goto out; + } + } +out: + qapi_free_MemoryDeviceInfoList(info_list); + return ret; +} + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr addr_limit, AddressSpace *as) { @@ -621,6 +657,12 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_in= fo *binfo, } } =20 + rc =3D fdt_add_hotpluggable_memory_nodes(fdt, acells, scells); + if (rc < 0) { + fprintf(stderr, "couldn't add hotpluggable memory nodes\n"); + goto fail; + } + rc =3D fdt_path_offset(fdt, "/chosen"); if (rc < 0) { qemu_fdt_add_subnode(fdt, "/chosen"); --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703457049501.1059500222177; Wed, 20 Feb 2019 14:57:37 -0800 (PST) Received: from localhost ([127.0.0.1]:50200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwao2-0000GT-3v for importer@patchew.org; Wed, 20 Feb 2019 17:57:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaY7-0004No-Ve for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaY5-0000SE-TT for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59186) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaY1-0000H7-Mc; Wed, 20 Feb 2019 17:41:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2EF1307D8BE; Wed, 20 Feb 2019 22:40:57 +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 2F71E5D6AA; Wed, 20 Feb 2019 22:40:54 +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: Wed, 20 Feb 2019 23:39:58 +0100 Message-Id: <20190220224003.4420-13-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 20 Feb 2019 22:40:57 +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 v7 12/17] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT 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" From: Shameer Kolothum Generate Memory Affinity Structures for PC-DIMM ranges. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov --- v6 -> v7: - add Igor's R-b v5 -> v6: - fix mingw compil issue v4 -> v5: - Align to x86 code and especially "pc: acpi: revert back to 1 SRAT entry for hotpluggable area" v3 -> v4: - do not use vms->bootinfo.device_memory_start/device_memory_size anymore v1 -> v2: - build_srat_hotpluggable_memory movedc to aml-build --- hw/arm/virt-acpi-build.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 829d2f0035..781eafaf5e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -516,6 +516,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); + MachineState *ms =3D MACHINE(vms); const CPUArchIdList *cpu_list =3D mc->possible_cpu_arch_ids(MACHINE(vm= s)); =20 srat_start =3D table_data->len; @@ -541,6 +542,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) } } =20 + if (ms->device_memory) { + numamem =3D acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, ms->device_memory->base, + memory_region_size(&ms->device_memory->mr), + nb_numa_nodes - 1, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); + } + build_header(linker, table_data, (void *)(table_data->data + srat_star= t), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703327345475.0827721625308; Wed, 20 Feb 2019 14:55:27 -0800 (PST) Received: from localhost ([127.0.0.1]:50151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwalv-0007C5-DF for importer@patchew.org; Wed, 20 Feb 2019 17:55:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaY9-0004PY-PO for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaY8-0000Vr-J1 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaY3-0000JB-N1; Wed, 20 Feb 2019 17:41:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C87E33081244; Wed, 20 Feb 2019 22:41:00 +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 2891D5D6B3; Wed, 20 Feb 2019 22:40:57 +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: Wed, 20 Feb 2019 23:39:59 +0100 Message-Id: <20190220224003.4420-14-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 20 Feb 2019 22:41:00 +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 v7 13/17] 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 --- v6 -> v7: - check the device memory top does not wrap - check the device memory can fit the slots 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 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 470ca0ce2d..33ad9b3f63 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -62,6 +62,7 @@ #include "target/arm/internals.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, \ @@ -1263,6 +1264,34 @@ 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); + + if (!vms->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, GiB) !=3D ms->maxram_size) { + error_report("maximum memory size must be GiB aligned"); + exit(EXIT_FAILURE); + } + + ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); + ms->device_memory->base =3D vms->device_memory_base; + + memory_region_init(&ms->device_memory->mr, OBJECT(vms), + "device-memory", vms->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, @@ -1610,6 +1639,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 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703668458994.5999798821388; Wed, 20 Feb 2019 15:01:08 -0800 (PST) Received: from localhost ([127.0.0.1]:50266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwarP-0003HT-9j for importer@patchew.org; Wed, 20 Feb 2019 18:01:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaYA-0004Qx-RR for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaY9-0000Wg-ED for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59810) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaY4-0000P6-L5; Wed, 20 Feb 2019 17:41:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB9BA308624A; Wed, 20 Feb 2019 22:41:03 +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 28E545D6AA; Wed, 20 Feb 2019 22:41:00 +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: Wed, 20 Feb 2019 23:40:00 +0100 Message-Id: <20190220224003.4420-15-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 20 Feb 2019 22:41:03 +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 v7 14/17] nvdimm: use configurable ACPI IO base and size 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" From: Kwangwoo Lee This patch uses configurable IO base and size to create NPIO AML for ACPI NFIT. Since a different architecture like AArch64 does not use port-mapped IO, a configurable IO base is required to create correct mapping of ACPI IO address and size. Signed-off-by: Kwangwoo Lee Signed-off-by: Eric Auger --- v6 -> v7: - Use NvdimmDsmIO constant - use AcpiGenericAddress instead of AcpiNVDIMMIOEntry v2 -> v3: - s/size/len in pc_piix.c and pc_q35.c --- hw/acpi/nvdimm.c | 31 ++++++++++++++++++++++--------- hw/i386/pc_piix.c | 6 +++++- hw/i386/pc_q35.c | 6 +++++- include/hw/mem/nvdimm.h | 4 ++++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index e53b2cb681..fddc790945 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -33,6 +33,9 @@ #include "hw/nvram/fw_cfg.h" #include "hw/mem/nvdimm.h" =20 +const struct AcpiGenericAddress NvdimmDsmIO =3D { .space_id =3D AML_AS_SYS= TEM_IO, + .bit_width =3D NVDIMM_ACPI_IO_LEN << 3, .address =3D NVDIMM_ACPI_I= O_BASE}; + static int nvdimm_device_list(Object *obj, void *opaque) { GSList **list =3D opaque; @@ -929,8 +932,8 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, Mem= oryRegion *io, FWCfgState *fw_cfg, Object *owner) { memory_region_init_io(&state->io_mr, owner, &nvdimm_dsm_ops, state, - "nvdimm-acpi-io", NVDIMM_ACPI_IO_LEN); - memory_region_add_subregion(io, NVDIMM_ACPI_IO_BASE, &state->io_mr); + "nvdimm-acpi-io", state->dsm_io.bit_width >> 3); + memory_region_add_subregion(io, state->dsm_io.address, &state->io_mr); =20 state->dsm_mem =3D g_array_new(false, true /* clear */, 1); acpi_data_push(state->dsm_mem, sizeof(NvdimmDsmIn)); @@ -959,12 +962,14 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, M= emoryRegion *io, =20 #define NVDIMM_QEMU_RSVD_UUID "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62" =20 -static void nvdimm_build_common_dsm(Aml *dev) +static void nvdimm_build_common_dsm(Aml *dev, + AcpiNVDIMMState *acpi_nvdimm_state) { Aml *method, *ifctx, *function, *handle, *uuid, *dsm_mem, *elsectx2; Aml *elsectx, *unsupport, *unpatched, *expected_uuid, *uuid_invalid; Aml *pckg, *pckg_index, *pckg_buf, *field, *dsm_out_buf, *dsm_out_buf_= size; uint8_t byte_list[1]; + AmlRegionSpace rs; =20 method =3D aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED); uuid =3D aml_arg(0); @@ -975,9 +980,16 @@ static void nvdimm_build_common_dsm(Aml *dev) =20 aml_append(method, aml_store(aml_name(NVDIMM_ACPI_MEM_ADDR), dsm_mem)); =20 + if (acpi_nvdimm_state->dsm_io.space_id =3D=3D AML_AS_SYSTEM_IO) { + rs =3D AML_SYSTEM_IO; + } else { + rs =3D AML_SYSTEM_MEMORY; + } + /* map DSM memory and IO into ACPI namespace. */ - aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, AML_SYSTEM_= IO, - aml_int(NVDIMM_ACPI_IO_BASE), NVDIMM_ACPI_IO_LEN)); + aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, rs, + aml_int(acpi_nvdimm_state->dsm_io.address), + acpi_nvdimm_state->dsm_io.bit_width >> 3)); aml_append(method, aml_operation_region(NVDIMM_DSM_MEMORY, AML_SYSTEM_MEMORY, dsm_mem, sizeof(NvdimmDsmIn))); =20 @@ -1260,7 +1272,8 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev= , uint32_t ram_slots) } =20 static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker, GArray *dsm_dma_arrea, + BIOSLinker *linker, + AcpiNVDIMMState *acpi_nvdimm_state, uint32_t ram_slots) { Aml *ssdt, *sb_scope, *dev; @@ -1288,7 +1301,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, */ aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012"))); =20 - nvdimm_build_common_dsm(dev); + nvdimm_build_common_dsm(dev, acpi_nvdimm_state); =20 /* 0 is reserved for root device. */ nvdimm_build_device_dsm(dev, 0); @@ -1307,7 +1320,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, NVDIMM_ACPI_MEM_ADDR); =20 bios_linker_loader_alloc(linker, - NVDIMM_DSM_MEM_FILE, dsm_dma_arrea, + NVDIMM_DSM_MEM_FILE, acpi_nvdimm_state->dsm_m= em, sizeof(NvdimmDsmIn), false /* high memory */); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), @@ -1329,7 +1342,7 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray = *table_data, return; } =20 - nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, + nvdimm_build_ssdt(table_offsets, table_data, linker, state, ram_slots); =20 device_list =3D nvdimm_get_device_list(); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index fd0f2c268f..d0a262d106 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -298,7 +298,11 @@ static void pc_init1(MachineState *machine, } =20 if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + AcpiNVDIMMState *acpi_nvdimm_state =3D &pcms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io =3D NvdimmDsmIO; + + nvdimm_init_acpi_state(acpi_nvdimm_state, system_io, pcms->fw_cfg, OBJECT(pcms)); } } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 4a175ea50e..21f594001f 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -330,7 +330,11 @@ static void pc_q35_init(MachineState *machine) pc_nic_init(pcmc, isa_bus, host_bus); =20 if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + AcpiNVDIMMState *acpi_nvdimm_state =3D &pcms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io =3D NvdimmDsmIO; + + nvdimm_init_acpi_state(acpi_nvdimm_state, system_io, pcms->fw_cfg, OBJECT(pcms)); } } diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index c5c9b3c7f8..ead51d958d 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -25,6 +25,7 @@ =20 #include "hw/mem/pc-dimm.h" #include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/aml-build.h" =20 #define NVDIMM_DEBUG 0 #define nvdimm_debug(fmt, ...) \ @@ -123,6 +124,8 @@ struct NvdimmFitBuffer { }; typedef struct NvdimmFitBuffer NvdimmFitBuffer; =20 +extern const struct AcpiGenericAddress NvdimmDsmIO; + struct AcpiNVDIMMState { /* detect if NVDIMM support is enabled. */ bool is_enabled; @@ -140,6 +143,7 @@ struct AcpiNVDIMMState { */ int32_t persistence; char *persistence_string; + struct AcpiGenericAddress dsm_io; }; typedef struct AcpiNVDIMMState AcpiNVDIMMState; =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702854632132.79160985602482; Wed, 20 Feb 2019 14:47:34 -0800 (PST) Received: from localhost ([127.0.0.1]:50019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaeJ-0000l6-Jd for importer@patchew.org; Wed, 20 Feb 2019 17:47:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaYF-0004Wo-UP for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaYE-0000oh-UG for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43468) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaYB-0000Zz-Jf; Wed, 20 Feb 2019 17:41:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A14D2308A9E0; Wed, 20 Feb 2019 22:41:10 +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 2B9565D6AA; Wed, 20 Feb 2019 22:41:03 +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: Wed, 20 Feb 2019 23:40:01 +0100 Message-Id: <20190220224003.4420-16-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 20 Feb 2019 22:41:10 +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 v7 15/17] hw/arm/virt: Add nvdimm hot-plug infrastructure 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" From: Kwangwoo Lee Pre-plug and plug handlers are prepared for NVDIMM support. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee --- default-configs/arm-softmmu.mak | 2 ++ hw/arm/virt-acpi-build.c | 6 ++++++ hw/arm/virt.c | 22 ++++++++++++++++++++++ include/hw/arm/virt.h | 3 +++ 4 files changed, 33 insertions(+) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.= mak index 0a78421f72..03dbebb197 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -165,3 +165,5 @@ CONFIG_HIGHBANK=3Dy CONFIG_MUSICPAL=3Dy CONFIG_MEM_DEVICE=3Dy CONFIG_DIMM=3Dy +CONFIG_NVDIMM=3Dy +CONFIG_ACPI_NVDIMM=3Dy diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 781eafaf5e..f086adfa82 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -784,6 +784,7 @@ static void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); + MachineState *ms =3D MACHINE(vms); GArray *table_offsets; unsigned dsdt, xsdt; GArray *tables_blob =3D tables->table_data; @@ -824,6 +825,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildT= ables *tables) } } =20 + if (vms->acpi_nvdimm_state.is_enabled) { + nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, + &vms->acpi_nvdimm_state, ms->ram_slots); + } + if (its_class_name() && !vmc->no_its) { acpi_add_table(table_offsets, tables_blob); build_iort(tables_blob, tables->linker, vms); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 33ad9b3f63..1896920570 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -134,6 +134,7 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_GPIO] =3D { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] =3D { 0x09040000, 0x00001000 }, [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, + [VIRT_ACPI_IO] =3D { 0x09070000, 0x00010000 }, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -1675,6 +1676,18 @@ static void machvirt_init(MachineState *machine) =20 create_platform_bus(vms, pic); =20 + if (vms->acpi_nvdimm_state.is_enabled) { + AcpiNVDIMMState *acpi_nvdimm_state =3D &vms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.space_id =3D AML_AS_SYSTEM_MEMORY; + acpi_nvdimm_state->dsm_io.address =3D + vms->memmap[VIRT_ACPI_IO].base + NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.bit_width =3D NVDIMM_ACPI_IO_LEN << 3; + + nvdimm_init_acpi_state(acpi_nvdimm_state, sysmem, + vms->fw_cfg, OBJECT(vms)); + } + vms->bootinfo.ram_size =3D machine->ram_size; vms->bootinfo.kernel_filename =3D machine->kernel_filename; vms->bootinfo.kernel_cmdline =3D machine->kernel_cmdline; @@ -1860,10 +1873,19 @@ static void virt_memory_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); Error *local_err =3D NULL; =20 pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + if (local_err) { + goto out; + } =20 + if (is_nvdimm) { + nvdimm_plug(&vms->acpi_nvdimm_state); + } + +out: error_propagate(errp, local_err); } =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 7798462cb0..bd9cf68311 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -37,6 +37,7 @@ #include "hw/arm/arm.h" #include "sysemu/kvm.h" #include "hw/intc/arm_gicv3_common.h" +#include "hw/mem/nvdimm.h" =20 #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -77,6 +78,7 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_ACPI_IO, VIRT_LOWMEMMAP_LAST, }; =20 @@ -137,6 +139,7 @@ typedef struct { hwaddr device_memory_base; hwaddr device_memory_size; bool extended_memmap; + AcpiNVDIMMState acpi_nvdimm_state; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550702822678615.923769680515; Wed, 20 Feb 2019 14:47:02 -0800 (PST) Received: from localhost ([127.0.0.1]:50015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwadn-0000Pv-IX for importer@patchew.org; Wed, 20 Feb 2019 17:46:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaYI-0004Zt-Qd for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaYG-0000wK-V0 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23691) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaYE-0000hc-TX; Wed, 20 Feb 2019 17:41:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91DC9308A967; Wed, 20 Feb 2019 22:41:13 +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 03E0A5D6AA; Wed, 20 Feb 2019 22:41:10 +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: Wed, 20 Feb 2019 23:40:02 +0100 Message-Id: <20190220224003.4420-17-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 20 Feb 2019 22:41:13 +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 v7 16/17] hw/arm/boot: Expose the pmem nodes in the DT 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" In case of NV-DIMM slots, let's add /pmem DT nodes. Signed-off-by: Eric Auger --- v6 -> v7 - does the same rework as for fdt_add_memory_node --- hw/arm/boot.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 255aaca0cf..66caf005e5 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -450,6 +450,32 @@ out: return ret; } =20 +static int fdt_add_pmem_node(void *fdt, uint32_t acells, hwaddr mem_base, + uint32_t scells, hwaddr mem_len, + int numa_node_id) +{ + char *nodename; + int ret; + + nodename =3D g_strdup_printf("/pmem@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "pmem-region"); + ret =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem= _base, + scells, mem_len); + if (ret < 0) { + goto out; + } + + /* only set the NUMA ID if it is specified */ + if (numa_node_id >=3D 0) { + ret =3D qemu_fdt_setprop_cell(fdt, nodename, + "numa-node-id", numa_node_id); + } +out: + g_free(nodename); + return ret; +} + static void fdt_add_psci_node(void *fdt) { uint32_t cpu_suspend_fn; @@ -546,6 +572,20 @@ static int fdt_add_hotpluggable_memory_nodes(void *fdt, } break; } + case MEMORY_DEVICE_INFO_KIND_NVDIMM: + { + PCDIMMDeviceInfo *di =3D mi->u.nvdimm.data; + + ret =3D fdt_add_pmem_node(fdt, acells, di->addr, + scells, di->size, di->node); + if (ret) { + fprintf(stderr, + "couldn't add NVDIMM /memory@%"PRIx64" node\n", + di->addr); + goto out; + } + break; + } default: fprintf(stderr, "%s memory nodes are not yet supported\n", MemoryDeviceInfoKind_str(mi->type)); --=20 2.20.1 From nobody Sun Nov 9 11:36:03 2025 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550703448792898.146392653431; Wed, 20 Feb 2019 14:57:28 -0800 (PST) Received: from localhost ([127.0.0.1]:50198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwant-00009v-QJ for importer@patchew.org; Wed, 20 Feb 2019 17:57:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwaYa-0004po-Ee for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwaYT-0001fT-Fh for qemu-devel@nongnu.org; Wed, 20 Feb 2019 17:41:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55544) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwaYI-0000vn-Od; Wed, 20 Feb 2019 17:41:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 964BC3082E09; Wed, 20 Feb 2019 22:41:16 +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 E84E85D6AA; Wed, 20 Feb 2019 22:41:13 +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: Wed, 20 Feb 2019 23:40:03 +0100 Message-Id: <20190220224003.4420-18-eric.auger@redhat.com> In-Reply-To: <20190220224003.4420-1-eric.auger@redhat.com> References: <20190220224003.4420-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 20 Feb 2019 22:41:16 +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 v7 17/17] hw/arm/virt: Add nvdimm and nvdimm-persistence options 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" Machine option nvdimm allows to turn NVDIMM support on. Signed-off-by: Eric Auger --- hw/arm/virt.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1896920570..c7e68e2428 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1814,6 +1814,47 @@ static void virt_set_iommu(Object *obj, const char *= value, Error **errp) } } =20 +static bool virt_get_nvdimm(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return vms->acpi_nvdimm_state.is_enabled; +} + +static void virt_set_nvdimm(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + vms->acpi_nvdimm_state.is_enabled =3D value; +} + +static char *virt_get_nvdimm_persistence(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return g_strdup(vms->acpi_nvdimm_state.persistence_string); +} + +static void virt_set_nvdimm_persistence(Object *obj, const char *value, + Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + AcpiNVDIMMState *nvdimm_state =3D &vms->acpi_nvdimm_state; + + if (strcmp(value, "cpu") =3D=3D 0) + nvdimm_state->persistence =3D 3; + else if (strcmp(value, "mem-ctrl") =3D=3D 0) + nvdimm_state->persistence =3D 2; + else { + error_report("-machine nvdimm-persistence=3D%s: unsupported option= ", + value); + exit(EXIT_FAILURE); + } + + g_free(nvdimm_state->persistence_string); + nvdimm_state->persistence_string =3D g_strdup(value); +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1856,13 +1897,14 @@ static void virt_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, Error **errp) { const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 if (dev->hotplugged) { error_setg(errp, "memory hotplug is not supported"); } =20 - if (is_nvdimm) { - error_setg(errp, "nvdimm is not yet supported"); + if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { + error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); return; } =20 @@ -2076,6 +2118,19 @@ static void virt_instance_init(Object *obj) vms->extended_memmap =3D true; } =20 + object_property_add_bool(obj, "nvdimm", + virt_get_nvdimm, virt_set_nvdimm, NULL); + object_property_set_description(obj, "nvdimm", + "Set on/off to enable/disable NVD= IMM " + "instantiation", NULL); + + object_property_add_str(obj, "nvdimm-persistence", + virt_get_nvdimm_persistence, + virt_set_nvdimm_persistence, NULL); + object_property_set_description(obj, "nvdimm-persistence", + "Set NVDIMM persistence" + "Valid values are cpu and mem-ctrl", N= ULL); + vms->irqmap =3D a15irqmap; } =20 --=20 2.20.1