Received: by 10.192.165.156 with SMTP id m28csp933869imm; Wed, 18 Apr 2018 00:36:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/dEsauXN1LH6u+1LQ1gVdTflBfpn/KJ7PoSme9CZI0BRoTRDjdfmJBJcpSQ5HocMMRcfhO X-Received: by 2002:a17:902:b105:: with SMTP id q5-v6mr1077933plr.173.1524036999264; Wed, 18 Apr 2018 00:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524036999; cv=none; d=google.com; s=arc-20160816; b=SzeCjA00c7Z/PKXTQab7JjJKVxNmUeNhaHdeYZBXMoxlFh0MjIWaswehTLu/fmFOdZ gGBxex+aTX6lS+JYld445qgiS/OxHSccvYOXbb2urDZrMpx6OsugnNM6XeXJE+3kPxxs CJiSo6HGPKAkpiN+0ScqP8ihdIMIl/ujcbJEGrwhDX5HOK7EKP74zAnFW5WUIFtUrd4j BrnyCLCmzw8sR70pOQuKlfCzW+UDgWKHFFzzbVIFBdNu65GC0fVIoCjZfYJS6eTVC2zo j/5BtOw+kII8jyWKXDfvJki/MlD6YYgPGC4Eed8sIEQa+xuVvCLxcy4iwx4zrIoaxb2H y4qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=0I5/q8T/583+g5j3G3qPgvbCM/Lxx+08c39s+2+cnig=; b=YWUgVnIibWp/D29t0/wrS+iRrQFd5zkvVBxOvOx5feZSsEKnwCgNqqkKxKRCA/imGj QFXjbm3i8xdzGZtBA6SukAsLxIe8fRh2i3fFJzYs2cqp8civdtsd7/PQhmxfdmnvaVOn rY/ZzhJB8Kd1hEzJX7oTycEXWSMfSCMjMIY5s6ok9HlxUA56b2QuZls+348uybiA8bqh TiEEo3FynbMGrgkB3+/nfII4cbP1s0jOdxvsifo2zVLbCPXtuY7QZRC/uaci9x2yT3df PlLvbpAZIF1U97zx1buaBnKarG8nLmbgDPl9xcSj6Y/yoTl42VScsuz81zXZ9LoyGYu2 xg7w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i14si622574pgf.284.2018.04.18.00.36.25; Wed, 18 Apr 2018 00:36:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753114AbeDRHfR (ORCPT + 99 others); Wed, 18 Apr 2018 03:35:17 -0400 Received: from smtp.eu.citrix.com ([185.25.65.24]:20921 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752760AbeDRHfQ (ORCPT ); Wed, 18 Apr 2018 03:35:16 -0400 X-IronPort-AV: E=Sophos;i="5.48,464,1517875200"; d="scan'208";a="71728365" Date: Wed, 18 Apr 2018 08:35:08 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Oleksandr Andrushchenko CC: Dongwon Kim , "Oleksandr_Andrushchenko@epam.com" , , Artem Mygaiev , , , , , "Potrola, MateuszX" , , , , Matt Roper Subject: Re: [Xen-devel] [PATCH 0/1] drm/xen-zcopy: Add Xen zero-copy helper DRM driver Message-ID: <20180418073508.ptvntwedczpvl7bx@MacBook-Pro-de-Roger.local> References: <20180329131931.29957-1-andr2000@gmail.com> <5d8fec7f-956c-378f-be90-f45029385740@gmail.com> <20180416192905.GA18096@downor-Z87X-UD5H> <20180417075928.GT31310@phenom.ffwll.local> <20180417205744.GA15930@downor-Z87X-UD5H> <41487acb-a67a-8933-d0c3-702c19b0938e@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <41487acb-a67a-8933-d0c3-702c19b0938e@gmail.com> User-Agent: NeoMutt/20180323 X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 09:38:39AM +0300, Oleksandr Andrushchenko wrote: > On 04/17/2018 11:57 PM, Dongwon Kim wrote: > > On Tue, Apr 17, 2018 at 09:59:28AM +0200, Daniel Vetter wrote: > > > On Mon, Apr 16, 2018 at 12:29:05PM -0700, Dongwon Kim wrote: > 3.2 Backend exports dma-buf to xen-front > > In this case Dom0 pages are shared with DomU. As before, DomU can only write > to these pages, not any other page from Dom0, so it can be still considered > safe. > But, the following must be considered (highlighted in xen-front's Kernel > documentation): > ?- If guest domain dies then pages/grants received from the backend cannot > ?? be claimed back - think of it as memory lost to Dom0 (won't be used for > any > ?? other guest) > ?- Misbehaving guest may send too many requests to the backend exhausting > ?? its grant references and memory (consider this from security POV). As the > ?? backend runs in the trusted domain we also assume that it is trusted as > well, > ?? e.g. must take measures to prevent DDoS attacks. I cannot parse the above sentence: "As the backend runs in the trusted domain we also assume that it is trusted as well, e.g. must take measures to prevent DDoS attacks." What's the relation between being trusted and protecting from DoS attacks? In any case, all? PV protocols are implemented with the frontend sharing pages to the backend, and I think there's a reason why this model is used, and it should continue to be used. Having to add logic in the backend to prevent such attacks means that: - We need more code in the backend, which increases complexity and chances of bugs. - Such code/logic could be wrong, thus allowing DoS. > 4. xen-front/backend/xen-zcopy synchronization > > 4.1. As I already said in 2) all the inter VM communication happens between > xen-front and the backend, xen-zcopy is NOT involved in that. > When xen-front wants to destroy a display buffer (dumb/dma-buf) it issues a > XENDISPL_OP_DBUF_DESTROY command (opposite to XENDISPL_OP_DBUF_CREATE). > This call is synchronous, so xen-front expects that backend does free the > buffer pages on return. > > 4.2. Backend, on XENDISPL_OP_DBUF_DESTROY: > ? - closes all dumb handles/fd's of the buffer according to [3] > ? - issues DRM_IOCTL_XEN_ZCOPY_DUMB_WAIT_FREE IOCTL to xen-zcopy to make > sure > ??? the buffer is freed (think of it as it waits for dma-buf->release > callback) So this zcopy thing keeps some kind of track of the memory usage? Why can't the user-space backend keep track of the buffer usage? > ? - replies to xen-front that the buffer can be destroyed. > This way deletion of the buffer happens synchronously on both Dom0 and DomU > sides. In case if DRM_IOCTL_XEN_ZCOPY_DUMB_WAIT_FREE returns with time-out > error > (BTW, wait time is a parameter of this IOCTL), Xen will defer grant > reference > removal and will retry later until those are free. > > Hope this helps understand how buffers are synchronously deleted in case > of xen-zcopy with a single protocol command. > > I think the above logic can also be re-used by the hyper-dmabuf driver with > some additional work: > > 1. xen-zcopy can be split into 2 parts and extend: > 1.1. Xen gntdev driver [4], [5] to allow creating dma-buf from grefs and > vise versa, I don't know much about the dma-buf implementation in Linux, but gntdev is a user-space device, and AFAICT user-space applications don't have any notion of dma buffers. How are such buffers useful for user-space? Why can't this just be called memory? Also, (with my FreeBSD maintainer hat) how is this going to translate to other OSes? So far the operations performed by the gntdev device are mostly OS-agnostic because this just map/unmap memory, and in fact they are implemented by Linux and FreeBSD. > implement "wait" ioctl (wait for dma-buf->release): currently these are > DRM_XEN_ZCOPY_DUMB_FROM_REFS, DRM_XEN_ZCOPY_DUMB_TO_REFS and > DRM_XEN_ZCOPY_DUMB_WAIT_FREE > 1.2. Xen balloon driver [6] to allow allocating contiguous buffers (not > needed > by current hyper-dmabuf, but is a must for xen-zcopy use-cases) I think this needs clarifying. In which memory space do you need those regions to be contiguous? Do they need to be contiguous in host physical memory, or guest physical memory? If it's in guest memory space, isn't there any generic interface that you can use? If it's in host physical memory space, why do you need this buffer to be contiguous in host physical memory space? The IOMMU should hide all this. Thanks, Roger.