From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E459C87FC9 for ; Tue, 29 Jul 2025 09:23:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uggXq-0007pp-Qo; Tue, 29 Jul 2025 05:22:50 -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 1uggXi-0006lg-AZ for qemu-devel@nongnu.org; Tue, 29 Jul 2025 05:22:42 -0400 Received: from mgamail.intel.com ([192.198.163.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uggXg-0002jL-3q for qemu-devel@nongnu.org; Tue, 29 Jul 2025 05:22:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1753780960; x=1785316960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I2dMBqxtdpWeHT9/kcjBI8D+yW8p0bL704f9n7JQzqk=; b=HF1VsYoDvFZ/oPlsF5FCfLBUwIGceDMxBPzai3ojVeofF6fAY5QU7Psf UirTpzZ1OMkPHtMRoP3B5ykMv6fKaeGjiqnErfPcjeFlODxOQikWIctXE ZwuPVR5tGkvITPhFHrRUcKeqZh+yZPf/YUF/ahMoxmw5uWkjQDXJ4QmYl 6Lz6oTd9iDF0U+dnLAFVydBh/JFmxCiOjlkoBNTMXA23yRZ9RdLX5VLCS P/+VGPThBEWV08+d/wpCB5JggQ90qSejp99yROaXe2bwRLXmAPNza6Rh+ lbiLI5ZUzB4wRWZVz7DbkkQ+3qId/AKtUmHR4NfpUd5HnWZuBsb6K/igS w==; X-CSE-ConnectionGUID: cfXT4kjmQRWui9g1QdcUlg== X-CSE-MsgGUID: eVHDSpwxSxyzpBeHFmY2xQ== X-IronPort-AV: E=McAfee;i="6800,10657,11505"; a="55982055" X-IronPort-AV: E=Sophos;i="6.16,348,1744095600"; d="scan'208";a="55982055" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2025 02:22:26 -0700 X-CSE-ConnectionGUID: jMJk6o9MQ/23XJxrXZ8vQg== X-CSE-MsgGUID: VK1a+vq5QBqE3Lys3Ih1LA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,348,1744095600"; d="scan'208";a="162691451" Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2025 02:22:11 -0700 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, shameerali.kolothum.thodi@huawei.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 v4 17/20] intel_iommu: Replay all pasid bindings when either SRTP or TE bit is changed Date: Tue, 29 Jul 2025 05:20:39 -0400 Message-ID: <20250729092043.785836-18-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250729092043.785836-1-zhenzhong.duan@intel.com> References: <20250729092043.785836-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=192.198.163.17; 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Yi Liu When either 'Set Root Table Pointer' or 'Translation Enable' bit is changed, all pasid bindings on host side become stale and need to be updated. Introduce a helper function vtd_replay_pasid_bindings_all() to go through all pasid entries in all passthrough devices to update host side bindings. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 27bd8c4c89..d2442ff28d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -89,6 +89,7 @@ struct vtd_iotlb_key { static void vtd_address_space_refresh_all(IntelIOMMUState *s); static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n); +static void vtd_replay_pasid_bindings_all(IntelIOMMUState *s); static void vtd_pasid_cache_reset_locked(IntelIOMMUState *s); static void vtd_pasid_cache_sync(IntelIOMMUState *s, @@ -3050,6 +3051,7 @@ static void vtd_handle_gcmd_srtp(IntelIOMMUState *s) vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_RTPS); vtd_reset_caches(s); vtd_address_space_refresh_all(s); + vtd_replay_pasid_bindings_all(s); } /* Set Interrupt Remap Table Pointer */ @@ -3084,6 +3086,7 @@ static void vtd_handle_gcmd_te(IntelIOMMUState *s, bool en) vtd_reset_caches(s); vtd_address_space_refresh_all(s); + vtd_replay_pasid_bindings_all(s); } /* Handle Interrupt Remap Enable/Disable */ @@ -3774,6 +3777,17 @@ static void vtd_replay_guest_pasid_bindings(IntelIOMMUState *s, } } +static void vtd_replay_pasid_bindings_all(IntelIOMMUState *s) +{ + VTDPASIDCacheInfo pc_info = { .type = VTD_PASID_CACHE_GLOBAL_INV }; + + if (!s->flts || !s->root_scalable || !s->dmar_enabled) { + return; + } + + vtd_replay_guest_pasid_bindings(s, &pc_info); +} + /* * For a PASID cache invalidation, this function handles below scenarios: * a) a present cached pasid entry needs to be removed -- 2.47.1