From patchwork Fri Mar 7 18:03:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 871224 Delivered-To: patch@linaro.org Received: by 2002:a5d:64c8:0:b0:38f:210b:807b with SMTP id f8csp895419wri; Fri, 7 Mar 2025 10:07:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXxLCwdHE3HLjbqkfTMKigDLvOkjGkU31AGoOWjD6T6EwjnEOwHypKqoVwRg8604OwQRwDAFA==@linaro.org X-Google-Smtp-Source: AGHT+IFiX7pkSbkzLvZH8wl6UjwlVOE6DpMD3J4+Obp4dJGiVfIVmpXKeWhnI34s+tDi/Yiv4NqJ X-Received: by 2002:a05:6102:a54:b0:4c1:b001:b53 with SMTP id ada2fe7eead31-4c30a65e00bmr2955887137.18.1741370827238; Fri, 07 Mar 2025 10:07:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741370827; cv=none; d=google.com; s=arc-20240605; b=AXRJHinihfoc4GZm3kV4OeWjjeUElVofnnMsUl5lBJMKF9HnB5nSMUcaDMY8DL82Pd 2cNHlhfyrax3Rf3dcuJdC+4+AnTa6qpaHY1FvjqOPGnLmk6xO9hRpBUUK1Sqlp/UUPZ9 4w6+gsqtkJlzr5Z5D+F6ClQVvujuibSKTAm347eJG8waK00sthwJEs/ZtCwh3aZeUio+ epIHCe7O4a26KTt6YFZq3+tvIlvFYrEYk0Jlgjd19DgOQ5USdvDT+q1tXWmlxod6jMkD eJlvwLc2DfqJhcyvMlxMSx+v5WVDsDwv0xw7nGVDV4MuvcX22VBHe1y/Jf6d5/GRdbjg pONQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=g0+sj+5fZPDlRh8EKfyzOVB2Z+MoNxqNRQg5EoTr07c=; fh=ZyzqLhNGJAXkYZjVqygzIY1NON/Kumlz+Vm/jUj6bQE=; b=jY/vh6bONwbZiFOhn/P7jm5Se6T7z+L7XX0p36Tp1NUga+aSo9WnwhxyAiOerj7zl/ iX+A6Zhz+yDfLyFxsuu7z9fgaxWSojGssCQZWsgt3KcyTcEcWUKvskg5ww4k6rLVXZ8m nU4uk6TwiGYZAywgNSEJBgLX98Ly29/Q9j/0/IRtRYY1rho7veWDAVInSnkGCHoeXbGS vh+v60iPrCxxHJ0UQLZXjGA8Nr5jJLZJbvbEKtgJzpIksPBpVAjVr45GoNmx+Sv+QFbs CqTykcCPsJxwwek+jgvNtD5Hg7FtVYHYzQFBzdLPA2cBJM9si/3YEjPuZWYzdw2HPiQf D3dA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Llj4NGZ4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4c2fb427803si1189155137.112.2025.03.07.10.07.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Mar 2025 10:07:07 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=Llj4NGZ4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqc5l-0007Hg-So; Fri, 07 Mar 2025 13:06:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqc43-0004Sp-AM for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:04:51 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqc40-0002JZ-7H for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:04:51 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-388cae9eb9fso1055505f8f.3 for ; Fri, 07 Mar 2025 10:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741370686; x=1741975486; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g0+sj+5fZPDlRh8EKfyzOVB2Z+MoNxqNRQg5EoTr07c=; b=Llj4NGZ4VxZ79idn6xySoUfWGFUAx777jbCT6IOHvS4DnubMwLbSD7DSzqtNbKyQbR YlHYxI5ejMMLW2rqkPQ+gfiLT8E5C2CWP7jBCBb/uWAEYVh3YA67jYN/BnM/TLnj6KRI x8hgXqt4p0cQnNOT6OcLtf3bHbm6x2dqocOHGqsciXlcWDjGE/DpuLYZ19KpTnkd16d0 qrZfyDx4PKKwzsP86zCSYYJjYIhwJTHYmI+R490cjzmG81jf2/rhmHpc3xuVDMXZZvZY VpWK0ugAqZpbeRUy31caz2QKmgnJSZaiwzpMxLOOVnton3lJthPAEpAck5ycn/8ufg2u h3Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741370686; x=1741975486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g0+sj+5fZPDlRh8EKfyzOVB2Z+MoNxqNRQg5EoTr07c=; b=Lb/Wca4OKi7h4Y5+tw1hIsVQYAG+uPrZTaUM4Xx4U8ip1vFZuCrItvWAkrRI31RmEN OotW4usibuXgdrSjRuuUNpGh3YKSgODAAroIw77Kyz+ATnVyvd14zawDJl5Mwetg5zf1 7irgQM2wIGmQ2WccFXzPQOFw/PUehSe3Al0+3vPcrS/79Do35uJ5UefppHgpUBoCG/w3 gu+3N3HMXyi7P8Zt+fFEG6sdZIPZV2af10Bwec4Iwx36X4JFPfaFRXOeImJtHcwjSyu2 2n7uLEDQ0K8tMWXgiLiv91iyf2JpQzTUj0+pLlrRPvhU5/Ut0229daKATRVUHPAK7/W9 +cVw== X-Gm-Message-State: AOJu0YwuvsvG6XBtUsx/coE8pzEx51KeY4YiomTHeWGatHl9OGWW60k9 7MyZwMqmehnY25pUBiEhw81lmQmTYyivJkCCG5WECG131r0k3IvTYuVI6Vk6ZVWx8XvnbYz1hF1 yqEA= X-Gm-Gg: ASbGncv54w82dNwdpatgcnhzH+Emf+wg3EQEyK5cMcB2J6qWR7i0FrcBKMK3kW6pVg9 VkAMML3+1cyS49ClA/qIUK8vwlQA6lio+7KoAefluR/bZNWHeKkr6zBQZelcUP7aRZHDnWXGHL4 sZh/NkCQlnnpioh8JuIibHjd2c1HbIM17dZwXq/P/Cg6HuNPLJigVPPfIIgEOFPkftODQ7pSHj6 HrQoUKrfzHfLoMCGC33WCxyxTzuz1Iu2sHztXu8KZlXq5TqViWVlli72Fc/1VoprR0bnk9XfazZ NISGODsnvX5k5333O952yZ+kNLjqt5khEJY7XIEKnKGMH0ssDu65KvQdhCM17YOCOmNY1IOyLR4 en7GGLhRJiZyW+ZKr0ys= X-Received: by 2002:a05:6000:402b:b0:38d:e401:fd61 with SMTP id ffacd0b85a97d-39132db746amr2784656f8f.49.1741370686062; Fri, 07 Mar 2025 10:04:46 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43bdd8b046dsm58414135e9.5.2025.03.07.10.04.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Mar 2025 10:04:45 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Igor Mammedov , qemu-ppc@nongnu.org, Thomas Huth , Richard Henderson , Tony Krowiak , Ilya Leoshkevich , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yi Liu , Paolo Bonzini , Zhenzhong Duan , Matthew Rosato , Eric Farman , Peter Xu , Pierrick Bouvier , Daniel Henrique Barboza , Eric Auger , qemu-s390x@nongnu.org, Jason Herne , =?utf-8?q?C=C3=A9dric_Le_Goater?= , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Harsh Prateek Bora , Nicholas Piggin , Halil Pasic , Christian Borntraeger Subject: [PATCH 12/14] hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Date: Fri, 7 Mar 2025 19:03:35 +0100 Message-ID: <20250307180337.14811-13-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250307180337.14811-1-philmd@linaro.org> References: <20250307180337.14811-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the compile time check on the CONFIG_IOMMUFD definition by a runtime one by calling iommufd_builtin(). Since the file doesn't use any target-specific knowledge anymore, move it to system_ss[] to build it once. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier --- target/s390x/kvm/kvm_s390x.h | 2 +- hw/vfio/ap.c | 27 +++++++++++++-------------- hw/vfio/meson.build | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h index 649dae5948a..7b1cce3e60d 100644 --- a/target/s390x/kvm/kvm_s390x.h +++ b/target/s390x/kvm/kvm_s390x.h @@ -10,7 +10,7 @@ #ifndef KVM_S390X_H #define KVM_S390X_H -#include "cpu-qom.h" +#include "target/s390x/cpu-qom.h" struct kvm_s390_irq; diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index c7ab4ff57ad..832b98532ea 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -11,7 +11,6 @@ */ #include "qemu/osdep.h" -#include CONFIG_DEVICES /* CONFIG_IOMMUFD */ #include #include #include "qapi/error.h" @@ -24,7 +23,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "kvm/kvm_s390x.h" +#include "target/s390x/kvm/kvm_s390x.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/s390x/ap-bridge.h" @@ -193,10 +192,11 @@ static void vfio_ap_unrealize(DeviceState *dev) static const Property vfio_ap_properties[] = { DEFINE_PROP_STRING("sysfsdev", VFIOAPDevice, vdev.sysfsdev), -#ifdef CONFIG_IOMMUFD +}; + +static const Property vfio_ap_iommufd_properties[] = { DEFINE_PROP_LINK("iommufd", VFIOAPDevice, vdev.iommufd, TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), -#endif }; static void vfio_ap_reset(DeviceState *dev) @@ -234,21 +234,20 @@ static void vfio_ap_instance_init(Object *obj) vbasedev->mdev = true; } -#ifdef CONFIG_IOMMUFD static void vfio_ap_set_fd(Object *obj, const char *str, Error **errp) { vfio_device_set_fd(&VFIO_AP_DEVICE(obj)->vdev, str, errp); } -#endif static void vfio_ap_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); device_class_set_props(dc, vfio_ap_properties); -#ifdef CONFIG_IOMMUFD - object_class_property_add_str(klass, "fd", NULL, vfio_ap_set_fd); -#endif + if (iommufd_builtin()) { + device_class_set_props(dc, vfio_ap_iommufd_properties); + object_class_property_add_str(klass, "fd", NULL, vfio_ap_set_fd); + } dc->vmsd = &vfio_ap_vmstate; dc->desc = "VFIO-based AP device assignment"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); @@ -261,11 +260,11 @@ static void vfio_ap_class_init(ObjectClass *klass, void *data) object_class_property_set_description(klass, /* 3.1 */ "sysfsdev", "Host sysfs path of assigned device"); -#ifdef CONFIG_IOMMUFD - object_class_property_set_description(klass, /* 9.0 */ - "iommufd", - "Set host IOMMUFD backend device"); -#endif + if (iommufd_builtin()) { + object_class_property_set_description(klass, /* 9.0 */ + "iommufd", + "Set host IOMMUFD backend device"); + } } static const TypeInfo vfio_ap_info = { diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 9a004992c11..510ebe6d720 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -9,7 +9,6 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( )) vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c')) vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c')) -vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c')) specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) @@ -26,6 +25,7 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files( system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( 'iommufd.c', )) +system_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c')) system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( 'display.c', 'pci.c',