qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <dgibson@redhat.com>
To: Marcel Apfelbaum <marcel@redhat.com>
Cc: "Markus Armbruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org, "Mao Zhongyi" <maozy.fnst@cn.fujitsu.com>,
	jiri@resnulli.us, jasowang@redhat.com,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead error handling
Date: Thu, 25 May 2017 11:02:16 +1000	[thread overview]
Message-ID: <20170525110216.78adc508@umbus.fritz.box> (raw)
In-Reply-To: <231699708.13319856.1495627307861.JavaMail.zimbra@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3007 bytes --]

On Wed, 24 May 2017 08:01:47 -0400 (EDT)
Marcel Apfelbaum <marcel@redhat.com> wrote:

> ----- Original Message -----
> > From: "Markus Armbruster" <armbru@redhat.com>
> > To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> > Cc: qemu-devel@nongnu.org, "Mao Zhongyi" <maozy.fnst@cn.fujitsu.com>, jiri@resnulli.us, jasowang@redhat.com, "Michael
> > S. Tsirkin" <mst@redhat.com>, "Marcel Apfelbaum" <marcel@redhat.com>
> > Sent: Wednesday, May 24, 2017 8:35:04 AM
> > Subject: Re: [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead error handling
> > 
> > Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> >   
> > > Hi Markus,
> > >
> > > On 05/23/2017 06:27 AM, Markus Armbruster wrote:
> > > [...]  
> > >> There's one more cleanup opportunity:
> > >>  
> > > [...]  
> > >>>      if (pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf,
> > >>>      size)) {
> > >>>          return NULL;
> > >>>      }  
> > >>
> > >> None of the pci_dma_read() calls outside rocker check the return value.
> > >> Just as well, because it always returns 0.  Please clean this up in a
> > >> separate followup patch.  
> > >
> > > It may be the correct way to do it but this sounds like we are missing
> > > something somewhere... pci_dma_read() calls pci_dma_rw() which always
> > > returns 0. Why not let it returns void? It is inlined and never used
> > > by address. Else we should document why returning 0 is correct, and
> > > what is the reason to not use a void prototype.
> > >
> > > pci_dma_rw() calls dma_memory_rw() which does return a boolean value,
> > > false on success (MEMTX_OK) and true on error
> > > (MEMTX_ERROR/DECODE_ERROR)  
> > 
> > PCI question.  Michael, Marcel?
> >   
> 
> Hi Markus,
> 
> Looking at the git history, pci_dma_rw used to call cpu_physical_memory_rw
> which, at that time (commit ec17457), returned void. Since the interface dictated
> to return int, 0 is returned as "always OK".
> 
> The callers to pci_dma_read did not bother to check it for obvious reasons (even if they should).
> 
> In the meantime the memory API has changed to allow returning errors, but since the callers of
> pci_dma_rw don't check the return value, why bother to update the PCI DMA?
> 
> History aside (and my speculations above), it seems  the right move is to update
> the return value and check it by callers, but honestly I don't have any idea
> if the emulated devices expect pci dma to fail.
> Adding Paolo and David for more insights.

It seems to me that PCI DMA transfers ought to be able to fail, and
devices ought to be able to handle that (to a limited extent).

After all, what will happen if you try to DMA to PCI addresses that
simply aren't mapped.  Or which are in the domain of a vIOMMU which
wither hasn't mapped those addreses, or has them mapped read-only
(meaning host-to-device only in this context).

-- 
David Gibson <dgibson@redhat.com>
Principal Software Engineer, Virtualization, Red Hat

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2017-05-25  1:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23  4:04 [Qemu-devel] [PATCH v5 0/4] Convert to realize and fix error handling Mao Zhongyi
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead " Mao Zhongyi
2017-05-23  9:27   ` Markus Armbruster
2017-05-23 10:09     ` Mao Zhongyi
2017-05-23 10:52       ` Markus Armbruster
2017-05-24  4:43     ` Philippe Mathieu-Daudé
2017-05-24  5:35       ` Markus Armbruster
2017-05-24 12:01         ` Marcel Apfelbaum
2017-05-25  1:02           ` David Gibson [this message]
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 2/4] net/rocker: Plug memory leak in pci_rocker_init() Mao Zhongyi
2017-05-24  4:48   ` Philippe Mathieu-Daudé
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 3/4] net/rocker: Convert to realize() Mao Zhongyi
2017-05-24  4:48   ` Philippe Mathieu-Daudé
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 4/4] net/rocker: Fix the unusual macro name Mao Zhongyi
2017-05-23  9:16   ` Markus Armbruster
2017-05-24  4:48   ` Philippe Mathieu-Daudé
2017-07-26  3:45 ` [Qemu-devel] [PATCH v5 0/4] Convert to realize and fix error handling Mao Zhongyi
2017-07-26  4:09   ` Jason Wang
2017-07-26  5:11     ` Mao Zhongyi

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=20170525110216.78adc508@umbus.fritz.box \
    --to=dgibson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=maozy.fnst@cn.fujitsu.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).