Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1003749ybe; Thu, 19 Sep 2019 07:15:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRer0pLyu2lXuGjppNe7JBxWHKpxcuk3Xn97EL8wNaMD8r0JfvH9aLLvqNAGlgyQTKuoL2 X-Received: by 2002:a17:906:4d58:: with SMTP id b24mr13416187ejv.263.1568902510523; Thu, 19 Sep 2019 07:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568902510; cv=none; d=google.com; s=arc-20160816; b=XnnjP5QUWM0bkzvP81xqb3CBShbcl7BADJD87w/kudniWjupkG3aIDRYL7R7arojdG 54qItvKcIRdmCkytcRETGgBZ9kfGQgJRe1X7perjhcoxPV54lXcX5rl43tyJAnvo5MwM A8/DpL2oloKB5FyTPGj/QtRqtpBrtDrOG6hAZG+8bMQiSqCiEliqPdoJWO1qvhloaYid iUwfbxCSQ0lTJgvAm0o+B+YTOPEr4NcjmTWknXY5alfkXY6aiRR3SLURWX+qmTLhlfLh OZjO3hBWDYkwP8CvsFx8gHoVIktpA4drjEWzrYinHki8kHimg/0uNHMvAOH8mQjTNQfh kBrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=bUHZ6skhWOFY3rNEMxex/mPZG8s6EHtinrCSJMSwzhw=; b=aP82fI+p2TRuuXkrliPV38tnGa6tGMgjJLfxLuLkr1jFXMTkAdL8lRc9u+W2y2JkJk iU+fWeOI/wOoK0SepF06dzTsR8RUY8n3Qum16v05AH8k964vY0e4cQZlqqz3ptuR6NhT GzNs3ae30f3aBZ5U027TxFJZ8bwPRfhCNbeX/DbqoA0A5it3ySjRRZZTjnZl17wJokWW 1ZY4AGUb3hDa8n3uwvBsyXl3GKHOo7ng+pFbVkb45CUdKZpzNacRXz/VOGrk+zNrq6Lq RmMAwdmDbLL6b2DNa1yKJQzhaUZd/PfMUqM1gn84LjX5DUAG5nCWwRW6CkhvHPreDfZo tiRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=a7DO3X1D; 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 oz25si4580721ejb.175.2019.09.19.07.14.46; Thu, 19 Sep 2019 07:15:10 -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=@ffwll.ch header.s=google header.b=a7DO3X1D; 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 S1732426AbfISOKz (ORCPT + 99 others); Thu, 19 Sep 2019 10:10:55 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:46558 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732274AbfISOKz (ORCPT ); Thu, 19 Sep 2019 10:10:55 -0400 Received: by mail-ot1-f66.google.com with SMTP id f21so3140325otl.13 for ; Thu, 19 Sep 2019 07:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bUHZ6skhWOFY3rNEMxex/mPZG8s6EHtinrCSJMSwzhw=; b=a7DO3X1D3qGDmJBSvrzYhEdmHsXfeQz8ERSO+dg2ScKV+hMCa8ts734NtNIc1iew3c MyG7xi4rdQbutdgYNLeNg2jl6MAIOytvNZMZmB/NgRmLgG4TbGcZqDZetjvo+elj6RHO YzUhvJgtqp2cDU/vl2xsWf3J4lV/+zBEEj8qQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bUHZ6skhWOFY3rNEMxex/mPZG8s6EHtinrCSJMSwzhw=; b=tGvon9cLaKGMdwCcf/36AZJy9joMaS89+ZFWYH+kt37Fyq7AedSCRxi7V/uh+wMrYA Of1blrck/MYReyrc4OeD9tesg3+QSgvxtsra19KqIWnVpXFPyRxKrcRH2r5yOprzy6FK OwCOQjrNmpoDarvbRVnbEogz6SHCh6jk1mbKFRSyaUgeOvPERo6LXK1cedvBSQ4BLKod 2ifs8LyuRGbqITwB2V5JCtU/soZbjEG8xx7K3BVE/we3CvwuU/4o4r56aU+lRIYyKAyV ogQ7UKZ+8ufoK01HIB9DH1/Rr2+wDH3M3Q2gqhTtnNR6ZdBnkcVCVifwzH/bFKyUAEqm PdlA== X-Gm-Message-State: APjAAAXVUf9eAwXg+bunUcjEJV90A7nllRAPm2959xvLySdnfmXVVtV1 SZa5JcitdzWEu0LhuhKbvDSaUKnjgh1Z2daIaGdexg== X-Received: by 2002:a9d:7ace:: with SMTP id m14mr4051422otn.106.1568902254044; Thu, 19 Sep 2019 07:10:54 -0700 (PDT) MIME-Version: 1.0 References: <20190909134241.23297-1-ayan.halder@arm.com> <20190917125301.GQ3958@phenom.ffwll.local> <20190918120406.2ylkxx2rqsbhn2te@e110455-lin.cambridge.arm.com> <20190919140323.GA3456@arm.com> In-Reply-To: <20190919140323.GA3456@arm.com> From: Daniel Vetter Date: Thu, 19 Sep 2019 16:10:42 +0200 Message-ID: Subject: Re: [RFC PATCH] drm:- Add a modifier to denote 'protected' framebuffer To: Ayan Halder Cc: Daniel Stone , Liviu Dudau , "maxime.ripard@bootlin.com" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "airlied@linux.ie" , nd , "sean@poorly.run" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 19, 2019 at 4:03 PM Ayan Halder wrote: > > On Wed, Sep 18, 2019 at 10:30:12PM +0100, Daniel Stone wrote: > > Hi All, > Thanks for your suggestions. > > > Hi Liviu, > > > > On Wed, 18 Sep 2019 at 13:04, Liviu Dudau wrote: > > > On Wed, Sep 18, 2019 at 09:49:40AM +0100, Daniel Stone wrote: > > > > I totally agree. Framebuffers aren't about the underlying memory they > > > > point to, but about how to _interpret_ that memory: it decorates a > > > > pointer with width, height, stride, format, etc, to allow you to make > > > > sense of that memory. I see content protection as being the same as > > > > physical contiguity, which is a property of the underlying memory > > > > itself. Regardless of the width, height, or format, you just cannot > > > > access that memory unless it's under the appropriate ('secure enough') > > > > conditions. > > > > > > > > So I think a dmabuf attribute would be most appropriate, since that's > > > > where you have to do all your MMU handling, and everything else you > > > > need to do to allow access to that buffer, anyway. > > > > > > Isn't it how AMD currently implements protected buffers as well? > > > > No idea to be honest, I haven't seen anything upstream. > > > > > > There's a lot of complexity beyond just 'it's protected'; for > > > > instance, some CP providers mandate that their content can only be > > > > streamed over HDCP 2.2 Type-1 when going through an external > > > > connection. One way you could do that is to use a secure world > > > > (external controller like Intel's ME, or CPU-internal enclave like SGX > > > > or TEE) to examine the display pipe configuration, and only then allow > > > > access to the buffers and/or keys. Stuff like that is always going to > > > > be out in the realm of vendor & product-policy-specific add-ons, but > > > > it should be possible to agree on at least the basic mechanics and > > > > expectations of a secure path without things like that. > > > > > > I also expect that going through the secure world will be pretty much transparent for > > > the kernel driver, as the most likely hardware implementations would enable > > > additional signaling that will get trapped and handled by the secure OS. I'm not > > > trying to simplify things, just taking the stance that it is userspace that is > > > coordinating all this, we're trying only to find a common ground on how to handle > > > this in the kernel. > > > > Yeah, makes sense. > > > > As a strawman, how about a new flag to drmPrimeHandleToFD() which sets > > the 'protected' flag on the resulting dmabuf? > > To be honest, during our internal discussion james.qian.wang@arm.com had a > similar suggestion of adding a new flag to dma_buf but I decided > against it. > > As per my understanding, adding custom dma buf flags (like > AMDGPU_GEM_CREATE_XXX, etc) is possible if we(Arm) had our own allocator. We > rely on the dumb allocator and ion allocator for framebuffer creation. > > I was looking at an allocator independent way of userspace > communicating to the drm framework that the framebuffer is protected. > > Thus, it looked to me that framebuffer modifier is the best (or the least > corrupt) way of going forth. > > We use ion and dumb allocator for framebuffer object creation. The way > I see it is as follows :- > > 1. For ion allocator :- > Userspace can specify that it wants the buffer from a secure heap or any other > special region of heap. The ion driver will either fault into the secure os to > create the buffers or it will do some other magic. Honestly, I have still not > figured that out. But it will be agnostic to the drm core. Allocating buffers from a special heap is what I expected the interface to be. The issue is that if we specify the secure mode any time later on, then it could be changed. E.g. with Daniel Stone's idea of a handle2fd flag, you could export the buffer twice, once secure, once non-secure. That sounds like a silly thing to me, and better to prevent that - or is this actually possible/wanted, i.e. do we want to change the secure mode for a buffer later on? > The userspace gets a handle to the buffer and then it calls addFB2 with > DRM_FORMAT_MOD_ARM_PROTECTED, so that the driver can configure the > dpu's protection bits (to access the memory with special signals). If we allocate a secure buffer there's no need for flags anymore I think - it would be a property of the underlying buffer (like a contiguous buffer). All we need are two things: - make sure secure buffers can only be imported by secure-buffer aware drivers - some way for such drivers to figure out whether they deal with a secure buffer or not. There's no need for any flags anywhere else with the ion/secure dma-buf heap solution. E.g. for contig buffer we also dont pass around a DRM_FORMAT_MOD_PHYSICALLY_CONTIG for addfb2. > 2. For dumb allocator :- > I am curious to know if we can add 'IS_PROTECTED' flag to > drm_mode_create_dumb.flags. This can/might be used to set dma_buf > flags. Let me know if this is an incorrect/forbidden path. dumb is dumb, this definitely feels like the wrong interface to me. > In a nutshell, my objective is to figure out if the userspace is able > to communicate to the drm core about the 'protection' status of the > buffer without introducing Arm specific buffer allocator. Why does userspace need to communicate this again? What's the issue with using an ARM specific allocator for this? -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch