vfio-ccw: support hsch/csch (QEMU part)
v4 cover vfio-ccw: support hsch/csch (QEMU part)
The Linux part of this is now merged in master, so this is mostly a resend with a real headers update.
I'd like to queue this soon; even better would be if I could do a header update with KVM updates as well (as then I could queue another series at the same time).
Changes v3->v4:
- replace dummy header update with a real one
- add missing g_free [Eric]
Changes v2->v3:
- update kernel header to v4 of kernel patches
- rebased on master
Changes v1->v2:
- update kernel header to v2 of kernel patches
- rebased on master
Cornelia Huck (2):
linux-headers: update
vfio-ccw: support async command subregion
hw/s390x/css.c | 27 ++- hw/vfio/ccw.c | 110 +++++++++++- include/hw/s390x/s390-ccw.h | 3 + .../infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 15 +- include/standard-headers/drm/drm_fourcc.h | 63 +++++++ include/standard-headers/linux/ethtool.h | 37 ++-- .../linux/input-event-codes.h | 8 +- include/standard-headers/linux/input.h | 6 +- include/standard-headers/linux/pci_regs.h | 2 + .../standard-headers/linux/virtio_config.h | 6 + include/standard-headers/linux/virtio_ring.h | 10 -- .../standard-headers/rdma/vmw_pvrdma-abi.h | 1 + linux-headers/asm-arm/unistd-common.h | 26 +++ linux-headers/asm-arm64/unistd.h | 2 + linux-headers/asm-generic/mman-common.h | 4 +- linux-headers/asm-generic/unistd.h | 158 ++++++++++++++---- linux-headers/asm-mips/mman.h | 4 +- linux-headers/asm-mips/unistd_n32.h | 24 +++ linux-headers/asm-mips/unistd_n64.h | 4 + linux-headers/asm-mips/unistd_o32.h | 34 ++++ linux-headers/asm-powerpc/kvm.h | 2 + linux-headers/asm-powerpc/unistd_32.h | 34 ++++ linux-headers/asm-powerpc/unistd_64.h | 15 ++ linux-headers/asm-s390/unistd_32.h | 37 ++++ linux-headers/asm-s390/unistd_64.h | 18 ++ linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 34 ++++ linux-headers/asm-x86/unistd_64.h | 4 + linux-headers/asm-x86/unistd_x32.h | 4 + linux-headers/linux/mman.h | 4 + linux-headers/linux/psci.h | 7 + linux-headers/linux/psp-sev.h | 18 +- linux-headers/linux/vfio.h | 4 + linux-headers/linux/vfio_ccw.h | 12 ++ 34 files changed, 661 insertions(+), 77 deletions(-)
Signature · 1 line
2.20.1
PATCH v4 1/2 linux-headers: update
Update against 71ae5fc87c34 ("Merge tag 'linux-kselftest-5.2-rc1' ofgit://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest")
--- .../infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 15 +- include/standard-headers/drm/drm_fourcc.h | 63 +++++++ include/standard-headers/linux/ethtool.h | 37 ++-- .../linux/input-event-codes.h | 8 +- include/standard-headers/linux/input.h | 6 +- include/standard-headers/linux/pci_regs.h | 2 + .../standard-headers/linux/virtio_config.h | 6 + include/standard-headers/linux/virtio_ring.h | 10 -- .../standard-headers/rdma/vmw_pvrdma-abi.h | 1 + linux-headers/asm-arm/unistd-common.h | 26 +++ linux-headers/asm-arm64/unistd.h | 2 + linux-headers/asm-generic/mman-common.h | 4 +- linux-headers/asm-generic/unistd.h | 158 ++++++++++++++---- linux-headers/asm-mips/mman.h | 4 +- linux-headers/asm-mips/unistd_n32.h | 24 +++ linux-headers/asm-mips/unistd_n64.h | 4 + linux-headers/asm-mips/unistd_o32.h | 34 ++++ linux-headers/asm-powerpc/kvm.h | 2 + linux-headers/asm-powerpc/unistd_32.h | 34 ++++ linux-headers/asm-powerpc/unistd_64.h | 15 ++ linux-headers/asm-s390/unistd_32.h | 37 ++++ linux-headers/asm-s390/unistd_64.h | 18 ++ linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 34 ++++ linux-headers/asm-x86/unistd_64.h | 4 + linux-headers/asm-x86/unistd_x32.h | 4 + linux-headers/linux/mman.h | 4 + linux-headers/linux/psci.h | 7 + linux-headers/linux/psp-sev.h | 18 +- linux-headers/linux/vfio.h | 4 + linux-headers/linux/vfio_ccw.h | 12 ++ 31 files changed, 527 insertions(+), 71 deletions(-)
include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +10 -5
@@ -57,7 +57,8 @@#define PVRDMA_ROCEV1_VERSION 17#define PVRDMA_ROCEV2_VERSION 18 -#define PVRDMA_VERSION PVRDMA_ROCEV2_VERSION +#define PVRDMA_PPN64_VERSION 19 +#define PVRDMA_VERSION PVRDMA_PPN64_VERSION#define PVRDMA_BOARD_ID 1#define PVRDMA_REV_ID 1
@@ -279,8 +280,10 @@ struct pvrdma_device_shared_region {/* W: Async ring page info. */ struct pvrdma_ring_page_info cq_ring_pages;/* W: CQ ring page info. */ -uint32_t uar_pfn;/* W: UAR pageframe. */ -uint32_t pad2;/* Pad to 8-byte align. */ +union { +uint32_t uar_pfn;/* W: UAR pageframe. */ +uint64_t uar_pfn64;/* W: 64-bit UAR page frame. */ + };struct pvrdma_device_caps caps;/* R: Device capabilities. */ };
@@ -411,8 +414,10 @@ struct pvrdma_cmd_query_pkey_resp {struct pvrdma_cmd_create_uc {struct pvrdma_cmd_hdr hdr; -uint32_t pfn;/* UAR page frame number */ -uint8_t reserved[4 ]; +union { +uint32_t pfn;/* UAR page frame number */ +uint64_t pfn64;/* 64-bit UAR page frame number */ + }; };struct pvrdma_cmd_create_uc_resp {
include/standard-headers/drm/drm_fourcc.h +63 -0
97 lines not on this page · raw message
include/standard-headers/linux/ethtool.h +27 -10
@@ -1432,6 +1432,13 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT =29 , ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT =30 , ETHTOOL_LINK_MODE_25000baseCR_Full_BIT =31 , + +/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit +* 31. Please do NOT define any SUPPORTED_* or ADVERTISED_* +* macro for bits > 31. The only way to use indices > 31 is to +* use the new ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API. +*/ + ETHTOOL_LINK_MODE_25000baseKR_Full_BIT =32 , ETHTOOL_LINK_MODE_25000baseSR_Full_BIT =33 , ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT = 34,
@@ -1453,15 +1460,24 @@ enum ethtool_link_mode_bit_indices {ETHTOOL_LINK_MODE_FEC_NONE_BIT =49 ,ETHTOOL_LINK_MODE_FEC_RS_BIT =50 ,ETHTOOL_LINK_MODE_FEC_BASER_BIT =51 , - -/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit -* 31. Please do NOT define any SUPPORTED_* or ADVERTISED_* -* macro for bits > 31. The only way to use indices > 31 is to -* use the new ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API. -*/ - - __ETHTOOL_LINK_MODE_LAST - = ETHTOOL_LINK_MODE_FEC_BASER_BIT, + ETHTOOL_LINK_MODE_50000baseKR_Full_BIT =52 , + ETHTOOL_LINK_MODE_50000baseSR_Full_BIT =53 , + ETHTOOL_LINK_MODE_50000baseCR_Full_BIT =54 , + ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT =55 , + ETHTOOL_LINK_MODE_50000baseDR_Full_BIT =56 , + ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT =57 , + ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT =58 , + ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT =59 , + ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT =60 , + ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT =61 , + ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT =62 , + ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT =63 , + ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT =64 , + ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT =65 , + ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT =66 , + +/* must be last entry */ + __ETHTOOL_LINK_MODE_MASK_NBITS };#define __ETHTOOL_LINK_MODE_LEGACY_MASK (base_name) \
@@ -1569,12 +1585,13 @@ enum ethtool_link_mode_bit_indices {#define SPEED_50000 50000#define SPEED_56000 56000#define SPEED_100000 100000 +#define SPEED_200000 200000#define SPEED_UNKNOWN -1static inline int ethtool_validate_speed (uint32_t speed) { -return speed <=INT_MAX || speed ==SPEED_UNKNOWN ; +return speed <=INT_MAX || speed == (uint32_t )SPEED_UNKNOWN ; }/* Duplex, half or full. */
include/standard-headers/linux/input-event-codes.h +6 -2
@@ -439,10 +439,12 @@#define KEY_TITLE 0x171#define KEY_SUBTITLE 0x172#define KEY_ANGLE 0x173 -#define KEY_ZOOM 0x174 +#define KEY_FULL_SCREEN 0x174/* AC View Toggle */ +#define KEY_ZOOM KEY_FULL_SCREEN#define KEY_MODE 0x175#define KEY_KEYBOARD 0x176 -#define KEY_SCREEN 0x177 +#define KEY_ASPECT_RATIO 0x177/* HUTRR37: Aspect */ +#define KEY_SCREEN KEY_ASPECT_RATIO#define KEY_PC 0x178/* Media Select Computer */ #define KEY_TV 0x179/* Media Select TV */ #define KEY_TV2 0x17a/* Media Select Cable */
@@ -716,6 +718,8 @@* the situation described above. */ #define REL_RESERVED 0x0a +#define REL_WHEEL_HI_RES 0x0b +#define REL_HWHEEL_HI_RES 0x0c#define REL_MAX 0x0f#define REL_CNT (REL_MAX+1)
include/standard-headers/linux/input.h +5 -1
@@ -23,13 +23,17 @@*/ struct input_event { -#if (HOST_LONG_BITS !=32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL) +#if (HOST_LONG_BITS !=32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)struct timeval time;#define input_event_sec time.tv_sec#define input_event_usec time.tv_usec#else unsigned long __sec; +#if defined(__sparc__) && defined(__arch64__) +unsigned int __usec; +#else unsigned long __usec; +#endif #define input_event_sec __sec#define input_event_usec __usec#endif
include/standard-headers/linux/pci_regs.h +2 -0
@@ -866,6 +866,7 @@#define PCI_ATS_CAP 0x04/* ATS Capability Register */ #define PCI_ATS_CAP_QDEP (x) ((x) & 0x1f)/* Invalidate Queue Depth */ #define PCI_ATS_MAX_QDEP 32/* Max Invalidate Queue Depth */ +#define PCI_ATS_CAP_PAGE_ALIGNED 0x0020/* Page Aligned Request */ #define PCI_ATS_CTRL 0x06/* ATS Control Register */ #define PCI_ATS_CTRL_ENABLE 0x8000/* ATS Enable */ #define PCI_ATS_CTRL_STU (x) ((x) & 0x1f)/* Smallest Translation Unit */
@@ -880,6 +881,7 @@#define PCI_PRI_STATUS_RF 0x001/* Response Failure */ #define PCI_PRI_STATUS_UPRGI 0x002/* Unexpected PRG index */ #define PCI_PRI_STATUS_STOPPED 0x100/* PRI Stopped */ +#define PCI_PRI_STATUS_PASID 0x8000/* PRG Response PASID Required */ #define PCI_PRI_MAX_REQ 0x08/* PRI max reqs supported */ #define PCI_PRI_ALLOC_REQ 0x0c/* PRI max reqs allowed */ #define PCI_EXT_CAP_PRI_SIZEOF 16
include/standard-headers/linux/virtio_config.h +6 -0
@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */
include/standard-headers/linux/virtio_ring.h +0 -10
@@ -211,14 +211,4 @@ struct vring_packed_desc { uint16_t flags; }; -struct vring_packed { -unsigned int num; - -struct vring_packed_desc *desc; - -struct vring_packed_desc_event *driver; - -struct vring_packed_desc_event *device; -}; -#endif /* _LINUX_VIRTIO_RING_H */
include/standard-headers/rdma/vmw_pvrdma-abi.h +1 -0
@@ -78,6 +78,7 @@ enum pvrdma_wr_opcode {PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD ,PVRDMA_WR_BIND_MW ,PVRDMA_WR_REG_SIG_MR , + PVRDMA_WR_ERROR, }; enum pvrdma_wc_status {
linux-headers/asm-arm/unistd-common.h +26 -0
@@ -356,5 +356,31 @@#define __NR_statx (__NR_SYSCALL_BASE + 397)#define __NR_rseq (__NR_SYSCALL_BASE + 398)#define __NR_io_pgetevents (__NR_SYSCALL_BASE + 399) +#define __NR_migrate_pages (__NR_SYSCALL_BASE + 400) +#define __NR_kexec_file_load (__NR_SYSCALL_BASE + 401) +#define __NR_clock_gettime64 (__NR_SYSCALL_BASE + 403) +#define __NR_clock_settime64 (__NR_SYSCALL_BASE + 404) +#define __NR_clock_adjtime64 (__NR_SYSCALL_BASE + 405) +#define __NR_clock_getres_time64 (__NR_SYSCALL_BASE + 406) +#define __NR_clock_nanosleep_time64 (__NR_SYSCALL_BASE + 407) +#define __NR_timer_gettime64 (__NR_SYSCALL_BASE + 408) +#define __NR_timer_settime64 (__NR_SYSCALL_BASE + 409) +#define __NR_timerfd_gettime64 (__NR_SYSCALL_BASE + 410) +#define __NR_timerfd_settime64 (__NR_SYSCALL_BASE + 411) +#define __NR_utimensat_time64 (__NR_SYSCALL_BASE + 412) +#define __NR_pselect6_time64 (__NR_SYSCALL_BASE + 413) +#define __NR_ppoll_time64 (__NR_SYSCALL_BASE + 414) +#define __NR_io_pgetevents_time64 (__NR_SYSCALL_BASE + 416) +#define __NR_recvmmsg_time64 (__NR_SYSCALL_BASE + 417) +#define __NR_mq_timedsend_time64 (__NR_SYSCALL_BASE + 418) +#define __NR_mq_timedreceive_time64 (__NR_SYSCALL_BASE + 419) +#define __NR_semtimedop_time64 (__NR_SYSCALL_BASE + 420) +#define __NR_rt_sigtimedwait_time64 (__NR_SYSCALL_BASE + 421) +#define __NR_futex_time64 (__NR_SYSCALL_BASE + 422) +#define __NR_sched_rr_get_interval_time64 (__NR_SYSCALL_BASE + 423) +#define __NR_pidfd_send_signal (__NR_SYSCALL_BASE + 424) +#define __NR_io_uring_setup (__NR_SYSCALL_BASE + 425) +#define __NR_io_uring_enter (__NR_SYSCALL_BASE + 426) +#define __NR_io_uring_register (__NR_SYSCALL_BASE + 427)#endif /* _ASM_ARM_UNISTD_COMMON_H */
linux-headers/asm-arm64/unistd.h +2 -0
@@ -17,5 +17,7 @@#define __ARCH_WANT_RENAMEAT#define __ARCH_WANT_NEW_STAT +#define __ARCH_WANT_SET_GET_RLIMIT +#define __ARCH_WANT_TIME32_SYSCALLS#include <asm-generic/unistd.h>
linux-headers/asm-generic/mman-common.h +1 -3
@@ -15,9 +15,7 @@#define PROT_GROWSDOWN 0x01000000/* mprotect flag: extend change to start of growsdown vma */ #define PROT_GROWSUP 0x02000000/* mprotect flag: extend change to end of growsup vma */ -#define MAP_SHARED 0x01/* Share changes */ -#define MAP_PRIVATE 0x02/* Changes are private */ -#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* 0x01 - 0x03 are defined in linux/mman.h */ #define MAP_TYPE 0x0f/* Mask for type of mapping */ #define MAP_FIXED 0x10/* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20/* don't use a file */
linux-headers/asm-generic/unistd.h +125 -33
305 lines not on this page · raw message
linux-headers/asm-mips/mman.h +1 -3
@@ -27,9 +27,7 @@/* * Flags for mmap */ -#define MAP_SHARED 0x001/* Share changes */ -#define MAP_PRIVATE 0x002/* Changes are private */ -#define MAP_SHARED_VALIDATE 0x003/* share + validate extension flags */ +/* 0x01 - 0x03 are defined in linux/mman.h */ #define MAP_TYPE 0x00f/* Mask for type of mapping */ #define MAP_FIXED 0x010/* Interpret addr exactly */
linux-headers/asm-mips/unistd_n32.h +24 -0
@@ -333,6 +333,30 @@#define __NR_statx (__NR_Linux + 330)#define __NR_rseq (__NR_Linux + 331)#define __NR_io_pgetevents (__NR_Linux + 332) +#define __NR_clock_gettime64 (__NR_Linux + 403) +#define __NR_clock_settime64 (__NR_Linux + 404) +#define __NR_clock_adjtime64 (__NR_Linux + 405) +#define __NR_clock_getres_time64 (__NR_Linux + 406) +#define __NR_clock_nanosleep_time64 (__NR_Linux + 407) +#define __NR_timer_gettime64 (__NR_Linux + 408) +#define __NR_timer_settime64 (__NR_Linux + 409) +#define __NR_timerfd_gettime64 (__NR_Linux + 410) +#define __NR_timerfd_settime64 (__NR_Linux + 411) +#define __NR_utimensat_time64 (__NR_Linux + 412) +#define __NR_pselect6_time64 (__NR_Linux + 413) +#define __NR_ppoll_time64 (__NR_Linux + 414) +#define __NR_io_pgetevents_time64 (__NR_Linux + 416) +#define __NR_recvmmsg_time64 (__NR_Linux + 417) +#define __NR_mq_timedsend_time64 (__NR_Linux + 418) +#define __NR_mq_timedreceive_time64 (__NR_Linux + 419) +#define __NR_semtimedop_time64 (__NR_Linux + 420) +#define __NR_rt_sigtimedwait_time64 (__NR_Linux + 421) +#define __NR_futex_time64 (__NR_Linux + 422) +#define __NR_sched_rr_get_interval_time64 (__NR_Linux + 423) +#define __NR_pidfd_send_signal (__NR_Linux + 424) +#define __NR_io_uring_setup (__NR_Linux + 425) +#define __NR_io_uring_enter (__NR_Linux + 426) +#define __NR_io_uring_register (__NR_Linux + 427)#endif /* _ASM_MIPS_UNISTD_N32_H */
linux-headers/asm-mips/unistd_n64.h +4 -0
@@ -329,6 +329,10 @@#define __NR_statx (__NR_Linux + 326)#define __NR_rseq (__NR_Linux + 327)#define __NR_io_pgetevents (__NR_Linux + 328) +#define __NR_pidfd_send_signal (__NR_Linux + 424) +#define __NR_io_uring_setup (__NR_Linux + 425) +#define __NR_io_uring_enter (__NR_Linux + 426) +#define __NR_io_uring_register (__NR_Linux + 427)#endif /* _ASM_MIPS_UNISTD_N64_H */
linux-headers/asm-mips/unistd_o32.h +34 -0
@@ -369,6 +369,40 @@#define __NR_statx (__NR_Linux + 366)#define __NR_rseq (__NR_Linux + 367)#define __NR_io_pgetevents (__NR_Linux + 368) +#define __NR_semget (__NR_Linux + 393) +#define __NR_semctl (__NR_Linux + 394) +#define __NR_shmget (__NR_Linux + 395) +#define __NR_shmctl (__NR_Linux + 396) +#define __NR_shmat (__NR_Linux + 397) +#define __NR_shmdt (__NR_Linux + 398) +#define __NR_msgget (__NR_Linux + 399) +#define __NR_msgsnd (__NR_Linux + 400) +#define __NR_msgrcv (__NR_Linux + 401) +#define __NR_msgctl (__NR_Linux + 402) +#define __NR_clock_gettime64 (__NR_Linux + 403) +#define __NR_clock_settime64 (__NR_Linux + 404) +#define __NR_clock_adjtime64 (__NR_Linux + 405) +#define __NR_clock_getres_time64 (__NR_Linux + 406) +#define __NR_clock_nanosleep_time64 (__NR_Linux + 407) +#define __NR_timer_gettime64 (__NR_Linux + 408) +#define __NR_timer_settime64 (__NR_Linux + 409) +#define __NR_timerfd_gettime64 (__NR_Linux + 410) +#define __NR_timerfd_settime64 (__NR_Linux + 411) +#define __NR_utimensat_time64 (__NR_Linux + 412) +#define __NR_pselect6_time64 (__NR_Linux + 413) +#define __NR_ppoll_time64 (__NR_Linux + 414) +#define __NR_io_pgetevents_time64 (__NR_Linux + 416) +#define __NR_recvmmsg_time64 (__NR_Linux + 417) +#define __NR_mq_timedsend_time64 (__NR_Linux + 418) +#define __NR_mq_timedreceive_time64 (__NR_Linux + 419) +#define __NR_semtimedop_time64 (__NR_Linux + 420) +#define __NR_rt_sigtimedwait_time64 (__NR_Linux + 421) +#define __NR_futex_time64 (__NR_Linux + 422) +#define __NR_sched_rr_get_interval_time64 (__NR_Linux + 423) +#define __NR_pidfd_send_signal (__NR_Linux + 424) +#define __NR_io_uring_setup (__NR_Linux + 425) +#define __NR_io_uring_enter (__NR_Linux + 426) +#define __NR_io_uring_register (__NR_Linux + 427)#endif /* _ASM_MIPS_UNISTD_O32_H */
linux-headers/asm-powerpc/kvm.h +2 -0
@@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char {#define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58)#define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57)#define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56) +#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST (1ull << 54)#define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63)#define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62)#define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61) +#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE (1ull << 58)/* Per-vcpu XICS interrupt controller state */ #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
linux-headers/asm-powerpc/unistd_32.h +34 -0
@@ -376,6 +376,40 @@#define __NR_pkey_mprotect 386#define __NR_rseq 387#define __NR_io_pgetevents 388 +#define __NR_semget 393 +#define __NR_semctl 394 +#define __NR_shmget 395 +#define __NR_shmctl 396 +#define __NR_shmat 397 +#define __NR_shmdt 398 +#define __NR_msgget 399 +#define __NR_msgsnd 400 +#define __NR_msgrcv 401 +#define __NR_msgctl 402 +#define __NR_clock_gettime64 403 +#define __NR_clock_settime64 404 +#define __NR_clock_adjtime64 405 +#define __NR_clock_getres_time64 406 +#define __NR_clock_nanosleep_time64 407 +#define __NR_timer_gettime64 408 +#define __NR_timer_settime64 409 +#define __NR_timerfd_gettime64 410 +#define __NR_timerfd_settime64 411 +#define __NR_utimensat_time64 412 +#define __NR_pselect6_time64 413 +#define __NR_ppoll_time64 414 +#define __NR_io_pgetevents_time64 416 +#define __NR_recvmmsg_time64 417 +#define __NR_mq_timedsend_time64 418 +#define __NR_mq_timedreceive_time64 419 +#define __NR_semtimedop_time64 420 +#define __NR_rt_sigtimedwait_time64 421 +#define __NR_futex_time64 422 +#define __NR_sched_rr_get_interval_time64 423 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427#endif /* _ASM_POWERPC_UNISTD_32_H */
linux-headers/asm-powerpc/unistd_64.h +15 -0
@@ -367,6 +367,21 @@#define __NR_pkey_mprotect 386#define __NR_rseq 387#define __NR_io_pgetevents 388 +#define __NR_semtimedop 392 +#define __NR_semget 393 +#define __NR_semctl 394 +#define __NR_shmget 395 +#define __NR_shmctl 396 +#define __NR_shmat 397 +#define __NR_shmdt 398 +#define __NR_msgget 399 +#define __NR_msgsnd 400 +#define __NR_msgrcv 401 +#define __NR_msgctl 402 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427#endif /* _ASM_POWERPC_UNISTD_64_H */
linux-headers/asm-s390/unistd_32.h +37 -0
@@ -363,5 +363,42 @@#define __NR_kexec_file_load 381#define __NR_io_pgetevents 382#define __NR_rseq 383 +#define __NR_pkey_mprotect 384 +#define __NR_pkey_alloc 385 +#define __NR_pkey_free 386 +#define __NR_semget 393 +#define __NR_semctl 394 +#define __NR_shmget 395 +#define __NR_shmctl 396 +#define __NR_shmat 397 +#define __NR_shmdt 398 +#define __NR_msgget 399 +#define __NR_msgsnd 400 +#define __NR_msgrcv 401 +#define __NR_msgctl 402 +#define __NR_clock_gettime64 403 +#define __NR_clock_settime64 404 +#define __NR_clock_adjtime64 405 +#define __NR_clock_getres_time64 406 +#define __NR_clock_nanosleep_time64 407 +#define __NR_timer_gettime64 408 +#define __NR_timer_settime64 409 +#define __NR_timerfd_gettime64 410 +#define __NR_timerfd_settime64 411 +#define __NR_utimensat_time64 412 +#define __NR_pselect6_time64 413 +#define __NR_ppoll_time64 414 +#define __NR_io_pgetevents_time64 416 +#define __NR_recvmmsg_time64 417 +#define __NR_mq_timedsend_time64 418 +#define __NR_mq_timedreceive_time64 419 +#define __NR_semtimedop_time64 420 +#define __NR_rt_sigtimedwait_time64 421 +#define __NR_futex_time64 422 +#define __NR_sched_rr_get_interval_time64 423 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427#endif /* _ASM_S390_UNISTD_32_H */
linux-headers/asm-s390/unistd_64.h +18 -0
@@ -330,5 +330,23 @@#define __NR_kexec_file_load 381#define __NR_io_pgetevents 382#define __NR_rseq 383 +#define __NR_pkey_mprotect 384 +#define __NR_pkey_alloc 385 +#define __NR_pkey_free 386 +#define __NR_semtimedop 392 +#define __NR_semget 393 +#define __NR_semctl 394 +#define __NR_shmget 395 +#define __NR_shmctl 396 +#define __NR_shmat 397 +#define __NR_shmdt 398 +#define __NR_msgget 399 +#define __NR_msgsnd 400 +#define __NR_msgrcv 401 +#define __NR_msgctl 402 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427#endif /* _ASM_S390_UNISTD_64_H */
linux-headers/asm-x86/kvm.h +1 -0
@@ -381,6 +381,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_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)#define KVM_STATE_NESTED_GUEST_MODE 0x00000001#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
linux-headers/asm-x86/unistd_32.h +34 -0
@@ -384,5 +384,39 @@#define __NR_arch_prctl 384#define __NR_io_pgetevents 385#define __NR_rseq 386 +#define __NR_semget 393 +#define __NR_semctl 394 +#define __NR_shmget 395 +#define __NR_shmctl 396 +#define __NR_shmat 397 +#define __NR_shmdt 398 +#define __NR_msgget 399 +#define __NR_msgsnd 400 +#define __NR_msgrcv 401 +#define __NR_msgctl 402 +#define __NR_clock_gettime64 403 +#define __NR_clock_settime64 404 +#define __NR_clock_adjtime64 405 +#define __NR_clock_getres_time64 406 +#define __NR_clock_nanosleep_time64 407 +#define __NR_timer_gettime64 408 +#define __NR_timer_settime64 409 +#define __NR_timerfd_gettime64 410 +#define __NR_timerfd_settime64 411 +#define __NR_utimensat_time64 412 +#define __NR_pselect6_time64 413 +#define __NR_ppoll_time64 414 +#define __NR_io_pgetevents_time64 416 +#define __NR_recvmmsg_time64 417 +#define __NR_mq_timedsend_time64 418 +#define __NR_mq_timedreceive_time64 419 +#define __NR_semtimedop_time64 420 +#define __NR_rt_sigtimedwait_time64 421 +#define __NR_futex_time64 422 +#define __NR_sched_rr_get_interval_time64 423 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427#endif /* _ASM_X86_UNISTD_32_H */
linux-headers/asm-x86/unistd_64.h +4 -0
@@ -336,5 +336,9 @@#define __NR_statx 332#define __NR_io_pgetevents 333#define __NR_rseq 334 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427#endif /* _ASM_X86_UNISTD_64_H */
linux-headers/asm-x86/unistd_x32.h +4 -0
@@ -289,6 +289,10 @@#define __NR_statx (__X32_SYSCALL_BIT + 332)#define __NR_io_pgetevents (__X32_SYSCALL_BIT + 333)#define __NR_rseq (__X32_SYSCALL_BIT + 334) +#define __NR_pidfd_send_signal (__X32_SYSCALL_BIT + 424) +#define __NR_io_uring_setup (__X32_SYSCALL_BIT + 425) +#define __NR_io_uring_enter (__X32_SYSCALL_BIT + 426) +#define __NR_io_uring_register (__X32_SYSCALL_BIT + 427)#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
linux-headers/linux/mman.h +4 -0
@@ -12,6 +12,10 @@#define OVERCOMMIT_ALWAYS 1#define OVERCOMMIT_NEVER 2 +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* * Huge page size encoding when MAP_HUGETLB is specified, and a huge page * size other than the default is desired. See hugetlb_encode.h.
linux-headers/linux/psci.h +7 -0
@@ -49,8 +49,11 @@#define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10)#define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) +#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) +#define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18)#define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) +#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18)/* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff
@@ -97,6 +100,10 @@#define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) +#define PSCI_1_0_OS_INITIATED BIT(0) +#define PSCI_1_0_SUSPEND_MODE_PC 0 +#define PSCI_1_0_SUSPEND_MODE_OSI 1 +/* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0#define PSCI_RET_NOT_SUPPORTED -1
linux-headers/linux/psp-sev.h +14 -4
@@ -6,8 +6,7 @@* * Author: Brijesh Singh <[email protected]> * -* SEV spec 0.14 is available at: -* http://support.amd.com/TechDocs/55766_SEV-KM%20API_Specification.pdf +* SEV API specification is available at: https://developer.amd.com/sev/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -30,7 +29,8 @@ enum {SEV_PDH_GEN ,SEV_PDH_CERT_EXPORT ,SEV_PEK_CERT_IMPORT , -SEV_GET_ID , +SEV_GET_ID ,/* This command is deprecated, use SEV_GET_ID2 */ +SEV_GET_ID2 , SEV_MAX, };
@@ -125,7 +125,7 @@ struct sev_user_data_pdh_cert_export { } __attribute__((packed));/** -* struct sev_user_data_get_id - GET_ID command parameters +* struct sev_user_data_get_id - GET_ID command parameters (deprecated) * * @socket1: Buffer to pass unique ID of first socket * @socket2: Buffer to pass unique ID of second socket
@@ -135,6 +135,16 @@ struct sev_user_data_get_id {__u8 socket2[64 ];/* Out */ } __attribute__((packed)); +/** +* struct sev_user_data_get_id2 - GET_ID command parameters +* @address: Buffer to store unique ID +* @length: length of the unique ID +*/ +struct sev_user_data_get_id2 { +__u64 address;/* In */ +__u32 length;/* In/Out */ +} __attribute__((packed)); +/** * struct sev_issue_cmd - SEV ioctl parameters *
linux-headers/linux/vfio.h +4 -0
@@ -353,6 +353,10 @@ struct vfio_region_gfx_edid {#define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2 }; +#define VFIO_REGION_TYPE_CCW (2) +/* ccw sub-types */ +#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1) +/* * 10de vendor sub-type *
linux-headers/linux/vfio_ccw.h +12 -0
@@ -12,6 +12,7 @@#include <linux/types.h> +/* used for START SUBCHANNEL, always present */ struct ccw_io_region {#define ORB_AREA_SIZE 12__u8 orb_area[ORB_AREA_SIZE ];
@@ -22,4 +23,15 @@ struct ccw_io_region {__u32 ret_code; } __attribute__((packed)); +/* +* used for processing commands that trigger asynchronous actions +* Note: this is controlled by a capability +*/ +#define VFIO_CCW_ASYNC_CMD_HSCH (1 << 0) +#define VFIO_CCW_ASYNC_CMD_CSCH (1 << 1) +struct ccw_cmd_region { +__u32 command; +__u32 ret_code; +} __attribute__((packed)); +#endif
Signature · 1 line
2.20.1
PATCH v4 2/2 vfio-ccw: support async command subregion
In reply to Cornelia HuckA vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)
hw/s390x/css.c +23 -4
@@ -22,6 +22,7 @@#include "trace.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/s390-ccw.h" typedef struct CrwContainer { CRW crw;
@@ -1191,6 +1192,26 @@ static void sch_handle_start_func_virtual(SubchDev *sch) } +static void sch_handle_halt_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_halt (sch); +if (ret == -ENOSYS ) { +sch_handle_halt_func (sch); + } +} + +static void sch_handle_clear_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_clear (sch); +if (ret == -ENOSYS ) { +sch_handle_clear_func (sch); + } +} +static IOInstEnding sch_handle_start_func_passthrough (SubchDev *sch) {SCHIB *schib = &sch->curr_status;
@@ -1230,11 +1251,9 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sch)SCHIB *schib = &sch->curr_status;if (schib->scsw.ctrl &SCSW_FCTL_CLEAR_FUNC ) { -/* TODO: Clear handling */ -sch_handle_clear_func (sch); +sch_handle_clear_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_HALT_FUNC ) { -/* TODO: Halt handling */ -sch_handle_halt_func (sch); +sch_handle_halt_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_START_FUNC ) {return sch_handle_start_func_passthrough (sch); }
hw/vfio/ccw.c +108 -2
149 lines not on this page · raw message
include/hw/s390x/s390-ccw.h +3 -0
@@ -37,4 +37,7 @@ typedef struct S390CCWDeviceClass { IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass; +int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +#endif
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 11 lines · On Tue, 7 May 2019 17:47:33 +0200 Cornelia Huck <[email protected]> wrote:
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)
Ping. I'd like to include this in my next QEMU pull request; any comments?
(I already have a headers update queued.)
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 15 lines · Cornelia Huck
Quoted 11 lines · On Tue, 7 May 2019 17:47:33 +0200 Cornelia Huck <[email protected]> wrote:
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)
Quoted 2 lines
Ping. I'd like to include this in my next QEMU pull request; any comments?
Apologies, I was looking at this late last week and thought it'd all become clear over the weekend. That didn't happen, so I've asked the only question I came up with. :)
- Eric
Quoted 3 lines
(I already have a headers update queued.)
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
In reply to Cornelia HuckQuoted 100 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/s390x/css.c +23
-4@@ -22,6 +22,7 @@#include "trace.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/s390-ccw.h" typedef struct CrwContainer { CRW crw;@@ -1191,6 +1192,26 @@ static void sch_handle_start_func_virtual(SubchDev *sch) } +static void sch_handle_halt_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_halt (sch); +if (ret == -ENOSYS ) { +sch_handle_halt_func (sch); + } +} + +static void sch_handle_clear_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_clear (sch); +if (ret == -ENOSYS ) { +sch_handle_clear_func (sch); + } +} +static IOInstEnding sch_handle_start_func_passthrough (SubchDev *sch) {SCHIB *schib = &sch->curr_status;@@ -1230,11 +1251,9 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sch)SCHIB *schib = &sch->curr_status;if (schib->scsw.ctrl &SCSW_FCTL_CLEAR_FUNC ) { -/* TODO: Clear handling */ -sch_handle_clear_func (sch); +sch_handle_clear_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_HALT_FUNC ) { -/* TODO: Halt handling */ -sch_handle_halt_func (sch); +sch_handle_halt_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_START_FUNC ) {return sch_handle_start_func_passthrough (sch); }hw/vfio/ccw.c +10
-0@@ -2,9 +2,12 @@* vfio based subchannel assignment support * * Copyright 2017 IBM Corp. +* Copyright 2019 Red Hat, Inc. +* * Author(s): Dong Jia Shi <[email protected]> * Xiao Feng Ren <[email protected]> * Pierre Morel <[email protected]> +* Cornelia Huck <[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 @@ -32,6 +35,9 @@ struct VFIOCCWDevice {uint64_t io_region_size;uint64_t io_region_offset;struct ccw_io_region *io_region; +uint64_t async_cmd_region_size; +uint64_t async_cmd_region_offset; +struct ccw_cmd_region *async_cmd_region;EventNotifier io_notifier;bool force_orb_pfch;bool warned_orb_pfch;@@ -114,6 +120,87 @@ again: } } +int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev);
hw/vfio/ccw.c again: · line 136
Quoted 10 lines
hw/vfio/ccw.c +10
-0+struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region)); + region->command =VFIO_CCW_ASYNC_CMD_CSCH ;
Considering the serialization you added on the kernel side, what happens if another vcpu runs this code (or _halt) and clears the async region before the kernel code gains control from the pwrite() call below? Asked another way, there's nothing preventing us from issuing more than one asynchronous command concurrently, so how do we make sure the command gets to the kernel rather than "current command wins" ?
That possibly worrisome question aside, this seems generally fine.
Quoted 126 lines
hw/vfio/ccw.c +88
-2+ +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +} + +int vfio_ccw_handle_halt (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region)); + region->command =VFIO_CCW_ASYNC_CMD_HSCH ; + +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -EBUSY : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +} +static void vfio_ccw_reset (DeviceState *dev) {CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev);@@ -287,9 +374,13 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp)return ; } +/* +* We always expect at least the I/O region to be present. We also +* may have a variable number of regions governed by capabilities. +*/ if (vdev->num_regions <VFIO_CCW_CONFIG_REGION_INDEX +1 ) { -error_setg (errp,"vfio: Unexpected number of the I/O region %u" , - vdev->num_regions); +error_setg (errp,"vfio: too few regions (%u), expected at least %u" , + vdev->num_regions,VFIO_CCW_CONFIG_REGION_INDEX +1 );return ; }@@ -309,11 +400,26 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) vcdev->io_region_offset = info->offset; vcdev->io_region =g_malloc0 (info->size); +/* check for the optional async command region */ + ret =vfio_get_dev_region_info (vdev,VFIO_REGION_TYPE_CCW , +VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD , &info); +if (!ret) { + vcdev->async_cmd_region_size = info->size; +if (sizeof (*vcdev->async_cmd_region) != vcdev->async_cmd_region_size) { +error_setg (errp,"vfio: Unexpected size of the async cmd region" ); +g_free (info); +return ; + } + vcdev->async_cmd_region_offset = info->offset; + vcdev->async_cmd_region =g_malloc0 (info->size); + } +g_free (info); }static void vfio_ccw_put_region (VFIOCCWDevice *vcdev) { +g_free (vcdev->async_cmd_region);g_free (vcdev->io_region); }include/hw/s390x/s390-ccw.h +3
-0@@ -37,4 +37,7 @@ typedef struct S390CCWDeviceClass { IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass; +int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +#endif
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 12 lines · On Mon, 20 May 2019 12:29:56 -0400 Eric Farman <[email protected]> wrote:
Quoted 11 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)
(...)
Quoted 13 lines
Quoted 13 lines
hw/vfio/ccw.c +13
-0+int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region));
Quoted 8 lines
Quoted 1 line
+
region->command=VFIO_CCW_ASYNC_CMD_CSCH;Considering the serialization you added on the kernel side, what happens if another vcpu runs this code (or
_halt) and clears the async region before the kernel code gains control from thepwrite()call below? Asked another way, there's nothing preventing us from issuing more than one asynchronous command concurrently, so how do we make sure the command gets to the kernel rather than "current command wins" ?
Hm... good question. But unfortunately not one I can answer quickly, so I'll put off queuing this patch and just send a pull request without it. It's not like we're in a hurry :)
Quoted 2 lines
That possibly worrisome question aside, this seems generally fine.
Thanks for looking!
Quoted 24 lines
Quoted 24 lines
hw/vfio/ccw.c +24
-0+ +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + }
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
In reply to Eric FarmanQuoted 27 lines · On Mon, 20 May 2019 12:29:56 -0400 Eric Farman <[email protected]> wrote:
Quoted 26 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/vfio/ccw.c +13
-0+int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region));
Quoted 8 lines
Quoted 1 line
+
region->command=VFIO_CCW_ASYNC_CMD_CSCH;Considering the serialization you added on the kernel side, what happens if another vcpu runs this code (or
_halt) and clears the async region before the kernel code gains control from thepwrite()call below? Asked another way, there's nothing preventing us from issuing more than one asynchronous command concurrently, so how do we make sure the command gets to the kernel rather than "current command wins" ?
This send me digging through the code, because if two threads can call this at the same time for passthrough, we'd also have the same problem for virtual.
If I followed the code correctly, all I/O instruction interpretation is currently serialized via qemu_mutex_{lock,unlock}_iothread() (see target/s390x/kvm.c respectively target/s390x/misc_helper.c). This should mostly be enough to avoid stepping on each other's toes.
Why mostly? I'm not sure yet whether we handling multiple requests for passthrough devices correctly yet (virtual should be fine.)
Start vs. (start|halt|clear) is fine, as the code checks whether something is already pending before poking the kernel interface. Likewise, halt vs. (start|halt|clear) is fine, as the code checks for halt or clear and start and halt use different regions. The problematic one is clear, as that's something that's always supposed to go through. Probably fine if clear should always "win", but I need to think some more about that.
Quoted 29 lines
That possibly worrisome question aside, this seems generally fine.
Quoted 25 lines
hw/vfio/ccw.c +25
-0+ +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +}
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 39 lines · Cornelia Huck
Quoted 27 lines · On Mon, 20 May 2019 12:29:56 -0400 Eric Farman <[email protected]> wrote:
Quoted 26 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/vfio/ccw.c +13
-0+int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region));Quoted 8 lines
Quoted 1 line
+
region->command=VFIO_CCW_ASYNC_CMD_CSCH;Considering the serialization you added on the kernel side, what happens if another vcpu runs this code (or
_halt) and clears the async region before the kernel code gains control from thepwrite()call below? Asked another way, there's nothing preventing us from issuing more than one asynchronous command concurrently, so how do we make sure the command gets to the kernel rather than "current command wins" ?
Quoted 8 lines
This send me digging through the code, because if two threads can call this at the same time for passthrough, we'd also have the same problem for virtual.
If I followed the code correctly, all I/O instruction interpretation is currently serialized via qemu_mutex_{lock,unlock}_iothread() (see
target/s390x/kvm.crespectivelytarget/s390x/misc_helper.c). This should mostly be enough to avoid stepping on each other's toes.
Ahhh, I didn't follow the bread crumbs back far enough to notice that. Yes, that should help keep things in line.
Quoted 11 lines
Why mostly? I'm not sure yet whether we handling multiple requests for passthrough devices correctly yet (virtual should be fine.)
Start vs. (start|halt|clear) is fine, as the code checks whether something is already pending before poking the kernel interface. Likewise, halt vs. (start|halt|clear) is fine, as the code checks for halt or clear and start and halt use different regions. The problematic one is clear, as that's something that's always supposed to go through. Probably fine if clear should always "win", but I need to think some more about that.
I suspect you are right, because of the check on the halt side, and considering that the clear is the biggest recovery action we have. So this does seem like things are okay. I'll ponder this overnight and finish my review tomorrow.
Quoted 31 lines
Quoted 30 lines
That possibly worrisome question aside, this seems generally fine.
Quoted 25 lines
hw/vfio/ccw.c +25
-0+ +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +}
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 13 lines · On Tue, 21 May 2019 16:47:45 -0400 Eric Farman <[email protected]> wrote:
Quoted 10 lines · Cornelia Huck
Why mostly? I'm not sure yet whether we handling multiple requests for passthrough devices correctly yet (virtual should be fine.)
Start vs. (start|halt|clear) is fine, as the code checks whether something is already pending before poking the kernel interface. Likewise, halt vs. (start|halt|clear) is fine, as the code checks for halt or clear and start and halt use different regions. The problematic one is clear, as that's something that's always supposed to go through. Probably fine if clear should always "win", but I need to think some more about that.
Quoted 4 lines
I suspect you are right, because of the check on the halt side, and considering that the clear is the biggest recovery action we have. So this does seem like things are okay. I'll ponder this overnight and finish my review tomorrow.
Ok, what's the verdict here? :)
(I'm trying to clean up my pending stuff :)
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 16 lines · Cornelia Huck
Quoted 13 lines · On Tue, 21 May 2019 16:47:45 -0400 Eric Farman <[email protected]> wrote:
Quoted 10 lines · Cornelia Huck
Why mostly? I'm not sure yet whether we handling multiple requests for passthrough devices correctly yet (virtual should be fine.)
Start vs. (start|halt|clear) is fine, as the code checks whether something is already pending before poking the kernel interface. Likewise, halt vs. (start|halt|clear) is fine, as the code checks for halt or clear and start and halt use different regions. The problematic one is clear, as that's something that's always supposed to go through. Probably fine if clear should always "win", but I need to think some more about that.
Quoted 6 lines
Quoted 4 lines
I suspect you are right, because of the check on the halt side, and considering that the clear is the biggest recovery action we have. So this does seem like things are okay. I'll ponder this overnight and finish my review tomorrow.
Ok, what's the verdict here? :)
Gah, I left this sit in my draft folder before holiday. Sorry about that!
Quoted 3 lines
(I'm trying to clean up my pending stuff :)
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
In reply to Cornelia HuckQuoted 43 lines · Cornelia Huck
Quoted 27 lines · On Mon, 20 May 2019 12:29:56 -0400 Eric Farman <[email protected]> wrote:
Quoted 26 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/vfio/ccw.c +13
-0+int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region));Quoted 8 lines
Quoted 1 line
+
region->command=VFIO_CCW_ASYNC_CMD_CSCH;Considering the serialization you added on the kernel side, what happens if another vcpu runs this code (or
_halt) and clears the async region before the kernel code gains control from thepwrite()call below? Asked another way, there's nothing preventing us from issuing more than one asynchronous command concurrently, so how do we make sure the command gets to the kernel rather than "current command wins" ?This send me digging through the code, because if two threads can call this at the same time for passthrough, we'd also have the same problem for virtual.
Quoted 7 lines
If I followed the code correctly, all I/O instruction interpretation is currently serialized via qemu_mutex_{lock,unlock}_iothread() (see
target/s390x/kvm.crespectivelytarget/s390x/misc_helper.c). This should mostly be enough to avoid stepping on each other's toes.Why mostly? I'm not sure yet whether we handling multiple requests for passthrough devices correctly yet (virtual should be fine.)
But don't virtual and passthrough device end up calling the same ioinst_handle_* functions to interpret the I/O instructions?
As you mentioned all the ioinst_handle_* functions are called with the qemu_mutex held. So I am confused as why virtual devices should be fine and not passthrough? :)
Quoted 40 lines
Start vs. (start|halt|clear) is fine, as the code checks whether something is already pending before poking the kernel interface. Likewise, halt vs. (start|halt|clear) is fine, as the code checks for halt or clear and start and halt use different regions. The problematic one is clear, as that's something that's always supposed to go through. Probably fine if clear should always "win", but I need to think some more about that.
Quoted 29 lines
That possibly worrisome question aside, this seems generally fine.
Quoted 25 lines
hw/vfio/ccw.c +25
-0+ +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +}
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 49 lines · On Tue, 21 May 2019 16:51:27 -0400 Farhan Ali <[email protected]> wrote:
Quoted 48 lines · Cornelia Huck
Quoted 27 lines · On Mon, 20 May 2019 12:29:56 -0400 Eric Farman <[email protected]> wrote:
Quoted 26 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/vfio/ccw.c +13
-0+int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region));Quoted 8 lines
Quoted 1 line
+
region->command=VFIO_CCW_ASYNC_CMD_CSCH;Considering the serialization you added on the kernel side, what happens if another vcpu runs this code (or
_halt) and clears the async region before the kernel code gains control from thepwrite()call below? Asked another way, there's nothing preventing us from issuing more than one asynchronous command concurrently, so how do we make sure the command gets to the kernel rather than "current command wins" ?This send me digging through the code, because if two threads can call this at the same time for passthrough, we'd also have the same problem for virtual.
If I followed the code correctly, all I/O instruction interpretation is currently serialized via qemu_mutex_{lock,unlock}_iothread() (see
target/s390x/kvm.crespectivelytarget/s390x/misc_helper.c). This should mostly be enough to avoid stepping on each other's toes.
Quoted 6 lines
Quoted 2 lines
Why mostly? I'm not sure yet whether we handling multiple requests for passthrough devices correctly yet (virtual should be fine.)
But don't virtual and passthrough device end up calling the same ioinst_handle_* functions to interpret the I/O instructions?
Yes, they do.
Quoted 4 lines
As you mentioned all the ioinst_handle_* functions are called with the
qemu_mutexheld. So I am confused as why virtual devices should be fine and not passthrough? :)
I'm mostly worried about the "wipe the area, then call pwrite()" sequence. We might wipe too often; but if clear is about hammering through in any case, this is hopefully fine.
Quoted 43 lines
Quoted 42 lines
Start vs. (start|halt|clear) is fine, as the code checks whether something is already pending before poking the kernel interface. Likewise, halt vs. (start|halt|clear) is fine, as the code checks for halt or clear and start and halt use different regions. The problematic one is clear, as that's something that's always supposed to go through. Probably fine if clear should always "win", but I need to think some more about that.
Quoted 29 lines
That possibly worrisome question aside, this seems generally fine.
Quoted 25 lines
hw/vfio/ccw.c +25
-0+ +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +}
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
In reply to Cornelia HuckQuoted 228 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/s390x/css.c +23
-4@@ -22,6 +22,7 @@#include "trace.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/s390-ccw.h" typedef struct CrwContainer { CRW crw;@@ -1191,6 +1192,26 @@ static void sch_handle_start_func_virtual(SubchDev *sch) } +static void sch_handle_halt_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_halt (sch); +if (ret == -ENOSYS ) { +sch_handle_halt_func (sch); + } +} + +static void sch_handle_clear_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_clear (sch); +if (ret == -ENOSYS ) { +sch_handle_clear_func (sch); + } +} +static IOInstEnding sch_handle_start_func_passthrough (SubchDev *sch) {SCHIB *schib = &sch->curr_status;@@ -1230,11 +1251,9 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sch)SCHIB *schib = &sch->curr_status;if (schib->scsw.ctrl &SCSW_FCTL_CLEAR_FUNC ) { -/* TODO: Clear handling */ -sch_handle_clear_func (sch); +sch_handle_clear_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_HALT_FUNC ) { -/* TODO: Halt handling */ -sch_handle_halt_func (sch); +sch_handle_halt_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_START_FUNC ) {return sch_handle_start_func_passthrough (sch); }hw/vfio/ccw.c +108
-2@@ -2,9 +2,12 @@* vfio based subchannel assignment support * * Copyright 2017 IBM Corp. +* Copyright 2019 Red Hat, Inc. +* * Author(s): Dong Jia Shi <[email protected]> * Xiao Feng Ren <[email protected]> * Pierre Morel <[email protected]> +* Cornelia Huck <[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 @@ -32,6 +35,9 @@ struct VFIOCCWDevice {uint64_t io_region_size;uint64_t io_region_offset;struct ccw_io_region *io_region; +uint64_t async_cmd_region_size; +uint64_t async_cmd_region_offset; +struct ccw_cmd_region *async_cmd_region;EventNotifier io_notifier;bool force_orb_pfch;bool warned_orb_pfch;@@ -114,6 +120,87 @@ again: } } +int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region)); + region->command =VFIO_CCW_ASYNC_CMD_CSCH ; + +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +} + +int vfio_ccw_handle_halt (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region)); + region->command =VFIO_CCW_ASYNC_CMD_HSCH ; + +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -EBUSY : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +} +static void vfio_ccw_reset (DeviceState *dev) {CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev);@@ -287,9 +374,13 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp)return ; } +/* +* We always expect at least the I/O region to be present. We also +* may have a variable number of regions governed by capabilities. +*/ if (vdev->num_regions <VFIO_CCW_CONFIG_REGION_INDEX +1 ) { -error_setg (errp,"vfio: Unexpected number of the I/O region %u" , - vdev->num_regions); +error_setg (errp,"vfio: too few regions (%u), expected at least %u" , + vdev->num_regions,VFIO_CCW_CONFIG_REGION_INDEX +1 );return ; }@@ -309,11 +400,26 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) vcdev->io_region_offset = info->offset; vcdev->io_region =g_malloc0 (info->size); +/* check for the optional async command region */ + ret =vfio_get_dev_region_info (vdev,VFIO_REGION_TYPE_CCW , +VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD , &info); +if (!ret) { + vcdev->async_cmd_region_size = info->size; +if (sizeof (*vcdev->async_cmd_region) != vcdev->async_cmd_region_size) { +error_setg (errp,"vfio: Unexpected size of the async cmd region" ); +g_free (info); +return ; + } + vcdev->async_cmd_region_offset = info->offset; + vcdev->async_cmd_region =g_malloc0 (info->size); + } +g_free (info); }static void vfio_ccw_put_region (VFIOCCWDevice *vcdev) { +g_free (vcdev->async_cmd_region);g_free (vcdev->io_region); }include/hw/s390x/s390-ccw.h +0
-0
include/hw/s390x/s390-ccw.h typedef struct S390CCWDeviceClass { · line 42
Quoted 6 lines
include/hw/s390x/s390-ccw.h +3
-0@@ -37,4 +37,7 @@ typedef struct S390CCWDeviceClass {IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass; +int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +
We are not making clear and halt functions part of the S390CCWDeviceClass, is there are reason for doing this? Currently we handle ssch through the handle_request function, it just looks a little inconsistent.
Thanks
Farhan
Quoted 2 lines
include/hw/s390x/s390-ccw.h +0
-0#endif
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 21 lines · On Tue, 21 May 2019 16:50:47 -0400 Farhan Ali <[email protected]> wrote:
Quoted 20 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)include/hw/s390x/s390-ccw.h +0
-0@@ -37,4 +37,7 @@ typedef struct S390CCWDeviceClass {IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass;
Quoted 8 lines
include/hw/s390x/s390-ccw.h typedef struct S390CCWDeviceClass { · line 42
Quoted 3 lines
include/hw/s390x/s390-ccw.h +3
-0+int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +We are not making clear and halt functions part of the S390CCWDeviceClass, is there are reason for doing this? Currently we handle ssch through the
handle_requestfunction, it just looks a little inconsistent.
I don't quite remember why I did it this way; not sure if there is a good reason for that (that patch has been around for too long...)
We can change such internal details later on, though. (And I think your comment has merit.)
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 33 lines · Cornelia Huck
Quoted 21 lines · On Tue, 21 May 2019 16:50:47 -0400 Farhan Ali <[email protected]> wrote:
Quoted 20 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)include/hw/s390x/s390-ccw.h +0
-0@@ -37,4 +37,7 @@ typedef struct S390CCWDeviceClass {IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass;Quoted 8 lines
include/hw/s390x/s390-ccw.h typedef struct S390CCWDeviceClass { · line 42
Quoted 3 lines
include/hw/s390x/s390-ccw.h +3
-0+int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +We are not making clear and halt functions part of the S390CCWDeviceClass, is there are reason for doing this? Currently we handle ssch through the
handle_requestfunction, it just looks a little inconsistent.
Quoted 7 lines
I don't quite remember why I did it this way; not sure if there is a good reason for that (that patch has been around for too long...)
We can change such internal details later on, though. (And I think your comment has merit.)
Yes, sure we could change it later on. I do prefer your way though, it avoids one more layer of indirection.
Thanks
Farhan
Re: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
In reply to Cornelia HuckQuoted 6 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Signed-off-by Cornelia Huck <[email protected]>
This looks fine to me; thanks for the explanations!
Quoted 230 lines
--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)hw/s390x/css.c +23
-4@@ -22,6 +22,7 @@#include "trace.h" #include "hw/s390x/s390_flic.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/s390-ccw.h" typedef struct CrwContainer { CRW crw;@@ -1191,6 +1192,26 @@ static void sch_handle_start_func_virtual(SubchDev *sch) } +static void sch_handle_halt_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_halt (sch); +if (ret == -ENOSYS ) { +sch_handle_halt_func (sch); + } +} + +static void sch_handle_clear_func_passthrough (SubchDev *sch) +{ +int ret; + + ret =vfio_ccw_handle_clear (sch); +if (ret == -ENOSYS ) { +sch_handle_clear_func (sch); + } +} +static IOInstEnding sch_handle_start_func_passthrough (SubchDev *sch) {SCHIB *schib = &sch->curr_status;@@ -1230,11 +1251,9 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sch)SCHIB *schib = &sch->curr_status;if (schib->scsw.ctrl &SCSW_FCTL_CLEAR_FUNC ) { -/* TODO: Clear handling */ -sch_handle_clear_func (sch); +sch_handle_clear_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_HALT_FUNC ) { -/* TODO: Halt handling */ -sch_handle_halt_func (sch); +sch_handle_halt_func_passthrough (sch); }else if (schib->scsw.ctrl &SCSW_FCTL_START_FUNC ) {return sch_handle_start_func_passthrough (sch); }hw/vfio/ccw.c +108
-2@@ -2,9 +2,12 @@* vfio based subchannel assignment support * * Copyright 2017 IBM Corp. +* Copyright 2019 Red Hat, Inc. +* * Author(s): Dong Jia Shi <[email protected]> * Xiao Feng Ren <[email protected]> * Pierre Morel <[email protected]> +* Cornelia Huck <[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 @@ -32,6 +35,9 @@ struct VFIOCCWDevice {uint64_t io_region_size;uint64_t io_region_offset;struct ccw_io_region *io_region; +uint64_t async_cmd_region_size; +uint64_t async_cmd_region_offset; +struct ccw_cmd_region *async_cmd_region;EventNotifier io_notifier;bool force_orb_pfch;bool warned_orb_pfch;@@ -114,6 +120,87 @@ again: } } +int vfio_ccw_handle_clear (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region)); + region->command =VFIO_CCW_ASYNC_CMD_CSCH ; + +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +} + +int vfio_ccw_handle_halt (SubchDev *sch) +{ +S390CCWDevice *cdev = sch->driver_data; +VFIOCCWDevice *vcdev =DO_UPCAST (VFIOCCWDevice, cdev, cdev); +struct ccw_cmd_region *region = vcdev->async_cmd_region; +int ret; + +if (!vcdev->async_cmd_region) { +/* Async command region not available, fall back to emulation */ +return -ENOSYS ; + } + +memset (region,0 ,sizeof (*region)); + region->command =VFIO_CCW_ASYNC_CMD_HSCH ; + +again: + ret =pwrite (vcdev->vdev.fd, region, + vcdev->async_cmd_region_size, vcdev->async_cmd_region_offset); +if (ret != vcdev->async_cmd_region_size) { +if (errno ==EAGAIN ) { + goto again; + } +error_report ("vfio-ccw: write cmd region failed with errno=%d" , errno); + ret = -errno; + }else { + ret = region->ret_code; + } +switch (ret) { +case 0 : +case -EBUSY : +case -ENODEV : +case -EACCES : +return 0 ; +case -EFAULT : +default : +sch_gen_unit_exception (sch); +css_inject_io_interrupt (sch); +return 0 ; + } +} +static void vfio_ccw_reset (DeviceState *dev) {CcwDevice *ccw_dev =DO_UPCAST (CcwDevice, parent_obj, dev);@@ -287,9 +374,13 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp)return ; } +/* +* We always expect at least the I/O region to be present. We also +* may have a variable number of regions governed by capabilities. +*/ if (vdev->num_regions <VFIO_CCW_CONFIG_REGION_INDEX +1 ) { -error_setg (errp,"vfio: Unexpected number of the I/O region %u" , - vdev->num_regions); +error_setg (errp,"vfio: too few regions (%u), expected at least %u" , + vdev->num_regions,VFIO_CCW_CONFIG_REGION_INDEX +1 );return ; }@@ -309,11 +400,26 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) vcdev->io_region_offset = info->offset; vcdev->io_region =g_malloc0 (info->size); +/* check for the optional async command region */ + ret =vfio_get_dev_region_info (vdev,VFIO_REGION_TYPE_CCW , +VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD , &info); +if (!ret) { + vcdev->async_cmd_region_size = info->size; +if (sizeof (*vcdev->async_cmd_region) != vcdev->async_cmd_region_size) { +error_setg (errp,"vfio: Unexpected size of the async cmd region" ); +g_free (info); +return ; + } + vcdev->async_cmd_region_offset = info->offset; + vcdev->async_cmd_region =g_malloc0 (info->size); + } +g_free (info); }static void vfio_ccw_put_region (VFIOCCWDevice *vcdev) { +g_free (vcdev->async_cmd_region);g_free (vcdev->io_region); }include/hw/s390x/s390-ccw.h +3
-0@@ -37,4 +37,7 @@ typedef struct S390CCWDeviceClass { IOInstEnding (*handle_request) (SubchDev *sch); } S390CCWDeviceClass; +int vfio_ccw_handle_clear (SubchDev *sch); +int vfio_ccw_handle_halt (SubchDev *sch); +#endif
Cornelia Huck
AppliedRe: [Qemu-devel] [PATCH v4 2/2] vfio-ccw: support async command subregion
Quoted 6 lines · On Wed, 29 May 2019 09:47:57 -0400 Eric Farman <[email protected]> wrote:
Quoted 5 lines · Cornelia Huck
A vfio-ccw device may provide an async command subregion for issuing halt/clear subchannel requests. If it is present, use it for sending halt/clear request to the device; if not, fall back to emulation (as done today).
Quoted 11 lines
Quoted 1 line
Signed-off-by Cornelia Huck <[email protected]>This looks fine to me; thanks for the explanations!
Reviewed-by Eric Farman <[email protected]>Quoted 5 lines
--- hw/s390x/css.c | 27 +++++++-- hw/vfio/ccw.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/s390x/s390-ccw.h | 3 + 3 files changed, 134 insertions(+), 6 deletions(-)
Thanks for your review!
Queued to s390-next.