From nobody Sat Feb 7 20:43:58 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 A8A84EB64D8 for ; Wed, 14 Jun 2023 02:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242357AbjFNCtG (ORCPT ); Tue, 13 Jun 2023 22:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242321AbjFNCso (ORCPT ); Tue, 13 Jun 2023 22:48:44 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634D71FEF for ; Tue, 13 Jun 2023 19:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686710897; x=1718246897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ajj3+Tvbe7c1CGxr5IoLKuJl8BuTkCHeP1QAQhNq9bM=; b=SWqvETxnzvliPCZNpSWRQyATV5vKOLqs49W5WBZtiYd0qgF+o6hMK7N+ 0MNB5rl0wu92sz7tES/m8vZsW3oManO98e7NgXXhqNEd6V/Vq70PB+y2b 87DXYLi5wVbv0YfsVlUfOZ/V+Ar5V+RZyh0RgBKQSwGm8y1yF8EXOqUTt L/OcJuFojp/WSLOK8qWuuyoRMluaSEkcWaiBeGe5MknKZVS8QTZw02mr4 IH3EdvkwzQ7jR0P15vhDuE5BkZ2/r/Ko8LQiicXaGg/C9oBE52H9vso/G xuqYaHGK3ZhUSP72FrjHdJTn+EqmM15+X0drxVRVw/B+pHCw9dCyxx3tH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="348164446" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="348164446" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 19:48:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="711884191" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="711884191" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2023 19:48:15 -0700 From: Lu Baolu To: Joerg Roedel Cc: Yanfei Xu , Suhui , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] iommu/vt-d: Remove unnecessary (void*) conversions Date: Wed, 14 Jun 2023 10:47:02 +0800 Message-Id: <20230614024705.88878-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614024705.88878-1-baolu.lu@linux.intel.com> References: <20230614024705.88878-1-baolu.lu@linux.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" From: Suhui No need cast (void*) to (struct root_entry *). Signed-off-by: Suhui Link: https://lore.kernel.org/r/20230425033743.75986-1-suhui@nfschina.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index b871a6afd803..323fa1a93765 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1185,7 +1185,7 @@ static int iommu_alloc_root_entry(struct intel_iommu = *iommu) { struct root_entry *root; =20 - root =3D (struct root_entry *)alloc_pgtable_page(iommu->node, GFP_ATOMIC); + root =3D alloc_pgtable_page(iommu->node, GFP_ATOMIC); if (!root) { pr_err("Allocating root entry for %s failed\n", iommu->name); --=20 2.34.1 From nobody Sat Feb 7 20:43:58 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 5B4F2EB64D7 for ; Wed, 14 Jun 2023 02:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231386AbjFNCtJ (ORCPT ); Tue, 13 Jun 2023 22:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242329AbjFNCsp (ORCPT ); Tue, 13 Jun 2023 22:48:45 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7D01FFB for ; Tue, 13 Jun 2023 19:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686710899; x=1718246899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Kwv1UQHKRHrV8kbWrew4OGtdP1EEr6az2+Laq0Cs7w=; b=gGdyfAl9EuQOf2ibGWoHN2TA8KPQH1DBeu5qIRxTjFy5jxayKerF90qU 7c11gD3BoMx+5koNzfVLqBnWv37eeFoIge4rhjNOqAOM8QqGL4KuuxQLf rjpGmBvweF2faVr9WMMCfLRLL65ouna/S50+88kUrNnTFCGxQJkMVR9hg Di5QXpdfpQOh5G63GHy48R0otLtZMnaIzUt09yZ4FB0KrCi5F9V5Oap8j zPvzN51XGkMrqtrZDfIzh0rToKOZ3wK6xkZ8dgXoEuuylB6M0lOWSCGgr BEyIoiFrFqfEGWcAb6jMR6E5I0zVFmDsP0MntIQvOkB2tu1OVhVYbjJKi w==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="348164455" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="348164455" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 19:48:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="711884198" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="711884198" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2023 19:48:16 -0700 From: Lu Baolu To: Joerg Roedel Cc: Yanfei Xu , Suhui , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] iommu/vt-d: Handle the failure case of dmar_reenable_qi() Date: Wed, 14 Jun 2023 10:47:03 +0800 Message-Id: <20230614024705.88878-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614024705.88878-1-baolu.lu@linux.intel.com> References: <20230614024705.88878-1-baolu.lu@linux.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" From: Yanfei Xu dmar_reenable_qi() may not succeed. Check and return when it fails. Signed-off-by: Yanfei Xu Link: https://lore.kernel.org/r/20230605112659.308981-2-yanfei.xu@intel.com Signed-off-by: Lu Baolu --- 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 323fa1a93765..e83fe243680b 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 Sat Feb 7 20:43:58 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 9CE2EEB64D8 for ; Wed, 14 Jun 2023 02:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242474AbjFNCtN (ORCPT ); Tue, 13 Jun 2023 22:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242356AbjFNCst (ORCPT ); Tue, 13 Jun 2023 22:48:49 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA1B2112 for ; Tue, 13 Jun 2023 19:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686710900; x=1718246900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WrDuSdB9iYumVVBXtypeizwCzmEr0vrCm5Dy+N+kwxM=; b=lgqSQ/Nq5pVoN7RZymWTRPB3e6GlTrC65cBoX81IJlXvgQbYKxSS1+Sn 7BCapw+C+o0ICOsvSJnN7MKRU/GtmvzMvA3vKCjEeUgaeyrHzuZ+8jHIN M8/xMgwy2BOfKQPDfUNjHQruTbLfY9H7cOblWrDvirDWdK6TZXekw3M22 N3k/jHpvEpZ7N3tbrzYkTkHFTDZ1Rw2vqFxlp/y7Io9jrRjE4FoH3fgU9 KdSho4jdRciYB33hx4EGLp3fb0GeA9spqa0EKrZ1UIzfSY+LgFc0ez9AC VugGJcNmnTuUPMn4s/1AolL3m7FkHHnhWmQCGOMGY+2w/5qexVx0X4Xed g==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="348164462" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="348164462" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 19:48:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="711884211" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="711884211" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2023 19:48:18 -0700 From: Lu Baolu To: Joerg Roedel Cc: Yanfei Xu , Suhui , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] iommu/vt-d: Remove two WARN_ON in domain_context_mapping_one() Date: Wed, 14 Jun 2023 10:47:04 +0800 Message-Id: <20230614024705.88878-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614024705.88878-1-baolu.lu@linux.intel.com> References: <20230614024705.88878-1-baolu.lu@linux.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" From: Yanfei Xu 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. Remove 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 Link: https://lore.kernel.org/r/20230605112659.308981-3-yanfei.xu@intel.com Signed-off-by: Lu Baolu --- 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 e83fe243680b..4c0b7424c45e 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 From nobody Sat Feb 7 20:43:58 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 6AA37EB64D7 for ; Wed, 14 Jun 2023 02:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242484AbjFNCtR (ORCPT ); Tue, 13 Jun 2023 22:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242372AbjFNCsu (ORCPT ); Tue, 13 Jun 2023 22:48:50 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D77D2128 for ; Tue, 13 Jun 2023 19:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686710902; x=1718246902; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UGWXKlFwoha8aQZA4PcpDVrWAANHfSgY3CsRnwLIe6c=; b=a0+U6IQ5EdhQP35L6gr0wvawf4BRZU/vGOm0zeTiZNIUK6WYApbJhCev R0FDHPlJZIn1jwBbx2UwPwpSmGV5IEP+szU/CotZ44VSW3mlq6NCVANOG PmQ+7q3SCTNCH7JK6/PsMTdqil1Bj4Y4ZIpKF4cJbLn6nPNdwTkWHnV3q 5QnmQLGDHiSqB0TOzIvsbxSE8zuWNECeVu1hMsahLfBWCFCnQR3J1/5xd jbaZXLi0HOnC8KZ8JFl956SNaYA2Kt2pClFzxk6HNm69EnHkopv2dDJ42 eStzxda+Xg2HUnB6Aft/s47DIe6OeQDrtoqWO1BCSgUGTa46FgmE8EydL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="348164469" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="348164469" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 19:48:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="711884219" X-IronPort-AV: E=Sophos;i="6.00,241,1681196400"; d="scan'208";a="711884219" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2023 19:48:20 -0700 From: Lu Baolu To: Joerg Roedel Cc: Yanfei Xu , Suhui , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] iommu/vt-d: Remove commented-out code Date: Wed, 14 Jun 2023 10:47:05 +0800 Message-Id: <20230614024705.88878-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230614024705.88878-1-baolu.lu@linux.intel.com> References: <20230614024705.88878-1-baolu.lu@linux.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" These lines of code were commented out when they were first added in commit ba39592764ed ("Intel IOMMU: Intel IOMMU driver"). We do not want to restore them because the VT-d spec has deprecated the read/write draining hit. VT-d spec (section 11.4.2): " Hardware implementation with Major Version 2 or higher (VER_REG), always performs required drain without software explicitly requesting a drain in IOTLB invalidation. This field is deprecated and hardware will always report it as 1 to maintain backward compatibility with software. " Remove the code to make the code cleaner. Signed-off-by: Lu Baolu Reviewed-by: Jerry Snitselaar Link: https://lore.kernel.org/r/20230609060514.15154-1-baolu.lu@linux.intel= .com --- drivers/iommu/intel/iommu.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 4c0b7424c45e..e5c111ff4dd9 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1312,15 +1312,7 @@ static void __iommu_flush_iotlb(struct intel_iommu *= iommu, u16 did, iommu->name, type); return; } - /* Note: set drain read/write */ -#if 0 - /* - * This is probably to be super secure.. Looks like we can - * ignore it without any impact. - */ - if (cap_read_drain(iommu->cap)) - val |=3D DMA_TLB_READ_DRAIN; -#endif + if (cap_write_drain(iommu->cap)) val |=3D DMA_TLB_WRITE_DRAIN; =20 --=20 2.34.1