From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E14C433B4 for ; Wed, 21 Apr 2021 12:02:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C4B661417 for ; Wed, 21 Apr 2021 12:02:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C4B661417 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:Cc:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Pi2w0ItrpaxEtYojeL/IN9TlEVKaXAKMdLd6bDBMipE=; b=emFiGKPdND66nabmvgEhGB2sD pf+pY6qWLBPWg+i361eJIu/pzcfuUf6hYFJzIkKiFLIbBXyR6eOCzlKrCETJEGf54cH2lYuUz8jIt 8czF3YKaWitxCsDfBnNYyLAk+tzQhyH/8GVXOwb3pCbnZNJpWPsif4oSuR+wxAFc7iLD1n5ZFqAGD QR8RrLilIcOKNd6XXqK8Smx/as0VPKZ8F81MQcSLb/ftWNJ9Uya1lLWg4d1axCYSopZJVanDsRsMu FqOO80Dftmi90XKNtw4xa/HPPJl6m2di8LwE8LRbcEdZIahcfaSCHwVomJrgP4uGINlj9q0GYT9qg 8A5PYIDeQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZBWB-00ELRW-6D; Wed, 21 Apr 2021 11:59:43 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZBW9-00ELRF-3G for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 11:59:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NfS/aCLV8wKMIuMHN2x9W2E39xFjTIoE93P5WExBMD8=; b=h+at2ljNpgFfPWegpLH5xhCupx GrXWrE06WIMhlIbMHD9sKhAkuT6OfpctuFmIhc2m3DhSvDsL1TkQaHDOQt8UetH6B1oCDpnAQjHAr 36Y+9n2WnFS0M9WAXnRYEL9Adc3ixDWJVu1yZ0vd27nX+icVhcxTmHui7pI9hHTN1uMOaqrvOyF1P 9V6WWGofkOsDHTqkbJnscMnqa051iqRSyIy8im6rbKrTA4SuoYD8rEedL13bMiaxW1TDG6OxxQt5M LiwHtGLigM5aGgJuwpkXqtvBmZpcv0UFRdrF5gABzL055z7HhmtP9b9I/nGD2fbmA83nzwDHvtWTm jyYsJ5vw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZBW6-00CqqD-FV for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 11:59:39 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C8D561448; Wed, 21 Apr 2021 11:59:37 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lZBW2-008fnk-UT; Wed, 21 Apr 2021 12:59:35 +0100 Date: Wed, 21 Apr 2021 12:59:34 +0100 Message-ID: <871rb3rgpl.wl-maz@kernel.org> From: Marc Zyngier To: Keqian Zhu Cc: Gavin Shan , , , , , , "Wanghaibin (D)" Subject: Re: [PATCH] KVM: arm64: Correctly handle the mmio faulting In-Reply-To: References: <1603297010-18787-1-git-send-email-sashukla@nvidia.com> <8b20dfc0-3b5e-c658-c47d-ebc50d20568d@huawei.com> <2e23aaa7-0c8d-13ba-2eae-9e6ab2adc587@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: zhukeqian1@huawei.com, gshan@redhat.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, cjia@nvidia.com, linux-arm-kernel@lists.infradead.org, wanghaibin.wang@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_045938_607902_9E49D488 X-CRM114-Status: GOOD ( 32.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 21 Apr 2021 07:17:44 +0100, Keqian Zhu wrote: > > Hi Gavin, > > On 2021/4/21 14:20, Gavin Shan wrote: > > Hi Keqian and Santosh, > > > > 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. > > > > The example can be found from vfio driver in drivers/vfio/pci/vfio_pci.c: > > vfio_pci_mmap: VM_PFNMAP is set for the vma > > vfio_pci_mmap_fault: remap_pfn_range() is called > Right. I have discussed the above with Marc. I want to find the driver > to fix it. However, AFAICS, there is no driver matches the description... I have the feeling this is an out-of-tree driver (and Santosh email address is bouncing, so I guess we won't have much information from him). However, the simple fact that any odd driver can provide a fault handler and populate it the VMA on demand makes me think that we need to support this case. M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel