From patchwork Fri Jun 2 02:05:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanfei Xu X-Patchwork-Id: 102282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp750252vqr; Thu, 1 Jun 2023 19:34:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YWdkLEswASbjR9kRLjsinrCMNch0EGOdMRdfml+eOzIQyKv9x6FWo3J6EVrdUKWBzhgTL X-Received: by 2002:a17:903:41d2:b0:1b1:8ec8:7f67 with SMTP id u18-20020a17090341d200b001b18ec87f67mr926864ple.5.1685673274606; Thu, 01 Jun 2023 19:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685673274; cv=none; d=google.com; s=arc-20160816; b=ylgkV7GVABOZKSYfeyQuyDCFRmaeBXpAEwz4gcvcqDSq68zxn+I1HzqDwtG9vvkDir Lek+lZTqJDwNPANv9/KCAGCHEZilZeSSrVfJm3GIp/C5qOPHfXZXxotwafVEgW7Acikq f3kgXfbneySsThUvrUWIf2VPHIo6tKb1Yac6ltSLtm2lv1cLAbjOX4S1cw3ii3Z4uLi7 wrNZbxTq4Ru3ovryJCvtjMD+BrGoiVq2gP90ynJg/B7TxrwsVaHJDYUT9CM+NtjZfvHC gOmW/Gi96nmF/I09fV8sJU961gtHVGwdhquPD1ZDiZswpZJ+ruQtP1WFEm7WCQxCC8vT 1nyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4/rMujaOZaaCbySzKnCuUr4fE9psWIFDWjIJfU1x45c=; b=XxaIr/MAN8jj2eI7y0ORs/F5LWdqzfi9UzSGGAaj97jRxH04VIy7d4p9vwZd5KY072 I2UYOLjCiCX3xoEMrwdj4XMG9edpl/nzbeUwT1cNBKlD3NmhJ4Prrf1iINfxdsDldbKn 8XXNTsxwu+3CGbkJeDsyGCe4V0sKSnaa3+T7Uo2B2pOfCVMPRDDiZtod0JZbeS8ZpZjZ i3TZutlb1M46ASD+G5oDYC+yMzYhooZ08nnk3whtR4azsGjRhGdpa+8WHoUvBWTG9cRz l9yb/kIWr0pOBHH5od56XnkuQgCRQ9A8nkVWqSXo4kfUsc2PNmCQJPpI+0cGnmBS/7nx 7/7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YENGcEbc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a170903234100b001afe110eb66si97326plh.532.2023.06.01.19.34.23; Thu, 01 Jun 2023 19:34:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YENGcEbc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233480AbjFBCIi (ORCPT + 99 others); Thu, 1 Jun 2023 22:08:38 -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 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767556539362306195?= X-GMAIL-MSGID: =?utf-8?q?1767556539362306195?= Remove the WARN_ON(did == 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_domain *domain, struct context_entry *context; int ret; - WARN_ON(did == 0); - if (hw_pass_through && domain_type_is_si(domain)) translation = CONTEXT_TT_PASS_THROUGH; @@ -1944,8 +1942,6 @@ static int domain_context_mapping_one(struct dmar_domain *domain, if (sm_supported(iommu)) { unsigned long pds; - WARN_ON(!table); - /* Setup the PASID DIR pointer: */ pds = context_get_sm_pds(table); context->lo = (u64)virt_to_phys(table->table) |