18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci============================= 48c2ecf20Sopenharmony_ciThe s390 DIAGNOSE call on KVM 58c2ecf20Sopenharmony_ci============================= 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciKVM on s390 supports the DIAGNOSE call for making hypercalls, both for 88c2ecf20Sopenharmony_cinative hypercalls and for selected hypercalls found on other s390 98c2ecf20Sopenharmony_cihypervisors. 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciNote that bits are numbered as by the usual s390 convention (most significant 128c2ecf20Sopenharmony_cibit on the left). 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciGeneral remarks 168c2ecf20Sopenharmony_ci--------------- 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciDIAGNOSE calls by the guest cause a mandatory intercept. This implies 198c2ecf20Sopenharmony_ciall supported DIAGNOSE calls need to be handled by either KVM or its 208c2ecf20Sopenharmony_ciuserspace. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciAll DIAGNOSE calls supported by KVM use the RS-a format:: 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci -------------------------------------- 258c2ecf20Sopenharmony_ci | '83' | R1 | R3 | B2 | D2 | 268c2ecf20Sopenharmony_ci -------------------------------------- 278c2ecf20Sopenharmony_ci 0 8 12 16 20 31 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciThe second-operand address (obtained by the base/displacement calculation) 308c2ecf20Sopenharmony_ciis not used to address data. Instead, bits 48-63 of this address specify 318c2ecf20Sopenharmony_cithe function code, and bits 0-47 are ignored. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciThe supported DIAGNOSE function codes vary by the userspace used. For 348c2ecf20Sopenharmony_ciDIAGNOSE function codes not specific to KVM, please refer to the 358c2ecf20Sopenharmony_cidocumentation for the s390 hypervisors defining them. 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciDIAGNOSE function code 'X'500' - KVM virtio functions 398c2ecf20Sopenharmony_ci----------------------------------------------------- 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciIf the function code specifies 0x500, various virtio-related functions 428c2ecf20Sopenharmony_ciare performed. 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciGeneral register 1 contains the virtio subfunction code. Supported 458c2ecf20Sopenharmony_civirtio subfunctions depend on KVM's userspace. Generally, userspace 468c2ecf20Sopenharmony_ciprovides either s390-virtio (subcodes 0-2) or virtio-ccw (subcode 3). 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciUpon completion of the DIAGNOSE instruction, general register 2 contains 498c2ecf20Sopenharmony_cithe function's return code, which is either a return code or a subcode 508c2ecf20Sopenharmony_cispecific value. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciSubcode 0 - s390-virtio notification and early console printk 538c2ecf20Sopenharmony_ci Handled by userspace. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciSubcode 1 - s390-virtio reset 568c2ecf20Sopenharmony_ci Handled by userspace. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciSubcode 2 - s390-virtio set status 598c2ecf20Sopenharmony_ci Handled by userspace. 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciSubcode 3 - virtio-ccw notification 628c2ecf20Sopenharmony_ci Handled by either userspace or KVM (ioeventfd case). 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci General register 2 contains a subchannel-identification word denoting 658c2ecf20Sopenharmony_ci the subchannel of the virtio-ccw proxy device to be notified. 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci General register 3 contains the number of the virtqueue to be notified. 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci General register 4 contains a 64bit identifier for KVM usage (the 708c2ecf20Sopenharmony_ci kvm_io_bus cookie). If general register 4 does not contain a valid 718c2ecf20Sopenharmony_ci identifier, it is ignored. 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci After completion of the DIAGNOSE call, general register 2 may contain 748c2ecf20Sopenharmony_ci a 64bit identifier (in the kvm_io_bus cookie case), or a negative 758c2ecf20Sopenharmony_ci error value, if an internal error occurred. 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci See also the virtio standard for a discussion of this hypercall. 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ciDIAGNOSE function code 'X'501 - KVM breakpoint 818c2ecf20Sopenharmony_ci---------------------------------------------- 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciIf the function code specifies 0x501, breakpoint functions may be performed. 848c2ecf20Sopenharmony_ciThis function code is handled by userspace. 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ciThis diagnose function code has no subfunctions and uses no parameters. 87