qemu-e2k/hw/vfio
Eric Farman d6cd66311f vfio-ccw: Do not read region ret_code after write
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>
Message-Id: <20210303160739.2179378-1-farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2021-03-04 11:24:49 +01:00
..
Kconfig hw/vfio: Move the IGD quirk code to a separate file 2020-02-06 11:55:42 -07:00
amd-xgbe.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
ap.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
calxeda-xgmac.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
ccw.c vfio-ccw: Do not read region ret_code after write 2021-03-04 11:24:49 +01:00
common.c vfio: Change default dirty pages tracking behavior during migration 2020-11-23 10:05:58 -07:00
display.c ui: add an optional get_flags callback to GraphicHwOps 2021-02-04 15:58:54 +01:00
igd.c docs: Fix some typos (found by codespell) 2020-11-18 09:29:41 +01:00
meson.build vfio: Add migration region initialization and finalize function 2020-11-01 12:30:50 -07:00
migration.c vfio: Make migration support experimental 2020-11-23 08:29:29 -07:00
pci-quirks.c vfio: add quirk device write method 2021-02-08 15:15:32 +01:00
pci.c qdev: Move softmmu properties to qdev-properties-system.h 2020-12-18 15:20:17 -05:00
pci.h vfio: Make vfio-pci device migration capable 2020-11-01 12:30:51 -07:00
platform.c hw/vfio: Use lock guard macros 2020-11-01 12:30:52 -07:00
spapr.c vfio/spapr: Fix page size calculation 2020-04-07 08:55:10 +10:00
trace-events vfio: Dirty page tracking when vIOMMU is enabled 2020-11-01 12:30:51 -07:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00