s390x: vfio-ap: guest dedicated crypto adapters
v6 cover s390x: vfio-ap: guest dedicated crypto adapters
From: Tony Krowiak <[email protected]>
This patch series is the QEMU counterpart to the KVM/kernel support for guest dedicated crypto adapters. The KVM/kernel model is built on the VFIO mediated device framework and provides the infrastructure for granting exclusive guest access to crypto devices installed on the linux host. This patch series introduces a new QEMU command line option, QEMU object model and CPU model features to exploit the KVM/kernel model.
See the detailed specifications for AP virtualization provided by this patch set in docs/vfio-ap.txt for a more complete discussion of the design introduced by this patch series.
Note: This series implements the minimal viable product (MVP) and does not
provide support for hot plug/unplug or migration. The goal of the MVP model is to solidify a base upon which these additional features will be built.
--
v5 => v6 Change log:
===================
* Added reset handling fo vfio-ap device
* Added a bridge/bus to AP device object model - thanks to Halil Pasic
v4 => v5 Change log:
===================
* Added MAINTAINERS entries for VFIO AP
* Added explanation for why we are only supporting zEC12 and newer CPU models.
* Changed CPU model feature qci=on|off to apqci=on|off
* Misc. minor changes
v3 => v4 Change log:
===================
* Made vfio-ap device unpluggable for now
* Renamed command line CPU model feature for QCI: qci=on -> apqci=on
* Removed call to KVM_S390_VM_CRYPTO_INTERPRET_AP ioctl - ioctl was removed from kernel and AP instruction interpretation is set from the VFIO device driver
* Added check to ensure only one vfio-ap device can be configured per guest
* Removed AP instruction interception handlers: AP instructions will be interpreted by default if AP facilities are installed to handle the case where feature ap=on and no vfio-ap device is configured for the guest.
Tony Krowiak (5):
linux-headers: linux header updates for AP support s390x/cpumodel: Set up CPU model for AP device support s390x/ap: base Adjunct Processor (AP) object model s390x/vfio: ap: Introduce VFIO AP device
s390: doc: detailed specifications for AP virtualization
MAINTAINERS | 14 + default-configs/s390x-softmmu.mak | 1 + docs/vfio-ap.txt | 649 +++++++++++++++++++++++++++++++++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 +++++ hw/s390x/ap-device.c | 39 +++ hw/s390x/s390-virtio-ccw.c | 4 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++ include/hw/s390x/ap-bridge.h | 37 +++ include/hw/s390x/ap-device.h | 38 +++ include/hw/vfio/vfio-common.h | 1 + linux-headers/asm-s390/kvm.h | 2 + linux-headers/linux/vfio.h | 2 + target/s390x/cpu_features.c | 3 + target/s390x/cpu_features_def.h | 3 + target/s390x/cpu_models.c | 2 + target/s390x/gen-features.c | 3 + target/s390x/kvm.c | 1 + 19 files changed, 1061 insertions(+), 0 deletions(-) create mode 100644 docs/vfio-ap.txt create mode 100644 hw/s390x/ap-bridge.c create mode 100644 hw/s390x/ap-device.c create mode 100644 hw/vfio/ap.c create mode 100644 include/hw/s390x/ap-bridge.h create mode 100644 include/hw/s390x/ap-device.h
PATCH v6 1/5 linux-headers: linux header updates for AP support
Updates the linux header files in preparation for introduction of the VFIO AP device:
* Added a feature ID to indicate AP facilities are installed
* Added a device attribute to the KVM_S390_VM_CRYPTO group to indicate whether AP instructions are to be interpreted
* Added VFIO device information for AP devices
--- linux-headers/asm-s390/kvm.h | 2 ++ linux-headers/linux/vfio.h | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
linux-headers/asm-s390/kvm.h +2 -0
@@ -130,6 +130,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_AP 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };
@@ -160,6 +161,7 @@ struct kvm_s390_vm_cpu_subfunc {#define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1#define KVM_S390_VM_CRYPTO_DISABLE_AES_KW 2#define KVM_S390_VM_CRYPTO_DISABLE_DEA_KW 3 +#define KVM_S390_VM_CRYPTO_INTERPRET_AP 4/* kvm attributes for migration mode */ #define KVM_S390_VM_MIGRATION_STOP 0
linux-headers/linux/vfio.h +2 -0
@@ -200,6 +200,7 @@ struct vfio_device_info {#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)/* vfio-platform device */ #define VFIO_DEVICE_FLAGS_AMBA (1 << 3)/* vfio-amba device */ #define VFIO_DEVICE_FLAGS_CCW (1 << 4)/* vfio-ccw device */ +#define VFIO_DEVICE_FLAGS_AP (1 << 5)/* vfio-ap device */ __u32 num_regions;/* Max region index + 1 */ __u32 num_irqs;/* Max IRQ index + 1 */ };
@@ -215,6 +216,7 @@ struct vfio_device_info {#define VFIO_DEVICE_API_PLATFORM_STRING "vfio-platform"#define VFIO_DEVICE_API_AMBA_STRING "vfio-amba"#define VFIO_DEVICE_API_CCW_STRING "vfio-ccw" +#define VFIO_DEVICE_API_AP_STRING "vfio-ap"/** * VFIO_DEVICE_GET_REGION_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 8,
Signature · 1 line
1.7.1
PATCH v6 2/5 s390x/cpumodel: Set up CPU model for AP device support
In reply to Tony KrowiakA new CPU model feature and two new CPU model facilities are introduced to support AP devices for a KVM guest.
CPU model features:
1. The KVM_S390_VM_CPU_FEAT_AP CPU model feature indicates that AP facilities are installed. This feature will be enabled by the kernel only if the AP facilities are installed on the linux host. This feature must be turned on from userspace to access AP devices from the KVM guest. The QEMU command line to turn this feature looks something like this:
qemu-system-s390x ... -cpu xxx,ap=on
This feature will be supported for zEC12 and newer CPU models. The feature will not be supported for older models due to testability issues.
CPU model facilities:
1. The S390_FEAT_AP_QUERY_CONFIG_INFO feature indicates the AP Query Configuration Information (QCI) facility is installed. This feature will be enabled by the kernel only if the QCI is installed on the host.
2. The S390_FEAT_AP_FACILITY_TEST feature indicates that the AP Facility Test (APFT) facility is installed. This feature will be enabled by the kernel only if the APFT facility is installed on the host.
--- target/s390x/cpu_features.c | 3 +++ target/s390x/cpu_features_def.h | 3 +++ target/s390x/cpu_models.c | 2 ++ target/s390x/gen-features.c | 3 +++ target/s390x/kvm.c | 1 + 5 files changed, 12 insertions(+), 0 deletions(-)
target/s390x/cpu_features.c +3 -0
@@ -40,8 +40,10 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("srs" ,S390_FEAT_TYPE_STFL ,9 ,"Sense-running-status facility" ),FEAT_INIT ("csske" ,S390_FEAT_TYPE_STFL ,10 ,"Conditional-SSKE facility" ),FEAT_INIT ("ctop" ,S390_FEAT_TYPE_STFL ,11 ,"Configuration-topology facility" ), +FEAT_INIT ("apqci" ,S390_FEAT_TYPE_STFL ,12 ,"Query AP Configuration Information facility" ),FEAT_INIT ("ipter" ,S390_FEAT_TYPE_STFL ,13 ,"IPTE-range facility" ),FEAT_INIT ("nonqks" ,S390_FEAT_TYPE_STFL ,14 ,"Nonquiescing key-setting facility" ), +FEAT_INIT ("apft" ,S390_FEAT_TYPE_STFL ,15 ,"AP Facilities Test facility" ),FEAT_INIT ("etf2" ,S390_FEAT_TYPE_STFL ,16 ,"Extended-translation facility 2" ),FEAT_INIT ("msa-base" ,S390_FEAT_TYPE_STFL ,17 ,"Message-security-assist facility (excluding subfunctions)" ), FEAT_INIT("ldisp", S390_FEAT_TYPE_STFL, 18, "Long-displacement facility"),
@@ -129,6 +131,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT_MISC ("dateh2" ,"DAT-enhancement facility 2" ),FEAT_INIT_MISC ("cmm" ,"Collaborative-memory-management facility" ), +FEAT_INIT_MISC ("ap" ,"AP instructions installed" ),FEAT_INIT ("plo-cl" ,S390_FEAT_TYPE_PLO ,0 ,"PLO Compare and load (32 bit in general registers)" ), FEAT_INIT("plo-clg", S390_FEAT_TYPE_PLO, 1, "PLO Compare and load (64 bit in parameter list)"),
target/s390x/cpu_features_def.h +3 -0
@@ -27,8 +27,10 @@ typedef enum {S390_FEAT_SENSE_RUNNING_STATUS ,S390_FEAT_CONDITIONAL_SSKE ,S390_FEAT_CONFIGURATION_TOPOLOGY , +S390_FEAT_AP_QUERY_CONFIG_INFO ,S390_FEAT_IPTE_RANGE ,S390_FEAT_NONQ_KEY_SETTING , +S390_FEAT_AP_FACILITIES_TEST ,S390_FEAT_EXTENDED_TRANSLATION_2 ,S390_FEAT_MSA , S390_FEAT_LONG_DISPLACEMENT,
@@ -118,6 +120,7 @@ typedef enum {/* Misc */ S390_FEAT_DAT_ENH_2 ,S390_FEAT_CMM , +S390_FEAT_AP ,/* PLO */ S390_FEAT_PLO_CL,
target/s390x/cpu_models.c +2 -0
@@ -771,6 +771,8 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_PRNO_TRNG_QRTCR, S390_FEAT_MSA_EXT_5 }, { S390_FEAT_PRNO_TRNG, S390_FEAT_MSA_EXT_5 }, { S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 }, + { S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP }, + { S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP }, };int i;
target/s390x/gen-features.c +3 -0
@@ -447,6 +447,9 @@ static uint16_t full_GEN12_GA1[] = {S390_FEAT_ADAPTER_INT_SUPPRESSION ,S390_FEAT_EDAT_2 ,S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2 , +S390_FEAT_AP_QUERY_CONFIG_INFO , +S390_FEAT_AP_FACILITIES_TEST , + S390_FEAT_AP, }; static uint16_t full_GEN12_GA2[] = {
target/s390x/kvm.c +1 -0
@@ -2081,6 +2081,7 @@ static int kvm_to_feat[][2] = { { KVM_S390_VM_CPU_FEAT_PFMFI, S390_FEAT_SIE_PFMFI}, { KVM_S390_VM_CPU_FEAT_SIGPIF, S390_FEAT_SIE_SIGPIF}, { KVM_S390_VM_CPU_FEAT_KSS, S390_FEAT_SIE_KSS}, + { KVM_S390_VM_CPU_FEAT_AP, S390_FEAT_AP}, };static int query_cpu_feat (S390FeatBitmap features)
Signature · 1 line
1.7.1
PATCH v6 3/5 s390x/ap: base Adjunct Processor (AP) object model
In reply to Tony KrowiakFrom: Tony Krowiak <[email protected]>
Introduces the base object model for virtualizing AP devices.
--- MAINTAINERS | 12 +++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 ++++++++++++++++++++++++++++++++++++++++++ hw/s390x/ap-device.c | 39 +++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 4 ++ include/hw/s390x/ap-bridge.h | 37 ++++++++++++++++++++ include/hw/s390x/ap-device.h | 38 +++++++++++++++++++++ 7 files changed, 208 insertions(+), 0 deletions(-) create mode 100644 hw/s390x/ap-bridge.c create mode 100644 hw/s390x/ap-device.c create mode 100644 include/hw/s390x/ap-bridge.h create mode 100644 include/hw/s390x/ap-device.h
MAINTAINERS +12 -0
@@ -1183,6 +1183,18 @@ F: include/hw/s390x/s390-ccw.h T: git git://github.com/cohuck/qemu.git s390-next L: [email protected] +vfio-ap +M: Christian Borntraeger <[email protected]> +M: Tony Krowiak <[email protected]> +M: Halil Pasic <[email protected]> +M: Pierre Morel <[email protected]> +S: Supported +F: hw/s390x/ap-device.c +F: hw/s390x/ap-bridge.c +F: include/hw/s390x/ap-device.h +F: include/hw/s390x/ap-bridge.h +L: [email protected] + vhost M: Michael S. Tsirkin <[email protected]> S: Supported
hw/s390x/Makefile.objs +2 -0
@@ -17,3 +17,5 @@ obj-y += s390-stattrib.o obj-$(CONFIG_KVM) += s390-skeys-kvm.o obj-$(CONFIG_KVM) += s390-stattrib-kvm.o obj-y += s390-ccw.o +obj-y += ap-device.o +obj-y += ap-bridge.o
hw/s390x/ap-bridge.c new file +76 -0
76 lines not on this page · raw message
hw/s390x/ap-device.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Adjunct Processor (AP) matrix device +* +* Copyright 2018 IBM Corp. +* Author(s): Tony Krowiak <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ +#include "qemu/osdep.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "hw/qdev.h" +#include "hw/s390x/ap-device.h" + +static void ap_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->desc ="AP device class" ; + dc->hotpluggable = false; +} + +static const TypeInfo ap_device_info = { + .name =AP_DEVICE_TYPE , + .parent =TYPE_DEVICE , + .instance_size =sizeof (APDevice), + .class_size =sizeof (APDeviceClass), + .class_init = ap_class_init, + .abstract = true, +}; + +static void ap_device_register (void ) +{ +type_register_static (&ap_device_info); +} + +type_init (ap_device_register)
hw/s390x/s390-virtio-ccw.c +4 -0
@@ -32,6 +32,7 @@#include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/css-bridge.h" +#include "hw/s390x/ap-bridge.h" #include "migration/register.h" #include "cpu_models.h" #include "hw/nmi.h"
@@ -314,6 +315,9 @@ static void ccw_init(MachineState *machine)/* init the SIGP facility */ s390_init_sigp (); +/* create AP bridge and bus(es) */ +s390_init_ap (); +/* get a BUS */ css_bus =virtual_css_bus_init (); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
include/hw/s390x/ap-bridge.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* ap bridge +* +* Copyright 2018 IBM Corp. +* Author(s): Halil Pasic <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ + +#ifndef HW_S390X_AP_BRIDGE_H +#define HW_S390X_AP_BRIDGE_H +#include "qom/object.h" +#include "hw/qdev-core.h" +#include "hw/sysbus.h" + +typedef struct APBridge { +SysBusDevice sysbus_dev; +bool css_dev_path; +}APBridge ; + +#define TYPE_AP_BRIDGE "ap-bridge" +#define AP_BRIDGE (obj) \ + OBJECT_CHECK(APBridge, (obj), TYPE_AP_BRIDGE) + +typedef struct VFIOAPBus { +BusState parent_obj; +}VFIOAPBus ; + +#define TYPE_VFIO_AP_BUS "vfio-ap-bus" +#define VFIO_AP_BUS (obj) \ + OBJECT_CHECK(VFIOAPBus, (obj), TYPE_VFIO_AP_BUS) + +void s390_init_ap (void ); + +#endif
include/hw/s390x/ap-device.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Adjunct Processor (AP) matrix device interfaces +* +* Copyright 2018 IBM Corp. +* Author(s): Tony Krowiak <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ +#ifndef HW_S390X_AP_DEVICE_H +#define HW_S390X_AP_DEVICE_H + +#define AP_DEVICE_TYPE "ap-device" + +typedef struct APDevice { +DeviceState parent_obj; +}APDevice ; + +typedef struct APDeviceClass { +DeviceClass parent_class; +}APDeviceClass ; + +static inline APDevice *to_ap_dev (DeviceState *dev) +{ +return container_of (dev, APDevice, parent_obj); +} + +#define AP_DEVICE (obj) \ + OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE) + +#define AP_DEVICE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(APDeviceClass, (obj), AP_DEVICE_TYPE) + +#define AP_DEVICE_CLASS (klass) \ + OBJECT_CLASS_CHECK(APDeviceClass, (klass), AP_DEVICE_TYPE) + +#endif /* HW_S390X_AP_DEVICE_H */
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v6 3/5] s390x/ap: base Adjunct Processor (AP) object model
Quoted 1 line · On Fri, 29 Jun 2018 18:48:01 -0400 Tony Krowiak <[email protected]>…
From: Tony Krowiak <[email protected]>
You may want to switch your sending address to this one as well.
Quoted 36 lines
Introduces the base object model for virtualizing AP devices.
Signed-off-by Tony Krowiak <[email protected]>--- MAINTAINERS | 12 +++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 ++++++++++++++++++++++++++++++++++++++++++ hw/s390x/ap-device.c | 39 +++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 4 ++ include/hw/s390x/ap-bridge.h | 37 ++++++++++++++++++++ include/hw/s390x/ap-device.h | 38 +++++++++++++++++++++ 7 files changed, 208 insertions(+), 0 deletions(-) create mode 100644 hw/s390x/ap-bridge.c create mode 100644 hw/s390x/ap-device.c create mode 100644 include/hw/s390x/ap-bridge.h create mode 100644 include/hw/s390x/ap-device.hhw/s390x/ap-bridge.c new file +11
-0@@ -0,0 +1,76 @@ +/* +* ap bridge +* +* Copyright 2018 IBM Corp. +* Author(s): Halil Pasic <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ +#include "qemu/osdep.h"
hw/s390x/ap-bridge.c line 21
Quoted 10 lines
hw/s390x/ap-bridge.c new file +10
-0+#include "qapi/error.h" +#include "hw/sysbus.h" +#include "qemu/bitops.h" +#include "hw/s390x/ap-bridge.h" +#include "cpu.h" + +static char *vfio_ap_bus_get_dev_path (DeviceState *dev) +{ +/* at most one */ +return g_strdup_printf ("/1" );
Looks a bit odd... add 'ap'? Start counting with 0?
Quoted 2 lines
hw/s390x/ap-bridge.c new file +2
-0+} +
(...)
Quoted 16 lines
include/hw/s390x/ap-bridge.h new file +10
-0@@ -0,0 +1,37 @@ +/* +* ap bridge +* +* Copyright 2018 IBM Corp. +* Author(s): Halil Pasic <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/
include/hw/s390x/ap-bridge.h line 20
Quoted 10 lines
include/hw/s390x/ap-bridge.h new file +10
-0+ +#ifndef HW_S390X_AP_BRIDGE_H +#define HW_S390X_AP_BRIDGE_H +#include "qom/object.h" +#include "hw/qdev-core.h" +#include "hw/sysbus.h" + +typedef struct APBridge { + SysBusDevice sysbus_dev; + bool css_dev_path;
Probable copy-and-paste error?
Quoted 7 lines
include/hw/s390x/ap-bridge.h new file +7
-0+} APBridge; + +#define TYPE_AP_BRIDGE "ap-bridge" +#define AP_BRIDGE (obj) \ + OBJECT_CHECK(APBridge, (obj), TYPE_AP_BRIDGE) + +typedef struct VFIOAPBus {
include/hw/s390x/ap-bridge.h line 37
Quoted 10 lines
include/hw/s390x/ap-bridge.h new file +10
-0+ BusState parent_obj; +} VFIOAPBus; + +#define TYPE_VFIO_AP_BUS "vfio-ap-bus" +#define VFIO_AP_BUS (obj) \ + OBJECT_CHECK(VFIOAPBus, (obj), TYPE_VFIO_AP_BUS) + +void s390_init_ap (void ); + +#endif
Else, looks sane to me.
PATCH v6 4/5 s390x/vfio: ap: Introduce VFIO AP device
In reply to Tony KrowiakIntroduces a VFIO based AP device. The device is defined via the QEMU command line by specifying:
-device vfio-ap,sysfsdev=<path-to-mediated-matrix-device>
There may be only one vfio-ap device configured for a guest.
The mediated matrix device is created by the VFIO AP device driver by writing a UUID to a sysfs attribute file (see docs/vfio-ap.txt). The mediated matrix device will be named after the UUID. Symbolic links to the $uuid are created in many places, so the path to the mediated matrix device $uuid can be specified in any of the following ways:
/sys/devices/vfio_ap/matrix/$uuid /sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/devices/$uuid /sys/bus/mdev/devices/$uuid/sys/bus/mdev/drivers/vfio_mdev/$uuid
When the vfio-ap device is realized, it acquires and opens the VFIO iommu group to which the mediated matrix device is bound. This causes a VFIO group notification event to be signaled. The vfio_ap device driver's group notification handler will get called at which time the device driver will configure the the AP devices to which the guest will be granted access.
--- MAINTAINERS | 1 + default-configs/s390x-softmmu.mak | 1 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 1 + 5 files changed, 187 insertions(+), 0 deletions(-) create mode 100644 hw/vfio/ap.c
MAINTAINERS +1 -0
@@ -1193,6 +1193,7 @@ F: hw/s390x/ap-device.c F: hw/s390x/ap-bridge.c F: include/hw/s390x/ap-device.h F: include/hw/s390x/ap-bridge.h +F: hw/vfio/ap.c L: [email protected] vhost
default-configs/s390x-softmmu.mak +1 -0
@@ -7,3 +7,4 @@ CONFIG_S390_FLIC=y CONFIG_S390_FLIC_KVM=$(CONFIG_KVM) CONFIG_VFIO_CCW=$(CONFIG_LINUX) CONFIG_WDT_DIAG288=y +CONFIG_VFIO_AP=$(CONFIG_LINUX)
hw/vfio/Makefile.objs +1 -0
@@ -6,4 +6,5 @@ obj-$(CONFIG_SOFTMMU) += platform.o obj-$(CONFIG_VFIO_XGMAC) += calxeda-xgmac.o obj-$(CONFIG_VFIO_AMD_XGBE) += amd-xgbe.o obj-$(CONFIG_SOFTMMU) += spapr.o +obj-$(CONFIG_VFIO_AP) += ap.o endif
hw/vfio/ap.c new file +183 -0
183 lines not on this page · raw message
include/hw/vfio/vfio-common.h +1 -0
@@ -37,6 +37,7 @@ enum {VFIO_DEVICE_TYPE_PCI =0 ,VFIO_DEVICE_TYPE_PLATFORM =1 ,VFIO_DEVICE_TYPE_CCW =2 , + VFIO_DEVICE_TYPE_AP = 3, }; typedef struct VFIOMmap {
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v6 4/5] s390x/vfio: ap: Introduce VFIO AP device
Quoted 27 lines · On Fri, 29 Jun 2018 18:48:02 -0400 Tony Krowiak <[email protected]>…
Introduces a VFIO based AP device. The device is defined via the QEMU command line by specifying:
-device vfio-ap,sysfsdev=<path-to-mediated-matrix-device>
There may be only one vfio-ap device configured for a guest.
The mediated matrix device is created by the VFIO AP device driver by writing a UUID to a sysfs attribute file (see
docs/vfio-ap.txt). The mediated matrix device will be named after the UUID. Symbolic links to the $uuid are created in many places, so the path to the mediated matrix device $uuid can be specified in any of the following ways:
/sys/devices/vfio_ap/matrix/$uuid/sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/devices/$uuid/sys/bus/mdev/devices/$uuid/sys/bus/mdev/drivers/vfio_mdev/$uuidWhen the vfio-ap device is realized, it acquires and opens the VFIO iommu group to which the mediated matrix device is bound. This causes a VFIO group notification event to be signaled. The
vfio_apdevice driver's group notification handler will get called at which time the device driver will configure the the AP devices to which the guest will be granted access.
Quoted 2 lines
Signed-off-by Tony Krowiak <[email protected]>Signed-off-by Tony Krowiak <[email protected]>
Nit: You may want to decide one address or the other :)
Quoted 8 lines
--- MAINTAINERS | 1 + default-configs/s390x-softmmu.mak | 1 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 1 + 5 files changed, 187 insertions(+), 0 deletions(-) create mode 100644 hw/vfio/ap.c
No complaints about the code from me.
Re: [Qemu-devel] [PATCH v6 4/5] s390x/vfio: ap: Introduce VFIO AP device
Quoted 30 lines · Cornelia Huck
Quoted 27 lines · On Fri, 29 Jun 2018 18:48:02 -0400 Tony Krowiak <[email protected]>…
Introduces a VFIO based AP device. The device is defined via the QEMU command line by specifying:
-device vfio-ap,sysfsdev=<path-to-mediated-matrix-device>
There may be only one vfio-ap device configured for a guest.
The mediated matrix device is created by the VFIO AP device driver by writing a UUID to a sysfs attribute file (see
docs/vfio-ap.txt). The mediated matrix device will be named after the UUID. Symbolic links to the $uuid are created in many places, so the path to the mediated matrix device $uuid can be specified in any of the following ways:
/sys/devices/vfio_ap/matrix/$uuid/sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/devices/$uuid/sys/bus/mdev/devices/$uuid/sys/bus/mdev/drivers/vfio_mdev/$uuidWhen the vfio-ap device is realized, it acquires and opens the VFIO iommu group to which the mediated matrix device is bound. This causes a VFIO group notification event to be signaled. The
vfio_apdevice driver's group notification handler will get called at which time the device driver will configure the the AP devices to which the guest will be granted access.
Quoted 3 lines
Quoted 2 lines
Signed-off-by Tony Krowiak <[email protected]>Signed-off-by Tony Krowiak <[email protected]>Nit: You may want to decide one address or the other :)
Unintentional .... I'll correct it.
Quoted 10 lines
Quoted 9 lines
--- MAINTAINERS | 1 + default-configs/s390x-softmmu.mak | 1 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 1 + 5 files changed, 187 insertions(+), 0 deletions(-)create mode 100644
hw/vfio/ap.cNo complaints about the code from me.
I like no complaints:)
Quoted 1 line
PATCH v6 5/5 s390: doc: detailed specifications for AP virtualization
In reply to Tony KrowiakThis patch provides documentation describing the AP architecture and design concepts behind the virtualization of AP devices. It also includes an example of how to configure AP devices for exclusive use of KVM guests.
--- MAINTAINERS | 1 + docs/vfio-ap.txt | 649 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 650 insertions(+), 0 deletions(-) create mode 100644 docs/vfio-ap.txt
MAINTAINERS +1 -0
@@ -1194,6 +1194,7 @@ F: hw/s390x/ap-bridge.c F: include/hw/s390x/ap-device.h F: include/hw/s390x/ap-bridge.h F: hw/vfio/ap.c +F: docs/vfio-ap.txt L: [email protected] vhost
docs/vfio-ap.txt new file +649 -0
649 lines not on this page · raw message
Signature · 1 line
1.7.1
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v6 0/5] s390x: vfio-ap: guest dedicated crypto adapters
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'151e47ee38 s390: doc: detailed specifications for AP virtualization 59c7d58586 s390x/vfio: ap: Introduce VFIO AP device 7ec8925cc0 s390x/ap: base Adjunct Processor (AP) object model 56a56760da s390x/cpumodel: Set up CPU model for AP device support f4b39498a8 linux-headers: linux header updates for AP support
=== OUTPUT BEGIN ===
Checking PATCH 1/5: linux-headers: linux header updates for AP support... Checking PATCH 2/5: s390x/cpumodel: Set up CPU model for AP device support...
ERROR: line over 90 characters
#48: FILE: target/s390x/cpu_features.c:43:
+ FEAT_INIT("apqci", S390_FEAT_TYPE_STFL, 12, "Query AP Configuration Information facility"),
total: 1 errors, 0 warnings, 58 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 3/5: s390x/ap: base Adjunct Processor (AP) object model...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #45:
new file mode 100644
total: 0 errors, 1 warnings, 229 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 4/5: s390x/vfio: ap: Introduce VFIO AP device...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #69:
new file mode 100644
total: 0 errors, 1 warnings, 206 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 5/5: s390: doc: detailed specifications for AP virtualization...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #28:
new file mode 100644
total: 0 errors, 1 warnings, 656 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Ping
Quoted 80 lines · Tony Krowiak
From: Tony Krowiak <[email protected]>
This patch series is the QEMU counterpart to the KVM/kernel support for guest dedicated crypto adapters. The KVM/kernel model is built on the VFIO mediated device framework and provides the infrastructure for granting exclusive guest access to crypto devices installed on the linux host. This patch series introduces a new QEMU command line option, QEMU object model and CPU model features to exploit the KVM/kernel model.
See the detailed specifications for AP virtualization provided by this patch set in
docs/vfio-ap.txtfor a more complete discussion of the design introduced by this patch series.Note: This series implements the minimal viable product (MVP) and does not
provide support for hot plug/unplug or migration. The goal of the MVP model is to solidify a base upon which these additional features will be built.--
v5 => v6 Change log:
===================
* Added reset handling fo vfio-ap device
* Added a bridge/bus to AP device object model - thanks to Halil Pasicv4 => v5 Change log:
===================
* AddedMAINTAINERSentries for VFIO AP
* Added explanation for why we are only supporting zEC12 and newer CPU models.
* Changed CPU model feature qci=on|off to apqci=on|off
* Misc. minor changesv3 => v4 Change log:
===================
* Made vfio-ap device unpluggable for now
* Renamed command line CPU model feature for QCI: qci=on -> apqci=on
* Removed call toKVM_S390_VM_CRYPTO_INTERPRET_APioctl - ioctl was removed from kernel and AP instruction interpretation is set from the VFIO device driver
* Added check to ensure only one vfio-ap device can be configured per guest
* Removed AP instruction interception handlers: AP instructions will be interpreted by default if AP facilities are installed to handle the case where feature ap=on and no vfio-ap device is configured for the guest.Tony Krowiak (5):
linux-headers: linux header updates for AP support s390x/cpumodel: Set up CPU model for AP device support s390x/ap: base Adjunct Processor (AP) object model s390x/vfio: ap: Introduce VFIO AP device
s390: doc: detailed specifications for AP virtualizationMAINTAINERS | 14 + default-configs/s390x-softmmu.mak | 1 + docs/vfio-ap.txt | 649 +++++++++++++++++++++++++++++++++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 +++++ hw/s390x/ap-device.c | 39 +++ hw/s390x/s390-virtio-ccw.c | 4 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++ include/hw/s390x/ap-bridge.h | 37 +++ include/hw/s390x/ap-device.h | 38 +++ include/hw/vfio/vfio-common.h | 1 + linux-headers/asm-s390/kvm.h | 2 + linux-headers/linux/vfio.h | 2 + target/s390x/cpu_features.c | 3 + target/s390x/cpu_features_def.h | 3 + target/s390x/cpu_models.c | 2 + target/s390x/gen-features.c | 3 + target/s390x/kvm.c | 1 + 19 files changed, 1061 insertions(+), 0 deletions(-)create mode 100644
docs/vfio-ap.txt
create mode 100644hw/s390x/ap-bridge.c
create mode 100644hw/s390x/ap-device.c
create mode 100644hw/vfio/ap.c
create mode 100644include/hw/s390x/ap-bridge.h
create mode 100644include/hw/s390x/ap-device.h
Quoted 1 line · On Tue, 7 Aug 2018 18:41:29 -0400 Tony Krowiak <[email protected]> wrote:
Ping
Maybe send a new version when the kernel part is sent again? I don't think I had any further comments.
Quoted 83 lines · Tony Krowiak
Quoted 80 lines
From: Tony Krowiak <[email protected]>
This patch series is the QEMU counterpart to the KVM/kernel support for guest dedicated crypto adapters. The KVM/kernel model is built on the VFIO mediated device framework and provides the infrastructure for granting exclusive guest access to crypto devices installed on the linux host. This patch series introduces a new QEMU command line option, QEMU object model and CPU model features to exploit the KVM/kernel model.
See the detailed specifications for AP virtualization provided by this patch set in
docs/vfio-ap.txtfor a more complete discussion of the design introduced by this patch series.Note: This series implements the minimal viable product (MVP) and does not
provide support for hot plug/unplug or migration. The goal of the MVP model is to solidify a base upon which these additional features will be built.--
v5 => v6 Change log:
===================
* Added reset handling fo vfio-ap device
* Added a bridge/bus to AP device object model - thanks to Halil Pasicv4 => v5 Change log:
===================
* AddedMAINTAINERSentries for VFIO AP
* Added explanation for why we are only supporting zEC12 and newer CPU models.
* Changed CPU model feature qci=on|off to apqci=on|off
* Misc. minor changesv3 => v4 Change log:
===================
* Made vfio-ap device unpluggable for now
* Renamed command line CPU model feature for QCI: qci=on -> apqci=on
* Removed call toKVM_S390_VM_CRYPTO_INTERPRET_APioctl - ioctl was removed from kernel and AP instruction interpretation is set from the VFIO device driver
* Added check to ensure only one vfio-ap device can be configured per guest
* Removed AP instruction interception handlers: AP instructions will be interpreted by default if AP facilities are installed to handle the case where feature ap=on and no vfio-ap device is configured for the guest.Tony Krowiak (5):
linux-headers: linux header updates for AP support s390x/cpumodel: Set up CPU model for AP device support s390x/ap: base Adjunct Processor (AP) object model s390x/vfio: ap: Introduce VFIO AP device
s390: doc: detailed specifications for AP virtualizationMAINTAINERS | 14 + default-configs/s390x-softmmu.mak | 1 + docs/vfio-ap.txt | 649 +++++++++++++++++++++++++++++++++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 +++++ hw/s390x/ap-device.c | 39 +++ hw/s390x/s390-virtio-ccw.c | 4 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++ include/hw/s390x/ap-bridge.h | 37 +++ include/hw/s390x/ap-device.h | 38 +++ include/hw/vfio/vfio-common.h | 1 + linux-headers/asm-s390/kvm.h | 2 + linux-headers/linux/vfio.h | 2 + target/s390x/cpu_features.c | 3 + target/s390x/cpu_features_def.h | 3 + target/s390x/cpu_models.c | 2 + target/s390x/gen-features.c | 3 + target/s390x/kvm.c | 1 + 19 files changed, 1061 insertions(+), 0 deletions(-)create mode 100644
docs/vfio-ap.txt
create mode 100644hw/s390x/ap-bridge.c
create mode 100644hw/s390x/ap-device.c
create mode 100644hw/vfio/ap.c
create mode 100644include/hw/s390x/ap-bridge.h
create mode 100644include/hw/s390x/ap-device.h
Quoted 6 lines · Cornelia Huck
Quoted 1 line · On Tue, 7 Aug 2018 18:41:29 -0400 Tony Krowiak <[email protected]> wrote:
Ping
Maybe send a new version when the kernel part is sent again? I don't think I had any further comments.
I'll consider that.
Quoted 82 lines
Quoted 82 lines · Tony Krowiak
Quoted 80 lines
From: Tony Krowiak <[email protected]>
This patch series is the QEMU counterpart to the KVM/kernel support for guest dedicated crypto adapters. The KVM/kernel model is built on the VFIO mediated device framework and provides the infrastructure for granting exclusive guest access to crypto devices installed on the linux host. This patch series introduces a new QEMU command line option, QEMU object model and CPU model features to exploit the KVM/kernel model.
See the detailed specifications for AP virtualization provided by this patch set in
docs/vfio-ap.txtfor a more complete discussion of the design introduced by this patch series.Note: This series implements the minimal viable product (MVP) and does not
provide support for hot plug/unplug or migration. The goal of the MVP model is to solidify a base upon which these additional features will be built.--
v5 => v6 Change log:
===================
* Added reset handling fo vfio-ap device
* Added a bridge/bus to AP device object model - thanks to Halil Pasicv4 => v5 Change log:
===================
* AddedMAINTAINERSentries for VFIO AP
* Added explanation for why we are only supporting zEC12 and newer CPU models.
* Changed CPU model feature qci=on|off to apqci=on|off
* Misc. minor changesv3 => v4 Change log:
===================
* Made vfio-ap device unpluggable for now
* Renamed command line CPU model feature for QCI: qci=on -> apqci=on
* Removed call toKVM_S390_VM_CRYPTO_INTERPRET_APioctl - ioctl was removed from kernel and AP instruction interpretation is set from the VFIO device driver
* Added check to ensure only one vfio-ap device can be configured per guest
* Removed AP instruction interception handlers: AP instructions will be interpreted by default if AP facilities are installed to handle the case where feature ap=on and no vfio-ap device is configured for the guest.Tony Krowiak (5):
linux-headers: linux header updates for AP support s390x/cpumodel: Set up CPU model for AP device support s390x/ap: base Adjunct Processor (AP) object model s390x/vfio: ap: Introduce VFIO AP device s390: doc: detailed specifications for AP virtualizationMAINTAINERS | 14 + default-configs/s390x-softmmu.mak | 1 + docs/vfio-ap.txt | 649 +++++++++++++++++++++++++++++++++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 +++++ hw/s390x/ap-device.c | 39 +++ hw/s390x/s390-virtio-ccw.c | 4 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 183 +++++++++++ include/hw/s390x/ap-bridge.h | 37 +++ include/hw/s390x/ap-device.h | 38 +++ include/hw/vfio/vfio-common.h | 1 + linux-headers/asm-s390/kvm.h | 2 + linux-headers/linux/vfio.h | 2 + target/s390x/cpu_features.c | 3 + target/s390x/cpu_features_def.h | 3 + target/s390x/cpu_models.c | 2 + target/s390x/gen-features.c | 3 + target/s390x/kvm.c | 1 + 19 files changed, 1061 insertions(+), 0 deletions(-)create mode 100644
docs/vfio-ap.txtcreate mode 100644hw/s390x/ap-bridge.ccreate mode 100644hw/s390x/ap-device.ccreate mode 100644hw/vfio/ap.c
create mode 100644include/hw/s390x/ap-bridge.hcreate mode 100644include/hw/s390x/ap-device.h