qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Alexander Bulekov <alxndr@bu.edu>
Cc: qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Mauro Matteo Cascella" <mcascell@redhat.com>,
	"Qiuhao Li" <Qiuhao.Li@outlook.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Li Qiang" <liq3ea@gmail.com>, "Thomas Huth" <thuth@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Bandan Das" <bsd@redhat.com>,
	"Edgar E . Iglesias" <edgar.iglesias@gmail.com>,
	"Darren Kenny" <darren.kenny@oracle.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Jon Maloy" <jmaloy@redhat.com>, "Siqi Chen" <coc.cyqh@gmail.com>
Subject: Re: [PATCH v3 1/7] memory: associate DMA accesses with the initiator Device
Date: Mon, 14 Nov 2022 15:31:54 -0500	[thread overview]
Message-ID: <CAJSP0QXq=3vL-+A=AXD7dKaUSLNoM1aTnucE_hQSzfUJvGuZBA@mail.gmail.com> (raw)
In-Reply-To: <20221028191648.964076-2-alxndr@bu.edu>

The _guarded() calls are required in BHs, timers, fd read/write
callbacks, etc because we're no longer in the memory region dispatch
code with the reentrancy guard set. It's not clear to me whether the
_guarded() calls are actually required in most of these patches
though? Do you plan to convert every DMA API call to a _guarded() call
in the future?

I'm asking because coming up with an API that doesn't require these
code changes will reduce code churn and make existing code safe.

Does it make sense to separate the DMA API and the reentrancy guard
API? That way the reentrancy guard can be put in place once in any BH,
timer, etc callback and then the existing DMA APIs are used within
those callbacks without new _guarded() APIs.

This approach also reduces the number of times that the guard is
toggled. The current approach is fine-grained (per DMA API call) so
the guard needs to be toggled all the time, e.g. in DMA sglist loops.

If we want the compiler to prevent DMA API calls without a reentrancy
guard, then AddressSpace pointers can be hidden behind an API that
sets the guard. This ensures that you cannot access an address space
unless you have a reentrancy guard.

Stefan


  parent reply	other threads:[~2022-11-14 23:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 19:16 [PATCH v3 0/7] memory: prevent dma-reentracy issues Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 1/7] memory: associate DMA accesses with the initiator Device Alexander Bulekov
2022-11-14 20:08   ` Stefan Hajnoczi
2022-11-14 20:31   ` Stefan Hajnoczi [this message]
2022-11-15 16:19   ` Peter Xu
2022-11-15 16:49     ` Peter Maydell
2022-11-15 17:44     ` Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 2/7] dma-helpers: switch to guarded DMA accesses Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 3/7] ahci: switch to guarded DMA acccesses Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 4/7] sdhci: switch to guarded DMA accesses Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 5/7] ehci: " Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 6/7] xhci: " Alexander Bulekov
2022-10-28 19:16 ` [PATCH v3 7/7] usb/libhw: " Alexander Bulekov
2022-11-07 17:09 ` [PATCH v3 0/7] memory: prevent dma-reentracy issues Alexander Bulekov
2022-11-10 20:50 ` Stefan Hajnoczi
2022-11-10 20:53   ` Michael S. Tsirkin
2022-11-10 22:50   ` Peter Maydell
2022-11-15 11:28   ` Philippe Mathieu-Daudé

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='CAJSP0QXq=3vL-+A=AXD7dKaUSLNoM1aTnucE_hQSzfUJvGuZBA@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=Qiuhao.Li@outlook.com \
    --cc=alxndr@bu.edu \
    --cc=berrange@redhat.com \
    --cc=bin.meng@windriver.com \
    --cc=bsd@redhat.com \
    --cc=coc.cyqh@gmail.com \
    --cc=darren.kenny@oracle.com \
    --cc=david@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=jasowang@redhat.com \
    --cc=jmaloy@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=lvivier@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mcascell@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).