Received: by 2002:a17:907:681:b0:a6f:694d:5ff8 with SMTP id wn1csp152946ejb; Fri, 14 Jun 2024 03:02:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWu635g0w/wlAcX97LXOI3Ap7Ld0bQXbgo05W89ClKUd5etQ5e3chZa6PAlIwYL1oZZlCae2jnHnj2OCKUMIPxOXmcgCqWw X-Google-Smtp-Source: AGHT+IH8CoVIu+4VgA0wzr6ltsDlSbWDrc+emdj2szw9bFHkKAwLFpKcJVwA6OMIKaYTIMlyl3Tv X-Received: by 2002:a05:620a:244f:b0:795:575c:5bc2 with SMTP id af79cd13be357-798d26afac0mr214075085a.67.1718359327291; Fri, 14 Jun 2024 03:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718359327; cv=none; d=google.com; s=arc-20160816; b=n8wlzLuKMA/2ihBgk8/uA30Hy+UOFc7HbyE+hODGi44LNY6XVInqpcK0FlZFU0AfVk nsm5Fb0YSUbN1FSkfhmOU/1ZI3KtLmgWRzXE34w1FGDrTeD/5g1LMoNYwGNwriFDWB7h S9TG5mKYbX8S2E40S+8mcfRIIc1QtLPbE3hSga0tPLoA7YhABWCzHtD2W18g3pKaVmtd QMdlwWLWHJaREbH+04xu27SHRM2xIaPj58F4aVbHjum3bAJerOOuYZGdR+3v3jyxaNzV MfZAAe2hJlUWQam0U3opQ8zoHVwLkQZEMFOo3ICbZPZgwb89L9lPJ8exovceYN8py89+ +iQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=spMXs0hA1lUXNIprH3Oaitq4RHiLh0Qb0nwaEaL5KcY=; fh=R6TiT0Wtz7X8XEbDuegOYIRLCGW5RDppmUNAjVZXg4E=; b=yydRvgFunHlS2zdKSJVTSI3CGrO9544P7we5ljZQOqkBGimvr++6IeDnpIiW1ltGQZ xMZrV39XHwJ2y8vllgO/agpIWadnbcf9Cf/5I/U+aVYJB+BKI8ZaWf/YNoHoj4IP1LWL EQrz18AExHVkTVnJ7ICTxkASf/5KYG7qaiX4fbUXt+m+k0hUIGyMxI5uxNq2r0vNyfX2 gE5nl357RepF1CqAliSYYnys9obKcO7NEqalOurulyoZUf6/0HMVCbSLVfXSrpZIXHER 2JoQ8G1OE1rRdtweJf/5vceNKxwdq4oigSV6wrQsZbFS9gl4rMvSNedM7gv9s84mCAhN DByg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RdSufYXq; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-798b9f084c8si343811885a.116.2024.06.14.03.02.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2024 03:02:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=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=@redhat.com header.s=mimecast20190719 header.b=RdSufYXq; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sI3kE-0005S7-3l; Fri, 14 Jun 2024 06:01:18 -0400 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 1sI3kB-0005OW-VB for qemu-devel@nongnu.org; Fri, 14 Jun 2024 06:01:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sI3k8-0005JQ-VZ for qemu-devel@nongnu.org; Fri, 14 Jun 2024 06:01:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718359271; h=from:from:reply-to: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: in-reply-to:in-reply-to:references:references; bh=spMXs0hA1lUXNIprH3Oaitq4RHiLh0Qb0nwaEaL5KcY=; b=RdSufYXqqf3dG2DKNFkVz+5tt8nIMowOK/pRX56cPN2toZwY5UJvs3daW0E4LGAo9swzl/ dwdQozZtThCOPtUKfEJJozENeVI6XIejk37szwe4LF+AAuB3jTW3D8LGPLDYz4RkM9hdIh bKeXxhZQxfHErVOQV3p8drGFKabXG5s= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-SuKom7b1OAeD2fIqEt3KyQ-1; Fri, 14 Jun 2024 06:01:10 -0400 X-MC-Unique: SuKom7b1OAeD2fIqEt3KyQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-421292df2adso12888865e9.3 for ; Fri, 14 Jun 2024 03:01:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718359269; x=1718964069; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=spMXs0hA1lUXNIprH3Oaitq4RHiLh0Qb0nwaEaL5KcY=; b=mPebooNWqSou06/eFlZpkZP9uDBNX/NiC8wCq3HHavAAVEO7EadyBumiw87j46Kjq9 G4bPZNjwhtwLBb1JpWZuasbl5ZyFSoadSZXyBOmCiQRUtreeXRifk1c8p+OwanSJcYN+ 30v8aCZJlDOXanC3ecVceQG4pfYxWc9YXTPbipeNeSbXx3rqdGc+s5iikfiKZj1MzIUT /V88HpgawHuumWYz+8wN0EFPUB9YH00e4DNFc7S2KxgAeDLI0AHaCIhooXGbm6RpZm6a KESBLcxiKYGKKrvjghwgWUj19bvqMx70JU/wQCr7R8CjLKCRPXpGZlxwWanywoTyGQJh 3YWQ== X-Forwarded-Encrypted: i=1; AJvYcCWuv//ytf3r7ecBQdyXbejJ3oOCmkZVhAZrtvvxZcy/AXEcvp4yfV0nkjS6YBTR0owaEGffiez5CXGJD3BT6olGyC4jmy8= X-Gm-Message-State: AOJu0Yxfc+1IygQMAig+bLgRZ9Av4LNPpnHMCUL+Sy6CTYRnRMZjOCEO eL/I3ooQ/bC+ygFwc1AxDhzIbtsviohaeBmEsRwFIWa/DeBA9A5uhUXJevW/YR9JnEBLyRiWMGS EhSPxYAwz/MzvsQMOJMPBCYZAYKdIgPJuX4rYiBKY2+bVXI2C+wyR X-Received: by 2002:a05:600c:19d3:b0:422:aca:f887 with SMTP id 5b1f17b1804b1-42304844ddamr20676405e9.28.1718359268888; Fri, 14 Jun 2024 03:01:08 -0700 (PDT) X-Received: by 2002:a05:600c:19d3:b0:422:aca:f887 with SMTP id 5b1f17b1804b1-42304844ddamr20676155e9.28.1718359268468; Fri, 14 Jun 2024 03:01:08 -0700 (PDT) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750f23cdsm3918081f8f.77.2024.06.14.03.01.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jun 2024 03:01:07 -0700 (PDT) Message-ID: Date: Fri, 14 Jun 2024 12:01:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/7] HostIOMMUDevice: Store the VFIO/VDPA agent Content-Language: en-US To: =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , eric.auger.pro@gmail.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, peter.maydell@linaro.org, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com References: <20240613092359.847145-1-eric.auger@redhat.com> <20240613092359.847145-2-eric.auger@redhat.com> From: Eric Auger In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.145, 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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Reply-To: eric.auger@redhat.com Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: ENku3nAJwJi2 Hi Cédric, On 6/14/24 11:13, Cédric Le Goater wrote: > On 6/13/24 11:20 AM, Eric Auger wrote: >> Store the agent device (VFIO or VDPA) in the host IOMMU device. >> This will allow easy access to some of its resources. >> >> Signed-off-by: Eric Auger >> Reviewed-by: Zhenzhong Duan >> --- >>   include/sysemu/host_iommu_device.h | 1 + >>   hw/vfio/container.c                | 1 + >>   hw/vfio/iommufd.c                  | 2 ++ >>   3 files changed, 4 insertions(+) >> >> diff --git a/include/sysemu/host_iommu_device.h >> b/include/sysemu/host_iommu_device.h >> index a57873958b..3e5f058e7b 100644 >> --- a/include/sysemu/host_iommu_device.h >> +++ b/include/sysemu/host_iommu_device.h >> @@ -34,6 +34,7 @@ struct HostIOMMUDevice { >>       Object parent_obj; >>         char *name; >> +    void *agent; /* pointer to agent device, ie. VFIO or VDPA device */ >>       HostIOMMUDeviceCaps caps; >>   }; >>   diff --git a/hw/vfio/container.c b/hw/vfio/container.c >> index 26e6f7fb4f..b728b978a2 100644 >> --- a/hw/vfio/container.c >> +++ b/hw/vfio/container.c >> @@ -1145,6 +1145,7 @@ static bool >> hiod_legacy_vfio_realize(HostIOMMUDevice *hiod, void *opaque, >>         hiod->name = g_strdup(vdev->name); >>       hiod->caps.aw_bits = vfio_device_get_aw_bits(vdev); >> +    hiod->agent = opaque; >>         return true; >>   } >> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c >> index 409ed3dcc9..dbdae1adbb 100644 >> --- a/hw/vfio/iommufd.c >> +++ b/hw/vfio/iommufd.c >> @@ -631,6 +631,8 @@ static bool >> hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque, >>           struct iommu_hw_info_vtd vtd; >>       } data; >>   +    hiod->agent = opaque; >> + > > This opaque pointer could be assigned in vfio_attach_device(). > > Talking of which, why are we passing a 'VFIODevice *' parameter to > HostIOMMUDeviceClass::realize ? I don't see a good reason > > I think a 'VFIOContainerBase *' would be more appropriate since > 'HostIOMMUDevice' represents a device on the host which is common > to all VFIO devices. >   > In that case, HostIOMMUDevice::agent wouldn't need to be opaque > anymore. It could  simply be a 'VFIOContainerBase *' and > hiod_legacy_vfio_get_iova_ranges() in patch 3 would grab the > 'iova_ranges' from the 'VFIOContainerBase *' directly. > > This means some rework : > > * vfio_device_get_aw_bits() would use a  'VFIOContainerBase *' instead. > * HostIOMMUDevice::name would be removed. This is just for error > messages. > * hiod_iommufd_vfio_realize() would use VFIOIOMMUFDContainer::be. > > That said, I think we need the QOMification changes first. OK I need to review your series first. At the moment I have just addressed Zhenzhong's comment in v4, just sent. Thanks Eric > > Thanks, > > C. > > > > >>       if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, >>                                            &type, &data, >> sizeof(data), errp)) { >>           return false; >