From patchwork Thu Oct 21 10:42:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1544280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CVggJ8lI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZkcn1Cz2z9sWJ for ; Thu, 21 Oct 2021 21:44:23 +1100 (AEDT) Received: from localhost ([::1]:36904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdVYa-0001tj-1u for incoming@patchwork.ozlabs.org; Thu, 21 Oct 2021 06:44:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdVXX-0001tT-CZ for qemu-devel@nongnu.org; Thu, 21 Oct 2021 06:43:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdVXV-0001iU-BK for qemu-devel@nongnu.org; Thu, 21 Oct 2021 06:43:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634812992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ola10SeFyjh+YukD2yM5i1hwlxPrtXxrhv4X4dnt3E0=; b=CVggJ8lI2TXlrA/qWehBsVeDnpvJ4LMi2EAaNhwzeWMCe2HYVEHa9/KAjWueta0QMPVNSH pftbBwpjTlmm2aC+m6SWnYGTMNpbApZWuz6idDL8pqAu598WieJOqPXXxdpa7WU4YEZgYO O4rCq9W4I8wnhZzqhzHGkVoo/wn6I20= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-601-8l6eIFmqNHOm1CZsoU5heg-1; Thu, 21 Oct 2021 06:43:11 -0400 X-MC-Unique: 8l6eIFmqNHOm1CZsoU5heg-1 Received: by mail-pj1-f69.google.com with SMTP id mm1-20020a17090b358100b001a0a81b8664so2072344pjb.6 for ; Thu, 21 Oct 2021 03:43:11 -0700 (PDT) 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=O81IFWasSc/lqcy27juFh4nVyCe07fmVPajCY3pbcY8=; b=xiqMUx5I/IwbgwIl162a26eXnt0haUptJwSi+NAmoi7pN+eSztkGFWzjSiNzpjQ6Y/ NqFRFkkrDNYx1Rkj2epF4K9Zh2Iby4eUr3M9C/mk3tg9Zhdm7TjpiO3BVS6FCLKesdBI +i1u4lQsKPQdFNx2sWunPSrgNOJnZJxpHBnsZBlRGq5Hwvif17vU95aH3gSD+LkBw8Ma B973A7nOX0erI5cCO5a5Sky4SpkfcIYH6FWA3iG8tDtQRItPik6esCalEjXUX/l0G6HU hGpuWaAT+3jkadl/cG5oVk2YPb6O/+9xYMrsj1hg0duHZlyHCFHJ5Hg2hLRZcZ9MC7Vv hcWg== X-Gm-Message-State: AOAM533mrDZQLfWiaq2xzZGwcIJVxGbH057ofAL+3kCJdJzfawulLk2o 24yT5/9rw7SaEaqs71lW6FU1KI6XrwiXBc7rRFrL/za7XQiG0OlcvMw8Equ3AO5jnKSAugvyNoh 0Z0LNvd10RwmCychTQppUJfan3t0YFspyyZu5wPHMee54QnLlVYl8GPESwh6ra8A7 X-Received: by 2002:a17:902:7e84:b0:13e:d793:20d8 with SMTP id z4-20020a1709027e8400b0013ed79320d8mr4430576pla.67.1634812989892; Thu, 21 Oct 2021 03:43:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpGj0xN5Zuzms+wtAP9YzLI48F0fnMvgQbza4BsJ41WcXG9d9J7+oY21cVwEH+6VBOC7t3dw== X-Received: by 2002:a17:902:7e84:b0:13e:d793:20d8 with SMTP id z4-20020a1709027e8400b0013ed79320d8mr4430545pla.67.1634812989488; Thu, 21 Oct 2021 03:43:09 -0700 (PDT) Received: from localhost.localdomain ([84.17.34.135]) by smtp.gmail.com with ESMTPSA id e1sm5246893pgi.43.2021.10.21.03.43.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Oct 2021 03:43:08 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 0/8] pci/iommu: Fail early if vfio-pci detected before vIOMMU Date: Thu, 21 Oct 2021 18:42:51 +0800 Message-Id: <20211021104259.57754-1-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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 , "Daniel P . Berrange" , Eduardo Habkost , "Michael S . Tsirkin" , Jason Wang , David Hildenbrand , Markus Armbruster , peterx@redhat.com, Shannon Zhao , Alex Williamson , Paolo Bonzini , Igor Mammedov , Eric Auger , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This series overrides one previous patchset: https://lore.kernel.org/qemu-devel/20210818194217.110451-1-peterx@redhat.com/ I started from v1 because obviously it's completely different way of doing the same thing, hence versioning upon it would be weird. Patches 1-7 are majorly cleanups for current pci code to finally provide a clean way to loop over all the pci devices on the system. Patch 8 uses the last helper pci_for_each_device_all() to loop over all the devices during x86 vIOMMU realize() function to fail early if e.g. vfio-pci devices are detected. Although this is not exactly what Igor suggested but it should be mostly the same approach, so I kept the Suggested-by credit. Please review, thanks. Peter Xu (8): pci: Define pci_bus_dev_fn type pci: Export pci_for_each_device_under_bus*() pci: Use pci_for_each_device_under_bus*() pci: Define pci_bus_fn/pci_bus_ret_fn type pci: Add pci_for_each_root_bus() pci: Use pci_for_each_root_bus() in current code pci: Add pci_for_each_device_all() x86-iommu: Fail early if vIOMMU specified after vfio-pci hw/arm/virt-acpi-build.c | 31 ++++++--------- hw/i386/acpi-build.c | 39 +++++-------------- hw/i386/x86-iommu.c | 18 +++++++++ hw/pci/pci.c | 77 +++++++++++++++++++++++++++++--------- hw/pci/pcie.c | 4 +- hw/ppc/spapr_pci.c | 12 +++--- hw/ppc/spapr_pci_nvlink2.c | 7 ++-- hw/ppc/spapr_pci_vfio.c | 4 +- hw/s390x/s390-pci-bus.c | 5 +-- hw/xen/xen_pt.c | 4 +- include/hw/pci/pci.h | 28 +++++++++----- 11 files changed, 132 insertions(+), 97 deletions(-)