1 .. SPDX-License-Identifier: GPL-2.0
3 =============================
4 The s390 DIAGNOSE call on KVM
5 =============================
7 KVM on s390 supports the DIAGNOSE call for making hypercalls, both for
8 native hypercalls and for selected hypercalls found on other s390
11 Note that bits are numbered as by the usual s390 convention (most significant
18 DIAGNOSE calls by the guest cause a mandatory intercept. This implies
19 all supported DIAGNOSE calls need to be handled by either KVM or its
22 All DIAGNOSE calls supported by KVM use the RS-a format::
24 --------------------------------------
25 | '83' | R1 | R3 | B2 | D2 |
26 --------------------------------------
29 The second-operand address (obtained by the base/displacement calculation)
30 is not used to address data. Instead, bits 48-63 of this address specify
31 the function code, and bits 0-47 are ignored.
33 The supported DIAGNOSE function codes vary by the userspace used. For
34 DIAGNOSE function codes not specific to KVM, please refer to the
35 documentation for the s390 hypervisors defining them.
38 DIAGNOSE function code 'X'500' - KVM virtio functions
39 -----------------------------------------------------
41 If the function code specifies 0x500, various virtio-related functions
44 General register 1 contains the virtio subfunction code. Supported
45 virtio subfunctions depend on KVM's userspace. Generally, userspace
46 provides either s390-virtio (subcodes 0-2) or virtio-ccw (subcode 3).
48 Upon completion of the DIAGNOSE instruction, general register 2 contains
49 the function's return code, which is either a return code or a subcode
52 Subcode 0 - s390-virtio notification and early console printk
55 Subcode 1 - s390-virtio reset
58 Subcode 2 - s390-virtio set status
61 Subcode 3 - virtio-ccw notification
62 Handled by either userspace or KVM (ioeventfd case).
64 General register 2 contains a subchannel-identification word denoting
65 the subchannel of the virtio-ccw proxy device to be notified.
67 General register 3 contains the number of the virtqueue to be notified.
69 General register 4 contains a 64bit identifier for KVM usage (the
70 kvm_io_bus cookie). If general register 4 does not contain a valid
71 identifier, it is ignored.
73 After completion of the DIAGNOSE call, general register 2 may contain
74 a 64bit identifier (in the kvm_io_bus cookie case), or a negative
75 error value, if an internal error occurred.
77 See also the virtio standard for a discussion of this hypercall.
80 DIAGNOSE function code 'X'501 - KVM breakpoint
81 ----------------------------------------------
83 If the function code specifies 0x501, breakpoint functions may be performed.
84 This function code is handled by userspace.
86 This diagnose function code has no subfunctions and uses no parameters.