From nobody Wed Nov 27 14:31:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1698317285; cv=none; d=zohomail.com; s=zohoarc; b=lyI2PsKOlE0I4dA+hjRmx/Aj8z78bbRaASBqfyoUils+UvT5GrAl2gkPL3HoRnfM1aZDfSE3Lh8IiDlRPDDAXCmTRgqOoAXLjyHKolCxc9UaaZe1uNBcTWYPGTpzvdvRX04KKtoVcxzUenhZclWJyynQWE9XJaRwTKQXyzfU5rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698317285; 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=k+qFffS4e7ivbvN0EAefjx+bett5ARpH0Friert0T2g=; b=nvAVpjnMyneTHfXmA5lhRS8SBgAiGsEPGlIri0TSS3eBloJVgRkG3zmKklEW6AwRWG8sx3sqH8h8p3lXp+YMCSKf1ZT/maR6zSiM8DyVwyfr0rKRu2R38UWHStKbhPAL6PjBgv/pcNOGz2hBtGsaQB/rFxK7GAZvDOD951R6erw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698317285747169.15487736131308; Thu, 26 Oct 2023 03:48:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvxuE-0001cm-6W; Thu, 26 Oct 2023 06:48:02 -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 1qvxu9-0001Jd-2F; Thu, 26 Oct 2023 06:47:59 -0400 Received: from mgamail.intel.com ([134.134.136.126]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvxu6-0001Nv-VE; Thu, 26 Oct 2023 06:47:56 -0400 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 03:47:26 -0700 Received: from duan-server-s2600bt.bj.intel.com ([10.240.192.147]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 03:47:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698317274; x=1729853274; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q4+Rw92ILOH6hUtVhfMsdOHd49usfmzFgq2SDp59M9g=; b=RB/r5AvTD1RExQBsRZh+vI3DOVQj8WsS1c075qIlEp4WnfpPyMOZTL7F UCpf6Mf7hkwmjAHPwH85a+VAj8z3DGBD4jImEmiBBFO13rmex1ns9I6C8 xWzYIrcC5M21A2qnNQZaivjJfaALXN/jmfq4kDbgtDQiqqclSo0jAFxvI ZcIV6C3TLsximAAVcna5dloEf5+iWxWIVNd0PxaOPr+hoDHjzqrE0J0nQ qaUzMZYSczT7Oiv20wccccXI44mSqWD7gmmKqUsaZhQ5pB4I+AsfNvrHs slVj7k+ki6kdV2OMQ9FmaOw3V+CoSF/EF4jyf8+BwgNMftGWTRb5q3ftv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="372563522" X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="372563522" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="463718" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, eric.auger@redhat.com, peterx@redhat.com, jasowang@redhat.com, kevin.tian@intel.com, yi.l.liu@intel.com, yi.y.sun@intel.com, chao.p.peng@intel.com, Zhenzhong Duan , Nicholas Piggin , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Harsh Prateek Bora , qemu-ppc@nongnu.org (open list:sPAPR (pseries)) Subject: [PATCH v3 19/37] vfio/spapr: Introduce spapr backend and target interface Date: Thu, 26 Oct 2023 18:30:46 +0800 Message-Id: <20231026103104.1686921-20-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026103104.1686921-1-zhenzhong.duan@intel.com> References: <20231026103104.1686921-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=134.134.136.126; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 @intel.com) X-ZM-MESSAGEID: 1698317286542100005 Content-Type: text/plain; charset="utf-8" Introduce an empry spapr backend which will hold spapr specific content, currently only prereg_listener and hostwin_list. Also introduce and instantiate a spapr specific target interface, currently only has add/del_window callbacks. Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 8 ++++++++ include/hw/vfio/vfio-container-base.h | 2 ++ hw/vfio/spapr.c | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 938f75e70c..a74e60e677 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -169,6 +169,14 @@ VFIOAddressSpace *vfio_get_address_space(AddressSpace = *as); void vfio_put_address_space(VFIOAddressSpace *space); =20 /* SPAPR specific */ +typedef struct VFIOIOMMUSpaprOps { + int (*add_window)(VFIOContainerBase *bcontainer, + MemoryRegionSection *section, + Error **errp); + void (*del_window)(VFIOContainerBase *bcontainer, + MemoryRegionSection *section); +} VFIOIOMMUSpaprOps; + int vfio_container_add_section_window(VFIOContainer *container, MemoryRegionSection *section, Error **errp); diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 2ffafb0d58..1e1854d24f 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -31,6 +31,7 @@ =20 typedef struct VFIODevice VFIODevice; typedef struct VFIOIOMMUOps VFIOIOMMUOps; +typedef struct VFIOIOMMUSpaprOps VFIOIOMMUSpaprOps; =20 typedef struct { unsigned long *bitmap; @@ -49,6 +50,7 @@ typedef struct VFIOAddressSpace { */ typedef struct VFIOContainerBase { const VFIOIOMMUOps *ops; + const VFIOIOMMUSpaprOps *spapr_ops; VFIOAddressSpace *space; MemoryListener listener; Error *error; diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 5786377317..3739004151 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -24,6 +24,10 @@ #include "qapi/error.h" #include "trace.h" =20 +typedef struct VFIOSpaprContainer { + VFIOContainer container; +} VFIOSpaprContainer; + static bool vfio_prereg_listener_skipped_section(MemoryRegionSection *sect= ion) { if (memory_region_is_iommu(section->mr)) { @@ -384,6 +388,8 @@ void vfio_container_del_section_window(VFIOContainer *c= ontainer, } } =20 +const VFIOIOMMUSpaprOps vfio_iommu_spapr_ops; + bool vfio_spapr_container_init(VFIOContainer *container, Error **errp) { VFIOContainerBase *bcontainer =3D &container->bcontainer; @@ -447,6 +453,8 @@ bool vfio_spapr_container_init(VFIOContainer *container= , Error **errp) 0x1000); } =20 + bcontainer->spapr_ops =3D &vfio_iommu_spapr_ops; + listener_unregister_exit: if (v2) { memory_listener_unregister(&container->prereg_listener); --=20 2.34.1