KVM: s390: interface to query and configure cpu subfunctions
[cascardo/linux.git] / Documentation / virtual / kvm / devices / vm.txt
1 Generic vm interface
2 ====================================
3
4 The virtual machine "device" also accepts the ioctls KVM_SET_DEVICE_ATTR,
5 KVM_GET_DEVICE_ATTR, and KVM_HAS_DEVICE_ATTR. The interface uses the same
6 struct kvm_device_attr as other devices, but targets VM-wide settings
7 and controls.
8
9 The groups and attributes per virtual machine, if any, are architecture
10 specific.
11
12 1. GROUP: KVM_S390_VM_MEM_CTRL
13 Architectures: s390
14
15 1.1. ATTRIBUTE: KVM_S390_VM_MEM_ENABLE_CMMA
16 Parameters: none
17 Returns: -EBUSY if a vcpu is already defined, otherwise 0
18
19 Enables Collaborative Memory Management Assist (CMMA) for the virtual machine.
20
21 1.2. ATTRIBUTE: KVM_S390_VM_MEM_CLR_CMMA
22 Parameters: none
23 Returns: 0
24
25 Clear the CMMA status for all guest pages, so any pages the guest marked
26 as unused are again used any may not be reclaimed by the host.
27
28 1.3. ATTRIBUTE KVM_S390_VM_MEM_LIMIT_SIZE
29 Parameters: in attr->addr the address for the new limit of guest memory
30 Returns: -EFAULT if the given address is not accessible
31          -EINVAL if the virtual machine is of type UCONTROL
32          -E2BIG if the given guest memory is to big for that machine
33          -EBUSY if a vcpu is already defined
34          -ENOMEM if not enough memory is available for a new shadow guest mapping
35           0 otherwise
36
37 Allows userspace to query the actual limit and set a new limit for
38 the maximum guest memory size. The limit will be rounded up to
39 2048 MB, 4096 GB, 8192 TB respectively, as this limit is governed by
40 the number of page table levels. In the case that there is no limit we will set
41 the limit to KVM_S390_NO_MEM_LIMIT (U64_MAX).
42
43 2. GROUP: KVM_S390_VM_CPU_MODEL
44 Architectures: s390
45
46 2.1. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE (r/o)
47
48 Allows user space to retrieve machine and kvm specific cpu related information:
49
50 struct kvm_s390_vm_cpu_machine {
51        __u64 cpuid;           # CPUID of host
52        __u32 ibc;             # IBC level range offered by host
53        __u8  pad[4];
54        __u64 fac_mask[256];   # set of cpu facilities enabled by KVM
55        __u64 fac_list[256];   # set of cpu facilities offered by host
56 }
57
58 Parameters: address of buffer to store the machine related cpu data
59             of type struct kvm_s390_vm_cpu_machine*
60 Returns:    -EFAULT if the given address is not accessible from kernel space
61             -ENOMEM if not enough memory is available to process the ioctl
62             0 in case of success
63
64 2.2. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR (r/w)
65
66 Allows user space to retrieve or request to change cpu related information for a vcpu:
67
68 struct kvm_s390_vm_cpu_processor {
69        __u64 cpuid;           # CPUID currently (to be) used by this vcpu
70        __u16 ibc;             # IBC level currently (to be) used by this vcpu
71        __u8  pad[6];
72        __u64 fac_list[256];   # set of cpu facilities currently (to be) used
73                               # by this vcpu
74 }
75
76 KVM does not enforce or limit the cpu model data in any form. Take the information
77 retrieved by means of KVM_S390_VM_CPU_MACHINE as hint for reasonable configuration
78 setups. Instruction interceptions triggered by additionally set facility bits that
79 are not handled by KVM need to by imlemented in the VM driver code.
80
81 Parameters: address of buffer to store/set the processor related cpu
82             data of type struct kvm_s390_vm_cpu_processor*.
83 Returns:    -EBUSY in case 1 or more vcpus are already activated (only in write case)
84             -EFAULT if the given address is not accessible from kernel space
85             -ENOMEM if not enough memory is available to process the ioctl
86             0 in case of success
87
88 2.3. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE_FEAT (r/o)
89
90 Allows user space to retrieve available cpu features. A feature is available if
91 provided by the hardware and supported by kvm. In theory, cpu features could
92 even be completely emulated by kvm.
93
94 struct kvm_s390_vm_cpu_feat {
95         __u64 feat[16]; # Bitmap (1 = feature available), MSB 0 bit numbering
96 };
97
98 Parameters: address of a buffer to load the feature list from.
99 Returns:    -EFAULT if the given address is not accessible from kernel space.
100             0 in case of success.
101
102 2.4. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR_FEAT (r/w)
103
104 Allows user space to retrieve or change enabled cpu features for all VCPUs of a
105 VM. Features that are not available cannot be enabled.
106
107 See 2.3. for a description of the parameter struct.
108
109 Parameters: address of a buffer to store/load the feature list from.
110 Returns:    -EFAULT if the given address is not accessible from kernel space.
111             -EINVAL if a cpu feature that is not available is to be enabled.
112             -EBUSY if at least one VCPU has already been defined.
113             0 in case of success.
114
115 2.5. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE_SUBFUNC (r/o)
116
117 Allows user space to retrieve available cpu subfunctions without any filtering
118 done by a set IBC. These subfunctions are indicated to the guest VCPU via
119 query or "test bit" subfunctions and used e.g. by cpacf functions, plo and ptff.
120
121 A subfunction block is only valid if KVM_S390_VM_CPU_MACHINE contains the
122 STFL(E) bit introducing the affected instruction. If the affected instruction
123 indicates subfunctions via a "query subfunction", the response block is
124 contained in the returned struct. If the affected instruction
125 indicates subfunctions via a "test bit" mechanism, the subfunction codes are
126 contained in the returned struct in MSB 0 bit numbering.
127
128 struct kvm_s390_vm_cpu_subfunc {
129        u8 plo[32];           # always valid (ESA/390 feature)
130        u8 ptff[16];          # valid with TOD-clock steering
131        u8 kmac[16];          # valid with Message-Security-Assist
132        u8 kmc[16];           # valid with Message-Security-Assist
133        u8 km[16];            # valid with Message-Security-Assist
134        u8 kimd[16];          # valid with Message-Security-Assist
135        u8 klmd[16];          # valid with Message-Security-Assist
136        u8 pckmo[16];         # valid with Message-Security-Assist-Extension 3
137        u8 kmctr[16];         # valid with Message-Security-Assist-Extension 4
138        u8 kmf[16];           # valid with Message-Security-Assist-Extension 4
139        u8 kmo[16];           # valid with Message-Security-Assist-Extension 4
140        u8 pcc[16];           # valid with Message-Security-Assist-Extension 4
141        u8 ppno[16];          # valid with Message-Security-Assist-Extension 5
142        u8 reserved[1824];    # reserved for future instructions
143 };
144
145 Parameters: address of a buffer to load the subfunction blocks from.
146 Returns:    -EFAULT if the given address is not accessible from kernel space.
147             0 in case of success.
148
149 2.6. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR_SUBFUNC (r/w)
150
151 Allows user space to retrieve or change cpu subfunctions to be indicated for
152 all VCPUs of a VM. This attribute will only be available if kernel and
153 hardware support are in place.
154
155 The kernel uses the configured subfunction blocks for indication to
156 the guest. A subfunction block will only be used if the associated STFL(E) bit
157 has not been disabled by user space (so the instruction to be queried is
158 actually available for the guest).
159
160 As long as no data has been written, a read will fail. The IBC will be used
161 to determine available subfunctions in this case, this will guarantee backward
162 compatibility.
163
164 See 2.5. for a description of the parameter struct.
165
166 Parameters: address of a buffer to store/load the subfunction blocks from.
167 Returns:    -EFAULT if the given address is not accessible from kernel space.
168             -EINVAL when reading, if there was no write yet.
169             -EBUSY if at least one VCPU has already been defined.
170             0 in case of success.
171
172 3. GROUP: KVM_S390_VM_TOD
173 Architectures: s390
174
175 3.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH
176
177 Allows user space to set/get the TOD clock extension (u8).
178
179 Parameters: address of a buffer in user space to store the data (u8) to
180 Returns:    -EFAULT if the given address is not accessible from kernel space
181             -EINVAL if setting the TOD clock extension to != 0 is not supported
182
183 3.2. ATTRIBUTE: KVM_S390_VM_TOD_LOW
184
185 Allows user space to set/get bits 0-63 of the TOD clock register as defined in
186 the POP (u64).
187
188 Parameters: address of a buffer in user space to store the data (u64) to
189 Returns:    -EFAULT if the given address is not accessible from kernel space
190
191 4. GROUP: KVM_S390_VM_CRYPTO
192 Architectures: s390
193
194 4.1. ATTRIBUTE: KVM_S390_VM_CRYPTO_ENABLE_AES_KW (w/o)
195
196 Allows user space to enable aes key wrapping, including generating a new
197 wrapping key.
198
199 Parameters: none
200 Returns:    0
201
202 4.2. ATTRIBUTE: KVM_S390_VM_CRYPTO_ENABLE_DEA_KW (w/o)
203
204 Allows user space to enable dea key wrapping, including generating a new
205 wrapping key.
206
207 Parameters: none
208 Returns:    0
209
210 4.3. ATTRIBUTE: KVM_S390_VM_CRYPTO_DISABLE_AES_KW (w/o)
211
212 Allows user space to disable aes key wrapping, clearing the wrapping key.
213
214 Parameters: none
215 Returns:    0
216
217 4.4. ATTRIBUTE: KVM_S390_VM_CRYPTO_DISABLE_DEA_KW (w/o)
218
219 Allows user space to disable dea key wrapping, clearing the wrapping key.
220
221 Parameters: none
222 Returns:    0