[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <98721904-003d-4d0d-8cfe-1cecdd59ce01@amd.com>
Date: Thu, 16 May 2024 10:17:13 +0200
From: Christian König <christian.koenig@....com>
To: Yong Wu <yong.wu@...iatek.com>, Rob Herring <robh+dt@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Benjamin Gaignard <benjamin.gaignard@...labora.com>,
Brian Starkey <Brian.Starkey@....com>, John Stultz <jstultz@...gle.com>,
tjmercier@...gle.com,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, Robin Murphy <robin.murphy@....com>,
Vijayanand Jitta <quic_vjitta@...cinc.com>,
Joakim Bech <joakim.bech@...aro.org>,
Jeffrey Kardatzke <jkardatzke@...gle.com>, Pavel Machek <pavel@....cz>,
Simon Ser <contact@...rsion.fr>, Pekka Paalanen <ppaalanen@...il.com>,
willy@...radead.org, Logan Gunthorpe <logang@...tatee.com>,
Daniel Vetter <daniel@...ll.ch>, jianjiao.zeng@...iatek.com,
kuohong.wang@...iatek.com, youlin.pei@...iatek.com
Subject: Re: [PATCH v5 2/9] scatterlist: Add a flag for the restricted memory
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.
Regards,
Christian.
>
> Signed-off-by: Yong Wu <yong.wu@...iatek.com>
> ---
> include/linux/scatterlist.h | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index 77df3d7b18a6..a6ad9018eca0 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -282,6 +282,7 @@ static inline void sg_unmark_end(struct scatterlist *sg)
>
> #define SG_DMA_BUS_ADDRESS (1 << 0)
> #define SG_DMA_SWIOTLB (1 << 1)
> +#define SG_DMA_RESTRICTED (2 << 1)
>
> /**
> * sg_dma_is_bus_address - Return whether a given segment was marked
> @@ -352,6 +353,31 @@ static inline void sg_dma_mark_swiotlb(struct scatterlist *sg)
> sg->dma_flags |= SG_DMA_SWIOTLB;
> }
>
> +/**
> + * sg_dma_mark_restricted - Mark the scatterlist for restricted buffer.
> + * @sg: SG entry
> + *
> + * Description:
> + * Marks a a scatterlist for the restricted buffer that may be inaccessiable
> + * in kernel if it is protected.
> + */
> +static inline void sg_dma_mark_restricted(struct scatterlist *sg)
> +{
> + sg->dma_flags |= SG_DMA_RESTRICTED;
> +}
> +
> +/**
> + * sg_dma_is_restricted - Return whether the scatterlist was marked as restricted
> + * buffer.
> + * @sg: SG entry
> + *
> + * Description:
> + * Returns true if the scatterlist was marked as restricted buffer.
> + */
> +static inline bool sg_dma_is_restricted(struct scatterlist *sg)
> +{
> + return sg->dma_flags & SG_DMA_RESTRICTED;
> +}
> #else
>
> static inline bool sg_dma_is_bus_address(struct scatterlist *sg)
> @@ -372,6 +398,14 @@ static inline void sg_dma_mark_swiotlb(struct scatterlist *sg)
> {
> }
>
> +static inline bool sg_dma_is_restricted(struct scatterlist *sg)
> +{
> + return false;
> +}
> +
> +static inline void sg_dma_mark_restrited(struct scatterlist *sg)
> +{
> +}
> #endif /* CONFIG_NEED_SG_DMA_FLAGS */
>
> /**
Powered by blists - more mailing lists