From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E21FDC04AAF for ; Thu, 16 May 2019 12:42:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F97A20815 for ; Thu, 16 May 2019 12:42:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F97A20815 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:54238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRFik-0003mE-Tb for qemu-devel@archiver.kernel.org; Thu, 16 May 2019 08:42:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRFMJ-0000fa-PA for qemu-devel@nongnu.org; Thu, 16 May 2019 08:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRFMF-00023S-Vk for qemu-devel@nongnu.org; Thu, 16 May 2019 08:19:39 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:40308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRFME-00022C-Bc for qemu-devel@nongnu.org; Thu, 16 May 2019 08:19:35 -0400 Received: by mail-qk1-f193.google.com with SMTP id q197so2074073qke.7 for ; Thu, 16 May 2019 05:19:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=82yaoR5Qd6z6aUjmHl7ZXeDTv2ZIDxYt8pX/8qpvvOk=; b=fG3SekBm+RwUibe1yM9VjTnOJxmzmruUBe5dEuoGnnYn2LseR3dFbGHV31OzdCiEJp rrCG/apghymlexEkpc2RhwMPVcC/fmbYa0uzzlJxejrB30bFpGSXp6bZMhqamfGP1Z8s dfF5//criOrtrwp2RkxcVVIDCz0cSQ9zORRbdy6cWvXi3gEkfhqTfNpt5M4ZgkvK8dl8 /KdzAn20+ee0r3pt15GjNaBupL9fdvySf+eItsTWDktuAmynUXYDAWN19qjETUrMOKCB aJWkl4pLmVS+GM2gRNUAcR4QXna6QgGzIleU4OkHoS6RzTZX37KH+D2vqfWkAlBDjDCx MXmQ== X-Gm-Message-State: APjAAAX2/NFq8EMVNdlMixDmzVVcmKzczeU0lOhmBsJUEgupGP6jzGKc Rrsj5FHQAgnzYqriQ5fF5hNZfRQpDso= X-Google-Smtp-Source: APXvYqx34zoLCFmLiPl28IIfIqHHtICWH40cz66CJ7bYHhb5RpmZ49g79svpllq+8Ib6nN31w6DGmQ== X-Received: by 2002:a05:620a:13c6:: with SMTP id g6mr26179321qkl.153.1558009173486; Thu, 16 May 2019 05:19:33 -0700 (PDT) Received: from redhat.com ([185.54.206.10]) by smtp.gmail.com with ESMTPSA id 22sm2546484qkl.4.2019.05.16.05.19.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 16 May 2019 05:19:32 -0700 (PDT) Date: Thu, 16 May 2019 08:19:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190419003053.8260-5-richardw.yang@linux.intel.com> References: <20190515121146.7248-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190515121146.7248-1-mst@redhat.com> X-Mailer: git-send-email 2.17.1.1206.gb667731e2e.dirty X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.222.193 Subject: [Qemu-devel] [PULL 18/37] hw/arm/virt-acpi-build: pass AcpiMcfgInfo to build_mcfg() 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: Peter Maydell , Eduardo Habkost , Shannon Zhao , qemu-arm@nongnu.org, Wei Yang , Igor Mammedov , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190516121929.FaACVnuNU21q-MoeDQky1B2GOklKb1ntKtlYnvUwB8s@z> From: Wei Yang To build MCFG, two information is necessary: * bus number * base address Abstract these two information to AcpiMcfgInfo so that build_mcfg and build_mcfg_q35 will have the same declaration. Signed-off-by: Wei Yang Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Message-Id: <20190419003053.8260-5-richardw.yang@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/pci.h | 33 +++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 18 +++++++++++------- hw/i386/acpi-build.c | 6 +----- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 include/hw/acpi/pci.h diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h new file mode 100644 index 0000000000..124af7d32a --- /dev/null +++ b/include/hw/acpi/pci.h @@ -0,0 +1,33 @@ +/* + * Support for generating PCI related ACPI tables and passing them to Guests + * + * Copyright (C) 2006 Fabrice Bellard + * Copyright (C) 2008-2010 Kevin O'Connor + * Copyright (C) 2013-2019 Red Hat Inc + * Copyright (C) 2019 Intel Corporation + * + * Author: Wei Yang + * Author: Michael S. Tsirkin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ +#ifndef HW_ACPI_PCI_H +#define HW_ACPI_PCI_H + +typedef struct AcpiMcfgInfo { + uint64_t base; + uint32_t size; +} AcpiMcfgInfo; + +#endif diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 12dbaf3846..e7c96d658e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -40,6 +40,7 @@ #include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/pci.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -546,21 +547,18 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } static void -build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) +build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info) { AcpiTableMcfg *mcfg; - const MemMapEntry *memmap = vms->memmap; - int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam); int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]); mcfg = acpi_data_push(table_data, len); - mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base); + mcfg->allocation[0].address = cpu_to_le64(info->base); /* Only a single allocation so no need to play with segments */ mcfg->allocation[0].pci_segment = cpu_to_le16(0); mcfg->allocation[0].start_bus_number = 0; - mcfg->allocation[0].end_bus_number = - PCIE_MMCFG_BUS(memmap[ecam_id].size - 1); + mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->size - 1); build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1, NULL, NULL); } @@ -801,7 +799,13 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) build_gtdt(tables_blob, tables->linker, vms); acpi_add_table(table_offsets, tables_blob); - build_mcfg(tables_blob, tables->linker, vms); + { + AcpiMcfgInfo mcfg = { + .base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base, + .size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size, + }; + build_mcfg(tables_blob, tables->linker, &mcfg); + } acpi_add_table(table_offsets, tables_blob); build_spcr(tables_blob, tables->linker, vms); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 6df7bb3abc..dbd3a6cac2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -58,6 +58,7 @@ #include "hw/i386/x86-iommu.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/pci.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" @@ -86,11 +87,6 @@ /* Default IOAPIC ID */ #define ACPI_BUILD_IOAPIC_ID 0x0 -typedef struct AcpiMcfgInfo { - uint64_t base; - uint32_t size; -} AcpiMcfgInfo; - typedef struct AcpiPmInfo { bool s3_disabled; bool s4_disabled; -- MST