From nobody Sun May 19 12:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640639938991357.23192792361965; Mon, 27 Dec 2021 13:18:58 -0800 (PST) Received: from localhost ([::1]:44888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1xOU-00080Z-6q for importer@patchew.org; Mon, 27 Dec 2021 16:18:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMk-0005IL-Gn for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from [2604:1380:4601:e00::1] (port=60152 helo=ams.source.kernel.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMi-0002Wp-Fc for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A01F9B81155; Mon, 27 Dec 2021 21:17:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56621C36AE7; Mon, 27 Dec 2021 21:17:05 +0000 (UTC) Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=hot-poop.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n1xMd-00Ed4b-Cn; Mon, 27 Dec 2021 21:17:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640639825; bh=VdhgTeMTsnRl0ShXJsG4HnhKtgpRBpDQJ/z2lQPwWvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q4LY7aur7b3oX4ZI56ydS6L5YOdeyp1+/1cV3YE88AjMKLvOKXZTPg7MvuOX5HIIM 5Kgbqub2GS01CaCVAikKKDR5ZbOz8ng4UEf7BxwGsdsxGgLcFOvAibaWih9mRkaqXD sMaOYeJbIcr4GqN4TJxyXlaFExVKppNwmPxXrVxqYcSpP7dKCtl6t1WjrJoG5ig77M OpyQIiFUK4FjCWPszaDUkg6FmRtKgRVmENYa6mwITHdw9mBSGMSCC+xdme8+pqXOyy Tu92AJNssuIUU74fSZgsMKdLDJ1iH056eZGpA5BRKk64f8EwH3yd2intruRdnSz81N O2XDKCNxspN5A== From: Marc Zyngier To: qemu-devel@nongnu.org Subject: [PATCH v3 1/5] hw/arm/virt: Key enablement of highmem PCIe on highmem_ecam Date: Mon, 27 Dec 2021 21:16:38 +0000 Message-Id: <20211227211642.994461-2-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211227211642.994461-1-maz@kernel.org> References: <20211227211642.994461-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qemu-devel@nongnu.org, drjones@redhat.com, eric.auger@redhat.com, peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Host-Lookup-Failed: Reverse DNS lookup failed for 2604:1380:4601:e00::1 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2604:1380:4601:e00::1; envelope-from=maz@kernel.org; helo=ams.source.kernel.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.575, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , kvm@vger.kernel.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640639940596000001 Content-Type: text/plain; charset="utf-8" Currently, the highmem PCIe region is oddly keyed on the highmem attribute instead of highmem_ecam. Move the enablement of this PCIe region over to highmem_ecam. Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier --- hw/arm/virt-acpi-build.c | 10 ++++------ hw/arm/virt.c | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index d0f4867fdf..d04c107fd8 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -158,10 +158,9 @@ static void acpi_dsdt_add_virtio(Aml *scope, } =20 static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, - uint32_t irq, bool use_highmem, bool highmem= _ecam, - VirtMachineState *vms) + uint32_t irq, VirtMachineState *vms) { - int ecam_id =3D VIRT_ECAM_ID(highmem_ecam); + int ecam_id =3D VIRT_ECAM_ID(vms->highmem_ecam); struct GPEXConfig cfg =3D { .mmio32 =3D memmap[VIRT_PCIE_MMIO], .pio =3D memmap[VIRT_PCIE_PIO], @@ -170,7 +169,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapE= ntry *memmap, .bus =3D vms->bus, }; =20 - if (use_highmem) { + if (vms->highmem_ecam) { cfg.mmio64 =3D memmap[VIRT_HIGH_PCIE_MMIO]; } =20 @@ -868,8 +867,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]); acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO], (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPO= RTS); - acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), - vms->highmem, vms->highmem_ecam, vms); + acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms= ); if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev), diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6bce595aba..a54dc43175 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1412,7 +1412,7 @@ static void create_pcie(VirtMachineState *vms) mmio_reg, base_mmio, size_mmio); memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias= ); =20 - if (vms->highmem) { + if (vms->highmem_ecam) { /* Map high MMIO space */ MemoryRegion *high_mmio_alias =3D g_new0(MemoryRegion, 1); =20 @@ -1466,7 +1466,7 @@ static void create_pcie(VirtMachineState *vms) qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 2, base_ecam, 2, size_ecam); =20 - if (vms->highmem) { + if (vms->highmem_ecam) { qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "ranges", 1, FDT_PCI_RANGE_IOPORT, 2, 0, 2, base_pio, 2, size_pio, --=20 2.30.2 From nobody Sun May 19 12:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640639936161126.37666638927294; Mon, 27 Dec 2021 13:18:56 -0800 (PST) Received: from localhost ([::1]:44684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1xOQ-0007sW-Ic for importer@patchew.org; Mon, 27 Dec 2021 16:18:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMi-0005Hv-Us for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:08 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMh-0002WW-1t for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 052BB6116E; Mon, 27 Dec 2021 21:17:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BA8CC36AEB; Mon, 27 Dec 2021 21:17:05 +0000 (UTC) Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=hot-poop.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n1xMd-00Ed4b-IW; Mon, 27 Dec 2021 21:17:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640639825; bh=w5B4FKdW6ZAej5mWLvSTvLKVvqcT8OfEspAdnpMgodU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFJU9ao/gRvD3WtN4AQ4a4VApKXJ7FVoiJ0gOoyd/f8Ze3Xv67biNZ7oAbW/+ZQ8M U6Vaed+H/bMa8MBI0+ba2frwPBGPynD2oKBkI4SyOYRFu1vADnn4B5pcwzQ9RUpK7G 0Q1hAjX8wnbLuP5bCYeLEIBOoqbTHm6A/aY1/XHkEQ8QTyRs3asMXAHhbnniKl/6GU ln7qqpG85/RdcOazfQLLcAx8jgOkuYHwSjiy4uYfg4Q+JYUljQtdesZYS0HBU1NCZM LxiYUA7gQ3RGIxvKMpjczvmeRweb36fSILBeH9HHY26eRGiJnDvpapplB1hVMYY1ly W+YIn9l1URzmw== From: Marc Zyngier To: qemu-devel@nongnu.org Subject: [PATCH v3 2/5] hw/arm/virt: Add a control for the the highmem redistributors Date: Mon, 27 Dec 2021 21:16:39 +0000 Message-Id: <20211227211642.994461-3-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211227211642.994461-1-maz@kernel.org> References: <20211227211642.994461-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qemu-devel@nongnu.org, drjones@redhat.com, eric.auger@redhat.com, peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.178.84.217; envelope-from=maz@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.575, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , kvm@vger.kernel.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640639938047000002 Content-Type: text/plain; charset="utf-8" Just like we can control the enablement of the highmem PCIe region using highmem_ecam, let's add a control for the highmem GICv3 redistributor region. Similarily to highmem_ecam, these redistributors are disabled when highmem is off. Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier --- hw/arm/virt-acpi-build.c | 2 ++ hw/arm/virt.c | 3 +++ include/hw/arm/virt.h | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index d04c107fd8..fcbff9d835 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -946,6 +946,8 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTa= bles *tables) acpi_add_table(table_offsets, tables_blob); build_fadt_rev5(tables_blob, tables->linker, vms, dsdt); =20 + vms->highmem_redists &=3D vms->highmem; + acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, vms); =20 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a54dc43175..8b600d82c1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2105,6 +2105,8 @@ static void machvirt_init(MachineState *machine) =20 virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); =20 + vms->highmem_redists &=3D vms->highmem; + create_gic(vms, sysmem); =20 virt_cpu_post_init(vms, sysmem); @@ -2802,6 +2804,7 @@ static void virt_instance_init(Object *obj) vms->gic_version =3D VIRT_GIC_VERSION_NOSEL; =20 vms->highmem_ecam =3D !vmc->no_highmem_ecam; + vms->highmem_redists =3D true; =20 if (vmc->no_its) { vms->its =3D false; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index dc6b66ffc8..726623a176 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -143,6 +143,7 @@ struct VirtMachineState { bool secure; bool highmem; bool highmem_ecam; + bool highmem_redists; bool its; bool tcg_its; bool virt; @@ -189,7 +190,8 @@ static inline int virt_gicv3_redist_region_count(VirtMa= chineState *vms) =20 assert(vms->gic_version =3D=3D VIRT_GIC_VERSION_3); =20 - return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1; + return (MACHINE(vms)->smp.cpus > redist0_capacity && + vms->highmem_redists) ? 2 : 1; } =20 #endif /* QEMU_ARM_VIRT_H */ --=20 2.30.2 From nobody Sun May 19 12:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640639937775268.30911149594385; Mon, 27 Dec 2021 13:18:57 -0800 (PST) Received: from localhost ([::1]:44832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1xOR-0007yS-WF for importer@patchew.org; Mon, 27 Dec 2021 16:18:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMj-0005IB-W2 for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from [2604:1380:4641:c500::1] (port=35450 helo=dfw.source.kernel.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMh-0002WZ-2J for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3B6F261170; Mon, 27 Dec 2021 21:17:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5553C36AED; Mon, 27 Dec 2021 21:17:05 +0000 (UTC) Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=hot-poop.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n1xMd-00Ed4b-OD; Mon, 27 Dec 2021 21:17:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640639825; bh=IHY2+6hBS2o9nbH7P+X3mza23XiKdsCbkiZ64E2sCow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ll0djBguy52iSPcnsf8MC/e8sqKmI9zoHgkxDQf+dlCiMB0RmCRRHYwoaAWJ5tmnO GYR+/H+tZpPDwl2chLHs7n3O7m5FfCSZV+oq88b3hT/nVVMVZgPtNNWwS/Kz15L0jZ yQZHAPhn8XYLlR7OA7JNXqta2STrYQKHUsFU7aStqCI9ZXWqg/d1uxmGPdnRdHug5D DWJDt9mObZMaNKCP3uCK4G9KqKdqdShIh2YBe17yoyAA8XuZDBRYGAevDZnlOvlWX7 3WZUyoLbRzh5LQjm8e0bkSagPYwinUH2MB97KW9EKe6lNzNsoceQJ/CfqGuKO2kT5h 125hjUH8pRCYA== From: Marc Zyngier To: qemu-devel@nongnu.org Subject: [PATCH v3 3/5] hw/arm/virt: Honor highmem setting when computing the memory map Date: Mon, 27 Dec 2021 21:16:40 +0000 Message-Id: <20211227211642.994461-4-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211227211642.994461-1-maz@kernel.org> References: <20211227211642.994461-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qemu-devel@nongnu.org, drjones@redhat.com, eric.auger@redhat.com, peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Host-Lookup-Failed: Reverse DNS lookup failed for 2604:1380:4641:c500::1 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2604:1380:4641:c500::1; envelope-from=maz@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.575, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , kvm@vger.kernel.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640639938125000005 Content-Type: text/plain; charset="utf-8" Even when the VM is configured with highmem=3Doff, the highest_gpa field includes devices that are above the 4GiB limit. Similarily, nothing seem to check that the memory is within the limit set by the highmem=3Doff option. This leads to failures in virt_kvm_type() on systems that have a crippled IPA range, as the reported IPA space is larger than what it should be. Instead, honor the user-specified limit to only use the devices at the lowest end of the spectrum, and fail if we have memory crossing the 4GiB limit. Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier --- hw/arm/virt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8b600d82c1..84dd3b36fb 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1678,6 +1678,11 @@ static void virt_set_memmap(VirtMachineState *vms) exit(EXIT_FAILURE); } =20 + if (!vms->highmem && + vms->memmap[VIRT_MEM].base + ms->maxram_size > 4 * GiB) { + error_report("highmem=3Doff, but memory crosses the 4GiB limit\n"); + exit(EXIT_FAILURE); + } /* * We compute the base of the high IO region depending on the * amount of initial and device memory. The device memory start/size @@ -1707,7 +1712,9 @@ static void virt_set_memmap(VirtMachineState *vms) vms->memmap[i].size =3D size; base +=3D size; } - vms->highest_gpa =3D base - 1; + vms->highest_gpa =3D (vms->highmem ? + base : + vms->memmap[VIRT_MEM].base + ms->maxram_size) - 1; if (device_memory_size > 0) { ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); ms->device_memory->base =3D device_memory_base; --=20 2.30.2 From nobody Sun May 19 12:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640640228479873.2895751020365; Mon, 27 Dec 2021 13:23:48 -0800 (PST) Received: from localhost ([::1]:53128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1xT9-0004x0-T4 for importer@patchew.org; Mon, 27 Dec 2021 16:23:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMk-0005IT-Lv for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from [2604:1380:4601:e00::1] (port=60172 helo=ams.source.kernel.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMi-0002Ws-Hi for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 315D1B8115B; Mon, 27 Dec 2021 21:17:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0464C36AEC; Mon, 27 Dec 2021 21:17:05 +0000 (UTC) Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=hot-poop.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n1xMd-00Ed4b-Uv; Mon, 27 Dec 2021 21:17:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640639825; bh=tbsU5WM2/7sfTWA3R2CesoLJCU/BNsaWltw5ZW/N/wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HwTP0H9zSsAWMrEX6rEx6GxsxQ7scxzIXrAErBb5sV3orqvsYjI11UvUxTePK4hSO s44HaL71Q5zmw0VRiRdtTYtQ9Wr6YvMVWFn++K0OTavShP11Kbd2il3WZWF/NEYAKY Se4+IysEjnqhg0jEO1C05ihiiRvfa70G+k5ejz7i+GCLtWVzlqoSTlpimFg3/KSZil AJOFtA8ZzJf52LbxHwnfxRmzm1Z3xFWYDxX8d2W+PwW8tnyytgKQzLc/oPvHPC/GLX tzGVCviMv+luuC5iEgVXpgPeL1XAHdAO7glvrmdjRHmlwgcvCLu1PTv5HaEC4/VM6J 1sxxiVBtQd0eA== From: Marc Zyngier To: qemu-devel@nongnu.org Subject: [PATCH v3 4/5] hw/arm/virt: Use the PA range to compute the memory map Date: Mon, 27 Dec 2021 21:16:41 +0000 Message-Id: <20211227211642.994461-5-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211227211642.994461-1-maz@kernel.org> References: <20211227211642.994461-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qemu-devel@nongnu.org, drjones@redhat.com, eric.auger@redhat.com, peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Host-Lookup-Failed: Reverse DNS lookup failed for 2604:1380:4601:e00::1 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2604:1380:4601:e00::1; envelope-from=maz@kernel.org; helo=ams.source.kernel.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.575, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , kvm@vger.kernel.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640640229665000001 Content-Type: text/plain; charset="utf-8" The highmem attribute is nothing but another way to express the PA range of a VM. To support HW that has a smaller PA range then what QEMU assumes, pass this PA range to the virt_set_memmap() function, allowing it to correctly exclude highmem devices if they are outside of the PA range. Signed-off-by: Marc Zyngier --- hw/arm/virt.c | 64 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 84dd3b36fb..212079e7a6 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1660,10 +1660,10 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineSta= te *vms, int idx) return arm_cpu_mp_affinity(idx, clustersz); } =20 -static void virt_set_memmap(VirtMachineState *vms) +static void virt_set_memmap(VirtMachineState *vms, int pa_bits) { MachineState *ms =3D MACHINE(vms); - hwaddr base, device_memory_base, device_memory_size; + hwaddr base, device_memory_base, device_memory_size, memtop; int i; =20 vms->memmap =3D extended_memmap; @@ -1678,11 +1678,9 @@ static void virt_set_memmap(VirtMachineState *vms) exit(EXIT_FAILURE); } =20 - if (!vms->highmem && - vms->memmap[VIRT_MEM].base + ms->maxram_size > 4 * GiB) { - error_report("highmem=3Doff, but memory crosses the 4GiB limit\n"); - exit(EXIT_FAILURE); - } + if (!vms->highmem) + pa_bits =3D 32; + /* * We compute the base of the high IO region depending on the * amount of initial and device memory. The device memory start/size @@ -1695,7 +1693,12 @@ static void virt_set_memmap(VirtMachineState *vms) device_memory_size =3D ms->maxram_size - ms->ram_size + ms->ram_slots = * GiB; =20 /* Base address of the high IO region */ - base =3D device_memory_base + ROUND_UP(device_memory_size, GiB); + memtop =3D base =3D device_memory_base + ROUND_UP(device_memory_size, = GiB); + if (memtop > BIT_ULL(pa_bits)) { + error_report("Addressing limited to %d bits, but memory exceeds it by= %llu bytes\n", + pa_bits, memtop - BIT_ULL(pa_bits)); + exit(EXIT_FAILURE); + } if (base < device_memory_base) { error_report("maxmem/slots too huge"); exit(EXIT_FAILURE); @@ -1712,9 +1715,17 @@ static void virt_set_memmap(VirtMachineState *vms) vms->memmap[i].size =3D size; base +=3D size; } - vms->highest_gpa =3D (vms->highmem ? - base : - vms->memmap[VIRT_MEM].base + ms->maxram_size) - 1; + + /* + * If base fits within pa_bits, all good. If it doesn't, limit it + * to the end of RAM, which is guaranteed to fit within pa_bits. + */ + if (base <=3D BIT_ULL(pa_bits)) { + vms->highest_gpa =3D base - 1; + } else { + vms->highest_gpa =3D memtop - 1; + } + if (device_memory_size > 0) { ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); ms->device_memory->base =3D device_memory_base; @@ -1905,12 +1916,38 @@ static void machvirt_init(MachineState *machine) unsigned int smp_cpus =3D machine->smp.cpus; unsigned int max_cpus =3D machine->smp.max_cpus; =20 + possible_cpus =3D mc->possible_cpu_arch_ids(machine); + /* * In accelerated mode, the memory map is computed earlier in kvm_type= () * to create a VM with the right number of IPA bits. */ if (!vms->memmap) { - virt_set_memmap(vms); + Object *cpuobj; + ARMCPU *armcpu; + int pa_bits; + + /* + * Instanciate a temporary CPU object to find out about what + * we are about to deal with. Once this is done, get rid of + * the object. + */ + cpuobj =3D object_new(possible_cpus->cpus[0].type); + armcpu =3D ARM_CPU(cpuobj); + + if (object_property_get_bool(cpuobj, "aarch64", NULL)) { + pa_bits =3D arm_pamax(armcpu); + } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) { + /* v7 with LPAE */ + pa_bits =3D 40; + } else { + /* Anything else */ + pa_bits =3D 32; + } + + object_unref(cpuobj); + + virt_set_memmap(vms, pa_bits); } =20 /* We can probe only here because during property set @@ -1992,7 +2029,6 @@ static void machvirt_init(MachineState *machine) =20 create_fdt(vms); =20 - possible_cpus =3D mc->possible_cpu_arch_ids(machine); assert(possible_cpus->len =3D=3D max_cpus); for (n =3D 0; n < possible_cpus->len; n++) { Object *cpuobj; @@ -2648,7 +2684,7 @@ static int virt_kvm_type(MachineState *ms, const char= *type_str) max_vm_pa_size =3D kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa); =20 /* we freeze the memory map to compute the highest gpa */ - virt_set_memmap(vms); + virt_set_memmap(vms, max_vm_pa_size); =20 requested_pa_size =3D 64 - clz64(vms->highest_gpa); =20 --=20 2.30.2 From nobody Sun May 19 12:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1640639936552457.6053414234676; Mon, 27 Dec 2021 13:18:56 -0800 (PST) Received: from localhost ([::1]:44872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1xOR-000801-Tg for importer@patchew.org; Mon, 27 Dec 2021 16:18:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMk-0005IK-Eb for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:53084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1xMi-0002Wr-No for qemu-devel@nongnu.org; Mon, 27 Dec 2021 16:17:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 365F4B8115E; Mon, 27 Dec 2021 21:17:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 099C7C36AEF; Mon, 27 Dec 2021 21:17:06 +0000 (UTC) Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=hot-poop.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n1xMe-00Ed4b-4O; Mon, 27 Dec 2021 21:17:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640639826; bh=8jnTIlm8Zob2Jvux6Qz42yjEvf+iD+5kMVUVUXnj1ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q56PjvJIBDPFg9k+R/s7jSrr+hm/vcoXAPHyqveK2tK+tOZF4My4oU+D3fGM2JOxU jUyQuacheThXBYwn3eKWIod4ntDY14Wqy54ieL8EK13vzrkXe9cxeVE+3iqJ6wlF+P MCr6gHk23XNFjs9wBL2Dv4S3Q3SEivjB8rhtlQDulEstMsWTBCbMLP2ioAn+KVO/M2 MYkOkzZD9ErsRWPfHGTPf8XcjoN/ogqYYUn/1x5TC0ekcNH/+6pPNrfl7X1dfCkS5o pDjuRmdzJpo27+OhxuYyYIFX/QTh+2+A5kVU+c+xJvX3CY8acZwo3iMSStu7WlhKgZ zPRSTJhcPlu0Q== From: Marc Zyngier To: qemu-devel@nongnu.org Subject: [PATCH v3 5/5] hw/arm/virt: Disable highmem devices that don't fit in the PA range Date: Mon, 27 Dec 2021 21:16:42 +0000 Message-Id: <20211227211642.994461-6-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211227211642.994461-1-maz@kernel.org> References: <20211227211642.994461-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qemu-devel@nongnu.org, drjones@redhat.com, eric.auger@redhat.com, peter.maydell@linaro.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=145.40.68.75; envelope-from=maz@kernel.org; helo=ams.source.kernel.org X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.575, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jones , kvm@vger.kernel.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640639938044000001 Content-Type: text/plain; charset="utf-8" Make sure both the highmem PCIe and GICv3 regions are disabled when they don't fully fit in the PA range. Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier --- hw/arm/virt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 212079e7a6..18e615070f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1723,6 +1723,9 @@ static void virt_set_memmap(VirtMachineState *vms, in= t pa_bits) if (base <=3D BIT_ULL(pa_bits)) { vms->highest_gpa =3D base - 1; } else { + /* Advertise that we have disabled the highmem devices */ + vms->highmem_ecam =3D false; + vms->highmem_redists =3D false; vms->highest_gpa =3D memtop - 1; } =20 --=20 2.30.2