s390x updates
The following changes since commit 75e50c80e051423a6f55a34ee4a1eec842444a5b:
Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2018-10-10' into staging (2018-10-11 10:43:37 +0100)
are available in the Git repository at:
git://github.com/cohuck/qemu tags/s390x-20181012
for you to fetch changes up to 0161215d435ef5680c4623bcbdfe89ce5b35cf42:
hw/s390x: Include the tod-qemu also for builds with --disable-tcg (2018-10-12 11:32:19 +0200)
----------------------------------------------------------------
More s390x updates:
- introduce support for vfio-ap (s390 crypto devices), including a Linux headers update to get the new interfaces
- the usual fixing + cleanup
----------------------------------------------------------------
Cornelia Huck (1):
linux-headers: update
Thomas Huth (2):
target/s390x/excp_helper: Remove DPRINTF() macro hw/s390x: Include the tod-qemu also for builds with --disable-tcg
Tony Krowiak (5):
s390x/cpumodel: Set up CPU model for AP device support s390x/kvm: enable AP instruction interpretation for guest s390x/ap: base Adjunct Processor (AP) object model s390x/vfio: ap: Introduce VFIO AP device
s390: doc: detailed specifications for AP virtualization
MAINTAINERS | 16 + default-configs/s390x-softmmu.mak | 1 + docs/vfio-ap.txt | 825 +++++++++++++++++++++++++++++++++ hw/s390x/Makefile.objs | 4 +- hw/s390x/ap-bridge.c | 78 ++++ hw/s390x/ap-device.c | 38 ++ hw/s390x/s390-virtio-ccw.c | 4 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 181 ++++++++ include/hw/s390x/ap-bridge.h | 19 + include/hw/s390x/ap-device.h | 22 + include/hw/vfio/vfio-common.h | 1 + include/standard-headers/linux/input.h | 9 +- linux-headers/asm-arm/kvm.h | 13 + linux-headers/asm-arm64/kvm.h | 13 + linux-headers/asm-s390/kvm.h | 2 + linux-headers/asm-x86/kvm.h | 1 + linux-headers/linux/kvm.h | 2 + linux-headers/linux/vfio.h | 2 + linux-headers/linux/vhost.h | 2 +- target/s390x/cpu_features.c | 3 + target/s390x/cpu_features_def.h | 3 + target/s390x/cpu_models.c | 2 + target/s390x/excp_helper.c | 48 +- target/s390x/gen-features.c | 3 + target/s390x/kvm.c | 19 + 26 files changed, 1269 insertions(+), 43 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
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 1/8] target/s390x/excp_helper: Remove DPRINTF() macro
From: Thomas Huth <[email protected]>
Debug macros that are disabled by default should be avoided (since the code bit-rots quite easily). Thus turn these debug prints into proper qemu_log_mask(CPU_LOG_xxx, ...) statements instead. The DPRINTF statements in do_[ext|io|mchk]_interrupt can even be removed completely since we can log the information in a central place, s390_cpu_do_interrupt, instead.
Message-Id: <[email protected]>
--- target/s390x/excp_helper.c | 48 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 37 deletions(-)
target/s390x/excp_helper.c +11 -37
@@ -33,23 +33,6 @@#include "hw/s390x/s390_flic.h" #endif -/* #define DEBUG_S390 */ -/* #define DEBUG_S390_STDOUT */ - -#ifdef DEBUG_S390 -#ifdef DEBUG_S390_STDOUT -#define DPRINTF (fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); \ - if (qemu_log_separate()) { qemu_log(fmt, ##__VA_ARGS__); } } while (0) -#else -#define DPRINTF (fmt, ...) \ - do { qemu_log(fmt, ## __VA_ARGS__); } while (0) -#endif -#else -#define DPRINTF (fmt, ...) \ - do { } while (0) -#endif - void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code,int ilen,uintptr_t ra) {
@@ -128,8 +111,8 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size,uint64_t asc;int prot; -DPRINTF ("%s: address 0x%" VADDR_PRIx" rw %d mmu_idx %d\n" , - __func__, orig_vaddr, rw, mmu_idx); +qemu_log_mask (CPU_LOG_MMU ,"%s: addr 0x%" VADDR_PRIx" rw %d mmu_idx %d\n" , + __func__, orig_vaddr, rw, mmu_idx); vaddr = orig_vaddr;
@@ -158,8 +141,9 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size,if (!address_space_access_valid (&address_space_memory, raddr,TARGET_PAGE_SIZE , rw,MEMTXATTRS_UNSPECIFIED )) { -DPRINTF ("%s: raddr %" PRIx64" > ram_size %" PRIx64"\n" , __func__, - (uint64_t )raddr, (uint64_t )ram_size); +qemu_log_mask (CPU_LOG_MMU , +"%s: raddr %" PRIx64" > ram_size %" PRIx64"\n" , + __func__, (uint64_t )raddr, (uint64_t )ram_size);trigger_pgm_exception (env,PGM_ADDRESSING ,ILEN_AUTO );return 1 ; }
@@ -217,8 +201,10 @@ static void do_program_interrupt(CPUS390XState *env)break ; } -qemu_log_mask (CPU_LOG_INT ,"%s: code=0x%x ilen=%d\n" , - __func__, env->int_pgm_code, ilen); +qemu_log_mask (CPU_LOG_INT , +"%s: code=0x%x ilen=%d psw: %" PRIx64" %" PRIx64"\n" , + __func__, env->int_pgm_code, ilen, env->psw.mask, + env->psw.addr); lowcore =cpu_map_lowcore (env);
@@ -240,10 +226,6 @@ static void do_program_interrupt(CPUS390XState *env)cpu_unmap_lowcore (lowcore); -DPRINTF ("%s: %x %x %" PRIx64" %" PRIx64"\n" , __func__, - env->int_pgm_code, ilen, env->psw.mask, - env->psw.addr); -load_psw (env, mask, addr); }
@@ -334,9 +316,6 @@ static void do_ext_interrupt(CPUS390XState *env)cpu_unmap_lowcore (lowcore); -DPRINTF ("%s: %" PRIx64" %" PRIx64"\n" , __func__, - env->psw.mask, env->psw.addr); -load_psw (env, mask, addr); }
@@ -365,8 +344,6 @@ static void do_io_interrupt(CPUS390XState *env)cpu_unmap_lowcore (lowcore);g_free (io); -DPRINTF ("%s: %" PRIx64" %" PRIx64"\n" , __func__, env->psw.mask, - env->psw.addr);load_psw (env, mask, addr); }
@@ -408,9 +385,6 @@ static void do_mchk_interrupt(CPUS390XState *env)cpu_unmap_lowcore (lowcore); -DPRINTF ("%s: %" PRIx64" %" PRIx64"\n" , __func__, - env->psw.mask, env->psw.addr); -load_psw (env, mask, addr); }
@@ -421,8 +395,8 @@ void s390_cpu_do_interrupt(CPUState *cs)CPUS390XState *env = &cpu->env;bool stopped = false; -qemu_log_mask (CPU_LOG_INT ,"%s: %d at pc=%" PRIx64"\n" , - __func__, cs->exception_index, env->psw.addr); +qemu_log_mask (CPU_LOG_INT ,"%s: %d at psw=%" PRIx64":%" PRIx64"\n" , + __func__, cs->exception_index, env->psw.mask, env->psw.addr); try_deliver:/* handle machine checks */
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 2/8] linux-headers: update
In reply to Cornelia HuckUpdate to kvm/next commit dd5bd0a65ff6 ("Merge tag 'kvm-s390-next-4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD")
--- include/standard-headers/linux/input.h | 9 +++++---- linux-headers/asm-arm/kvm.h | 13 +++++++++++++ linux-headers/asm-arm64/kvm.h | 13 +++++++++++++ linux-headers/asm-s390/kvm.h | 2 ++ linux-headers/asm-x86/kvm.h | 1 + linux-headers/linux/kvm.h | 2 ++ linux-headers/linux/vfio.h | 2 ++ linux-headers/linux/vhost.h | 2 +- 8 files changed, 39 insertions(+), 5 deletions(-)
include/standard-headers/linux/input.h +5 -4
@@ -267,10 +267,11 @@ struct input_mask {/* * MT_TOOL types */ -#define MT_TOOL_FINGER 0 -#define MT_TOOL_PEN 1 -#define MT_TOOL_PALM 2 -#define MT_TOOL_MAX 2 +#define MT_TOOL_FINGER 0x00 +#define MT_TOOL_PEN 0x01 +#define MT_TOOL_PALM 0x02 +#define MT_TOOL_DIAL 0x0a +#define MT_TOOL_MAX 0x0f/* * Values describing the status of a force-feedback effect
linux-headers/asm-arm/kvm.h +13 -0
@@ -27,6 +27,7 @@#define __KVM_HAVE_GUEST_DEBUG#define __KVM_HAVE_IRQ_LINE#define __KVM_HAVE_READONLY_MEM +#define __KVM_HAVE_VCPU_EVENTS#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
@@ -125,6 +126,18 @@ struct kvm_sync_regs {struct kvm_arch_memory_slot { }; +/* for KVM_GET/SET_VCPU_EVENTS */ +struct kvm_vcpu_events { +struct { +__u8 serror_pending; +__u8 serror_has_esr; +/* Align it to 8 bytes */ +__u8 pad[6 ]; +__u64 serror_esr; + } exception; +__u32 reserved[12 ]; +}; +/* If you need to interpret the index values, here is the key: */ #define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000#define KVM_REG_ARM_COPROC_SHIFT 16
linux-headers/asm-arm64/kvm.h +13 -0
@@ -39,6 +39,7 @@#define __KVM_HAVE_GUEST_DEBUG#define __KVM_HAVE_IRQ_LINE#define __KVM_HAVE_READONLY_MEM +#define __KVM_HAVE_VCPU_EVENTS#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
@@ -154,6 +155,18 @@ struct kvm_sync_regs {struct kvm_arch_memory_slot { }; +/* for KVM_GET/SET_VCPU_EVENTS */ +struct kvm_vcpu_events { +struct { +__u8 serror_pending; +__u8 serror_has_esr; +/* Align it to 8 bytes */ +__u8 pad[6 ]; +__u64 serror_esr; + } exception; +__u32 reserved[12 ]; +}; +/* If you need to interpret the index values, here is the key: */ #define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000#define KVM_REG_ARM_COPROC_SHIFT 16
linux-headers/asm-s390/kvm.h +2 -0
@@ -160,6 +160,8 @@ 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_ENABLE_APIE 4 +#define KVM_S390_VM_CRYPTO_DISABLE_APIE 5/* kvm attributes for migration mode */ #define KVM_S390_VM_MIGRATION_STOP 0
linux-headers/asm-x86/kvm.h +1 -0
@@ -377,6 +377,7 @@ struct kvm_sync_regs {#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) +#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)#define KVM_STATE_NESTED_GUEST_MODE 0x00000001#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
linux-headers/linux/kvm.h +2 -0
@@ -951,6 +951,8 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_HYPERV_TLBFLUSH 155#define KVM_CAP_S390_HPAGE_1M 156#define KVM_CAP_NESTED_STATE 157 +#define KVM_CAP_ARM_INJECT_SERROR_ESR 158 +#define KVM_CAP_MSR_PLATFORM_INFO 159#ifdef KVM_CAP_IRQ_ROUTING
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,
linux-headers/linux/vhost.h +1 -1
@@ -176,7 +176,7 @@ struct vhost_memory {#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1#define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) -#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64) +#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)/* VHOST_NET specific defines */
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 3/8] s390x/cpumodel: Set up CPU model for AP device support
In reply to Cornelia HuckFrom: Tony Krowiak <[email protected]>
A 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 S390_FEAT_AP CPU model feature indicates whether AP instructions are available to the guest. This feature will be enabled only if the AP instructions are available on the linux host as determined by the availability of the KVM_S390_VM_CRYPTO_ENABLE_APIE VM attribute which is exposed by KVM only if the AP instructions are available on the host.
This feature must be turned on from userspace to execute AP instructions on the KVM guest. The QEMU command line to turn this feature on 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 because there are few older systems on which to test and the older crypto cards will be going out of service in the relatively near future.
CPU model facilities:
1. The S390_FEAT_AP_QUERY_CONFIG_INFO feature indicates whether the AP Query Configuration Information (QCI) facility is available to the guest as determined by whether the facility is available on the host. This feature will be exposed by KVM only if the QCI facility is installed on the host.
2. The S390_FEAT_AP_FACILITY_TEST feature indicates whether the AP Facility Test (APFT) facility is available to the guest as determined by whether the facility is available on the host. This feature will be exposed by KVM only if APFT is installed on the host.
Message-Id: <[email protected]>
--- 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 +++ 4 files changed, 11 insertions(+)
target/s390x/cpu_features.c +3 -0
@@ -39,8 +39,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,
@@ -119,6 +121,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
@@ -786,6 +786,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[] = {
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 4/8] s390x/kvm: enable AP instruction interpretation for guest
In reply to Cornelia HuckFrom: Tony Krowiak <[email protected]>
Let's use the KVM_SET_DEVICE_ATTR ioctl to enable hardware interpretation of AP instructions executed on the guest. If the S390_FEAT_AP feature is switched on for the guest, AP instructions must be interpreted by default; otherwise, they will be intercepted.
This attribute setting may be overridden by a device. For example, a device may want to provide AP instructions to the guest (i.e., S390_FEAT_AP turned on), but it may want to emulate them. In this case, the AP instructions executed on the guest must be intercepted; so when the device is realized, it must disable interpretation.
Message-Id: <[email protected]>
--- target/s390x/kvm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
target/s390x/kvm.c +19 -0
@@ -2299,11 +2299,26 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)error_setg (errp,"KVM: host CPU model could not be identified" );return ; } +/* for now, we can only provide the AP feature with HW support */ +if (kvm_vm_check_attr (kvm_state,KVM_S390_VM_CRYPTO , +KVM_S390_VM_CRYPTO_ENABLE_APIE )) { +set_bit (S390_FEAT_AP , model->features); + }/* strip of features that are not part of the maximum model */ bitmap_and (model->features, model->features, model->def->full_feat,S390_FEAT_MAX ); } +static void kvm_s390_configure_apie (bool interpret) +{ +uint64_t attr = interpret ?KVM_S390_VM_CRYPTO_ENABLE_APIE : +KVM_S390_VM_CRYPTO_DISABLE_APIE ; + +if (kvm_vm_check_attr (kvm_state,KVM_S390_VM_CRYPTO , attr)) { +kvm_s390_set_attr (attr); + } +} +void kvm_s390_apply_cpu_model (const S390CPUModel *model,Error **errp) {struct kvm_s390_vm_cpu_processor prop = {
@@ -2353,6 +2368,10 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)if (test_bit (S390_FEAT_CMM , model->features)) {kvm_s390_enable_cmma (); } + +if (test_bit (S390_FEAT_AP , model->features)) { +kvm_s390_configure_apie (true); + } }void kvm_s390_restart_interrupt (S390CPU *cpu)
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 6/8] s390x/vfio: ap: Introduce VFIO AP device
In reply to Cornelia HuckFrom: 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/$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.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 + default-configs/s390x-softmmu.mak | 1 + hw/vfio/Makefile.objs | 1 + hw/vfio/ap.c | 181 ++++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 1 + 5 files changed, 186 insertions(+) create mode 100644 hw/vfio/ap.c
MAINTAINERS +2 -0
@@ -88,6 +88,7 @@ F: hw/char/terminal3270.c F: hw/intc/s390_flic.c F: hw/intc/s390_flic_kvm.c F: hw/s390x/ +F: hw/vfio/ap.c F: hw/vfio/ccw.c F: hw/watchdog/wdt_diag288.c F: include/hw/s390x/
@@ -1217,6 +1218,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 +181 -0
181 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
2.14.4
[Qemu-devel] [PULL 5/8] s390x/ap: base Adjunct Processor (AP) object model
In reply to Cornelia HuckFrom: Tony Krowiak <[email protected]>
Introduces the base object model for virtualizing AP devices.
Message-Id: <[email protected]>
--- MAINTAINERS | 12 +++++++ hw/s390x/Makefile.objs | 2 ++ hw/s390x/ap-bridge.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/ap-device.c | 38 +++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 4 +++ include/hw/s390x/ap-bridge.h | 19 +++++++++++ include/hw/s390x/ap-device.h | 22 +++++++++++++ 7 files changed, 175 insertions(+) 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
@@ -1207,6 +1207,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
@@ -31,3 +31,5 @@ obj-$(CONFIG_TCG) += tod-qemu.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 +78 -0
78 lines not on this page · raw message
hw/s390x/ap-device.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Adjunct Processor (AP) matrix device +* +* Copyright 2018 IBM Corp. +* +* 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 (DeviceClass), + .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"
@@ -263,6 +264,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 +19 -0
@@ -0,0 +1,19 @@ +/* +* ap bridge +* +* Copyright 2018 IBM Corp. +* +* 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 + +#define TYPE_AP_BRIDGE "ap-bridge" +#define TYPE_AP_BUS "ap-bus" + +void s390_init_ap (void ); + +#endif
include/hw/s390x/ap-device.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Adjunct Processor (AP) matrix device interfaces +* +* Copyright 2018 IBM Corp. +* +* 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 ; + +#define AP_DEVICE (obj) \ + OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE) + +#endif /* HW_S390X_AP_DEVICE_H */
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 7/8] s390: doc: detailed specifications for AP virtualization
In reply to Cornelia HuckFrom: Tony Krowiak <[email protected]>
This 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.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 + docs/vfio-ap.txt | 825 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 827 insertions(+) create mode 100644 docs/vfio-ap.txt
MAINTAINERS +2 -0
@@ -96,6 +96,7 @@ F: include/hw/watchdog/wdt_diag288.h F: pc-bios/s390-ccw/ F: pc-bios/s390-ccw.img F: target/s390x/ +F: docs/vfio-ap.txt K: ^Subject:.*(?i)s390x? T: git git://github.com/cohuck/qemu.git s390-next L: [email protected]
@@ -1219,6 +1220,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 +825 -0
825 lines not on this page · raw message
Signature · 1 line
2.14.4
[Qemu-devel] [PULL 8/8] hw/s390x: Include the tod-qemu also for builds with --disable-tcg
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
The device is required for running qtests, see hw/s390x/tod.c:
void s390_init_tod(void)
{
Object *obj;
if (kvm_enabled()) {
obj = object_new(TYPE_KVM_S390_TOD);
} else {
obj = object_new(TYPE_QEMU_S390_TOD);
}
[...]}
During qtests, we're running without kvm, so TYPE_QEMU_S390_TOD is required to avoid that QEMU aborts here.
Message-Id: <[email protected]>
--- hw/s390x/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/Makefile.objs +1 -1
@@ -26,8 +26,8 @@ obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o obj-y += s390-skeys.o obj-y += s390-stattrib.o obj-y += tod.o +obj-y += tod-qemu.o obj-$(CONFIG_KVM) += tod-kvm.o -obj-$(CONFIG_TCG) += tod-qemu.o obj-$(CONFIG_KVM) += s390-skeys-kvm.o obj-$(CONFIG_KVM) += s390-stattrib-kvm.o obj-y += s390-ccw.o
Signature · 1 line
2.14.4
Peter Maydell
AppliedQuoted 12 lines · Cornelia Huck
The following changes since commit
75e50c80e051423a6f55a34ee4a1eec842444a5b:Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2018-10-10' into staging (2018-10-11 10:43:37 +0100)
are available in the Git repository at:
git://github.com/cohuck/qemutags/s390x-20181012for you to fetch changes up to
0161215d435ef5680c4623bcbdfe89ce5b35cf42:hw/s390x: Include the tod-qemu also for builds with --disable-tcg (2018-10-12 11:32:19 +0200)
Quoted 7 lines
----------------------------------------------------------------
More s390x updates:
- introduce support for vfio-ap (s390 crypto devices), including a Linux headers update to get the new interfaces
- the usual fixing + cleanup----------------------------------------------------------------
Applied, thanks.
-- PMM
Re: [Qemu-devel] [PULL 6/8] s390x/vfio: ap: Introduce VFIO AP device
In reply to Cornelia HuckQuoted 34 lines · Cornelia Huck
From: 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.Signed-off-by Tony Krowiak <[email protected]>Tested-by Pierre Morel <[email protected]>Acked-by Halil Pasic <[email protected]>Tested-by Pierre Morel <[email protected]>
Quoted 4 lines
Message-Id: <[email protected]>
Reviewed-by Thomas Huth <[email protected]>[CH: added missing g_free and device category]Signed-off-by Cornelia Huck <[email protected]>
Hi; Coverity has pointed out a bug in this function (CID 1396176):
hw/vfio/ap.c line 145
Quoted 10 lines
hw/vfio/ap.c new file +10
-0+static void vfio_ap_reset (DeviceState *dev) +{ +int ret; +APDevice *apdev =AP_DEVICE (dev); +VFIOAPDevice *vapdev =VFIO_AP_DEVICE (apdev); + + ret =ioctl (vapdev->vdev.fd,VFIO_DEVICE_RESET ); +if (ret) { +error_report ("%s: failed to reset %s device: %s" , __func__, + vapdev->vdev.name,strerror (ret));
ioctl returns -1 and sets errno, so "strerror(ret)" is the wrong thing here; we want "strerror(errno)".
thanks
-- PMM