Linux IOMMU Development
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Chathura Rajapaksha <chathura.abeyrathne.lk@gmail.com>,
	iommu@lists.linux.dev
Cc: baolu.lu@linux.intel.com
Subject: Re: IOMMU software bounce buffers and their overhead
Date: Tue, 6 Jun 2023 10:15:10 +0800	[thread overview]
Message-ID: <f416c0dc-a82b-f608-4c6a-c2441b417bfb@linux.intel.com> (raw)
In-Reply-To: <CAD7mqryC_JROVXY9eD--iigjCU9266+ufPvZO2BujhVfM7qYfw@mail.gmail.com>

On 2023/6/4 0:49, Chathura Rajapaksha wrote:
> Hi All,
> 
> I have a few questions about IOMMU software bounce buffering.
> Description of the kernel config IOMMU_DEFAULT_DMA_STRICT mentions that,
> "Untrusted devices always use this mode, with an additional layer of
> bounce-buffering such that they cannot gain access to any unrelated data
> within a mapped page.".
> 
> What I am trying to do:
> What I understood from the above description is that the STRICT mode
> provides an additional layer of security for the hardware IOMMU.
> I want to measure the overhead of this additional layer of protection
> (software bounce buffers).
> 
> My questions are:
> 1. Is my understanding correct regarding the software bounce buffers
> being used alongside hardware IOMMU, or do software bounce buffers replace
> the hardware IOMMU?

No.

The strict mode represents that every time a DMA buffer unmaps, the
IOMMU caches (IOTLB and possibly device TLB) will be invalidated and the
cache invalidation will be completed before the unmap is returned.

The IOMMU DMA bounce buffering occurs only when the device has been
marked by the PCI subsystem as an "untrusted device". You can get more
details about "PCI untrusted device" and how IOMMU subsystem addresses
them by reading this:

https://lwn.net/Articles/786558/

> 2. Are untrusted PCI devices use SW bounce buffers by default in the upstream
> kernel?

Yes.

> 
> 3. Are there already available numbers for the performance/memory overhead
> of software bounce buffers?

It's case by case. I haven't seen a complete study on this aspect yet.

> 3. How can I enable/disable software bounce buffers without
> enabling/disabling strict IOTLB invalidations?

You can't disable it. Perhaps you can hack one for your test or
evaluation purpose.

Another option is to use ACPI/DT overriding and tell the OS if a device
is trusted according to your wishes if you are playing with an out-of-
box Linux kernel.

> Details:
> Since I want to measure the overhead of SW bounce buffers, I want to
> know if there is a way to enable/disable only the bounce buffers while
> keeping all other configurations the same. Any suggestions on how to
> properly measure the overhead is welcome.
> 
> I tried to find answers to these questions in kernel mailing lists and
> documentation but I could not find the exact answers.
> References I looked at so far:
> https://www.kernel.org/doc/Documentation/x86/x86_64/boot-options.txt
> https://www.kernel.org/doc/html/v6.3/admin-guide/kernel-parameters.html
> https://lore.kernel.org/lkml/20190730045229.3826-9-baolu.lu@linux.intel.com/T/
> https://lwn.net/Articles/786558/
> 
> I really appreciate any help on this. Thank you in advance.
> 
> Regards,
> Chathura
> 

Best regards,
baolu

  reply	other threads:[~2023-06-06  2:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-03 16:49 IOMMU software bounce buffers and their overhead Chathura Rajapaksha
2023-06-06  2:15 ` Baolu Lu [this message]
2023-06-10 20:50   ` Chathura Rajapaksha

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=f416c0dc-a82b-f608-4c6a-c2441b417bfb@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=chathura.abeyrathne.lk@gmail.com \
    --cc=iommu@lists.linux.dev \
    /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