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: 494328 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3733753jap; Tue, 10 Aug 2021 01:47:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/j5A5JykhBH/JG4yY3Xik2PCtD6nr7gsiehVAJC/m8/dweSMQUM1vu4jgejyMl7g4gMKu X-Received: by 2002:a6b:440d:: with SMTP id r13mr151800ioa.1.1628585229562; Tue, 10 Aug 2021 01:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628585229; cv=none; d=google.com; s=arc-20160816; b=EYOfNskoVbAX+mG6qf5YKiF1zVeeYjovYSy8l8KqvL/lkJUi7judKC3zs9+3BAdEBe 5Ha63861Mw/nWHEJtazR2I7DDN432l4RAb2qztELxGpEpArE+Zj1VHHexkfRb5EXTWmW gOrSMQLAClVV2dQxaRefKgyjAlrJYcHy1wSqluFf1BRxsEGged+ED2O3FZz1DM32w75U dVRcuOXN0NQuFC6QR7kkMxpsUq6PoqZXjw0avPJY7UKb/11+1PqdOoqfRmRqmw8M4WOI H5HIRDxokY2FtO2ETQlVvi1Okhn6bKba/XzBwQuXEAKdiYjdJtvkZMbcRxB+m0d8vHVz J+FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tM+6Q/09BSPbSVODH5fu80QY1gdHUNNnA2XQdyRcxCo=; b=XEyZ5iAtCV0PmnNEkYhiBUUUwPr9uE2gPBWNXLwSnE3/jbcWzVT+kBYWvUef0Nutd1 vETmEDcNVxOtbrlEZeGR+P/AfpDWQCmQKD4eAmBO9FRgKDNCxgZH7us/oXwFvLr0BWgo zbZ+TTY+SxC+kzv+vxZJXrHsgQNRzFC1MOLszUDtWfScAnZYNuxJE2fQj9qAKMJl++S9 nuVTHXcWvXDwF5+W2aTZKnbX9TpAjHedcPLXYrXmKyUvsGA1KFVIL7A5uMdcLDZU1fiS u9DvafbuzjPFb60Jj1r4wJrojIzAMLoGEZ0InjirMCbhhNZ7JDr/HpPdMsl6ghcN8cTc KULw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bgg2g5BG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay15si2779018jab.111.2021.08.10.01.47.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Aug 2021 01:47:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bgg2g5BG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNPg-0006Zl-V0 for patch@linaro.org; Tue, 10 Aug 2021 04:47:08 -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-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+patch=linaro.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(+) -- 2.32.0 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: 494333 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3735282jap; Tue, 10 Aug 2021 01:49:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztIorqwg7JF/kc/HnGDiW6bkyHHhp7sRaQ47h1OjQ8g/Byl8Av/IWxiDmYRpVd6rOxN/QO X-Received: by 2002:a92:d650:: with SMTP id x16mr497287ilp.195.1628585364218; Tue, 10 Aug 2021 01:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628585364; cv=none; d=google.com; s=arc-20160816; b=Ze7F0xsEa4qmcUe1r+zAo37zuF4N/lna8HXUf2M1ZtwDaAEBhIg1QCE0mKuq/k6REt DjlXq9fJPPkJ6O0Rwu2IKNN1plw8n3CD8rE2B/PKcTxH/ahjsgIXY9fS3FPpys7QsF8z dQQGZqVenNhXEwaP+otIBu78FhCvK2YnX3o/lOrfF3XIohROZqvGjBLdCmwTSts8Bglo NdV6V0/0zOtlqcAulk3J0hpOSqO5qh+NGPBThYmVG4apv9udDkgZnueKxPEH9maeDw/a npsWAujy+f7gZmRMfePc6hl3apxgJRg14/jkV+NBq+FmYb6TnAhO8eRqGe+iJXFa3cX+ x5kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=/o/Uf1wri3qCwdek1lnFkD8g6fp4lM2+UgFr9YmIozI=; b=aXb1RpputIX+ruYBhH0cPypVCzrLiXZ3EgvDYOeSsjKYutt+Q71+fRcEdWqzeyDL+K Bwx/ZsGF5XpDIblCdYdtg5NkeCt+v4o3oZburSpxgXzQ6d5XQJHr1ZgMHP0HYRwDBBhi VPqF8WG9zIASpYFWGDNPMjwDMh5A1BS2puV65A/gDdZxvSloCPKXwEJDIkDcKGpKEUhb tkaVPpbTe4OIEjW3firH70PVexZWAy9deXTD5TlcUkrtyoBAUj0urzmkjnFsQvDqYCPz m7/wBdRexryjufs0jxlsYd++kRkMmr/MhOffpYmQxTQlRKJlRN9ZKSOGOyfdYucl7Nl7 Dnmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nQ+UUoP+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b2si3440108jat.76.2021.08.10.01.49.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Aug 2021 01:49:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nQ+UUoP+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNRr-0004rs-KV for patch@linaro.org; Tue, 10 Aug 2021 04:49:23 -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-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+patch=linaro.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 -- 2.32.0 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: 494334 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3735880jap; Tue, 10 Aug 2021 01:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP1yi5TsGW84zpqrMoM5gyo1nB1oLTNdaD+xKl0Mqbn5wrQVA4uR7ox2XbQ+LTsln2a4d4 X-Received: by 2002:a5e:a907:: with SMTP id c7mr126891iod.46.1628585411641; Tue, 10 Aug 2021 01:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628585411; cv=none; d=google.com; s=arc-20160816; b=g9UALsqFJ0c46/9vdebfArIFVbY/tdkR6CVoIgUjypHAeaBeDIxtfX8LzCbHxAV3hf Bew2UBSPBfiuA0d/FonSMBrgZkcbxSc227kB6UvPE7iPDa5X5gp7L6xw8YFK8arUs5vl hsKbTqjiBzOPF4Tm7jdC7sl+At5lZ53beyCTRipChOssm9OaMPy3Nw/IrKjwrrbANNCl 6r+2WujOprAIzWP0Qc7EdXbLe2C6FUowvH+YUWrTYqd6OOYaNi3xNW03FDEsMVrp+2/g L1qKXfqc0XSTgbxJ19qAbTrBA3FlNJ8K3z4ErGSKEfRcwbDiyJV+8238KjbD9SuFz8+t Qfmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=a03XgQNkFMPjBL/zvIBVfYCJefW6jvTdpIcqSkUY9rI=; b=bDu4P8SwE7K5/izPN0NwqOODZhhJjxgRfFO0h+ZUXfik2mSY3ogmNdgaLY8s2jR+3G IxmaWpl6uX/Evv1lslno4l9bwJCq2+WiQsfhVCsuyffXMCAPLIKIKANzm1i/WcVx1SSC P/lpnNaZnL9F0HR1xk12noxsDDoxEpnD/ZFLSHu4hnR2Nt52KvKa3V32RGwQYLd2jTTa 7Ow7lMfG6cl2DFcGWfE5d+6Pb6wzizdEsWB2RlCgzzvoR2JZLsOMBnO/m7Q6XFWXq8e8 u6YT7VD6IxQzurnJhGlBOGSb0HyAkR8M5clXQSotcHe5nfgdJSnIDMVk4HzJqCNb9fZE s88Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=u1e5c0Sk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p6si23348707ilo.37.2021.08.10.01.50.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Aug 2021 01:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=u1e5c0Sk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNSd-00086Z-3n for patch@linaro.org; Tue, 10 Aug 2021 04:50:11 -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-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+patch=linaro.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(+) -- 2.32.0 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: 494332 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3735075jap; Tue, 10 Aug 2021 01:49:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuW0OJ34fJDVXd9q/0YJYpRy9raOtg3tp6xn0qdlD/5ocaV//TS+7zHj5KlmsbAtDvhrTd X-Received: by 2002:a92:c8c1:: with SMTP id c1mr393198ilq.106.1628585348116; Tue, 10 Aug 2021 01:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628585348; cv=none; d=google.com; s=arc-20160816; b=zMMpq5LD2KdojQA+eEyGpxsg6qfX+iPwQ9ee9YfKSdxzP7pxMgcDfdJz40u/t2+cDY GFI8noCo+39V4RYcOS0GSOnLsQQL9m6/SvpSL+6JPtHhVz8S+I96Qa7KiCDDwRLz8JxK 9n3Eq18f1I4tJTFxtO9aOLuRM77R3CP2c/ucpjx2zGdrbUzhdsHMp304K9QhhIu+/bfD 7/6N5jfS8jp2vhhqbJ+GlLglrTadNeHo8sCyCQivd82o9S/X7Uv497tarH+2URej7eCR oXZ82lf5WsGN/YQKqUfIH3DCJIzH9dtLtM5RMEctBHaedyIp3QotoPp3mSUyfsh99dAE jBbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=w0WrmTsj2crsjvUQBpyETk8wh1igNNKeXtR7nnjXX9k=; b=LwKK3gJckaQG8BH80YQUVbrUYlmuQ+L4JCss1EVR02b5dalOlEW4nWmBfZR+SDZizL eq0nuCphQ4aoW0tcXqfKyTimvhiuiohEb8F/uRzMB8bAgoZyTL92meFVKCysWHip1cdu EcpaTl1A7acRi4tjrBjxfGycIIXlsWrbvwM968B7EXtdw1glJc10dO4qu0UESFN0WT7H Hb1A/wclRuvrH5Amm5WL6J4zcc35EipJYefA0oIYJdhWy0J+nY1xgskwDdkikRDh/K54 huwForsN+5RFiGhRgn4m+Ukvw9YhvUXURIfMMasJAKYUFZYN68b+emTMPnyYg3r7WWe5 YYEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GSU4LoJJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k14si20926153ion.22.2021.08.10.01.49.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Aug 2021 01:49:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GSU4LoJJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNRb-0003ni-Kf for patch@linaro.org; Tue, 10 Aug 2021 04:49:07 -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-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+patch=linaro.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(-) -- 2.32.0 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: 494331 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3734113jap; Tue, 10 Aug 2021 01:47:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFBFQSdKgX05gsvW+woihItxleYEozzRs47efmHnU4/smVbpfv/q5pGzPRV0P82WnL6wWf X-Received: by 2002:a05:620a:12bc:: with SMTP id x28mr27160019qki.419.1628585257285; Tue, 10 Aug 2021 01:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628585257; cv=none; d=google.com; s=arc-20160816; b=zM+UCMkLzL7LP3VDKseQU6c53e8NYTlwPXeDCsVEaH6mfWZGCxcl+3xtqlEchJAZrk am7GkitVSm2AkcygxUAulX6CPmo3QHfIo2kaHGQ2B/1Ru2ynHDymOBHNZghddFRwUDqH 6FILqtzfkiTlUrKQkh8joVrT6o/RZSzmUmgXo8fwjChMLrHAXqEKOckklKpv9OG1HfG4 DWnEzFqjUJ+dZ+KPVlhrhbbxzsOvekopLHCduk4IZYZroSgw2TpbDxxIhXoxE9rQ2ROE 8nGrakBszhPWIMWzZhkWlG1/6G1D/Jnv5FOjSmAQp5vwyPp2rWp+k93J0TvM7OPc5C9u cUwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=lKy7vQ/+L1TPLeHZOFXY0eP2HbiclZAzdFbqfddm5Y4=; b=eKzc3loA+mgYdhvtq+PYGuGxLeock5Tbx6/L12r3OBVDS3CAO6cCtRqT+A2MWnTx0m TFrsTWH75LYtVP++JMek006Ed4aSImc/bSYwEoyA6/OP/DnPYt+glBX7QI/5rv49yHEJ M9HUq6/Oc9I7QKxquriGok41CTnjfBsnje8KUb6xdJ1B7J5UiXU4Rfzpfp9uGr5DEDtI ALI4LRlSGraK54fsTwJhQ+reZBdf9uHLu+jG5+BkMuy7PaViamffW/+qXdmLQ15q6pGt YxqWTXc28oU/Qyzgr+uzxXyCLB8sI7aycAE4cDn6yOWfJXDFkVY3TVlrwJhd+0Tt9rjU T1tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rd3WsHeu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q2si9600067qtn.149.2021.08.10.01.47.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Aug 2021 01:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rd3WsHeu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNQ8-0006eV-Ka for patch@linaro.org; Tue, 10 Aug 2021 04:47:36 -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-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+patch=linaro.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(+) -- 2.32.0 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: 494329 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3734026jap; Tue, 10 Aug 2021 01:47:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWo5qIsiwZ8SRqL2BvjjZon/cI7pmX1U8McY7dkL5TT+b7mi61vM/cNbToAAcmwYsXeyc0 X-Received: by 2002:a37:84c1:: with SMTP id g184mr27600237qkd.102.1628585250691; Tue, 10 Aug 2021 01:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628585250; cv=none; d=google.com; s=arc-20160816; b=FGnmquvXsK/S/2bPs79+FOKBocWxvdDyEu7Xykk8s29tsN+wTo4Xsr56eXfE9pYWj+ TzF08E9Xx+EhGfDILDMHD5l7tLRf3wmEKnmkgFL4/SblAnH5A86Ygkk6rXF65sXrn1Kw +HY9QqjyIkSO9GZDnld71cS/vv+QHp3cMRberSAMbVgC5ZLK/+kxit76pAMQt76RMbIq kjrFh6xPWw9WQks1rAGQeDC351F60HSTjfoQNRfJ82RSxB6na4KfrUBumoousBs6kefZ 8p1cuSu6U8XqnyK/d0tpmAhTniOfOb1xHBICHuadScICbC21YZ5zB3xHbTnl43A6EYFC Advw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xB7FpPG1QBi8Fyann/5OmrdvhqhF3tJF6qRyCpwuZjo=; b=V4r7PIPVhQG1gwiXe5+3aowYhTDijVKyyeqrZ+WhtOco8bYhbuhyp2Vx0ULDwxMKme Q7UiZI0vcjMw/hcWACBlCzFBpAoVhvHusZ4P+JnWNuGZy+b+1Z5p6P9Zfe4E07uhHPEV ALkHQZwk1JVqcPBvT9AKKCN5+wpdKYPF9OTahgFVSwbkczwn1pONyO55sF4o4VkVlnjH o1zukBm1eGD689Yaw7b4rufnFTHR6g90UfTJy08PbfHFm7ddCUoDtuy7Nb4QQsmGlQyq aZahp1qtiAq20ODt0NYBftwEoCEucLfpLbaeQ2Lv2+BP7u/bVXvqOc4G0hXUMnDOeiOC +Hcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="wo5V/IbM"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u12si13195660qvg.181.2021.08.10.01.47.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Aug 2021 01:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="wo5V/IbM"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNQ2-0007zt-27 for patch@linaro.org; Tue, 10 Aug 2021 04:47:30 -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-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+patch=linaro.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(-) -- 2.32.0 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); }