From nobody Sun Feb 8 09:11:17 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 2B473C7EE24 for ; Mon, 5 Jun 2023 11:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbjFEL3z (ORCPT ); Mon, 5 Jun 2023 07:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbjFEL3r (ORCPT ); Mon, 5 Jun 2023 07:29:47 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18376DF for ; Mon, 5 Jun 2023 04:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685964586; x=1717500586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xTKbEBDDCXHkiOwFc8keR7O1v8qG4g2CVMGkrh5HwGY=; b=F4qmDLinHiPUi1r4HMGClI4bzPYB+Idiyoie6zQ+StyadjzFnt507zoT ByhdC/xvn6WnMPXEmBr5FHaZFR94BRmzrXd6aE2LVzSqKoxB753EQ6JFJ J3araf93lCAoe39ah6s+y5QjRNp+JjvSCzgptwyUdCPfUeIKZFUR6LmwH rLONSxUgBH5uF3NrCKRjdRK2H8j9WiAItQDaiMfEcK67HzsAILVu3iev0 YUd+BoADalqgZ6xEeWI4jk3SoavhfzWK5IF/aY4KkW/twlQhO1CxCYCHo oyLu9UHYNZbN1yg8QbyPwzZaWkgVpXks/TgEb56PO5M+Fxi3b/slq7jFI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="336699349" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="336699349" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:29:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="708626664" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="708626664" Received: from tower.bj.intel.com ([10.238.157.62]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:29:43 -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 v3 1/2] iommu/vt-d: Handle the failure case of dmar_reenable_qi() Date: Mon, 5 Jun 2023 19:26:58 +0800 Message-Id: <20230605112659.308981-2-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230605112659.308981-1-yanfei.xu@intel.com> References: <20230605112659.308981-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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 8096273b034c..c13c6475b626 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2967,10 +2967,15 @@ 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) - if (iommu->qi) - dmar_reenable_qi(iommu); + for_each_active_iommu(iommu, drhd) { + if (iommu->qi) { + 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 09:11:17 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 2C426C7EE24 for ; Mon, 5 Jun 2023 11:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbjFELaA (ORCPT ); Mon, 5 Jun 2023 07:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232151AbjFEL3t (ORCPT ); Mon, 5 Jun 2023 07:29:49 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 648C4F9 for ; Mon, 5 Jun 2023 04:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685964588; x=1717500588; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WEJON0mdcarcf+gq8BZwb49Cru53/uhaflnw7S9fEAQ=; b=FXQnaWXrpKbXMlEDWrQ7hJWXjYZRv3n+bmwx1R4fIrPkZ7l3HUtq48ix QV3SokPOGPWYkUVGXF8kcp76HLzULeXX3j7eSVCnpaSs1BB8TdWeQBW+m 7NzW9Mj9KZ20OvYTuVDpfYjdlU2UkjvM9EaMZMk4mAuJ84xOYxQDlueke 6Oi7v9h1tStl4NGvpWZb5RrU2gMn/DmbeeUneErl6JoEOQNXeNSPFfFAE deYI/0mdziFRFkVMYoX4myYBKGibwP5vExzdUQk0OwiPKSu3O+iWK0syI Q6htNz4tL7wOQHsDwLt9oluUWi1FSANTcTjNspV6aenXWpoyExqkhhBnm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="336699362" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="336699362" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:29:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="708626668" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="708626668" Received: from tower.bj.intel.com ([10.238.157.62]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:29:45 -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 v3 2/2] iommu/vt-d: Remove two WARN_ON in domain_context_mapping_one() Date: Mon, 5 Jun 2023 19:26:59 +0800 Message-Id: <20230605112659.308981-3-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230605112659.308981-1-yanfei.xu@intel.com> References: <20230605112659.308981-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 c13c6475b626..cd9e01a0aa1d 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