Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp50380rdb; Wed, 29 Nov 2023 19:48:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuoMid8aCURQ+8FpRLdgV8xAM17D156QSjljbrmTzcH69Ogxg+Oaq0YPDyJw8NMdfaUVF2 X-Received: by 2002:a05:6a20:c189:b0:189:7c2:508d with SMTP id bg9-20020a056a20c18900b0018907c2508dmr22873043pzb.12.1701316139130; Wed, 29 Nov 2023 19:48:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701316139; cv=none; d=google.com; s=arc-20160816; b=Elo3JwcbirI77HoIWa0JS6lV5qUIRzv9HHrH6L1wNPtKmOiGlb0cMS+xaM4VO4iD8D HpxSS5S+lzLm7p50a5vFMP3DfF0NcwKqhCpyCZUHGM+OTFygjPFI+qZZ15BAcXboKFMW gQCGClE0N5l6m1a7+G4QdgIb9mrkpBqmkvmfpuXlH5uQNFGkXJ0wMOI4v1RhMPz/i9Fh ZskT4niyU2DSSrzTin21ig4YPuaEfzxFxBRAkHUuc606B7jhUi5YHtL5P8olGl0nDgC7 NjosSZNx6Hzet701xGcBIKyHdqHh6H1GdTIDOcSQzX0tMROitktM4ri67ZDraApPoTZt fruw== 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=xH/0Mw2hBQ7jYkdcYX58uUTxKn/tgX/kcVOrp3JT4aI=; fh=JpfWtCw9fBPh0qfGxT1K2yf4i+TGEOcQwG1UWtdiC3c=; b=lJOVKXg9GgU47t8NZjae+uV+N2UwYGvWrp2h/86lFnSxLjg2xcjZ59rxXB2Sb4W9Xp xK+DOc4Q/wjVMXHpQFCHZjImPjKuGAFVQDW3t00qv7hWwa0j3460pjlBnG5npI43Qn8m RnqeZh+BRhcK1ayyHoi20c86u3pgh3gyHhCytc+GSW6Cgb8BF99JxWWadOHL5t/jPfBU Mh0G2LG/kJK/uhSoioIOXL4ThTSGWea4kikS4ylwYAzvrga2U+zxH4V/rUUTsi2qjFBO hzqF7HH4T5K7JXIv2eeZt7S403wijM6Xk2uYJJcS6/CwpYxH/rtil580DsVZ5bi38iZ7 68pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fLXAm5Fi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u17-20020a170902e81100b001d00a56b03asi265462plg.337.2023.11.29.19.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 19:48:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fLXAm5Fi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 8C734802AA28; Wed, 29 Nov 2023 19:48:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbjK3Dsl (ORCPT + 99 others); Wed, 29 Nov 2023 22:48:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbjK3Dsk (ORCPT ); Wed, 29 Nov 2023 22:48:40 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03D9D66 for ; Wed, 29 Nov 2023 19:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701316127; x=1732852127; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=xC3dwYlDuD1hlwFCoRdZoguQbZrD/kr1AFHDGZNT2y0=; b=fLXAm5FiX8W6//bp1eU5ySP12/Cm/YkYIVuM8eVYajoYF2cp8rD7Zwgk /8AkS7WmZkPeUtZJD1UxJdr6w3/wk+hla++acwlMB366WWUaG2YdjF5Eh sdBSUltZM34h8igpBI8ZsXqNaih3Xuy+BD4OC7TIZkDJpsBMdqGdvvQKZ mdT6anxrGR+WdgsUy/P0vNVSEoG64s44j3GNdEmJF+qPdOKfwYLnNI9h+ VbyGHd0kSUg2JdPIZ/u2mXvu+yffGJ9/koo+HKF3V4HhTlEtKbv9jzlFp ep3TF/vTebyol02akwcb8y1wA9vZ2fKwFj4FJzqvYIYh6/KVPXZIMmlIM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="373447806" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="373447806" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 19:48:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="1100780499" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="1100780499" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.249.171.155]) ([10.249.171.155]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 19:48:45 -0800 Message-ID: <07f6d0f1-0b3d-486a-a26b-483874a93b24@linux.intel.com> Date: Thu, 30 Nov 2023 11:48:43 +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: Support enforce_cache_coherency only for empty domains Content-Language: en-US To: Jason Gunthorpe References: <20231114011036.70142-1-baolu.lu@linux.intel.com> <20231129200834.GJ1312390@ziepe.ca> From: Baolu Lu In-Reply-To: <20231129200834.GJ1312390@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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 29 Nov 2023 19:48:56 -0800 (PST) On 2023/11/30 4:08, Jason Gunthorpe wrote: > On Tue, Nov 14, 2023 at 09:10:33AM +0800, Lu Baolu wrote: >> diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h >> index 65d37a138c75..ce030c5b5772 100644 >> --- a/drivers/iommu/intel/iommu.h >> +++ b/drivers/iommu/intel/iommu.h >> @@ -602,6 +602,9 @@ struct dmar_domain { >> */ >> u8 dirty_tracking:1; /* Dirty tracking is enabled */ >> u8 nested_parent:1; /* Has other domains nested on it */ >> + u8 has_mappings:1; /* Has mappings configured through >> + * iommu_map() interface. >> + */ > Is it racey? > > The other option is to make iommfd do this and forbid it from > switching the enforce_cache_coherency if the IOAS has any maps > attached. We can get the correct locking at that point. > > AMD has the same issue if it ever wants to implement its per-PTE bit Yes. It's better to do this in iommufd. With that done, we can then remove this code. Best regards, baolu