Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp56296rdb; Wed, 29 Nov 2023 20:07:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4ey60EAztwpyhlnS8Q803xqsVlDLogAMPsB4dgSxJjbec82xyhwxw3enc+h5NxyC9KVXL X-Received: by 2002:a05:6a20:1605:b0:18b:f90d:9d84 with SMTP id l5-20020a056a20160500b0018bf90d9d84mr28250396pzj.54.1701317253930; Wed, 29 Nov 2023 20:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701317253; cv=none; d=google.com; s=arc-20160816; b=Hapacj+QZIBC6fUGPmHHEDmiOwr0C1mo8KQCQ0KSkjSfldhdJ0akG+W7YgFeEjY7Xu eWGoQ8xir13kJ4FvH5k1OQplx610p/MlJV9Mcab5Eoutfmcumr3Snj4lFieY44NLe0yc 89XWUKJC9jfB/RonzHwXMSitA0FVVZc8dCAH+mQx6gcWYU/KeO+QPc60DeVkQB0FcpSu 4+IY/phcMmB1QQAtuwhzOuNEB+UHGoLf5KL0ehuUH67NZIC4eLjx13KWqKkBjwBYsgMU XgzEek4+LepTkh9k/SpbV5fgZMsXB+9goLrud4kJ6VGDHoFpMBMiFTh1SgAnkqv+pVwP SGpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=FmFjlLjYXtNxELwkdZMtzC5pHKHFzzbz3kJXcry8O0g=; fh=JpfWtCw9fBPh0qfGxT1K2yf4i+TGEOcQwG1UWtdiC3c=; b=Hy22vwPbyGOiscaPrV+JOYXcTvHivP7Gsl+i0vu/uUqfbRiamYefXx2O9hToQMwJHd QgeX7Bs56MlziOosFdAziW6o2HLlHOxd5GpvngtfLS2oxc6t/Qza6kxbJs8PgIKKnE1h 8acwSVM3J1FDmAlYHDdghXS4x9gEPUsBf8fmyWau46b1pVTT/q5RkDzpaUaB3MNXt3Ue 9bN2OIjNz/neIXzLDsIRc/kn8gBLdoTN6Ov4vrEchuzJoQIc0OKK77O/irNA1NNzpkFb zfNKcKJCH6TVr+tK7ztEGvYBZUEc0erIX4rByKSVRe5rOEJ7zMnO5toMNSKMpDVlys/V 4LFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DE1ZLcaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y4-20020a056a001c8400b006cc01c90d31si340617pfw.312.2023.11.29.20.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 20:07:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DE1ZLcaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id AC55A8056A35; Wed, 29 Nov 2023 20:07:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344426AbjK3EHJ (ORCPT + 99 others); Wed, 29 Nov 2023 23:07:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344410AbjK3EG6 (ORCPT ); Wed, 29 Nov 2023 23:06:58 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3B7310CB for ; Wed, 29 Nov 2023 20:07:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701317224; x=1732853224; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=KxJStMIjvmZs8RPaJO7hZ8ggE4sIsO6JisfWuT7Iv7g=; b=DE1ZLcaDbtezW340PO6lWTB2/Cr3A4imTzzLvyI4MQzmFRtWmcjwW7Pd sYpYoxNTj7rtpZiQiSifVLnwPVQjHWN95X3Vk1u0ooPttrXSp9T4Xu5jo GPryUO9364ZhyGVNYfdjkhWAYxJ2UIA5LT0heA5G+5ZQu9i9PaLC9gQOt LWbweAJbLVLfClMazh3t5kFhfVskTVqbxMyZ98UYjflcvtiW5+Mxxi2Y5 CK6OLhh3MzM9rZ4HCDylmCZnGT33j9RdOkqlX/v3WtfQ9pQR+anDR10p+ fzMsLm+G2HHiyegWk2eiwiFYzmlJxh7ZcXXQqD7eiKWcTY4LLDasIM878 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="392130204" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="392130204" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 20:07:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="10614646" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.249.171.155]) ([10.249.171.155]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 20:07:02 -0800 Message-ID: <2f2582df-fb56-4b46-8ce3-364879b34734@linux.intel.com> Date: Thu, 30 Nov 2023 12:06:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] iommu/vt-d: Omit devTLB invalidation requests when TES=0 Content-Language: en-US To: Jason Gunthorpe References: <20231114011036.70142-1-baolu.lu@linux.intel.com> <20231114011036.70142-2-baolu.lu@linux.intel.com> <20231129201020.GK1312390@ziepe.ca> From: Baolu Lu In-Reply-To: <20231129201020.GK1312390@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 20:07:28 -0800 (PST) On 2023/11/30 4:10, Jason Gunthorpe wrote: > On Tue, Nov 14, 2023 at 09:10:34AM +0800, Lu Baolu wrote: >> The latest VT-d spec indicates that when remapping hardware is disabled >> (TES=0 in Global Status Register), upstream ATS Invalidation Completion >> requests are treated as UR (Unsupported Request). >> >> Consequently, the spec recommends in section 4.3 Handling of Device-TLB >> Invalidations that software refrain from submitting any Device-TLB >> invalidation requests when address remapping hardware is disabled. >> >> Verify address remapping hardware is enabled prior to submitting Device- >> TLB invalidation requests. >> >> Fixes: 792fb43ce2c9 ("iommu/vt-d: Enable Intel IOMMU scalable mode by default") >> Signed-off-by: Lu Baolu >> --- >> drivers/iommu/intel/dmar.c | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) > How did you get to the point where flush_dev_iotlb could even be > called if the iommu has somehow been globally disabled? > > Shouldn't the attach of the domain compeltely fail if the HW is > disabled? > > If the domain is not attached to anything why would flushing happen? The VT-d hardware can be in a state where the hardware is on but DMA translation is deactivated. In this state, the device probe process during boot proceeds as follows: 1) Initialize the IOMMU contexts: This sets up the data structures that the IOMMU uses to manage address translation for DMA operations. 2) Register the IOMMU devices: This registers the IOMMU devices to the core. The core then probes devices on buses like PCI. 3) Enable DMA translation: This step activates DMA translation. With regard to step 2), the call to iommu_flush_iotlb_all() in iommu_create_device_direct_mappings() can potentially cause device TBL invalidation when the VT-d DMA translation is deactivated. Best regards, baolu