From patchwork Tue Sep 14 14:19:55 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: 510939 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1621028jao; Tue, 14 Sep 2021 07:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqlBUIES6kAtiO78mAiew/SdF+pLnu+l+3QjBRVgBvpm8UAIjOdeK9Skb9mb/Rii8eXY4p X-Received: by 2002:a05:6130:31b:: with SMTP id ay27mr76401uab.135.1631631168120; Tue, 14 Sep 2021 07:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631631168; cv=none; d=google.com; s=arc-20160816; b=h1/YHZUWNgjG7IzQWKqs7VuFT/cNwlJf5J5fcqaZjSJbgsBAB8hzG4FzLEF3KaWoyh +SNxuTFdhIRWKfZ2djM/ldPEFctfU0yjZ4C3wADErJ6vKJ0vWk3a5R+GTZZfq0Lb3LGu 1JlDKr5DXYFutkixzOnGdWthXuC346+A3JPwv8QPwif9m4LVla2lCtkiyBMpveh2Xcrr U8Apcie4B8BU4DyU0OCPMMo44H/9YdB9az8OxFFTKR4tQkCVU5T0ylIxLGmNZzNTOTc6 aVMgo6Z9ImWxTqVv2j4FI+X112jMQgXy99tCKiry900Eod8J/U4zZS0pVzn5pziQe8+i SDwg== 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:message-id:date:subject:to:from:dkim-signature; bh=UHyMPYlDmIlbQAAhibWP9XaTuAff2yKrgLf7OIJQfpQ=; b=w3jTY2Nv8JdHA+lR2N0r6kjtV+IfUpKbj/bLpuG8D6wqnOMvtaFTcD8bXevpCdcz40 au4BfVOOoC2u4MjB+NlYJAg/W/agk+PGMj0vk862smlmw5mQ/ThjAARcZJKkaJlVp5zq Ie71S6NpnQ89pk+kQ33JBWmswPTBpKl0l6EFis0WvNBQ4UGuO0jLRJIRHZ+SOd7prRmn 7NJTwCABWX3Bp7AEkDFe7kazOTvsrgWcbg7rX2xr42DQJGHT1Z/JPt368DhpFZ78kHb3 Y3bUfyVuyY2nAsqwLLP2cPhg+zOh1cMjz5hDZj7cpzn17ZFwDtrcmu6AiuX66GwIW6fI QLcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qS7g8zxr; 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 f19si3766691vsq.404.2021.09.14.07.52.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Sep 2021 07:52:48 -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=qS7g8zxr; 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]:60302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9nj-0003xD-HI for patch@linaro.org; Tue, 14 Sep 2021 10:52:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9MP-00069p-K9 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:35 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:39548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQ9MH-0005Jd-9c for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:33 -0400 Received: by mail-wm1-x335.google.com with SMTP id 196-20020a1c04cd000000b002fa489ffe1fso2249025wme.4 for ; Tue, 14 Sep 2021 07:24:22 -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:mime-version :content-transfer-encoding; bh=UHyMPYlDmIlbQAAhibWP9XaTuAff2yKrgLf7OIJQfpQ=; b=qS7g8zxrXEidnQwPjtG+BfH2l5PHMHFvHxM9pQVY5k2uhQoulRiyJDxOg2gWL4+1nH GYN0qmanL1rFL/E7rg1yDgpSxiCOs37Yf4kPYOdCzeoS0BhWC0/omBikgIH5lliFN5To 5fkmfnioP1Nlh2xOYKtZku/M9U2QcTFxw3LsrtPHgp1vjtgyVQfciIbaG04jFam49wLw DufB1SV8nB5Yj49XTTPRWxhLhspQrenrDwTP8+PfSkhbCU9X41g8Wq6JC9JK2QQ3liqO ajzoaH4iSBD4RpFYActGu7LjOOaQCQQ+W+BdijPvRnSgrBvJySp57NbSov11PCA7j0uJ pS8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UHyMPYlDmIlbQAAhibWP9XaTuAff2yKrgLf7OIJQfpQ=; b=JXC8NNkrvo/MuPl/1pVuG5aSdclJQ6tcyyX/EADr7bFSQfk/7KpqD9awjmhK9O4pnC OyXTRuRpEwE3eNwY7g7fp9eSHqbYBgN3TN4EZX0H8NQzDroY/hlCh6/DlOaYPiK9cQ/f uAn/P/86kozNa+zsDyVXCRmtJfgCA+Uu5AjZooE/SF9i8uYitEDm0TYDqPSBb7jjVFFA t8vcuriyxll29iWL89bm0VgfqYi+7NQVYQ3fBhpZ3huaEGqM83PhJQBvx2/CeTEVQmP/ C03M3ndjF+DMPoyBX/TLREDNvmtu0aagN9zJtGt8kZe+9SFmJdM2+NIQFCqS8duyWVkU 0FKQ== X-Gm-Message-State: AOAM530U6WmGdBQpQmlBHSLOrlQNQOtNY1YdrtH0va9MTCB99H/NHSq3 wtEKipB3ZZC4VNLQKdGmADHIoA== X-Received: by 2002:a1c:a181:: with SMTP id k123mr2538278wme.90.1631629460929; Tue, 14 Sep 2021 07:24:20 -0700 (PDT) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id k6sm184252wmo.37.2021.09.14.07.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 07:24:20 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH v3 00/10] virtio-iommu: Add ACPI support Date: Tue, 14 Sep 2021 15:19:55 +0100 Message-Id: <20210914142004.2433568-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x335.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, ani@anisinha.ca, imammedo@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allow instantiating a virtio-iommu device on ACPI systems by adding a Virtual I/O Translation table (VIOT). Enable x86 support for VIOT. Changes since v2 [1]: * Use acpi_table_begin() and acpi_table_end(). This series now depends on "acpi: refactor error prone build_header() and packed structures usage in ACPI tables" [2] * Dropped ACPI header definitions. * Dropped doc patch, to be revisited later. * Squashed patch 5. * Added tests for q35 and virt machines: patch 6 temporarily enables blob updates (for bisectability), patch 7 adds the two test cases and patches 8-10 add the three reference tables. There is an important caveat at the moment: when virtio-iommu is instantiated, device DMA faults until the guest configures the IOMMU. Firmware is therefore unable to access storage devices and load the bootloader and OS. Upcoming patches will align virtio-iommu with other vIOMMUs and let DMA bypass the IOMMU during boot. In the meantime there are several ways to circumvent the problem: * Use plain old virtio-blk as storage, without enabling the 'iommu_platform' property. DMA from the device bypasses the IOMMU. * Place the storage device behind a PCI bus that bypasses the IOMMU, using the new 'bypass_iommu' bridge property. See docs/bypass-iommu.txt * Use non-PCI storage devices, for example virtio-blk-device on the arm64 virt machine. You can find a description of the VIOT table, which will be included in next ACPI version, here: https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf [1] https://lore.kernel.org/qemu-devel/20210903143208.2434284-1-jean-philippe@linaro.org/ [2] https://lore.kernel.org/qemu-devel/20210907144814.741785-1-imammedo@redhat.com/ Jean-Philippe Brucker (10): hw/acpi: Add VIOT table hw/arm/virt-acpi-build: Add VIOT table for virtio-iommu hw/arm/virt: Remove device tree restriction for virtio-iommu hw/arm/virt: Reject instantiation of multiple IOMMUs pc: Allow instantiating a virtio-iommu device tests/acpi: allow updates of VIOT expected data files tests/acpi: add test cases for VIOT tests/acpi: add expected VIOT blob for virt machine tests/acpi: add expected DSDT blob for VIOT test on q35 tests/acpi: add expected VIOT blob for q35 machine hw/acpi/viot.h | 13 ++++ include/hw/i386/pc.h | 2 + hw/acpi/viot.c | 112 +++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 7 +++ hw/arm/virt.c | 15 +++-- hw/i386/acpi-build.c | 5 ++ hw/i386/pc.c | 28 ++++++++- hw/virtio/virtio-iommu-pci.c | 7 --- tests/qtest/bios-tables-test.c | 39 ++++++++++++ hw/acpi/Kconfig | 4 ++ hw/acpi/meson.build | 1 + hw/arm/Kconfig | 1 + hw/i386/Kconfig | 1 + tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9415 bytes tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes 16 files changed, 219 insertions(+), 16 deletions(-) create mode 100644 hw/acpi/viot.h create mode 100644 hw/acpi/viot.c create mode 100644 tests/data/acpi/q35/DSDT.viot create mode 100644 tests/data/acpi/q35/VIOT.viot create mode 100644 tests/data/acpi/virt/VIOT -- 2.33.0