From nobody Sun Feb 8 00:26:11 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3117C7EE2A for ; Fri, 2 Jun 2023 02:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233468AbjFBCIh (ORCPT ); Thu, 1 Jun 2023 22:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233340AbjFBCId (ORCPT ); Thu, 1 Jun 2023 22:08:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585D4180 for ; Thu, 1 Jun 2023 19:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685671712; x=1717207712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JEJ1L3fbLIKfs8vDviE5ZoWgHo3ib3dTNshAkV9bzsg=; b=JvCysEE68GeseskCo0qc0y6LVQfrBG47NEVEfOICGRbJ4J6W3tFkWlBV OwcQm5IMz3OL3r/W/PNjd23NS7CIB9txgunRoZ7cYQTy/JCdDh0t4WOEY QLDCGTqmx92d7AqrjMpmdtIZgZQ5bhYvF2a/9/I5XArUwEsp3QLAAf87B t8DQfQwLOGYMHV3DItwctG1zkzz5I2q5t6ZKDb0bxnCYlcgKdXDFXfR1L D1LykknocDXoMyrESt/SINIpiaqIBX5aZ+blksslvcBBXZ24Pwktfc9FC 3Gxy4qlbLq935IRZQiEwiXpUSTbcntM824etgBnsZCzwskVSroy3e57b5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="359039378" X-IronPort-AV: E=Sophos;i="6.00,211,1681196400"; d="scan'208";a="359039378" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 19:08:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="777457812" X-IronPort-AV: E=Sophos;i="6.00,211,1681196400"; d="scan'208";a="777457812" Received: from tower.bj.intel.com ([10.238.157.62]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 19:08:22 -0700 From: Yanfei Xu To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, yanfei.xu@intel.com Subject: [PATCH v2 1/2] iommu/vt-d: Handle the failure case of dmar_reenable_qi() Date: Fri, 2 Jun 2023 10:05:19 +0800 Message-Id: <20230602020520.224465-2-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230602020520.224465-1-yanfei.xu@intel.com> References: <20230602020520.224465-1-yanfei.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" dmar_reenable_qi() may not succeed. Check and return when it fails. Signed-off-by: Yanfei Xu --- drivers/iommu/intel/iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 8096273b034c..e9188d045609 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2967,10 +2967,14 @@ static int init_iommu_hw(void) { struct dmar_drhd_unit *drhd; struct intel_iommu *iommu =3D NULL; + int ret; =20 - for_each_active_iommu(iommu, drhd) + for_each_active_iommu(iommu, drhd) { if (iommu->qi) - dmar_reenable_qi(iommu); + ret =3D dmar_reenable_qi(iommu); + if (ret) + return ret; + } =20 for_each_iommu(iommu, drhd) { if (drhd->ignored) { --=20 2.34.1 From nobody Sun Feb 8 00:26:11 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 809EFC7EE2A for ; Fri, 2 Jun 2023 02:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233490AbjFBCIj (ORCPT ); Thu, 1 Jun 2023 22:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233416AbjFBCId (ORCPT ); Thu, 1 Jun 2023 22:08:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894B213E for ; Thu, 1 Jun 2023 19:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685671712; x=1717207712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xXDHEebrmcG8OAsrT6tWlvpRC2d/E9PoJjmv8khoEmE=; b=YENGcEbcSYn/b/gmzsxOOzGgI4858rwzERInKA4cVqwGNdsgE9H7Q1Wi Md8UVrO3rxXEAsY0z0sE/poEd5+BVVGrt/I2nn4LcZTKfcsO/Xqm1z/Xt 79UYrjpOKYDqAFeM7RAUsRd1j/ExY0gHrP+aqvqEyWaTBIAOoIoH/rZtp ShwENKS7BhyrSonq/t0PUyGJpA3IMePno93KBHwEpW3NfNcoNhfsBSM2f Kb0XGudfkfy+P1OVtFc9iAtThr1i5UJLe36wPvg2ZFVXwGtJjGyqv3v80 f59CX9Bifh7tARCfBrBUrPTUHU8Sq2prHABpbQJgqnN+XaZ2osZN2MRxJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="359039385" X-IronPort-AV: E=Sophos;i="6.00,211,1681196400"; d="scan'208";a="359039385" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 19:08:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="777457827" X-IronPort-AV: E=Sophos;i="6.00,211,1681196400"; d="scan'208";a="777457827" Received: from tower.bj.intel.com ([10.238.157.62]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 19:08:24 -0700 From: Yanfei Xu To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, yanfei.xu@intel.com Subject: [PATCH v2 2/2] iommu/vt-d: Remove two WARN_ON in domain_context_mapping_one() Date: Fri, 2 Jun 2023 10:05:20 +0800 Message-Id: <20230602020520.224465-3-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230602020520.224465-1-yanfei.xu@intel.com> References: <20230602020520.224465-1-yanfei.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the WARN_ON(did =3D=3D 0) as the domain id 0 is reserved and set once the domain_ids is allocated. So iommu_init_domains will never return 0. Remvoe the WARN_ON(!table) as this pointer will be accessed in the following code, if empty "table" really happens, the kernel will report a NULL pointer reference warning at the first place. Signed-off-by: Yanfei Xu --- drivers/iommu/intel/iommu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e9188d045609..3953dd69200d 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1897,8 +1897,6 @@ static int domain_context_mapping_one(struct dmar_dom= ain *domain, struct context_entry *context; int ret; =20 - WARN_ON(did =3D=3D 0); - if (hw_pass_through && domain_type_is_si(domain)) translation =3D CONTEXT_TT_PASS_THROUGH; =20 @@ -1944,8 +1942,6 @@ static int domain_context_mapping_one(struct dmar_dom= ain *domain, if (sm_supported(iommu)) { unsigned long pds; =20 - WARN_ON(!table); - /* Setup the PASID DIR pointer: */ pds =3D context_get_sm_pds(table); context->lo =3D (u64)virt_to_phys(table->table) | --=20 2.34.1