From nobody Sun Nov 24 21:24:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1720784948; cv=none; d=zohomail.com; s=zohoarc; b=BXz/dBXHUlEgRgt40IjxFWR2rUfEh3rOVRMPycDoRpyfkIJuEeOyr8/5R9jgnrhFGlaxesjkSbfSea8RvWSHJqvlOSZ7vH24ohy9czDCCm8Wrtu8LD6bTEcgdokTfal6Hda7rPdB3aWoX6VtTEi4YD5p41W4/4LEYaWCyeyr5Rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720784948; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5rzZgaurg3uuiaZ3o8czx3hGgHHFONmGGwlQtj3jByE=; b=GQlI12HuRAhhP/8rGTpYbN0Yq4QHjxITfxJfUyu/j4qBqwgEFuXlq7T5jWVO6Dp5KyhDIvYGf6CfDSU984IKxIUIStiUg3iZASZ2GzllYrFwDsoEtkZmbQeYbSdIrI91r2A0+GUEPDinf4Zr3mc2MZByUqKPj1U2Z73fG0j2UEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720784948508952.8069960457983; Fri, 12 Jul 2024 04:49:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSEkq-0006Mw-7n; Fri, 12 Jul 2024 07:48:00 -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 1sSEkR-0005XV-Bc for qemu-devel@nongnu.org; Fri, 12 Jul 2024 07:47:35 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSEkP-0007eW-FV for qemu-devel@nongnu.org; Fri, 12 Jul 2024 07:47:34 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46C1BY8R020921; Fri, 12 Jul 2024 11:47:30 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 407emt30ah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jul 2024 11:47:30 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46CA6MoJ022627; Fri, 12 Jul 2024 11:47:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 409vv3pq5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jul 2024 11:47:29 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 46CBlCCe008041; Fri, 12 Jul 2024 11:47:29 GMT Received: from joaomart-mac.nl.oracle.com (dhcp-10-175-0-59.vpn.oracle.com [10.175.0.59]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 409vv3ppxv-7; Fri, 12 Jul 2024 11:47:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=5 rzZgaurg3uuiaZ3o8czx3hGgHHFONmGGwlQtj3jByE=; b=hlb0TfRgXMiwS2EsN Cchq+687hhokU8ov+B/8U0wReaZNGTAP5b1ELNFPt+MC/lZYGSjwKujcapMUR1Xv ZOYU4yojKeTsJSeApA1sikKW2geGp5n8JybQLrRAhVJ1X6NRsWYz4K0B31umlL4W 83VGe56D0ge2UZkEfo+sD5wm7+DSycQRcZ0fMnvZ0CxR5bjqr1VZcatOy3ekF6cp 9u4lXG+XnDU0SwROToGCYtiGQiswqhBhyg/iXy1AZ/HjxsYcWkt705CnFISoJk1b vNyeiPilFPccE3ARfK/VD/2YKwOGEoOLRZXkP6Dxh8nBBlZsd2h3NRE73iW92qID Xxt+Q== From: Joao Martins To: qemu-devel@nongnu.org Cc: Yi Liu , Eric Auger , Zhenzhong Duan , Alex Williamson , Cedric Le Goater , Jason Gunthorpe , Avihai Horon , Joao Martins Subject: [PATCH v4 06/12] vfio/{iommufd,container}: Remove caps::aw_bits Date: Fri, 12 Jul 2024 12:46:58 +0100 Message-Id: <20240712114704.8708-7-joao.m.martins@oracle.com> In-Reply-To: <20240712114704.8708-1-joao.m.martins@oracle.com> References: <20240712114704.8708-1-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-12_08,2024-07-11_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 mlxscore=0 mlxlogscore=951 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407120080 X-Proofpoint-GUID: ILbVIHpq5fYhkAY5lM2u1HWxf4XJAqLm X-Proofpoint-ORIG-GUID: ILbVIHpq5fYhkAY5lM2u1HWxf4XJAqLm Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=joao.m.martins@oracle.com; helo=mx0b-00069f02.pphosted.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_MED=-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_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1720784949425116600 Content-Type: text/plain; charset="utf-8" In preparation to moving HostIOMMUDevice realize() being able to called early during attach_device(), remove properties that rely on container being initialized. This means removing caps::aw_bits which requires the bcontainer::iova_ranges to be inititalized after device is actually attached. Instead defer that to .get_cap() and call vfio_device_get_aw_bits() directly. Suggested-by: Zhenzhong Duan Signed-off-by: Joao Martins Reviewed-by: C=C3=A9dric Le Goater --- include/sysemu/host_iommu_device.h | 1 - backends/iommufd.c | 3 ++- hw/vfio/container.c | 5 +---- hw/vfio/iommufd.c | 1 - 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/include/sysemu/host_iommu_device.h b/include/sysemu/host_iommu= _device.h index ee6c813c8b22..20e77cf54568 100644 --- a/include/sysemu/host_iommu_device.h +++ b/include/sysemu/host_iommu_device.h @@ -24,7 +24,6 @@ */ typedef struct HostIOMMUDeviceCaps { uint32_t type; - uint8_t aw_bits; } HostIOMMUDeviceCaps; =20 #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device" diff --git a/backends/iommufd.c b/backends/iommufd.c index 5d3dfa917415..41a9dec3b2c5 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "monitor/monitor.h" #include "trace.h" +#include "hw/vfio/vfio-common.h" #include #include =20 @@ -270,7 +271,7 @@ static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, = int cap, Error **errp) case HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE: return caps->type; case HOST_IOMMU_DEVICE_CAP_AW_BITS: - return caps->aw_bits; + return vfio_device_get_aw_bits(hiod->agent); default: error_setg(errp, "%s: unsupported capability %x", hiod->name, cap); return -EINVAL; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 88ede913d6f7..c27f448ba26e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -1144,7 +1144,6 @@ static bool hiod_legacy_vfio_realize(HostIOMMUDevice = *hiod, void *opaque, VFIODevice *vdev =3D opaque; =20 hiod->name =3D g_strdup(vdev->name); - hiod->caps.aw_bits =3D vfio_device_get_aw_bits(vdev); hiod->agent =3D opaque; =20 return true; @@ -1153,11 +1152,9 @@ static bool hiod_legacy_vfio_realize(HostIOMMUDevice= *hiod, void *opaque, static int hiod_legacy_vfio_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp) { - HostIOMMUDeviceCaps *caps =3D &hiod->caps; - switch (cap) { case HOST_IOMMU_DEVICE_CAP_AW_BITS: - return caps->aw_bits; + return vfio_device_get_aw_bits(hiod->agent); default: error_setg(errp, "%s: unsupported capability %x", hiod->name, cap); return -EINVAL; diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 325c7598d5a1..873c919e319c 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -722,7 +722,6 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *= hiod, void *opaque, =20 hiod->name =3D g_strdup(vdev->name); caps->type =3D type; - caps->aw_bits =3D vfio_device_get_aw_bits(vdev); =20 return true; } --=20 2.17.2