Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752024AbdLNGKp (ORCPT ); Thu, 14 Dec 2017 01:10:45 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:11977 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbdLNGKn (ORCPT ); Thu, 14 Dec 2017 01:10:43 -0500 Subject: Re: [PATCH 1/2] mm: Add kernel MMU notifier to manage IOTLB/DEVTLB To: Lu Baolu , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "Alex Williamson" , Joerg Roedel , David Woodhouse References: <1513213366-22594-1-git-send-email-baolu.lu@linux.intel.com> <1513213366-22594-2-git-send-email-baolu.lu@linux.intel.com> <5A31F232.90901@linux.intel.com> CC: Rik van Riel , Michal Hocko , Dave Jiang , Dave Hansen , , , , , Vegard Nossum , Andy Lutomirski , Huang Ying , "Matthew Wilcox" , Andrew Morton , "Paul E . McKenney" , "Kirill A . Shutemov" , Kees Cook , "xieyisheng (A)" From: Bob Liu Message-ID: Date: Thu, 14 Dec 2017 14:07:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <5A31F232.90901@linux.intel.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.83.150] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5A321549.007B,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9761813b59200f41c7a98dfa8d4b4ca8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1677 Lines: 47 On 2017/12/14 11:38, Lu Baolu wrote: > Hi, > > On 12/14/2017 11:10 AM, Bob Liu wrote: >> On 2017/12/14 9:02, Lu Baolu wrote: >>>> From: Huang Ying >>>> >>>> Shared Virtual Memory (SVM) allows a kernel memory mapping to be >>>> shared between CPU and and a device which requested a supervisor >>>> PASID. Both devices and IOMMU units have TLBs that cache entries >>>> from CPU's page tables. We need to get a chance to flush them at >>>> the same time when we flush the CPU TLBs. >>>> >>>> We already have an existing MMU notifiers for userspace updates, >>>> however we lack the same thing for kernel page table updates. To >> Sorry, I didn't get which situation need this notification. >> Could you please describe the full scenario? > > Okay. > > 1. When an SVM capable driver calls intel_svm_bind_mm() with > SVM_FLAG_SUPERVISOR_MODE set in the @flags, the kernel > memory page mappings will be shared between CPUs and > the DMA remapping agent (a.k.a. IOMMU). The page table > entries will also be cached in both IOTLB (located in IOMMU) > and the DEVTLB (located in device). > But who/what kind of real device has the requirement to access a kernel VA? Looks like SVM_FLAG_SUPERVISOR_MODE is used by nobody? Cheers, Liubo > 2. When vmalloc/vfree interfaces are called, the page mappings > for kernel memory might get changed. And current code calls > flush_tlb_kernel_range() to flush CPU TLBs only. The IOTLB or > DevTLB will be stale compared to that on the cpu for kernel > mappings. > > We need a kernel mmu notification to flush TLBs in IOMMU and > devices as well. > > Best regards, > Lu Baolu >