Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932409AbdIGQ1R (ORCPT ); Thu, 7 Sep 2017 12:27:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60986 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932373AbdIGQ1O (ORCPT ); Thu, 7 Sep 2017 12:27:14 -0400 Subject: Re: [RFC PATCH 0/6] Add platform device SVM support for ARM SMMUv3 To: Bob Liu , Yisheng Xie Cc: joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, will.deacon@arm.com, robin.murphy@arm.com, robert.moore@intel.com, lv.zheng@intel.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devel@acpica.org, chenjiankang1@huawei.com, xieyisheng@huawei.com References: <1504167642-14922-1-git-send-email-xieyisheng1@huawei.com> <95d1a9e2-1816-ff7d-9a8d-98406a6c2c22@arm.com> <8e4764f5-0e5d-7fd6-529b-35914e1e3668@huawei.com> From: Jean-Philippe Brucker Message-ID: <24e7e405-ad4a-4847-6177-987966182cbd@arm.com> Date: Thu, 7 Sep 2017 17:30:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <8e4764f5-0e5d-7fd6-529b-35914e1e3668@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1148 Lines: 26 On 07/09/17 02:55, Bob Liu wrote: > Speak to the invalidation, I have one more question. > > There is a time window between 1) modify page table; 2) tlb invalidate; > > ARM-CPU Device > > 1. modify page table > > ^^^^^ > Can still write data through smmu tlb even page table was already modified. > (At this point, the same virtual addr may not point to the same thing for CPU and device!!! > I'm afraid there may be some data-loss or other potential problems if this situation happens.) > > 2. tlb invalidate range The mm code serializes map/unmap operations with mm->mmap_sem, and at a lower level I think the pte lock is used to prevent more subtle races. Don't take my word for it though, mm/ is still very obscure to me. So the kernel shouldn't be able to reuse the VA for something else before the tlb invalidation completes. Even if you're using the CMDQ to invalidate instead of TLBI instructions, you're still called by a notifier from the mm code so there is no problem. Thanks, Jean