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 v2] vfio-ccw: Do not read region ret_code after write
Date: Thu, 4 Mar 2021 13:09:13 +0100 [thread overview]
Message-ID: <20210304130913.115724dd.cohuck@redhat.com> (raw)
In-Reply-To: <20210303160739.2179378-1-farman@linux.ibm.com>
On Wed, 3 Mar 2021 17:07:39 +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 not equal, this is a failure and the errno is used to
> determine exactly how things failed. An errno of zero is possible
> (though unlikely) in this situation and would be translated to a
> successful operation.
>
> If they ARE equal, the ret_code field is read from the region to
> determine how to proceed. 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.
>
> So, let's convert an unexpected length with errno of zero to a
> return code of -EFAULT, and explicitly set an expected length to
> a return code of zero. This will be a little safer and clearer.
>
> Suggested-by: Matthew Rosato <mjrosato@linux.ibm.com>
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
>
> Notes:
> Changes v1->v2:
> - Add code to handle an unexpected length being returned,
> but errno is not set. [CH]
>
> v1: https://lore.kernel.org/qemu-devel/cc440ee8-28c5-3208-19db-ebb48ea60e9d@linux.ibm.com/
>
> hw/vfio/ccw.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Thanks, applied.
prev parent reply other threads:[~2021-03-04 12:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-03 16:07 [PATCH v2] vfio-ccw: Do not read region ret_code after write Eric Farman
2021-03-04 12:09 ` Cornelia Huck [this message]
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=20210304130913.115724dd.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).