From patchwork Tue Aug 10 08:45:00 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: 12428377 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.6 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 286C2C4338F for ; Tue, 10 Aug 2021 08:47:59 +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 733EE60234 for ; Tue, 10 Aug 2021 08:47:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 733EE60234 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]:40240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDNQT-0000k8-Cm for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 04:47:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDNPH-0006UQ-Ux for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:44 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:46753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDNPG-00081L-44 for qemu-devel@nongnu.org; Tue, 10 Aug 2021 04:46:43 -0400 Received: by mail-ed1-x530.google.com with SMTP id f13so29043467edq.13 for ; Tue, 10 Aug 2021 01:46:40 -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=n6/p42lQ3xlNmfzVU4VUBau7zfQXFWcF9XLxtvX2gxQ=; b=IR3q8C0grgYJ2Ulmzdtvqf/mHEo/1cebMbaqFotufmRaoI/14bRrU7Z4FuhX14PxW5 N9cwXpbqLbfSUD4qxLUBnZadabq9bIfkHKCpwksViVXGZ7FYP5rHf1IhyoQjVR91MZfw RELft+FIRUcyPeTGM3QqwTa7txrGmrErOLSeXmkkh5zED2RrVjjzEOOWccHwH7aQ/Kp0 Zm3bcCqZNixAMxghsf8E4l+wS6+nudcJa2vNYxBnVvCG4BPGFTKkajXurF1W9gpFoz9d 7EHbsN07UYySGbgN8WPzIn6uqk3SS9v68E3NA60jLdUObLroueQuRw8KLU5IIAnrb7iw pufw== 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=n6/p42lQ3xlNmfzVU4VUBau7zfQXFWcF9XLxtvX2gxQ=; b=fEtjV+EIR/puz56fEGpCVQ5VlphjAzL5MxpzOIkmugW/O1fh2dodbmhnfgeMDMR1GM DxeFFtvMEDSHG2q5AhdUR1Sd8U/I43cDsc1aMeJwjK1lQ3R0vYHT9ozUyUIg1zaAsFdB tRnxkt7B3gSgnRFx3hSRK+Y3YpOLvgHu7HMe2MyqOqmCPKyQI+cLHL8b90s7ztF2krhr gRhWDpxhNsQO1m2vLLKvbI/uV0KzWOz1gFKUIGlq3gXLzZQ4BYDaK/lr1wmrIz9BlW2J E5eF2hoKdmpLP6Ulo0diacfobGgqqju8Kx44QOui02uW6MfRJVRdWea6er39cGkrNoQc XwYw== X-Gm-Message-State: AOAM53171+uNRuimFraXScGe35yqL7Cc6GT134XdVbGFElZOwlZW3Kma Lh/lIKnpemStgjw9FuYrvCaVcw== X-Google-Smtp-Source: ABdhPJwfrJRONBjS92yufDryy835xrq+Zm30oTTuaE51wulXH8WGFoRhQ1c0G0e+4GQRNHT5WkE2lw== X-Received: by 2002:a05:6402:74f:: with SMTP id p15mr3595682edy.195.1628585199769; Tue, 10 Aug 2021 01:46:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 01:46:39 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com Subject: [PATCH 0/6] virtio-iommu: Add ACPI support Date: Tue, 10 Aug 2021 10:45:00 +0200 Message-Id: <20210810084505.2257983-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=jean-philippe@linaro.org; helo=mail-ed1-x530.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" Allow instantiating a virtio-iommu device on ACPI systems by adding a Virtual I/O Translation table (VIOT). Enable x86 support for VIOT. With a simple configuration the table contains a virtio-iommu-pci node and a pci-range node: qemu-system-aarch64 -M virt -bios QEMU_EFI.fd -device virtio-iommu ... $ iasl -d ... [000h 0000 4] Signature : "VIOT" [024h 0036 2] Node count : 0002 [026h 0038 2] Node offset : 0030 [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] [032h 0050 2] Length : 0010 [034h 0052 2] PCI Segment : 0000 [036h 0054 2] PCI BDF number : 0030 [040h 0064 1] Type : 01 [PCI Range] [042h 0066 2] Length : 0018 [044h 0068 4] Endpoint start : 00000000 [048h 0072 2] PCI Segment start : 0000 [04Ah 0074 2] PCI Segment end : 0000 [04Ch 0076 2] PCI BDF start : 0000 [04Eh 0078 2] PCI BDF end : 00FF [050h 0080 2] Output node : 0030 With a more complex topology multiple PCI Range nodes describe the system: qemu-system-aarch64 -bios QEMU_EFI.fd -device virtio-iommu -M virt,default_bus_bypass_iommu=true -device pxb-pcie,bus_nr=0x10,id=pcie.1000,bus=pcie.0 -device pxb-pcie,bus_nr=0x20,id=pcie.2000,bus=pcie.0,bypass_iommu=true -device pxb-pcie,bus_nr=0x30,id=pcie.3000,bus=pcie.0 [024h 0036 2] Node count : 0003 [026h 0038 2] Node offset : 0030 [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] [032h 0050 2] Length : 0010 [034h 0052 2] PCI Segment : 0000 [036h 0054 2] PCI BDF number : 0020 [040h 0064 1] Type : 01 [PCI Range] [042h 0066 2] Length : 0018 [044h 0068 4] Endpoint start : 00003000 [048h 0072 2] PCI Segment start : 0000 [04Ah 0074 2] PCI Segment end : 0000 [04Ch 0076 2] PCI BDF start : 3000 [04Eh 0078 2] PCI BDF end : 32FF [050h 0080 2] Output node : 0030 [058h 0088 1] Type : 01 [PCI Range] [05Ah 0090 2] Length : 0018 [05Ch 0092 4] Endpoint start : 00001000 [060h 0096 2] PCI Segment start : 0000 [062h 0098 2] PCI Segment end : 0000 [064h 0100 2] PCI BDF start : 1000 [066h 0102 2] PCI BDF end : 11FF [068h 0104 2] Output node : 0030 The VIOT table description will be in the next release of ACPI. In the meantime you can find a description at https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf Linux support for VIOT was added in version 5.14 Eric Auger (1): pc: Allow instantiating a virtio-iommu device Jean-Philippe Brucker (5): 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 pc: Add VIOT table for virtio-iommu hw/acpi/viot.h | 13 ++++++ include/hw/acpi/acpi-defs.h | 60 ++++++++++++++++++++++++++ include/hw/i386/pc.h | 2 + hw/acpi/viot.c | 82 ++++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 7 +++ hw/arm/virt.c | 10 +---- hw/i386/acpi-build.c | 5 +++ hw/i386/pc.c | 18 +++++++- hw/virtio/virtio-iommu-pci.c | 7 --- hw/acpi/Kconfig | 4 ++ hw/acpi/meson.build | 1 + hw/arm/Kconfig | 1 + hw/i386/Kconfig | 1 + 13 files changed, 195 insertions(+), 16 deletions(-) create mode 100644 hw/acpi/viot.h create mode 100644 hw/acpi/viot.c