Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp943953pxy; Thu, 22 Apr 2021 18:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwosJE5gk6wt6tyGn9oGFKPUZn8zqGA5SZ8Q8sks8o9W1+ImvF4TyATPG0dApzJHoVHdL/X X-Received: by 2002:a17:906:28c9:: with SMTP id p9mr1522283ejd.111.1619140072272; Thu, 22 Apr 2021 18:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619140072; cv=none; d=google.com; s=arc-20160816; b=CSHkOHa2eN9gqUY+3Vik3tjCUII+AkGiI6dQjCsFCEm1P5W2SMHZbNsuI1nvf0KCKk Z+Uwoaf5dKVuBWE5dTs5zdb9zVs9y99wGds3tlbvghYLTa0/0SrHnYkvEoMUQZOVIow4 jwxcZ0qkFJhsgid0zhHRdj6E16HRicxxjwDsXQSUZgeXWO/KKPw1iht106giv4nB9iv8 g7PDL1iPS2EXGu1LH0UotBNPDOdS5JXYogQn9XaJLdlC8RnaUOIaqNa81Nsr4KkaIcgk asGt7YV+Qkjctc4r3ltbhbZ0DcznhjgMGdj1YJMQR0EjLlyn5z9SAl3bBuFV6iVIKiqV DdYw== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=aDYb+cf8VTEdEQvc0/iIpvcaC5Nj+sq4sk4X4wFgmbc=; b=GDy6Yh3SlIJiJdc+NHYqa3EWLH+BLcx/LJgkTMm8QX9mQyljpXecy4odlT/ViHvTj0 R7kkdNzbjfrvs+1S3pzkFlhLAFqifMl3+pxQ8TfB++zsOduk0S7RlT+g+GJ1059at2+L 1hNVL0mdEr4Q67I0sAXcPG/pYdkg3CDl8pwPqidD2+IrrjxIR91HcUrJ9LQ5i368TcTk /0JwrtO28hMpO9qGJcd/cLqLAAzDAHRM6EhVc4DTVoLFXAvALGOBszpYbNoWkdGMTsii pnHpyRClgX92f1f2kPiJeegFgSb1sl2TXHc3uNoJb4JvnN/racNu8O3rpgjELqQxc3MW zX3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si4089710edj.233.2021.04.22.18.07.29; Thu, 22 Apr 2021 18:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236068AbhDWBHJ (ORCPT + 99 others); Thu, 22 Apr 2021 21:07:09 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:17392 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbhDWBHJ (ORCPT ); Thu, 22 Apr 2021 21:07:09 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FRGKF14mpzlZ7r; Fri, 23 Apr 2021 09:04:33 +0800 (CST) Received: from [10.174.187.224] (10.174.187.224) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Fri, 23 Apr 2021 09:06:21 +0800 Subject: Re: [PATCH] KVM: arm64: Correctly handle the mmio faulting To: Santosh Shukla , "Tarun Gupta (SW-GPU)" References: <1603297010-18787-1-git-send-email-sashukla@nvidia.com> <8b20dfc0-3b5e-c658-c47d-ebc50d20568d@huawei.com> <2e23aaa7-0c8d-13ba-2eae-9e6ab2adc587@redhat.com> <871rb3rgpl.wl-maz@kernel.org> <87v98eq0dh.wl-maz@kernel.org> CC: Marc Zyngier , Gavin Shan , , , , , , "Wanghaibin (D)" From: Keqian Zhu Message-ID: Date: Fri, 23 Apr 2021 09:06:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/22 16:00, Santosh Shukla wrote: > On Thu, Apr 22, 2021 at 1:07 PM Tarun Gupta (SW-GPU) > wrote: >> >> >> >> On 4/22/2021 12:20 PM, Marc Zyngier wrote: >>> External email: Use caution opening links or attachments >>> >>> >>> On Thu, 22 Apr 2021 03:02:00 +0100, >>> Gavin Shan wrote: >>>> >>>> Hi Marc, >>>> >>>> On 4/21/21 9:59 PM, Marc Zyngier wrote: >>>>> On Wed, 21 Apr 2021 07:17:44 +0100, >>>>> Keqian Zhu wrote: >>>>>> On 2021/4/21 14:20, Gavin Shan wrote: >>>>>>> On 4/21/21 12:59 PM, Keqian Zhu wrote: >>>>>>>> On 2020/10/22 0:16, Santosh Shukla wrote: >>>>>>>>> The Commit:6d674e28 introduces a notion to detect and handle the >>>>>>>>> device mapping. The commit checks for the VM_PFNMAP flag is set >>>>>>>>> in vma->flags and if set then marks force_pte to true such that >>>>>>>>> if force_pte is true then ignore the THP function check >>>>>>>>> (/transparent_hugepage_adjust()). >>>>>>>>> >>>>>>>>> There could be an issue with the VM_PFNMAP flag setting and checking. >>>>>>>>> For example consider a case where the mdev vendor driver register's >>>>>>>>> the vma_fault handler named vma_mmio_fault(), which maps the >>>>>>>>> host MMIO region in-turn calls remap_pfn_range() and maps >>>>>>>>> the MMIO's vma space. Where, remap_pfn_range implicitly sets >>>>>>>>> the VM_PFNMAP flag into vma->flags. >>>>>>>> Could you give the name of the mdev vendor driver that triggers this issue? >>>>>>>> I failed to find one according to your description. Thanks. >>>>>>>> >>>>>>> >>>>>>> I think it would be fixed in driver side to set VM_PFNMAP in >>>>>>> its mmap() callback (call_mmap()), like vfio PCI driver does. >>>>>>> It means it won't be delayed until page fault is issued and >>>>>>> remap_pfn_range() is called. It's determined from the beginning >>>>>>> that the vma associated the mdev vendor driver is serving as >>>>>>> PFN remapping purpose. So the vma should be populated completely, >>>>>>> including the VM_PFNMAP flag before it becomes visible to user >>>>>>> space. >>>>> >>>>> Why should that be a requirement? Lazy populating of the VMA should be >>>>> perfectly acceptable if the fault can only happen on the CPU side. >>>>> > > Right. > Hi keqian, > You can refer to case > http://lkml.iu.edu/hypermail/linux/kernel/2010.3/00952.html Hi Santosh, Yeah, thanks for that. BRs, Keqian