From patchwork Mon Jun 5 11:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanfei Xu X-Patchwork-Id: 103211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2614184vqr; Mon, 5 Jun 2023 04:33:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ603G6Fbaonir72WSpJG8fdgLRBL7iXb1wCwbqp6kyTmpl8ErTxxgy8a/x2XF5Ay7EOBorT X-Received: by 2002:a17:902:f548:b0:1ac:4735:45d7 with SMTP id h8-20020a170902f54800b001ac473545d7mr8786470plf.6.1685964781256; Mon, 05 Jun 2023 04:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685964781; cv=none; d=google.com; s=arc-20160816; b=Xo1lhP8cu1f5IkUjaIK3LC4JMd+c5240ug59vPYxVTnMyF6ZoGzQuTKlO86og0QkHM +XMv8KGwKDQAU9aEpWYcIlidkFWuCMznGN1e8OWpaKriURtoTjANdzc2XZZbOEZM00i7 bHbfDKiaJn33rMxEEFw6KpnRsanyvoYxHFZn/1sBTPEHNzueUjssqvBePzeH4R5PgScj A1ReCLdHdHRyxFp4In7wqbX1uVafN0zGSm0QjLLol8qnR66zXCW8yTI7WEJ1XMs0PeDh /AsFn0AL2k1a71WKYJu6Qoi9wRX43TqnWQdqgMKpeu4T5TxqxKCN80Me5dgfqXH/ZvPd 2JBw== 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=fWnoi8rAQ4/zASfqkoPutemyxWGUlMtp1Ho5U3caBlU=; b=fNbUvzBtPtgcxhkIyY/fEZvJ2RXgvJrbao6NyX5PHGwx6J5BTrSIYQ3QhlNLXafN/v ZFCUR5jUzTMdzyRLaavanM7F68+Pg/S3ZycHuXpw8PGDDGeRw4RJeZeUWnFKWT4v6dmI DzbDmZR5xg89B1j2JPZpH0t8q7UyBSuG4sPBE/uv9vwA/9n7F58+gKHgGAXvEOXtEyfV qrwIHQQXjMf1kkbq0/5THF0kYxNDIbpXo27w8qoOoTektn6kI9Bo9o8JWCHDAQ49yby1 uvQ8hV8SJwd75Wx3iUqblsbsyEkolOfECAu7vBUrj9ZepjkGLJ/TsZs7xmW8GEjswxbg becw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FXQnaWXr; 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 f9-20020a170902ce8900b001b1f984784fsi2489452plg.476.2023.06.05.04.32.47; Mon, 05 Jun 2023 04:33:01 -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=FXQnaWXr; 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 S232157AbjFEL37 (ORCPT + 99 others); Mon, 5 Jun 2023 07:29:59 -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 X-Spam-Status: No, score=-4.4 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 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?1767862206636275343?= X-GMAIL-MSGID: =?utf-8?q?1767862206636275343?= 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 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_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) |