From nobody Tue Nov 26 19:47:41 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=1705905806; cv=none; d=zohomail.com; s=zohoarc; b=Y7yEKfkC3LAGLW2/ACnEktRzQT+eXCpQApKyiRXBkk7N2/78CoHl3pHYwgTwmfXyvipWEEU17DV6cK01GKfeH7DaXv9gTCJAgIaL2WNfqWrlSnM34aCYMfrV3if4nKmcx33BCtB2XIBFaZcaq/fT0xT5M/JZb+ySgfCgBPvjLg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705905806; 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=dZFfiej1iBV5OvPWxn2He31XfiDUyYaE+KpHm6XdWNk=; b=dricyKEnT5tjUYfGzcra//1WyE3oob5CkMTOGkW6aPGRBdmxkI87agUnefdfqeTCCz+UHgQ/TvA5IZjswZLAKYTULZSmZb6T1nlzBvhRoJ6tkhvDGqAYL7ZWmDeLOLlAKilGm7W0lKYdC3dAuwJiSr6M8IGgSe16UqlnRCasCfg= 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 1705905806685304.97603328912226; Sun, 21 Jan 2024 22:43:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRo1I-0005AB-76; Mon, 22 Jan 2024 01:42:59 -0500 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 1rRo15-00057y-8u; Mon, 22 Jan 2024 01:42:43 -0500 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRo13-0007FD-1P; Mon, 22 Jan 2024 01:42:42 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 22:42:34 -0800 Received: from spr-s2600bt.bj.intel.com ([10.240.192.124]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 22:42:30 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705905761; x=1737441761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZQY0H75u+yRvchuolvuAcTS1ZqiXfRlinti37nkbD/Y=; b=KZETwAGcOs81cGrFxEXllrgm9AekN9LBdJnE6tQ9sjqKoTqspCCoAln7 8u3xB32BxzPenwo12RpJl23zDHGRCdlqC7yEb9qEkVBI/4uXQMpN2MfWt FwGyL9okMxku5eLzQDw0jWg/Iihx7CBxzBqC8EQvBepYFtwU5dmhhXKb9 ZLAMMqJ7cKBfLqLqt4BIn4q8ocREgVTyK1tY26tLtDHTp8QLcIkANyhWJ g2qmyeIlnn3ErWRKaft3ON31gbAlcourgCvck6CDXdRsgpxIhaCxXZDnw djYF/LdXC7/RuZrhvI4DgqV4YKpDmZ2N2mF6i78OQMDWsUKTHn7s9unAM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="7792045" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="7792045" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="761646631" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="761646631" From: Zhenzhong Duan To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: eric.auger@redhat.com, jean-philippe@linaro.org, alex.williamson@redhat.com, clg@redhat.com, peterx@redhat.com, jasowang@redhat.com, mst@redhat.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH 1/3] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset Date: Mon, 22 Jan 2024 14:40:13 +0800 Message-Id: <20240122064015.94630-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122064015.94630-1-zhenzhong.duan@intel.com> References: <20240122064015.94630-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=198.175.65.11; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.287, 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, 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: , 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: 1705905807362100001 Content-Type: text/plain; charset="utf-8" IOMMUPciBus pointer cache is indexed by bus number, bus number may not always be a fixed value, i.e., guest reboot to different kernel which set bus number with different algorithm. This could lead to endpoint binding to wrong iommu MR in virtio_iommu_get_endpoint(), then vfio device setup wrong mapping from other device. Signed-off-by: Zhenzhong Duan --- hw/virtio/virtio-iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 8a4bd933c6..bfce3237f3 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -1264,6 +1264,8 @@ static void virtio_iommu_system_reset(void *opaque) =20 trace_virtio_iommu_system_reset(); =20 + memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_nu= m)); + /* * config.bypass is sticky across device reset, but should be restored= on * system reset --=20 2.34.1