From patchwork Fri Sep 3 14:32: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: 12474497 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=-11.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,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 464AAC433F5 for ; Fri, 3 Sep 2021 14:34:08 +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 E80EA60295 for ; Fri, 3 Sep 2021 14:34:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E80EA60295 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]:56726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMAGc-00071h-Vx for qemu-devel@archiver.kernel.org; Fri, 03 Sep 2021 10:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMAFF-0004EA-FU for qemu-devel@nongnu.org; Fri, 03 Sep 2021 10:32:41 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:55959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMAFC-0005Yb-Kr for qemu-devel@nongnu.org; Fri, 03 Sep 2021 10:32:41 -0400 Received: by mail-wm1-x329.google.com with SMTP id g135so3638771wme.5 for ; Fri, 03 Sep 2021 07:32:36 -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=wCmSGUagquqiKpr5H6LCLK5h69XDNubxlm2zXBcPFl0=; b=ps07xr1oG2cKa292IgBKezled1nYH1hT5Hwx+/4EiZfSWtbgHtcvTQh761jivh7tmx zmqxI2ofqFcTZwLRwxSVmfRpELzWgoV1ceAjm3Gz2da22H8lq9gm+2TY0WpAm+rretHb 9mS+yf2qJaG5azCCcwGME6UCW7UROatve7M2NtyJn/Jtd78D6K9r5Bqt2rXve75wDkue ZwoK4m61h/gXlHzgHoVJtsFdmPS5aAFhcEbzsBI9MrKdsuQv/c+KcaVq0T6srurfaSfG IhhUe9QCcJI7MUlDTDQ4j05FfQqn1Klo5AFhfdV6cjvyCmB8RWMrFdOJtlDH25oBXXDM avyQ== 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:mime-version :content-transfer-encoding; bh=wCmSGUagquqiKpr5H6LCLK5h69XDNubxlm2zXBcPFl0=; b=uH5Xj6ykdQmlWNFFa51oqJ+a+fgBwPMyCwfJZaZDraiO7otXLbGl75Izr+ZZaEBQ/L y5Yl5iJUhtuC1oNJ7A4pwjq+XFz4QzSk5YdvYAWs6uq6dcwpSShFHZ+/6Bm36fhA9fu6 UvEXbUAGGoCrb/zC9smc7AjzMUcvNFcscU3HCZ9QNPda4VHK29DJs3wH9g4wwAiBZic4 QUWwinJLyaolRoaCnG3QHQYzdMwPNchgT78TC6OV9MqQTVjSatPCkDjd8GJ50VwJl8dX Afrj0rR8B2WUqtOBy6wJd7GNu7jnNGeC4oZ3kOnKQ0GIdQy/6Ib5yU1tZu8iTu5VXQpv iLCg== X-Gm-Message-State: AOAM53236bFm2WwxobLDyL5quLfBvo8ZA5RNGufXrG9Kzqyh0WDSVaZA SEjKZBV1VMltbcOh0Vduvb0HgA== X-Google-Smtp-Source: ABdhPJxIk2UFfpPkRdnjJaqFeYLtPPxQayhhldBNwrIvjWKxvUaC+ZP5X8PiF00jh0sxnH5WIoX/ww== X-Received: by 2002:a05:600c:3213:: with SMTP id r19mr8551815wmp.11.1630679555026; Fri, 03 Sep 2021 07:32:35 -0700 (PDT) Received: from localhost.localdomain (19.11.114.78.rev.sfr.net. [78.114.11.19]) by smtp.gmail.com with ESMTPSA id z2sm4314843wma.45.2021.09.03.07.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 07:32:34 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH v2 0/8] virtio-iommu: Add ACPI support Date: Fri, 3 Sep 2021 16:32:01 +0200 Message-Id: <20210903143208.2434284-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::329; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 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, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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" 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 [v1]: * Patch 2, use build_append_int_noprefix() to generate the ACPI table. * Patch 7, check that only one IOMMU is instantiated on x86. * Added patch 5 that rejects multiple instantations of virtio-iommu on Arm. It's not crucial to the series but it matches the check added to x86 and is very simple. * Added patch 8 documenting that interrupt remapping is not supported. 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 [v1] https://lore.kernel.org/qemu-devel/20210810084505.2257983-1-jean-philippe@linaro.org/ Eric Auger (1): pc: Allow instantiating a virtio-iommu device Jean-Philippe Brucker (7): acpi: Add VIOT structure definitions 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: Add VIOT table for virtio-iommu docs: Add '-device virtio-iommu' entry hw/acpi/Kconfig | 4 ++ hw/arm/Kconfig | 1 + hw/i386/Kconfig | 1 + hw/acpi/viot.h | 13 ++++ include/hw/acpi/acpi-defs.h | 60 +++++++++++++++++++ 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 --- hw/acpi/meson.build | 1 + qemu-options.hx | 3 + 14 files changed, 243 insertions(+), 16 deletions(-) create mode 100644 hw/acpi/viot.h create mode 100644 hw/acpi/viot.c