From nobody Sat Nov 15 01:18:36 2025 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=1758186124; cv=none; d=zohomail.com; s=zohoarc; b=TwE+fidSnh+vIb39fi3lDc2yg1dXPOFz6kScZ+nKxPqUpr+0SahqWoRdtURLMJq/Y+xs8mPZS8K8o96q40S/6Wg/UMUVRQmwe1+QlSPvQbq9r5Qc6TSPjhjmRGVG2djG+dK4CHnb6gJwyUBhS8w6jTIxquSv9mXEQZwKoGL0a0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758186124; 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=uubm2MOEqCaMfTXG3oTWByXmQwtGSqOYD+mRPLr1APU=; b=WRqZNptW7blWYsTEmSe9ogqUZuQiHWeu+03M19HjyZyoaU21yytVbW1KevA5ov1eYf45/bDUCA+wJUfb4gxa7hETiYtMlf2pu+DGBSBQ604B9Eo/oEezVHUEJTnzd05WNqrGaiKI3DW/jXBBXHYz7sd4HJptPTTmxLW0aZeZrSI= 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 1758186124498643.4321141483067; Thu, 18 Sep 2025 02:02:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzAUu-00047A-SB; Thu, 18 Sep 2025 05:00:13 -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 1uzAUo-0003tB-Ui for qemu-devel@nongnu.org; Thu, 18 Sep 2025 05:00:07 -0400 Received: from mgamail.intel.com ([192.198.163.8]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzAUm-0004kl-6D for qemu-devel@nongnu.org; Thu, 18 Sep 2025 05:00:06 -0400 Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2025 01:59:49 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2025 01:59:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758186004; x=1789722004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CHqmw14bMKZHqF6V7+19ya9aAL7hu+O14g1LnGYZSJ0=; b=Wa+8sdUWF1GPTY88su4KMg/uCcXhj0dxShAz4PONzcwpPw4kLJtjWFfp 6Y3ctxDelQ0mY4y0MOL3rVsgoodTSsTEqOVldQB5LlbWDEtPtjUKXgKvb BbAjxrxHEFAuC74MI4vJAKtfxlQKP5Q8WqHzrE4tnQUDMvw7U9qYGoC0r 04rlDxF9Pp4GtCcbu8W4WEq7fDNpv2oHr59v+anq/n1PVzJvQNduJZNv/ g2IhHNbx6ErZMkuSREVP3WTIK0vMdWbBjJX2B0iiaS/ojE3s9hEETKO8x 1Ato7blNdcryzUR+KI6bqENY9Jy0yiVxM/CCZ9ey3iRkhcVuNMe2R5j4M Q==; X-CSE-ConnectionGUID: KRHjBzmHTemLMxREVvosmA== X-CSE-MsgGUID: wrO+uGbqQEWgsJ03eGMdLQ== X-IronPort-AV: E=McAfee;i="6800,10657,11556"; a="78109580" X-IronPort-AV: E=Sophos;i="6.18,274,1751266800"; d="scan'208";a="78109580" X-CSE-ConnectionGUID: fep0xTKBS8Os4UZlAPhUdg== X-CSE-MsgGUID: eSs6vPQhRu6nkE+sX1Ac/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,274,1751266800"; d="scan'208";a="175930580" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, ddutile@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, skolothumtho@nvidia.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v6 19/22] vfio: Add a new element bypass_ro in VFIOContainerBase Date: Thu, 18 Sep 2025 04:57:58 -0400 Message-ID: <20250918085803.796942-20-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250918085803.796942-1-zhenzhong.duan@intel.com> References: <20250918085803.796942-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=192.198.163.8; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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 @intel.com) X-ZM-MESSAGEID: 1758186125974116600 Content-Type: text/plain; charset="utf-8" When bypass_ro is true, readonly memory section is bypassed from mapping in the container. This is a preparing patch to workaround Intel ERRATA_772415, see changelog in next patch for details about the errata. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-container-base.h | 1 + hw/vfio/listener.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index acbd48a18a..2b9fec217a 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -52,6 +52,7 @@ struct VFIOContainerBase { QLIST_HEAD(, VFIODevice) device_list; GList *iova_ranges; NotifierWithReturn cpr_reboot_notifier; + bool bypass_ro; }; =20 #define TYPE_VFIO_IOMMU "vfio-iommu" diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index e093833165..581ebfda36 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -76,8 +76,13 @@ static bool vfio_log_sync_needed(const VFIOContainerBase= *bcontainer) return true; } =20 -static bool vfio_listener_skipped_section(MemoryRegionSection *section) +static bool vfio_listener_skipped_section(MemoryRegionSection *section, + bool bypass_ro) { + if (bypass_ro && section->readonly) { + return true; + } + return (!memory_region_is_ram(section->mr) && !memory_region_is_iommu(section->mr)) || memory_region_is_protected(section->mr) || @@ -368,9 +373,9 @@ static bool vfio_known_safe_misalignment(MemoryRegionSe= ction *section) } =20 static bool vfio_listener_valid_section(MemoryRegionSection *section, - const char *name) + bool bypass_ro, const char *name) { - if (vfio_listener_skipped_section(section)) { + if (vfio_listener_skipped_section(section, bypass_ro)) { trace_vfio_listener_region_skip(name, section->offset_within_address_space, section->offset_within_address_space + @@ -497,7 +502,8 @@ void vfio_container_region_add(VFIOContainerBase *bcont= ainer, int ret; Error *err =3D NULL; =20 - if (!vfio_listener_valid_section(section, "region_add")) { + if (!vfio_listener_valid_section(section, bcontainer->bypass_ro, + "region_add")) { return; } =20 @@ -663,7 +669,8 @@ static void vfio_listener_region_del(MemoryListener *li= stener, int ret; bool try_unmap =3D true; =20 - if (!vfio_listener_valid_section(section, "region_del")) { + if (!vfio_listener_valid_section(section, bcontainer->bypass_ro, + "region_del")) { return; } =20 @@ -820,7 +827,7 @@ static void vfio_dirty_tracking_update(MemoryListener *= listener, container_of(listener, VFIODirtyRangesListener, listener); hwaddr iova, end; =20 - if (!vfio_listener_valid_section(section, "tracking_update") || + if (!vfio_listener_valid_section(section, false, "tracking_update") || !vfio_get_section_iova_range(dirty->bcontainer, section, &iova, &end, NULL)) { return; @@ -1214,7 +1221,7 @@ static void vfio_listener_log_sync(MemoryListener *li= stener, int ret; Error *local_err =3D NULL; =20 - if (vfio_listener_skipped_section(section)) { + if (vfio_listener_skipped_section(section, false)) { return; } =20 --=20 2.47.1