Re: [net-next,v6 1/8] octeontx2-pf: map skb data as device writeable

From: Jakub Kicinski
Date: Thu Aug 22 2024 - 10:48:56 EST


On Thu, 22 Aug 2024 09:15:43 +0530 Bharat Bhushan wrote:
> On Wed, Aug 21, 2024 at 4:06 AM Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
> > On Mon, 19 Aug 2024 17:53:41 +0530 Bharat Bhushan wrote:
> > > Crypto hardware need write permission for in-place encrypt
> > > or decrypt operation on skb-data to support IPsec crypto
> > > offload. So map this memory as device read-write.
> >
> > How do you know the fragments are not read only?
>
> IOMMU permission faults will be reported if the DMA_TO_DEVICE direction flag
> is used in dma_map_page_attrs(). This is because iommu creates read only mapping
> if the DMA_TO_DEVICE direction flag is used. If the direction flag used in
> dma_map_pages() is DMA_BIDIRECTIONAL then iommu creates mapping with
> both read and write permission.

The other way around, I understand that your code makes the pages
writable for the device. What I'm concerned about is that if this
code path is fed Tx skbs you will corrupt them. Are these not Tx
skbs that you're mapping? Have you fully CoW'd them to make sure
they are writable?