qemu-patch-raspberry4/hw/s390x
Tony Krowiak 374b78e370 s390x/vfio-ap: Implement hot plug/unplug of vfio-ap device
Introduces hot plug/unplug support for the vfio-ap device.

To hot plug a vfio-ap device using the QEMU device_add command:

	(qemu) device_add vfio-ap,sysfsdev=$path-to-mdev

	Where $path-to-mdev is the absolute path to the mediated matrix device
	to which AP resources to be used by the guest have been assigned.

A vfio-ap device can be hot plugged only if:

1. A vfio-ap device has not been attached to the virtual machine's ap-bus
   via the QEMU command line or a prior hot plug action.

2. The guest was started with the CPU model feature for AP enabled
   (e.g., -cpu host,ap=on)

To hot unplug a vfio-ap device using the QEMU device_del command:

	(qemu) device_del vfio-ap,sysfsdev=$path-to-mdev

	Where $path-to-mdev is the absolute path to the mediated matrix device
	specified when the vfio-ap device was attached to the virtual machine's
	ap-bus.

A vfio-ap device can be hot unplugged only if:

1. A vfio-ap device has been attached to the virtual machine's ap-bus
   via the QEMU command line or a prior hot plug action.

2. The guest was started with the CPU model feature for AP enabled
   (e.g., -cpu host,ap=on)

Please note that a hot plug handler is not necessary for the vfio-ap device
because the AP matrix configuration for the guest is performed by the
kernel device driver when the vfio-ap device is realized. The vfio-ap device
represents a VFIO mediated device created in the host sysfs for use by a guest.
The mdev device is configured with an AP matrix (i.e., adapters and domains) via
its sysfs attribute interfaces prior to starting the guest or plugging a vfio-ap
device in. When the device is realized, a file descriptor is opened on the mdev
device which results in a callback to the vfio_ap kernel device driver. The
device driver then configures the AP matrix in the guest's SIE state description
from the AP matrix assigned via the mdev device's sysfs interfaces. The AP
devices will be created for the guest when the AP bus running on the guest
subsequently performs its periodic scan for AP devices.

The qdev_simple_device_unplug_cb() callback function is used for the same
reaons; namely, the vfio_ap kernel device driver will perform the AP resource
de-configuration for the guest when the vfio-ap device is unplugged. When the
vfio-ap device is unrealized, the mdev device file descriptor is closed which
results in a callback to the vfio_ap kernel device driver. The device driver
then clears the AP matrix configuration in the guest's SIE state description
and resets all of the affected queues. The AP devices created for the guest
will be removed when the AP bus running on the guest subsequently performs
its periodic scan and finds there are no longer any AP resources assigned to the
guest.

Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Tested-by: Pierre Morel <pmorel@linux.ibm.com>
Message-Id: <1550519397-25359-2-git-send-email-akrowiak@linux.ibm.com>
[CH: adapt to changed qbus_set_hotplug_handler() signature]
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2019-03-04 11:49:31 +01:00
..
3270-ccw.c s390x: remove 's390-squash-mcss' option 2018-08-20 14:18:49 +02:00
ap-bridge.c s390x/vfio-ap: Implement hot plug/unplug of vfio-ap device 2019-03-04 11:49:31 +01:00
ap-device.c s390x/ap: base Adjunct Processor (AP) object model 2018-10-12 11:32:18 +02:00
ccw-device.c s390x/ccw: make sure all ccw devices are properly reset 2018-05-14 17:10:02 +02:00
ccw-device.h s390x: vmstatify config migration for virtio-ccw 2017-07-05 12:16:55 +02:00
css-bridge.c qdev: pass an Object * to qbus_set_hotplug_handler() 2019-02-17 21:54:02 +11:00
css.c hw/s390/ccw.c: Don't take address of packed members 2018-12-20 17:07:24 +01:00
event-facility.c hw/s390x: Allow to configure the consoles with the "-serial" parameter 2018-04-30 10:48:29 +02:00
ipl.c elf: Add optional function ptr to load_elf() to parse ELF notes 2019-02-05 16:50:16 +01:00
ipl.h hw/s390x/ipl: Fix alignment problems of S390IPLState members 2018-10-04 10:32:38 +02:00
Makefile.objs s390x: always provide pci support 2019-02-18 11:25:43 +01:00
s390-ccw.c s390x: remove 's390-squash-mcss' option 2018-08-20 14:18:49 +02:00
s390-pci-bus.c qdev: pass an Object * to qbus_set_hotplug_handler() 2019-02-17 21:54:02 +11:00
s390-pci-bus.h s390x/pci: Drop release timer and replace it with a flag 2019-02-04 13:47:50 +01:00
s390-pci-inst.c s390x/pci: add common function measurement block 2019-01-18 11:52:01 +01:00
s390-pci-inst.h s390x/pci: add common function measurement block 2019-01-18 11:52:01 +01:00
s390-skeys-kvm.c s390x/s390-skeys: Mark the storage key devices with user_creatable = false 2017-08-30 18:23:25 +02:00
s390-skeys.c qapi: make s390 commands depend on TARGET_S390X 2019-02-18 14:44:05 +01:00
s390-stattrib-kvm.c s390x/storage attributes: fix CMMA_BLOCK_SIZE usage 2018-07-11 14:36:54 +02:00
s390-stattrib.c s390x/storage attributes: fix CMMA_BLOCK_SIZE usage 2018-07-11 14:36:54 +02:00
s390-virtio-ccw.c s390x/cpumodel: default enable mepoch for z14 and later 2019-02-18 11:25:43 +01:00
s390-virtio-hcall.c s390x: rename s390-virtio.h to s390-virtio-hcall.h 2017-09-19 18:31:31 +02:00
s390-virtio-hcall.h s390/kvm_virtio/linux-headers: remove traces of old virtio transport 2017-11-24 10:52:05 +01:00
sclp.c s390x/sclp: fix maxram calculation 2018-07-30 17:41:52 +02:00
sclpcpu.c s390x/sclp: clean up sclp masks 2018-03-08 15:49:23 +01:00
sclpquiesce.c s390x/sclp: clean up sclp masks 2018-03-08 15:49:23 +01:00
tod-kvm.c s390x/tod: Properly stop the KVM TOD while the guest is not running 2018-12-12 10:39:28 +01:00
tod-qemu.c s390x/tcg: properly implement the TOD 2018-07-02 10:37:38 +02:00
tod.c s390x/tcg: properly implement the TOD 2018-07-02 10:37:38 +02:00
trace-events trace-events: fix code style: print 0x before hex numbers 2017-08-01 12:13:07 +01:00
vhost-vsock-ccw.c hw/s390x: Move vhost-vsock-ccw code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-9p.c hw/s390x: Move virtio-ccw-9p code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-balloon.c hw/s390x: Move virtio-ccw-balloon code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-blk.c hw/s390x: Move virtio-ccw-blk code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-crypto.c hw/s390x: Move virtio-ccw-crypto code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-gpu.c hw/s390x: Move virtio-ccw-gpu code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-input.c hw/s390x: Move virtio-ccw-input code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-net.c hw/s390x: Move virtio-ccw-net code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-rng.c hw/s390x: Move virtio-ccw-rng code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-scsi.c hw/s390x: Move virtio-ccw-scsi code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw-serial.c hw/s390x: Move virtio-ccw-serial code to a separate file 2018-08-28 17:37:01 +02:00
virtio-ccw.c hw/s390x/virtio-ccw.c: Don't take address of fields in packed structs 2018-12-12 10:39:28 +01:00
virtio-ccw.h s390x/ccw: make sure all ccw devices are properly reset 2018-05-14 17:10:02 +02:00