Received: by 10.223.185.116 with SMTP id b49csp4353196wrg; Mon, 26 Feb 2018 16:16:17 -0800 (PST) X-Google-Smtp-Source: AH8x224Y1Vd5lAFlH/LJ6VXyii95fTBz7C4Pp2dlcgtyxYOXWlib6nfyuwsPoRb76lFZYKb9caIT X-Received: by 10.101.100.208 with SMTP id t16mr9466972pgv.398.1519690577188; Mon, 26 Feb 2018 16:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519690577; cv=none; d=google.com; s=arc-20160816; b=ML4iuFKYk8PYzs9C0l0GSlVfWwEwxahm3sA2/6MczEMLWAmk/nawXqyph+sH5iH9q3 QNDZiD+drCI0W5wkETO2leGhjOaddJRYThRmBNzw3xAKeAwkL/vxrh7Bk3E5XImWsMOk ik1xzmhr0onEGF6R3vKiZvZ4vimuzSatfujym6Gbj6s67S/d0A+00UVvRN8RndFMPW40 +dNl4r9ztW06OhgKPbPsFnd+KBcr/c2DB+6zZPqiHHZnknwMEo4lYLXpsXz0yELlVUd2 oVxL3ryuI6dBhdbIa38S5lH2G9pNDurs63Cb3TQl8AiyfHouihjXiATzgpsWAWu/1YIn 06SQ== 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:to:subject:dkim-signature :arc-authentication-results; bh=HhA01JvE69IM5/qRfkv/YykiXnmyqY8xElUSqq9ZpEY=; b=cJ9IZQ/XK04WVlHjpYwKvtDwk7JDohgwqClHzl+6MV08LVi4V5/pED+a+mdalon2mY oOCRFVdaqRWpVy6Bhh7Wz6Rn/UMr31HpAWNGRhGSb3LhsdgOwmh5dUli92L6CW2ctzPZ AdmjUbrtPYqjIFlRLvfZfoHrMuv14/e8dQIB96uA1SbyXBEXKdTZcmZAKM+SAUAXFem+ cya5huJkmBAWIC62G0AUKVPZqtK0Mjv1OAkNo1adcHb3liloLB4g1kVIMqBQ7mR6OML8 su8MZMtOcqz7i34uDrMbhOSkKcZFEWMg7V9kHrXym94DLUDiueyfwMYUEv7/dH/S/Wso 59DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=WXnngbYZ; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si6225193pgq.168.2018.02.26.16.15.59; Mon, 26 Feb 2018 16:16:17 -0800 (PST) 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=@oracle.com header.s=corp-2017-10-26 header.b=WXnngbYZ; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751411AbeBZXrA (ORCPT + 99 others); Mon, 26 Feb 2018 18:47:00 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:53160 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750941AbeBZXq7 (ORCPT ); Mon, 26 Feb 2018 18:46:59 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1QNgpGI011519; Mon, 26 Feb 2018 23:46:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=HhA01JvE69IM5/qRfkv/YykiXnmyqY8xElUSqq9ZpEY=; b=WXnngbYZXdN9AQIiDVLBa3UxWmn+Q4xOae3K9kDe47M55KFqXE+agPG2OnvstQpqDyBa Ur6gs8ATF3jShNP8bS2SxoY3k/ZsztHYEezaEIMZD8XCSl+zU8H50I505gOPt+QIO4+v O1uncx9RysQkna7Xc3As3nEJ68UJYAuWi/b56mPl53SbtVQ6P+XhT/q0zYfwYBt5bv+J 2FD/yANzktp6V7c4MJ1Maafr3Jb6SIZmuoUtclW8mptreuHnEn2+c06AzAmAOWGNywap f/CmYcUEYYbQ9gK1A/8NwbtE/Xa9BOoun9DB5XqV+GCD3xkHH78O4SbC0W3Us69mZiQW oA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2gcutp03pe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2018 23:46:47 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1QNkkGq004385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Feb 2018 23:46:46 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1QNkiwm019108; Mon, 26 Feb 2018 23:46:44 GMT Received: from dhcp-burlington7-2nd-B-east-10-152-55-162.usdhcp.oraclecorp.com (/10.152.32.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Feb 2018 15:46:44 -0800 Subject: Re: [PATCH 8/9] drm/xen-front: Implement GEM operations To: Oleksandr Andrushchenko , Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel.vetter@intel.com, seanpaul@chromium.org, gustavo@padovan.org, jgross@suse.com, konrad.wilk@oracle.com References: <1519200222-20623-1-git-send-email-andr2000@gmail.com> <1519200222-20623-9-git-send-email-andr2000@gmail.com> <2f2c6fea-c0cb-e244-41f3-269db07986fc@oracle.com> <56c4a78b-356a-fb35-a97e-187581ae45ad@epam.com> From: Boris Ostrovsky Message-ID: <71ab9d03-dc07-f7f2-c9f8-463cc926e573@oracle.com> Date: Mon, 26 Feb 2018 18:47:22 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <56c4a78b-356a-fb35-a97e-187581ae45ad@epam.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8816 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=881 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802260297 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/23/2018 10:35 AM, Oleksandr Andrushchenko wrote: > On 02/23/2018 05:26 PM, Boris Ostrovsky wrote: >> On 02/21/2018 03:03 AM, Oleksandr Andrushchenko wrote: >>> +static struct xen_gem_object *gem_create(struct drm_device *dev, >>> size_t size) >>> +{ >>> + struct xen_drm_front_drm_info *drm_info = dev->dev_private; >>> + struct xen_gem_object *xen_obj; >>> + int ret; >>> + >>> + size = round_up(size, PAGE_SIZE); >>> + xen_obj = gem_create_obj(dev, size); >>> + if (IS_ERR_OR_NULL(xen_obj)) >>> + return xen_obj; >>> + >>> + if (drm_info->cfg->be_alloc) { >>> + /* >>> + * backend will allocate space for this buffer, so >>> + * only allocate array of pointers to pages >>> + */ >>> + xen_obj->be_alloc = true; >> If be_alloc is a flag (which I am not sure about) --- should it be set >> to true *after* you've successfully allocated your things? > this is a configuration option telling about the way > the buffer gets allocated: either by the frontend or > backend (be_alloc -> buffer allocated by the backend) I can see how drm_info->cfg->be_alloc might be a configuration option but xen_obj->be_alloc is set here and that's not how configuration options typically behave. >> >>> + ret = gem_alloc_pages_array(xen_obj, size); >>> + if (ret < 0) { >>> + gem_free_pages_array(xen_obj); >>> + goto fail; >>> + } >>> + >>> + ret = alloc_xenballooned_pages(xen_obj->num_pages, >>> + xen_obj->pages); >> Why are you allocating balloon pages? > in this use-case we map pages provided by the backend > (yes, I know this can be a problem from both security > POV and that DomU can die holding pages of Dom0 forever: > but still it is a configuration option, so user decides > if her use-case needs this and takes responsibility for > such a decision). Perhaps I am missing something here but when you say "I know this can be a problem from both security POV ..." then there is something wrong with your solution. -boris > > Please see description of the buffering modes in xen_drm_front.h > specifically for backend allocated buffers: > ******************************************************************************* > > * 2. Buffers allocated by the backend > ******************************************************************************* > > * > * This mode of operation is run-time configured via guest domain > configuration > * through XenStore entries. > * > * For systems which do not provide IOMMU support, but having specific > * requirements for display buffers it is possible to allocate such > buffers > * at backend side and share those with the frontend. > * For example, if host domain is 1:1 mapped and has DRM/GPU hardware > expecting > * physically contiguous memory, this allows implementing zero-copying > * use-cases. > >> >> -boris >> >>> + if (ret < 0) { >>> + DRM_ERROR("Cannot allocate %zu ballooned pages: %d\n", >>> + xen_obj->num_pages, ret); >>> + goto fail; >>> + } >>> + >>> + return xen_obj; >>> + } >>> + /* >>> + * need to allocate backing pages now, so we can share those >>> + * with the backend >>> + */ >>> + xen_obj->num_pages = DIV_ROUND_UP(size, PAGE_SIZE); >>> + xen_obj->pages = drm_gem_get_pages(&xen_obj->base); >>> + if (IS_ERR_OR_NULL(xen_obj->pages)) { >>> + ret = PTR_ERR(xen_obj->pages); >>> + xen_obj->pages = NULL; >>> + goto fail; >>> + } >>> + >>> + return xen_obj; >>> + >>> +fail: >>> + DRM_ERROR("Failed to allocate buffer with size %zu\n", size); >>> + return ERR_PTR(ret); >>> +} >>> + >>> >