Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3371198rwb; Wed, 30 Nov 2022 20:18:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Qk70qk9XHc9TKGNIZp1ta61pIduMdxOQ4sIrkbhyEP8i3OJJq7EQJNLMBTHDZuFNbeKmi X-Received: by 2002:a17:902:ce04:b0:187:3a54:9b93 with SMTP id k4-20020a170902ce0400b001873a549b93mr54793432plg.2.1669868312303; Wed, 30 Nov 2022 20:18:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669868312; cv=none; d=google.com; s=arc-20160816; b=AtGLHzGRBfCYo3+7E38JroallLRqJ0A9uayLSFTEWNR0l+ARshKkPAz5HoOqcWrICO gQnCaUdV64GfxCvtk5oEg3AJC02GB7MPDw4rcF8TL4+kxKf81rWc8p+XW60kH9y4d7Qs 3F9U/BhZZps8epipr3mLjVmEydidn66tFFR3Yf9+xHFE/LSiCntISgD2uGiHHPlEhBb5 2qKl6ekQxX1EZmypLVAaNUJus1axrm+d9MbdMOeZ6/eydKO6Vc9MOu6ybPLa99VJrjyj PpDuYbHH4qL+HQQZuYpKdySF+ALP22sovddbUDxgm31dK7uYxX0MrgZbKrxkuqGFAZk9 S6FQ== 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 :content-language:references:to:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=3y2bQT17NlIzrW6tsCD85tkn4CPY8I/diFqMDD4kQBc=; b=E1y2dg+jlVX6TW6zKMHYyilD4jMyYHlfkoGHaasMF5RU3MEZAsOYrg/lHltcDHwEhY xO9vzNlPle3/klvowPrORiMItjUopQ5LcHfmycSCUtmwob+ikaWJcWjDprvpWrND9RNu ZK/uUSli7I9f77g0l0Vh6J6qIeBuROA5F73O4oHLkFK6HGFncaHzSce+nvSfK1fuxwCO e56MALGgnOJ8eYBaygVqJx9agSaUGoQJZ4OqFlU0txuNjdmq0/QxYQW87hbgl9zV4STj Z0XVcAtDnSjhwbzP62L9bu1l44f8cx80gB3ADU9PiBTGwjdW0fcJRTWmzKX5pM94n8np ccwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d+j3MuSk; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gf18-20020a17090ac7d200b002193f84afc5si5722982pjb.121.2022.11.30.20.18.21; Wed, 30 Nov 2022 20:18:32 -0800 (PST) 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=d+j3MuSk; 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 S229513AbiLAEC6 (ORCPT + 84 others); Wed, 30 Nov 2022 23:02:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiLAEC4 (ORCPT ); Wed, 30 Nov 2022 23:02:56 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C10233A4 for ; Wed, 30 Nov 2022 20:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669867375; x=1701403375; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=LkFVZ5y6iSsxWGJVWWeyV1KM60WDNR0NwUkCRUvE9y4=; b=d+j3MuSkar3qtDy4j0J06RNuBvWn1lbmG5IRV1j5x8PM6wecsdE1yxod q2hgd5RHWQpeaXy8dhFhJbNwLBzgVjKEgFAGMOQwGtswVZXWxTTeviLlI NBdxbcLzrsPwvBQwyBNJi5+9qcXIpxEwqFQpWbThFz8/SauonTjaKEFfh i+dRRlciBh8AyJLg6l6/4vuCIM/79SeestRrLuEmpclRtAru4fpcaYJSi ZOiMHCX0ueLjt03/AeOqO0fXhP+p7S+0jyDahDQx5pW36zrIJRwnDjdxr jwCdNmZcOmdOVyyFr/6F+P1nYHSBlHInyC0IQU+zoVYLjmzdmiG9bsPyU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="316733686" X-IronPort-AV: E=Sophos;i="5.96,207,1665471600"; d="scan'208";a="316733686" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 20:02:55 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="713068765" X-IronPort-AV: E=Sophos;i="5.96,207,1665471600"; d="scan'208";a="713068765" Received: from xuhuiyan-mobl1.ccr.corp.intel.com (HELO [10.254.215.206]) ([10.254.215.206]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 20:02:52 -0800 Message-ID: Date: Thu, 1 Dec 2022 12:02:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Cc: baolu.lu@linux.intel.com, Robin Murphy , Will Deacon , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , Yuzhang Luo Subject: Re: [PATCH v3] iommu/vt-d: Add a fix for devices need extra dtlb flush To: Jacob Pan , LKML , iommu@lists.linux.dev, Joerg Roedel References: <20221130062449.1360063-1-jacob.jun.pan@linux.intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <20221130062449.1360063-1-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 On 2022/11/30 14:24, Jacob Pan wrote: > QAT devices on Intel Sapphire Rapids and Emerald Rapids have a defect in > address translation service (ATS). These devices may inadvertently issue > ATS invalidation completion before posted writes initiated with > translated address that utilized translations matching the invalidation > address range, violating the invalidation completion ordering. > > This patch adds an extra device TLB invalidation for the affected devices, > it is needed to ensure no more posted writes with translated address > following the invalidation completion. Therefore, the ordering is > preserved and data-corruption is prevented. > > Device TLBs are invalidated under the following six conditions: > 1. Device driver does DMA API unmap IOVA > 2. Device driver unbind a PASID from a process, sva_unbind_device() > 3. PASID is torn down, after PASID cache is flushed. e.g. process > exit_mmap() due to crash > 4. Under SVA usage, called by mmu_notifier.invalidate_range() where > VM has to free pages that were unmapped > 5. userspace driver unmaps a DMA buffer > 6. Cache invalidation in vSVA usage (upcoming) > > For #1 and #2, device drivers are responsible for stopping DMA traffic > before unmap/unbind. For #3, iommu driver gets mmu_notifier to > invalidate TLB the same way as normal user unmap which will do an extra > invalidation. The dTLB invalidation after PASID cache flush does not > need an extra invalidation. > > Therefore, we only need to deal with #4 and #5 in this patch. #1 is also > covered by this patch due to common code path with #5. > > Tested-by: Yuzhang Luo > Reviewed-by: Ashok Raj > Reviewed-by: Kevin Tian > Signed-off-by: Jacob Pan Queued for Joerg. Thank you! Best regards, baolu