qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Eric Farman <farman@linux.ibm.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	Matthew Rosato <mjrosato@linux.ibm.com>
Subject: Re: [PATCH] vfio-ccw: Do not read region ret_code after write
Date: Tue, 2 Mar 2021 19:14:02 +0100	[thread overview]
Message-ID: <20210302191402.7bce604b.cohuck@redhat.com> (raw)
In-Reply-To: <20210301195143.4106604-1-farman@linux.ibm.com>

On Mon,  1 Mar 2021 20:51:43 +0100
Eric Farman <farman@linux.ibm.com> wrote:

> A pwrite() call returns the number of bytes written (or -1 on error),
> and vfio-ccw compares this number with the size of the region to
> determine if an error had occurred or not. If they are equal, the
> code reads the ret_code field from the region. However, while the
> kernel sets the ret_code field as necessary, the region and thus
> this field is not "written back" to the user. So the value can only
> be what it was initialized to, which is zero.
> 
> Not harming anything, but it's a puzzle. Let's avoid the confusion
> and just set the return code to zero for this case.

Yes, ret_code seems to be pretty much useless for us: we don't even
look at it when we read the region for interrupt handling. Thankfully,
we don't seem to really need it, as we can rely on errno. (Probably
worth double checking that this is indeed the case.)

I don't suppose we need to handle a hypothetical broken kernel that
returns the wrong size with errno==0?

> 
> Suggested-by: Matthew Rosato <mjrosato@linux.ibm.com>
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
>  hw/vfio/ccw.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index bc78a0ad76..bfd5fd07a5 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -106,7 +106,7 @@ again:
>          error_report("vfio-ccw: write I/O region failed with errno=%d", errno);
>          ret = -errno;
>      } else {
> -        ret = region->ret_code;
> +        ret = 0;
>      }
>      switch (ret) {
>      case 0:
> @@ -194,7 +194,7 @@ again:
>          error_report("vfio-ccw: write cmd region failed with errno=%d", errno);
>          ret = -errno;
>      } else {
> -        ret = region->ret_code;
> +        ret = 0;
>      }
>      switch (ret) {
>      case 0:
> @@ -234,7 +234,7 @@ again:
>          error_report("vfio-ccw: write cmd region failed with errno=%d", errno);
>          ret = -errno;
>      } else {
> -        ret = region->ret_code;
> +        ret = 0;
>      }
>      switch (ret) {
>      case 0:



  reply	other threads:[~2021-03-02 19:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 19:51 [PATCH] vfio-ccw: Do not read region ret_code after write Eric Farman
2021-03-02 18:14 ` Cornelia Huck [this message]
2021-03-02 20:51   ` Eric Farman

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=20210302191402.7bce604b.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@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).