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=-5.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 C0707C433DF for ; Wed, 22 Jul 2020 11:17:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 8D1D6206F5 for ; Wed, 22 Jul 2020 11:17:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="fOF1mCZ1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D1D6206F5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jyCke-0007d8-Pq; Wed, 22 Jul 2020 11:17:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jyCkc-0007d3-TF for xen-devel@lists.xenproject.org; Wed, 22 Jul 2020 11:17:30 +0000 X-Inumbo-ID: ee805b84-cc0c-11ea-8631-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ee805b84-cc0c-11ea-8631-bc764e2007e4; Wed, 22 Jul 2020 11:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OolPR9fxPy209fVnQYEahm8Kor0kPOiihLICyEuQJeQ=; b=fOF1mCZ10HvrVMbkQu/9B/r3RZ i91y2VX5I8Idrv1fRhVVsWjlICgLjLVsrO+hanvSnE9nDFRtRL6ySRp7Wp65a+srQjMxcIrLJyVbX Kwrkd9n6GPOB3SoVLZCrLeghwjZH7Lh1+cxbxtXahqdHkjjdxFStbmhHyOO1tOUBRE3s=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jyCka-0004ij-T9; Wed, 22 Jul 2020 11:17:28 +0000 Received: from 54-240-197-239.amazon.com ([54.240.197.239] helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jyCka-0000BF-Kr; Wed, 22 Jul 2020 11:17:28 +0000 Subject: Re: Virtio in Xen on Arm (based on IOREQ concept) To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <20200717150039.GV7191@Air-de-Roger> <8f4e0c0d-b3d4-9dd3-ce20-639539321968@gmail.com> <3dcab37d-0d60-f1cc-1d59-b5497f0fa95f@xen.org> <05acce61-5b29-76f7-5664-3438361caf82@xen.org> <20200722082115.GR7191@Air-de-Roger> <20200722111012.GX7191@Air-de-Roger> From: Julien Grall Message-ID: Date: Wed, 22 Jul 2020 12:17:26 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200722111012.GX7191@Air-de-Roger> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Oleksandr Andrushchenko , Bertrand Marquis , Oleksandr , xen-devel , Artem Mygaiev Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 22/07/2020 12:10, Roger Pau Monné wrote: > On Wed, Jul 22, 2020 at 11:47:18AM +0100, Julien Grall wrote: >>> >>> You can still use the map-on-fault behaviour as above, but I would >>> recommend that you try to limit the number of hypercalls issued. >>> Having to issue a single hypercall for each page fault it's going to >>> be slow, so I would instead use mmap batch to map the hole range in >>> unpopulated physical memory and then the OS fault handler just needs to >>> fill the page tables with the corresponding address. >> IIUC your proposal, you are assuming that you will have enough free space in >> the physical address space to map the foreign mapping. >> >> However that amount of free space is not unlimited and may be quite small >> (see above). It would be fairly easy to exhaust it given that a userspace >> application can map many times the same guest physical address. >> >> So I still think we need to be able to allow Linux to swap a foreign page >> with another page. > > Right, but you will have to be careful to make sure physical addresses > are not swapped while being used for IO with devices, as in that case > you won't get a recoverable fault. This is safe now because physical > mappings created by privcmd are never swapped out, but if you go the > route you propose you will have to figure a way to correctly populate > physical ranges used for IO with devices, even when the CPU hasn't > accessed them. > > Relying solely on CPU page faults to populate them will not be enough, > as the CPU won't necessarily access all the pages that would be send > to devices for IO. The problem you described here doesn't seem to be specific to foreign mapping. So I would really be surprised if Linux doesn't already have generic mechanism to deal with this. Hence why I suggested before to deal with foreign mapping the same way as Linux would do with user memory. Cheers, -- Julien Grall