On Tue, Jul 02, 2024 at 10:57:35PM GMT, Amirreza Zarrabi wrote:
> Qualcomm TEE hosts Trusted Applications (TAs) and services that run in
> the secure world. Access to these resources is provided using MinkIPC.
> MinkIPC is a capability-based synchronous message passing facility. It
> allows code executing in one domain to invoke objects running in other
> domains. When a process holds a reference to an object that lives in
> another domain, that object reference is a capability. Capabilities
> allow us to separate implementation of policies from implementation of
> the transport.
>
> As part of the upstreaming of the object invoke driver (called SMC-Invoke
> driver), we need to provide a reasonable kernel API and UAPI. The clear
> option is to use TEE subsystem and write a back-end driver, however the
> TEE subsystem doesn't fit with the design of Qualcomm TEE.
>
> Does TEE subsystem fit requirements of a capability based system?
> -----------------------------------------------------------------
> In TEE subsystem, to invoke a function:
> - client should open a device file "/dev/teeX",
> - create a session with a TA, and
> - invoke the functions in that session.
>
> 1. The privilege to invoke a function is determined by a session. If a
> client has a session, it cannot share it with other clients. Even if
> it does, it is not fine-grained enough, i.e. either all accessible
> functions/resources in a session or none. Assume a scenario when a client
> wants to grant a permission to invoke just a function that it has the rights,
> to another client.
>
> The "all or nothing" for sharing sessions is not in line with our
> capability system: "if you own a capability, you should be able to grant
> or share it".
Can you please be more specific here? What kind of sharing is expected
on the user side of it?
> 2. In TEE subsystem, resources are managed in a context. Every time a
> client opens "/dev/teeX", a new context is created to keep track of
> the allocated resources, including opened sessions and remote objects. Any
> effort for sharing resources between two independent clients requires
> involvement of context manager, i.e. the back-end driver. This requires
> implementing some form of policy in the back-end driver.
What kind of resource sharing?
> 3. The TEE subsystem supports two type of memory sharing:
> - per-device memory pools, and
> - user defined memory references.
> User defined memory references are private to the application and cannot
> be shared. Memory allocated from per-device "shared" pools are accessible
> using a file descriptor. It can be mapped by any process if it has
> access to it. This means, we cannot provide the resource isolation
> between two clients. Assume a scenario when a client wants to allocate a
> memory (which is shared with TEE) from an "isolated" pool and share it
> with another client, without the right to access the contents of memory.
This doesn't explain, why would it want to share such memory with
another client.
> 4. The kernel API provided by TEE subsystem does not support a kernel
> supplicant. Adding support requires an execution context (e.g. a
> kernel thread) due to the TEE subsystem design. tee_driver_ops supports
> only "send" and "receive" callbacks and to deliver a request, someone
> should wait on "receive".
There is nothing wrong here, but maybe I'm misunderstanding something.
> We need a callback to "dispatch" or "handle" a request in the context of
> the client thread. It should redirect a request to a kernel service or
> a user supplicant. In TEE subsystem such requirement should be implemented
> in TEE back-end driver, independent from the TEE subsystem.
>
> 5. The UAPI provided by TEE subsystem is similar to the GPTEE Client
> interface. This interface is not suitable for a capability system.
> For instance, there is no session in a capability system which means
> either its should not be used, or we should overload its definition.
General comment: maybe adding more detailed explanation of how the
capabilities are aquired and how they can be used might make sense.
BTW. It might be my imperfect English, but each time I see the word
'capability' I'm thinking that some is capable of doing something. I
find it hard to use 'capability' for the reference to another object.
>
> Can we use TEE subsystem?
> -------------------------
> There are workarounds for some of the issues above. The question is if we
> should define our own UAPI or try to use a hack-y way of fitting into
> the TEE subsystem. I am using word hack-y, as most of the workaround
> involves:
>
> - "diverging from the definition". For instance, ignoring the session
> open and close ioctl calls or use file descriptors for all remote
> resources (as, fd is the closet to capability) which undermines the
> isolation provided by the contexts,
>
> - "overloading the variables". For instance, passing object ID as file
> descriptors in a place of session ID, or
>
> - "bypass TEE subsystem". For instance, extensively rely on meta
> parameters or push everything (e.g. kernel services) to the back-end
> driver, which means leaving almost all TEE subsystem unused.
>
> We cannot take the full benefits of TEE subsystem and may need to
> implement most of the requirements in the back-end driver. Also, as
> discussed above, the UAPI is not suitable for capability-based use cases.
> We proposed a new set of ioctl calls for SMC-Invoke driver.
>
> In this series we posted three patches. We implemented a transport
> driver that provides qcom_tee_object. Any object on secure side is
> represented with an instance of qcom_tee_object and any struct exposed
> to TEE should embed an instance of qcom_tee_object. Any, support for new
> services, e.g. memory object, RPMB, userspace clients or supplicants are
> implemented independently from the driver.
>
> We have a simple memory object and a user driver that uses
> qcom_tee_object.
Could you please point out any user for the uAPI? I'd like to understand
how does it from from the userspace point of view.
>
> Signed-off-by: Amirreza Zarrabi <quic_azarrabi(a)quicinc.com>
> ---
> Amirreza Zarrabi (3):
> firmware: qcom: implement object invoke support
> firmware: qcom: implement memory object support for TEE
> firmware: qcom: implement ioctl for TEE object invocation
>
> drivers/firmware/qcom/Kconfig | 36 +
> drivers/firmware/qcom/Makefile | 2 +
> drivers/firmware/qcom/qcom_object_invoke/Makefile | 12 +
> drivers/firmware/qcom/qcom_object_invoke/async.c | 142 +++
> drivers/firmware/qcom/qcom_object_invoke/core.c | 1139 ++++++++++++++++++
> drivers/firmware/qcom/qcom_object_invoke/core.h | 186 +++
> .../qcom/qcom_object_invoke/qcom_scm_invoke.c | 22 +
> .../firmware/qcom/qcom_object_invoke/release_wq.c | 90 ++
> .../qcom/qcom_object_invoke/xts/mem_object.c | 406 +++++++
> .../qcom_object_invoke/xts/object_invoke_uapi.c | 1231 ++++++++++++++++++++
> include/linux/firmware/qcom/qcom_object_invoke.h | 233 ++++
> include/uapi/misc/qcom_tee.h | 117 ++
> 12 files changed, 3616 insertions(+)
> ---
> base-commit: 74564adfd3521d9e322cfc345fdc132df80f3c79
> change-id: 20240702-qcom-tee-object-and-ioctls-6f52fde03485
>
> Best regards,
> --
> Amirreza Zarrabi <quic_azarrabi(a)quicinc.com>
>
--
With best wishes
Dmitry
Am 27.06.24 um 05:21 schrieb Jason-JH Lin (林睿祥):
>
> On Wed, 2024-06-26 at 19:56 +0200, Daniel Vetter wrote:
> >
> > External email : Please do not click links or open attachments until
> > you have verified the sender or the content.
> > On Wed, Jun 26, 2024 at 12:49:02PM +0200, Christian König wrote:
> > > Am 26.06.24 um 10:05 schrieb Jason-JH Lin (林睿祥):
> > > > > > I think I have the same problem as the ECC_FLAG mention in:
> > > > > > > >
> > https://lore.kernel.org/linux-media/20240515-dma-buf-ecc-heap-v1-0-54cbbd04…
> > > > > > > > I think it would be better to have the user configurable
> > private
> > > > > > information in dma-buf, so all the drivers who have the same
> > > > > > requirement can get their private information from dma-buf
> > directly
> > > > > > and
> > > > > > no need to change or add the interface.
> > > > > > > > What's your opinion in this point?
> > > > > > Well of hand I don't see the need for that.
> > > > > > What happens if you get a non-secure buffer imported in your
> > secure
> > > > > device?
> > > >
> > > > We use the same mediatek-drm driver for secure and non-secure
> > buffer.
> > > > If non-secure buffer imported to mediatek-drm driver, it's go to
> > the
> > > > normal flow with normal hardware settings.
> > > >
> > > > We use different configurations to make hardware have different
> > > > permission to access the buffer it should access.
> > > >
> > > > So if we can't get the information of "the buffer is allocated
> > from
> > > > restricted_mtk_cma" when importing the buffer into the driver, we
> > won't
> > > > be able to configure the hardware correctly.
> > >
> > > Why can't you get this information from userspace?
> >
> > Same reason amd and i915/xe also pass this around internally in the
> > kernel, it's just that for those gpus the render and kms node are the
> > same
> > driver so this is easy.
> >
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.
>
> > But on arm you have split designs everywhere and dma-buf
> > import/export, so
> > something else is needed. And neither current kms uapi nor
> > protocols/extensions have provisions for this (afaik) because it
> > works on
> > the big gpus, and on android it's just hacked up with backchannels.
> >
> > So yeah essentially I think we probably need something like this, as
> > much
> > as it sucks. I see it somewhat similar to handling pcip2pdma
> > limitations
> > in the kernel too.
> >
> > Not sure where/how it should be handled though, and maybe I've missed
> > something around protocols, in which case I guess we should add some
> > secure buffer flags to the ADDFB2 ioctl.
>
> Thanks for your hint, I'll try to add the secure flag to the ADDFB2
> ioctl. If it works, I'll send the patch.
Yeah, exactly what I would suggest as well.
I'm not an expert for that part, but as far as I know we already have
bunch of device specific tilling flags in there.
Adding an MTK_ENCRYPTED flag should be trivial.
Regards,
Christian.
>
> Regards,
> Jason-JH.Lin
>
> > -Sima
>
> ************* MEDIATEK Confidentiality Notice ********************
> The information contained in this e-mail message (including any
> attachments) may be confidential, proprietary, privileged, or otherwise
> exempt from disclosure under applicable laws. It is intended to be
> conveyed only to the designated recipient(s). Any use, dissemination,
> distribution, printing, retaining or copying of this e-mail (including its
> attachments) by unintended recipient(s) is strictly prohibited and may
> be unlawful. If you are not an intended recipient of this e-mail, or believe
> that you have received this e-mail in error, please notify the sender
> immediately (by replying to this e-mail), delete any and all copies of
> this e-mail (including any attachments) from your system, and do not
> disclose the content of this e-mail to any other person. Thank you!
Hi Jonathan,
Here's the v12 of my patchset that introduces DMABUF support to IIO.
Apart from a small documentation fix, it reverts to using
mutex_lock/mutex_unlock in one particular place, which used cleanup
GOTOs (which don't play well with scope-managed cleanups).
Changelog:
- [3/7]:
- Revert to mutex_lock/mutex_unlock in iio_buffer_attach_dmabuf(),
as it uses cleanup GOTOs
- [6/7]:
- "obtained using..." -> "which can be obtained using..."
This is based on next-20240619.
Cheers,
-Paul
Paul Cercueil (7):
dmaengine: Add API function dmaengine_prep_peripheral_dma_vec()
dmaengine: dma-axi-dmac: Implement device_prep_peripheral_dma_vec
iio: core: Add new DMABUF interface infrastructure
iio: buffer-dma: Enable support for DMABUFs
iio: buffer-dmaengine: Support new DMABUF based userspace API
Documentation: iio: Document high-speed DMABUF based API
Documentation: dmaengine: Document new dma_vec API
Documentation/driver-api/dmaengine/client.rst | 9 +
.../driver-api/dmaengine/provider.rst | 10 +
Documentation/iio/iio_dmabuf_api.rst | 54 +++
Documentation/iio/index.rst | 1 +
drivers/dma/dma-axi-dmac.c | 40 ++
drivers/iio/Kconfig | 1 +
drivers/iio/buffer/industrialio-buffer-dma.c | 178 ++++++-
.../buffer/industrialio-buffer-dmaengine.c | 62 ++-
drivers/iio/industrialio-buffer.c | 459 ++++++++++++++++++
include/linux/dmaengine.h | 33 ++
include/linux/iio/buffer-dma.h | 31 ++
include/linux/iio/buffer_impl.h | 33 ++
include/uapi/linux/iio/buffer.h | 22 +
13 files changed, 913 insertions(+), 20 deletions(-)
create mode 100644 Documentation/iio/iio_dmabuf_api.rst
--
2.43.0
Am 27.06.24 um 05:17 schrieb Jason-JH Lin (林睿祥):
>
> On Wed, 2024-06-26 at 12:49 +0200, Christian König wrote:
> >
> > External email : Please do not click links or open attachments until
> > you have verified the sender or the content.
> > Am 26.06.24 um 10:05 schrieb Jason-JH Lin (林睿祥):
> > > >
> > > > > In the step 3), we need to verify the dma-buf is allocated from
> > > > > "restricted_mtk_cma", but there is no way to pass the
> > > secure flag
> > > > > or
> > > > > private data from userspace to the import interface in DRM
> > > driver.
> > > >
> > > > Why do you need to verify that?
> > >
> > > I need to know the imported buffer is allocated from restricted cma
> > > and
> > > mark it as a secure buffer in mediatek-drm driver. Then, I will add
> > > some configuration to the hardware if the buffer is secure buffer,
> > > so
> > > that it can get the permission to access the secure buffer.
> >
> > Yeah so far that makes sense. This is basically what other drivers do
> > with secure buffers as well.
> >
> > But why do you want the kernel to transport that information? Usually
> > drivers get the information from userspace what to do with a buffer.
> >
> > In other words the format, stride, tilling and also if it's a secure
> > buffer or not comes from userspace.
> >
>
> Thanks for your clear explanation.
> I think this is what I want, but I can't find any DRM interface to pass
> the secure flag from userspace.
Well stuff like that is usually device driver specific.
So you should probably use something device specific which tells the
driver that this buffer is encrypted.
> > What the hardware usually handles internally is things like
> > encryption keys, but you eventually get the information where to look
> > for the key from userspace as well.
> >
> > Handling inside the kernel would only be necessary if userspace could
> > for example crash the system with invalid parameters. But for
> > encryption that is usually not the case.
> >
>
> Yes, that's true.
>
> > > >
> > > > > So I can only verify it like this now:
> > > > > struct drm_gem_object *mtk_gem_prime_import_sg_table(struct
> > > > > drm_device
> > > > > *dev, struct dma_buf_attachment *attach, struct sg_table *sg)
> > > > > {
> > > > > struct mtk_gem_obj *mtk_gem;
> > > > >
> > > > > /* check if the entries in the sg_table are contiguous */
> > > > > if (drm_prime_get_contiguous_size(sg) <
> > > attach->dmabuf->size) {
> > > > > DRM_ERROR("sg_table is not contiguous");
> > > > > return ERR_PTR(-EINVAL);
> > > > > }
> > > > > mtk_gem = mtk_gem_init(dev, attach->dmabuf->size);
> > > > > if (IS_ERR(mtk_gem))
> > > > > return ERR_CAST(mtk_gem);
> > > > >
> > > > > + 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;
> > > > >
> > > > > return &mtk_gem->base;
> > > > > }
> > > >
> > > > Complete NAK from my side to that approach. Importing of a DMA-
> > > buf
> > > > should be independent of the exporter.
> > > >
> > > > What you could do is to provide the secure buffer from a device
> > > and
> > > > not a device heap.
> > > >
> > >
> > > You mean I should allocate buffer in mediate-drm driver not
> > > userspace?
> >
> > Well that depends. The question is if you have multiple drivers which
> > needs to work with this secure buffer?
> >
> > If yes then you should have a general allocation heap for it. If no
> > then the buffers could as well be allocated from the driver interface
> > directly.
> >
>
> Yes, this buffer needs work with GPU and DRM drivers, so this general
> "restricted_mtk_cma" will allocated in userspace, then being passed to
> GPU and DRM.
Well do you really need a separate heap for that? In other words is only
a certain part of the system memory capable of being encrypted?
Or would the "normal" CMA heap do as well and you only need to setup
your hardware properly for encryption?
Additional to that in most other drivers buffer sharing and encryption
are two separate things. In other words other drivers do something like
this:
1. Allocate the buffer.
2. Import the buffer using DRM_IOCTL_PRIME_FD_TO_HANDLE.
3. Set additional buffer properties, e.g. format, stride, tilling, if
it's secure, which encryption key to use, where to map etc...
So as far as I can see the problem you are facing is that you try to
mangle everything into DRM_IOCTL_PRIME_FD_TO_HANDLE. Why not make that a
separate IOCTL?
I mean we intentionally don't provide things like format, stride,
tilling etc.. to DRM_IOCTL_PRIME_FD_TO_HANDLE. Encryption is just
another of those parameters.
Regards,
Christian.
>
> > > I just have modified this to userspace by the comment here:
> > >
> > >
> https://patchwork.kernel.org/project/linux-mediatek/patch/20240403102701.36…
> > >
> > > > > I think I have the same problem as the ECC_FLAG mention in:
> > > > >
> > > > >
> > >
> https://lore.kernel.org/linux-media/20240515-dma-buf-ecc-heap-v1-0-54cbbd04…
> > > > >
> > > > > I think it would be better to have the user configurable
> > > private
> > > > > information in dma-buf, so all the drivers who have the same
> > > > > requirement can get their private information from dma-buf
> > > directly
> > > > > and
> > > > > no need to change or add the interface.
> > > > >
> > > > > What's your opinion in this point?
> > > >
> > > > Well of hand I don't see the need for that.
> > > >
> > > > What happens if you get a non-secure buffer imported in your
> > > secure
> > > > device?
> > >
> > > We use the same mediatek-drm driver for secure and non-secure
> > > buffer.
> > > If non-secure buffer imported to mediatek-drm driver, it's go to
> > > the
> > > normal flow with normal hardware settings.
> > >
> > > We use different configurations to make hardware have different
> > > permission to access the buffer it should access.
> > >
> > > So if we can't get the information of "the buffer is allocated from
> > > restricted_mtk_cma" when importing the buffer into the driver, we
> > > won't
> > > be able to configure the hardware correctly.
> >
> > Why can't you get this information from userspace?
>
> As I mentioned here:
>
> https://patchwork.kernel.org/project/linux-mediatek/cover/20240525232928.55…
>
> I tried some DRM interfaces using buffer FD and arg->flag as
> parameters, but it didn't work. So I ask for your help here.
>
> But I think I should find DRM maintainer to add the secure flag to DRM
> interface now.
>
> Regards,
> Jason-JH.Lin
>
> ************* MEDIATEK Confidentiality Notice ********************
> The information contained in this e-mail message (including any
> attachments) may be confidential, proprietary, privileged, or otherwise
> exempt from disclosure under applicable laws. It is intended to be
> conveyed only to the designated recipient(s). Any use, dissemination,
> distribution, printing, retaining or copying of this e-mail (including its
> attachments) by unintended recipient(s) is strictly prohibited and may
> be unlawful. If you are not an intended recipient of this e-mail, or believe
> that you have received this e-mail in error, please notify the sender
> immediately (by replying to this e-mail), delete any and all copies of
> this e-mail (including any attachments) from your system, and do not
> disclose the content of this e-mail to any other person. Thank you!
Am 26.06.24 um 10:05 schrieb Jason-JH Lin (林睿祥):
>
> >
> > > In the step 3), we need to verify the dma-buf is allocated from
> > > "restricted_mtk_cma", but there is no way to pass the secure flag
> > > or
> > > private data from userspace to the import interface in DRM driver.
> >
> > Why do you need to verify that?
>
> I need to know the imported buffer is allocated from restricted cma and
> mark it as a secure buffer in mediatek-drm driver. Then, I will add
> some configuration to the hardware if the buffer is secure buffer, so
> that it can get the permission to access the secure buffer.
Yeah so far that makes sense. This is basically what other drivers do
with secure buffers as well.
But why do you want the kernel to transport that information? Usually
drivers get the information from userspace what to do with a buffer.
In other words the format, stride, tilling and also if it's a secure
buffer or not comes from userspace.
What the hardware usually handles internally is things like encryption
keys, but you eventually get the information where to look for the key
from userspace as well.
Handling inside the kernel would only be necessary if userspace could
for example crash the system with invalid parameters. But for encryption
that is usually not the case.
> >
> > > So I can only verify it like this now:
> > > struct drm_gem_object *mtk_gem_prime_import_sg_table(struct
> > > drm_device
> > > *dev, struct dma_buf_attachment *attach, struct sg_table *sg)
> > > {
> > > struct mtk_gem_obj *mtk_gem;
> > >
> > > /* check if the entries in the sg_table are contiguous */
> > > if (drm_prime_get_contiguous_size(sg) < attach->dmabuf->size) {
> > > DRM_ERROR("sg_table is not contiguous");
> > > return ERR_PTR(-EINVAL);
> > > }
> > > mtk_gem = mtk_gem_init(dev, attach->dmabuf->size);
> > > if (IS_ERR(mtk_gem))
> > > return ERR_CAST(mtk_gem);
> > >
> > > + 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;
> > >
> > > return &mtk_gem->base;
> > > }
> >
> > Complete NAK from my side to that approach. Importing of a DMA-buf
> > should be independent of the exporter.
> >
> > What you could do is to provide the secure buffer from a device and
> > not a device heap.
> >
>
> You mean I should allocate buffer in mediate-drm driver not userspace?
Well that depends. The question is if you have multiple drivers which
needs to work with this secure buffer?
If yes then you should have a general allocation heap for it. If no then
the buffers could as well be allocated from the driver interface directly.
> I just have modified this to userspace by the comment here:
>
> https://patchwork.kernel.org/project/linux-mediatek/patch/20240403102701.36…
>
> > > I think I have the same problem as the ECC_FLAG mention in:
> > >
> > >
> https://lore.kernel.org/linux-media/20240515-dma-buf-ecc-heap-v1-0-54cbbd04…
> > >
> > > I think it would be better to have the user configurable private
> > > information in dma-buf, so all the drivers who have the same
> > > requirement can get their private information from dma-buf directly
> > > and
> > > no need to change or add the interface.
> > >
> > > What's your opinion in this point?
> >
> > Well of hand I don't see the need for that.
> >
> > What happens if you get a non-secure buffer imported in your secure
> > device?
>
> We use the same mediatek-drm driver for secure and non-secure buffer.
> If non-secure buffer imported to mediatek-drm driver, it's go to the
> normal flow with normal hardware settings.
>
> We use different configurations to make hardware have different
> permission to access the buffer it should access.
>
> So if we can't get the information of "the buffer is allocated from
> restricted_mtk_cma" when importing the buffer into the driver, we won't
> be able to configure the hardware correctly.
Why can't you get this information from userspace?
Regards,
Christian.
>
> Regards,
> Jason-JH.Lin
>
> >
> > Regards,
> > Christian.
> >
> > > Regards,
> > > Jason-JH.Lin
> > >
> > > > Regards,
> > > > Christian.
> > >
> > > ************* MEDIATEK Confidentiality Notice
> > > ********************
> > > The information contained in this e-mail message (including any
> > > attachments) may be confidential, proprietary, privileged, or
> > > otherwise
> > > exempt from disclosure under applicable laws. It is intended to be
> > > conveyed only to the designated recipient(s). Any use,
> > > dissemination,
> > > distribution, printing, retaining or copying of this e-mail
> > > (including its
> > > attachments) by unintended recipient(s) is strictly prohibited and
> > > may
> > > be unlawful. If you are not an intended recipient of this e-mail,
> > > or believe
> > >
> > > that you have received this e-mail in error, please notify the
> > > sender
> > > immediately (by replying to this e-mail), delete any and all copies
> > > of
> > > this e-mail (including any attachments) from your system, and do
> > > not
> > > disclose the content of this e-mail to any other person. Thank you!
> >
>
> ************* MEDIATEK Confidentiality Notice
> ********************
> The information contained in this e-mail message (including any
> attachments) may be confidential, proprietary, privileged, or otherwise
> exempt from disclosure under applicable laws. It is intended to be
> conveyed only to the designated recipient(s). Any use, dissemination,
> distribution, printing, retaining or copying of this e-mail (including its
> attachments) by unintended recipient(s) is strictly prohibited and may
> be unlawful. If you are not an intended recipient of this e-mail, or believe
>
> that you have received this e-mail in error, please notify the sender
> immediately (by replying to this e-mail), delete any and all copies of
> this e-mail (including any attachments) from your system, and do not
> disclose the content of this e-mail to any other person. Thank you!
On 19/06/2024 16:46, Alexandre Mergnat wrote:
> Add the audio codec sub-device. This sub-device is used to set the
> optional voltage values according to the hardware.
> The properties are:
> - Setup of microphone bias voltage.
> - Setup of the speaker pin pull-down.
>
> Also, add the audio power supply property which is dedicated for
> the audio codec sub-device.
>
> Signed-off-by: Alexandre Mergnat <amergnat(a)baylibre.com>
> ---
> .../devicetree/bindings/mfd/mediatek,mt6357.yaml | 33 ++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
> index 37423c2e0fdf..d95307393e75 100644
> --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
> +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
> @@ -37,6 +37,32 @@ properties:
> "#interrupt-cells":
> const: 2
>
> + vaud28-supply:
> + description: 2.8 volt supply phandle for the audio codec
> +
> + audio-codec:
> + type: object
Still not much improved. You do not have any resources there, so these
should go to the parent node.
Best regards,
Krzysztof
On 26/06/2024 10:30, Alexandre Mergnat wrote:
>
>
> On 25/06/2024 15:44, Krzysztof Kozlowski wrote:
>> On 25/06/2024 11:23, Alexandre Mergnat wrote:
>>>
>>>
>>> On 21/06/2024 17:00, Krzysztof Kozlowski wrote:
>>>> On 19/06/2024 16:46, Alexandre Mergnat wrote:
>>>>> Add the audio codec sub-device. This sub-device is used to set the
>>>>> optional voltage values according to the hardware.
>>>>> The properties are:
>>>>> - Setup of microphone bias voltage.
>>>>> - Setup of the speaker pin pull-down.
>>>>>
>>>>> Also, add the audio power supply property which is dedicated for
>>>>> the audio codec sub-device.
>>>>>
>>>>> Signed-off-by: Alexandre Mergnat<amergnat(a)baylibre.com>
>>>>> ---
>>>>> .../devicetree/bindings/mfd/mediatek,mt6357.yaml | 33 ++++++++++++++++++++++
>>>>> 1 file changed, 33 insertions(+)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
>>>>> index 37423c2e0fdf..d95307393e75 100644
>>>>> --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
>>>>> +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
>>>>> @@ -37,6 +37,32 @@ properties:
>>>>> "#interrupt-cells":
>>>>> const: 2
>>>>>
>>>>> + vaud28-supply:
>>>>> + description: 2.8 volt supply phandle for the audio codec
>>>>> +
>>>>> + audio-codec:
>>>>> + type: object
>>>> Still not much improved. You do not have any resources there, so these
>>>> should go to the parent node.
>>>
>>> Hi Krzysztof,
>>>
>>> vaud28-supply seems to be a mistake that I forward port.
>>> In the V4, AFAII, your feedback [1] suggested me to move the vaud28-supply from the "audio-codec"
>>> sub-node to the parent node, which for me is the "pmic" (mfd), because the property is considered as
>>> power-supply.
>>>
>>> pwrap {
>>> pmic {
>>> ...
>>> audio-codec {
>>> ...
>>>
>>> Hardware side, vaud28-supply is the output of PMIC-regulator subsystem, and AVDD28 is the input of
>>> PMIC-audio-codec subsystem. Then:
>>> - The property name is wrong and must be change to AVDD28, which is a consumer (power input), not a
>>> power-supply. => description: 2.8 volt power input for microphones (AU_VIN0, AU_VIN1, AU_VIN2)
>>> - IMHO, move this property to the next parent (pwrap) isn't consistent. It should be moved back to
>>> Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml (Done in the V4) into audio-codec
>>> substystem, beside mediatek,micbias0-microvolt
>>
>> I don't understand why do we talk again about supply. My comment was not
>> under the supply.
>
> Because your word are:
> "
> And now you should see how odd it looks. Supplies are part of entire
> chip, not subblock, even if they supply dedicated domain within that chip.
>
> That's why I asked to put it in the parent node.
> "
>
> My bad, I forgot to link you the old message in my previous answer [1]
>
> [1] https://lore.kernel.org/all/6d21da37-8be7-467c-8878-d57af0b0201b@kernel.org…
And you implemented this, so why do we talk again about it? It is
already solved, isn't it? Since previous version?
Best regards,
Krzysztof
On 25/06/2024 11:23, Alexandre Mergnat wrote:
>
>
> On 21/06/2024 17:00, Krzysztof Kozlowski wrote:
>> On 19/06/2024 16:46, Alexandre Mergnat wrote:
>>> Add the audio codec sub-device. This sub-device is used to set the
>>> optional voltage values according to the hardware.
>>> The properties are:
>>> - Setup of microphone bias voltage.
>>> - Setup of the speaker pin pull-down.
>>>
>>> Also, add the audio power supply property which is dedicated for
>>> the audio codec sub-device.
>>>
>>> Signed-off-by: Alexandre Mergnat<amergnat(a)baylibre.com>
>>> ---
>>> .../devicetree/bindings/mfd/mediatek,mt6357.yaml | 33 ++++++++++++++++++++++
>>> 1 file changed, 33 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml b/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
>>> index 37423c2e0fdf..d95307393e75 100644
>>> --- a/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
>>> +++ b/Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml
>>> @@ -37,6 +37,32 @@ properties:
>>> "#interrupt-cells":
>>> const: 2
>>>
>>> + vaud28-supply:
>>> + description: 2.8 volt supply phandle for the audio codec
>>> +
>>> + audio-codec:
>>> + type: object
>> Still not much improved. You do not have any resources there, so these
>> should go to the parent node.
>
> Hi Krzysztof,
>
> vaud28-supply seems to be a mistake that I forward port.
> In the V4, AFAII, your feedback [1] suggested me to move the vaud28-supply from the "audio-codec"
> sub-node to the parent node, which for me is the "pmic" (mfd), because the property is considered as
> power-supply.
>
> pwrap {
> pmic {
> ...
> audio-codec {
> ...
>
> Hardware side, vaud28-supply is the output of PMIC-regulator subsystem, and AVDD28 is the input of
> PMIC-audio-codec subsystem. Then:
> - The property name is wrong and must be change to AVDD28, which is a consumer (power input), not a
> power-supply. => description: 2.8 volt power input for microphones (AU_VIN0, AU_VIN1, AU_VIN2)
> - IMHO, move this property to the next parent (pwrap) isn't consistent. It should be moved back to
> Documentation/devicetree/bindings/mfd/mediatek,mt6357.yaml (Done in the V4) into audio-codec
> substystem, beside mediatek,micbias0-microvolt
I don't understand why do we talk again about supply. My comment was not
under the supply.
Best regards,
Krzysztof
Am 25.06.24 um 13:02 schrieb Jason-JH Lin (林睿祥):
>
> Hi Christian,
>
> On Tue, 2024-05-21 at 20:36 +0200, Christian König wrote:
> > Am 20.05.24 um 09:58 schrieb Yong Wu (吴勇):
> > > On Thu, 2024-05-16 at 10:17 +0200, Christian König wrote:
> > > >
> > > > External email : Please do not click links or open attachments
> > > > until
> > > > you have verified the sender or the content.
> > > > Am 15.05.24 um 13:23 schrieb Yong Wu:
> > > > > Introduce a FLAG for the restricted memory which means the
> > > > > memory
> > > >
> > > > is
> > > > > protected by TEE or hypervisor, then it's inaccessiable for
> > > > > kernel.
> > > > >
> > > > > Currently we don't use sg_dma_unmark_restricted, thus this
> > > >
> > > > interface
> > > > > has not been added.
> > > >
> > > > Why should that be part of the scatterlist? It doesn't seem to
> > > > affect
> > > > any of it's functionality.
> > > >
> > > > As far as I can see the scatterlist shouldn't be the transport of
> > > > this
> > > > kind of information.
> > >
> > > Thanks for the review. I will remove this.
> > >
> > > In our user scenario, DRM will import these buffers and check if
> > > this
> > > is a restricted buffer. If yes, it will use secure GCE takes over.
> > >
> > > If this judgment is not suitable to be placed in scatterlist. I
> > > don't
> > > know if it is ok to limit this inside dma-buf. Adding such an
> > > interface:
> > >
> > > static bool dma_buf_is_restricted(struct dma_buf *dmabuf)
> > > {
> > > return !strncmp(dmabuf->exp_name, "restricted", 10);
> > > }
> >
> > No, usually stuff like that doesn't belong into DMA buf either.
> >
> > Question here really is who controls the security status of the
> > memory
> > backing the buffer?
> >
> > In other words who tells the exporter that it should allocate and
> > fill a
> > buffer with encrypted data?
> >
> > If that is userspace then that is part of the format information and
> > it
> > is also userspace who should tell the importer that it needs to work
> > with encrypted data.
> >
> > The kernel is intentionally not involved in stuff like that.
> >
>
> Here is the expected protected content buffer flow in DRM:
> 1) userspace allocates a dma-buf FD from the "restricted_mtk_cma" by
> DMA_HEAP_IOCTL_ALLOC.
> 2) userspace imports that dma-buf into the device using prime for the
> drm_file.
> 3) userspace uses the already implemented driver import code for the
> special cases of protected content buffer.
What is so special on that case?
>
> In the step 3), we need to verify the dma-buf is allocated from
> "restricted_mtk_cma", but there is no way to pass the secure flag or
> private data from userspace to the import interface in DRM driver.
Why do you need to verify that?
>
> So I can only verify it like this now:
> struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device
> *dev, struct dma_buf_attachment *attach, struct sg_table *sg)
> {
> struct mtk_gem_obj *mtk_gem;
>
> /* check if the entries in the sg_table are contiguous */
> if (drm_prime_get_contiguous_size(sg) < attach->dmabuf->size) {
> DRM_ERROR("sg_table is not contiguous");
> return ERR_PTR(-EINVAL);
> }
> mtk_gem = mtk_gem_init(dev, attach->dmabuf->size);
> if (IS_ERR(mtk_gem))
> return ERR_CAST(mtk_gem);
>
> + 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;
>
> return &mtk_gem->base;
> }
Complete NAK from my side to that approach. Importing of a DMA-buf
should be independent of the exporter.
What you could do is to provide the secure buffer from a device and not
a device heap.
> I think I have the same problem as the ECC_FLAG mention in:
>
> https://lore.kernel.org/linux-media/20240515-dma-buf-ecc-heap-v1-0-54cbbd04…
>
> I think it would be better to have the user configurable private
> information in dma-buf, so all the drivers who have the same
> requirement can get their private information from dma-buf directly and
> no need to change or add the interface.
>
> What's your opinion in this point?
Well of hand I don't see the need for that.
What happens if you get a non-secure buffer imported in your secure device?
Regards,
Christian.
>
> Regards,
> Jason-JH.Lin
>
> > Regards,
> > Christian.
>
> ************* MEDIATEK Confidentiality Notice
> ********************
> The information contained in this e-mail message (including any
> attachments) may be confidential, proprietary, privileged, or otherwise
> exempt from disclosure under applicable laws. It is intended to be
> conveyed only to the designated recipient(s). Any use, dissemination,
> distribution, printing, retaining or copying of this e-mail (including its
> attachments) by unintended recipient(s) is strictly prohibited and may
> be unlawful. If you are not an intended recipient of this e-mail, or believe
>
> that you have received this e-mail in error, please notify the sender
> immediately (by replying to this e-mail), delete any and all copies of
> this e-mail (including any attachments) from your system, and do not
> disclose the content of this e-mail to any other person. Thank you!