1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun============================= 4*4882a593SmuzhiyunThe s390 DIAGNOSE call on KVM 5*4882a593Smuzhiyun============================= 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunKVM on s390 supports the DIAGNOSE call for making hypercalls, both for 8*4882a593Smuzhiyunnative hypercalls and for selected hypercalls found on other s390 9*4882a593Smuzhiyunhypervisors. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunNote that bits are numbered as by the usual s390 convention (most significant 12*4882a593Smuzhiyunbit on the left). 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunGeneral remarks 16*4882a593Smuzhiyun--------------- 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunDIAGNOSE calls by the guest cause a mandatory intercept. This implies 19*4882a593Smuzhiyunall supported DIAGNOSE calls need to be handled by either KVM or its 20*4882a593Smuzhiyunuserspace. 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunAll DIAGNOSE calls supported by KVM use the RS-a format:: 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun -------------------------------------- 25*4882a593Smuzhiyun | '83' | R1 | R3 | B2 | D2 | 26*4882a593Smuzhiyun -------------------------------------- 27*4882a593Smuzhiyun 0 8 12 16 20 31 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunThe second-operand address (obtained by the base/displacement calculation) 30*4882a593Smuzhiyunis not used to address data. Instead, bits 48-63 of this address specify 31*4882a593Smuzhiyunthe function code, and bits 0-47 are ignored. 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunThe supported DIAGNOSE function codes vary by the userspace used. For 34*4882a593SmuzhiyunDIAGNOSE function codes not specific to KVM, please refer to the 35*4882a593Smuzhiyundocumentation for the s390 hypervisors defining them. 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunDIAGNOSE function code 'X'500' - KVM virtio functions 39*4882a593Smuzhiyun----------------------------------------------------- 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunIf the function code specifies 0x500, various virtio-related functions 42*4882a593Smuzhiyunare performed. 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunGeneral register 1 contains the virtio subfunction code. Supported 45*4882a593Smuzhiyunvirtio subfunctions depend on KVM's userspace. Generally, userspace 46*4882a593Smuzhiyunprovides either s390-virtio (subcodes 0-2) or virtio-ccw (subcode 3). 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunUpon completion of the DIAGNOSE instruction, general register 2 contains 49*4882a593Smuzhiyunthe function's return code, which is either a return code or a subcode 50*4882a593Smuzhiyunspecific value. 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunSubcode 0 - s390-virtio notification and early console printk 53*4882a593Smuzhiyun Handled by userspace. 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunSubcode 1 - s390-virtio reset 56*4882a593Smuzhiyun Handled by userspace. 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunSubcode 2 - s390-virtio set status 59*4882a593Smuzhiyun Handled by userspace. 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunSubcode 3 - virtio-ccw notification 62*4882a593Smuzhiyun Handled by either userspace or KVM (ioeventfd case). 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun General register 2 contains a subchannel-identification word denoting 65*4882a593Smuzhiyun the subchannel of the virtio-ccw proxy device to be notified. 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun General register 3 contains the number of the virtqueue to be notified. 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun General register 4 contains a 64bit identifier for KVM usage (the 70*4882a593Smuzhiyun kvm_io_bus cookie). If general register 4 does not contain a valid 71*4882a593Smuzhiyun identifier, it is ignored. 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun After completion of the DIAGNOSE call, general register 2 may contain 74*4882a593Smuzhiyun a 64bit identifier (in the kvm_io_bus cookie case), or a negative 75*4882a593Smuzhiyun error value, if an internal error occurred. 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun See also the virtio standard for a discussion of this hypercall. 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun 80*4882a593SmuzhiyunDIAGNOSE function code 'X'501 - KVM breakpoint 81*4882a593Smuzhiyun---------------------------------------------- 82*4882a593Smuzhiyun 83*4882a593SmuzhiyunIf the function code specifies 0x501, breakpoint functions may be performed. 84*4882a593SmuzhiyunThis function code is handled by userspace. 85*4882a593Smuzhiyun 86*4882a593SmuzhiyunThis diagnose function code has no subfunctions and uses no parameters. 87