From patchwork Tue Aug 10 08:45:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12428379 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=-21.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 B3F0AC432BE for ; Tue, 10 Aug 2021 08:48:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D0C560F25 for ; Tue, 10 Aug 2021 08:48:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2D0C560F25 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNQV-0000qV-49 for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:47:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPK-0006VF-9T for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:44625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPG-00082J-NH for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: by mail-ej1-x62e.google.com with SMTP id yk17so33984123ejb.11 for ; Tue, 10 Aug 2021 01:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tM+6Q/09BSPbSVODH5fu80QY1gdHUNNnA2XQdyRcxCo=; b=bgg2g5BGFBkOFVC6Pv98IBy8W6IbIxAefJihsfII+k01QsEIB1idH8G1Ap/jqapThX fouGHHZ/9eBuucRXIXxN0iPqWqA08+xEQaQQxSXqW/Y3B+AHIzCBsKJrpirbQ6hZB8Qx EJh2LCnXNSvnKYnC8xvuV4ZqFeDG4u1LID+vvH6ImqpXOuHU8ZSjh0xxl/DHKothLgg5 b6ZbitvO42PDBB9YuzWLhWNiaMVhkT1kdV1zBkYSJFOBDgzMrfRw3mgNkq05xOCJfqCc 3u6fXMAfVYgt4pYBBiWFz3PjkOQvlgrgFZAtBk9RZAHp2dwQ9GrIPtJi1UzIif4r625A 56vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tM+6Q/09BSPbSVODH5fu80QY1gdHUNNnA2XQdyRcxCo=; b=SmVPBMja1eQjeg9IZmehHYPggfVzLx4x4IkggsgVYuyJNxGivMEejcZjarQ925QvUj 4m+39ZOL1ETbcATQEJTwMhyCPAebWtUozNBHTtqe2jxRLC31deUpySJ9f2maxbbRxequ eF/BuxWASw2Rk3bodV7uq38M52EbhbKtZbyVr+F1/LdLm8NSgG/VbX9dOVBPC5AFQbzj Cz2BgPM0mnU4O54KZD/6uTg+YRC1h9Uj/keLksXIrE63NrtpvK6geGXetPebWtNFaYzX lrucFahBCJ3/lhj/vobnM9Wn8uVnslhgGTuo+ccxOyDG/KMDuTED3O8r89OfU/ZhTjv8 cu5g== X-Gm-Message-State: AOAM532l8uPGagmszAwypsaSVNI+CfDyWjqEb/NIzr/rZZ3eOq4VFp/v iaPGfE5q9qzLeYK2ukoqI9sfEg== X-Google-Smtp-Source: ABdhPJynOMIFbkh2evNpYVG36xC3WaixnyaUIV1E05ed1ZnljsyOTAKn+OPYhXluH5n/QUuNSW0WpA== X-Received: by 2002:a17:906:2d51:: with SMTP id e17mr26408407eji.500.1628585200703; Tue, 10 Aug 2021 01:46:40 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id fl2sm1533516ejc.114.2021.08.10.01.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:40 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 1/6] acpi: Add VIOT structure definitions Date: Tue, 10 Aug 2021 10:45:01 +0200 Message-Id: <20210810084505.2257983-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810084505.2257983-1-jean-philippe@linaro.org> References: <20210810084505.2257983-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ACPI Virtual I/O Translation table (VIOT) table describes I/O topology for paravirtual devices. At the moment it describes the relation between virtio-iommu devices and their endpoints. Add the structure definitions for VIOT. Signed-off-by: Jean-Philippe Brucker --- Following the latest spec draft, and related acpica change https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf https://github.com/acpica/acpica/commit/fc4e33319c1ee08f20f5c44853dd8426643f6dfd --- include/hw/acpi/acpi-defs.h | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index cf9f44299c..adbf7d7b77 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -618,4 +618,64 @@ struct AcpiIortRC { } QEMU_PACKED; typedef struct AcpiIortRC AcpiIortRC; +/* + * Virtual I/O Translation Table + */ +struct AcpiViot { + ACPI_TABLE_HEADER_DEF + uint16_t node_count; + uint16_t node_offset; + uint8_t reserved[8]; +} QEMU_PACKED; +typedef struct AcpiViot AcpiViot; + +#define ACPI_VIOT_NODE_HEADER_DEF /* Fields common to all nodes */ \ + uint8_t type; \ + uint8_t reserved; \ + uint16_t length; + +/* Values for node Type above */ +enum { + ACPI_VIOT_NODE_PCI_RANGE = 0x01, + ACPI_VIOT_NODE_MMIO = 0x02, + ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI = 0x03, + ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO = 0x04, +}; + +struct AcpiViotPciRange { + ACPI_VIOT_NODE_HEADER_DEF + uint32_t endpoint_start; + uint16_t segment_start; + uint16_t segment_end; + uint16_t bdf_start; + uint16_t bdf_end; + uint16_t output_node; + uint8_t reserved1[6]; +} QEMU_PACKED; +typedef struct AcpiViotPciRange AcpiViotPciRange; + +struct AcpiViotMmio { + ACPI_VIOT_NODE_HEADER_DEF + uint32_t endpoint; + uint64_t base_address; + uint16_t output_node; + uint8_t reserved1[6]; +} QEMU_PACKED; +typedef struct AcpiViotMmio AcpiViotMmio; + +struct AcpiViotVirtioIommuPci { + ACPI_VIOT_NODE_HEADER_DEF + uint16_t segment; + uint16_t bdf; + uint8_t reserved1[8]; +} QEMU_PACKED; +typedef struct AcpiViotVirtioIommuPci AcpiViotVirtioIommuPci; + +struct AcpiViotVirtioIommuMmio { + ACPI_VIOT_NODE_HEADER_DEF + uint8_t reserved1[4]; + uint64_t base_address; +} QEMU_PACKED; +typedef struct AcpiViotVirtioIommuMmio AcpiViotVirtioIommuMmio; + #endif From patchwork Tue Aug 10 08:45:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12428387 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 96DA4C4338F for ; Tue, 10 Aug 2021 08:49:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDF6E61019 for ; Tue, 10 Aug 2021 08:49:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CDF6E61019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNS4-0006Rf-QB for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:49:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPK-0006VE-9H for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:42508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPG-000834-TN for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: by mail-ej1-x632.google.com with SMTP id e19so33990772ejs.9 for ; Tue, 10 Aug 2021 01:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/o/Uf1wri3qCwdek1lnFkD8g6fp4lM2+UgFr9YmIozI=; b=nQ+UUoP+wuuPbFTDeFkTMF34/YPBHROLUxIe/NQXg/bFVM8RJtY1Xs1iGWzG/Qc4uQ naQz2qviShtJJBgxCdT9kd4iH4uML//DJJpDx/hCt/SUix/IR7v03bWAvC7dwzhGhDET zFG5ABkd0KFIORLgG5BAfJIj0r/V9SDVQQvYrtfRvjWvBS5DXAkEHmsmE5u79cofIVJ1 Du4CSJgFfETYEnKPAAdef75hgSpCR14l5qHrkhf69rAgeyZq/L5d28UUruaKaWpQpjxI 9VbBLHhmvvzFVrO38K258OYCe6TJm31f21WwWpejYAzqzM0GrrBCPDrg8HvudNEnyFpx SFWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/o/Uf1wri3qCwdek1lnFkD8g6fp4lM2+UgFr9YmIozI=; b=X6Vw6I6h2e2VIaWjBmH6t43y55DDCtC4awFgym9ADO8dI0F7r/2EiZCuIUxe+zcwXP 36G8t4yD9gd45uh16HqtCJCyeXKNhgE32xjmy/CJJi094jJGJyQTKGQ26OOu2Wfi4oto rqkwXGlEBMYcxKMMySloSMos96IK+OQKbnNdWZPjKBQwnNCpsYXfArr7y8cSG5F+ihOW LTUtyGDmrEwtF7z9X26TkBuurOVdC03RDmeUxTKdg59O8W3Ptb2n5n+9T4QNNvIIJash RmJoXet+7WZLzOacfwXxqjoiJU9zKLCAzEii+xVNtMOrXpDpB8MFPzmDMVEuWzOCuim+ u5pQ== X-Gm-Message-State: AOAM53141saQiadWd9u4A2JZct2dSKoPKahx/RYl2oGtH3EY0fgfrL+W WraB6Xn1JCix+LUTh/P2V95Lxw== X-Google-Smtp-Source: ABdhPJxuZwWRATtwAXz8XAqpeTqYMK5V82Koefu2JnWonplrAxQC65sVkhZpxrY/KC6Aytjs4dItzA== X-Received: by 2002:a17:906:8606:: with SMTP id o6mr26853228ejx.247.1628585201594; Tue, 10 Aug 2021 01:46:41 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id fl2sm1533516ejc.114.2021.08.10.01.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:41 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 2/6] hw/acpi: Add VIOT table Date: Tue, 10 Aug 2021 10:45:02 +0200 Message-Id: <20210810084505.2257983-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810084505.2257983-1-jean-philippe@linaro.org> References: <20210810084505.2257983-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x632.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a function that generates a Virtual I/O Translation table (VIOT), describing the topology of paravirtual IOMMUs. The table is created when instantiating a virtio-iommu device. It contains a virtio-iommu node and PCI Range nodes for endpoints managed by the IOMMU. By default, a single node describes all PCI devices. When passing the "default_bus_bypass_iommu" machine option and "bypass_iommu" PXB option, only buses that do not bypass the IOMMU are described by PCI Range nodes. Signed-off-by: Jean-Philippe Brucker --- hw/acpi/viot.h | 13 +++++++ hw/acpi/viot.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/Kconfig | 4 +++ hw/acpi/meson.build | 1 + 4 files changed, 100 insertions(+) create mode 100644 hw/acpi/viot.h create mode 100644 hw/acpi/viot.c diff --git a/hw/acpi/viot.h b/hw/acpi/viot.h new file mode 100644 index 0000000000..4cef29a640 --- /dev/null +++ b/hw/acpi/viot.h @@ -0,0 +1,13 @@ +/* + * ACPI Virtual I/O Translation Table implementation + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef VIOT_H +#define VIOT_H + +void build_viot(GArray *table_data, BIOSLinker *linker, + uint16_t virtio_iommu_bdf, const char *oem_id, + const char *oem_table_id); + +#endif /* VIOT_H */ diff --git a/hw/acpi/viot.c b/hw/acpi/viot.c new file mode 100644 index 0000000000..5cd10e9553 --- /dev/null +++ b/hw/acpi/viot.c @@ -0,0 +1,82 @@ +/* + * ACPI Virtual I/O Translation table implementation + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/viot.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" + +/* Build PCI range for a given PCI host bridge */ +static int viot_host_bridges(Object *obj, void *opaque) +{ + GArray *pci_range_blob = opaque; + + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { + PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus; + + if (bus && !pci_bus_bypass_iommu(bus)) { + int min_bus, max_bus; + + pci_bus_range(bus, &min_bus, &max_bus); + + AcpiViotPciRange pci_range = { + .type = ACPI_VIOT_NODE_PCI_RANGE, + .length = cpu_to_le16(sizeof(pci_range)), + .bdf_start = cpu_to_le16(PCI_BUILD_BDF(min_bus, 0)), + .bdf_end = cpu_to_le16(PCI_BUILD_BDF(max_bus, 0xff)), + .endpoint_start = cpu_to_le32(PCI_BUILD_BDF(min_bus, 0)), + }; + + g_array_append_val(pci_range_blob, pci_range); + } + } + + return 0; +} + +/* + * Generate a VIOT table with one PCI-based virtio-iommu that manages PCI + * endpoints. + */ +void build_viot(GArray *table_data, BIOSLinker *linker, + uint16_t virtio_iommu_bdf, const char *oem_id, + const char *oem_table_id) +{ + int i; + AcpiViot *viot; + AcpiViotPciRange *pci_range; + AcpiViotVirtioIommuPci *viommu; + int viommu_off = sizeof(*viot); + int viot_start = table_data->len; + GArray *pci_ranges = g_array_new(false, true, sizeof(*pci_range)); + + viot = acpi_data_push(table_data, sizeof(*viot)); + viot->node_offset = cpu_to_le16(viommu_off); + + viommu = acpi_data_push(table_data, sizeof(*viommu)); + viommu->type = ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI; + viommu->length = cpu_to_le16(sizeof(*viommu)); + viommu->bdf = cpu_to_le16(virtio_iommu_bdf); + + /* Build the list of PCI ranges that this viommu manages */ + object_child_foreach_recursive(object_get_root(), viot_host_bridges, + pci_ranges); + + for (i = 0; i < pci_ranges->len; i++) { + pci_range = &g_array_index(pci_ranges, AcpiViotPciRange, i); + pci_range->output_node = cpu_to_le16(viommu_off); + } + viot->node_count = cpu_to_le16(pci_ranges->len + 1); + + g_array_append_vals(table_data, pci_ranges->data, + pci_ranges->len * sizeof(*pci_range)); + g_array_free(pci_ranges, true); + + build_header(linker, table_data, (void *)(table_data->data + viot_start), + "VIOT", table_data->len - viot_start, 0, oem_id, oem_table_id); +} + diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index cfc4ede8d9..abad79c103 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -41,6 +41,10 @@ config ACPI_VMGENID default y depends on PC +config ACPI_VIOT + bool + depends on ACPI + config ACPI_HW_REDUCED bool select ACPI diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index 29f804d13e..a510988b27 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -16,6 +16,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c')) acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c')) acpi_ss.add(when: 'CONFIG_ACPI_X86', if_true: files('piix4.c', 'pcihp.c')) +acpi_ss.add(when: 'CONFIG_ACPI_VIOT', if_true: files('viot.c')) acpi_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('ich9.c', 'tco.c')) acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: files('ipmi-stub.c')) acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) From patchwork Tue Aug 10 08:45:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12428399 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 D0D26C4338F for ; Tue, 10 Aug 2021 08:51:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3FD8960ED8 for ; Tue, 10 Aug 2021 08:51:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3FD8960ED8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNTP-0001EI-7z for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:50:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPK-0006W6-L5 for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:33336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPI-00083v-2L for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: by mail-ed1-x533.google.com with SMTP id by4so10329245edb.0 for ; Tue, 10 Aug 2021 01:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a03XgQNkFMPjBL/zvIBVfYCJefW6jvTdpIcqSkUY9rI=; b=u1e5c0Sk3pIOVi1F9DI9SZVYO4dUSulXZ81wo6KgFlZA7aJlfITm5Eru4O7myZ8xEn czUTu6hJ5Sy8a+HuZAGdn2CbOLXEJ+30wvgwJaUwObGiOZVGwV5nxbLAYqT1n6BddoUq J8+534SSeeINaLRkj7+hxWe58EWwZ5gjpMzxtkkAjcao0ds8ziQEq+cWhyw5aXe5k1oz T+W9d8fMzAuN0ZSsmd86+kFpt83jcm3mJiPeUlgL1QCEV2yKFZ3u38JEEmtcGgtA4wpY pESnSWHe/60wuRThjkDeIRjwstFgfVjp+EkoZXBGKiUSZRem23yVnkuLtCw2gEysGNuA xv7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a03XgQNkFMPjBL/zvIBVfYCJefW6jvTdpIcqSkUY9rI=; b=hVRunHpb/02zXYrgPxRsnDenHCZ49ntwo5dEG7mBj6edc9baxD6B5FslsRYNJIK0HI 6ltEfY4Qb4QGSeeh7FID/zYxGeJvmPn8bBdZrO10aWQczsLwF2bnvfjsrb5eKLqp+04X 7jR2eKgLUvJkPA6tZ1vtkozgF2W5MQ43qVVHCD1iu22oagRD371032hxBAvRQkdbs1f2 3dfGDUwiKJ4R5LLXhF+1ehPgelYovU48oT+3yaBGRX1r5noMt/IXlprW9MrYyF7xRRhO eKFkSBZwvTE+JSt8Xkdz/K3ifcii/zUYlYESXAm/qR7PZgxmqr+QxMc4O64Ybxe7yNo/ RqoQ== X-Gm-Message-State: AOAM533HL1j1FEvmjOgVP+DmxTCVqqM3++65KGLx5lGq7oTCvb7dwhzQ ZlWzwOlUYph8Q6SudOeKBZZ8MQ== X-Google-Smtp-Source: ABdhPJy4yaOV9xftfj0WUrN5deo6EqYz3S7ai5YLcM9ACTWhg8ii0wYrC3+QBpGL630kbLcTkLaWRg== X-Received: by 2002:a05:6402:619:: with SMTP id n25mr3645198edv.243.1628585202531; Tue, 10 Aug 2021 01:46:42 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id fl2sm1533516ejc.114.2021.08.10.01.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:42 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 3/6] hw/arm/virt-acpi-build: Add VIOT table for virtio-iommu Date: Tue, 10 Aug 2021 10:45:03 +0200 Message-Id: <20210810084505.2257983-4-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810084505.2257983-1-jean-philippe@linaro.org> References: <20210810084505.2257983-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=jean-philippe@linaro.org; helo=mail-ed1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When a virtio-iommu is instantiated, describe it using the ACPI VIOT table. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt-acpi-build.c | 7 +++++++ hw/arm/Kconfig | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 037cc1fd82..e2fa677d80 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -55,6 +55,7 @@ #include "kvm_arm.h" #include "migration/vmstate.h" #include "hw/acpi/ghes.h" +#include "hw/acpi/viot.h" #define ARM_SPI_BASE 32 @@ -849,6 +850,12 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) } #endif + if (vms->iommu == VIRT_IOMMU_VIRTIO) { + acpi_add_table(table_offsets, tables_blob); + build_viot(tables_blob, tables->linker, vms->virtio_iommu_bdf, + vms->oem_id, vms->oem_table_id); + } + /* XSDT is pointed to by RSDP */ xsdt = tables_blob->len; build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id, diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 4ba0aca067..7da0422446 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -29,6 +29,7 @@ config ARM_VIRT select ACPI_HW_REDUCED select ACPI_NVDIMM select ACPI_APEI + select ACPI_VIOT config CHEETAH bool From patchwork Tue Aug 10 08:45:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12428385 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 91F69C4320A for ; Tue, 10 Aug 2021 08:49:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECB6E61019 for ; Tue, 10 Aug 2021 08:49:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ECB6E61019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNRp-0005jd-08 for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:49:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPK-0006WM-SK for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:43733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPI-00084j-Oo for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:46 -0400 Received: by mail-ej1-x62d.google.com with SMTP id b15so9914635ejg.10 for ; Tue, 10 Aug 2021 01:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w0WrmTsj2crsjvUQBpyETk8wh1igNNKeXtR7nnjXX9k=; b=GSU4LoJJbL9VyHHM3L22tON6TYOqHzdu9c4dpHA5Bi+yX/i1Ju/HZC22lZPEObqV9C vOVpk+BaFTRms839Of775KYjhOKZKhMEqwCij70r4B2Mlgpjid+xRAcHZ5BznolZuP9W Rb0yExz/vjGwRvprqgCJIu0w80Kn83UHjjnyc3+FHW+Kq+iq8E0dYZz5A4B8kMqoR0Wj BSSo1aN2yt+9dU3Q4sBuskHLozwxpd5SmXiQobkE0/wBW2oH0UjPBcZ7zrWJmpkn+YvQ NYWZmZ0MTb7cxQfS/Shb9fdLU0rjlwKjRY4vp7OkoCGpyJsGCElhu6HrWwmbEohHiU7A nHrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w0WrmTsj2crsjvUQBpyETk8wh1igNNKeXtR7nnjXX9k=; b=Wkmu3TkSNhOLf+FGxXOb2Ha9kn2PA7wDtCzqGtq7iMuFzLiGA/IXOyH3PbsP+QjsHD z0yvgyqbrq0syvq7q9U1f07IyuTst1Ayw5/Md/lJm7wviInA2QvZLlIu1kc8jkKWlZo5 FX5Np1JaNAbu8NrDh2I8m+QohpYAet9ApxQs6oporcxdetZwGkFYD9/DQGuq5TJ5IUPG Vg4vb/DYcQ1fyaF79YGEuohKI6lJ2CCrO8A1Lv9liadTj0veA+ERkqvJLL2Czqa4Gaq/ XSAPUdRTcR8o+Vy5Qo84XNXyg1+086PqFoPoAXpLZtTGWyXjeNh83ZTozRQsNFWVvIQP ONnw== X-Gm-Message-State: AOAM533qmnhI4VQ7gEJS2yIfGM6005OhvK4eECWpmC0LW6VF85b+zoXS qilJmdVR3MT8/kDD5T6V7pqhbg== X-Google-Smtp-Source: ABdhPJy80Nj9NM828DCXOKRe4hszP4d3sAkCbA0BnrTQ4kGQTAOJMsznmEj3Uqyq2IAhzEhwU8s4jw== X-Received: by 2002:a17:906:e0ce:: with SMTP id gl14mr26936247ejb.168.1628585203430; Tue, 10 Aug 2021 01:46:43 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id fl2sm1533516ejc.114.2021.08.10.01.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:43 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 4/6] hw/arm/virt: Remove device tree restriction for virtio-iommu Date: Tue, 10 Aug 2021 10:45:04 +0200 Message-Id: <20210810084505.2257983-5-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810084505.2257983-1-jean-philippe@linaro.org> References: <20210810084505.2257983-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" virtio-iommu is now supported with ACPI VIOT as well as device tree. Remove the restriction that prevents from instantiating a virtio-iommu device under ACPI. Signed-off-by: Jean-Philippe Brucker --- hw/arm/virt.c | 10 ++-------- hw/virtio/virtio-iommu-pci.c | 7 ------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 81eda46b0b..b4598d3fe6 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2551,16 +2551,10 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, MachineClass *mc = MACHINE_GET_CLASS(machine); if (device_is_dynamic_sysbus(mc, dev) || - (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { return HOTPLUG_HANDLER(machine); } - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { - VirtMachineState *vms = VIRT_MACHINE(machine); - - if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { - return HOTPLUG_HANDLER(machine); - } - } return NULL; } diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c index 770c286be7..f30eb16cbf 100644 --- a/hw/virtio/virtio-iommu-pci.c +++ b/hw/virtio/virtio-iommu-pci.c @@ -48,16 +48,9 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) { - MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); - - error_setg(errp, - "%s machine fails to create iommu-map device tree bindings", - mc->name); error_append_hint(errp, "Check your machine implements a hotplug handler " "for the virtio-iommu-pci device\n"); - error_append_hint(errp, "Check the guest is booted without FW or with " - "-no-acpi\n"); return; } for (int i = 0; i < s->nb_reserved_regions; i++) { From patchwork Tue Aug 10 08:45:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12428381 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 7CC14C4338F for ; Tue, 10 Aug 2021 08:48:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED1FC60F25 for ; Tue, 10 Aug 2021 08:48:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ED1FC60F25 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNQW-0000wF-7m for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:48:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPL-0006ZF-Vj for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:48 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:33557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPJ-00085z-Lb for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:47 -0400 Received: by mail-ej1-x630.google.com with SMTP id hs10so34116292ejc.0 for ; Tue, 10 Aug 2021 01:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lKy7vQ/+L1TPLeHZOFXY0eP2HbiclZAzdFbqfddm5Y4=; b=rd3WsHeuO1qx5IvNODbz1WmK5JsjMTy4OdiZSVrjdXOC3SBxbu0VTiGqxxwFBOOz1q lml4LomoTzRnbJIMWXeOOgzGHzP/00ozH1J6ZMv+Drl55NiaY7hZCAd2VxQMpQvBTwHf w+aBRnCSr4SY1HjjA4WlhklnUqyO97mLx1LqaHDZ5pmzejPX0AVgNHA0a4z8KUlLGA5O 3bYHvfMnOmTPoAsflu8tIo3Ae/YmG32wt8+KSWlYZyepyhWvspebr0NfAn6u2D0Y+DWS LfL4YsFI8aMIr5AMuwc9WgSzAuSl90KZu7yC7YUKa5dizTE8maPkGDS87Xuncuuvi2JY SsJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lKy7vQ/+L1TPLeHZOFXY0eP2HbiclZAzdFbqfddm5Y4=; b=PXmAtRcm/1qg/Z4E0GU6wB7YGlHztlyHUQQ4fErmSviXvwyOfJSb3Vk0xEfD9MZ5cQ x4N0ktzYt4iSUm+4on7NfdlFUgg/e/JF0Gju8R1TzF8iCzw+T43L9i5Y1qXUY2f5ipB7 uNGc3ekU+SWR7v7xHq9KXp25fRBpmtcQTsMEKb73EcsqAyxK9iIeFYqB6Ybhlhtrfa55 hOK6MTPvH6QU69WevXppnpCXc22GA5ThrBs7G9afmT5CQW4KI+WuHwMqnlM8HsNJvWZp KJYYdo9Ncyd7bAMLLmbekk4WZI+pVTsqGTi+OqWyqSPpNFn8Mt9fwLfVx6N3eB42eD0p cvvA== X-Gm-Message-State: AOAM533eej+fS4HG6rnddc7R1t6L5XhJndrA+rethEIvp0o0V7SA4TkI 04WlCKZYo5obQN+60Sig49jaBg== X-Google-Smtp-Source: ABdhPJzi/4diVuWm4pGC1n7HWit8QOZTLS5tc+sHvsYDyClMljRJto3UMUFltL0Wk5FbFOFfWLUEPw== X-Received: by 2002:a17:907:98b9:: with SMTP id ju25mr26588005ejc.290.1628585204387; Tue, 10 Aug 2021 01:46:44 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id fl2sm1533516ejc.114.2021.08.10.01.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:43 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 5/6] pc: Add VIOT table for virtio-iommu Date: Tue, 10 Aug 2021 10:45:05 +0200 Message-Id: <20210810084505.2257983-6-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810084505.2257983-1-jean-philippe@linaro.org> References: <20210810084505.2257983-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x630.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ACPI Virtual I/O Translation table (VIOT) describes the relation between a virtio-iommu and the endpoints it manages. When a virtio-iommu device is instantiated, add a VIOT table. Signed-off-by: Jean-Philippe Brucker --- include/hw/i386/pc.h | 2 ++ hw/i386/acpi-build.c | 5 +++++ hw/i386/pc.c | 7 +++++++ hw/i386/Kconfig | 1 + 4 files changed, 15 insertions(+) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 88dffe7517..979b8d0b7c 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -45,6 +45,8 @@ typedef struct PCMachineState { bool pit_enabled; bool hpet_enabled; bool default_bus_bypass_iommu; + bool virtio_iommu; + uint16_t virtio_iommu_bdf; uint64_t max_fw_size; /* NUMA information: */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a33ac8b91e..078b7f5c6f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -71,6 +71,7 @@ #include "hw/acpi/ipmi.h" #include "hw/acpi/hmat.h" +#include "hw/acpi/viot.h" /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows @@ -2559,6 +2560,10 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) build_dmar_q35(tables_blob, tables->linker, x86ms->oem_id, x86ms->oem_table_id); } + } else if (pcms->virtio_iommu) { + acpi_add_table(table_offsets, tables_blob); + build_viot(tables_blob, tables->linker, pcms->virtio_iommu_bdf, + x86ms->oem_id, x86ms->oem_table_id); } if (machine->nvdimms_state->is_enabled) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c2b9d62a35..694fc9ce07 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -84,6 +84,7 @@ #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" #include "standard-headers/asm-x86/bootparam.h" +#include "hw/virtio/virtio-iommu.h" #include "hw/virtio/virtio-pmem-pci.h" #include "hw/virtio/virtio-mem-pci.h" #include "hw/mem/memory-device.h" @@ -1388,6 +1389,12 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { pc_virtio_md_pci_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { + PCMachineState *pcms = PC_MACHINE(hotplug_dev); + PCIDevice *pdev = PCI_DEVICE(dev); + + pcms->virtio_iommu = true; + pcms->virtio_iommu_bdf = pci_get_bdf(pdev); } } diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index ddedcef0b2..13db05d557 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -54,6 +54,7 @@ config PC_ACPI select ACPI_X86 select ACPI_CPU_HOTPLUG select ACPI_MEMORY_HOTPLUG + select ACPI_VIOT select SMBUS_EEPROM select PFLASH_CFI01 depends on ACPI_SMBUS From patchwork Tue Aug 10 08:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12428383 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 6B44EC432BE for ; Tue, 10 Aug 2021 08:48:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B579960234 for ; Tue, 10 Aug 2021 08:48:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B579960234 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNQv-0002CZ-M5 for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPM-0006aa-DY for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:48 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:42504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPK-00086u-SU for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:48 -0400 Received: by mail-ej1-x62d.google.com with SMTP id e19so33991148ejs.9 for ; Tue, 10 Aug 2021 01:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xB7FpPG1QBi8Fyann/5OmrdvhqhF3tJF6qRyCpwuZjo=; b=wo5V/IbMUuxMOuQOyy1gdEqRgFC/HZcZtPt9RnKGom8BsuPsFVvpq0ZwJa5rrJyq0y cOni6T346vHfbam6siIL+lORtLuUahArN8B6oE7yrDgFg1lBLb5Y3T0Cxj8Kn2Spxi7B 5iTeM/ANVNh9UWV1w9UjvC72mJ+k0PNJGnPguz65E0biVDrj9fcAX7qu/F5gT98ohXMY KscK2Gt/ghAJ7XNzCcjpWUEUvlGssoDGr+FamzmiQmeG50Ei2tSAYjV7EQdqXVKEfE6l XKHmgfNOshVP6q3KippUcHNUqWGx8HtXFBA8wA3kw0w0fsdNSOon6Q33foVgLu6EWbJP hBPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xB7FpPG1QBi8Fyann/5OmrdvhqhF3tJF6qRyCpwuZjo=; b=W95Z0w+cXZeZQgdEPnp7RRueNpVbolzeSHhkp2ouadIPvY1cVcibwDRIWSqKDZO3l3 BUo8bsNsnnn1+qcSGfBeEhqqdt1emPeK1H6AicP6z7A/ag34365UBSrsg+AlsYb6oLmM 9o5WwDa+MeefWgSO9G4GgfW2C9rtpetIfwzPUT5kvDu1CMrWgBcdeJ09kwqTGqc6urRn 6SBP2WELlowxElyopUkcmwZXL3G8q/dMK4QrSKVHUWCKsTS0/iQQMfNI4dxujQvGAKyB Aq+K2sQjfzoUM0V8InvZUhJ0nsTlB36UwneNeIaPkFqO0oChuJpNW/dj/ybB8QHMVYio P9Iw== X-Gm-Message-State: AOAM5322IJVwFroLM9/cs0vKVYncgw9t2NOWlB7bKfQsIbAb8giv/3eF pPifS23p2v8M4f27lTUTLFfhrg== X-Google-Smtp-Source: ABdhPJzo+G7TlUr10RweXz+ZbK26erpsmLHV/vTJXpJhGfmFYXQdG3FmHz9Rp3vAUdf+oUGNYid4jA== X-Received: by 2002:a17:907:7291:: with SMTP id dt17mr11359697ejc.162.1628585205361; Tue, 10 Aug 2021 01:46:45 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id fl2sm1533516ejc.114.2021.08.10.01.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:44 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 6/6] pc: Allow instantiating a virtio-iommu device Date: Tue, 10 Aug 2021 10:45:06 +0200 Message-Id: <20210810084505.2257983-7-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810084505.2257983-1-jean-philippe@linaro.org> References: <20210810084505.2257983-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=jean-philippe@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com, Jean-Philippe Brucker , qemu-arm@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Eric Auger Add a hotplug handler for virtio-iommu on x86 and set the necessary reserved region property. On x86, the [0xfee00000, 0xfeefffff] DMA region is reserved for MSIs. DMA transactions to this range either trigger IRQ remapping in the IOMMU or bypasses IOMMU translation. Although virtio-iommu does not support IRQ remapping it must be informed of the reserved region so that it can forward DMA transactions targeting this region. Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker --- hw/i386/pc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 694fc9ce07..fb24f000e7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1376,6 +1376,14 @@ static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { pc_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { + /* Declare the reserved MSI region */ + char *resv_prop_str = g_strdup_printf("0xfee00000:0xfeefffff:%d", + VIRTIO_IOMMU_RESV_MEM_T_MSI); + + qdev_prop_set_uint32(dev, "len-reserved-regions", 1); + qdev_prop_set_string(dev, "reserved-regions[0]", resv_prop_str); + g_free(resv_prop_str); } } @@ -1436,7 +1444,8 @@ static HotplugHandler *pc_get_hotplug_handler(MachineState *machine, if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_CPU) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_PMEM_PCI) || - object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) || + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { return HOTPLUG_HANDLER(machine); }