xref: /linux/Documentation/virt/kvm/devices/vm.rst (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
16c972ba6SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
26c972ba6SMauro Carvalho Chehab
36c972ba6SMauro Carvalho Chehab====================
46c972ba6SMauro Carvalho ChehabGeneric vm interface
56c972ba6SMauro Carvalho Chehab====================
66c972ba6SMauro Carvalho Chehab
76c972ba6SMauro Carvalho ChehabThe virtual machine "device" also accepts the ioctls KVM_SET_DEVICE_ATTR,
86c972ba6SMauro Carvalho ChehabKVM_GET_DEVICE_ATTR, and KVM_HAS_DEVICE_ATTR. The interface uses the same
96c972ba6SMauro Carvalho Chehabstruct kvm_device_attr as other devices, but targets VM-wide settings
106c972ba6SMauro Carvalho Chehaband controls.
116c972ba6SMauro Carvalho Chehab
126c972ba6SMauro Carvalho ChehabThe groups and attributes per virtual machine, if any, are architecture
136c972ba6SMauro Carvalho Chehabspecific.
146c972ba6SMauro Carvalho Chehab
156c972ba6SMauro Carvalho Chehab1. GROUP: KVM_S390_VM_MEM_CTRL
166c972ba6SMauro Carvalho Chehab==============================
176c972ba6SMauro Carvalho Chehab
186c972ba6SMauro Carvalho Chehab:Architectures: s390
196c972ba6SMauro Carvalho Chehab
206c972ba6SMauro Carvalho Chehab1.1. ATTRIBUTE: KVM_S390_VM_MEM_ENABLE_CMMA
216c972ba6SMauro Carvalho Chehab-------------------------------------------
226c972ba6SMauro Carvalho Chehab
236c972ba6SMauro Carvalho Chehab:Parameters: none
246c972ba6SMauro Carvalho Chehab:Returns: -EBUSY if a vcpu is already defined, otherwise 0
256c972ba6SMauro Carvalho Chehab
266c972ba6SMauro Carvalho ChehabEnables Collaborative Memory Management Assist (CMMA) for the virtual machine.
276c972ba6SMauro Carvalho Chehab
286c972ba6SMauro Carvalho Chehab1.2. ATTRIBUTE: KVM_S390_VM_MEM_CLR_CMMA
296c972ba6SMauro Carvalho Chehab----------------------------------------
306c972ba6SMauro Carvalho Chehab
316c972ba6SMauro Carvalho Chehab:Parameters: none
326c972ba6SMauro Carvalho Chehab:Returns: -EINVAL if CMMA was not enabled;
336c972ba6SMauro Carvalho Chehab	  0 otherwise
346c972ba6SMauro Carvalho Chehab
356c972ba6SMauro Carvalho ChehabClear the CMMA status for all guest pages, so any pages the guest marked
366c972ba6SMauro Carvalho Chehabas unused are again used any may not be reclaimed by the host.
376c972ba6SMauro Carvalho Chehab
386c972ba6SMauro Carvalho Chehab1.3. ATTRIBUTE KVM_S390_VM_MEM_LIMIT_SIZE
396c972ba6SMauro Carvalho Chehab-----------------------------------------
406c972ba6SMauro Carvalho Chehab
416c972ba6SMauro Carvalho Chehab:Parameters: in attr->addr the address for the new limit of guest memory
426c972ba6SMauro Carvalho Chehab:Returns: -EFAULT if the given address is not accessible;
436c972ba6SMauro Carvalho Chehab	  -EINVAL if the virtual machine is of type UCONTROL;
446c972ba6SMauro Carvalho Chehab	  -E2BIG if the given guest memory is to big for that machine;
456c972ba6SMauro Carvalho Chehab	  -EBUSY if a vcpu is already defined;
466c972ba6SMauro Carvalho Chehab	  -ENOMEM if not enough memory is available for a new shadow guest mapping;
476c972ba6SMauro Carvalho Chehab	  0 otherwise.
486c972ba6SMauro Carvalho Chehab
496c972ba6SMauro Carvalho ChehabAllows userspace to query the actual limit and set a new limit for
506c972ba6SMauro Carvalho Chehabthe maximum guest memory size. The limit will be rounded up to
516c972ba6SMauro Carvalho Chehab2048 MB, 4096 GB, 8192 TB respectively, as this limit is governed by
526c972ba6SMauro Carvalho Chehabthe number of page table levels. In the case that there is no limit we will set
536c972ba6SMauro Carvalho Chehabthe limit to KVM_S390_NO_MEM_LIMIT (U64_MAX).
546c972ba6SMauro Carvalho Chehab
556c972ba6SMauro Carvalho Chehab2. GROUP: KVM_S390_VM_CPU_MODEL
566c972ba6SMauro Carvalho Chehab===============================
576c972ba6SMauro Carvalho Chehab
586c972ba6SMauro Carvalho Chehab:Architectures: s390
596c972ba6SMauro Carvalho Chehab
606c972ba6SMauro Carvalho Chehab2.1. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE (r/o)
616c972ba6SMauro Carvalho Chehab---------------------------------------------
626c972ba6SMauro Carvalho Chehab
636c972ba6SMauro Carvalho ChehabAllows user space to retrieve machine and kvm specific cpu related information::
646c972ba6SMauro Carvalho Chehab
656c972ba6SMauro Carvalho Chehab  struct kvm_s390_vm_cpu_machine {
666c972ba6SMauro Carvalho Chehab       __u64 cpuid;           # CPUID of host
676c972ba6SMauro Carvalho Chehab       __u32 ibc;             # IBC level range offered by host
686c972ba6SMauro Carvalho Chehab       __u8  pad[4];
696c972ba6SMauro Carvalho Chehab       __u64 fac_mask[256];   # set of cpu facilities enabled by KVM
706c972ba6SMauro Carvalho Chehab       __u64 fac_list[256];   # set of cpu facilities offered by host
716c972ba6SMauro Carvalho Chehab  }
726c972ba6SMauro Carvalho Chehab
736c972ba6SMauro Carvalho Chehab:Parameters: address of buffer to store the machine related cpu data
746c972ba6SMauro Carvalho Chehab	     of type struct kvm_s390_vm_cpu_machine*
756c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
766c972ba6SMauro Carvalho Chehab	    -ENOMEM if not enough memory is available to process the ioctl;
776c972ba6SMauro Carvalho Chehab	    0 in case of success.
786c972ba6SMauro Carvalho Chehab
796c972ba6SMauro Carvalho Chehab2.2. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR (r/w)
806c972ba6SMauro Carvalho Chehab===============================================
816c972ba6SMauro Carvalho Chehab
826c972ba6SMauro Carvalho ChehabAllows user space to retrieve or request to change cpu related information for a vcpu::
836c972ba6SMauro Carvalho Chehab
846c972ba6SMauro Carvalho Chehab  struct kvm_s390_vm_cpu_processor {
856c972ba6SMauro Carvalho Chehab       __u64 cpuid;           # CPUID currently (to be) used by this vcpu
866c972ba6SMauro Carvalho Chehab       __u16 ibc;             # IBC level currently (to be) used by this vcpu
876c972ba6SMauro Carvalho Chehab       __u8  pad[6];
886c972ba6SMauro Carvalho Chehab       __u64 fac_list[256];   # set of cpu facilities currently (to be) used
896c972ba6SMauro Carvalho Chehab			      # by this vcpu
906c972ba6SMauro Carvalho Chehab  }
916c972ba6SMauro Carvalho Chehab
926c972ba6SMauro Carvalho ChehabKVM does not enforce or limit the cpu model data in any form. Take the information
936c972ba6SMauro Carvalho Chehabretrieved by means of KVM_S390_VM_CPU_MACHINE as hint for reasonable configuration
946c972ba6SMauro Carvalho Chehabsetups. Instruction interceptions triggered by additionally set facility bits that
95*d56b699dSBjorn Helgaasare not handled by KVM need to by implemented in the VM driver code.
966c972ba6SMauro Carvalho Chehab
976c972ba6SMauro Carvalho Chehab:Parameters: address of buffer to store/set the processor related cpu
986c972ba6SMauro Carvalho Chehab	     data of type struct kvm_s390_vm_cpu_processor*.
996c972ba6SMauro Carvalho Chehab:Returns:  -EBUSY in case 1 or more vcpus are already activated (only in write case);
1006c972ba6SMauro Carvalho Chehab	   -EFAULT if the given address is not accessible from kernel space;
1016c972ba6SMauro Carvalho Chehab	   -ENOMEM if not enough memory is available to process the ioctl;
1026c972ba6SMauro Carvalho Chehab	   0 in case of success.
1036c972ba6SMauro Carvalho Chehab
1046c972ba6SMauro Carvalho Chehab.. _KVM_S390_VM_CPU_MACHINE_FEAT:
1056c972ba6SMauro Carvalho Chehab
1066c972ba6SMauro Carvalho Chehab2.3. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE_FEAT (r/o)
1076c972ba6SMauro Carvalho Chehab--------------------------------------------------
1086c972ba6SMauro Carvalho Chehab
1096c972ba6SMauro Carvalho ChehabAllows user space to retrieve available cpu features. A feature is available if
1106c972ba6SMauro Carvalho Chehabprovided by the hardware and supported by kvm. In theory, cpu features could
1116c972ba6SMauro Carvalho Chehabeven be completely emulated by kvm.
1126c972ba6SMauro Carvalho Chehab
1136c972ba6SMauro Carvalho Chehab::
1146c972ba6SMauro Carvalho Chehab
1156c972ba6SMauro Carvalho Chehab  struct kvm_s390_vm_cpu_feat {
1166c972ba6SMauro Carvalho Chehab	__u64 feat[16]; # Bitmap (1 = feature available), MSB 0 bit numbering
1176c972ba6SMauro Carvalho Chehab  };
1186c972ba6SMauro Carvalho Chehab
1196c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer to load the feature list from.
1206c972ba6SMauro Carvalho Chehab:Returns:  -EFAULT if the given address is not accessible from kernel space;
1216c972ba6SMauro Carvalho Chehab	   0 in case of success.
1226c972ba6SMauro Carvalho Chehab
1236c972ba6SMauro Carvalho Chehab2.4. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR_FEAT (r/w)
1246c972ba6SMauro Carvalho Chehab----------------------------------------------------
1256c972ba6SMauro Carvalho Chehab
1266c972ba6SMauro Carvalho ChehabAllows user space to retrieve or change enabled cpu features for all VCPUs of a
1276c972ba6SMauro Carvalho ChehabVM. Features that are not available cannot be enabled.
1286c972ba6SMauro Carvalho Chehab
1296c972ba6SMauro Carvalho ChehabSee :ref:`KVM_S390_VM_CPU_MACHINE_FEAT` for
1306c972ba6SMauro Carvalho Chehaba description of the parameter struct.
1316c972ba6SMauro Carvalho Chehab
1326c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer to store/load the feature list from.
1336c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
1346c972ba6SMauro Carvalho Chehab	    -EINVAL if a cpu feature that is not available is to be enabled;
1356c972ba6SMauro Carvalho Chehab	    -EBUSY if at least one VCPU has already been defined;
1366c972ba6SMauro Carvalho Chehab	    0 in case of success.
1376c972ba6SMauro Carvalho Chehab
1386c972ba6SMauro Carvalho Chehab.. _KVM_S390_VM_CPU_MACHINE_SUBFUNC:
1396c972ba6SMauro Carvalho Chehab
1406c972ba6SMauro Carvalho Chehab2.5. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE_SUBFUNC (r/o)
1416c972ba6SMauro Carvalho Chehab-----------------------------------------------------
1426c972ba6SMauro Carvalho Chehab
1436c972ba6SMauro Carvalho ChehabAllows user space to retrieve available cpu subfunctions without any filtering
1446c972ba6SMauro Carvalho Chehabdone by a set IBC. These subfunctions are indicated to the guest VCPU via
1456c972ba6SMauro Carvalho Chehabquery or "test bit" subfunctions and used e.g. by cpacf functions, plo and ptff.
1466c972ba6SMauro Carvalho Chehab
1476c972ba6SMauro Carvalho ChehabA subfunction block is only valid if KVM_S390_VM_CPU_MACHINE contains the
1486c972ba6SMauro Carvalho ChehabSTFL(E) bit introducing the affected instruction. If the affected instruction
1496c972ba6SMauro Carvalho Chehabindicates subfunctions via a "query subfunction", the response block is
1506c972ba6SMauro Carvalho Chehabcontained in the returned struct. If the affected instruction
1516c972ba6SMauro Carvalho Chehabindicates subfunctions via a "test bit" mechanism, the subfunction codes are
1526c972ba6SMauro Carvalho Chehabcontained in the returned struct in MSB 0 bit numbering.
1536c972ba6SMauro Carvalho Chehab
1546c972ba6SMauro Carvalho Chehab::
1556c972ba6SMauro Carvalho Chehab
1566c972ba6SMauro Carvalho Chehab  struct kvm_s390_vm_cpu_subfunc {
1576c972ba6SMauro Carvalho Chehab       u8 plo[32];           # always valid (ESA/390 feature)
1586c972ba6SMauro Carvalho Chehab       u8 ptff[16];          # valid with TOD-clock steering
1596c972ba6SMauro Carvalho Chehab       u8 kmac[16];          # valid with Message-Security-Assist
1606c972ba6SMauro Carvalho Chehab       u8 kmc[16];           # valid with Message-Security-Assist
1616c972ba6SMauro Carvalho Chehab       u8 km[16];            # valid with Message-Security-Assist
1626c972ba6SMauro Carvalho Chehab       u8 kimd[16];          # valid with Message-Security-Assist
1636c972ba6SMauro Carvalho Chehab       u8 klmd[16];          # valid with Message-Security-Assist
1646c972ba6SMauro Carvalho Chehab       u8 pckmo[16];         # valid with Message-Security-Assist-Extension 3
1656c972ba6SMauro Carvalho Chehab       u8 kmctr[16];         # valid with Message-Security-Assist-Extension 4
1666c972ba6SMauro Carvalho Chehab       u8 kmf[16];           # valid with Message-Security-Assist-Extension 4
1676c972ba6SMauro Carvalho Chehab       u8 kmo[16];           # valid with Message-Security-Assist-Extension 4
1686c972ba6SMauro Carvalho Chehab       u8 pcc[16];           # valid with Message-Security-Assist-Extension 4
1696c972ba6SMauro Carvalho Chehab       u8 ppno[16];          # valid with Message-Security-Assist-Extension 5
1706c972ba6SMauro Carvalho Chehab       u8 kma[16];           # valid with Message-Security-Assist-Extension 8
1716c972ba6SMauro Carvalho Chehab       u8 kdsa[16];          # valid with Message-Security-Assist-Extension 9
1726c972ba6SMauro Carvalho Chehab       u8 reserved[1792];    # reserved for future instructions
1736c972ba6SMauro Carvalho Chehab  };
1746c972ba6SMauro Carvalho Chehab
1756c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer to load the subfunction blocks from.
1766c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
1776c972ba6SMauro Carvalho Chehab	    0 in case of success.
1786c972ba6SMauro Carvalho Chehab
1796c972ba6SMauro Carvalho Chehab2.6. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR_SUBFUNC (r/w)
1806c972ba6SMauro Carvalho Chehab-------------------------------------------------------
1816c972ba6SMauro Carvalho Chehab
1826c972ba6SMauro Carvalho ChehabAllows user space to retrieve or change cpu subfunctions to be indicated for
1836c972ba6SMauro Carvalho Chehaball VCPUs of a VM. This attribute will only be available if kernel and
1846c972ba6SMauro Carvalho Chehabhardware support are in place.
1856c972ba6SMauro Carvalho Chehab
1866c972ba6SMauro Carvalho ChehabThe kernel uses the configured subfunction blocks for indication to
1876c972ba6SMauro Carvalho Chehabthe guest. A subfunction block will only be used if the associated STFL(E) bit
1886c972ba6SMauro Carvalho Chehabhas not been disabled by user space (so the instruction to be queried is
1896c972ba6SMauro Carvalho Chehabactually available for the guest).
1906c972ba6SMauro Carvalho Chehab
1916c972ba6SMauro Carvalho ChehabAs long as no data has been written, a read will fail. The IBC will be used
1926c972ba6SMauro Carvalho Chehabto determine available subfunctions in this case, this will guarantee backward
1936c972ba6SMauro Carvalho Chehabcompatibility.
1946c972ba6SMauro Carvalho Chehab
1956c972ba6SMauro Carvalho ChehabSee :ref:`KVM_S390_VM_CPU_MACHINE_SUBFUNC` for a
1966c972ba6SMauro Carvalho Chehabdescription of the parameter struct.
1976c972ba6SMauro Carvalho Chehab
1986c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer to store/load the subfunction blocks from.
1996c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
2006c972ba6SMauro Carvalho Chehab	    -EINVAL when reading, if there was no write yet;
2016c972ba6SMauro Carvalho Chehab	    -EBUSY if at least one VCPU has already been defined;
2026c972ba6SMauro Carvalho Chehab	    0 in case of success.
2036c972ba6SMauro Carvalho Chehab
2046c972ba6SMauro Carvalho Chehab3. GROUP: KVM_S390_VM_TOD
2056c972ba6SMauro Carvalho Chehab=========================
2066c972ba6SMauro Carvalho Chehab
2076c972ba6SMauro Carvalho Chehab:Architectures: s390
2086c972ba6SMauro Carvalho Chehab
2096c972ba6SMauro Carvalho Chehab3.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH
2106c972ba6SMauro Carvalho Chehab------------------------------------
2116c972ba6SMauro Carvalho Chehab
2126c972ba6SMauro Carvalho ChehabAllows user space to set/get the TOD clock extension (u8) (superseded by
2136c972ba6SMauro Carvalho ChehabKVM_S390_VM_TOD_EXT).
2146c972ba6SMauro Carvalho Chehab
2156c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer in user space to store the data (u8) to
2166c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
2176c972ba6SMauro Carvalho Chehab	    -EINVAL if setting the TOD clock extension to != 0 is not supported
2186973091dSNico Boehr	    -EOPNOTSUPP for a PV guest (TOD managed by the ultravisor)
2196c972ba6SMauro Carvalho Chehab
2206c972ba6SMauro Carvalho Chehab3.2. ATTRIBUTE: KVM_S390_VM_TOD_LOW
2216c972ba6SMauro Carvalho Chehab-----------------------------------
2226c972ba6SMauro Carvalho Chehab
2236c972ba6SMauro Carvalho ChehabAllows user space to set/get bits 0-63 of the TOD clock register as defined in
2246c972ba6SMauro Carvalho Chehabthe POP (u64).
2256c972ba6SMauro Carvalho Chehab
2266c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer in user space to store the data (u64) to
2276c972ba6SMauro Carvalho Chehab:Returns:    -EFAULT if the given address is not accessible from kernel space
2286973091dSNico Boehr	     -EOPNOTSUPP for a PV guest (TOD managed by the ultravisor)
2296c972ba6SMauro Carvalho Chehab
2306c972ba6SMauro Carvalho Chehab3.3. ATTRIBUTE: KVM_S390_VM_TOD_EXT
2316c972ba6SMauro Carvalho Chehab-----------------------------------
2326c972ba6SMauro Carvalho Chehab
2336c972ba6SMauro Carvalho ChehabAllows user space to set/get bits 0-63 of the TOD clock register as defined in
2346c972ba6SMauro Carvalho Chehabthe POP (u64). If the guest CPU model supports the TOD clock extension (u8), it
2356c972ba6SMauro Carvalho Chehabalso allows user space to get/set it. If the guest CPU model does not support
2366c972ba6SMauro Carvalho Chehabit, it is stored as 0 and not allowed to be set to a value != 0.
2376c972ba6SMauro Carvalho Chehab
2386c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer in user space to store the data
2396c972ba6SMauro Carvalho Chehab	     (kvm_s390_vm_tod_clock) to
2406c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
2416c972ba6SMauro Carvalho Chehab	    -EINVAL if setting the TOD clock extension to != 0 is not supported
2426973091dSNico Boehr	    -EOPNOTSUPP for a PV guest (TOD managed by the ultravisor)
2436c972ba6SMauro Carvalho Chehab
2446c972ba6SMauro Carvalho Chehab4. GROUP: KVM_S390_VM_CRYPTO
2456c972ba6SMauro Carvalho Chehab============================
2466c972ba6SMauro Carvalho Chehab
2476c972ba6SMauro Carvalho Chehab:Architectures: s390
2486c972ba6SMauro Carvalho Chehab
2496c972ba6SMauro Carvalho Chehab4.1. ATTRIBUTE: KVM_S390_VM_CRYPTO_ENABLE_AES_KW (w/o)
2506c972ba6SMauro Carvalho Chehab------------------------------------------------------
2516c972ba6SMauro Carvalho Chehab
2526c972ba6SMauro Carvalho ChehabAllows user space to enable aes key wrapping, including generating a new
2536c972ba6SMauro Carvalho Chehabwrapping key.
2546c972ba6SMauro Carvalho Chehab
2556c972ba6SMauro Carvalho Chehab:Parameters: none
2566c972ba6SMauro Carvalho Chehab:Returns:    0
2576c972ba6SMauro Carvalho Chehab
2586c972ba6SMauro Carvalho Chehab4.2. ATTRIBUTE: KVM_S390_VM_CRYPTO_ENABLE_DEA_KW (w/o)
2596c972ba6SMauro Carvalho Chehab------------------------------------------------------
2606c972ba6SMauro Carvalho Chehab
2616c972ba6SMauro Carvalho ChehabAllows user space to enable dea key wrapping, including generating a new
2626c972ba6SMauro Carvalho Chehabwrapping key.
2636c972ba6SMauro Carvalho Chehab
2646c972ba6SMauro Carvalho Chehab:Parameters: none
2656c972ba6SMauro Carvalho Chehab:Returns:    0
2666c972ba6SMauro Carvalho Chehab
2676c972ba6SMauro Carvalho Chehab4.3. ATTRIBUTE: KVM_S390_VM_CRYPTO_DISABLE_AES_KW (w/o)
2686c972ba6SMauro Carvalho Chehab-------------------------------------------------------
2696c972ba6SMauro Carvalho Chehab
2706c972ba6SMauro Carvalho ChehabAllows user space to disable aes key wrapping, clearing the wrapping key.
2716c972ba6SMauro Carvalho Chehab
2726c972ba6SMauro Carvalho Chehab:Parameters: none
2736c972ba6SMauro Carvalho Chehab:Returns:    0
2746c972ba6SMauro Carvalho Chehab
2756c972ba6SMauro Carvalho Chehab4.4. ATTRIBUTE: KVM_S390_VM_CRYPTO_DISABLE_DEA_KW (w/o)
2766c972ba6SMauro Carvalho Chehab-------------------------------------------------------
2776c972ba6SMauro Carvalho Chehab
2786c972ba6SMauro Carvalho ChehabAllows user space to disable dea key wrapping, clearing the wrapping key.
2796c972ba6SMauro Carvalho Chehab
2806c972ba6SMauro Carvalho Chehab:Parameters: none
2816c972ba6SMauro Carvalho Chehab:Returns:    0
2826c972ba6SMauro Carvalho Chehab
2836c972ba6SMauro Carvalho Chehab5. GROUP: KVM_S390_VM_MIGRATION
2846c972ba6SMauro Carvalho Chehab===============================
2856c972ba6SMauro Carvalho Chehab
2866c972ba6SMauro Carvalho Chehab:Architectures: s390
2876c972ba6SMauro Carvalho Chehab
2886c972ba6SMauro Carvalho Chehab5.1. ATTRIBUTE: KVM_S390_VM_MIGRATION_STOP (w/o)
2896c972ba6SMauro Carvalho Chehab------------------------------------------------
2906c972ba6SMauro Carvalho Chehab
2916c972ba6SMauro Carvalho ChehabAllows userspace to stop migration mode, needed for PGSTE migration.
2926c972ba6SMauro Carvalho ChehabSetting this attribute when migration mode is not active will have no
2936c972ba6SMauro Carvalho Chehabeffects.
2946c972ba6SMauro Carvalho Chehab
2956c972ba6SMauro Carvalho Chehab:Parameters: none
2966c972ba6SMauro Carvalho Chehab:Returns:    0
2976c972ba6SMauro Carvalho Chehab
2986c972ba6SMauro Carvalho Chehab5.2. ATTRIBUTE: KVM_S390_VM_MIGRATION_START (w/o)
2996c972ba6SMauro Carvalho Chehab-------------------------------------------------
3006c972ba6SMauro Carvalho Chehab
3016c972ba6SMauro Carvalho ChehabAllows userspace to start migration mode, needed for PGSTE migration.
3026c972ba6SMauro Carvalho ChehabSetting this attribute when migration mode is already active will have
3036c972ba6SMauro Carvalho Chehabno effects.
3046c972ba6SMauro Carvalho Chehab
305f2d3155eSNico BoehrDirty tracking must be enabled on all memslots, else -EINVAL is returned. When
306f2d3155eSNico Boehrdirty tracking is disabled on any memslot, migration mode is automatically
307f2d3155eSNico Boehrstopped.
308f2d3155eSNico Boehr
3096c972ba6SMauro Carvalho Chehab:Parameters: none
3106c972ba6SMauro Carvalho Chehab:Returns:   -ENOMEM if there is not enough free memory to start migration mode;
3116c972ba6SMauro Carvalho Chehab	    -EINVAL if the state of the VM is invalid (e.g. no memory defined);
3126c972ba6SMauro Carvalho Chehab	    0 in case of success.
3136c972ba6SMauro Carvalho Chehab
3146c972ba6SMauro Carvalho Chehab5.3. ATTRIBUTE: KVM_S390_VM_MIGRATION_STATUS (r/o)
3156c972ba6SMauro Carvalho Chehab--------------------------------------------------
3166c972ba6SMauro Carvalho Chehab
3176c972ba6SMauro Carvalho ChehabAllows userspace to query the status of migration mode.
3186c972ba6SMauro Carvalho Chehab
3196c972ba6SMauro Carvalho Chehab:Parameters: address of a buffer in user space to store the data (u64) to;
3206c972ba6SMauro Carvalho Chehab	     the data itself is either 0 if migration mode is disabled or 1
3216c972ba6SMauro Carvalho Chehab	     if it is enabled
3226c972ba6SMauro Carvalho Chehab:Returns:   -EFAULT if the given address is not accessible from kernel space;
3236c972ba6SMauro Carvalho Chehab	    0 in case of success.
324821d935cSOliver Upton
325821d935cSOliver Upton6. GROUP: KVM_ARM_VM_SMCCC_CTRL
326821d935cSOliver Upton===============================
327821d935cSOliver Upton
328821d935cSOliver Upton:Architectures: arm64
329821d935cSOliver Upton
330821d935cSOliver Upton6.1. ATTRIBUTE: KVM_ARM_VM_SMCCC_FILTER (w/o)
331821d935cSOliver Upton---------------------------------------------
332821d935cSOliver Upton
333821d935cSOliver Upton:Parameters: Pointer to a ``struct kvm_smccc_filter``
334821d935cSOliver Upton
335821d935cSOliver Upton:Returns:
336821d935cSOliver Upton
337821d935cSOliver Upton        ======  ===========================================
338821d935cSOliver Upton        EEXIST  Range intersects with a previously inserted
339821d935cSOliver Upton                or reserved range
340821d935cSOliver Upton        EBUSY   A vCPU in the VM has already run
341821d935cSOliver Upton        EINVAL  Invalid filter configuration
342821d935cSOliver Upton        ENOMEM  Failed to allocate memory for the in-kernel
343821d935cSOliver Upton                representation of the SMCCC filter
344821d935cSOliver Upton        ======  ===========================================
345821d935cSOliver Upton
346821d935cSOliver UptonRequests the installation of an SMCCC call filter described as follows::
347821d935cSOliver Upton
348821d935cSOliver Upton    enum kvm_smccc_filter_action {
349821d935cSOliver Upton            KVM_SMCCC_FILTER_HANDLE = 0,
350821d935cSOliver Upton            KVM_SMCCC_FILTER_DENY,
351821d935cSOliver Upton            KVM_SMCCC_FILTER_FWD_TO_USER,
352821d935cSOliver Upton    };
353821d935cSOliver Upton
354821d935cSOliver Upton    struct kvm_smccc_filter {
355821d935cSOliver Upton            __u32 base;
356821d935cSOliver Upton            __u32 nr_functions;
357821d935cSOliver Upton            __u8 action;
358821d935cSOliver Upton            __u8 pad[15];
359821d935cSOliver Upton    };
360821d935cSOliver Upton
361821d935cSOliver UptonThe filter is defined as a set of non-overlapping ranges. Each
362821d935cSOliver Uptonrange defines an action to be applied to SMCCC calls within the range.
363821d935cSOliver UptonUserspace can insert multiple ranges into the filter by using
364821d935cSOliver Uptonsuccessive calls to this attribute.
365821d935cSOliver Upton
366821d935cSOliver UptonThe default configuration of KVM is such that all implemented SMCCC
367821d935cSOliver Uptoncalls are allowed. Thus, the SMCCC filter can be defined sparsely
368821d935cSOliver Uptonby userspace, only describing ranges that modify the default behavior.
369821d935cSOliver Upton
370821d935cSOliver UptonThe range expressed by ``struct kvm_smccc_filter`` is
371821d935cSOliver Upton[``base``, ``base + nr_functions``). The range is not allowed to wrap,
372821d935cSOliver Uptoni.e. userspace cannot rely on ``base + nr_functions`` overflowing.
373821d935cSOliver Upton
374821d935cSOliver UptonThe SMCCC filter applies to both SMC and HVC calls initiated by the
375821d935cSOliver Uptonguest. The SMCCC filter gates the in-kernel emulation of SMCCC calls
376821d935cSOliver Uptonand as such takes effect before other interfaces that interact with
377821d935cSOliver UptonSMCCC calls (e.g. hypercall bitmap registers).
378821d935cSOliver Upton
379821d935cSOliver UptonActions:
380821d935cSOliver Upton
381821d935cSOliver Upton - ``KVM_SMCCC_FILTER_HANDLE``: Allows the guest SMCCC call to be
382821d935cSOliver Upton   handled in-kernel. It is strongly recommended that userspace *not*
383821d935cSOliver Upton   explicitly describe the allowed SMCCC call ranges.
384821d935cSOliver Upton
385821d935cSOliver Upton - ``KVM_SMCCC_FILTER_DENY``: Rejects the guest SMCCC call in-kernel
386821d935cSOliver Upton   and returns to the guest.
387821d935cSOliver Upton
388821d935cSOliver Upton - ``KVM_SMCCC_FILTER_FWD_TO_USER``: The guest SMCCC call is forwarded
389821d935cSOliver Upton   to userspace with an exit reason of ``KVM_EXIT_HYPERCALL``.
390821d935cSOliver Upton
391821d935cSOliver UptonThe ``pad`` field is reserved for future use and must be zero. KVM may
392821d935cSOliver Uptonreturn ``-EINVAL`` if the field is nonzero.
393821d935cSOliver Upton
394821d935cSOliver UptonKVM reserves the 'Arm Architecture Calls' range of function IDs and
395821d935cSOliver Uptonwill reject attempts to define a filter for any portion of these ranges:
396821d935cSOliver Upton
397821d935cSOliver Upton        =========== ===============
398821d935cSOliver Upton        Start       End (inclusive)
399821d935cSOliver Upton        =========== ===============
400821d935cSOliver Upton        0x8000_0000 0x8000_FFFF
401821d935cSOliver Upton        0xC000_0000 0xC000_FFFF
402821d935cSOliver Upton        =========== ===============
403