From: Daniel Vetter <daniel@ffwll.ch>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: "Christian König" <christian.koenig@amd.com>,
"mripard@kernel.org" <mripard@kernel.org>,
"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"quic_vjitta@quicinc.com" <quic_vjitta@quicinc.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"sumit.semwal@linaro.org" <sumit.semwal@linaro.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"jkardatzke@google.com" <jkardatzke@google.com>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"joakim.bech@linaro.org" <joakim.bech@linaro.org>,
"Youlin Pei (裴友林)" <youlin.pei@mediatek.com>,
"logang@deltatee.com" <logang@deltatee.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"Kuohong Wang (王國鴻)" <kuohong.wang@mediatek.com>,
"Jianjiao Zeng (曾健姣)" <Jianjiao.Zeng@mediatek.com>,
"contact@emersion.fr" <contact@emersion.fr>,
"benjamin.gaignard@collabora.com"
<benjamin.gaignard@collabora.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
"willy@infradead.org" <willy@infradead.org>,
"pavel@ucw.cz" <pavel@ucw.cz>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"Brian.Starkey@arm.com" <Brian.Starkey@arm.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"tjmercier@google.com" <tjmercier@google.com>,
"jstultz@google.com" <jstultz@google.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"Yong Wu (吴勇)" <Yong.Wu@mediatek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"ppaalanen@gmail.com" <ppaalanen@gmail.com>
Subject: Re: [PATCH v5 2/9] scatterlist: Add a flag for the restricted memory
Date: Fri, 28 Jun 2024 19:52:15 +0200 [thread overview]
Message-ID: <Zn74Tys4eCji2qm0@phenom.ffwll.local> (raw)
In-Reply-To: <fh37zowioui7hcabzrco7xqxttze2lufijq67wbzylah3e3ry6@ahwnr2rspt3l>
On Fri, Jun 28, 2024 at 03:57:49PM +0200, Thierry Reding wrote:
> On Fri, Jun 28, 2024 at 02:34:24PM GMT, Christian König wrote:
> > Am 28.06.24 um 13:47 schrieb Thierry Reding:
> > > [SNIP]
> > > > > The reason I ask is that encryption here looks just like another parameter
> > > > > for the buffer, e.g. like format, stride, tilling etc..
> > > > >
> > > > > So instead of this during buffer import:
> > > > >
> > > > > mtk_gem->secure = (!strncmp(attach->dmabuf->exp_name, "restricted", 10));
> > > > > mtk_gem->dma_addr = sg_dma_address(sg->sgl);
> > > > > mtk_gem->size = attach->dmabuf->size;
> > > > > mtk_gem->sg = sg;
> > > > >
> > > > > You can trivially say during use hey this buffer is encrypted.
> > > > >
> > > > > At least that's my 10 mile high view, maybe I'm missing some extensive key
> > > > > exchange or something like that.
> > > > That doesn't work in all cases, unfortunately.
> > > >
> > > > If you're doing secure video playback, the firmware is typically in
> > > > charge of the frame decryption/decoding, and you'd get dma-buf back that
> > > > aren't accessible by the CPU (or at least, not at the execution level
> > > > Linux runs with).
> > > Can you clarify which firmware you're talking about? Is this secure
> > > firmware, or firmware running on the video decoding hardware?
> > >
> > > > So nobody can map that buffer, and the firmware driver is the one who
> > > > knows that this buffer cannot be accessed by anyone. Putting this on the
> > > > userspace to know would be pretty weird, and wouldn't solve the case
> > > > where the kernel would try to map it.
> > > Doesn't userspace need to know from the start whether it's trying to do
> > > secure playback or not? Typically this involves more than just the
> > > decoding part. You'd typically set up things like HDCP as part of the
> > > process, so userspace probably already does know that the buffers being
> > > passed around are protected.
> > >
> > > Also, the kernel shouldn't really be mapping these buffers unless
> > > explicitly told to. In most cases you also wouldn't want the kernel to
> > > map these kinds of buffers, right? Are there any specific cases where
> > > you expect the kernel to need to map these?
> > >
> > > I've been looking at this on the Tegra side recently and the way it
> > > works on these chips is that you basically get an opaque carveout region
> > > that has been locked down by secure firmware or early bootloaders, so
> > > only certain hardware blocks can access it. We can allocate from that
> > > carveout and then pass the buffers around.
> > >
> > > It may be possible to use these protected carveout regions exclusively
> > > from the DRM/KMS driver and share them with multimedia engines via DMA-
> > > BUF, but I've also been looking into perhaps using DMA-BUF heaps to
> > > expose the carveout, which would make this a bit more flexible and allow
> > > either userspace to allocate the buffers or have multiple kernel drivers
> > > share the carveout via the DMA-BUF heap. Though the latter would require
> > > that there be in-kernel APIs for heaps, so not too sure about that yet.
> >
> > Yeah as far as I can see that would be a perfectly valid use case for
> > DMA-Buf heaps.
> >
> > One question here: How does the HDCP setup work on Tegra? From your comment
> > I guess you pass most of the information through userspace as well.
>
> Well, we don't currently support HDCP at all. I do have proof-of-concept
> patches from a long time ago and, yes, judging by that we'd need to
> control all of this from userspace. The way I imagine that this would
> work is that userspace needs to first set the "Content Protection" and
> "HDCP Content Type" properties and wait for the state change. Once that
> has happened it can go and allocate the protected memory and start
> decoding into it and then scan out from these buffers.
Yeah this is how this is meant to work, because some userspace is happy
with just hdcp, while the buffers are not encrypted/protected, the only
protection is system lockdown with secure boot.
So enable hdcp first, then allocate secure buffers and display them there.
And the hardware needs to make sure that if we ever drop hcpd, the screen
goes black (or encrypted garbage) when trying to display encrypted/secure
buffers.
> > Or is there any info inside the DMA-buf for this? In other words would you
> > also need to know if a buffer is then allocated from this special carveout?
>
> I don't think so. It's possible to scan out an unprotected buffer with
> HDCP enabled. It may also be possible to scan out a protected buffer
> even if HDCP wasn't enabled, though you would obviously want to prevent
> that somehow. Not sure if there's a common way to do this, but I guess
> in end-user devices you'd need a fully trusted boot chain to do that in
> a compliant way.
Where I know how it works it's hardware making that guarantee.
> It's been a long time since I looked at this, but I seem to recall that
> at the time all software that could do DRM-protected playback on Linux
> was proprietary for reasons like these.
Yeah it's still not much better unfortunately :-/
-Sima
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2024-06-28 17:52 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 11:22 [PATCH v5 0/9] dma-buf: heaps: Add restricted heap Yong Wu
2024-05-15 11:23 ` [PATCH v5 1/9] dt-bindings: reserved-memory: Add mediatek,dynamic-restricted-region Yong Wu
2024-05-15 11:23 ` [PATCH v5 2/9] scatterlist: Add a flag for the restricted memory Yong Wu
2024-05-16 8:17 ` Christian König
2024-05-20 7:58 ` Yong Wu (吴勇)
2024-05-21 18:36 ` Christian König
2024-06-25 11:02 ` Jason-JH Lin (林睿祥)
[not found] ` <3104b765-5666-44e4-8788-f1b1b296fe17@amd.com>
2024-06-26 8:05 ` Jason-JH Lin (林睿祥)
[not found] ` <75dc1136-7751-4772-9fa7-dd9124684cd2@amd.com>
2024-06-26 17:56 ` Daniel Vetter
2024-06-27 3:21 ` Jason-JH Lin (林睿祥)
2024-06-27 6:57 ` Christian König
2024-06-27 14:40 ` mripard
2024-06-28 11:47 ` Thierry Reding
2024-06-28 13:21 ` mripard
2024-06-28 14:11 ` Thierry Reding
2024-06-28 20:34 ` Nicolas Dufresne
[not found] ` <c96f82e3-bbd6-407e-a71b-3a794a56585b@amd.com>
2024-06-28 13:57 ` Thierry Reding
2024-06-28 17:52 ` Daniel Vetter [this message]
[not found] ` <304c9faa-5a9c-4520-a3d8-0818f76dd7c9@amd.com>
2024-06-28 13:40 ` mripard
[not found] ` <18c6ab56-1d43-4646-914b-6de793811040@amd.com>
2024-07-10 9:56 ` Jason-JH Lin (林睿祥)
2024-06-28 20:23 ` Nicolas Dufresne
2024-06-28 20:16 ` Nicolas Dufresne
2024-07-01 8:41 ` [Linaro-mm-sig] " Christian König
2024-06-27 3:17 ` Jason-JH Lin (林睿祥)
2024-05-16 9:59 ` AngeloGioacchino Del Regno
2024-05-20 9:53 ` Yong Wu (吴勇)
2024-05-15 11:23 ` [PATCH v5 3/9] lib/scatterlist: Add sg_dup_table Yong Wu
2024-05-15 11:23 ` [PATCH v5 4/9] dma-buf: heaps: Initialize a restricted heap Yong Wu
2024-05-15 11:23 ` [PATCH v5 5/9] dma-buf: heaps: restricted_heap: Add private heap ops Yong Wu
2024-06-28 12:26 ` Thierry Reding
2024-05-15 11:23 ` [PATCH v5 6/9] dma-buf: heaps: restricted_heap: Add dma_ops Yong Wu
2024-05-15 11:23 ` [PATCH v5 7/9] dma-buf: heaps: restricted_heap: Add MediaTek restricted heap and heap_init Yong Wu
2024-06-28 12:38 ` Thierry Reding
2024-08-22 15:11 ` Jens Wiklander
2024-05-15 11:23 ` [PATCH v5 8/9] dma-buf: heaps: restricted_heap_mtk: Add TEE memory service call Yong Wu
2024-05-15 11:23 ` [PATCH v5 9/9] dma_buf: heaps: restricted_heap_mtk: Add a new CMA heap Yong Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zn74Tys4eCji2qm0@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=Brian.Starkey@arm.com \
--cc=Jason-JH.Lin@mediatek.com \
--cc=Jianjiao.Zeng@mediatek.com \
--cc=Yong.Wu@mediatek.com \
--cc=akpm@linux-foundation.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=benjamin.gaignard@collabora.com \
--cc=christian.koenig@amd.com \
--cc=conor+dt@kernel.org \
--cc=contact@emersion.fr \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jkardatzke@google.com \
--cc=joakim.bech@linaro.org \
--cc=jstultz@google.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuohong.wang@mediatek.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=logang@deltatee.com \
--cc=matthias.bgg@gmail.com \
--cc=mripard@kernel.org \
--cc=pavel@ucw.cz \
--cc=ppaalanen@gmail.com \
--cc=quic_vjitta@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sumit.semwal@linaro.org \
--cc=thierry.reding@gmail.com \
--cc=tjmercier@google.com \
--cc=willy@infradead.org \
--cc=youlin.pei@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox