Received: by 10.213.65.68 with SMTP id h4csp421703imn; Fri, 6 Apr 2018 02:36:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4//GabO7xNp5YMndppDy+81ia4aQKQisPamVK5Tvov+mc3FV40AwY5aD1kJ18sN1x4XRBg8 X-Received: by 10.101.85.200 with SMTP id k8mr13212416pgs.290.1523007396506; Fri, 06 Apr 2018 02:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523007396; cv=none; d=google.com; s=arc-20160816; b=fn94IeBoX12Z3BTtnmrvjrNJ0/2auGeg+PtjQkdEovJj/DBxZuZkEl/RNmzcirC/wf OlMoleWT1N3lxPZP113F3uwpm9XULzjd3VVcVcS5QibLK5jcVnImeV8lK1u5CJ7mqO9k gxSMWl+T8Uoz4U8aD25wDFmAYT2UZ2fmolZ8N/smhVn8ArIb0+GKp7OPvQ5PJ6zciu8T oxRfudgjTsWAvOFHG91VEPeFTrPNxxshLvXxOjNDqwxRJsLZ3tuGwvGdBWIXlPeVuZWC 79sJIYMCEnJUqLbyT2l/iN3P8BhjPTisHJ/WUMMNacQA5lPFtXQvZ+z2cx1jJft4aQ1x yMkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=49hU4OQ5Izmd71XHhuhqvNarVWa+ib7J6DGsP/eZb/w=; b=I5ef7jJ7NrOtpUGPXRYrd89/732gPvF0cT90ZKbSqzjcUIwqI6CJi/EpW8pWuC57ik spcs8UZ8Ozfj3Whseakd1imwFbofyqsdVo+7JyzSpTJb8lvcDdVa+ORPgkYNuz9gB1/e s/I5dIVraJwKdTIAvFQa0lUpXFkJzELYfhc8uZalvOh/APpYvyw7mOA6L6/5PnUrrK3V G0aj4STlWdDJpWCU++uSSyFD2hrlJ7vqJmw8/tCKPDB8sI7E2tED8D/3lRvb4Mdif9rp 46bxB5Hi3T2PnpSNMCFVcSif24EKFiGKGbdcHHmc2DLl2zhu8KnmEXQmouvQqs/kNTXd T2Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZSRa0Fi1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e34-v6si10068959plb.281.2018.04.06.02.36.22; Fri, 06 Apr 2018 02:36:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZSRa0Fi1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751971AbeDFJev (ORCPT + 99 others); Fri, 6 Apr 2018 05:34:51 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:37756 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751874AbeDFJet (ORCPT ); Fri, 6 Apr 2018 05:34:49 -0400 Received: by mail-wm0-f68.google.com with SMTP id r131so1987505wmb.2; Fri, 06 Apr 2018 02:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=49hU4OQ5Izmd71XHhuhqvNarVWa+ib7J6DGsP/eZb/w=; b=ZSRa0Fi1JDlk9IZlBImT1f3OnfifPh9md0ZKjPUZopKT42dvs2UlqgElOinNuqGwhB RGCzX/We4H0/QX3VUJh5Kmxkum26Our+mN2EV+ippYUOgPgS+p9ziVqgp9WBoWRAIEEe Vgq5ZR9KM2cPXjRI/QpnsDa3LS9k4VftlduaToro2qcUY0Pv3uz5/leC2jlODPuZEVtn 3jyl2HMdCdyRaz/aIBV0cMto2adwCm4CgN5WsoGAAwwAoPcuY1Z7RQX5phxHQ1Nix9xh jZFRZ9C5+QWbvovGtlE5dsd9qUz5tbzO0EBoBJFkpGUAguYLAmz4ljRNes01LVfvr8Nw Z++Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=49hU4OQ5Izmd71XHhuhqvNarVWa+ib7J6DGsP/eZb/w=; b=ka6du452z8Q3u/Wfh6OjteCTrSNtSB2+TUWECTuR5A+rS5kKKWQCD3CtrH3EMfK3lJ r+/1KuUXoN1Yw97BhxezeaG/m37qRafZdeu61Fk7Yefku1xHITSExw5MNdaf6iGKlUMM hVLQSL36eoa2HnR9Q9B5Jh1phohuENL+7Z0j1kKeUD5SdfwEXJ+BBfTFW7aBN/4ybMeB eyqqrHgfMiy5o+66L845osG5WvZXnEIAVWWj7AWBnNS7SZWc6FnaGIqZlqfGuxAHO1Jf asFnMZ8XwKcBGEHDEVtEkYEI9R0v9cq6bdKzrL/RVkIe2vPFJcHQF2AvB/dhYomzf9Tu cULg== X-Gm-Message-State: AElRT7ElPEQW6hbNtkHUgUsxJxqBYcleB0x7GfsH0+Ol6+1bUPHFRd3g I91vG+aZ9/wz9g2142BVJUiU/v4lVUg= X-Received: by 10.46.2.134 with SMTP id y6mr15845525lje.118.1523007287254; Fri, 06 Apr 2018 02:34:47 -0700 (PDT) Received: from [10.17.182.9] (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id h68-v6sm1990988lfk.67.2018.04.06.02.34.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 02:34:46 -0700 (PDT) Subject: Re: [RfC PATCH] Add udmabuf misc device To: Gerd Hoffmann , Oleksandr Andrushchenko Cc: Dongwon Kim , Tomeu Vizoso , David Airlie , open list , dri-devel , qemu-devel@nongnu.org, "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:DMA BUFFER SHARING FRAMEWORK" References: <20180313154826.20436-1-kraxel@redhat.com> <20180313161035.GL4788@phenom.ffwll.local> <20180314080301.366zycak3whqvvqx@sirius.home.kraxel.org> <20180406001117.GD31612@mdroper-desk.amr.corp.intel.com> <2411d2c1-33c0-2ba5-67ea-3bb9af5d5ec9@epam.com> <20180406090747.gwiegu22z4noj23i@sirius.home.kraxel.org> From: Oleksandr Andrushchenko Message-ID: <0351cf53-3e27-d0b4-a77b-8392c2b0a951@gmail.com> Date: Fri, 6 Apr 2018 12:34:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180406090747.gwiegu22z4noj23i@sirius.home.kraxel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/2018 12:07 PM, Gerd Hoffmann wrote: > Hi, > >>> * The general interface should be able to express sharing from any >>> guest:guest, not just guest:host. Arbitrary G:G sharing might be >>> something some hypervisors simply aren't able to support, but the >>> userspace API itself shouldn't make assumptions or restrict that. I >>> think ideally the sharing API would include some kind of >>> query_targets interface that would return a list of VM's that your >>> current OS is allowed to share with; that list would be depend on the >>> policy established by the system integrator, but obviously wouldn't >>> include targets that the hypervisor itself wouldn't be capable of >>> handling. >> Can you give a use-case for this? I mean that the system integrator >> is the one who defines which guests/hosts talk to each other, >> but querying means that it is possible that VMs have some sort >> of discovery mechanism, so they can decide on their own whom >> to connect to. > Note that vsock (created by vmware, these days also has a virtio > transport for kvm) started with support for both guest <=> host and > guest <=> guest support. But later on guest <=> guest was dropped. > As far I know the reasons where (a) lack of use cases and (b) security. > > So, I likewise would know more details on the use cases you have in mind > here. Unless we have a compelling use case here I'd suggest to drop the > guest <=> guest requirement as it makes the whole thing alot more > complex. This is exactly the use-case we have: in our setup Dom0 doesn't own any HW at all and all the HW is passed into a dedicated driver domain (DomD) which is still a guest domain. Then, buffers are shared between two guests, for example, DomD and DomA (Android guest) >>> * The sharing API could be used to share multiple kinds of content in a >>> single system. The sharing sink driver running in the content >>> producer's VM should accept some additional metadata that will be >>> passed over to the target VM as well. > Not sure this should be part of hyper-dmabuf. A dma-buf is nothing but > a block of data, period. Therefore protocols with dma-buf support > (wayland for example) typically already send over metadata describing > the content, so duplicating that in hyper-dmabuf looks pointless. > >> 1. We are targeting ARM and one of the major requirements for the buffer >> sharing is the ability to allocate physically contiguous buffers, which gets >> even more complicated for systems not backed with an IOMMU. So, for some >> use-cases it is enough to make the buffers contiguous in terms of IPA and >> sometimes those need to be contiguous in terms of PA. > Which pretty much implies the host must to the allocation. > >> 2. For Xen we would love to see UAPI to create a dma-buf from grant >> references provided, so we can use this generic solution to implement >> zero-copying without breaking the existing Xen protocols. This can >> probably be extended to other hypervizors as well. > I'm not sure we can create something which works on both kvm and xen. > The memory management model is quite different ... > > > On xen the hypervisor manages all memory. Guests can allow other guests > to access specific pages (using grant tables). In theory any guest <=> > guest communication is possible. In practice is mostly guest <=> dom0 > because guests access their virtual hardware that way. dom0 is the > priviledged guest which owns any hardware not managed by xen itself. Please see above for our setup with DomD and Dom0 being a generic ARMv8 domain, no HW > Xen guests can ask the hypervisor to update the mapping of guest > physical pages. They can ballon down (unmap and free pages). They can > ballon up (ask the hypervisor to map fresh pages). They can map pages > exported by other guests using grant tables. xen-zcopy makes heavy use > of this. It balloons down, to make room in the guest physical address > space, then goes map the exported pages there, finally composes a > dma-buf. This is what it does > > On kvm qemu manages all guest memory. qemu also has all guest memory > mapped, so a grant-table like mechanism isn't needed to implement > virtual devices. qemu can decide how it backs memory for the guest. > qemu propagates the guest memory map to the kvm driver in the linux > kernel. kvm guests have some control over the guest memory map, for > example they can map pci bars wherever they want in their guest physical > address space by programming the base registers accordingly, but unlike > xen guests they can't ask the host to remap individual pages. > > Due to qemu having all guest memory mapped virtual devices are typically > designed to have the guest allocate resources, then notify the host > where they are located. This is where the udmabuf idea comes from: > Guest tells the host (qemu) where the gem object is, and qemu then can > create a dmabuf backed by those pages to pass it on to other processes > such as the wayland display server. Possibly even without the guest > explicitly asking for it, i.e. export the framebuffer placed by the > guest in the (virtual) vga pci memory bar as dma-buf. And I can imagine > that this is useful outsize virtualization too. > > > I fail to see any common ground for xen-zcopy and udmabuf ... > > Beside that there is the problem that the udmabuf idea has its own share > of issues, for example the fork() issue pointed out by Christian > König[1]. So I still need to find something which can work for kvm ... > > cheers, > Gerd > > [1] https://www.spinics.net/lists/dri-devel/msg169442.html > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel