18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci=================================================================== 48c2ecf20Sopenharmony_ciThe Definitive KVM (Kernel-based Virtual Machine) API Documentation 58c2ecf20Sopenharmony_ci=================================================================== 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci1. General description 88c2ecf20Sopenharmony_ci====================== 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciThe kvm API is a set of ioctls that are issued to control various aspects 118c2ecf20Sopenharmony_ciof a virtual machine. The ioctls belong to the following classes: 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci - System ioctls: These query and set global attributes which affect the 148c2ecf20Sopenharmony_ci whole kvm subsystem. In addition a system ioctl is used to create 158c2ecf20Sopenharmony_ci virtual machines. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci - VM ioctls: These query and set attributes that affect an entire virtual 188c2ecf20Sopenharmony_ci machine, for example memory layout. In addition a VM ioctl is used to 198c2ecf20Sopenharmony_ci create virtual cpus (vcpus) and devices. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci VM ioctls must be issued from the same process (address space) that was 228c2ecf20Sopenharmony_ci used to create the VM. 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci - vcpu ioctls: These query and set attributes that control the operation 258c2ecf20Sopenharmony_ci of a single virtual cpu. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci vcpu ioctls should be issued from the same thread that was used to create 288c2ecf20Sopenharmony_ci the vcpu, except for asynchronous vcpu ioctl that are marked as such in 298c2ecf20Sopenharmony_ci the documentation. Otherwise, the first ioctl after switching threads 308c2ecf20Sopenharmony_ci could see a performance impact. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci - device ioctls: These query and set attributes that control the operation 338c2ecf20Sopenharmony_ci of a single device. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci device ioctls must be issued from the same process (address space) that 368c2ecf20Sopenharmony_ci was used to create the VM. 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci2. File descriptors 398c2ecf20Sopenharmony_ci=================== 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciThe kvm API is centered around file descriptors. An initial 428c2ecf20Sopenharmony_ciopen("/dev/kvm") obtains a handle to the kvm subsystem; this handle 438c2ecf20Sopenharmony_cican be used to issue system ioctls. A KVM_CREATE_VM ioctl on this 448c2ecf20Sopenharmony_cihandle will create a VM file descriptor which can be used to issue VM 458c2ecf20Sopenharmony_ciioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will 468c2ecf20Sopenharmony_cicreate a virtual cpu or device and return a file descriptor pointing to 478c2ecf20Sopenharmony_cithe new resource. Finally, ioctls on a vcpu or device fd can be used 488c2ecf20Sopenharmony_cito control the vcpu or device. For vcpus, this includes the important 498c2ecf20Sopenharmony_citask of actually running guest code. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciIn general file descriptors can be migrated among processes by means 528c2ecf20Sopenharmony_ciof fork() and the SCM_RIGHTS facility of unix domain socket. These 538c2ecf20Sopenharmony_cikinds of tricks are explicitly not supported by kvm. While they will 548c2ecf20Sopenharmony_cinot cause harm to the host, their actual behavior is not guaranteed by 558c2ecf20Sopenharmony_cithe API. See "General description" for details on the ioctl usage 568c2ecf20Sopenharmony_cimodel that is supported by KVM. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciIt is important to note that althought VM ioctls may only be issued from 598c2ecf20Sopenharmony_cithe process that created the VM, a VM's lifecycle is associated with its 608c2ecf20Sopenharmony_cifile descriptor, not its creator (process). In other words, the VM and 618c2ecf20Sopenharmony_ciits resources, *including the associated address space*, are not freed 628c2ecf20Sopenharmony_ciuntil the last reference to the VM's file descriptor has been released. 638c2ecf20Sopenharmony_ciFor example, if fork() is issued after ioctl(KVM_CREATE_VM), the VM will 648c2ecf20Sopenharmony_cinot be freed until both the parent (original) process and its child have 658c2ecf20Sopenharmony_ciput their references to the VM's file descriptor. 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciBecause a VM's resources are not freed until the last reference to its 688c2ecf20Sopenharmony_cifile descriptor is released, creating additional references to a VM 698c2ecf20Sopenharmony_civia fork(), dup(), etc... without careful consideration is strongly 708c2ecf20Sopenharmony_cidiscouraged and may have unwanted side effects, e.g. memory allocated 718c2ecf20Sopenharmony_ciby and on behalf of the VM's process may not be freed/unaccounted when 728c2ecf20Sopenharmony_cithe VM is shut down. 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci3. Extensions 768c2ecf20Sopenharmony_ci============= 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciAs of Linux 2.6.22, the KVM ABI has been stabilized: no backward 798c2ecf20Sopenharmony_ciincompatible change are allowed. However, there is an extension 808c2ecf20Sopenharmony_cifacility that allows backward-compatible extensions to the API to be 818c2ecf20Sopenharmony_ciqueried and used. 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciThe extension mechanism is not based on the Linux version number. 848c2ecf20Sopenharmony_ciInstead, kvm defines extension identifiers and a facility to query 858c2ecf20Sopenharmony_ciwhether a particular extension identifier is available. If it is, a 868c2ecf20Sopenharmony_ciset of ioctls is available for application use. 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci4. API description 908c2ecf20Sopenharmony_ci================== 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ciThis section describes ioctls that can be used to control kvm guests. 938c2ecf20Sopenharmony_ciFor each ioctl, the following information is provided along with a 948c2ecf20Sopenharmony_cidescription: 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci Capability: 978c2ecf20Sopenharmony_ci which KVM extension provides this ioctl. Can be 'basic', 988c2ecf20Sopenharmony_ci which means that is will be provided by any kernel that supports 998c2ecf20Sopenharmony_ci API version 12 (see section 4.1), a KVM_CAP_xyz constant, which 1008c2ecf20Sopenharmony_ci means availability needs to be checked with KVM_CHECK_EXTENSION 1018c2ecf20Sopenharmony_ci (see section 4.4), or 'none' which means that while not all kernels 1028c2ecf20Sopenharmony_ci support this ioctl, there's no capability bit to check its 1038c2ecf20Sopenharmony_ci availability: for kernels that don't support the ioctl, 1048c2ecf20Sopenharmony_ci the ioctl returns -ENOTTY. 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci Architectures: 1078c2ecf20Sopenharmony_ci which instruction set architectures provide this ioctl. 1088c2ecf20Sopenharmony_ci x86 includes both i386 and x86_64. 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci Type: 1118c2ecf20Sopenharmony_ci system, vm, or vcpu. 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci Parameters: 1148c2ecf20Sopenharmony_ci what parameters are accepted by the ioctl. 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci Returns: 1178c2ecf20Sopenharmony_ci the return value. General error numbers (EBADF, ENOMEM, EINVAL) 1188c2ecf20Sopenharmony_ci are not detailed, but errors with specific meanings are. 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci4.1 KVM_GET_API_VERSION 1228c2ecf20Sopenharmony_ci----------------------- 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci:Capability: basic 1258c2ecf20Sopenharmony_ci:Architectures: all 1268c2ecf20Sopenharmony_ci:Type: system ioctl 1278c2ecf20Sopenharmony_ci:Parameters: none 1288c2ecf20Sopenharmony_ci:Returns: the constant KVM_API_VERSION (=12) 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ciThis identifies the API version as the stable kvm API. It is not 1318c2ecf20Sopenharmony_ciexpected that this number will change. However, Linux 2.6.20 and 1328c2ecf20Sopenharmony_ci2.6.21 report earlier versions; these are not documented and not 1338c2ecf20Sopenharmony_cisupported. Applications should refuse to run if KVM_GET_API_VERSION 1348c2ecf20Sopenharmony_cireturns a value other than 12. If this check passes, all ioctls 1358c2ecf20Sopenharmony_cidescribed as 'basic' will be available. 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci4.2 KVM_CREATE_VM 1398c2ecf20Sopenharmony_ci----------------- 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci:Capability: basic 1428c2ecf20Sopenharmony_ci:Architectures: all 1438c2ecf20Sopenharmony_ci:Type: system ioctl 1448c2ecf20Sopenharmony_ci:Parameters: machine type identifier (KVM_VM_*) 1458c2ecf20Sopenharmony_ci:Returns: a VM fd that can be used to control the new virtual machine. 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciThe new VM has no virtual cpus and no memory. 1488c2ecf20Sopenharmony_ciYou probably want to use 0 as machine type. 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ciIn order to create user controlled virtual machines on S390, check 1518c2ecf20Sopenharmony_ciKVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as 1528c2ecf20Sopenharmony_ciprivileged user (CAP_SYS_ADMIN). 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ciTo use hardware assisted virtualization on MIPS (VZ ASE) rather than 1558c2ecf20Sopenharmony_cithe default trap & emulate implementation (which changes the virtual 1568c2ecf20Sopenharmony_cimemory layout to fit in user mode), check KVM_CAP_MIPS_VZ and use the 1578c2ecf20Sopenharmony_ciflag KVM_VM_MIPS_VZ. 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ciOn arm64, the physical address size for a VM (IPA Size limit) is limited 1618c2ecf20Sopenharmony_cito 40bits by default. The limit can be configured if the host supports the 1628c2ecf20Sopenharmony_ciextension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use 1638c2ecf20Sopenharmony_ciKVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type 1648c2ecf20Sopenharmony_ciidentifier, where IPA_Bits is the maximum width of any physical 1658c2ecf20Sopenharmony_ciaddress used by the VM. The IPA_Bits is encoded in bits[7-0] of the 1668c2ecf20Sopenharmony_cimachine type identifier. 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cie.g, to configure a guest to use 48bit physical address size:: 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48)); 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ciThe requested size (IPA_Bits) must be: 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci == ========================================================= 1758c2ecf20Sopenharmony_ci 0 Implies default size, 40bits (for backward compatibility) 1768c2ecf20Sopenharmony_ci N Implies N bits, where N is a positive integer such that, 1778c2ecf20Sopenharmony_ci 32 <= N <= Host_IPA_Limit 1788c2ecf20Sopenharmony_ci == ========================================================= 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ciHost_IPA_Limit is the maximum possible value for IPA_Bits on the host and 1818c2ecf20Sopenharmony_ciis dependent on the CPU capability and the kernel configuration. The limit can 1828c2ecf20Sopenharmony_cibe retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION 1838c2ecf20Sopenharmony_ciioctl() at run-time. 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ciCreation of the VM will fail if the requested IPA size (whether it is 1868c2ecf20Sopenharmony_ciimplicit or explicit) is unsupported on the host. 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ciPlease note that configuring the IPA size does not affect the capability 1898c2ecf20Sopenharmony_ciexposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects 1908c2ecf20Sopenharmony_cisize of the address translated by the stage2 level (guest physical to 1918c2ecf20Sopenharmony_cihost physical address translations). 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci4.3 KVM_GET_MSR_INDEX_LIST, KVM_GET_MSR_FEATURE_INDEX_LIST 1958c2ecf20Sopenharmony_ci---------------------------------------------------------- 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci:Capability: basic, KVM_CAP_GET_MSR_FEATURES for KVM_GET_MSR_FEATURE_INDEX_LIST 1988c2ecf20Sopenharmony_ci:Architectures: x86 1998c2ecf20Sopenharmony_ci:Type: system ioctl 2008c2ecf20Sopenharmony_ci:Parameters: struct kvm_msr_list (in/out) 2018c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ciErrors: 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci ====== ============================================================ 2068c2ecf20Sopenharmony_ci EFAULT the msr index list cannot be read from or written to 2078c2ecf20Sopenharmony_ci E2BIG the msr index list is to be to fit in the array specified by 2088c2ecf20Sopenharmony_ci the user. 2098c2ecf20Sopenharmony_ci ====== ============================================================ 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci:: 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci struct kvm_msr_list { 2148c2ecf20Sopenharmony_ci __u32 nmsrs; /* number of msrs in entries */ 2158c2ecf20Sopenharmony_ci __u32 indices[0]; 2168c2ecf20Sopenharmony_ci }; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ciThe user fills in the size of the indices array in nmsrs, and in return 2198c2ecf20Sopenharmony_cikvm adjusts nmsrs to reflect the actual number of msrs and fills in the 2208c2ecf20Sopenharmony_ciindices array with their numbers. 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ciKVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list 2238c2ecf20Sopenharmony_civaries by kvm version and host processor, but does not change otherwise. 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ciNote: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are 2268c2ecf20Sopenharmony_cinot returned in the MSR list, as different vcpus can have a different number 2278c2ecf20Sopenharmony_ciof banks, as set via the KVM_X86_SETUP_MCE ioctl. 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ciKVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed 2308c2ecf20Sopenharmony_cito the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities 2318c2ecf20Sopenharmony_ciand processor features that are exposed via MSRs (e.g., VMX capabilities). 2328c2ecf20Sopenharmony_ciThis list also varies by kvm version and host processor, but does not change 2338c2ecf20Sopenharmony_ciotherwise. 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci4.4 KVM_CHECK_EXTENSION 2378c2ecf20Sopenharmony_ci----------------------- 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci:Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl 2408c2ecf20Sopenharmony_ci:Architectures: all 2418c2ecf20Sopenharmony_ci:Type: system ioctl, vm ioctl 2428c2ecf20Sopenharmony_ci:Parameters: extension identifier (KVM_CAP_*) 2438c2ecf20Sopenharmony_ci:Returns: 0 if unsupported; 1 (or some other positive integer) if supported 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ciThe API allows the application to query about extensions to the core 2468c2ecf20Sopenharmony_cikvm API. Userspace passes an extension identifier (an integer) and 2478c2ecf20Sopenharmony_cireceives an integer that describes the extension availability. 2488c2ecf20Sopenharmony_ciGenerally 0 means no and 1 means yes, but some extensions may report 2498c2ecf20Sopenharmony_ciadditional information in the integer return value. 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ciBased on their initialization different VMs may have different capabilities. 2528c2ecf20Sopenharmony_ciIt is thus encouraged to use the vm ioctl to query for capabilities (available 2538c2ecf20Sopenharmony_ciwith KVM_CAP_CHECK_EXTENSION_VM on the vm fd) 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci4.5 KVM_GET_VCPU_MMAP_SIZE 2568c2ecf20Sopenharmony_ci-------------------------- 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci:Capability: basic 2598c2ecf20Sopenharmony_ci:Architectures: all 2608c2ecf20Sopenharmony_ci:Type: system ioctl 2618c2ecf20Sopenharmony_ci:Parameters: none 2628c2ecf20Sopenharmony_ci:Returns: size of vcpu mmap area, in bytes 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ciThe KVM_RUN ioctl (cf.) communicates with userspace via a shared 2658c2ecf20Sopenharmony_cimemory region. This ioctl returns the size of that region. See the 2668c2ecf20Sopenharmony_ciKVM_RUN documentation for details. 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci4.6 KVM_SET_MEMORY_REGION 2708c2ecf20Sopenharmony_ci------------------------- 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci:Capability: basic 2738c2ecf20Sopenharmony_ci:Architectures: all 2748c2ecf20Sopenharmony_ci:Type: vm ioctl 2758c2ecf20Sopenharmony_ci:Parameters: struct kvm_memory_region (in) 2768c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ciThis ioctl is obsolete and has been removed. 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci4.7 KVM_CREATE_VCPU 2828c2ecf20Sopenharmony_ci------------------- 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci:Capability: basic 2858c2ecf20Sopenharmony_ci:Architectures: all 2868c2ecf20Sopenharmony_ci:Type: vm ioctl 2878c2ecf20Sopenharmony_ci:Parameters: vcpu id (apic id on x86) 2888c2ecf20Sopenharmony_ci:Returns: vcpu fd on success, -1 on error 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ciThis API adds a vcpu to a virtual machine. No more than max_vcpus may be added. 2918c2ecf20Sopenharmony_ciThe vcpu id is an integer in the range [0, max_vcpu_id). 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ciThe recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of 2948c2ecf20Sopenharmony_cithe KVM_CHECK_EXTENSION ioctl() at run-time. 2958c2ecf20Sopenharmony_ciThe maximum possible value for max_vcpus can be retrieved using the 2968c2ecf20Sopenharmony_ciKVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ciIf the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 2998c2ecf20Sopenharmony_cicpus max. 3008c2ecf20Sopenharmony_ciIf the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is 3018c2ecf20Sopenharmony_cisame as the value returned from KVM_CAP_NR_VCPUS. 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ciThe maximum possible value for max_vcpu_id can be retrieved using the 3048c2ecf20Sopenharmony_ciKVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time. 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ciIf the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id 3078c2ecf20Sopenharmony_ciis the same as the value returned from KVM_CAP_MAX_VCPUS. 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ciOn powerpc using book3s_hv mode, the vcpus are mapped onto virtual 3108c2ecf20Sopenharmony_cithreads in one or more virtual CPU cores. (This is because the 3118c2ecf20Sopenharmony_cihardware requires all the hardware threads in a CPU core to be in the 3128c2ecf20Sopenharmony_cisame partition.) The KVM_CAP_PPC_SMT capability indicates the number 3138c2ecf20Sopenharmony_ciof vcpus per virtual core (vcore). The vcore id is obtained by 3148c2ecf20Sopenharmony_cidividing the vcpu id by the number of vcpus per vcore. The vcpus in a 3158c2ecf20Sopenharmony_cigiven vcore will always be in the same physical core as each other 3168c2ecf20Sopenharmony_ci(though that might be a different physical core from time to time). 3178c2ecf20Sopenharmony_ciUserspace can control the threading (SMT) mode of the guest by its 3188c2ecf20Sopenharmony_ciallocation of vcpu ids. For example, if userspace wants 3198c2ecf20Sopenharmony_cisingle-threaded guest vcpus, it should make all vcpu ids be a multiple 3208c2ecf20Sopenharmony_ciof the number of vcpus per vcore. 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ciFor virtual cpus that have been created with S390 user controlled virtual 3238c2ecf20Sopenharmony_cimachines, the resulting vcpu fd can be memory mapped at page offset 3248c2ecf20Sopenharmony_ciKVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual 3258c2ecf20Sopenharmony_cicpu's hardware control block. 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci4.8 KVM_GET_DIRTY_LOG (vm ioctl) 3298c2ecf20Sopenharmony_ci-------------------------------- 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci:Capability: basic 3328c2ecf20Sopenharmony_ci:Architectures: all 3338c2ecf20Sopenharmony_ci:Type: vm ioctl 3348c2ecf20Sopenharmony_ci:Parameters: struct kvm_dirty_log (in/out) 3358c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci:: 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci /* for KVM_GET_DIRTY_LOG */ 3408c2ecf20Sopenharmony_ci struct kvm_dirty_log { 3418c2ecf20Sopenharmony_ci __u32 slot; 3428c2ecf20Sopenharmony_ci __u32 padding; 3438c2ecf20Sopenharmony_ci union { 3448c2ecf20Sopenharmony_ci void __user *dirty_bitmap; /* one bit per page */ 3458c2ecf20Sopenharmony_ci __u64 padding; 3468c2ecf20Sopenharmony_ci }; 3478c2ecf20Sopenharmony_ci }; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ciGiven a memory slot, return a bitmap containing any pages dirtied 3508c2ecf20Sopenharmony_cisince the last call to this ioctl. Bit 0 is the first page in the 3518c2ecf20Sopenharmony_cimemory slot. Ensure the entire structure is cleared to avoid padding 3528c2ecf20Sopenharmony_ciissues. 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ciIf KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies 3558c2ecf20Sopenharmony_cithe address space for which you want to return the dirty bitmap. 3568c2ecf20Sopenharmony_ciThey must be less than the value that KVM_CHECK_EXTENSION returns for 3578c2ecf20Sopenharmony_cithe KVM_CAP_MULTI_ADDRESS_SPACE capability. 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ciThe bits in the dirty bitmap are cleared before the ioctl returns, unless 3608c2ecf20Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is enabled. For more information, 3618c2ecf20Sopenharmony_cisee the description of the capability. 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci4.9 KVM_SET_MEMORY_ALIAS 3648c2ecf20Sopenharmony_ci------------------------ 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci:Capability: basic 3678c2ecf20Sopenharmony_ci:Architectures: x86 3688c2ecf20Sopenharmony_ci:Type: vm ioctl 3698c2ecf20Sopenharmony_ci:Parameters: struct kvm_memory_alias (in) 3708c2ecf20Sopenharmony_ci:Returns: 0 (success), -1 (error) 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ciThis ioctl is obsolete and has been removed. 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci4.10 KVM_RUN 3768c2ecf20Sopenharmony_ci------------ 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci:Capability: basic 3798c2ecf20Sopenharmony_ci:Architectures: all 3808c2ecf20Sopenharmony_ci:Type: vcpu ioctl 3818c2ecf20Sopenharmony_ci:Parameters: none 3828c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ciErrors: 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci ===== ============================= 3878c2ecf20Sopenharmony_ci EINTR an unmasked signal is pending 3888c2ecf20Sopenharmony_ci ===== ============================= 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ciThis ioctl is used to run a guest virtual cpu. While there are no 3918c2ecf20Sopenharmony_ciexplicit parameters, there is an implicit parameter block that can be 3928c2ecf20Sopenharmony_ciobtained by mmap()ing the vcpu fd at offset 0, with the size given by 3938c2ecf20Sopenharmony_ciKVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct 3948c2ecf20Sopenharmony_cikvm_run' (see below). 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci4.11 KVM_GET_REGS 3988c2ecf20Sopenharmony_ci----------------- 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci:Capability: basic 4018c2ecf20Sopenharmony_ci:Architectures: all except ARM, arm64 4028c2ecf20Sopenharmony_ci:Type: vcpu ioctl 4038c2ecf20Sopenharmony_ci:Parameters: struct kvm_regs (out) 4048c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ciReads the general purpose registers from the vcpu. 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci:: 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci /* x86 */ 4118c2ecf20Sopenharmony_ci struct kvm_regs { 4128c2ecf20Sopenharmony_ci /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 4138c2ecf20Sopenharmony_ci __u64 rax, rbx, rcx, rdx; 4148c2ecf20Sopenharmony_ci __u64 rsi, rdi, rsp, rbp; 4158c2ecf20Sopenharmony_ci __u64 r8, r9, r10, r11; 4168c2ecf20Sopenharmony_ci __u64 r12, r13, r14, r15; 4178c2ecf20Sopenharmony_ci __u64 rip, rflags; 4188c2ecf20Sopenharmony_ci }; 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci /* mips */ 4218c2ecf20Sopenharmony_ci struct kvm_regs { 4228c2ecf20Sopenharmony_ci /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 4238c2ecf20Sopenharmony_ci __u64 gpr[32]; 4248c2ecf20Sopenharmony_ci __u64 hi; 4258c2ecf20Sopenharmony_ci __u64 lo; 4268c2ecf20Sopenharmony_ci __u64 pc; 4278c2ecf20Sopenharmony_ci }; 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci4.12 KVM_SET_REGS 4318c2ecf20Sopenharmony_ci----------------- 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci:Capability: basic 4348c2ecf20Sopenharmony_ci:Architectures: all except ARM, arm64 4358c2ecf20Sopenharmony_ci:Type: vcpu ioctl 4368c2ecf20Sopenharmony_ci:Parameters: struct kvm_regs (in) 4378c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ciWrites the general purpose registers into the vcpu. 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ciSee KVM_GET_REGS for the data structure. 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_ci4.13 KVM_GET_SREGS 4458c2ecf20Sopenharmony_ci------------------ 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci:Capability: basic 4488c2ecf20Sopenharmony_ci:Architectures: x86, ppc 4498c2ecf20Sopenharmony_ci:Type: vcpu ioctl 4508c2ecf20Sopenharmony_ci:Parameters: struct kvm_sregs (out) 4518c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ciReads special registers from the vcpu. 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci:: 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci /* x86 */ 4588c2ecf20Sopenharmony_ci struct kvm_sregs { 4598c2ecf20Sopenharmony_ci struct kvm_segment cs, ds, es, fs, gs, ss; 4608c2ecf20Sopenharmony_ci struct kvm_segment tr, ldt; 4618c2ecf20Sopenharmony_ci struct kvm_dtable gdt, idt; 4628c2ecf20Sopenharmony_ci __u64 cr0, cr2, cr3, cr4, cr8; 4638c2ecf20Sopenharmony_ci __u64 efer; 4648c2ecf20Sopenharmony_ci __u64 apic_base; 4658c2ecf20Sopenharmony_ci __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; 4668c2ecf20Sopenharmony_ci }; 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */ 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ciinterrupt_bitmap is a bitmap of pending external interrupts. At most 4718c2ecf20Sopenharmony_cione bit may be set. This interrupt has been acknowledged by the APIC 4728c2ecf20Sopenharmony_cibut not yet injected into the cpu core. 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci4.14 KVM_SET_SREGS 4768c2ecf20Sopenharmony_ci------------------ 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci:Capability: basic 4798c2ecf20Sopenharmony_ci:Architectures: x86, ppc 4808c2ecf20Sopenharmony_ci:Type: vcpu ioctl 4818c2ecf20Sopenharmony_ci:Parameters: struct kvm_sregs (in) 4828c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ciWrites special registers into the vcpu. See KVM_GET_SREGS for the 4858c2ecf20Sopenharmony_cidata structures. 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci4.15 KVM_TRANSLATE 4898c2ecf20Sopenharmony_ci------------------ 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci:Capability: basic 4928c2ecf20Sopenharmony_ci:Architectures: x86 4938c2ecf20Sopenharmony_ci:Type: vcpu ioctl 4948c2ecf20Sopenharmony_ci:Parameters: struct kvm_translation (in/out) 4958c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ciTranslates a virtual address according to the vcpu's current address 4988c2ecf20Sopenharmony_citranslation mode. 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci:: 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci struct kvm_translation { 5038c2ecf20Sopenharmony_ci /* in */ 5048c2ecf20Sopenharmony_ci __u64 linear_address; 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci /* out */ 5078c2ecf20Sopenharmony_ci __u64 physical_address; 5088c2ecf20Sopenharmony_ci __u8 valid; 5098c2ecf20Sopenharmony_ci __u8 writeable; 5108c2ecf20Sopenharmony_ci __u8 usermode; 5118c2ecf20Sopenharmony_ci __u8 pad[5]; 5128c2ecf20Sopenharmony_ci }; 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci4.16 KVM_INTERRUPT 5168c2ecf20Sopenharmony_ci------------------ 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci:Capability: basic 5198c2ecf20Sopenharmony_ci:Architectures: x86, ppc, mips 5208c2ecf20Sopenharmony_ci:Type: vcpu ioctl 5218c2ecf20Sopenharmony_ci:Parameters: struct kvm_interrupt (in) 5228c2ecf20Sopenharmony_ci:Returns: 0 on success, negative on failure. 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ciQueues a hardware interrupt vector to be injected. 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci:: 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci /* for KVM_INTERRUPT */ 5298c2ecf20Sopenharmony_ci struct kvm_interrupt { 5308c2ecf20Sopenharmony_ci /* in */ 5318c2ecf20Sopenharmony_ci __u32 irq; 5328c2ecf20Sopenharmony_ci }; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ciX86: 5358c2ecf20Sopenharmony_ci^^^^ 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_ci:Returns: 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci ========= =================================== 5408c2ecf20Sopenharmony_ci 0 on success, 5418c2ecf20Sopenharmony_ci -EEXIST if an interrupt is already enqueued 5428c2ecf20Sopenharmony_ci -EINVAL the irq number is invalid 5438c2ecf20Sopenharmony_ci -ENXIO if the PIC is in the kernel 5448c2ecf20Sopenharmony_ci -EFAULT if the pointer is invalid 5458c2ecf20Sopenharmony_ci ========= =================================== 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ciNote 'irq' is an interrupt vector, not an interrupt pin or line. This 5488c2ecf20Sopenharmony_ciioctl is useful if the in-kernel PIC is not used. 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ciPPC: 5518c2ecf20Sopenharmony_ci^^^^ 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ciQueues an external interrupt to be injected. This ioctl is overleaded 5548c2ecf20Sopenharmony_ciwith 3 different irq values: 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_cia) KVM_INTERRUPT_SET 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci This injects an edge type external interrupt into the guest once it's ready 5598c2ecf20Sopenharmony_ci to receive interrupts. When injected, the interrupt is done. 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_cib) KVM_INTERRUPT_UNSET 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci This unsets any pending interrupt. 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_ci Only available with KVM_CAP_PPC_UNSET_IRQ. 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_cic) KVM_INTERRUPT_SET_LEVEL 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci This injects a level type external interrupt into the guest context. The 5708c2ecf20Sopenharmony_ci interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET 5718c2ecf20Sopenharmony_ci is triggered. 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci Only available with KVM_CAP_PPC_IRQ_LEVEL. 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ciNote that any value for 'irq' other than the ones stated above is invalid 5768c2ecf20Sopenharmony_ciand incurs unexpected behavior. 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ciMIPS: 5818c2ecf20Sopenharmony_ci^^^^^ 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ciQueues an external interrupt to be injected into the virtual CPU. A negative 5848c2ecf20Sopenharmony_ciinterrupt number dequeues the interrupt. 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ci4.17 KVM_DEBUG_GUEST 5908c2ecf20Sopenharmony_ci-------------------- 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci:Capability: basic 5938c2ecf20Sopenharmony_ci:Architectures: none 5948c2ecf20Sopenharmony_ci:Type: vcpu ioctl 5958c2ecf20Sopenharmony_ci:Parameters: none) 5968c2ecf20Sopenharmony_ci:Returns: -1 on error 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ciSupport for this has been removed. Use KVM_SET_GUEST_DEBUG instead. 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci4.18 KVM_GET_MSRS 6028c2ecf20Sopenharmony_ci----------------- 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_ci:Capability: basic (vcpu), KVM_CAP_GET_MSR_FEATURES (system) 6058c2ecf20Sopenharmony_ci:Architectures: x86 6068c2ecf20Sopenharmony_ci:Type: system ioctl, vcpu ioctl 6078c2ecf20Sopenharmony_ci:Parameters: struct kvm_msrs (in/out) 6088c2ecf20Sopenharmony_ci:Returns: number of msrs successfully returned; 6098c2ecf20Sopenharmony_ci -1 on error 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ciWhen used as a system ioctl: 6128c2ecf20Sopenharmony_ciReads the values of MSR-based features that are available for the VM. This 6138c2ecf20Sopenharmony_ciis similar to KVM_GET_SUPPORTED_CPUID, but it returns MSR indices and values. 6148c2ecf20Sopenharmony_ciThe list of msr-based features can be obtained using KVM_GET_MSR_FEATURE_INDEX_LIST 6158c2ecf20Sopenharmony_ciin a system ioctl. 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ciWhen used as a vcpu ioctl: 6188c2ecf20Sopenharmony_ciReads model-specific registers from the vcpu. Supported msr indices can 6198c2ecf20Sopenharmony_cibe obtained using KVM_GET_MSR_INDEX_LIST in a system ioctl. 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci:: 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci struct kvm_msrs { 6248c2ecf20Sopenharmony_ci __u32 nmsrs; /* number of msrs in entries */ 6258c2ecf20Sopenharmony_ci __u32 pad; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci struct kvm_msr_entry entries[0]; 6288c2ecf20Sopenharmony_ci }; 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci struct kvm_msr_entry { 6318c2ecf20Sopenharmony_ci __u32 index; 6328c2ecf20Sopenharmony_ci __u32 reserved; 6338c2ecf20Sopenharmony_ci __u64 data; 6348c2ecf20Sopenharmony_ci }; 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ciApplication code should set the 'nmsrs' member (which indicates the 6378c2ecf20Sopenharmony_cisize of the entries array) and the 'index' member of each array entry. 6388c2ecf20Sopenharmony_cikvm will fill in the 'data' member. 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci4.19 KVM_SET_MSRS 6428c2ecf20Sopenharmony_ci----------------- 6438c2ecf20Sopenharmony_ci 6448c2ecf20Sopenharmony_ci:Capability: basic 6458c2ecf20Sopenharmony_ci:Architectures: x86 6468c2ecf20Sopenharmony_ci:Type: vcpu ioctl 6478c2ecf20Sopenharmony_ci:Parameters: struct kvm_msrs (in) 6488c2ecf20Sopenharmony_ci:Returns: number of msrs successfully set (see below), -1 on error 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ciWrites model-specific registers to the vcpu. See KVM_GET_MSRS for the 6518c2ecf20Sopenharmony_cidata structures. 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ciApplication code should set the 'nmsrs' member (which indicates the 6548c2ecf20Sopenharmony_cisize of the entries array), and the 'index' and 'data' members of each 6558c2ecf20Sopenharmony_ciarray entry. 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_ciIt tries to set the MSRs in array entries[] one by one. If setting an MSR 6588c2ecf20Sopenharmony_cifails, e.g., due to setting reserved bits, the MSR isn't supported/emulated 6598c2ecf20Sopenharmony_ciby KVM, etc..., it stops processing the MSR list and returns the number of 6608c2ecf20Sopenharmony_ciMSRs that have been set successfully. 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ci4.20 KVM_SET_CPUID 6648c2ecf20Sopenharmony_ci------------------ 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_ci:Capability: basic 6678c2ecf20Sopenharmony_ci:Architectures: x86 6688c2ecf20Sopenharmony_ci:Type: vcpu ioctl 6698c2ecf20Sopenharmony_ci:Parameters: struct kvm_cpuid (in) 6708c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ciDefines the vcpu responses to the cpuid instruction. Applications 6738c2ecf20Sopenharmony_cishould use the KVM_SET_CPUID2 ioctl if available. 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ciNote, when this IOCTL fails, KVM gives no guarantees that previous valid CPUID 6768c2ecf20Sopenharmony_ciconfiguration (if there is) is not corrupted. Userspace can get a copy of the 6778c2ecf20Sopenharmony_ciresulting CPUID configuration through KVM_GET_CPUID2 in case. 6788c2ecf20Sopenharmony_ci 6798c2ecf20Sopenharmony_ci:: 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci struct kvm_cpuid_entry { 6828c2ecf20Sopenharmony_ci __u32 function; 6838c2ecf20Sopenharmony_ci __u32 eax; 6848c2ecf20Sopenharmony_ci __u32 ebx; 6858c2ecf20Sopenharmony_ci __u32 ecx; 6868c2ecf20Sopenharmony_ci __u32 edx; 6878c2ecf20Sopenharmony_ci __u32 padding; 6888c2ecf20Sopenharmony_ci }; 6898c2ecf20Sopenharmony_ci 6908c2ecf20Sopenharmony_ci /* for KVM_SET_CPUID */ 6918c2ecf20Sopenharmony_ci struct kvm_cpuid { 6928c2ecf20Sopenharmony_ci __u32 nent; 6938c2ecf20Sopenharmony_ci __u32 padding; 6948c2ecf20Sopenharmony_ci struct kvm_cpuid_entry entries[0]; 6958c2ecf20Sopenharmony_ci }; 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci4.21 KVM_SET_SIGNAL_MASK 6998c2ecf20Sopenharmony_ci------------------------ 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci:Capability: basic 7028c2ecf20Sopenharmony_ci:Architectures: all 7038c2ecf20Sopenharmony_ci:Type: vcpu ioctl 7048c2ecf20Sopenharmony_ci:Parameters: struct kvm_signal_mask (in) 7058c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ciDefines which signals are blocked during execution of KVM_RUN. This 7088c2ecf20Sopenharmony_cisignal mask temporarily overrides the threads signal mask. Any 7098c2ecf20Sopenharmony_ciunblocked signal received (except SIGKILL and SIGSTOP, which retain 7108c2ecf20Sopenharmony_citheir traditional behaviour) will cause KVM_RUN to return with -EINTR. 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ciNote the signal will only be delivered if not blocked by the original 7138c2ecf20Sopenharmony_cisignal mask. 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_ci:: 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci /* for KVM_SET_SIGNAL_MASK */ 7188c2ecf20Sopenharmony_ci struct kvm_signal_mask { 7198c2ecf20Sopenharmony_ci __u32 len; 7208c2ecf20Sopenharmony_ci __u8 sigset[0]; 7218c2ecf20Sopenharmony_ci }; 7228c2ecf20Sopenharmony_ci 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci4.22 KVM_GET_FPU 7258c2ecf20Sopenharmony_ci---------------- 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci:Capability: basic 7288c2ecf20Sopenharmony_ci:Architectures: x86 7298c2ecf20Sopenharmony_ci:Type: vcpu ioctl 7308c2ecf20Sopenharmony_ci:Parameters: struct kvm_fpu (out) 7318c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ciReads the floating point state from the vcpu. 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_ci:: 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_ci /* for KVM_GET_FPU and KVM_SET_FPU */ 7388c2ecf20Sopenharmony_ci struct kvm_fpu { 7398c2ecf20Sopenharmony_ci __u8 fpr[8][16]; 7408c2ecf20Sopenharmony_ci __u16 fcw; 7418c2ecf20Sopenharmony_ci __u16 fsw; 7428c2ecf20Sopenharmony_ci __u8 ftwx; /* in fxsave format */ 7438c2ecf20Sopenharmony_ci __u8 pad1; 7448c2ecf20Sopenharmony_ci __u16 last_opcode; 7458c2ecf20Sopenharmony_ci __u64 last_ip; 7468c2ecf20Sopenharmony_ci __u64 last_dp; 7478c2ecf20Sopenharmony_ci __u8 xmm[16][16]; 7488c2ecf20Sopenharmony_ci __u32 mxcsr; 7498c2ecf20Sopenharmony_ci __u32 pad2; 7508c2ecf20Sopenharmony_ci }; 7518c2ecf20Sopenharmony_ci 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci4.23 KVM_SET_FPU 7548c2ecf20Sopenharmony_ci---------------- 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci:Capability: basic 7578c2ecf20Sopenharmony_ci:Architectures: x86 7588c2ecf20Sopenharmony_ci:Type: vcpu ioctl 7598c2ecf20Sopenharmony_ci:Parameters: struct kvm_fpu (in) 7608c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ciWrites the floating point state to the vcpu. 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_ci:: 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci /* for KVM_GET_FPU and KVM_SET_FPU */ 7678c2ecf20Sopenharmony_ci struct kvm_fpu { 7688c2ecf20Sopenharmony_ci __u8 fpr[8][16]; 7698c2ecf20Sopenharmony_ci __u16 fcw; 7708c2ecf20Sopenharmony_ci __u16 fsw; 7718c2ecf20Sopenharmony_ci __u8 ftwx; /* in fxsave format */ 7728c2ecf20Sopenharmony_ci __u8 pad1; 7738c2ecf20Sopenharmony_ci __u16 last_opcode; 7748c2ecf20Sopenharmony_ci __u64 last_ip; 7758c2ecf20Sopenharmony_ci __u64 last_dp; 7768c2ecf20Sopenharmony_ci __u8 xmm[16][16]; 7778c2ecf20Sopenharmony_ci __u32 mxcsr; 7788c2ecf20Sopenharmony_ci __u32 pad2; 7798c2ecf20Sopenharmony_ci }; 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci4.24 KVM_CREATE_IRQCHIP 7838c2ecf20Sopenharmony_ci----------------------- 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390) 7868c2ecf20Sopenharmony_ci:Architectures: x86, ARM, arm64, s390 7878c2ecf20Sopenharmony_ci:Type: vm ioctl 7888c2ecf20Sopenharmony_ci:Parameters: none 7898c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ciCreates an interrupt controller model in the kernel. 7928c2ecf20Sopenharmony_ciOn x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up 7938c2ecf20Sopenharmony_cifuture vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both 7948c2ecf20Sopenharmony_ciPIC and IOAPIC; GSI 16-23 only go to the IOAPIC. 7958c2ecf20Sopenharmony_ciOn ARM/arm64, a GICv2 is created. Any other GIC versions require the usage of 7968c2ecf20Sopenharmony_ciKVM_CREATE_DEVICE, which also supports creating a GICv2. Using 7978c2ecf20Sopenharmony_ciKVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2. 7988c2ecf20Sopenharmony_ciOn s390, a dummy irq routing table is created. 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ciNote that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled 8018c2ecf20Sopenharmony_cibefore KVM_CREATE_IRQCHIP can be used. 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci4.25 KVM_IRQ_LINE 8058c2ecf20Sopenharmony_ci----------------- 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 8088c2ecf20Sopenharmony_ci:Architectures: x86, arm, arm64 8098c2ecf20Sopenharmony_ci:Type: vm ioctl 8108c2ecf20Sopenharmony_ci:Parameters: struct kvm_irq_level 8118c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ciSets the level of a GSI input to the interrupt controller model in the kernel. 8148c2ecf20Sopenharmony_ciOn some architectures it is required that an interrupt controller model has 8158c2ecf20Sopenharmony_cibeen previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered 8168c2ecf20Sopenharmony_ciinterrupts require the level to be set to 1 and then back to 0. 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_ciOn real hardware, interrupt pins can be active-low or active-high. This 8198c2ecf20Sopenharmony_cidoes not matter for the level field of struct kvm_irq_level: 1 always 8208c2ecf20Sopenharmony_cimeans active (asserted), 0 means inactive (deasserted). 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_cix86 allows the operating system to program the interrupt polarity 8238c2ecf20Sopenharmony_ci(active-low/active-high) for level-triggered interrupts, and KVM used 8248c2ecf20Sopenharmony_cito consider the polarity. However, due to bitrot in the handling of 8258c2ecf20Sopenharmony_ciactive-low interrupts, the above convention is now valid on x86 too. 8268c2ecf20Sopenharmony_ciThis is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace 8278c2ecf20Sopenharmony_cishould not present interrupts to the guest as active-low unless this 8288c2ecf20Sopenharmony_cicapability is present (or unless it is not using the in-kernel irqchip, 8298c2ecf20Sopenharmony_ciof course). 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ciARM/arm64 can signal an interrupt either at the CPU level, or at the 8338c2ecf20Sopenharmony_ciin-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to 8348c2ecf20Sopenharmony_ciuse PPIs designated for specific cpus. The irq field is interpreted 8358c2ecf20Sopenharmony_cilike this:: 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_ci bits: | 31 ... 28 | 27 ... 24 | 23 ... 16 | 15 ... 0 | 8388c2ecf20Sopenharmony_ci field: | vcpu2_index | irq_type | vcpu_index | irq_id | 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ciThe irq_type field has the following values: 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci- irq_type[0]: 8438c2ecf20Sopenharmony_ci out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ 8448c2ecf20Sopenharmony_ci- irq_type[1]: 8458c2ecf20Sopenharmony_ci in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.) 8468c2ecf20Sopenharmony_ci (the vcpu_index field is ignored) 8478c2ecf20Sopenharmony_ci- irq_type[2]: 8488c2ecf20Sopenharmony_ci in-kernel GIC: PPI, irq_id between 16 and 31 (incl.) 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_ci(The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs) 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_ciIn both cases, level is used to assert/deassert the line. 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ciWhen KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 is supported, the target vcpu is 8558c2ecf20Sopenharmony_ciidentified as (256 * vcpu2_index + vcpu_index). Otherwise, vcpu2_index 8568c2ecf20Sopenharmony_cimust be zero. 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ciNote that on arm/arm64, the KVM_CAP_IRQCHIP capability only conditions 8598c2ecf20Sopenharmony_ciinjection of interrupts for the in-kernel irqchip. KVM_IRQ_LINE can always 8608c2ecf20Sopenharmony_cibe used for a userspace interrupt controller. 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci:: 8638c2ecf20Sopenharmony_ci 8648c2ecf20Sopenharmony_ci struct kvm_irq_level { 8658c2ecf20Sopenharmony_ci union { 8668c2ecf20Sopenharmony_ci __u32 irq; /* GSI */ 8678c2ecf20Sopenharmony_ci __s32 status; /* not used for KVM_IRQ_LEVEL */ 8688c2ecf20Sopenharmony_ci }; 8698c2ecf20Sopenharmony_ci __u32 level; /* 0 or 1 */ 8708c2ecf20Sopenharmony_ci }; 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_ci4.26 KVM_GET_IRQCHIP 8748c2ecf20Sopenharmony_ci-------------------- 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 8778c2ecf20Sopenharmony_ci:Architectures: x86 8788c2ecf20Sopenharmony_ci:Type: vm ioctl 8798c2ecf20Sopenharmony_ci:Parameters: struct kvm_irqchip (in/out) 8808c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 8818c2ecf20Sopenharmony_ci 8828c2ecf20Sopenharmony_ciReads the state of a kernel interrupt controller created with 8838c2ecf20Sopenharmony_ciKVM_CREATE_IRQCHIP into a buffer provided by the caller. 8848c2ecf20Sopenharmony_ci 8858c2ecf20Sopenharmony_ci:: 8868c2ecf20Sopenharmony_ci 8878c2ecf20Sopenharmony_ci struct kvm_irqchip { 8888c2ecf20Sopenharmony_ci __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ 8898c2ecf20Sopenharmony_ci __u32 pad; 8908c2ecf20Sopenharmony_ci union { 8918c2ecf20Sopenharmony_ci char dummy[512]; /* reserving space */ 8928c2ecf20Sopenharmony_ci struct kvm_pic_state pic; 8938c2ecf20Sopenharmony_ci struct kvm_ioapic_state ioapic; 8948c2ecf20Sopenharmony_ci } chip; 8958c2ecf20Sopenharmony_ci }; 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_ci 8988c2ecf20Sopenharmony_ci4.27 KVM_SET_IRQCHIP 8998c2ecf20Sopenharmony_ci-------------------- 9008c2ecf20Sopenharmony_ci 9018c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 9028c2ecf20Sopenharmony_ci:Architectures: x86 9038c2ecf20Sopenharmony_ci:Type: vm ioctl 9048c2ecf20Sopenharmony_ci:Parameters: struct kvm_irqchip (in) 9058c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 9068c2ecf20Sopenharmony_ci 9078c2ecf20Sopenharmony_ciSets the state of a kernel interrupt controller created with 9088c2ecf20Sopenharmony_ciKVM_CREATE_IRQCHIP from a buffer provided by the caller. 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci:: 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci struct kvm_irqchip { 9138c2ecf20Sopenharmony_ci __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ 9148c2ecf20Sopenharmony_ci __u32 pad; 9158c2ecf20Sopenharmony_ci union { 9168c2ecf20Sopenharmony_ci char dummy[512]; /* reserving space */ 9178c2ecf20Sopenharmony_ci struct kvm_pic_state pic; 9188c2ecf20Sopenharmony_ci struct kvm_ioapic_state ioapic; 9198c2ecf20Sopenharmony_ci } chip; 9208c2ecf20Sopenharmony_ci }; 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci4.28 KVM_XEN_HVM_CONFIG 9248c2ecf20Sopenharmony_ci----------------------- 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM 9278c2ecf20Sopenharmony_ci:Architectures: x86 9288c2ecf20Sopenharmony_ci:Type: vm ioctl 9298c2ecf20Sopenharmony_ci:Parameters: struct kvm_xen_hvm_config (in) 9308c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 9318c2ecf20Sopenharmony_ci 9328c2ecf20Sopenharmony_ciSets the MSR that the Xen HVM guest uses to initialize its hypercall 9338c2ecf20Sopenharmony_cipage, and provides the starting address and size of the hypercall 9348c2ecf20Sopenharmony_ciblobs in userspace. When the guest writes the MSR, kvm copies one 9358c2ecf20Sopenharmony_cipage of a blob (32- or 64-bit, depending on the vcpu mode) to guest 9368c2ecf20Sopenharmony_cimemory. 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci:: 9398c2ecf20Sopenharmony_ci 9408c2ecf20Sopenharmony_ci struct kvm_xen_hvm_config { 9418c2ecf20Sopenharmony_ci __u32 flags; 9428c2ecf20Sopenharmony_ci __u32 msr; 9438c2ecf20Sopenharmony_ci __u64 blob_addr_32; 9448c2ecf20Sopenharmony_ci __u64 blob_addr_64; 9458c2ecf20Sopenharmony_ci __u8 blob_size_32; 9468c2ecf20Sopenharmony_ci __u8 blob_size_64; 9478c2ecf20Sopenharmony_ci __u8 pad2[30]; 9488c2ecf20Sopenharmony_ci }; 9498c2ecf20Sopenharmony_ci 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci4.29 KVM_GET_CLOCK 9528c2ecf20Sopenharmony_ci------------------ 9538c2ecf20Sopenharmony_ci 9548c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ADJUST_CLOCK 9558c2ecf20Sopenharmony_ci:Architectures: x86 9568c2ecf20Sopenharmony_ci:Type: vm ioctl 9578c2ecf20Sopenharmony_ci:Parameters: struct kvm_clock_data (out) 9588c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_ciGets the current timestamp of kvmclock as seen by the current guest. In 9618c2ecf20Sopenharmony_ciconjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios 9628c2ecf20Sopenharmony_cisuch as migration. 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ciWhen KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the 9658c2ecf20Sopenharmony_ciset of bits that KVM can return in struct kvm_clock_data's flag member. 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_ciThe only flag defined now is KVM_CLOCK_TSC_STABLE. If set, the returned 9688c2ecf20Sopenharmony_civalue is the exact kvmclock value seen by all VCPUs at the instant 9698c2ecf20Sopenharmony_ciwhen KVM_GET_CLOCK was called. If clear, the returned value is simply 9708c2ecf20Sopenharmony_ciCLOCK_MONOTONIC plus a constant offset; the offset can be modified 9718c2ecf20Sopenharmony_ciwith KVM_SET_CLOCK. KVM will try to make all VCPUs follow this clock, 9728c2ecf20Sopenharmony_cibut the exact value read by each VCPU could differ, because the host 9738c2ecf20Sopenharmony_ciTSC is not stable. 9748c2ecf20Sopenharmony_ci 9758c2ecf20Sopenharmony_ci:: 9768c2ecf20Sopenharmony_ci 9778c2ecf20Sopenharmony_ci struct kvm_clock_data { 9788c2ecf20Sopenharmony_ci __u64 clock; /* kvmclock current value */ 9798c2ecf20Sopenharmony_ci __u32 flags; 9808c2ecf20Sopenharmony_ci __u32 pad[9]; 9818c2ecf20Sopenharmony_ci }; 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci4.30 KVM_SET_CLOCK 9858c2ecf20Sopenharmony_ci------------------ 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ADJUST_CLOCK 9888c2ecf20Sopenharmony_ci:Architectures: x86 9898c2ecf20Sopenharmony_ci:Type: vm ioctl 9908c2ecf20Sopenharmony_ci:Parameters: struct kvm_clock_data (in) 9918c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 9928c2ecf20Sopenharmony_ci 9938c2ecf20Sopenharmony_ciSets the current timestamp of kvmclock to the value specified in its parameter. 9948c2ecf20Sopenharmony_ciIn conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios 9958c2ecf20Sopenharmony_cisuch as migration. 9968c2ecf20Sopenharmony_ci 9978c2ecf20Sopenharmony_ci:: 9988c2ecf20Sopenharmony_ci 9998c2ecf20Sopenharmony_ci struct kvm_clock_data { 10008c2ecf20Sopenharmony_ci __u64 clock; /* kvmclock current value */ 10018c2ecf20Sopenharmony_ci __u32 flags; 10028c2ecf20Sopenharmony_ci __u32 pad[9]; 10038c2ecf20Sopenharmony_ci }; 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci4.31 KVM_GET_VCPU_EVENTS 10078c2ecf20Sopenharmony_ci------------------------ 10088c2ecf20Sopenharmony_ci 10098c2ecf20Sopenharmony_ci:Capability: KVM_CAP_VCPU_EVENTS 10108c2ecf20Sopenharmony_ci:Extended by: KVM_CAP_INTR_SHADOW 10118c2ecf20Sopenharmony_ci:Architectures: x86, arm, arm64 10128c2ecf20Sopenharmony_ci:Type: vcpu ioctl 10138c2ecf20Sopenharmony_ci:Parameters: struct kvm_vcpu_event (out) 10148c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 10158c2ecf20Sopenharmony_ci 10168c2ecf20Sopenharmony_ciX86: 10178c2ecf20Sopenharmony_ci^^^^ 10188c2ecf20Sopenharmony_ci 10198c2ecf20Sopenharmony_ciGets currently pending exceptions, interrupts, and NMIs as well as related 10208c2ecf20Sopenharmony_cistates of the vcpu. 10218c2ecf20Sopenharmony_ci 10228c2ecf20Sopenharmony_ci:: 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_ci struct kvm_vcpu_events { 10258c2ecf20Sopenharmony_ci struct { 10268c2ecf20Sopenharmony_ci __u8 injected; 10278c2ecf20Sopenharmony_ci __u8 nr; 10288c2ecf20Sopenharmony_ci __u8 has_error_code; 10298c2ecf20Sopenharmony_ci __u8 pending; 10308c2ecf20Sopenharmony_ci __u32 error_code; 10318c2ecf20Sopenharmony_ci } exception; 10328c2ecf20Sopenharmony_ci struct { 10338c2ecf20Sopenharmony_ci __u8 injected; 10348c2ecf20Sopenharmony_ci __u8 nr; 10358c2ecf20Sopenharmony_ci __u8 soft; 10368c2ecf20Sopenharmony_ci __u8 shadow; 10378c2ecf20Sopenharmony_ci } interrupt; 10388c2ecf20Sopenharmony_ci struct { 10398c2ecf20Sopenharmony_ci __u8 injected; 10408c2ecf20Sopenharmony_ci __u8 pending; 10418c2ecf20Sopenharmony_ci __u8 masked; 10428c2ecf20Sopenharmony_ci __u8 pad; 10438c2ecf20Sopenharmony_ci } nmi; 10448c2ecf20Sopenharmony_ci __u32 sipi_vector; 10458c2ecf20Sopenharmony_ci __u32 flags; 10468c2ecf20Sopenharmony_ci struct { 10478c2ecf20Sopenharmony_ci __u8 smm; 10488c2ecf20Sopenharmony_ci __u8 pending; 10498c2ecf20Sopenharmony_ci __u8 smm_inside_nmi; 10508c2ecf20Sopenharmony_ci __u8 latched_init; 10518c2ecf20Sopenharmony_ci } smi; 10528c2ecf20Sopenharmony_ci __u8 reserved[27]; 10538c2ecf20Sopenharmony_ci __u8 exception_has_payload; 10548c2ecf20Sopenharmony_ci __u64 exception_payload; 10558c2ecf20Sopenharmony_ci }; 10568c2ecf20Sopenharmony_ci 10578c2ecf20Sopenharmony_ciThe following bits are defined in the flags field: 10588c2ecf20Sopenharmony_ci 10598c2ecf20Sopenharmony_ci- KVM_VCPUEVENT_VALID_SHADOW may be set to signal that 10608c2ecf20Sopenharmony_ci interrupt.shadow contains a valid state. 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci- KVM_VCPUEVENT_VALID_SMM may be set to signal that smi contains a 10638c2ecf20Sopenharmony_ci valid state. 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci- KVM_VCPUEVENT_VALID_PAYLOAD may be set to signal that the 10668c2ecf20Sopenharmony_ci exception_has_payload, exception_payload, and exception.pending 10678c2ecf20Sopenharmony_ci fields contain a valid state. This bit will be set whenever 10688c2ecf20Sopenharmony_ci KVM_CAP_EXCEPTION_PAYLOAD is enabled. 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_ciARM/ARM64: 10718c2ecf20Sopenharmony_ci^^^^^^^^^^ 10728c2ecf20Sopenharmony_ci 10738c2ecf20Sopenharmony_ciIf the guest accesses a device that is being emulated by the host kernel in 10748c2ecf20Sopenharmony_cisuch a way that a real device would generate a physical SError, KVM may make 10758c2ecf20Sopenharmony_cia virtual SError pending for that VCPU. This system error interrupt remains 10768c2ecf20Sopenharmony_cipending until the guest takes the exception by unmasking PSTATE.A. 10778c2ecf20Sopenharmony_ci 10788c2ecf20Sopenharmony_ciRunning the VCPU may cause it to take a pending SError, or make an access that 10798c2ecf20Sopenharmony_cicauses an SError to become pending. The event's description is only valid while 10808c2ecf20Sopenharmony_cithe VPCU is not running. 10818c2ecf20Sopenharmony_ci 10828c2ecf20Sopenharmony_ciThis API provides a way to read and write the pending 'event' state that is not 10838c2ecf20Sopenharmony_civisible to the guest. To save, restore or migrate a VCPU the struct representing 10848c2ecf20Sopenharmony_cithe state can be read then written using this GET/SET API, along with the other 10858c2ecf20Sopenharmony_ciguest-visible registers. It is not possible to 'cancel' an SError that has been 10868c2ecf20Sopenharmony_cimade pending. 10878c2ecf20Sopenharmony_ci 10888c2ecf20Sopenharmony_ciA device being emulated in user-space may also wish to generate an SError. To do 10898c2ecf20Sopenharmony_cithis the events structure can be populated by user-space. The current state 10908c2ecf20Sopenharmony_cishould be read first, to ensure no existing SError is pending. If an existing 10918c2ecf20Sopenharmony_ciSError is pending, the architecture's 'Multiple SError interrupts' rules should 10928c2ecf20Sopenharmony_cibe followed. (2.5.3 of DDI0587.a "ARM Reliability, Availability, and 10938c2ecf20Sopenharmony_ciServiceability (RAS) Specification"). 10948c2ecf20Sopenharmony_ci 10958c2ecf20Sopenharmony_ciSError exceptions always have an ESR value. Some CPUs have the ability to 10968c2ecf20Sopenharmony_cispecify what the virtual SError's ESR value should be. These systems will 10978c2ecf20Sopenharmony_ciadvertise KVM_CAP_ARM_INJECT_SERROR_ESR. In this case exception.has_esr will 10988c2ecf20Sopenharmony_cialways have a non-zero value when read, and the agent making an SError pending 10998c2ecf20Sopenharmony_cishould specify the ISS field in the lower 24 bits of exception.serror_esr. If 11008c2ecf20Sopenharmony_cithe system supports KVM_CAP_ARM_INJECT_SERROR_ESR, but user-space sets the events 11018c2ecf20Sopenharmony_ciwith exception.has_esr as zero, KVM will choose an ESR. 11028c2ecf20Sopenharmony_ci 11038c2ecf20Sopenharmony_ciSpecifying exception.has_esr on a system that does not support it will return 11048c2ecf20Sopenharmony_ci-EINVAL. Setting anything other than the lower 24bits of exception.serror_esr 11058c2ecf20Sopenharmony_ciwill return -EINVAL. 11068c2ecf20Sopenharmony_ci 11078c2ecf20Sopenharmony_ciIt is not possible to read back a pending external abort (injected via 11088c2ecf20Sopenharmony_ciKVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered 11098c2ecf20Sopenharmony_cidirectly to the virtual CPU). 11108c2ecf20Sopenharmony_ci 11118c2ecf20Sopenharmony_ci:: 11128c2ecf20Sopenharmony_ci 11138c2ecf20Sopenharmony_ci struct kvm_vcpu_events { 11148c2ecf20Sopenharmony_ci struct { 11158c2ecf20Sopenharmony_ci __u8 serror_pending; 11168c2ecf20Sopenharmony_ci __u8 serror_has_esr; 11178c2ecf20Sopenharmony_ci __u8 ext_dabt_pending; 11188c2ecf20Sopenharmony_ci /* Align it to 8 bytes */ 11198c2ecf20Sopenharmony_ci __u8 pad[5]; 11208c2ecf20Sopenharmony_ci __u64 serror_esr; 11218c2ecf20Sopenharmony_ci } exception; 11228c2ecf20Sopenharmony_ci __u32 reserved[12]; 11238c2ecf20Sopenharmony_ci }; 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_ci4.32 KVM_SET_VCPU_EVENTS 11268c2ecf20Sopenharmony_ci------------------------ 11278c2ecf20Sopenharmony_ci 11288c2ecf20Sopenharmony_ci:Capability: KVM_CAP_VCPU_EVENTS 11298c2ecf20Sopenharmony_ci:Extended by: KVM_CAP_INTR_SHADOW 11308c2ecf20Sopenharmony_ci:Architectures: x86, arm, arm64 11318c2ecf20Sopenharmony_ci:Type: vcpu ioctl 11328c2ecf20Sopenharmony_ci:Parameters: struct kvm_vcpu_event (in) 11338c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_ciX86: 11368c2ecf20Sopenharmony_ci^^^^ 11378c2ecf20Sopenharmony_ci 11388c2ecf20Sopenharmony_ciSet pending exceptions, interrupts, and NMIs as well as related states of the 11398c2ecf20Sopenharmony_civcpu. 11408c2ecf20Sopenharmony_ci 11418c2ecf20Sopenharmony_ciSee KVM_GET_VCPU_EVENTS for the data structure. 11428c2ecf20Sopenharmony_ci 11438c2ecf20Sopenharmony_ciFields that may be modified asynchronously by running VCPUs can be excluded 11448c2ecf20Sopenharmony_cifrom the update. These fields are nmi.pending, sipi_vector, smi.smm, 11458c2ecf20Sopenharmony_cismi.pending. Keep the corresponding bits in the flags field cleared to 11468c2ecf20Sopenharmony_cisuppress overwriting the current in-kernel state. The bits are: 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci=============================== ================================== 11498c2ecf20Sopenharmony_ciKVM_VCPUEVENT_VALID_NMI_PENDING transfer nmi.pending to the kernel 11508c2ecf20Sopenharmony_ciKVM_VCPUEVENT_VALID_SIPI_VECTOR transfer sipi_vector 11518c2ecf20Sopenharmony_ciKVM_VCPUEVENT_VALID_SMM transfer the smi sub-struct. 11528c2ecf20Sopenharmony_ci=============================== ================================== 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ciIf KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in 11558c2ecf20Sopenharmony_cithe flags field to signal that interrupt.shadow contains a valid state and 11568c2ecf20Sopenharmony_cishall be written into the VCPU. 11578c2ecf20Sopenharmony_ci 11588c2ecf20Sopenharmony_ciKVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available. 11598c2ecf20Sopenharmony_ci 11608c2ecf20Sopenharmony_ciIf KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_VCPUEVENT_VALID_PAYLOAD 11618c2ecf20Sopenharmony_cican be set in the flags field to signal that the 11628c2ecf20Sopenharmony_ciexception_has_payload, exception_payload, and exception.pending fields 11638c2ecf20Sopenharmony_cicontain a valid state and shall be written into the VCPU. 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_ciARM/ARM64: 11668c2ecf20Sopenharmony_ci^^^^^^^^^^ 11678c2ecf20Sopenharmony_ci 11688c2ecf20Sopenharmony_ciUser space may need to inject several types of events to the guest. 11698c2ecf20Sopenharmony_ci 11708c2ecf20Sopenharmony_ciSet the pending SError exception state for this VCPU. It is not possible to 11718c2ecf20Sopenharmony_ci'cancel' an Serror that has been made pending. 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_ciIf the guest performed an access to I/O memory which could not be handled by 11748c2ecf20Sopenharmony_ciuserspace, for example because of missing instruction syndrome decode 11758c2ecf20Sopenharmony_ciinformation or because there is no device mapped at the accessed IPA, then 11768c2ecf20Sopenharmony_ciuserspace can ask the kernel to inject an external abort using the address 11778c2ecf20Sopenharmony_cifrom the exiting fault on the VCPU. It is a programming error to set 11788c2ecf20Sopenharmony_ciext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or 11798c2ecf20Sopenharmony_ciKVM_EXIT_ARM_NISV. This feature is only available if the system supports 11808c2ecf20Sopenharmony_ciKVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in 11818c2ecf20Sopenharmony_cihow userspace reports accesses for the above cases to guests, across different 11828c2ecf20Sopenharmony_ciuserspace implementations. Nevertheless, userspace can still emulate all Arm 11838c2ecf20Sopenharmony_ciexceptions by manipulating individual registers using the KVM_SET_ONE_REG API. 11848c2ecf20Sopenharmony_ci 11858c2ecf20Sopenharmony_ciSee KVM_GET_VCPU_EVENTS for the data structure. 11868c2ecf20Sopenharmony_ci 11878c2ecf20Sopenharmony_ci 11888c2ecf20Sopenharmony_ci4.33 KVM_GET_DEBUGREGS 11898c2ecf20Sopenharmony_ci---------------------- 11908c2ecf20Sopenharmony_ci 11918c2ecf20Sopenharmony_ci:Capability: KVM_CAP_DEBUGREGS 11928c2ecf20Sopenharmony_ci:Architectures: x86 11938c2ecf20Sopenharmony_ci:Type: vm ioctl 11948c2ecf20Sopenharmony_ci:Parameters: struct kvm_debugregs (out) 11958c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 11968c2ecf20Sopenharmony_ci 11978c2ecf20Sopenharmony_ciReads debug registers from the vcpu. 11988c2ecf20Sopenharmony_ci 11998c2ecf20Sopenharmony_ci:: 12008c2ecf20Sopenharmony_ci 12018c2ecf20Sopenharmony_ci struct kvm_debugregs { 12028c2ecf20Sopenharmony_ci __u64 db[4]; 12038c2ecf20Sopenharmony_ci __u64 dr6; 12048c2ecf20Sopenharmony_ci __u64 dr7; 12058c2ecf20Sopenharmony_ci __u64 flags; 12068c2ecf20Sopenharmony_ci __u64 reserved[9]; 12078c2ecf20Sopenharmony_ci }; 12088c2ecf20Sopenharmony_ci 12098c2ecf20Sopenharmony_ci 12108c2ecf20Sopenharmony_ci4.34 KVM_SET_DEBUGREGS 12118c2ecf20Sopenharmony_ci---------------------- 12128c2ecf20Sopenharmony_ci 12138c2ecf20Sopenharmony_ci:Capability: KVM_CAP_DEBUGREGS 12148c2ecf20Sopenharmony_ci:Architectures: x86 12158c2ecf20Sopenharmony_ci:Type: vm ioctl 12168c2ecf20Sopenharmony_ci:Parameters: struct kvm_debugregs (in) 12178c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 12188c2ecf20Sopenharmony_ci 12198c2ecf20Sopenharmony_ciWrites debug registers into the vcpu. 12208c2ecf20Sopenharmony_ci 12218c2ecf20Sopenharmony_ciSee KVM_GET_DEBUGREGS for the data structure. The flags field is unused 12228c2ecf20Sopenharmony_ciyet and must be cleared on entry. 12238c2ecf20Sopenharmony_ci 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci4.35 KVM_SET_USER_MEMORY_REGION 12268c2ecf20Sopenharmony_ci------------------------------- 12278c2ecf20Sopenharmony_ci 12288c2ecf20Sopenharmony_ci:Capability: KVM_CAP_USER_MEMORY 12298c2ecf20Sopenharmony_ci:Architectures: all 12308c2ecf20Sopenharmony_ci:Type: vm ioctl 12318c2ecf20Sopenharmony_ci:Parameters: struct kvm_userspace_memory_region (in) 12328c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 12338c2ecf20Sopenharmony_ci 12348c2ecf20Sopenharmony_ci:: 12358c2ecf20Sopenharmony_ci 12368c2ecf20Sopenharmony_ci struct kvm_userspace_memory_region { 12378c2ecf20Sopenharmony_ci __u32 slot; 12388c2ecf20Sopenharmony_ci __u32 flags; 12398c2ecf20Sopenharmony_ci __u64 guest_phys_addr; 12408c2ecf20Sopenharmony_ci __u64 memory_size; /* bytes */ 12418c2ecf20Sopenharmony_ci __u64 userspace_addr; /* start of the userspace allocated memory */ 12428c2ecf20Sopenharmony_ci }; 12438c2ecf20Sopenharmony_ci 12448c2ecf20Sopenharmony_ci /* for kvm_memory_region::flags */ 12458c2ecf20Sopenharmony_ci #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 12468c2ecf20Sopenharmony_ci #define KVM_MEM_READONLY (1UL << 1) 12478c2ecf20Sopenharmony_ci 12488c2ecf20Sopenharmony_ciThis ioctl allows the user to create, modify or delete a guest physical 12498c2ecf20Sopenharmony_cimemory slot. Bits 0-15 of "slot" specify the slot id and this value 12508c2ecf20Sopenharmony_cishould be less than the maximum number of user memory slots supported per 12518c2ecf20Sopenharmony_ciVM. The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS. 12528c2ecf20Sopenharmony_ciSlots may not overlap in guest physical address space. 12538c2ecf20Sopenharmony_ci 12548c2ecf20Sopenharmony_ciIf KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot" 12558c2ecf20Sopenharmony_cispecifies the address space which is being modified. They must be 12568c2ecf20Sopenharmony_ciless than the value that KVM_CHECK_EXTENSION returns for the 12578c2ecf20Sopenharmony_ciKVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces 12588c2ecf20Sopenharmony_ciare unrelated; the restriction on overlapping slots only applies within 12598c2ecf20Sopenharmony_cieach address space. 12608c2ecf20Sopenharmony_ci 12618c2ecf20Sopenharmony_ciDeleting a slot is done by passing zero for memory_size. When changing 12628c2ecf20Sopenharmony_cian existing slot, it may be moved in the guest physical memory space, 12638c2ecf20Sopenharmony_cior its flags may be modified, but it may not be resized. 12648c2ecf20Sopenharmony_ci 12658c2ecf20Sopenharmony_ciMemory for the region is taken starting at the address denoted by the 12668c2ecf20Sopenharmony_cifield userspace_addr, which must point at user addressable memory for 12678c2ecf20Sopenharmony_cithe entire memory slot size. Any object may back this memory, including 12688c2ecf20Sopenharmony_cianonymous memory, ordinary files, and hugetlbfs. 12698c2ecf20Sopenharmony_ci 12708c2ecf20Sopenharmony_ciOn architectures that support a form of address tagging, userspace_addr must 12718c2ecf20Sopenharmony_cibe an untagged address. 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_ciIt is recommended that the lower 21 bits of guest_phys_addr and userspace_addr 12748c2ecf20Sopenharmony_cibe identical. This allows large pages in the guest to be backed by large 12758c2ecf20Sopenharmony_cipages in the host. 12768c2ecf20Sopenharmony_ci 12778c2ecf20Sopenharmony_ciThe flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and 12788c2ecf20Sopenharmony_ciKVM_MEM_READONLY. The former can be set to instruct KVM to keep track of 12798c2ecf20Sopenharmony_ciwrites to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to 12808c2ecf20Sopenharmony_ciuse it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it, 12818c2ecf20Sopenharmony_cito make a new slot read-only. In this case, writes to this memory will be 12828c2ecf20Sopenharmony_ciposted to userspace as KVM_EXIT_MMIO exits. 12838c2ecf20Sopenharmony_ci 12848c2ecf20Sopenharmony_ciWhen the KVM_CAP_SYNC_MMU capability is available, changes in the backing of 12858c2ecf20Sopenharmony_cithe memory region are automatically reflected into the guest. For example, an 12868c2ecf20Sopenharmony_cimmap() that affects the region will be made visible immediately. Another 12878c2ecf20Sopenharmony_ciexample is madvise(MADV_DROP). 12888c2ecf20Sopenharmony_ci 12898c2ecf20Sopenharmony_ciIt is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl. 12908c2ecf20Sopenharmony_ciThe KVM_SET_MEMORY_REGION does not allow fine grained control over memory 12918c2ecf20Sopenharmony_ciallocation and is deprecated. 12928c2ecf20Sopenharmony_ci 12938c2ecf20Sopenharmony_ci 12948c2ecf20Sopenharmony_ci4.36 KVM_SET_TSS_ADDR 12958c2ecf20Sopenharmony_ci--------------------- 12968c2ecf20Sopenharmony_ci 12978c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SET_TSS_ADDR 12988c2ecf20Sopenharmony_ci:Architectures: x86 12998c2ecf20Sopenharmony_ci:Type: vm ioctl 13008c2ecf20Sopenharmony_ci:Parameters: unsigned long tss_address (in) 13018c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 13028c2ecf20Sopenharmony_ci 13038c2ecf20Sopenharmony_ciThis ioctl defines the physical address of a three-page region in the guest 13048c2ecf20Sopenharmony_ciphysical address space. The region must be within the first 4GB of the 13058c2ecf20Sopenharmony_ciguest physical address space and must not conflict with any memory slot 13068c2ecf20Sopenharmony_cior any mmio address. The guest may malfunction if it accesses this memory 13078c2ecf20Sopenharmony_ciregion. 13088c2ecf20Sopenharmony_ci 13098c2ecf20Sopenharmony_ciThis ioctl is required on Intel-based hosts. This is needed on Intel hardware 13108c2ecf20Sopenharmony_cibecause of a quirk in the virtualization implementation (see the internals 13118c2ecf20Sopenharmony_cidocumentation when it pops into existence). 13128c2ecf20Sopenharmony_ci 13138c2ecf20Sopenharmony_ci 13148c2ecf20Sopenharmony_ci4.37 KVM_ENABLE_CAP 13158c2ecf20Sopenharmony_ci------------------- 13168c2ecf20Sopenharmony_ci 13178c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ENABLE_CAP 13188c2ecf20Sopenharmony_ci:Architectures: mips, ppc, s390 13198c2ecf20Sopenharmony_ci:Type: vcpu ioctl 13208c2ecf20Sopenharmony_ci:Parameters: struct kvm_enable_cap (in) 13218c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 13228c2ecf20Sopenharmony_ci 13238c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ENABLE_CAP_VM 13248c2ecf20Sopenharmony_ci:Architectures: all 13258c2ecf20Sopenharmony_ci:Type: vm ioctl 13268c2ecf20Sopenharmony_ci:Parameters: struct kvm_enable_cap (in) 13278c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 13288c2ecf20Sopenharmony_ci 13298c2ecf20Sopenharmony_ci.. note:: 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_ci Not all extensions are enabled by default. Using this ioctl the application 13328c2ecf20Sopenharmony_ci can enable an extension, making it available to the guest. 13338c2ecf20Sopenharmony_ci 13348c2ecf20Sopenharmony_ciOn systems that do not support this ioctl, it always fails. On systems that 13358c2ecf20Sopenharmony_cido support it, it only works for extensions that are supported for enablement. 13368c2ecf20Sopenharmony_ci 13378c2ecf20Sopenharmony_ciTo check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should 13388c2ecf20Sopenharmony_cibe used. 13398c2ecf20Sopenharmony_ci 13408c2ecf20Sopenharmony_ci:: 13418c2ecf20Sopenharmony_ci 13428c2ecf20Sopenharmony_ci struct kvm_enable_cap { 13438c2ecf20Sopenharmony_ci /* in */ 13448c2ecf20Sopenharmony_ci __u32 cap; 13458c2ecf20Sopenharmony_ci 13468c2ecf20Sopenharmony_ciThe capability that is supposed to get enabled. 13478c2ecf20Sopenharmony_ci 13488c2ecf20Sopenharmony_ci:: 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_ci __u32 flags; 13518c2ecf20Sopenharmony_ci 13528c2ecf20Sopenharmony_ciA bitfield indicating future enhancements. Has to be 0 for now. 13538c2ecf20Sopenharmony_ci 13548c2ecf20Sopenharmony_ci:: 13558c2ecf20Sopenharmony_ci 13568c2ecf20Sopenharmony_ci __u64 args[4]; 13578c2ecf20Sopenharmony_ci 13588c2ecf20Sopenharmony_ciArguments for enabling a feature. If a feature needs initial values to 13598c2ecf20Sopenharmony_cifunction properly, this is the place to put them. 13608c2ecf20Sopenharmony_ci 13618c2ecf20Sopenharmony_ci:: 13628c2ecf20Sopenharmony_ci 13638c2ecf20Sopenharmony_ci __u8 pad[64]; 13648c2ecf20Sopenharmony_ci }; 13658c2ecf20Sopenharmony_ci 13668c2ecf20Sopenharmony_ciThe vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl 13678c2ecf20Sopenharmony_cifor vm-wide capabilities. 13688c2ecf20Sopenharmony_ci 13698c2ecf20Sopenharmony_ci4.38 KVM_GET_MP_STATE 13708c2ecf20Sopenharmony_ci--------------------- 13718c2ecf20Sopenharmony_ci 13728c2ecf20Sopenharmony_ci:Capability: KVM_CAP_MP_STATE 13738c2ecf20Sopenharmony_ci:Architectures: x86, s390, arm, arm64 13748c2ecf20Sopenharmony_ci:Type: vcpu ioctl 13758c2ecf20Sopenharmony_ci:Parameters: struct kvm_mp_state (out) 13768c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 13778c2ecf20Sopenharmony_ci 13788c2ecf20Sopenharmony_ci:: 13798c2ecf20Sopenharmony_ci 13808c2ecf20Sopenharmony_ci struct kvm_mp_state { 13818c2ecf20Sopenharmony_ci __u32 mp_state; 13828c2ecf20Sopenharmony_ci }; 13838c2ecf20Sopenharmony_ci 13848c2ecf20Sopenharmony_ciReturns the vcpu's current "multiprocessing state" (though also valid on 13858c2ecf20Sopenharmony_ciuniprocessor guests). 13868c2ecf20Sopenharmony_ci 13878c2ecf20Sopenharmony_ciPossible values are: 13888c2ecf20Sopenharmony_ci 13898c2ecf20Sopenharmony_ci ========================== =============================================== 13908c2ecf20Sopenharmony_ci KVM_MP_STATE_RUNNABLE the vcpu is currently running [x86,arm/arm64] 13918c2ecf20Sopenharmony_ci KVM_MP_STATE_UNINITIALIZED the vcpu is an application processor (AP) 13928c2ecf20Sopenharmony_ci which has not yet received an INIT signal [x86] 13938c2ecf20Sopenharmony_ci KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, and is 13948c2ecf20Sopenharmony_ci now ready for a SIPI [x86] 13958c2ecf20Sopenharmony_ci KVM_MP_STATE_HALTED the vcpu has executed a HLT instruction and 13968c2ecf20Sopenharmony_ci is waiting for an interrupt [x86] 13978c2ecf20Sopenharmony_ci KVM_MP_STATE_SIPI_RECEIVED the vcpu has just received a SIPI (vector 13988c2ecf20Sopenharmony_ci accessible via KVM_GET_VCPU_EVENTS) [x86] 13998c2ecf20Sopenharmony_ci KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm/arm64] 14008c2ecf20Sopenharmony_ci KVM_MP_STATE_CHECK_STOP the vcpu is in a special error state [s390] 14018c2ecf20Sopenharmony_ci KVM_MP_STATE_OPERATING the vcpu is operating (running or halted) 14028c2ecf20Sopenharmony_ci [s390] 14038c2ecf20Sopenharmony_ci KVM_MP_STATE_LOAD the vcpu is in a special load/startup state 14048c2ecf20Sopenharmony_ci [s390] 14058c2ecf20Sopenharmony_ci ========================== =============================================== 14068c2ecf20Sopenharmony_ci 14078c2ecf20Sopenharmony_ciOn x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an 14088c2ecf20Sopenharmony_ciin-kernel irqchip, the multiprocessing state must be maintained by userspace on 14098c2ecf20Sopenharmony_cithese architectures. 14108c2ecf20Sopenharmony_ci 14118c2ecf20Sopenharmony_ciFor arm/arm64: 14128c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^ 14138c2ecf20Sopenharmony_ci 14148c2ecf20Sopenharmony_ciThe only states that are valid are KVM_MP_STATE_STOPPED and 14158c2ecf20Sopenharmony_ciKVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not. 14168c2ecf20Sopenharmony_ci 14178c2ecf20Sopenharmony_ci4.39 KVM_SET_MP_STATE 14188c2ecf20Sopenharmony_ci--------------------- 14198c2ecf20Sopenharmony_ci 14208c2ecf20Sopenharmony_ci:Capability: KVM_CAP_MP_STATE 14218c2ecf20Sopenharmony_ci:Architectures: x86, s390, arm, arm64 14228c2ecf20Sopenharmony_ci:Type: vcpu ioctl 14238c2ecf20Sopenharmony_ci:Parameters: struct kvm_mp_state (in) 14248c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 14258c2ecf20Sopenharmony_ci 14268c2ecf20Sopenharmony_ciSets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for 14278c2ecf20Sopenharmony_ciarguments. 14288c2ecf20Sopenharmony_ci 14298c2ecf20Sopenharmony_ciOn x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an 14308c2ecf20Sopenharmony_ciin-kernel irqchip, the multiprocessing state must be maintained by userspace on 14318c2ecf20Sopenharmony_cithese architectures. 14328c2ecf20Sopenharmony_ci 14338c2ecf20Sopenharmony_ciFor arm/arm64: 14348c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^ 14358c2ecf20Sopenharmony_ci 14368c2ecf20Sopenharmony_ciThe only states that are valid are KVM_MP_STATE_STOPPED and 14378c2ecf20Sopenharmony_ciKVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not. 14388c2ecf20Sopenharmony_ci 14398c2ecf20Sopenharmony_ci4.40 KVM_SET_IDENTITY_MAP_ADDR 14408c2ecf20Sopenharmony_ci------------------------------ 14418c2ecf20Sopenharmony_ci 14428c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR 14438c2ecf20Sopenharmony_ci:Architectures: x86 14448c2ecf20Sopenharmony_ci:Type: vm ioctl 14458c2ecf20Sopenharmony_ci:Parameters: unsigned long identity (in) 14468c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 14478c2ecf20Sopenharmony_ci 14488c2ecf20Sopenharmony_ciThis ioctl defines the physical address of a one-page region in the guest 14498c2ecf20Sopenharmony_ciphysical address space. The region must be within the first 4GB of the 14508c2ecf20Sopenharmony_ciguest physical address space and must not conflict with any memory slot 14518c2ecf20Sopenharmony_cior any mmio address. The guest may malfunction if it accesses this memory 14528c2ecf20Sopenharmony_ciregion. 14538c2ecf20Sopenharmony_ci 14548c2ecf20Sopenharmony_ciSetting the address to 0 will result in resetting the address to its default 14558c2ecf20Sopenharmony_ci(0xfffbc000). 14568c2ecf20Sopenharmony_ci 14578c2ecf20Sopenharmony_ciThis ioctl is required on Intel-based hosts. This is needed on Intel hardware 14588c2ecf20Sopenharmony_cibecause of a quirk in the virtualization implementation (see the internals 14598c2ecf20Sopenharmony_cidocumentation when it pops into existence). 14608c2ecf20Sopenharmony_ci 14618c2ecf20Sopenharmony_ciFails if any VCPU has already been created. 14628c2ecf20Sopenharmony_ci 14638c2ecf20Sopenharmony_ci4.41 KVM_SET_BOOT_CPU_ID 14648c2ecf20Sopenharmony_ci------------------------ 14658c2ecf20Sopenharmony_ci 14668c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SET_BOOT_CPU_ID 14678c2ecf20Sopenharmony_ci:Architectures: x86 14688c2ecf20Sopenharmony_ci:Type: vm ioctl 14698c2ecf20Sopenharmony_ci:Parameters: unsigned long vcpu_id 14708c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 14718c2ecf20Sopenharmony_ci 14728c2ecf20Sopenharmony_ciDefine which vcpu is the Bootstrap Processor (BSP). Values are the same 14738c2ecf20Sopenharmony_cias the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default 14748c2ecf20Sopenharmony_ciis vcpu 0. 14758c2ecf20Sopenharmony_ci 14768c2ecf20Sopenharmony_ci 14778c2ecf20Sopenharmony_ci4.42 KVM_GET_XSAVE 14788c2ecf20Sopenharmony_ci------------------ 14798c2ecf20Sopenharmony_ci 14808c2ecf20Sopenharmony_ci:Capability: KVM_CAP_XSAVE 14818c2ecf20Sopenharmony_ci:Architectures: x86 14828c2ecf20Sopenharmony_ci:Type: vcpu ioctl 14838c2ecf20Sopenharmony_ci:Parameters: struct kvm_xsave (out) 14848c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 14858c2ecf20Sopenharmony_ci 14868c2ecf20Sopenharmony_ci 14878c2ecf20Sopenharmony_ci:: 14888c2ecf20Sopenharmony_ci 14898c2ecf20Sopenharmony_ci struct kvm_xsave { 14908c2ecf20Sopenharmony_ci __u32 region[1024]; 14918c2ecf20Sopenharmony_ci }; 14928c2ecf20Sopenharmony_ci 14938c2ecf20Sopenharmony_ciThis ioctl would copy current vcpu's xsave struct to the userspace. 14948c2ecf20Sopenharmony_ci 14958c2ecf20Sopenharmony_ci 14968c2ecf20Sopenharmony_ci4.43 KVM_SET_XSAVE 14978c2ecf20Sopenharmony_ci------------------ 14988c2ecf20Sopenharmony_ci 14998c2ecf20Sopenharmony_ci:Capability: KVM_CAP_XSAVE 15008c2ecf20Sopenharmony_ci:Architectures: x86 15018c2ecf20Sopenharmony_ci:Type: vcpu ioctl 15028c2ecf20Sopenharmony_ci:Parameters: struct kvm_xsave (in) 15038c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 15048c2ecf20Sopenharmony_ci 15058c2ecf20Sopenharmony_ci:: 15068c2ecf20Sopenharmony_ci 15078c2ecf20Sopenharmony_ci 15088c2ecf20Sopenharmony_ci struct kvm_xsave { 15098c2ecf20Sopenharmony_ci __u32 region[1024]; 15108c2ecf20Sopenharmony_ci }; 15118c2ecf20Sopenharmony_ci 15128c2ecf20Sopenharmony_ciThis ioctl would copy userspace's xsave struct to the kernel. 15138c2ecf20Sopenharmony_ci 15148c2ecf20Sopenharmony_ci 15158c2ecf20Sopenharmony_ci4.44 KVM_GET_XCRS 15168c2ecf20Sopenharmony_ci----------------- 15178c2ecf20Sopenharmony_ci 15188c2ecf20Sopenharmony_ci:Capability: KVM_CAP_XCRS 15198c2ecf20Sopenharmony_ci:Architectures: x86 15208c2ecf20Sopenharmony_ci:Type: vcpu ioctl 15218c2ecf20Sopenharmony_ci:Parameters: struct kvm_xcrs (out) 15228c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 15238c2ecf20Sopenharmony_ci 15248c2ecf20Sopenharmony_ci:: 15258c2ecf20Sopenharmony_ci 15268c2ecf20Sopenharmony_ci struct kvm_xcr { 15278c2ecf20Sopenharmony_ci __u32 xcr; 15288c2ecf20Sopenharmony_ci __u32 reserved; 15298c2ecf20Sopenharmony_ci __u64 value; 15308c2ecf20Sopenharmony_ci }; 15318c2ecf20Sopenharmony_ci 15328c2ecf20Sopenharmony_ci struct kvm_xcrs { 15338c2ecf20Sopenharmony_ci __u32 nr_xcrs; 15348c2ecf20Sopenharmony_ci __u32 flags; 15358c2ecf20Sopenharmony_ci struct kvm_xcr xcrs[KVM_MAX_XCRS]; 15368c2ecf20Sopenharmony_ci __u64 padding[16]; 15378c2ecf20Sopenharmony_ci }; 15388c2ecf20Sopenharmony_ci 15398c2ecf20Sopenharmony_ciThis ioctl would copy current vcpu's xcrs to the userspace. 15408c2ecf20Sopenharmony_ci 15418c2ecf20Sopenharmony_ci 15428c2ecf20Sopenharmony_ci4.45 KVM_SET_XCRS 15438c2ecf20Sopenharmony_ci----------------- 15448c2ecf20Sopenharmony_ci 15458c2ecf20Sopenharmony_ci:Capability: KVM_CAP_XCRS 15468c2ecf20Sopenharmony_ci:Architectures: x86 15478c2ecf20Sopenharmony_ci:Type: vcpu ioctl 15488c2ecf20Sopenharmony_ci:Parameters: struct kvm_xcrs (in) 15498c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 15508c2ecf20Sopenharmony_ci 15518c2ecf20Sopenharmony_ci:: 15528c2ecf20Sopenharmony_ci 15538c2ecf20Sopenharmony_ci struct kvm_xcr { 15548c2ecf20Sopenharmony_ci __u32 xcr; 15558c2ecf20Sopenharmony_ci __u32 reserved; 15568c2ecf20Sopenharmony_ci __u64 value; 15578c2ecf20Sopenharmony_ci }; 15588c2ecf20Sopenharmony_ci 15598c2ecf20Sopenharmony_ci struct kvm_xcrs { 15608c2ecf20Sopenharmony_ci __u32 nr_xcrs; 15618c2ecf20Sopenharmony_ci __u32 flags; 15628c2ecf20Sopenharmony_ci struct kvm_xcr xcrs[KVM_MAX_XCRS]; 15638c2ecf20Sopenharmony_ci __u64 padding[16]; 15648c2ecf20Sopenharmony_ci }; 15658c2ecf20Sopenharmony_ci 15668c2ecf20Sopenharmony_ciThis ioctl would set vcpu's xcr to the value userspace specified. 15678c2ecf20Sopenharmony_ci 15688c2ecf20Sopenharmony_ci 15698c2ecf20Sopenharmony_ci4.46 KVM_GET_SUPPORTED_CPUID 15708c2ecf20Sopenharmony_ci---------------------------- 15718c2ecf20Sopenharmony_ci 15728c2ecf20Sopenharmony_ci:Capability: KVM_CAP_EXT_CPUID 15738c2ecf20Sopenharmony_ci:Architectures: x86 15748c2ecf20Sopenharmony_ci:Type: system ioctl 15758c2ecf20Sopenharmony_ci:Parameters: struct kvm_cpuid2 (in/out) 15768c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 15778c2ecf20Sopenharmony_ci 15788c2ecf20Sopenharmony_ci:: 15798c2ecf20Sopenharmony_ci 15808c2ecf20Sopenharmony_ci struct kvm_cpuid2 { 15818c2ecf20Sopenharmony_ci __u32 nent; 15828c2ecf20Sopenharmony_ci __u32 padding; 15838c2ecf20Sopenharmony_ci struct kvm_cpuid_entry2 entries[0]; 15848c2ecf20Sopenharmony_ci }; 15858c2ecf20Sopenharmony_ci 15868c2ecf20Sopenharmony_ci #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) 15878c2ecf20Sopenharmony_ci #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */ 15888c2ecf20Sopenharmony_ci #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */ 15898c2ecf20Sopenharmony_ci 15908c2ecf20Sopenharmony_ci struct kvm_cpuid_entry2 { 15918c2ecf20Sopenharmony_ci __u32 function; 15928c2ecf20Sopenharmony_ci __u32 index; 15938c2ecf20Sopenharmony_ci __u32 flags; 15948c2ecf20Sopenharmony_ci __u32 eax; 15958c2ecf20Sopenharmony_ci __u32 ebx; 15968c2ecf20Sopenharmony_ci __u32 ecx; 15978c2ecf20Sopenharmony_ci __u32 edx; 15988c2ecf20Sopenharmony_ci __u32 padding[3]; 15998c2ecf20Sopenharmony_ci }; 16008c2ecf20Sopenharmony_ci 16018c2ecf20Sopenharmony_ciThis ioctl returns x86 cpuid features which are supported by both the 16028c2ecf20Sopenharmony_cihardware and kvm in its default configuration. Userspace can use the 16038c2ecf20Sopenharmony_ciinformation returned by this ioctl to construct cpuid information (for 16048c2ecf20Sopenharmony_ciKVM_SET_CPUID2) that is consistent with hardware, kernel, and 16058c2ecf20Sopenharmony_ciuserspace capabilities, and with user requirements (for example, the 16068c2ecf20Sopenharmony_ciuser may wish to constrain cpuid to emulate older hardware, or for 16078c2ecf20Sopenharmony_cifeature consistency across a cluster). 16088c2ecf20Sopenharmony_ci 16098c2ecf20Sopenharmony_ciNote that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may 16108c2ecf20Sopenharmony_ciexpose cpuid features (e.g. MONITOR) which are not supported by kvm in 16118c2ecf20Sopenharmony_ciits default configuration. If userspace enables such capabilities, it 16128c2ecf20Sopenharmony_ciis responsible for modifying the results of this ioctl appropriately. 16138c2ecf20Sopenharmony_ci 16148c2ecf20Sopenharmony_ciUserspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure 16158c2ecf20Sopenharmony_ciwith the 'nent' field indicating the number of entries in the variable-size 16168c2ecf20Sopenharmony_ciarray 'entries'. If the number of entries is too low to describe the cpu 16178c2ecf20Sopenharmony_cicapabilities, an error (E2BIG) is returned. If the number is too high, 16188c2ecf20Sopenharmony_cithe 'nent' field is adjusted and an error (ENOMEM) is returned. If the 16198c2ecf20Sopenharmony_cinumber is just right, the 'nent' field is adjusted to the number of valid 16208c2ecf20Sopenharmony_cientries in the 'entries' array, which is then filled. 16218c2ecf20Sopenharmony_ci 16228c2ecf20Sopenharmony_ciThe entries returned are the host cpuid as returned by the cpuid instruction, 16238c2ecf20Sopenharmony_ciwith unknown or unsupported features masked out. Some features (for example, 16248c2ecf20Sopenharmony_cix2apic), may not be present in the host cpu, but are exposed by kvm if it can 16258c2ecf20Sopenharmony_ciemulate them efficiently. The fields in each entry are defined as follows: 16268c2ecf20Sopenharmony_ci 16278c2ecf20Sopenharmony_ci function: 16288c2ecf20Sopenharmony_ci the eax value used to obtain the entry 16298c2ecf20Sopenharmony_ci 16308c2ecf20Sopenharmony_ci index: 16318c2ecf20Sopenharmony_ci the ecx value used to obtain the entry (for entries that are 16328c2ecf20Sopenharmony_ci affected by ecx) 16338c2ecf20Sopenharmony_ci 16348c2ecf20Sopenharmony_ci flags: 16358c2ecf20Sopenharmony_ci an OR of zero or more of the following: 16368c2ecf20Sopenharmony_ci 16378c2ecf20Sopenharmony_ci KVM_CPUID_FLAG_SIGNIFCANT_INDEX: 16388c2ecf20Sopenharmony_ci if the index field is valid 16398c2ecf20Sopenharmony_ci 16408c2ecf20Sopenharmony_ci eax, ebx, ecx, edx: 16418c2ecf20Sopenharmony_ci the values returned by the cpuid instruction for 16428c2ecf20Sopenharmony_ci this function/index combination 16438c2ecf20Sopenharmony_ci 16448c2ecf20Sopenharmony_ciThe TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned 16458c2ecf20Sopenharmony_cias false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC 16468c2ecf20Sopenharmony_cisupport. Instead it is reported via:: 16478c2ecf20Sopenharmony_ci 16488c2ecf20Sopenharmony_ci ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) 16498c2ecf20Sopenharmony_ci 16508c2ecf20Sopenharmony_ciif that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the 16518c2ecf20Sopenharmony_cifeature in userspace, then you can enable the feature for KVM_SET_CPUID2. 16528c2ecf20Sopenharmony_ci 16538c2ecf20Sopenharmony_ci 16548c2ecf20Sopenharmony_ci4.47 KVM_PPC_GET_PVINFO 16558c2ecf20Sopenharmony_ci----------------------- 16568c2ecf20Sopenharmony_ci 16578c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_GET_PVINFO 16588c2ecf20Sopenharmony_ci:Architectures: ppc 16598c2ecf20Sopenharmony_ci:Type: vm ioctl 16608c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_pvinfo (out) 16618c2ecf20Sopenharmony_ci:Returns: 0 on success, !0 on error 16628c2ecf20Sopenharmony_ci 16638c2ecf20Sopenharmony_ci:: 16648c2ecf20Sopenharmony_ci 16658c2ecf20Sopenharmony_ci struct kvm_ppc_pvinfo { 16668c2ecf20Sopenharmony_ci __u32 flags; 16678c2ecf20Sopenharmony_ci __u32 hcall[4]; 16688c2ecf20Sopenharmony_ci __u8 pad[108]; 16698c2ecf20Sopenharmony_ci }; 16708c2ecf20Sopenharmony_ci 16718c2ecf20Sopenharmony_ciThis ioctl fetches PV specific information that need to be passed to the guest 16728c2ecf20Sopenharmony_ciusing the device tree or other means from vm context. 16738c2ecf20Sopenharmony_ci 16748c2ecf20Sopenharmony_ciThe hcall array defines 4 instructions that make up a hypercall. 16758c2ecf20Sopenharmony_ci 16768c2ecf20Sopenharmony_ciIf any additional field gets added to this structure later on, a bit for that 16778c2ecf20Sopenharmony_ciadditional piece of information will be set in the flags bitmap. 16788c2ecf20Sopenharmony_ci 16798c2ecf20Sopenharmony_ciThe flags bitmap is defined as:: 16808c2ecf20Sopenharmony_ci 16818c2ecf20Sopenharmony_ci /* the host supports the ePAPR idle hcall 16828c2ecf20Sopenharmony_ci #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 16838c2ecf20Sopenharmony_ci 16848c2ecf20Sopenharmony_ci4.52 KVM_SET_GSI_ROUTING 16858c2ecf20Sopenharmony_ci------------------------ 16868c2ecf20Sopenharmony_ci 16878c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQ_ROUTING 16888c2ecf20Sopenharmony_ci:Architectures: x86 s390 arm arm64 16898c2ecf20Sopenharmony_ci:Type: vm ioctl 16908c2ecf20Sopenharmony_ci:Parameters: struct kvm_irq_routing (in) 16918c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 16928c2ecf20Sopenharmony_ci 16938c2ecf20Sopenharmony_ciSets the GSI routing table entries, overwriting any previously set entries. 16948c2ecf20Sopenharmony_ci 16958c2ecf20Sopenharmony_ciOn arm/arm64, GSI routing has the following limitation: 16968c2ecf20Sopenharmony_ci 16978c2ecf20Sopenharmony_ci- GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD. 16988c2ecf20Sopenharmony_ci 16998c2ecf20Sopenharmony_ci:: 17008c2ecf20Sopenharmony_ci 17018c2ecf20Sopenharmony_ci struct kvm_irq_routing { 17028c2ecf20Sopenharmony_ci __u32 nr; 17038c2ecf20Sopenharmony_ci __u32 flags; 17048c2ecf20Sopenharmony_ci struct kvm_irq_routing_entry entries[0]; 17058c2ecf20Sopenharmony_ci }; 17068c2ecf20Sopenharmony_ci 17078c2ecf20Sopenharmony_ciNo flags are specified so far, the corresponding field must be set to zero. 17088c2ecf20Sopenharmony_ci 17098c2ecf20Sopenharmony_ci:: 17108c2ecf20Sopenharmony_ci 17118c2ecf20Sopenharmony_ci struct kvm_irq_routing_entry { 17128c2ecf20Sopenharmony_ci __u32 gsi; 17138c2ecf20Sopenharmony_ci __u32 type; 17148c2ecf20Sopenharmony_ci __u32 flags; 17158c2ecf20Sopenharmony_ci __u32 pad; 17168c2ecf20Sopenharmony_ci union { 17178c2ecf20Sopenharmony_ci struct kvm_irq_routing_irqchip irqchip; 17188c2ecf20Sopenharmony_ci struct kvm_irq_routing_msi msi; 17198c2ecf20Sopenharmony_ci struct kvm_irq_routing_s390_adapter adapter; 17208c2ecf20Sopenharmony_ci struct kvm_irq_routing_hv_sint hv_sint; 17218c2ecf20Sopenharmony_ci __u32 pad[8]; 17228c2ecf20Sopenharmony_ci } u; 17238c2ecf20Sopenharmony_ci }; 17248c2ecf20Sopenharmony_ci 17258c2ecf20Sopenharmony_ci /* gsi routing entry types */ 17268c2ecf20Sopenharmony_ci #define KVM_IRQ_ROUTING_IRQCHIP 1 17278c2ecf20Sopenharmony_ci #define KVM_IRQ_ROUTING_MSI 2 17288c2ecf20Sopenharmony_ci #define KVM_IRQ_ROUTING_S390_ADAPTER 3 17298c2ecf20Sopenharmony_ci #define KVM_IRQ_ROUTING_HV_SINT 4 17308c2ecf20Sopenharmony_ci 17318c2ecf20Sopenharmony_ciflags: 17328c2ecf20Sopenharmony_ci 17338c2ecf20Sopenharmony_ci- KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry 17348c2ecf20Sopenharmony_ci type, specifies that the devid field contains a valid value. The per-VM 17358c2ecf20Sopenharmony_ci KVM_CAP_MSI_DEVID capability advertises the requirement to provide 17368c2ecf20Sopenharmony_ci the device ID. If this capability is not available, userspace should 17378c2ecf20Sopenharmony_ci never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. 17388c2ecf20Sopenharmony_ci- zero otherwise 17398c2ecf20Sopenharmony_ci 17408c2ecf20Sopenharmony_ci:: 17418c2ecf20Sopenharmony_ci 17428c2ecf20Sopenharmony_ci struct kvm_irq_routing_irqchip { 17438c2ecf20Sopenharmony_ci __u32 irqchip; 17448c2ecf20Sopenharmony_ci __u32 pin; 17458c2ecf20Sopenharmony_ci }; 17468c2ecf20Sopenharmony_ci 17478c2ecf20Sopenharmony_ci struct kvm_irq_routing_msi { 17488c2ecf20Sopenharmony_ci __u32 address_lo; 17498c2ecf20Sopenharmony_ci __u32 address_hi; 17508c2ecf20Sopenharmony_ci __u32 data; 17518c2ecf20Sopenharmony_ci union { 17528c2ecf20Sopenharmony_ci __u32 pad; 17538c2ecf20Sopenharmony_ci __u32 devid; 17548c2ecf20Sopenharmony_ci }; 17558c2ecf20Sopenharmony_ci }; 17568c2ecf20Sopenharmony_ci 17578c2ecf20Sopenharmony_ciIf KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier 17588c2ecf20Sopenharmony_cifor the device that wrote the MSI message. For PCI, this is usually a 17598c2ecf20Sopenharmony_ciBFD identifier in the lower 16 bits. 17608c2ecf20Sopenharmony_ci 17618c2ecf20Sopenharmony_ciOn x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS 17628c2ecf20Sopenharmony_cifeature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, 17638c2ecf20Sopenharmony_ciaddress_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of 17648c2ecf20Sopenharmony_ciaddress_hi must be zero. 17658c2ecf20Sopenharmony_ci 17668c2ecf20Sopenharmony_ci:: 17678c2ecf20Sopenharmony_ci 17688c2ecf20Sopenharmony_ci struct kvm_irq_routing_s390_adapter { 17698c2ecf20Sopenharmony_ci __u64 ind_addr; 17708c2ecf20Sopenharmony_ci __u64 summary_addr; 17718c2ecf20Sopenharmony_ci __u64 ind_offset; 17728c2ecf20Sopenharmony_ci __u32 summary_offset; 17738c2ecf20Sopenharmony_ci __u32 adapter_id; 17748c2ecf20Sopenharmony_ci }; 17758c2ecf20Sopenharmony_ci 17768c2ecf20Sopenharmony_ci struct kvm_irq_routing_hv_sint { 17778c2ecf20Sopenharmony_ci __u32 vcpu; 17788c2ecf20Sopenharmony_ci __u32 sint; 17798c2ecf20Sopenharmony_ci }; 17808c2ecf20Sopenharmony_ci 17818c2ecf20Sopenharmony_ci 17828c2ecf20Sopenharmony_ci4.55 KVM_SET_TSC_KHZ 17838c2ecf20Sopenharmony_ci-------------------- 17848c2ecf20Sopenharmony_ci 17858c2ecf20Sopenharmony_ci:Capability: KVM_CAP_TSC_CONTROL 17868c2ecf20Sopenharmony_ci:Architectures: x86 17878c2ecf20Sopenharmony_ci:Type: vcpu ioctl 17888c2ecf20Sopenharmony_ci:Parameters: virtual tsc_khz 17898c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 17908c2ecf20Sopenharmony_ci 17918c2ecf20Sopenharmony_ciSpecifies the tsc frequency for the virtual machine. The unit of the 17928c2ecf20Sopenharmony_cifrequency is KHz. 17938c2ecf20Sopenharmony_ci 17948c2ecf20Sopenharmony_ci 17958c2ecf20Sopenharmony_ci4.56 KVM_GET_TSC_KHZ 17968c2ecf20Sopenharmony_ci-------------------- 17978c2ecf20Sopenharmony_ci 17988c2ecf20Sopenharmony_ci:Capability: KVM_CAP_GET_TSC_KHZ 17998c2ecf20Sopenharmony_ci:Architectures: x86 18008c2ecf20Sopenharmony_ci:Type: vcpu ioctl 18018c2ecf20Sopenharmony_ci:Parameters: none 18028c2ecf20Sopenharmony_ci:Returns: virtual tsc-khz on success, negative value on error 18038c2ecf20Sopenharmony_ci 18048c2ecf20Sopenharmony_ciReturns the tsc frequency of the guest. The unit of the return value is 18058c2ecf20Sopenharmony_ciKHz. If the host has unstable tsc this ioctl returns -EIO instead as an 18068c2ecf20Sopenharmony_cierror. 18078c2ecf20Sopenharmony_ci 18088c2ecf20Sopenharmony_ci 18098c2ecf20Sopenharmony_ci4.57 KVM_GET_LAPIC 18108c2ecf20Sopenharmony_ci------------------ 18118c2ecf20Sopenharmony_ci 18128c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 18138c2ecf20Sopenharmony_ci:Architectures: x86 18148c2ecf20Sopenharmony_ci:Type: vcpu ioctl 18158c2ecf20Sopenharmony_ci:Parameters: struct kvm_lapic_state (out) 18168c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 18178c2ecf20Sopenharmony_ci 18188c2ecf20Sopenharmony_ci:: 18198c2ecf20Sopenharmony_ci 18208c2ecf20Sopenharmony_ci #define KVM_APIC_REG_SIZE 0x400 18218c2ecf20Sopenharmony_ci struct kvm_lapic_state { 18228c2ecf20Sopenharmony_ci char regs[KVM_APIC_REG_SIZE]; 18238c2ecf20Sopenharmony_ci }; 18248c2ecf20Sopenharmony_ci 18258c2ecf20Sopenharmony_ciReads the Local APIC registers and copies them into the input argument. The 18268c2ecf20Sopenharmony_cidata format and layout are the same as documented in the architecture manual. 18278c2ecf20Sopenharmony_ci 18288c2ecf20Sopenharmony_ciIf KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is 18298c2ecf20Sopenharmony_cienabled, then the format of APIC_ID register depends on the APIC mode 18308c2ecf20Sopenharmony_ci(reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in 18318c2ecf20Sopenharmony_cithe APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID 18328c2ecf20Sopenharmony_ciwhich is stored in bits 31-24 of the APIC register, or equivalently in 18338c2ecf20Sopenharmony_cibyte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then 18348c2ecf20Sopenharmony_cibe called after MSR_IA32_APICBASE has been set with KVM_SET_MSR. 18358c2ecf20Sopenharmony_ci 18368c2ecf20Sopenharmony_ciIf KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state 18378c2ecf20Sopenharmony_cialways uses xAPIC format. 18388c2ecf20Sopenharmony_ci 18398c2ecf20Sopenharmony_ci 18408c2ecf20Sopenharmony_ci4.58 KVM_SET_LAPIC 18418c2ecf20Sopenharmony_ci------------------ 18428c2ecf20Sopenharmony_ci 18438c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 18448c2ecf20Sopenharmony_ci:Architectures: x86 18458c2ecf20Sopenharmony_ci:Type: vcpu ioctl 18468c2ecf20Sopenharmony_ci:Parameters: struct kvm_lapic_state (in) 18478c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 18488c2ecf20Sopenharmony_ci 18498c2ecf20Sopenharmony_ci:: 18508c2ecf20Sopenharmony_ci 18518c2ecf20Sopenharmony_ci #define KVM_APIC_REG_SIZE 0x400 18528c2ecf20Sopenharmony_ci struct kvm_lapic_state { 18538c2ecf20Sopenharmony_ci char regs[KVM_APIC_REG_SIZE]; 18548c2ecf20Sopenharmony_ci }; 18558c2ecf20Sopenharmony_ci 18568c2ecf20Sopenharmony_ciCopies the input argument into the Local APIC registers. The data format 18578c2ecf20Sopenharmony_ciand layout are the same as documented in the architecture manual. 18588c2ecf20Sopenharmony_ci 18598c2ecf20Sopenharmony_ciThe format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's 18608c2ecf20Sopenharmony_ciregs field) depends on the state of the KVM_CAP_X2APIC_API capability. 18618c2ecf20Sopenharmony_ciSee the note in KVM_GET_LAPIC. 18628c2ecf20Sopenharmony_ci 18638c2ecf20Sopenharmony_ci 18648c2ecf20Sopenharmony_ci4.59 KVM_IOEVENTFD 18658c2ecf20Sopenharmony_ci------------------ 18668c2ecf20Sopenharmony_ci 18678c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IOEVENTFD 18688c2ecf20Sopenharmony_ci:Architectures: all 18698c2ecf20Sopenharmony_ci:Type: vm ioctl 18708c2ecf20Sopenharmony_ci:Parameters: struct kvm_ioeventfd (in) 18718c2ecf20Sopenharmony_ci:Returns: 0 on success, !0 on error 18728c2ecf20Sopenharmony_ci 18738c2ecf20Sopenharmony_ciThis ioctl attaches or detaches an ioeventfd to a legal pio/mmio address 18748c2ecf20Sopenharmony_ciwithin the guest. A guest write in the registered address will signal the 18758c2ecf20Sopenharmony_ciprovided event instead of triggering an exit. 18768c2ecf20Sopenharmony_ci 18778c2ecf20Sopenharmony_ci:: 18788c2ecf20Sopenharmony_ci 18798c2ecf20Sopenharmony_ci struct kvm_ioeventfd { 18808c2ecf20Sopenharmony_ci __u64 datamatch; 18818c2ecf20Sopenharmony_ci __u64 addr; /* legal pio/mmio address */ 18828c2ecf20Sopenharmony_ci __u32 len; /* 0, 1, 2, 4, or 8 bytes */ 18838c2ecf20Sopenharmony_ci __s32 fd; 18848c2ecf20Sopenharmony_ci __u32 flags; 18858c2ecf20Sopenharmony_ci __u8 pad[36]; 18868c2ecf20Sopenharmony_ci }; 18878c2ecf20Sopenharmony_ci 18888c2ecf20Sopenharmony_ciFor the special case of virtio-ccw devices on s390, the ioevent is matched 18898c2ecf20Sopenharmony_cito a subchannel/virtqueue tuple instead. 18908c2ecf20Sopenharmony_ci 18918c2ecf20Sopenharmony_ciThe following flags are defined:: 18928c2ecf20Sopenharmony_ci 18938c2ecf20Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 18948c2ecf20Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 18958c2ecf20Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 18968c2ecf20Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 18978c2ecf20Sopenharmony_ci (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 18988c2ecf20Sopenharmony_ci 18998c2ecf20Sopenharmony_ciIf datamatch flag is set, the event will be signaled only if the written value 19008c2ecf20Sopenharmony_cito the registered address is equal to datamatch in struct kvm_ioeventfd. 19018c2ecf20Sopenharmony_ci 19028c2ecf20Sopenharmony_ciFor virtio-ccw devices, addr contains the subchannel id and datamatch the 19038c2ecf20Sopenharmony_civirtqueue index. 19048c2ecf20Sopenharmony_ci 19058c2ecf20Sopenharmony_ciWith KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and 19068c2ecf20Sopenharmony_cithe kernel will ignore the length of guest write and may get a faster vmexit. 19078c2ecf20Sopenharmony_ciThe speedup may only apply to specific architectures, but the ioeventfd will 19088c2ecf20Sopenharmony_ciwork anyway. 19098c2ecf20Sopenharmony_ci 19108c2ecf20Sopenharmony_ci4.60 KVM_DIRTY_TLB 19118c2ecf20Sopenharmony_ci------------------ 19128c2ecf20Sopenharmony_ci 19138c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SW_TLB 19148c2ecf20Sopenharmony_ci:Architectures: ppc 19158c2ecf20Sopenharmony_ci:Type: vcpu ioctl 19168c2ecf20Sopenharmony_ci:Parameters: struct kvm_dirty_tlb (in) 19178c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 19188c2ecf20Sopenharmony_ci 19198c2ecf20Sopenharmony_ci:: 19208c2ecf20Sopenharmony_ci 19218c2ecf20Sopenharmony_ci struct kvm_dirty_tlb { 19228c2ecf20Sopenharmony_ci __u64 bitmap; 19238c2ecf20Sopenharmony_ci __u32 num_dirty; 19248c2ecf20Sopenharmony_ci }; 19258c2ecf20Sopenharmony_ci 19268c2ecf20Sopenharmony_ciThis must be called whenever userspace has changed an entry in the shared 19278c2ecf20Sopenharmony_ciTLB, prior to calling KVM_RUN on the associated vcpu. 19288c2ecf20Sopenharmony_ci 19298c2ecf20Sopenharmony_ciThe "bitmap" field is the userspace address of an array. This array 19308c2ecf20Sopenharmony_ciconsists of a number of bits, equal to the total number of TLB entries as 19318c2ecf20Sopenharmony_cidetermined by the last successful call to KVM_CONFIG_TLB, rounded up to the 19328c2ecf20Sopenharmony_cinearest multiple of 64. 19338c2ecf20Sopenharmony_ci 19348c2ecf20Sopenharmony_ciEach bit corresponds to one TLB entry, ordered the same as in the shared TLB 19358c2ecf20Sopenharmony_ciarray. 19368c2ecf20Sopenharmony_ci 19378c2ecf20Sopenharmony_ciThe array is little-endian: the bit 0 is the least significant bit of the 19388c2ecf20Sopenharmony_cifirst byte, bit 8 is the least significant bit of the second byte, etc. 19398c2ecf20Sopenharmony_ciThis avoids any complications with differing word sizes. 19408c2ecf20Sopenharmony_ci 19418c2ecf20Sopenharmony_ciThe "num_dirty" field is a performance hint for KVM to determine whether it 19428c2ecf20Sopenharmony_cishould skip processing the bitmap and just invalidate everything. It must 19438c2ecf20Sopenharmony_cibe set to the number of set bits in the bitmap. 19448c2ecf20Sopenharmony_ci 19458c2ecf20Sopenharmony_ci 19468c2ecf20Sopenharmony_ci4.62 KVM_CREATE_SPAPR_TCE 19478c2ecf20Sopenharmony_ci------------------------- 19488c2ecf20Sopenharmony_ci 19498c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SPAPR_TCE 19508c2ecf20Sopenharmony_ci:Architectures: powerpc 19518c2ecf20Sopenharmony_ci:Type: vm ioctl 19528c2ecf20Sopenharmony_ci:Parameters: struct kvm_create_spapr_tce (in) 19538c2ecf20Sopenharmony_ci:Returns: file descriptor for manipulating the created TCE table 19548c2ecf20Sopenharmony_ci 19558c2ecf20Sopenharmony_ciThis creates a virtual TCE (translation control entry) table, which 19568c2ecf20Sopenharmony_ciis an IOMMU for PAPR-style virtual I/O. It is used to translate 19578c2ecf20Sopenharmony_cilogical addresses used in virtual I/O into guest physical addresses, 19588c2ecf20Sopenharmony_ciand provides a scatter/gather capability for PAPR virtual I/O. 19598c2ecf20Sopenharmony_ci 19608c2ecf20Sopenharmony_ci:: 19618c2ecf20Sopenharmony_ci 19628c2ecf20Sopenharmony_ci /* for KVM_CAP_SPAPR_TCE */ 19638c2ecf20Sopenharmony_ci struct kvm_create_spapr_tce { 19648c2ecf20Sopenharmony_ci __u64 liobn; 19658c2ecf20Sopenharmony_ci __u32 window_size; 19668c2ecf20Sopenharmony_ci }; 19678c2ecf20Sopenharmony_ci 19688c2ecf20Sopenharmony_ciThe liobn field gives the logical IO bus number for which to create a 19698c2ecf20Sopenharmony_ciTCE table. The window_size field specifies the size of the DMA window 19708c2ecf20Sopenharmony_ciwhich this TCE table will translate - the table will contain one 64 19718c2ecf20Sopenharmony_cibit TCE entry for every 4kiB of the DMA window. 19728c2ecf20Sopenharmony_ci 19738c2ecf20Sopenharmony_ciWhen the guest issues an H_PUT_TCE hcall on a liobn for which a TCE 19748c2ecf20Sopenharmony_citable has been created using this ioctl(), the kernel will handle it 19758c2ecf20Sopenharmony_ciin real mode, updating the TCE table. H_PUT_TCE calls for other 19768c2ecf20Sopenharmony_ciliobns will cause a vm exit and must be handled by userspace. 19778c2ecf20Sopenharmony_ci 19788c2ecf20Sopenharmony_ciThe return value is a file descriptor which can be passed to mmap(2) 19798c2ecf20Sopenharmony_cito map the created TCE table into userspace. This lets userspace read 19808c2ecf20Sopenharmony_cithe entries written by kernel-handled H_PUT_TCE calls, and also lets 19818c2ecf20Sopenharmony_ciuserspace update the TCE table directly which is useful in some 19828c2ecf20Sopenharmony_cicircumstances. 19838c2ecf20Sopenharmony_ci 19848c2ecf20Sopenharmony_ci 19858c2ecf20Sopenharmony_ci4.63 KVM_ALLOCATE_RMA 19868c2ecf20Sopenharmony_ci--------------------- 19878c2ecf20Sopenharmony_ci 19888c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_RMA 19898c2ecf20Sopenharmony_ci:Architectures: powerpc 19908c2ecf20Sopenharmony_ci:Type: vm ioctl 19918c2ecf20Sopenharmony_ci:Parameters: struct kvm_allocate_rma (out) 19928c2ecf20Sopenharmony_ci:Returns: file descriptor for mapping the allocated RMA 19938c2ecf20Sopenharmony_ci 19948c2ecf20Sopenharmony_ciThis allocates a Real Mode Area (RMA) from the pool allocated at boot 19958c2ecf20Sopenharmony_citime by the kernel. An RMA is a physically-contiguous, aligned region 19968c2ecf20Sopenharmony_ciof memory used on older POWER processors to provide the memory which 19978c2ecf20Sopenharmony_ciwill be accessed by real-mode (MMU off) accesses in a KVM guest. 19988c2ecf20Sopenharmony_ciPOWER processors support a set of sizes for the RMA that usually 19998c2ecf20Sopenharmony_ciincludes 64MB, 128MB, 256MB and some larger powers of two. 20008c2ecf20Sopenharmony_ci 20018c2ecf20Sopenharmony_ci:: 20028c2ecf20Sopenharmony_ci 20038c2ecf20Sopenharmony_ci /* for KVM_ALLOCATE_RMA */ 20048c2ecf20Sopenharmony_ci struct kvm_allocate_rma { 20058c2ecf20Sopenharmony_ci __u64 rma_size; 20068c2ecf20Sopenharmony_ci }; 20078c2ecf20Sopenharmony_ci 20088c2ecf20Sopenharmony_ciThe return value is a file descriptor which can be passed to mmap(2) 20098c2ecf20Sopenharmony_cito map the allocated RMA into userspace. The mapped area can then be 20108c2ecf20Sopenharmony_cipassed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the 20118c2ecf20Sopenharmony_ciRMA for a virtual machine. The size of the RMA in bytes (which is 20128c2ecf20Sopenharmony_cifixed at host kernel boot time) is returned in the rma_size field of 20138c2ecf20Sopenharmony_cithe argument structure. 20148c2ecf20Sopenharmony_ci 20158c2ecf20Sopenharmony_ciThe KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl 20168c2ecf20Sopenharmony_ciis supported; 2 if the processor requires all virtual machines to have 20178c2ecf20Sopenharmony_cian RMA, or 1 if the processor can use an RMA but doesn't require it, 20188c2ecf20Sopenharmony_cibecause it supports the Virtual RMA (VRMA) facility. 20198c2ecf20Sopenharmony_ci 20208c2ecf20Sopenharmony_ci 20218c2ecf20Sopenharmony_ci4.64 KVM_NMI 20228c2ecf20Sopenharmony_ci------------ 20238c2ecf20Sopenharmony_ci 20248c2ecf20Sopenharmony_ci:Capability: KVM_CAP_USER_NMI 20258c2ecf20Sopenharmony_ci:Architectures: x86 20268c2ecf20Sopenharmony_ci:Type: vcpu ioctl 20278c2ecf20Sopenharmony_ci:Parameters: none 20288c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 20298c2ecf20Sopenharmony_ci 20308c2ecf20Sopenharmony_ciQueues an NMI on the thread's vcpu. Note this is well defined only 20318c2ecf20Sopenharmony_ciwhen KVM_CREATE_IRQCHIP has not been called, since this is an interface 20328c2ecf20Sopenharmony_cibetween the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP 20338c2ecf20Sopenharmony_cihas been called, this interface is completely emulated within the kernel. 20348c2ecf20Sopenharmony_ci 20358c2ecf20Sopenharmony_ciTo use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the 20368c2ecf20Sopenharmony_cifollowing algorithm: 20378c2ecf20Sopenharmony_ci 20388c2ecf20Sopenharmony_ci - pause the vcpu 20398c2ecf20Sopenharmony_ci - read the local APIC's state (KVM_GET_LAPIC) 20408c2ecf20Sopenharmony_ci - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1) 20418c2ecf20Sopenharmony_ci - if so, issue KVM_NMI 20428c2ecf20Sopenharmony_ci - resume the vcpu 20438c2ecf20Sopenharmony_ci 20448c2ecf20Sopenharmony_ciSome guests configure the LINT1 NMI input to cause a panic, aiding in 20458c2ecf20Sopenharmony_cidebugging. 20468c2ecf20Sopenharmony_ci 20478c2ecf20Sopenharmony_ci 20488c2ecf20Sopenharmony_ci4.65 KVM_S390_UCAS_MAP 20498c2ecf20Sopenharmony_ci---------------------- 20508c2ecf20Sopenharmony_ci 20518c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_UCONTROL 20528c2ecf20Sopenharmony_ci:Architectures: s390 20538c2ecf20Sopenharmony_ci:Type: vcpu ioctl 20548c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_ucas_mapping (in) 20558c2ecf20Sopenharmony_ci:Returns: 0 in case of success 20568c2ecf20Sopenharmony_ci 20578c2ecf20Sopenharmony_ciThe parameter is defined like this:: 20588c2ecf20Sopenharmony_ci 20598c2ecf20Sopenharmony_ci struct kvm_s390_ucas_mapping { 20608c2ecf20Sopenharmony_ci __u64 user_addr; 20618c2ecf20Sopenharmony_ci __u64 vcpu_addr; 20628c2ecf20Sopenharmony_ci __u64 length; 20638c2ecf20Sopenharmony_ci }; 20648c2ecf20Sopenharmony_ci 20658c2ecf20Sopenharmony_ciThis ioctl maps the memory at "user_addr" with the length "length" to 20668c2ecf20Sopenharmony_cithe vcpu's address space starting at "vcpu_addr". All parameters need to 20678c2ecf20Sopenharmony_cibe aligned by 1 megabyte. 20688c2ecf20Sopenharmony_ci 20698c2ecf20Sopenharmony_ci 20708c2ecf20Sopenharmony_ci4.66 KVM_S390_UCAS_UNMAP 20718c2ecf20Sopenharmony_ci------------------------ 20728c2ecf20Sopenharmony_ci 20738c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_UCONTROL 20748c2ecf20Sopenharmony_ci:Architectures: s390 20758c2ecf20Sopenharmony_ci:Type: vcpu ioctl 20768c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_ucas_mapping (in) 20778c2ecf20Sopenharmony_ci:Returns: 0 in case of success 20788c2ecf20Sopenharmony_ci 20798c2ecf20Sopenharmony_ciThe parameter is defined like this:: 20808c2ecf20Sopenharmony_ci 20818c2ecf20Sopenharmony_ci struct kvm_s390_ucas_mapping { 20828c2ecf20Sopenharmony_ci __u64 user_addr; 20838c2ecf20Sopenharmony_ci __u64 vcpu_addr; 20848c2ecf20Sopenharmony_ci __u64 length; 20858c2ecf20Sopenharmony_ci }; 20868c2ecf20Sopenharmony_ci 20878c2ecf20Sopenharmony_ciThis ioctl unmaps the memory in the vcpu's address space starting at 20888c2ecf20Sopenharmony_ci"vcpu_addr" with the length "length". The field "user_addr" is ignored. 20898c2ecf20Sopenharmony_ciAll parameters need to be aligned by 1 megabyte. 20908c2ecf20Sopenharmony_ci 20918c2ecf20Sopenharmony_ci 20928c2ecf20Sopenharmony_ci4.67 KVM_S390_VCPU_FAULT 20938c2ecf20Sopenharmony_ci------------------------ 20948c2ecf20Sopenharmony_ci 20958c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_UCONTROL 20968c2ecf20Sopenharmony_ci:Architectures: s390 20978c2ecf20Sopenharmony_ci:Type: vcpu ioctl 20988c2ecf20Sopenharmony_ci:Parameters: vcpu absolute address (in) 20998c2ecf20Sopenharmony_ci:Returns: 0 in case of success 21008c2ecf20Sopenharmony_ci 21018c2ecf20Sopenharmony_ciThis call creates a page table entry on the virtual cpu's address space 21028c2ecf20Sopenharmony_ci(for user controlled virtual machines) or the virtual machine's address 21038c2ecf20Sopenharmony_cispace (for regular virtual machines). This only works for minor faults, 21048c2ecf20Sopenharmony_cithus it's recommended to access subject memory page via the user page 21058c2ecf20Sopenharmony_citable upfront. This is useful to handle validity intercepts for user 21068c2ecf20Sopenharmony_cicontrolled virtual machines to fault in the virtual cpu's lowcore pages 21078c2ecf20Sopenharmony_ciprior to calling the KVM_RUN ioctl. 21088c2ecf20Sopenharmony_ci 21098c2ecf20Sopenharmony_ci 21108c2ecf20Sopenharmony_ci4.68 KVM_SET_ONE_REG 21118c2ecf20Sopenharmony_ci-------------------- 21128c2ecf20Sopenharmony_ci 21138c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ONE_REG 21148c2ecf20Sopenharmony_ci:Architectures: all 21158c2ecf20Sopenharmony_ci:Type: vcpu ioctl 21168c2ecf20Sopenharmony_ci:Parameters: struct kvm_one_reg (in) 21178c2ecf20Sopenharmony_ci:Returns: 0 on success, negative value on failure 21188c2ecf20Sopenharmony_ci 21198c2ecf20Sopenharmony_ciErrors: 21208c2ecf20Sopenharmony_ci 21218c2ecf20Sopenharmony_ci ====== ============================================================ 21228c2ecf20Sopenharmony_ci ENOENT no such register 21238c2ecf20Sopenharmony_ci EINVAL invalid register ID, or no such register or used with VMs in 21248c2ecf20Sopenharmony_ci protected virtualization mode on s390 21258c2ecf20Sopenharmony_ci EPERM (arm64) register access not allowed before vcpu finalization 21268c2ecf20Sopenharmony_ci ====== ============================================================ 21278c2ecf20Sopenharmony_ci 21288c2ecf20Sopenharmony_ci(These error codes are indicative only: do not rely on a specific error 21298c2ecf20Sopenharmony_cicode being returned in a specific situation.) 21308c2ecf20Sopenharmony_ci 21318c2ecf20Sopenharmony_ci:: 21328c2ecf20Sopenharmony_ci 21338c2ecf20Sopenharmony_ci struct kvm_one_reg { 21348c2ecf20Sopenharmony_ci __u64 id; 21358c2ecf20Sopenharmony_ci __u64 addr; 21368c2ecf20Sopenharmony_ci }; 21378c2ecf20Sopenharmony_ci 21388c2ecf20Sopenharmony_ciUsing this ioctl, a single vcpu register can be set to a specific value 21398c2ecf20Sopenharmony_cidefined by user space with the passed in struct kvm_one_reg, where id 21408c2ecf20Sopenharmony_cirefers to the register identifier as described below and addr is a pointer 21418c2ecf20Sopenharmony_cito a variable with the respective size. There can be architecture agnostic 21428c2ecf20Sopenharmony_ciand architecture specific registers. Each have their own range of operation 21438c2ecf20Sopenharmony_ciand their own constants and width. To keep track of the implemented 21448c2ecf20Sopenharmony_ciregisters, find a list below: 21458c2ecf20Sopenharmony_ci 21468c2ecf20Sopenharmony_ci ======= =============================== ============ 21478c2ecf20Sopenharmony_ci Arch Register Width (bits) 21488c2ecf20Sopenharmony_ci ======= =============================== ============ 21498c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_HIOR 64 21508c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_IAC1 64 21518c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_IAC2 64 21528c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_IAC3 64 21538c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_IAC4 64 21548c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DAC1 64 21558c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DAC2 64 21568c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DABR 64 21578c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DSCR 64 21588c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PURR 64 21598c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SPURR 64 21608c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DAR 64 21618c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DSISR 32 21628c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_AMR 64 21638c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_UAMOR 64 21648c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMCR0 64 21658c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMCR1 64 21668c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMCRA 64 21678c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMCR2 64 21688c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMCRS 64 21698c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMCR3 64 21708c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SIAR 64 21718c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SDAR 64 21728c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SIER 64 21738c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SIER2 64 21748c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SIER3 64 21758c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC1 32 21768c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC2 32 21778c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC3 32 21788c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC4 32 21798c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC5 32 21808c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC6 32 21818c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC7 32 21828c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PMC8 32 21838c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_FPR0 64 21848c2ecf20Sopenharmony_ci ... 21858c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_FPR31 64 21868c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VR0 128 21878c2ecf20Sopenharmony_ci ... 21888c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VR31 128 21898c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VSR0 128 21908c2ecf20Sopenharmony_ci ... 21918c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VSR31 128 21928c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_FPSCR 64 21938c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VSCR 32 21948c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VPA_ADDR 64 21958c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VPA_SLB 128 21968c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VPA_DTL 128 21978c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_EPCR 32 21988c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_EPR 32 21998c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TCR 32 22008c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TSR 32 22018c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_OR_TSR 32 22028c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_CLEAR_TSR 32 22038c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MAS0 32 22048c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MAS1 32 22058c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MAS2 64 22068c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MAS7_3 64 22078c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MAS4 32 22088c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MAS6 32 22098c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_MMUCFG 32 22108c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB0CFG 32 22118c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB1CFG 32 22128c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB2CFG 32 22138c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB3CFG 32 22148c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB0PS 32 22158c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB1PS 32 22168c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB2PS 32 22178c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TLB3PS 32 22188c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_EPTCFG 32 22198c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_ICP_STATE 64 22208c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VP_STATE 128 22218c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TB_OFFSET 64 22228c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SPMC1 32 22238c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SPMC2 32 22248c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_IAMR 64 22258c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TFHAR 64 22268c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TFIAR 64 22278c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TEXASR 64 22288c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_FSCR 64 22298c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PSPB 32 22308c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_EBBHR 64 22318c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_EBBRR 64 22328c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_BESCR 64 22338c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TAR 64 22348c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DPDES 64 22358c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DAWR 64 22368c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DAWRX 64 22378c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_CIABR 64 22388c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_IC 64 22398c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VTB 64 22408c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_CSIGR 64 22418c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TACR 64 22428c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TCSCR 64 22438c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PID 64 22448c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_ACOP 64 22458c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_VRSAVE 32 22468c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_LPCR 32 22478c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_LPCR_64 64 22488c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PPR 64 22498c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_ARCH_COMPAT 32 22508c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DABRX 32 22518c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_WORT 64 22528c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_SPRG9 64 22538c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DBSR 32 22548c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TIDR 64 22558c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PSSCR 64 22568c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_DEC_EXPIRY 64 22578c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_PTCR 64 22588c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_GPR0 64 22598c2ecf20Sopenharmony_ci ... 22608c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_GPR31 64 22618c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_VSR0 128 22628c2ecf20Sopenharmony_ci ... 22638c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_VSR63 128 22648c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_CR 64 22658c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_LR 64 22668c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_CTR 64 22678c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_FPSCR 64 22688c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_AMR 64 22698c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_PPR 64 22708c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_VRSAVE 64 22718c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_VSCR 32 22728c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_DSCR 64 22738c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_TAR 64 22748c2ecf20Sopenharmony_ci PPC KVM_REG_PPC_TM_XER 64 22758c2ecf20Sopenharmony_ci 22768c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_R0 64 22778c2ecf20Sopenharmony_ci ... 22788c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_R31 64 22798c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_HI 64 22808c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_LO 64 22818c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_PC 64 22828c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_INDEX 32 22838c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ENTRYLO0 64 22848c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ENTRYLO1 64 22858c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONTEXT 64 22868c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONTEXTCONFIG 32 22878c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_USERLOCAL 64 22888c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_XCONTEXTCONFIG 64 22898c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PAGEMASK 32 22908c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PAGEGRAIN 32 22918c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_SEGCTL0 64 22928c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_SEGCTL1 64 22938c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_SEGCTL2 64 22948c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWBASE 64 22958c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWFIELD 64 22968c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWSIZE 64 22978c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_WIRED 32 22988c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWCTL 32 22998c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_HWRENA 32 23008c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_BADVADDR 64 23018c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_BADINSTR 32 23028c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_BADINSTRP 32 23038c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_COUNT 32 23048c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ENTRYHI 64 23058c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_COMPARE 32 23068c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_STATUS 32 23078c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_INTCTL 32 23088c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CAUSE 32 23098c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_EPC 64 23108c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PRID 32 23118c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_EBASE 64 23128c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG 32 23138c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG1 32 23148c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG2 32 23158c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG3 32 23168c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG4 32 23178c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG5 32 23188c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG7 32 23198c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_XCONTEXT 64 23208c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ERROREPC 64 23218c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH1 64 23228c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH2 64 23238c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH3 64 23248c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH4 64 23258c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH5 64 23268c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH6 64 23278c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_MAAR(0..63) 64 23288c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_COUNT_CTL 64 23298c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_COUNT_RESUME 64 23308c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_COUNT_HZ 64 23318c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_FPR_32(0..31) 32 23328c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_FPR_64(0..31) 64 23338c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_VEC_128(0..31) 128 23348c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_FCR_IR 32 23358c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_FCR_CSR 32 23368c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_MSA_IR 32 23378c2ecf20Sopenharmony_ci MIPS KVM_REG_MIPS_MSA_CSR 32 23388c2ecf20Sopenharmony_ci ======= =============================== ============ 23398c2ecf20Sopenharmony_ci 23408c2ecf20Sopenharmony_ciARM registers are mapped using the lower 32 bits. The upper 16 of that 23418c2ecf20Sopenharmony_ciis the register group type, or coprocessor number: 23428c2ecf20Sopenharmony_ci 23438c2ecf20Sopenharmony_ciARM core registers have the following id bit patterns:: 23448c2ecf20Sopenharmony_ci 23458c2ecf20Sopenharmony_ci 0x4020 0000 0010 <index into the kvm_regs struct:16> 23468c2ecf20Sopenharmony_ci 23478c2ecf20Sopenharmony_ciARM 32-bit CP15 registers have the following id bit patterns:: 23488c2ecf20Sopenharmony_ci 23498c2ecf20Sopenharmony_ci 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3> 23508c2ecf20Sopenharmony_ci 23518c2ecf20Sopenharmony_ciARM 64-bit CP15 registers have the following id bit patterns:: 23528c2ecf20Sopenharmony_ci 23538c2ecf20Sopenharmony_ci 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3> 23548c2ecf20Sopenharmony_ci 23558c2ecf20Sopenharmony_ciARM CCSIDR registers are demultiplexed by CSSELR value:: 23568c2ecf20Sopenharmony_ci 23578c2ecf20Sopenharmony_ci 0x4020 0000 0011 00 <csselr:8> 23588c2ecf20Sopenharmony_ci 23598c2ecf20Sopenharmony_ciARM 32-bit VFP control registers have the following id bit patterns:: 23608c2ecf20Sopenharmony_ci 23618c2ecf20Sopenharmony_ci 0x4020 0000 0012 1 <regno:12> 23628c2ecf20Sopenharmony_ci 23638c2ecf20Sopenharmony_ciARM 64-bit FP registers have the following id bit patterns:: 23648c2ecf20Sopenharmony_ci 23658c2ecf20Sopenharmony_ci 0x4030 0000 0012 0 <regno:12> 23668c2ecf20Sopenharmony_ci 23678c2ecf20Sopenharmony_ciARM firmware pseudo-registers have the following bit pattern:: 23688c2ecf20Sopenharmony_ci 23698c2ecf20Sopenharmony_ci 0x4030 0000 0014 <regno:16> 23708c2ecf20Sopenharmony_ci 23718c2ecf20Sopenharmony_ci 23728c2ecf20Sopenharmony_ciarm64 registers are mapped using the lower 32 bits. The upper 16 of 23738c2ecf20Sopenharmony_cithat is the register group type, or coprocessor number: 23748c2ecf20Sopenharmony_ci 23758c2ecf20Sopenharmony_ciarm64 core/FP-SIMD registers have the following id bit patterns. Note 23768c2ecf20Sopenharmony_cithat the size of the access is variable, as the kvm_regs structure 23778c2ecf20Sopenharmony_cicontains elements ranging from 32 to 128 bits. The index is a 32bit 23788c2ecf20Sopenharmony_civalue in the kvm_regs structure seen as a 32bit array:: 23798c2ecf20Sopenharmony_ci 23808c2ecf20Sopenharmony_ci 0x60x0 0000 0010 <index into the kvm_regs struct:16> 23818c2ecf20Sopenharmony_ci 23828c2ecf20Sopenharmony_ciSpecifically: 23838c2ecf20Sopenharmony_ci 23848c2ecf20Sopenharmony_ci======================= ========= ===== ======================================= 23858c2ecf20Sopenharmony_ci Encoding Register Bits kvm_regs member 23868c2ecf20Sopenharmony_ci======================= ========= ===== ======================================= 23878c2ecf20Sopenharmony_ci 0x6030 0000 0010 0000 X0 64 regs.regs[0] 23888c2ecf20Sopenharmony_ci 0x6030 0000 0010 0002 X1 64 regs.regs[1] 23898c2ecf20Sopenharmony_ci ... 23908c2ecf20Sopenharmony_ci 0x6030 0000 0010 003c X30 64 regs.regs[30] 23918c2ecf20Sopenharmony_ci 0x6030 0000 0010 003e SP 64 regs.sp 23928c2ecf20Sopenharmony_ci 0x6030 0000 0010 0040 PC 64 regs.pc 23938c2ecf20Sopenharmony_ci 0x6030 0000 0010 0042 PSTATE 64 regs.pstate 23948c2ecf20Sopenharmony_ci 0x6030 0000 0010 0044 SP_EL1 64 sp_el1 23958c2ecf20Sopenharmony_ci 0x6030 0000 0010 0046 ELR_EL1 64 elr_el1 23968c2ecf20Sopenharmony_ci 0x6030 0000 0010 0048 SPSR_EL1 64 spsr[KVM_SPSR_EL1] (alias SPSR_SVC) 23978c2ecf20Sopenharmony_ci 0x6030 0000 0010 004a SPSR_ABT 64 spsr[KVM_SPSR_ABT] 23988c2ecf20Sopenharmony_ci 0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND] 23998c2ecf20Sopenharmony_ci 0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ] 24008c2ecf20Sopenharmony_ci 0x6060 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ] 24018c2ecf20Sopenharmony_ci 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] [1]_ 24028c2ecf20Sopenharmony_ci 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] [1]_ 24038c2ecf20Sopenharmony_ci ... 24048c2ecf20Sopenharmony_ci 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31] [1]_ 24058c2ecf20Sopenharmony_ci 0x6020 0000 0010 00d4 FPSR 32 fp_regs.fpsr 24068c2ecf20Sopenharmony_ci 0x6020 0000 0010 00d5 FPCR 32 fp_regs.fpcr 24078c2ecf20Sopenharmony_ci======================= ========= ===== ======================================= 24088c2ecf20Sopenharmony_ci 24098c2ecf20Sopenharmony_ci.. [1] These encodings are not accepted for SVE-enabled vcpus. See 24108c2ecf20Sopenharmony_ci KVM_ARM_VCPU_INIT. 24118c2ecf20Sopenharmony_ci 24128c2ecf20Sopenharmony_ci The equivalent register content can be accessed via bits [127:0] of 24138c2ecf20Sopenharmony_ci the corresponding SVE Zn registers instead for vcpus that have SVE 24148c2ecf20Sopenharmony_ci enabled (see below). 24158c2ecf20Sopenharmony_ci 24168c2ecf20Sopenharmony_ciarm64 CCSIDR registers are demultiplexed by CSSELR value:: 24178c2ecf20Sopenharmony_ci 24188c2ecf20Sopenharmony_ci 0x6020 0000 0011 00 <csselr:8> 24198c2ecf20Sopenharmony_ci 24208c2ecf20Sopenharmony_ciarm64 system registers have the following id bit patterns:: 24218c2ecf20Sopenharmony_ci 24228c2ecf20Sopenharmony_ci 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3> 24238c2ecf20Sopenharmony_ci 24248c2ecf20Sopenharmony_ci.. warning:: 24258c2ecf20Sopenharmony_ci 24268c2ecf20Sopenharmony_ci Two system register IDs do not follow the specified pattern. These 24278c2ecf20Sopenharmony_ci are KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT, which map to 24288c2ecf20Sopenharmony_ci system registers CNTV_CVAL_EL0 and CNTVCT_EL0 respectively. These 24298c2ecf20Sopenharmony_ci two had their values accidentally swapped, which means TIMER_CVAL is 24308c2ecf20Sopenharmony_ci derived from the register encoding for CNTVCT_EL0 and TIMER_CNT is 24318c2ecf20Sopenharmony_ci derived from the register encoding for CNTV_CVAL_EL0. As this is 24328c2ecf20Sopenharmony_ci API, it must remain this way. 24338c2ecf20Sopenharmony_ci 24348c2ecf20Sopenharmony_ciarm64 firmware pseudo-registers have the following bit pattern:: 24358c2ecf20Sopenharmony_ci 24368c2ecf20Sopenharmony_ci 0x6030 0000 0014 <regno:16> 24378c2ecf20Sopenharmony_ci 24388c2ecf20Sopenharmony_ciarm64 SVE registers have the following bit patterns:: 24398c2ecf20Sopenharmony_ci 24408c2ecf20Sopenharmony_ci 0x6080 0000 0015 00 <n:5> <slice:5> Zn bits[2048*slice + 2047 : 2048*slice] 24418c2ecf20Sopenharmony_ci 0x6050 0000 0015 04 <n:4> <slice:5> Pn bits[256*slice + 255 : 256*slice] 24428c2ecf20Sopenharmony_ci 0x6050 0000 0015 060 <slice:5> FFR bits[256*slice + 255 : 256*slice] 24438c2ecf20Sopenharmony_ci 0x6060 0000 0015 ffff KVM_REG_ARM64_SVE_VLS pseudo-register 24448c2ecf20Sopenharmony_ci 24458c2ecf20Sopenharmony_ciAccess to register IDs where 2048 * slice >= 128 * max_vq will fail with 24468c2ecf20Sopenharmony_ciENOENT. max_vq is the vcpu's maximum supported vector length in 128-bit 24478c2ecf20Sopenharmony_ciquadwords: see [2]_ below. 24488c2ecf20Sopenharmony_ci 24498c2ecf20Sopenharmony_ciThese registers are only accessible on vcpus for which SVE is enabled. 24508c2ecf20Sopenharmony_ciSee KVM_ARM_VCPU_INIT for details. 24518c2ecf20Sopenharmony_ci 24528c2ecf20Sopenharmony_ciIn addition, except for KVM_REG_ARM64_SVE_VLS, these registers are not 24538c2ecf20Sopenharmony_ciaccessible until the vcpu's SVE configuration has been finalized 24548c2ecf20Sopenharmony_ciusing KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). See KVM_ARM_VCPU_INIT 24558c2ecf20Sopenharmony_ciand KVM_ARM_VCPU_FINALIZE for more information about this procedure. 24568c2ecf20Sopenharmony_ci 24578c2ecf20Sopenharmony_ciKVM_REG_ARM64_SVE_VLS is a pseudo-register that allows the set of vector 24588c2ecf20Sopenharmony_cilengths supported by the vcpu to be discovered and configured by 24598c2ecf20Sopenharmony_ciuserspace. When transferred to or from user memory via KVM_GET_ONE_REG 24608c2ecf20Sopenharmony_cior KVM_SET_ONE_REG, the value of this register is of type 24618c2ecf20Sopenharmony_ci__u64[KVM_ARM64_SVE_VLS_WORDS], and encodes the set of vector lengths as 24628c2ecf20Sopenharmony_cifollows:: 24638c2ecf20Sopenharmony_ci 24648c2ecf20Sopenharmony_ci __u64 vector_lengths[KVM_ARM64_SVE_VLS_WORDS]; 24658c2ecf20Sopenharmony_ci 24668c2ecf20Sopenharmony_ci if (vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX && 24678c2ecf20Sopenharmony_ci ((vector_lengths[(vq - KVM_ARM64_SVE_VQ_MIN) / 64] >> 24688c2ecf20Sopenharmony_ci ((vq - KVM_ARM64_SVE_VQ_MIN) % 64)) & 1)) 24698c2ecf20Sopenharmony_ci /* Vector length vq * 16 bytes supported */ 24708c2ecf20Sopenharmony_ci else 24718c2ecf20Sopenharmony_ci /* Vector length vq * 16 bytes not supported */ 24728c2ecf20Sopenharmony_ci 24738c2ecf20Sopenharmony_ci.. [2] The maximum value vq for which the above condition is true is 24748c2ecf20Sopenharmony_ci max_vq. This is the maximum vector length available to the guest on 24758c2ecf20Sopenharmony_ci this vcpu, and determines which register slices are visible through 24768c2ecf20Sopenharmony_ci this ioctl interface. 24778c2ecf20Sopenharmony_ci 24788c2ecf20Sopenharmony_ci(See Documentation/arm64/sve.rst for an explanation of the "vq" 24798c2ecf20Sopenharmony_cinomenclature.) 24808c2ecf20Sopenharmony_ci 24818c2ecf20Sopenharmony_ciKVM_REG_ARM64_SVE_VLS is only accessible after KVM_ARM_VCPU_INIT. 24828c2ecf20Sopenharmony_ciKVM_ARM_VCPU_INIT initialises it to the best set of vector lengths that 24838c2ecf20Sopenharmony_cithe host supports. 24848c2ecf20Sopenharmony_ci 24858c2ecf20Sopenharmony_ciUserspace may subsequently modify it if desired until the vcpu's SVE 24868c2ecf20Sopenharmony_ciconfiguration is finalized using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). 24878c2ecf20Sopenharmony_ci 24888c2ecf20Sopenharmony_ciApart from simply removing all vector lengths from the host set that 24898c2ecf20Sopenharmony_ciexceed some value, support for arbitrarily chosen sets of vector lengths 24908c2ecf20Sopenharmony_ciis hardware-dependent and may not be available. Attempting to configure 24918c2ecf20Sopenharmony_cian invalid set of vector lengths via KVM_SET_ONE_REG will fail with 24928c2ecf20Sopenharmony_ciEINVAL. 24938c2ecf20Sopenharmony_ci 24948c2ecf20Sopenharmony_ciAfter the vcpu's SVE configuration is finalized, further attempts to 24958c2ecf20Sopenharmony_ciwrite this register will fail with EPERM. 24968c2ecf20Sopenharmony_ci 24978c2ecf20Sopenharmony_ci 24988c2ecf20Sopenharmony_ciMIPS registers are mapped using the lower 32 bits. The upper 16 of that is 24998c2ecf20Sopenharmony_cithe register group type: 25008c2ecf20Sopenharmony_ci 25018c2ecf20Sopenharmony_ciMIPS core registers (see above) have the following id bit patterns:: 25028c2ecf20Sopenharmony_ci 25038c2ecf20Sopenharmony_ci 0x7030 0000 0000 <reg:16> 25048c2ecf20Sopenharmony_ci 25058c2ecf20Sopenharmony_ciMIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit 25068c2ecf20Sopenharmony_cipatterns depending on whether they're 32-bit or 64-bit registers:: 25078c2ecf20Sopenharmony_ci 25088c2ecf20Sopenharmony_ci 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit) 25098c2ecf20Sopenharmony_ci 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit) 25108c2ecf20Sopenharmony_ci 25118c2ecf20Sopenharmony_ciNote: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64 25128c2ecf20Sopenharmony_civersions of the EntryLo registers regardless of the word size of the host 25138c2ecf20Sopenharmony_cihardware, host kernel, guest, and whether XPA is present in the guest, i.e. 25148c2ecf20Sopenharmony_ciwith the RI and XI bits (if they exist) in bits 63 and 62 respectively, and 25158c2ecf20Sopenharmony_cithe PFNX field starting at bit 30. 25168c2ecf20Sopenharmony_ci 25178c2ecf20Sopenharmony_ciMIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit 25188c2ecf20Sopenharmony_cipatterns:: 25198c2ecf20Sopenharmony_ci 25208c2ecf20Sopenharmony_ci 0x7030 0000 0001 01 <reg:8> 25218c2ecf20Sopenharmony_ci 25228c2ecf20Sopenharmony_ciMIPS KVM control registers (see above) have the following id bit patterns:: 25238c2ecf20Sopenharmony_ci 25248c2ecf20Sopenharmony_ci 0x7030 0000 0002 <reg:16> 25258c2ecf20Sopenharmony_ci 25268c2ecf20Sopenharmony_ciMIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following 25278c2ecf20Sopenharmony_ciid bit patterns depending on the size of the register being accessed. They are 25288c2ecf20Sopenharmony_cialways accessed according to the current guest FPU mode (Status.FR and 25298c2ecf20Sopenharmony_ciConfig5.FRE), i.e. as the guest would see them, and they become unpredictable 25308c2ecf20Sopenharmony_ciif the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector 25318c2ecf20Sopenharmony_ciregisters (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they 25328c2ecf20Sopenharmony_cioverlap the FPU registers:: 25338c2ecf20Sopenharmony_ci 25348c2ecf20Sopenharmony_ci 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers) 25358c2ecf20Sopenharmony_ci 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers) 25368c2ecf20Sopenharmony_ci 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers) 25378c2ecf20Sopenharmony_ci 25388c2ecf20Sopenharmony_ciMIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the 25398c2ecf20Sopenharmony_cifollowing id bit patterns:: 25408c2ecf20Sopenharmony_ci 25418c2ecf20Sopenharmony_ci 0x7020 0000 0003 01 <0:3> <reg:5> 25428c2ecf20Sopenharmony_ci 25438c2ecf20Sopenharmony_ciMIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the 25448c2ecf20Sopenharmony_cifollowing id bit patterns:: 25458c2ecf20Sopenharmony_ci 25468c2ecf20Sopenharmony_ci 0x7020 0000 0003 02 <0:3> <reg:5> 25478c2ecf20Sopenharmony_ci 25488c2ecf20Sopenharmony_ci 25498c2ecf20Sopenharmony_ci4.69 KVM_GET_ONE_REG 25508c2ecf20Sopenharmony_ci-------------------- 25518c2ecf20Sopenharmony_ci 25528c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ONE_REG 25538c2ecf20Sopenharmony_ci:Architectures: all 25548c2ecf20Sopenharmony_ci:Type: vcpu ioctl 25558c2ecf20Sopenharmony_ci:Parameters: struct kvm_one_reg (in and out) 25568c2ecf20Sopenharmony_ci:Returns: 0 on success, negative value on failure 25578c2ecf20Sopenharmony_ci 25588c2ecf20Sopenharmony_ciErrors include: 25598c2ecf20Sopenharmony_ci 25608c2ecf20Sopenharmony_ci ======== ============================================================ 25618c2ecf20Sopenharmony_ci ENOENT no such register 25628c2ecf20Sopenharmony_ci EINVAL invalid register ID, or no such register or used with VMs in 25638c2ecf20Sopenharmony_ci protected virtualization mode on s390 25648c2ecf20Sopenharmony_ci EPERM (arm64) register access not allowed before vcpu finalization 25658c2ecf20Sopenharmony_ci ======== ============================================================ 25668c2ecf20Sopenharmony_ci 25678c2ecf20Sopenharmony_ci(These error codes are indicative only: do not rely on a specific error 25688c2ecf20Sopenharmony_cicode being returned in a specific situation.) 25698c2ecf20Sopenharmony_ci 25708c2ecf20Sopenharmony_ciThis ioctl allows to receive the value of a single register implemented 25718c2ecf20Sopenharmony_ciin a vcpu. The register to read is indicated by the "id" field of the 25728c2ecf20Sopenharmony_cikvm_one_reg struct passed in. On success, the register value can be found 25738c2ecf20Sopenharmony_ciat the memory location pointed to by "addr". 25748c2ecf20Sopenharmony_ci 25758c2ecf20Sopenharmony_ciThe list of registers accessible using this interface is identical to the 25768c2ecf20Sopenharmony_cilist in 4.68. 25778c2ecf20Sopenharmony_ci 25788c2ecf20Sopenharmony_ci 25798c2ecf20Sopenharmony_ci4.70 KVM_KVMCLOCK_CTRL 25808c2ecf20Sopenharmony_ci---------------------- 25818c2ecf20Sopenharmony_ci 25828c2ecf20Sopenharmony_ci:Capability: KVM_CAP_KVMCLOCK_CTRL 25838c2ecf20Sopenharmony_ci:Architectures: Any that implement pvclocks (currently x86 only) 25848c2ecf20Sopenharmony_ci:Type: vcpu ioctl 25858c2ecf20Sopenharmony_ci:Parameters: None 25868c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 25878c2ecf20Sopenharmony_ci 25888c2ecf20Sopenharmony_ciThis ioctl sets a flag accessible to the guest indicating that the specified 25898c2ecf20Sopenharmony_civCPU has been paused by the host userspace. 25908c2ecf20Sopenharmony_ci 25918c2ecf20Sopenharmony_ciThe host will set a flag in the pvclock structure that is checked from the 25928c2ecf20Sopenharmony_cisoft lockup watchdog. The flag is part of the pvclock structure that is 25938c2ecf20Sopenharmony_cishared between guest and host, specifically the second bit of the flags 25948c2ecf20Sopenharmony_cifield of the pvclock_vcpu_time_info structure. It will be set exclusively by 25958c2ecf20Sopenharmony_cithe host and read/cleared exclusively by the guest. The guest operation of 25968c2ecf20Sopenharmony_cichecking and clearing the flag must be an atomic operation so 25978c2ecf20Sopenharmony_ciload-link/store-conditional, or equivalent must be used. There are two cases 25988c2ecf20Sopenharmony_ciwhere the guest will clear the flag: when the soft lockup watchdog timer resets 25998c2ecf20Sopenharmony_ciitself or when a soft lockup is detected. This ioctl can be called any time 26008c2ecf20Sopenharmony_ciafter pausing the vcpu, but before it is resumed. 26018c2ecf20Sopenharmony_ci 26028c2ecf20Sopenharmony_ci 26038c2ecf20Sopenharmony_ci4.71 KVM_SIGNAL_MSI 26048c2ecf20Sopenharmony_ci------------------- 26058c2ecf20Sopenharmony_ci 26068c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SIGNAL_MSI 26078c2ecf20Sopenharmony_ci:Architectures: x86 arm arm64 26088c2ecf20Sopenharmony_ci:Type: vm ioctl 26098c2ecf20Sopenharmony_ci:Parameters: struct kvm_msi (in) 26108c2ecf20Sopenharmony_ci:Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error 26118c2ecf20Sopenharmony_ci 26128c2ecf20Sopenharmony_ciDirectly inject a MSI message. Only valid with in-kernel irqchip that handles 26138c2ecf20Sopenharmony_ciMSI messages. 26148c2ecf20Sopenharmony_ci 26158c2ecf20Sopenharmony_ci:: 26168c2ecf20Sopenharmony_ci 26178c2ecf20Sopenharmony_ci struct kvm_msi { 26188c2ecf20Sopenharmony_ci __u32 address_lo; 26198c2ecf20Sopenharmony_ci __u32 address_hi; 26208c2ecf20Sopenharmony_ci __u32 data; 26218c2ecf20Sopenharmony_ci __u32 flags; 26228c2ecf20Sopenharmony_ci __u32 devid; 26238c2ecf20Sopenharmony_ci __u8 pad[12]; 26248c2ecf20Sopenharmony_ci }; 26258c2ecf20Sopenharmony_ci 26268c2ecf20Sopenharmony_ciflags: 26278c2ecf20Sopenharmony_ci KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM 26288c2ecf20Sopenharmony_ci KVM_CAP_MSI_DEVID capability advertises the requirement to provide 26298c2ecf20Sopenharmony_ci the device ID. If this capability is not available, userspace 26308c2ecf20Sopenharmony_ci should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. 26318c2ecf20Sopenharmony_ci 26328c2ecf20Sopenharmony_ciIf KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier 26338c2ecf20Sopenharmony_cifor the device that wrote the MSI message. For PCI, this is usually a 26348c2ecf20Sopenharmony_ciBFD identifier in the lower 16 bits. 26358c2ecf20Sopenharmony_ci 26368c2ecf20Sopenharmony_ciOn x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS 26378c2ecf20Sopenharmony_cifeature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, 26388c2ecf20Sopenharmony_ciaddress_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of 26398c2ecf20Sopenharmony_ciaddress_hi must be zero. 26408c2ecf20Sopenharmony_ci 26418c2ecf20Sopenharmony_ci 26428c2ecf20Sopenharmony_ci4.71 KVM_CREATE_PIT2 26438c2ecf20Sopenharmony_ci-------------------- 26448c2ecf20Sopenharmony_ci 26458c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PIT2 26468c2ecf20Sopenharmony_ci:Architectures: x86 26478c2ecf20Sopenharmony_ci:Type: vm ioctl 26488c2ecf20Sopenharmony_ci:Parameters: struct kvm_pit_config (in) 26498c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 26508c2ecf20Sopenharmony_ci 26518c2ecf20Sopenharmony_ciCreates an in-kernel device model for the i8254 PIT. This call is only valid 26528c2ecf20Sopenharmony_ciafter enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following 26538c2ecf20Sopenharmony_ciparameters have to be passed:: 26548c2ecf20Sopenharmony_ci 26558c2ecf20Sopenharmony_ci struct kvm_pit_config { 26568c2ecf20Sopenharmony_ci __u32 flags; 26578c2ecf20Sopenharmony_ci __u32 pad[15]; 26588c2ecf20Sopenharmony_ci }; 26598c2ecf20Sopenharmony_ci 26608c2ecf20Sopenharmony_ciValid flags are:: 26618c2ecf20Sopenharmony_ci 26628c2ecf20Sopenharmony_ci #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */ 26638c2ecf20Sopenharmony_ci 26648c2ecf20Sopenharmony_ciPIT timer interrupts may use a per-VM kernel thread for injection. If it 26658c2ecf20Sopenharmony_ciexists, this thread will have a name of the following pattern:: 26668c2ecf20Sopenharmony_ci 26678c2ecf20Sopenharmony_ci kvm-pit/<owner-process-pid> 26688c2ecf20Sopenharmony_ci 26698c2ecf20Sopenharmony_ciWhen running a guest with elevated priorities, the scheduling parameters of 26708c2ecf20Sopenharmony_cithis thread may have to be adjusted accordingly. 26718c2ecf20Sopenharmony_ci 26728c2ecf20Sopenharmony_ciThis IOCTL replaces the obsolete KVM_CREATE_PIT. 26738c2ecf20Sopenharmony_ci 26748c2ecf20Sopenharmony_ci 26758c2ecf20Sopenharmony_ci4.72 KVM_GET_PIT2 26768c2ecf20Sopenharmony_ci----------------- 26778c2ecf20Sopenharmony_ci 26788c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PIT_STATE2 26798c2ecf20Sopenharmony_ci:Architectures: x86 26808c2ecf20Sopenharmony_ci:Type: vm ioctl 26818c2ecf20Sopenharmony_ci:Parameters: struct kvm_pit_state2 (out) 26828c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 26838c2ecf20Sopenharmony_ci 26848c2ecf20Sopenharmony_ciRetrieves the state of the in-kernel PIT model. Only valid after 26858c2ecf20Sopenharmony_ciKVM_CREATE_PIT2. The state is returned in the following structure:: 26868c2ecf20Sopenharmony_ci 26878c2ecf20Sopenharmony_ci struct kvm_pit_state2 { 26888c2ecf20Sopenharmony_ci struct kvm_pit_channel_state channels[3]; 26898c2ecf20Sopenharmony_ci __u32 flags; 26908c2ecf20Sopenharmony_ci __u32 reserved[9]; 26918c2ecf20Sopenharmony_ci }; 26928c2ecf20Sopenharmony_ci 26938c2ecf20Sopenharmony_ciValid flags are:: 26948c2ecf20Sopenharmony_ci 26958c2ecf20Sopenharmony_ci /* disable PIT in HPET legacy mode */ 26968c2ecf20Sopenharmony_ci #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 26978c2ecf20Sopenharmony_ci 26988c2ecf20Sopenharmony_ciThis IOCTL replaces the obsolete KVM_GET_PIT. 26998c2ecf20Sopenharmony_ci 27008c2ecf20Sopenharmony_ci 27018c2ecf20Sopenharmony_ci4.73 KVM_SET_PIT2 27028c2ecf20Sopenharmony_ci----------------- 27038c2ecf20Sopenharmony_ci 27048c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PIT_STATE2 27058c2ecf20Sopenharmony_ci:Architectures: x86 27068c2ecf20Sopenharmony_ci:Type: vm ioctl 27078c2ecf20Sopenharmony_ci:Parameters: struct kvm_pit_state2 (in) 27088c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 27098c2ecf20Sopenharmony_ci 27108c2ecf20Sopenharmony_ciSets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2. 27118c2ecf20Sopenharmony_ciSee KVM_GET_PIT2 for details on struct kvm_pit_state2. 27128c2ecf20Sopenharmony_ci 27138c2ecf20Sopenharmony_ciThis IOCTL replaces the obsolete KVM_SET_PIT. 27148c2ecf20Sopenharmony_ci 27158c2ecf20Sopenharmony_ci 27168c2ecf20Sopenharmony_ci4.74 KVM_PPC_GET_SMMU_INFO 27178c2ecf20Sopenharmony_ci-------------------------- 27188c2ecf20Sopenharmony_ci 27198c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_GET_SMMU_INFO 27208c2ecf20Sopenharmony_ci:Architectures: powerpc 27218c2ecf20Sopenharmony_ci:Type: vm ioctl 27228c2ecf20Sopenharmony_ci:Parameters: None 27238c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 27248c2ecf20Sopenharmony_ci 27258c2ecf20Sopenharmony_ciThis populates and returns a structure describing the features of 27268c2ecf20Sopenharmony_cithe "Server" class MMU emulation supported by KVM. 27278c2ecf20Sopenharmony_ciThis can in turn be used by userspace to generate the appropriate 27288c2ecf20Sopenharmony_cidevice-tree properties for the guest operating system. 27298c2ecf20Sopenharmony_ci 27308c2ecf20Sopenharmony_ciThe structure contains some global information, followed by an 27318c2ecf20Sopenharmony_ciarray of supported segment page sizes:: 27328c2ecf20Sopenharmony_ci 27338c2ecf20Sopenharmony_ci struct kvm_ppc_smmu_info { 27348c2ecf20Sopenharmony_ci __u64 flags; 27358c2ecf20Sopenharmony_ci __u32 slb_size; 27368c2ecf20Sopenharmony_ci __u32 pad; 27378c2ecf20Sopenharmony_ci struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 27388c2ecf20Sopenharmony_ci }; 27398c2ecf20Sopenharmony_ci 27408c2ecf20Sopenharmony_ciThe supported flags are: 27418c2ecf20Sopenharmony_ci 27428c2ecf20Sopenharmony_ci - KVM_PPC_PAGE_SIZES_REAL: 27438c2ecf20Sopenharmony_ci When that flag is set, guest page sizes must "fit" the backing 27448c2ecf20Sopenharmony_ci store page sizes. When not set, any page size in the list can 27458c2ecf20Sopenharmony_ci be used regardless of how they are backed by userspace. 27468c2ecf20Sopenharmony_ci 27478c2ecf20Sopenharmony_ci - KVM_PPC_1T_SEGMENTS 27488c2ecf20Sopenharmony_ci The emulated MMU supports 1T segments in addition to the 27498c2ecf20Sopenharmony_ci standard 256M ones. 27508c2ecf20Sopenharmony_ci 27518c2ecf20Sopenharmony_ci - KVM_PPC_NO_HASH 27528c2ecf20Sopenharmony_ci This flag indicates that HPT guests are not supported by KVM, 27538c2ecf20Sopenharmony_ci thus all guests must use radix MMU mode. 27548c2ecf20Sopenharmony_ci 27558c2ecf20Sopenharmony_ciThe "slb_size" field indicates how many SLB entries are supported 27568c2ecf20Sopenharmony_ci 27578c2ecf20Sopenharmony_ciThe "sps" array contains 8 entries indicating the supported base 27588c2ecf20Sopenharmony_cipage sizes for a segment in increasing order. Each entry is defined 27598c2ecf20Sopenharmony_cias follow:: 27608c2ecf20Sopenharmony_ci 27618c2ecf20Sopenharmony_ci struct kvm_ppc_one_seg_page_size { 27628c2ecf20Sopenharmony_ci __u32 page_shift; /* Base page shift of segment (or 0) */ 27638c2ecf20Sopenharmony_ci __u32 slb_enc; /* SLB encoding for BookS */ 27648c2ecf20Sopenharmony_ci struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 27658c2ecf20Sopenharmony_ci }; 27668c2ecf20Sopenharmony_ci 27678c2ecf20Sopenharmony_ciAn entry with a "page_shift" of 0 is unused. Because the array is 27688c2ecf20Sopenharmony_ciorganized in increasing order, a lookup can stop when encoutering 27698c2ecf20Sopenharmony_cisuch an entry. 27708c2ecf20Sopenharmony_ci 27718c2ecf20Sopenharmony_ciThe "slb_enc" field provides the encoding to use in the SLB for the 27728c2ecf20Sopenharmony_cipage size. The bits are in positions such as the value can directly 27738c2ecf20Sopenharmony_cibe OR'ed into the "vsid" argument of the slbmte instruction. 27748c2ecf20Sopenharmony_ci 27758c2ecf20Sopenharmony_ciThe "enc" array is a list which for each of those segment base page 27768c2ecf20Sopenharmony_cisize provides the list of supported actual page sizes (which can be 27778c2ecf20Sopenharmony_cionly larger or equal to the base page size), along with the 27788c2ecf20Sopenharmony_cicorresponding encoding in the hash PTE. Similarly, the array is 27798c2ecf20Sopenharmony_ci8 entries sorted by increasing sizes and an entry with a "0" shift 27808c2ecf20Sopenharmony_ciis an empty entry and a terminator:: 27818c2ecf20Sopenharmony_ci 27828c2ecf20Sopenharmony_ci struct kvm_ppc_one_page_size { 27838c2ecf20Sopenharmony_ci __u32 page_shift; /* Page shift (or 0) */ 27848c2ecf20Sopenharmony_ci __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 27858c2ecf20Sopenharmony_ci }; 27868c2ecf20Sopenharmony_ci 27878c2ecf20Sopenharmony_ciThe "pte_enc" field provides a value that can OR'ed into the hash 27888c2ecf20Sopenharmony_ciPTE's RPN field (ie, it needs to be shifted left by 12 to OR it 27898c2ecf20Sopenharmony_ciinto the hash PTE second double word). 27908c2ecf20Sopenharmony_ci 27918c2ecf20Sopenharmony_ci4.75 KVM_IRQFD 27928c2ecf20Sopenharmony_ci-------------- 27938c2ecf20Sopenharmony_ci 27948c2ecf20Sopenharmony_ci:Capability: KVM_CAP_IRQFD 27958c2ecf20Sopenharmony_ci:Architectures: x86 s390 arm arm64 27968c2ecf20Sopenharmony_ci:Type: vm ioctl 27978c2ecf20Sopenharmony_ci:Parameters: struct kvm_irqfd (in) 27988c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 27998c2ecf20Sopenharmony_ci 28008c2ecf20Sopenharmony_ciAllows setting an eventfd to directly trigger a guest interrupt. 28018c2ecf20Sopenharmony_cikvm_irqfd.fd specifies the file descriptor to use as the eventfd and 28028c2ecf20Sopenharmony_cikvm_irqfd.gsi specifies the irqchip pin toggled by this event. When 28038c2ecf20Sopenharmony_cian event is triggered on the eventfd, an interrupt is injected into 28048c2ecf20Sopenharmony_cithe guest using the specified gsi pin. The irqfd is removed using 28058c2ecf20Sopenharmony_cithe KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd 28068c2ecf20Sopenharmony_ciand kvm_irqfd.gsi. 28078c2ecf20Sopenharmony_ci 28088c2ecf20Sopenharmony_ciWith KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify 28098c2ecf20Sopenharmony_cimechanism allowing emulation of level-triggered, irqfd-based 28108c2ecf20Sopenharmony_ciinterrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an 28118c2ecf20Sopenharmony_ciadditional eventfd in the kvm_irqfd.resamplefd field. When operating 28128c2ecf20Sopenharmony_ciin resample mode, posting of an interrupt through kvm_irq.fd asserts 28138c2ecf20Sopenharmony_cithe specified gsi in the irqchip. When the irqchip is resampled, such 28148c2ecf20Sopenharmony_cias from an EOI, the gsi is de-asserted and the user is notified via 28158c2ecf20Sopenharmony_cikvm_irqfd.resamplefd. It is the user's responsibility to re-queue 28168c2ecf20Sopenharmony_cithe interrupt if the device making use of it still requires service. 28178c2ecf20Sopenharmony_ciNote that closing the resamplefd is not sufficient to disable the 28188c2ecf20Sopenharmony_ciirqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment 28198c2ecf20Sopenharmony_ciand need not be specified with KVM_IRQFD_FLAG_DEASSIGN. 28208c2ecf20Sopenharmony_ci 28218c2ecf20Sopenharmony_ciOn arm/arm64, gsi routing being supported, the following can happen: 28228c2ecf20Sopenharmony_ci 28238c2ecf20Sopenharmony_ci- in case no routing entry is associated to this gsi, injection fails 28248c2ecf20Sopenharmony_ci- in case the gsi is associated to an irqchip routing entry, 28258c2ecf20Sopenharmony_ci irqchip.pin + 32 corresponds to the injected SPI ID. 28268c2ecf20Sopenharmony_ci- in case the gsi is associated to an MSI routing entry, the MSI 28278c2ecf20Sopenharmony_ci message and device ID are translated into an LPI (support restricted 28288c2ecf20Sopenharmony_ci to GICv3 ITS in-kernel emulation). 28298c2ecf20Sopenharmony_ci 28308c2ecf20Sopenharmony_ci4.76 KVM_PPC_ALLOCATE_HTAB 28318c2ecf20Sopenharmony_ci-------------------------- 28328c2ecf20Sopenharmony_ci 28338c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_ALLOC_HTAB 28348c2ecf20Sopenharmony_ci:Architectures: powerpc 28358c2ecf20Sopenharmony_ci:Type: vm ioctl 28368c2ecf20Sopenharmony_ci:Parameters: Pointer to u32 containing hash table order (in/out) 28378c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 28388c2ecf20Sopenharmony_ci 28398c2ecf20Sopenharmony_ciThis requests the host kernel to allocate an MMU hash table for a 28408c2ecf20Sopenharmony_ciguest using the PAPR paravirtualization interface. This only does 28418c2ecf20Sopenharmony_cianything if the kernel is configured to use the Book 3S HV style of 28428c2ecf20Sopenharmony_civirtualization. Otherwise the capability doesn't exist and the ioctl 28438c2ecf20Sopenharmony_cireturns an ENOTTY error. The rest of this description assumes Book 3S 28448c2ecf20Sopenharmony_ciHV. 28458c2ecf20Sopenharmony_ci 28468c2ecf20Sopenharmony_ciThere must be no vcpus running when this ioctl is called; if there 28478c2ecf20Sopenharmony_ciare, it will do nothing and return an EBUSY error. 28488c2ecf20Sopenharmony_ci 28498c2ecf20Sopenharmony_ciThe parameter is a pointer to a 32-bit unsigned integer variable 28508c2ecf20Sopenharmony_cicontaining the order (log base 2) of the desired size of the hash 28518c2ecf20Sopenharmony_citable, which must be between 18 and 46. On successful return from the 28528c2ecf20Sopenharmony_ciioctl, the value will not be changed by the kernel. 28538c2ecf20Sopenharmony_ci 28548c2ecf20Sopenharmony_ciIf no hash table has been allocated when any vcpu is asked to run 28558c2ecf20Sopenharmony_ci(with the KVM_RUN ioctl), the host kernel will allocate a 28568c2ecf20Sopenharmony_cidefault-sized hash table (16 MB). 28578c2ecf20Sopenharmony_ci 28588c2ecf20Sopenharmony_ciIf this ioctl is called when a hash table has already been allocated, 28598c2ecf20Sopenharmony_ciwith a different order from the existing hash table, the existing hash 28608c2ecf20Sopenharmony_citable will be freed and a new one allocated. If this is ioctl is 28618c2ecf20Sopenharmony_cicalled when a hash table has already been allocated of the same order 28628c2ecf20Sopenharmony_cias specified, the kernel will clear out the existing hash table (zero 28638c2ecf20Sopenharmony_ciall HPTEs). In either case, if the guest is using the virtualized 28648c2ecf20Sopenharmony_cireal-mode area (VRMA) facility, the kernel will re-create the VMRA 28658c2ecf20Sopenharmony_ciHPTEs on the next KVM_RUN of any vcpu. 28668c2ecf20Sopenharmony_ci 28678c2ecf20Sopenharmony_ci4.77 KVM_S390_INTERRUPT 28688c2ecf20Sopenharmony_ci----------------------- 28698c2ecf20Sopenharmony_ci 28708c2ecf20Sopenharmony_ci:Capability: basic 28718c2ecf20Sopenharmony_ci:Architectures: s390 28728c2ecf20Sopenharmony_ci:Type: vm ioctl, vcpu ioctl 28738c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_interrupt (in) 28748c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 28758c2ecf20Sopenharmony_ci 28768c2ecf20Sopenharmony_ciAllows to inject an interrupt to the guest. Interrupts can be floating 28778c2ecf20Sopenharmony_ci(vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type. 28788c2ecf20Sopenharmony_ci 28798c2ecf20Sopenharmony_ciInterrupt parameters are passed via kvm_s390_interrupt:: 28808c2ecf20Sopenharmony_ci 28818c2ecf20Sopenharmony_ci struct kvm_s390_interrupt { 28828c2ecf20Sopenharmony_ci __u32 type; 28838c2ecf20Sopenharmony_ci __u32 parm; 28848c2ecf20Sopenharmony_ci __u64 parm64; 28858c2ecf20Sopenharmony_ci }; 28868c2ecf20Sopenharmony_ci 28878c2ecf20Sopenharmony_citype can be one of the following: 28888c2ecf20Sopenharmony_ci 28898c2ecf20Sopenharmony_ciKVM_S390_SIGP_STOP (vcpu) 28908c2ecf20Sopenharmony_ci - sigp stop; optional flags in parm 28918c2ecf20Sopenharmony_ciKVM_S390_PROGRAM_INT (vcpu) 28928c2ecf20Sopenharmony_ci - program check; code in parm 28938c2ecf20Sopenharmony_ciKVM_S390_SIGP_SET_PREFIX (vcpu) 28948c2ecf20Sopenharmony_ci - sigp set prefix; prefix address in parm 28958c2ecf20Sopenharmony_ciKVM_S390_RESTART (vcpu) 28968c2ecf20Sopenharmony_ci - restart 28978c2ecf20Sopenharmony_ciKVM_S390_INT_CLOCK_COMP (vcpu) 28988c2ecf20Sopenharmony_ci - clock comparator interrupt 28998c2ecf20Sopenharmony_ciKVM_S390_INT_CPU_TIMER (vcpu) 29008c2ecf20Sopenharmony_ci - CPU timer interrupt 29018c2ecf20Sopenharmony_ciKVM_S390_INT_VIRTIO (vm) 29028c2ecf20Sopenharmony_ci - virtio external interrupt; external interrupt 29038c2ecf20Sopenharmony_ci parameters in parm and parm64 29048c2ecf20Sopenharmony_ciKVM_S390_INT_SERVICE (vm) 29058c2ecf20Sopenharmony_ci - sclp external interrupt; sclp parameter in parm 29068c2ecf20Sopenharmony_ciKVM_S390_INT_EMERGENCY (vcpu) 29078c2ecf20Sopenharmony_ci - sigp emergency; source cpu in parm 29088c2ecf20Sopenharmony_ciKVM_S390_INT_EXTERNAL_CALL (vcpu) 29098c2ecf20Sopenharmony_ci - sigp external call; source cpu in parm 29108c2ecf20Sopenharmony_ciKVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) 29118c2ecf20Sopenharmony_ci - compound value to indicate an 29128c2ecf20Sopenharmony_ci I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel); 29138c2ecf20Sopenharmony_ci I/O interruption parameters in parm (subchannel) and parm64 (intparm, 29148c2ecf20Sopenharmony_ci interruption subclass) 29158c2ecf20Sopenharmony_ciKVM_S390_MCHK (vm, vcpu) 29168c2ecf20Sopenharmony_ci - machine check interrupt; cr 14 bits in parm, machine check interrupt 29178c2ecf20Sopenharmony_ci code in parm64 (note that machine checks needing further payload are not 29188c2ecf20Sopenharmony_ci supported by this ioctl) 29198c2ecf20Sopenharmony_ci 29208c2ecf20Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 29218c2ecf20Sopenharmony_ci 29228c2ecf20Sopenharmony_ci4.78 KVM_PPC_GET_HTAB_FD 29238c2ecf20Sopenharmony_ci------------------------ 29248c2ecf20Sopenharmony_ci 29258c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_HTAB_FD 29268c2ecf20Sopenharmony_ci:Architectures: powerpc 29278c2ecf20Sopenharmony_ci:Type: vm ioctl 29288c2ecf20Sopenharmony_ci:Parameters: Pointer to struct kvm_get_htab_fd (in) 29298c2ecf20Sopenharmony_ci:Returns: file descriptor number (>= 0) on success, -1 on error 29308c2ecf20Sopenharmony_ci 29318c2ecf20Sopenharmony_ciThis returns a file descriptor that can be used either to read out the 29328c2ecf20Sopenharmony_cientries in the guest's hashed page table (HPT), or to write entries to 29338c2ecf20Sopenharmony_ciinitialize the HPT. The returned fd can only be written to if the 29348c2ecf20Sopenharmony_ciKVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and 29358c2ecf20Sopenharmony_cican only be read if that bit is clear. The argument struct looks like 29368c2ecf20Sopenharmony_cithis:: 29378c2ecf20Sopenharmony_ci 29388c2ecf20Sopenharmony_ci /* For KVM_PPC_GET_HTAB_FD */ 29398c2ecf20Sopenharmony_ci struct kvm_get_htab_fd { 29408c2ecf20Sopenharmony_ci __u64 flags; 29418c2ecf20Sopenharmony_ci __u64 start_index; 29428c2ecf20Sopenharmony_ci __u64 reserved[2]; 29438c2ecf20Sopenharmony_ci }; 29448c2ecf20Sopenharmony_ci 29458c2ecf20Sopenharmony_ci /* Values for kvm_get_htab_fd.flags */ 29468c2ecf20Sopenharmony_ci #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1) 29478c2ecf20Sopenharmony_ci #define KVM_GET_HTAB_WRITE ((__u64)0x2) 29488c2ecf20Sopenharmony_ci 29498c2ecf20Sopenharmony_ciThe 'start_index' field gives the index in the HPT of the entry at 29508c2ecf20Sopenharmony_ciwhich to start reading. It is ignored when writing. 29518c2ecf20Sopenharmony_ci 29528c2ecf20Sopenharmony_ciReads on the fd will initially supply information about all 29538c2ecf20Sopenharmony_ci"interesting" HPT entries. Interesting entries are those with the 29548c2ecf20Sopenharmony_cibolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise 29558c2ecf20Sopenharmony_ciall entries. When the end of the HPT is reached, the read() will 29568c2ecf20Sopenharmony_cireturn. If read() is called again on the fd, it will start again from 29578c2ecf20Sopenharmony_cithe beginning of the HPT, but will only return HPT entries that have 29588c2ecf20Sopenharmony_cichanged since they were last read. 29598c2ecf20Sopenharmony_ci 29608c2ecf20Sopenharmony_ciData read or written is structured as a header (8 bytes) followed by a 29618c2ecf20Sopenharmony_ciseries of valid HPT entries (16 bytes) each. The header indicates how 29628c2ecf20Sopenharmony_cimany valid HPT entries there are and how many invalid entries follow 29638c2ecf20Sopenharmony_cithe valid entries. The invalid entries are not represented explicitly 29648c2ecf20Sopenharmony_ciin the stream. The header format is:: 29658c2ecf20Sopenharmony_ci 29668c2ecf20Sopenharmony_ci struct kvm_get_htab_header { 29678c2ecf20Sopenharmony_ci __u32 index; 29688c2ecf20Sopenharmony_ci __u16 n_valid; 29698c2ecf20Sopenharmony_ci __u16 n_invalid; 29708c2ecf20Sopenharmony_ci }; 29718c2ecf20Sopenharmony_ci 29728c2ecf20Sopenharmony_ciWrites to the fd create HPT entries starting at the index given in the 29738c2ecf20Sopenharmony_ciheader; first 'n_valid' valid entries with contents from the data 29748c2ecf20Sopenharmony_ciwritten, then 'n_invalid' invalid entries, invalidating any previously 29758c2ecf20Sopenharmony_civalid entries found. 29768c2ecf20Sopenharmony_ci 29778c2ecf20Sopenharmony_ci4.79 KVM_CREATE_DEVICE 29788c2ecf20Sopenharmony_ci---------------------- 29798c2ecf20Sopenharmony_ci 29808c2ecf20Sopenharmony_ci:Capability: KVM_CAP_DEVICE_CTRL 29818c2ecf20Sopenharmony_ci:Type: vm ioctl 29828c2ecf20Sopenharmony_ci:Parameters: struct kvm_create_device (in/out) 29838c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 29848c2ecf20Sopenharmony_ci 29858c2ecf20Sopenharmony_ciErrors: 29868c2ecf20Sopenharmony_ci 29878c2ecf20Sopenharmony_ci ====== ======================================================= 29888c2ecf20Sopenharmony_ci ENODEV The device type is unknown or unsupported 29898c2ecf20Sopenharmony_ci EEXIST Device already created, and this type of device may not 29908c2ecf20Sopenharmony_ci be instantiated multiple times 29918c2ecf20Sopenharmony_ci ====== ======================================================= 29928c2ecf20Sopenharmony_ci 29938c2ecf20Sopenharmony_ci Other error conditions may be defined by individual device types or 29948c2ecf20Sopenharmony_ci have their standard meanings. 29958c2ecf20Sopenharmony_ci 29968c2ecf20Sopenharmony_ciCreates an emulated device in the kernel. The file descriptor returned 29978c2ecf20Sopenharmony_ciin fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR. 29988c2ecf20Sopenharmony_ci 29998c2ecf20Sopenharmony_ciIf the KVM_CREATE_DEVICE_TEST flag is set, only test whether the 30008c2ecf20Sopenharmony_cidevice type is supported (not necessarily whether it can be created 30018c2ecf20Sopenharmony_ciin the current vm). 30028c2ecf20Sopenharmony_ci 30038c2ecf20Sopenharmony_ciIndividual devices should not define flags. Attributes should be used 30048c2ecf20Sopenharmony_cifor specifying any behavior that is not implied by the device type 30058c2ecf20Sopenharmony_cinumber. 30068c2ecf20Sopenharmony_ci 30078c2ecf20Sopenharmony_ci:: 30088c2ecf20Sopenharmony_ci 30098c2ecf20Sopenharmony_ci struct kvm_create_device { 30108c2ecf20Sopenharmony_ci __u32 type; /* in: KVM_DEV_TYPE_xxx */ 30118c2ecf20Sopenharmony_ci __u32 fd; /* out: device handle */ 30128c2ecf20Sopenharmony_ci __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 30138c2ecf20Sopenharmony_ci }; 30148c2ecf20Sopenharmony_ci 30158c2ecf20Sopenharmony_ci4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR 30168c2ecf20Sopenharmony_ci-------------------------------------------- 30178c2ecf20Sopenharmony_ci 30188c2ecf20Sopenharmony_ci:Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, 30198c2ecf20Sopenharmony_ci KVM_CAP_VCPU_ATTRIBUTES for vcpu device 30208c2ecf20Sopenharmony_ci:Type: device ioctl, vm ioctl, vcpu ioctl 30218c2ecf20Sopenharmony_ci:Parameters: struct kvm_device_attr 30228c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 30238c2ecf20Sopenharmony_ci 30248c2ecf20Sopenharmony_ciErrors: 30258c2ecf20Sopenharmony_ci 30268c2ecf20Sopenharmony_ci ===== ============================================================= 30278c2ecf20Sopenharmony_ci ENXIO The group or attribute is unknown/unsupported for this device 30288c2ecf20Sopenharmony_ci or hardware support is missing. 30298c2ecf20Sopenharmony_ci EPERM The attribute cannot (currently) be accessed this way 30308c2ecf20Sopenharmony_ci (e.g. read-only attribute, or attribute that only makes 30318c2ecf20Sopenharmony_ci sense when the device is in a different state) 30328c2ecf20Sopenharmony_ci ===== ============================================================= 30338c2ecf20Sopenharmony_ci 30348c2ecf20Sopenharmony_ci Other error conditions may be defined by individual device types. 30358c2ecf20Sopenharmony_ci 30368c2ecf20Sopenharmony_ciGets/sets a specified piece of device configuration and/or state. The 30378c2ecf20Sopenharmony_cisemantics are device-specific. See individual device documentation in 30388c2ecf20Sopenharmony_cithe "devices" directory. As with ONE_REG, the size of the data 30398c2ecf20Sopenharmony_citransferred is defined by the particular attribute. 30408c2ecf20Sopenharmony_ci 30418c2ecf20Sopenharmony_ci:: 30428c2ecf20Sopenharmony_ci 30438c2ecf20Sopenharmony_ci struct kvm_device_attr { 30448c2ecf20Sopenharmony_ci __u32 flags; /* no flags currently defined */ 30458c2ecf20Sopenharmony_ci __u32 group; /* device-defined */ 30468c2ecf20Sopenharmony_ci __u64 attr; /* group-defined */ 30478c2ecf20Sopenharmony_ci __u64 addr; /* userspace address of attr data */ 30488c2ecf20Sopenharmony_ci }; 30498c2ecf20Sopenharmony_ci 30508c2ecf20Sopenharmony_ci4.81 KVM_HAS_DEVICE_ATTR 30518c2ecf20Sopenharmony_ci------------------------ 30528c2ecf20Sopenharmony_ci 30538c2ecf20Sopenharmony_ci:Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, 30548c2ecf20Sopenharmony_ci KVM_CAP_VCPU_ATTRIBUTES for vcpu device 30558c2ecf20Sopenharmony_ci:Type: device ioctl, vm ioctl, vcpu ioctl 30568c2ecf20Sopenharmony_ci:Parameters: struct kvm_device_attr 30578c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 30588c2ecf20Sopenharmony_ci 30598c2ecf20Sopenharmony_ciErrors: 30608c2ecf20Sopenharmony_ci 30618c2ecf20Sopenharmony_ci ===== ============================================================= 30628c2ecf20Sopenharmony_ci ENXIO The group or attribute is unknown/unsupported for this device 30638c2ecf20Sopenharmony_ci or hardware support is missing. 30648c2ecf20Sopenharmony_ci ===== ============================================================= 30658c2ecf20Sopenharmony_ci 30668c2ecf20Sopenharmony_ciTests whether a device supports a particular attribute. A successful 30678c2ecf20Sopenharmony_cireturn indicates the attribute is implemented. It does not necessarily 30688c2ecf20Sopenharmony_ciindicate that the attribute can be read or written in the device's 30698c2ecf20Sopenharmony_cicurrent state. "addr" is ignored. 30708c2ecf20Sopenharmony_ci 30718c2ecf20Sopenharmony_ci4.82 KVM_ARM_VCPU_INIT 30728c2ecf20Sopenharmony_ci---------------------- 30738c2ecf20Sopenharmony_ci 30748c2ecf20Sopenharmony_ci:Capability: basic 30758c2ecf20Sopenharmony_ci:Architectures: arm, arm64 30768c2ecf20Sopenharmony_ci:Type: vcpu ioctl 30778c2ecf20Sopenharmony_ci:Parameters: struct kvm_vcpu_init (in) 30788c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 30798c2ecf20Sopenharmony_ci 30808c2ecf20Sopenharmony_ciErrors: 30818c2ecf20Sopenharmony_ci 30828c2ecf20Sopenharmony_ci ====== ================================================================= 30838c2ecf20Sopenharmony_ci EINVAL the target is unknown, or the combination of features is invalid. 30848c2ecf20Sopenharmony_ci ENOENT a features bit specified is unknown. 30858c2ecf20Sopenharmony_ci ====== ================================================================= 30868c2ecf20Sopenharmony_ci 30878c2ecf20Sopenharmony_ciThis tells KVM what type of CPU to present to the guest, and what 30888c2ecf20Sopenharmony_cioptional features it should have. This will cause a reset of the cpu 30898c2ecf20Sopenharmony_ciregisters to their initial values. If this is not called, KVM_RUN will 30908c2ecf20Sopenharmony_cireturn ENOEXEC for that vcpu. 30918c2ecf20Sopenharmony_ci 30928c2ecf20Sopenharmony_ciNote that because some registers reflect machine topology, all vcpus 30938c2ecf20Sopenharmony_cishould be created before this ioctl is invoked. 30948c2ecf20Sopenharmony_ci 30958c2ecf20Sopenharmony_ciUserspace can call this function multiple times for a given vcpu, including 30968c2ecf20Sopenharmony_ciafter the vcpu has been run. This will reset the vcpu to its initial 30978c2ecf20Sopenharmony_cistate. All calls to this function after the initial call must use the same 30988c2ecf20Sopenharmony_citarget and same set of feature flags, otherwise EINVAL will be returned. 30998c2ecf20Sopenharmony_ci 31008c2ecf20Sopenharmony_ciPossible features: 31018c2ecf20Sopenharmony_ci 31028c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state. 31038c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on 31048c2ecf20Sopenharmony_ci and execute guest code when KVM_RUN is called. 31058c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode. 31068c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only). 31078c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision 31088c2ecf20Sopenharmony_ci backward compatible with v0.2) for the CPU. 31098c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_PSCI_0_2. 31108c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU. 31118c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_PMU_V3. 31128c2ecf20Sopenharmony_ci 31138c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication 31148c2ecf20Sopenharmony_ci for arm64 only. 31158c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS. 31168c2ecf20Sopenharmony_ci If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are 31178c2ecf20Sopenharmony_ci both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and 31188c2ecf20Sopenharmony_ci KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be 31198c2ecf20Sopenharmony_ci requested. 31208c2ecf20Sopenharmony_ci 31218c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication 31228c2ecf20Sopenharmony_ci for arm64 only. 31238c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_PTRAUTH_GENERIC. 31248c2ecf20Sopenharmony_ci If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are 31258c2ecf20Sopenharmony_ci both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and 31268c2ecf20Sopenharmony_ci KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be 31278c2ecf20Sopenharmony_ci requested. 31288c2ecf20Sopenharmony_ci 31298c2ecf20Sopenharmony_ci - KVM_ARM_VCPU_SVE: Enables SVE for the CPU (arm64 only). 31308c2ecf20Sopenharmony_ci Depends on KVM_CAP_ARM_SVE. 31318c2ecf20Sopenharmony_ci Requires KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE): 31328c2ecf20Sopenharmony_ci 31338c2ecf20Sopenharmony_ci * After KVM_ARM_VCPU_INIT: 31348c2ecf20Sopenharmony_ci 31358c2ecf20Sopenharmony_ci - KVM_REG_ARM64_SVE_VLS may be read using KVM_GET_ONE_REG: the 31368c2ecf20Sopenharmony_ci initial value of this pseudo-register indicates the best set of 31378c2ecf20Sopenharmony_ci vector lengths possible for a vcpu on this host. 31388c2ecf20Sopenharmony_ci 31398c2ecf20Sopenharmony_ci * Before KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE): 31408c2ecf20Sopenharmony_ci 31418c2ecf20Sopenharmony_ci - KVM_RUN and KVM_GET_REG_LIST are not available; 31428c2ecf20Sopenharmony_ci 31438c2ecf20Sopenharmony_ci - KVM_GET_ONE_REG and KVM_SET_ONE_REG cannot be used to access 31448c2ecf20Sopenharmony_ci the scalable archietctural SVE registers 31458c2ecf20Sopenharmony_ci KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() or 31468c2ecf20Sopenharmony_ci KVM_REG_ARM64_SVE_FFR; 31478c2ecf20Sopenharmony_ci 31488c2ecf20Sopenharmony_ci - KVM_REG_ARM64_SVE_VLS may optionally be written using 31498c2ecf20Sopenharmony_ci KVM_SET_ONE_REG, to modify the set of vector lengths available 31508c2ecf20Sopenharmony_ci for the vcpu. 31518c2ecf20Sopenharmony_ci 31528c2ecf20Sopenharmony_ci * After KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE): 31538c2ecf20Sopenharmony_ci 31548c2ecf20Sopenharmony_ci - the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can 31558c2ecf20Sopenharmony_ci no longer be written using KVM_SET_ONE_REG. 31568c2ecf20Sopenharmony_ci 31578c2ecf20Sopenharmony_ci4.83 KVM_ARM_PREFERRED_TARGET 31588c2ecf20Sopenharmony_ci----------------------------- 31598c2ecf20Sopenharmony_ci 31608c2ecf20Sopenharmony_ci:Capability: basic 31618c2ecf20Sopenharmony_ci:Architectures: arm, arm64 31628c2ecf20Sopenharmony_ci:Type: vm ioctl 31638c2ecf20Sopenharmony_ci:Parameters: struct kvm_vcpu_init (out) 31648c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 31658c2ecf20Sopenharmony_ci 31668c2ecf20Sopenharmony_ciErrors: 31678c2ecf20Sopenharmony_ci 31688c2ecf20Sopenharmony_ci ====== ========================================== 31698c2ecf20Sopenharmony_ci ENODEV no preferred target available for the host 31708c2ecf20Sopenharmony_ci ====== ========================================== 31718c2ecf20Sopenharmony_ci 31728c2ecf20Sopenharmony_ciThis queries KVM for preferred CPU target type which can be emulated 31738c2ecf20Sopenharmony_ciby KVM on underlying host. 31748c2ecf20Sopenharmony_ci 31758c2ecf20Sopenharmony_ciThe ioctl returns struct kvm_vcpu_init instance containing information 31768c2ecf20Sopenharmony_ciabout preferred CPU target type and recommended features for it. The 31778c2ecf20Sopenharmony_cikvm_vcpu_init->features bitmap returned will have feature bits set if 31788c2ecf20Sopenharmony_cithe preferred target recommends setting these features, but this is 31798c2ecf20Sopenharmony_cinot mandatory. 31808c2ecf20Sopenharmony_ci 31818c2ecf20Sopenharmony_ciThe information returned by this ioctl can be used to prepare an instance 31828c2ecf20Sopenharmony_ciof struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in 31838c2ecf20Sopenharmony_ciVCPU matching underlying host. 31848c2ecf20Sopenharmony_ci 31858c2ecf20Sopenharmony_ci 31868c2ecf20Sopenharmony_ci4.84 KVM_GET_REG_LIST 31878c2ecf20Sopenharmony_ci--------------------- 31888c2ecf20Sopenharmony_ci 31898c2ecf20Sopenharmony_ci:Capability: basic 31908c2ecf20Sopenharmony_ci:Architectures: arm, arm64, mips 31918c2ecf20Sopenharmony_ci:Type: vcpu ioctl 31928c2ecf20Sopenharmony_ci:Parameters: struct kvm_reg_list (in/out) 31938c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 31948c2ecf20Sopenharmony_ci 31958c2ecf20Sopenharmony_ciErrors: 31968c2ecf20Sopenharmony_ci 31978c2ecf20Sopenharmony_ci ===== ============================================================== 31988c2ecf20Sopenharmony_ci E2BIG the reg index list is too big to fit in the array specified by 31998c2ecf20Sopenharmony_ci the user (the number required will be written into n). 32008c2ecf20Sopenharmony_ci ===== ============================================================== 32018c2ecf20Sopenharmony_ci 32028c2ecf20Sopenharmony_ci:: 32038c2ecf20Sopenharmony_ci 32048c2ecf20Sopenharmony_ci struct kvm_reg_list { 32058c2ecf20Sopenharmony_ci __u64 n; /* number of registers in reg[] */ 32068c2ecf20Sopenharmony_ci __u64 reg[0]; 32078c2ecf20Sopenharmony_ci }; 32088c2ecf20Sopenharmony_ci 32098c2ecf20Sopenharmony_ciThis ioctl returns the guest registers that are supported for the 32108c2ecf20Sopenharmony_ciKVM_GET_ONE_REG/KVM_SET_ONE_REG calls. 32118c2ecf20Sopenharmony_ci 32128c2ecf20Sopenharmony_ci 32138c2ecf20Sopenharmony_ci4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated) 32148c2ecf20Sopenharmony_ci----------------------------------------- 32158c2ecf20Sopenharmony_ci 32168c2ecf20Sopenharmony_ci:Capability: KVM_CAP_ARM_SET_DEVICE_ADDR 32178c2ecf20Sopenharmony_ci:Architectures: arm, arm64 32188c2ecf20Sopenharmony_ci:Type: vm ioctl 32198c2ecf20Sopenharmony_ci:Parameters: struct kvm_arm_device_address (in) 32208c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 32218c2ecf20Sopenharmony_ci 32228c2ecf20Sopenharmony_ciErrors: 32238c2ecf20Sopenharmony_ci 32248c2ecf20Sopenharmony_ci ====== ============================================ 32258c2ecf20Sopenharmony_ci ENODEV The device id is unknown 32268c2ecf20Sopenharmony_ci ENXIO Device not supported on current system 32278c2ecf20Sopenharmony_ci EEXIST Address already set 32288c2ecf20Sopenharmony_ci E2BIG Address outside guest physical address space 32298c2ecf20Sopenharmony_ci EBUSY Address overlaps with other device range 32308c2ecf20Sopenharmony_ci ====== ============================================ 32318c2ecf20Sopenharmony_ci 32328c2ecf20Sopenharmony_ci:: 32338c2ecf20Sopenharmony_ci 32348c2ecf20Sopenharmony_ci struct kvm_arm_device_addr { 32358c2ecf20Sopenharmony_ci __u64 id; 32368c2ecf20Sopenharmony_ci __u64 addr; 32378c2ecf20Sopenharmony_ci }; 32388c2ecf20Sopenharmony_ci 32398c2ecf20Sopenharmony_ciSpecify a device address in the guest's physical address space where guests 32408c2ecf20Sopenharmony_cican access emulated or directly exposed devices, which the host kernel needs 32418c2ecf20Sopenharmony_cito know about. The id field is an architecture specific identifier for a 32428c2ecf20Sopenharmony_cispecific device. 32438c2ecf20Sopenharmony_ci 32448c2ecf20Sopenharmony_ciARM/arm64 divides the id field into two parts, a device id and an 32458c2ecf20Sopenharmony_ciaddress type id specific to the individual device:: 32468c2ecf20Sopenharmony_ci 32478c2ecf20Sopenharmony_ci bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 | 32488c2ecf20Sopenharmony_ci field: | 0x00000000 | device id | addr type id | 32498c2ecf20Sopenharmony_ci 32508c2ecf20Sopenharmony_ciARM/arm64 currently only require this when using the in-kernel GIC 32518c2ecf20Sopenharmony_cisupport for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2 32528c2ecf20Sopenharmony_cias the device id. When setting the base address for the guest's 32538c2ecf20Sopenharmony_cimapping of the VGIC virtual CPU and distributor interface, the ioctl 32548c2ecf20Sopenharmony_cimust be called after calling KVM_CREATE_IRQCHIP, but before calling 32558c2ecf20Sopenharmony_ciKVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the 32568c2ecf20Sopenharmony_cibase addresses will return -EEXIST. 32578c2ecf20Sopenharmony_ci 32588c2ecf20Sopenharmony_ciNote, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API 32598c2ecf20Sopenharmony_cishould be used instead. 32608c2ecf20Sopenharmony_ci 32618c2ecf20Sopenharmony_ci 32628c2ecf20Sopenharmony_ci4.86 KVM_PPC_RTAS_DEFINE_TOKEN 32638c2ecf20Sopenharmony_ci------------------------------ 32648c2ecf20Sopenharmony_ci 32658c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_RTAS 32668c2ecf20Sopenharmony_ci:Architectures: ppc 32678c2ecf20Sopenharmony_ci:Type: vm ioctl 32688c2ecf20Sopenharmony_ci:Parameters: struct kvm_rtas_token_args 32698c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 32708c2ecf20Sopenharmony_ci 32718c2ecf20Sopenharmony_ciDefines a token value for a RTAS (Run Time Abstraction Services) 32728c2ecf20Sopenharmony_ciservice in order to allow it to be handled in the kernel. The 32738c2ecf20Sopenharmony_ciargument struct gives the name of the service, which must be the name 32748c2ecf20Sopenharmony_ciof a service that has a kernel-side implementation. If the token 32758c2ecf20Sopenharmony_civalue is non-zero, it will be associated with that service, and 32768c2ecf20Sopenharmony_cisubsequent RTAS calls by the guest specifying that token will be 32778c2ecf20Sopenharmony_cihandled by the kernel. If the token value is 0, then any token 32788c2ecf20Sopenharmony_ciassociated with the service will be forgotten, and subsequent RTAS 32798c2ecf20Sopenharmony_cicalls by the guest for that service will be passed to userspace to be 32808c2ecf20Sopenharmony_cihandled. 32818c2ecf20Sopenharmony_ci 32828c2ecf20Sopenharmony_ci4.87 KVM_SET_GUEST_DEBUG 32838c2ecf20Sopenharmony_ci------------------------ 32848c2ecf20Sopenharmony_ci 32858c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SET_GUEST_DEBUG 32868c2ecf20Sopenharmony_ci:Architectures: x86, s390, ppc, arm64 32878c2ecf20Sopenharmony_ci:Type: vcpu ioctl 32888c2ecf20Sopenharmony_ci:Parameters: struct kvm_guest_debug (in) 32898c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 32908c2ecf20Sopenharmony_ci 32918c2ecf20Sopenharmony_ci:: 32928c2ecf20Sopenharmony_ci 32938c2ecf20Sopenharmony_ci struct kvm_guest_debug { 32948c2ecf20Sopenharmony_ci __u32 control; 32958c2ecf20Sopenharmony_ci __u32 pad; 32968c2ecf20Sopenharmony_ci struct kvm_guest_debug_arch arch; 32978c2ecf20Sopenharmony_ci }; 32988c2ecf20Sopenharmony_ci 32998c2ecf20Sopenharmony_ciSet up the processor specific debug registers and configure vcpu for 33008c2ecf20Sopenharmony_cihandling guest debug events. There are two parts to the structure, the 33018c2ecf20Sopenharmony_cifirst a control bitfield indicates the type of debug events to handle 33028c2ecf20Sopenharmony_ciwhen running. Common control bits are: 33038c2ecf20Sopenharmony_ci 33048c2ecf20Sopenharmony_ci - KVM_GUESTDBG_ENABLE: guest debugging is enabled 33058c2ecf20Sopenharmony_ci - KVM_GUESTDBG_SINGLESTEP: the next run should single-step 33068c2ecf20Sopenharmony_ci 33078c2ecf20Sopenharmony_ciThe top 16 bits of the control field are architecture specific control 33088c2ecf20Sopenharmony_ciflags which can include the following: 33098c2ecf20Sopenharmony_ci 33108c2ecf20Sopenharmony_ci - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64] 33118c2ecf20Sopenharmony_ci - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390, arm64] 33128c2ecf20Sopenharmony_ci - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86] 33138c2ecf20Sopenharmony_ci - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86] 33148c2ecf20Sopenharmony_ci - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390] 33158c2ecf20Sopenharmony_ci 33168c2ecf20Sopenharmony_ciFor example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints 33178c2ecf20Sopenharmony_ciare enabled in memory so we need to ensure breakpoint exceptions are 33188c2ecf20Sopenharmony_cicorrectly trapped and the KVM run loop exits at the breakpoint and not 33198c2ecf20Sopenharmony_cirunning off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP 33208c2ecf20Sopenharmony_ciwe need to ensure the guest vCPUs architecture specific registers are 33218c2ecf20Sopenharmony_ciupdated to the correct (supplied) values. 33228c2ecf20Sopenharmony_ci 33238c2ecf20Sopenharmony_ciThe second part of the structure is architecture specific and 33248c2ecf20Sopenharmony_citypically contains a set of debug registers. 33258c2ecf20Sopenharmony_ci 33268c2ecf20Sopenharmony_ciFor arm64 the number of debug registers is implementation defined and 33278c2ecf20Sopenharmony_cican be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and 33288c2ecf20Sopenharmony_ciKVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number 33298c2ecf20Sopenharmony_ciindicating the number of supported registers. 33308c2ecf20Sopenharmony_ci 33318c2ecf20Sopenharmony_ciFor ppc, the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability indicates whether 33328c2ecf20Sopenharmony_cithe single-step debug event (KVM_GUESTDBG_SINGLESTEP) is supported. 33338c2ecf20Sopenharmony_ci 33348c2ecf20Sopenharmony_ciWhen debug events exit the main run loop with the reason 33358c2ecf20Sopenharmony_ciKVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run 33368c2ecf20Sopenharmony_cistructure containing architecture specific debug information. 33378c2ecf20Sopenharmony_ci 33388c2ecf20Sopenharmony_ci4.88 KVM_GET_EMULATED_CPUID 33398c2ecf20Sopenharmony_ci--------------------------- 33408c2ecf20Sopenharmony_ci 33418c2ecf20Sopenharmony_ci:Capability: KVM_CAP_EXT_EMUL_CPUID 33428c2ecf20Sopenharmony_ci:Architectures: x86 33438c2ecf20Sopenharmony_ci:Type: system ioctl 33448c2ecf20Sopenharmony_ci:Parameters: struct kvm_cpuid2 (in/out) 33458c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 33468c2ecf20Sopenharmony_ci 33478c2ecf20Sopenharmony_ci:: 33488c2ecf20Sopenharmony_ci 33498c2ecf20Sopenharmony_ci struct kvm_cpuid2 { 33508c2ecf20Sopenharmony_ci __u32 nent; 33518c2ecf20Sopenharmony_ci __u32 flags; 33528c2ecf20Sopenharmony_ci struct kvm_cpuid_entry2 entries[0]; 33538c2ecf20Sopenharmony_ci }; 33548c2ecf20Sopenharmony_ci 33558c2ecf20Sopenharmony_ciThe member 'flags' is used for passing flags from userspace. 33568c2ecf20Sopenharmony_ci 33578c2ecf20Sopenharmony_ci:: 33588c2ecf20Sopenharmony_ci 33598c2ecf20Sopenharmony_ci #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) 33608c2ecf20Sopenharmony_ci #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */ 33618c2ecf20Sopenharmony_ci #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */ 33628c2ecf20Sopenharmony_ci 33638c2ecf20Sopenharmony_ci struct kvm_cpuid_entry2 { 33648c2ecf20Sopenharmony_ci __u32 function; 33658c2ecf20Sopenharmony_ci __u32 index; 33668c2ecf20Sopenharmony_ci __u32 flags; 33678c2ecf20Sopenharmony_ci __u32 eax; 33688c2ecf20Sopenharmony_ci __u32 ebx; 33698c2ecf20Sopenharmony_ci __u32 ecx; 33708c2ecf20Sopenharmony_ci __u32 edx; 33718c2ecf20Sopenharmony_ci __u32 padding[3]; 33728c2ecf20Sopenharmony_ci }; 33738c2ecf20Sopenharmony_ci 33748c2ecf20Sopenharmony_ciThis ioctl returns x86 cpuid features which are emulated by 33758c2ecf20Sopenharmony_cikvm.Userspace can use the information returned by this ioctl to query 33768c2ecf20Sopenharmony_ciwhich features are emulated by kvm instead of being present natively. 33778c2ecf20Sopenharmony_ci 33788c2ecf20Sopenharmony_ciUserspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2 33798c2ecf20Sopenharmony_cistructure with the 'nent' field indicating the number of entries in 33808c2ecf20Sopenharmony_cithe variable-size array 'entries'. If the number of entries is too low 33818c2ecf20Sopenharmony_cito describe the cpu capabilities, an error (E2BIG) is returned. If the 33828c2ecf20Sopenharmony_cinumber is too high, the 'nent' field is adjusted and an error (ENOMEM) 33838c2ecf20Sopenharmony_ciis returned. If the number is just right, the 'nent' field is adjusted 33848c2ecf20Sopenharmony_cito the number of valid entries in the 'entries' array, which is then 33858c2ecf20Sopenharmony_cifilled. 33868c2ecf20Sopenharmony_ci 33878c2ecf20Sopenharmony_ciThe entries returned are the set CPUID bits of the respective features 33888c2ecf20Sopenharmony_ciwhich kvm emulates, as returned by the CPUID instruction, with unknown 33898c2ecf20Sopenharmony_cior unsupported feature bits cleared. 33908c2ecf20Sopenharmony_ci 33918c2ecf20Sopenharmony_ciFeatures like x2apic, for example, may not be present in the host cpu 33928c2ecf20Sopenharmony_cibut are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be 33938c2ecf20Sopenharmony_ciemulated efficiently and thus not included here. 33948c2ecf20Sopenharmony_ci 33958c2ecf20Sopenharmony_ciThe fields in each entry are defined as follows: 33968c2ecf20Sopenharmony_ci 33978c2ecf20Sopenharmony_ci function: 33988c2ecf20Sopenharmony_ci the eax value used to obtain the entry 33998c2ecf20Sopenharmony_ci index: 34008c2ecf20Sopenharmony_ci the ecx value used to obtain the entry (for entries that are 34018c2ecf20Sopenharmony_ci affected by ecx) 34028c2ecf20Sopenharmony_ci flags: 34038c2ecf20Sopenharmony_ci an OR of zero or more of the following: 34048c2ecf20Sopenharmony_ci 34058c2ecf20Sopenharmony_ci KVM_CPUID_FLAG_SIGNIFCANT_INDEX: 34068c2ecf20Sopenharmony_ci if the index field is valid 34078c2ecf20Sopenharmony_ci 34088c2ecf20Sopenharmony_ci eax, ebx, ecx, edx: 34098c2ecf20Sopenharmony_ci 34108c2ecf20Sopenharmony_ci the values returned by the cpuid instruction for 34118c2ecf20Sopenharmony_ci this function/index combination 34128c2ecf20Sopenharmony_ci 34138c2ecf20Sopenharmony_ci4.89 KVM_S390_MEM_OP 34148c2ecf20Sopenharmony_ci-------------------- 34158c2ecf20Sopenharmony_ci 34168c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_MEM_OP 34178c2ecf20Sopenharmony_ci:Architectures: s390 34188c2ecf20Sopenharmony_ci:Type: vcpu ioctl 34198c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_mem_op (in) 34208c2ecf20Sopenharmony_ci:Returns: = 0 on success, 34218c2ecf20Sopenharmony_ci < 0 on generic error (e.g. -EFAULT or -ENOMEM), 34228c2ecf20Sopenharmony_ci > 0 if an exception occurred while walking the page tables 34238c2ecf20Sopenharmony_ci 34248c2ecf20Sopenharmony_ciRead or write data from/to the logical (virtual) memory of a VCPU. 34258c2ecf20Sopenharmony_ci 34268c2ecf20Sopenharmony_ciParameters are specified via the following structure:: 34278c2ecf20Sopenharmony_ci 34288c2ecf20Sopenharmony_ci struct kvm_s390_mem_op { 34298c2ecf20Sopenharmony_ci __u64 gaddr; /* the guest address */ 34308c2ecf20Sopenharmony_ci __u64 flags; /* flags */ 34318c2ecf20Sopenharmony_ci __u32 size; /* amount of bytes */ 34328c2ecf20Sopenharmony_ci __u32 op; /* type of operation */ 34338c2ecf20Sopenharmony_ci __u64 buf; /* buffer in userspace */ 34348c2ecf20Sopenharmony_ci __u8 ar; /* the access register number */ 34358c2ecf20Sopenharmony_ci __u8 reserved[31]; /* should be set to 0 */ 34368c2ecf20Sopenharmony_ci }; 34378c2ecf20Sopenharmony_ci 34388c2ecf20Sopenharmony_ciThe type of operation is specified in the "op" field. It is either 34398c2ecf20Sopenharmony_ciKVM_S390_MEMOP_LOGICAL_READ for reading from logical memory space or 34408c2ecf20Sopenharmony_ciKVM_S390_MEMOP_LOGICAL_WRITE for writing to logical memory space. The 34418c2ecf20Sopenharmony_ciKVM_S390_MEMOP_F_CHECK_ONLY flag can be set in the "flags" field to check 34428c2ecf20Sopenharmony_ciwhether the corresponding memory access would create an access exception 34438c2ecf20Sopenharmony_ci(without touching the data in the memory at the destination). In case an 34448c2ecf20Sopenharmony_ciaccess exception occurred while walking the MMU tables of the guest, the 34458c2ecf20Sopenharmony_ciioctl returns a positive error number to indicate the type of exception. 34468c2ecf20Sopenharmony_ciThis exception is also raised directly at the corresponding VCPU if the 34478c2ecf20Sopenharmony_ciflag KVM_S390_MEMOP_F_INJECT_EXCEPTION is set in the "flags" field. 34488c2ecf20Sopenharmony_ci 34498c2ecf20Sopenharmony_ciThe start address of the memory region has to be specified in the "gaddr" 34508c2ecf20Sopenharmony_cifield, and the length of the region in the "size" field (which must not 34518c2ecf20Sopenharmony_cibe 0). The maximum value for "size" can be obtained by checking the 34528c2ecf20Sopenharmony_ciKVM_CAP_S390_MEM_OP capability. "buf" is the buffer supplied by the 34538c2ecf20Sopenharmony_ciuserspace application where the read data should be written to for 34548c2ecf20Sopenharmony_ciKVM_S390_MEMOP_LOGICAL_READ, or where the data that should be written is 34558c2ecf20Sopenharmony_cistored for a KVM_S390_MEMOP_LOGICAL_WRITE. When KVM_S390_MEMOP_F_CHECK_ONLY 34568c2ecf20Sopenharmony_ciis specified, "buf" is unused and can be NULL. "ar" designates the access 34578c2ecf20Sopenharmony_ciregister number to be used; the valid range is 0..15. 34588c2ecf20Sopenharmony_ci 34598c2ecf20Sopenharmony_ciThe "reserved" field is meant for future extensions. It is not used by 34608c2ecf20Sopenharmony_ciKVM with the currently defined set of flags. 34618c2ecf20Sopenharmony_ci 34628c2ecf20Sopenharmony_ci4.90 KVM_S390_GET_SKEYS 34638c2ecf20Sopenharmony_ci----------------------- 34648c2ecf20Sopenharmony_ci 34658c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_SKEYS 34668c2ecf20Sopenharmony_ci:Architectures: s390 34678c2ecf20Sopenharmony_ci:Type: vm ioctl 34688c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_skeys 34698c2ecf20Sopenharmony_ci:Returns: 0 on success, KVM_S390_GET_KEYS_NONE if guest is not using storage 34708c2ecf20Sopenharmony_ci keys, negative value on error 34718c2ecf20Sopenharmony_ci 34728c2ecf20Sopenharmony_ciThis ioctl is used to get guest storage key values on the s390 34738c2ecf20Sopenharmony_ciarchitecture. The ioctl takes parameters via the kvm_s390_skeys struct:: 34748c2ecf20Sopenharmony_ci 34758c2ecf20Sopenharmony_ci struct kvm_s390_skeys { 34768c2ecf20Sopenharmony_ci __u64 start_gfn; 34778c2ecf20Sopenharmony_ci __u64 count; 34788c2ecf20Sopenharmony_ci __u64 skeydata_addr; 34798c2ecf20Sopenharmony_ci __u32 flags; 34808c2ecf20Sopenharmony_ci __u32 reserved[9]; 34818c2ecf20Sopenharmony_ci }; 34828c2ecf20Sopenharmony_ci 34838c2ecf20Sopenharmony_ciThe start_gfn field is the number of the first guest frame whose storage keys 34848c2ecf20Sopenharmony_ciyou want to get. 34858c2ecf20Sopenharmony_ci 34868c2ecf20Sopenharmony_ciThe count field is the number of consecutive frames (starting from start_gfn) 34878c2ecf20Sopenharmony_ciwhose storage keys to get. The count field must be at least 1 and the maximum 34888c2ecf20Sopenharmony_ciallowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range 34898c2ecf20Sopenharmony_ciwill cause the ioctl to return -EINVAL. 34908c2ecf20Sopenharmony_ci 34918c2ecf20Sopenharmony_ciThe skeydata_addr field is the address to a buffer large enough to hold count 34928c2ecf20Sopenharmony_cibytes. This buffer will be filled with storage key data by the ioctl. 34938c2ecf20Sopenharmony_ci 34948c2ecf20Sopenharmony_ci4.91 KVM_S390_SET_SKEYS 34958c2ecf20Sopenharmony_ci----------------------- 34968c2ecf20Sopenharmony_ci 34978c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_SKEYS 34988c2ecf20Sopenharmony_ci:Architectures: s390 34998c2ecf20Sopenharmony_ci:Type: vm ioctl 35008c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_skeys 35018c2ecf20Sopenharmony_ci:Returns: 0 on success, negative value on error 35028c2ecf20Sopenharmony_ci 35038c2ecf20Sopenharmony_ciThis ioctl is used to set guest storage key values on the s390 35048c2ecf20Sopenharmony_ciarchitecture. The ioctl takes parameters via the kvm_s390_skeys struct. 35058c2ecf20Sopenharmony_ciSee section on KVM_S390_GET_SKEYS for struct definition. 35068c2ecf20Sopenharmony_ci 35078c2ecf20Sopenharmony_ciThe start_gfn field is the number of the first guest frame whose storage keys 35088c2ecf20Sopenharmony_ciyou want to set. 35098c2ecf20Sopenharmony_ci 35108c2ecf20Sopenharmony_ciThe count field is the number of consecutive frames (starting from start_gfn) 35118c2ecf20Sopenharmony_ciwhose storage keys to get. The count field must be at least 1 and the maximum 35128c2ecf20Sopenharmony_ciallowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range 35138c2ecf20Sopenharmony_ciwill cause the ioctl to return -EINVAL. 35148c2ecf20Sopenharmony_ci 35158c2ecf20Sopenharmony_ciThe skeydata_addr field is the address to a buffer containing count bytes of 35168c2ecf20Sopenharmony_cistorage keys. Each byte in the buffer will be set as the storage key for a 35178c2ecf20Sopenharmony_cisingle frame starting at start_gfn for count frames. 35188c2ecf20Sopenharmony_ci 35198c2ecf20Sopenharmony_ciNote: If any architecturally invalid key value is found in the given data then 35208c2ecf20Sopenharmony_cithe ioctl will return -EINVAL. 35218c2ecf20Sopenharmony_ci 35228c2ecf20Sopenharmony_ci4.92 KVM_S390_IRQ 35238c2ecf20Sopenharmony_ci----------------- 35248c2ecf20Sopenharmony_ci 35258c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_INJECT_IRQ 35268c2ecf20Sopenharmony_ci:Architectures: s390 35278c2ecf20Sopenharmony_ci:Type: vcpu ioctl 35288c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_irq (in) 35298c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 35308c2ecf20Sopenharmony_ci 35318c2ecf20Sopenharmony_ciErrors: 35328c2ecf20Sopenharmony_ci 35338c2ecf20Sopenharmony_ci 35348c2ecf20Sopenharmony_ci ====== ================================================================= 35358c2ecf20Sopenharmony_ci EINVAL interrupt type is invalid 35368c2ecf20Sopenharmony_ci type is KVM_S390_SIGP_STOP and flag parameter is invalid value, 35378c2ecf20Sopenharmony_ci type is KVM_S390_INT_EXTERNAL_CALL and code is bigger 35388c2ecf20Sopenharmony_ci than the maximum of VCPUs 35398c2ecf20Sopenharmony_ci EBUSY type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped, 35408c2ecf20Sopenharmony_ci type is KVM_S390_SIGP_STOP and a stop irq is already pending, 35418c2ecf20Sopenharmony_ci type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt 35428c2ecf20Sopenharmony_ci is already pending 35438c2ecf20Sopenharmony_ci ====== ================================================================= 35448c2ecf20Sopenharmony_ci 35458c2ecf20Sopenharmony_ciAllows to inject an interrupt to the guest. 35468c2ecf20Sopenharmony_ci 35478c2ecf20Sopenharmony_ciUsing struct kvm_s390_irq as a parameter allows 35488c2ecf20Sopenharmony_cito inject additional payload which is not 35498c2ecf20Sopenharmony_cipossible via KVM_S390_INTERRUPT. 35508c2ecf20Sopenharmony_ci 35518c2ecf20Sopenharmony_ciInterrupt parameters are passed via kvm_s390_irq:: 35528c2ecf20Sopenharmony_ci 35538c2ecf20Sopenharmony_ci struct kvm_s390_irq { 35548c2ecf20Sopenharmony_ci __u64 type; 35558c2ecf20Sopenharmony_ci union { 35568c2ecf20Sopenharmony_ci struct kvm_s390_io_info io; 35578c2ecf20Sopenharmony_ci struct kvm_s390_ext_info ext; 35588c2ecf20Sopenharmony_ci struct kvm_s390_pgm_info pgm; 35598c2ecf20Sopenharmony_ci struct kvm_s390_emerg_info emerg; 35608c2ecf20Sopenharmony_ci struct kvm_s390_extcall_info extcall; 35618c2ecf20Sopenharmony_ci struct kvm_s390_prefix_info prefix; 35628c2ecf20Sopenharmony_ci struct kvm_s390_stop_info stop; 35638c2ecf20Sopenharmony_ci struct kvm_s390_mchk_info mchk; 35648c2ecf20Sopenharmony_ci char reserved[64]; 35658c2ecf20Sopenharmony_ci } u; 35668c2ecf20Sopenharmony_ci }; 35678c2ecf20Sopenharmony_ci 35688c2ecf20Sopenharmony_citype can be one of the following: 35698c2ecf20Sopenharmony_ci 35708c2ecf20Sopenharmony_ci- KVM_S390_SIGP_STOP - sigp stop; parameter in .stop 35718c2ecf20Sopenharmony_ci- KVM_S390_PROGRAM_INT - program check; parameters in .pgm 35728c2ecf20Sopenharmony_ci- KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix 35738c2ecf20Sopenharmony_ci- KVM_S390_RESTART - restart; no parameters 35748c2ecf20Sopenharmony_ci- KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters 35758c2ecf20Sopenharmony_ci- KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters 35768c2ecf20Sopenharmony_ci- KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg 35778c2ecf20Sopenharmony_ci- KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall 35788c2ecf20Sopenharmony_ci- KVM_S390_MCHK - machine check interrupt; parameters in .mchk 35798c2ecf20Sopenharmony_ci 35808c2ecf20Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 35818c2ecf20Sopenharmony_ci 35828c2ecf20Sopenharmony_ci4.94 KVM_S390_GET_IRQ_STATE 35838c2ecf20Sopenharmony_ci--------------------------- 35848c2ecf20Sopenharmony_ci 35858c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_IRQ_STATE 35868c2ecf20Sopenharmony_ci:Architectures: s390 35878c2ecf20Sopenharmony_ci:Type: vcpu ioctl 35888c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_irq_state (out) 35898c2ecf20Sopenharmony_ci:Returns: >= number of bytes copied into buffer, 35908c2ecf20Sopenharmony_ci -EINVAL if buffer size is 0, 35918c2ecf20Sopenharmony_ci -ENOBUFS if buffer size is too small to fit all pending interrupts, 35928c2ecf20Sopenharmony_ci -EFAULT if the buffer address was invalid 35938c2ecf20Sopenharmony_ci 35948c2ecf20Sopenharmony_ciThis ioctl allows userspace to retrieve the complete state of all currently 35958c2ecf20Sopenharmony_cipending interrupts in a single buffer. Use cases include migration 35968c2ecf20Sopenharmony_ciand introspection. The parameter structure contains the address of a 35978c2ecf20Sopenharmony_ciuserspace buffer and its length:: 35988c2ecf20Sopenharmony_ci 35998c2ecf20Sopenharmony_ci struct kvm_s390_irq_state { 36008c2ecf20Sopenharmony_ci __u64 buf; 36018c2ecf20Sopenharmony_ci __u32 flags; /* will stay unused for compatibility reasons */ 36028c2ecf20Sopenharmony_ci __u32 len; 36038c2ecf20Sopenharmony_ci __u32 reserved[4]; /* will stay unused for compatibility reasons */ 36048c2ecf20Sopenharmony_ci }; 36058c2ecf20Sopenharmony_ci 36068c2ecf20Sopenharmony_ciUserspace passes in the above struct and for each pending interrupt a 36078c2ecf20Sopenharmony_cistruct kvm_s390_irq is copied to the provided buffer. 36088c2ecf20Sopenharmony_ci 36098c2ecf20Sopenharmony_ciThe structure contains a flags and a reserved field for future extensions. As 36108c2ecf20Sopenharmony_cithe kernel never checked for flags == 0 and QEMU never pre-zeroed flags and 36118c2ecf20Sopenharmony_cireserved, these fields can not be used in the future without breaking 36128c2ecf20Sopenharmony_cicompatibility. 36138c2ecf20Sopenharmony_ci 36148c2ecf20Sopenharmony_ciIf -ENOBUFS is returned the buffer provided was too small and userspace 36158c2ecf20Sopenharmony_cimay retry with a bigger buffer. 36168c2ecf20Sopenharmony_ci 36178c2ecf20Sopenharmony_ci4.95 KVM_S390_SET_IRQ_STATE 36188c2ecf20Sopenharmony_ci--------------------------- 36198c2ecf20Sopenharmony_ci 36208c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_IRQ_STATE 36218c2ecf20Sopenharmony_ci:Architectures: s390 36228c2ecf20Sopenharmony_ci:Type: vcpu ioctl 36238c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_irq_state (in) 36248c2ecf20Sopenharmony_ci:Returns: 0 on success, 36258c2ecf20Sopenharmony_ci -EFAULT if the buffer address was invalid, 36268c2ecf20Sopenharmony_ci -EINVAL for an invalid buffer length (see below), 36278c2ecf20Sopenharmony_ci -EBUSY if there were already interrupts pending, 36288c2ecf20Sopenharmony_ci errors occurring when actually injecting the 36298c2ecf20Sopenharmony_ci interrupt. See KVM_S390_IRQ. 36308c2ecf20Sopenharmony_ci 36318c2ecf20Sopenharmony_ciThis ioctl allows userspace to set the complete state of all cpu-local 36328c2ecf20Sopenharmony_ciinterrupts currently pending for the vcpu. It is intended for restoring 36338c2ecf20Sopenharmony_ciinterrupt state after a migration. The input parameter is a userspace buffer 36348c2ecf20Sopenharmony_cicontaining a struct kvm_s390_irq_state:: 36358c2ecf20Sopenharmony_ci 36368c2ecf20Sopenharmony_ci struct kvm_s390_irq_state { 36378c2ecf20Sopenharmony_ci __u64 buf; 36388c2ecf20Sopenharmony_ci __u32 flags; /* will stay unused for compatibility reasons */ 36398c2ecf20Sopenharmony_ci __u32 len; 36408c2ecf20Sopenharmony_ci __u32 reserved[4]; /* will stay unused for compatibility reasons */ 36418c2ecf20Sopenharmony_ci }; 36428c2ecf20Sopenharmony_ci 36438c2ecf20Sopenharmony_ciThe restrictions for flags and reserved apply as well. 36448c2ecf20Sopenharmony_ci(see KVM_S390_GET_IRQ_STATE) 36458c2ecf20Sopenharmony_ci 36468c2ecf20Sopenharmony_ciThe userspace memory referenced by buf contains a struct kvm_s390_irq 36478c2ecf20Sopenharmony_cifor each interrupt to be injected into the guest. 36488c2ecf20Sopenharmony_ciIf one of the interrupts could not be injected for some reason the 36498c2ecf20Sopenharmony_ciioctl aborts. 36508c2ecf20Sopenharmony_ci 36518c2ecf20Sopenharmony_cilen must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0 36528c2ecf20Sopenharmony_ciand it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq), 36538c2ecf20Sopenharmony_ciwhich is the maximum number of possibly pending cpu-local interrupts. 36548c2ecf20Sopenharmony_ci 36558c2ecf20Sopenharmony_ci4.96 KVM_SMI 36568c2ecf20Sopenharmony_ci------------ 36578c2ecf20Sopenharmony_ci 36588c2ecf20Sopenharmony_ci:Capability: KVM_CAP_X86_SMM 36598c2ecf20Sopenharmony_ci:Architectures: x86 36608c2ecf20Sopenharmony_ci:Type: vcpu ioctl 36618c2ecf20Sopenharmony_ci:Parameters: none 36628c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 36638c2ecf20Sopenharmony_ci 36648c2ecf20Sopenharmony_ciQueues an SMI on the thread's vcpu. 36658c2ecf20Sopenharmony_ci 36668c2ecf20Sopenharmony_ci4.97 KVM_CAP_PPC_MULTITCE 36678c2ecf20Sopenharmony_ci------------------------- 36688c2ecf20Sopenharmony_ci 36698c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_MULTITCE 36708c2ecf20Sopenharmony_ci:Architectures: ppc 36718c2ecf20Sopenharmony_ci:Type: vm 36728c2ecf20Sopenharmony_ci 36738c2ecf20Sopenharmony_ciThis capability means the kernel is capable of handling hypercalls 36748c2ecf20Sopenharmony_ciH_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user 36758c2ecf20Sopenharmony_cispace. This significantly accelerates DMA operations for PPC KVM guests. 36768c2ecf20Sopenharmony_ciUser space should expect that its handlers for these hypercalls 36778c2ecf20Sopenharmony_ciare not going to be called if user space previously registered LIOBN 36788c2ecf20Sopenharmony_ciin KVM (via KVM_CREATE_SPAPR_TCE or similar calls). 36798c2ecf20Sopenharmony_ci 36808c2ecf20Sopenharmony_ciIn order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest, 36818c2ecf20Sopenharmony_ciuser space might have to advertise it for the guest. For example, 36828c2ecf20Sopenharmony_ciIBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is 36838c2ecf20Sopenharmony_cipresent in the "ibm,hypertas-functions" device-tree property. 36848c2ecf20Sopenharmony_ci 36858c2ecf20Sopenharmony_ciThe hypercalls mentioned above may or may not be processed successfully 36868c2ecf20Sopenharmony_ciin the kernel based fast path. If they can not be handled by the kernel, 36878c2ecf20Sopenharmony_cithey will get passed on to user space. So user space still has to have 36888c2ecf20Sopenharmony_cian implementation for these despite the in kernel acceleration. 36898c2ecf20Sopenharmony_ci 36908c2ecf20Sopenharmony_ciThis capability is always enabled. 36918c2ecf20Sopenharmony_ci 36928c2ecf20Sopenharmony_ci4.98 KVM_CREATE_SPAPR_TCE_64 36938c2ecf20Sopenharmony_ci---------------------------- 36948c2ecf20Sopenharmony_ci 36958c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SPAPR_TCE_64 36968c2ecf20Sopenharmony_ci:Architectures: powerpc 36978c2ecf20Sopenharmony_ci:Type: vm ioctl 36988c2ecf20Sopenharmony_ci:Parameters: struct kvm_create_spapr_tce_64 (in) 36998c2ecf20Sopenharmony_ci:Returns: file descriptor for manipulating the created TCE table 37008c2ecf20Sopenharmony_ci 37018c2ecf20Sopenharmony_ciThis is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit 37028c2ecf20Sopenharmony_ciwindows, described in 4.62 KVM_CREATE_SPAPR_TCE 37038c2ecf20Sopenharmony_ci 37048c2ecf20Sopenharmony_ciThis capability uses extended struct in ioctl interface:: 37058c2ecf20Sopenharmony_ci 37068c2ecf20Sopenharmony_ci /* for KVM_CAP_SPAPR_TCE_64 */ 37078c2ecf20Sopenharmony_ci struct kvm_create_spapr_tce_64 { 37088c2ecf20Sopenharmony_ci __u64 liobn; 37098c2ecf20Sopenharmony_ci __u32 page_shift; 37108c2ecf20Sopenharmony_ci __u32 flags; 37118c2ecf20Sopenharmony_ci __u64 offset; /* in pages */ 37128c2ecf20Sopenharmony_ci __u64 size; /* in pages */ 37138c2ecf20Sopenharmony_ci }; 37148c2ecf20Sopenharmony_ci 37158c2ecf20Sopenharmony_ciThe aim of extension is to support an additional bigger DMA window with 37168c2ecf20Sopenharmony_cia variable page size. 37178c2ecf20Sopenharmony_ciKVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and 37188c2ecf20Sopenharmony_cia bus offset of the corresponding DMA window, @size and @offset are numbers 37198c2ecf20Sopenharmony_ciof IOMMU pages. 37208c2ecf20Sopenharmony_ci 37218c2ecf20Sopenharmony_ci@flags are not used at the moment. 37228c2ecf20Sopenharmony_ci 37238c2ecf20Sopenharmony_ciThe rest of functionality is identical to KVM_CREATE_SPAPR_TCE. 37248c2ecf20Sopenharmony_ci 37258c2ecf20Sopenharmony_ci4.99 KVM_REINJECT_CONTROL 37268c2ecf20Sopenharmony_ci------------------------- 37278c2ecf20Sopenharmony_ci 37288c2ecf20Sopenharmony_ci:Capability: KVM_CAP_REINJECT_CONTROL 37298c2ecf20Sopenharmony_ci:Architectures: x86 37308c2ecf20Sopenharmony_ci:Type: vm ioctl 37318c2ecf20Sopenharmony_ci:Parameters: struct kvm_reinject_control (in) 37328c2ecf20Sopenharmony_ci:Returns: 0 on success, 37338c2ecf20Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 37348c2ecf20Sopenharmony_ci -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier. 37358c2ecf20Sopenharmony_ci 37368c2ecf20Sopenharmony_cii8254 (PIT) has two modes, reinject and !reinject. The default is reinject, 37378c2ecf20Sopenharmony_ciwhere KVM queues elapsed i8254 ticks and monitors completion of interrupt from 37388c2ecf20Sopenharmony_civector(s) that i8254 injects. Reinject mode dequeues a tick and injects its 37398c2ecf20Sopenharmony_ciinterrupt whenever there isn't a pending interrupt from i8254. 37408c2ecf20Sopenharmony_ci!reinject mode injects an interrupt as soon as a tick arrives. 37418c2ecf20Sopenharmony_ci 37428c2ecf20Sopenharmony_ci:: 37438c2ecf20Sopenharmony_ci 37448c2ecf20Sopenharmony_ci struct kvm_reinject_control { 37458c2ecf20Sopenharmony_ci __u8 pit_reinject; 37468c2ecf20Sopenharmony_ci __u8 reserved[31]; 37478c2ecf20Sopenharmony_ci }; 37488c2ecf20Sopenharmony_ci 37498c2ecf20Sopenharmony_cipit_reinject = 0 (!reinject mode) is recommended, unless running an old 37508c2ecf20Sopenharmony_cioperating system that uses the PIT for timing (e.g. Linux 2.4.x). 37518c2ecf20Sopenharmony_ci 37528c2ecf20Sopenharmony_ci4.100 KVM_PPC_CONFIGURE_V3_MMU 37538c2ecf20Sopenharmony_ci------------------------------ 37548c2ecf20Sopenharmony_ci 37558c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 37568c2ecf20Sopenharmony_ci:Architectures: ppc 37578c2ecf20Sopenharmony_ci:Type: vm ioctl 37588c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_mmuv3_cfg (in) 37598c2ecf20Sopenharmony_ci:Returns: 0 on success, 37608c2ecf20Sopenharmony_ci -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read, 37618c2ecf20Sopenharmony_ci -EINVAL if the configuration is invalid 37628c2ecf20Sopenharmony_ci 37638c2ecf20Sopenharmony_ciThis ioctl controls whether the guest will use radix or HPT (hashed 37648c2ecf20Sopenharmony_cipage table) translation, and sets the pointer to the process table for 37658c2ecf20Sopenharmony_cithe guest. 37668c2ecf20Sopenharmony_ci 37678c2ecf20Sopenharmony_ci:: 37688c2ecf20Sopenharmony_ci 37698c2ecf20Sopenharmony_ci struct kvm_ppc_mmuv3_cfg { 37708c2ecf20Sopenharmony_ci __u64 flags; 37718c2ecf20Sopenharmony_ci __u64 process_table; 37728c2ecf20Sopenharmony_ci }; 37738c2ecf20Sopenharmony_ci 37748c2ecf20Sopenharmony_ciThere are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and 37758c2ecf20Sopenharmony_ciKVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest 37768c2ecf20Sopenharmony_cito use radix tree translation, and if clear, to use HPT translation. 37778c2ecf20Sopenharmony_ciKVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest 37788c2ecf20Sopenharmony_cito be able to use the global TLB and SLB invalidation instructions; 37798c2ecf20Sopenharmony_ciif clear, the guest may not use these instructions. 37808c2ecf20Sopenharmony_ci 37818c2ecf20Sopenharmony_ciThe process_table field specifies the address and size of the guest 37828c2ecf20Sopenharmony_ciprocess table, which is in the guest's space. This field is formatted 37838c2ecf20Sopenharmony_cias the second doubleword of the partition table entry, as defined in 37848c2ecf20Sopenharmony_cithe Power ISA V3.00, Book III section 5.7.6.1. 37858c2ecf20Sopenharmony_ci 37868c2ecf20Sopenharmony_ci4.101 KVM_PPC_GET_RMMU_INFO 37878c2ecf20Sopenharmony_ci--------------------------- 37888c2ecf20Sopenharmony_ci 37898c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_RADIX_MMU 37908c2ecf20Sopenharmony_ci:Architectures: ppc 37918c2ecf20Sopenharmony_ci:Type: vm ioctl 37928c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_rmmu_info (out) 37938c2ecf20Sopenharmony_ci:Returns: 0 on success, 37948c2ecf20Sopenharmony_ci -EFAULT if struct kvm_ppc_rmmu_info cannot be written, 37958c2ecf20Sopenharmony_ci -EINVAL if no useful information can be returned 37968c2ecf20Sopenharmony_ci 37978c2ecf20Sopenharmony_ciThis ioctl returns a structure containing two things: (a) a list 37988c2ecf20Sopenharmony_cicontaining supported radix tree geometries, and (b) a list that maps 37998c2ecf20Sopenharmony_cipage sizes to put in the "AP" (actual page size) field for the tlbie 38008c2ecf20Sopenharmony_ci(TLB invalidate entry) instruction. 38018c2ecf20Sopenharmony_ci 38028c2ecf20Sopenharmony_ci:: 38038c2ecf20Sopenharmony_ci 38048c2ecf20Sopenharmony_ci struct kvm_ppc_rmmu_info { 38058c2ecf20Sopenharmony_ci struct kvm_ppc_radix_geom { 38068c2ecf20Sopenharmony_ci __u8 page_shift; 38078c2ecf20Sopenharmony_ci __u8 level_bits[4]; 38088c2ecf20Sopenharmony_ci __u8 pad[3]; 38098c2ecf20Sopenharmony_ci } geometries[8]; 38108c2ecf20Sopenharmony_ci __u32 ap_encodings[8]; 38118c2ecf20Sopenharmony_ci }; 38128c2ecf20Sopenharmony_ci 38138c2ecf20Sopenharmony_ciThe geometries[] field gives up to 8 supported geometries for the 38148c2ecf20Sopenharmony_ciradix page table, in terms of the log base 2 of the smallest page 38158c2ecf20Sopenharmony_cisize, and the number of bits indexed at each level of the tree, from 38168c2ecf20Sopenharmony_cithe PTE level up to the PGD level in that order. Any unused entries 38178c2ecf20Sopenharmony_ciwill have 0 in the page_shift field. 38188c2ecf20Sopenharmony_ci 38198c2ecf20Sopenharmony_ciThe ap_encodings gives the supported page sizes and their AP field 38208c2ecf20Sopenharmony_ciencodings, encoded with the AP value in the top 3 bits and the log 38218c2ecf20Sopenharmony_cibase 2 of the page size in the bottom 6 bits. 38228c2ecf20Sopenharmony_ci 38238c2ecf20Sopenharmony_ci4.102 KVM_PPC_RESIZE_HPT_PREPARE 38248c2ecf20Sopenharmony_ci-------------------------------- 38258c2ecf20Sopenharmony_ci 38268c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SPAPR_RESIZE_HPT 38278c2ecf20Sopenharmony_ci:Architectures: powerpc 38288c2ecf20Sopenharmony_ci:Type: vm ioctl 38298c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_resize_hpt (in) 38308c2ecf20Sopenharmony_ci:Returns: 0 on successful completion, 38318c2ecf20Sopenharmony_ci >0 if a new HPT is being prepared, the value is an estimated 38328c2ecf20Sopenharmony_ci number of milliseconds until preparation is complete, 38338c2ecf20Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 38348c2ecf20Sopenharmony_ci -EINVAL if the supplied shift or flags are invalid, 38358c2ecf20Sopenharmony_ci -ENOMEM if unable to allocate the new HPT, 38368c2ecf20Sopenharmony_ci -ENOSPC if there was a hash collision 38378c2ecf20Sopenharmony_ci 38388c2ecf20Sopenharmony_ci:: 38398c2ecf20Sopenharmony_ci 38408c2ecf20Sopenharmony_ci struct kvm_ppc_rmmu_info { 38418c2ecf20Sopenharmony_ci struct kvm_ppc_radix_geom { 38428c2ecf20Sopenharmony_ci __u8 page_shift; 38438c2ecf20Sopenharmony_ci __u8 level_bits[4]; 38448c2ecf20Sopenharmony_ci __u8 pad[3]; 38458c2ecf20Sopenharmony_ci } geometries[8]; 38468c2ecf20Sopenharmony_ci __u32 ap_encodings[8]; 38478c2ecf20Sopenharmony_ci }; 38488c2ecf20Sopenharmony_ci 38498c2ecf20Sopenharmony_ciThe geometries[] field gives up to 8 supported geometries for the 38508c2ecf20Sopenharmony_ciradix page table, in terms of the log base 2 of the smallest page 38518c2ecf20Sopenharmony_cisize, and the number of bits indexed at each level of the tree, from 38528c2ecf20Sopenharmony_cithe PTE level up to the PGD level in that order. Any unused entries 38538c2ecf20Sopenharmony_ciwill have 0 in the page_shift field. 38548c2ecf20Sopenharmony_ci 38558c2ecf20Sopenharmony_ciThe ap_encodings gives the supported page sizes and their AP field 38568c2ecf20Sopenharmony_ciencodings, encoded with the AP value in the top 3 bits and the log 38578c2ecf20Sopenharmony_cibase 2 of the page size in the bottom 6 bits. 38588c2ecf20Sopenharmony_ci 38598c2ecf20Sopenharmony_ci4.102 KVM_PPC_RESIZE_HPT_PREPARE 38608c2ecf20Sopenharmony_ci-------------------------------- 38618c2ecf20Sopenharmony_ci 38628c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SPAPR_RESIZE_HPT 38638c2ecf20Sopenharmony_ci:Architectures: powerpc 38648c2ecf20Sopenharmony_ci:Type: vm ioctl 38658c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_resize_hpt (in) 38668c2ecf20Sopenharmony_ci:Returns: 0 on successful completion, 38678c2ecf20Sopenharmony_ci >0 if a new HPT is being prepared, the value is an estimated 38688c2ecf20Sopenharmony_ci number of milliseconds until preparation is complete, 38698c2ecf20Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 38708c2ecf20Sopenharmony_ci -EINVAL if the supplied shift or flags are invalid,when moving existing 38718c2ecf20Sopenharmony_ci HPT entries to the new HPT, 38728c2ecf20Sopenharmony_ci -EIO on other error conditions 38738c2ecf20Sopenharmony_ci 38748c2ecf20Sopenharmony_ciUsed to implement the PAPR extension for runtime resizing of a guest's 38758c2ecf20Sopenharmony_ciHashed Page Table (HPT). Specifically this starts, stops or monitors 38768c2ecf20Sopenharmony_cithe preparation of a new potential HPT for the guest, essentially 38778c2ecf20Sopenharmony_ciimplementing the H_RESIZE_HPT_PREPARE hypercall. 38788c2ecf20Sopenharmony_ci 38798c2ecf20Sopenharmony_ciIf called with shift > 0 when there is no pending HPT for the guest, 38808c2ecf20Sopenharmony_cithis begins preparation of a new pending HPT of size 2^(shift) bytes. 38818c2ecf20Sopenharmony_ciIt then returns a positive integer with the estimated number of 38828c2ecf20Sopenharmony_cimilliseconds until preparation is complete. 38838c2ecf20Sopenharmony_ci 38848c2ecf20Sopenharmony_ciIf called when there is a pending HPT whose size does not match that 38858c2ecf20Sopenharmony_cirequested in the parameters, discards the existing pending HPT and 38868c2ecf20Sopenharmony_cicreates a new one as above. 38878c2ecf20Sopenharmony_ci 38888c2ecf20Sopenharmony_ciIf called when there is a pending HPT of the size requested, will: 38898c2ecf20Sopenharmony_ci 38908c2ecf20Sopenharmony_ci * If preparation of the pending HPT is already complete, return 0 38918c2ecf20Sopenharmony_ci * If preparation of the pending HPT has failed, return an error 38928c2ecf20Sopenharmony_ci code, then discard the pending HPT. 38938c2ecf20Sopenharmony_ci * If preparation of the pending HPT is still in progress, return an 38948c2ecf20Sopenharmony_ci estimated number of milliseconds until preparation is complete. 38958c2ecf20Sopenharmony_ci 38968c2ecf20Sopenharmony_ciIf called with shift == 0, discards any currently pending HPT and 38978c2ecf20Sopenharmony_cireturns 0 (i.e. cancels any in-progress preparation). 38988c2ecf20Sopenharmony_ci 38998c2ecf20Sopenharmony_ciflags is reserved for future expansion, currently setting any bits in 39008c2ecf20Sopenharmony_ciflags will result in an -EINVAL. 39018c2ecf20Sopenharmony_ci 39028c2ecf20Sopenharmony_ciNormally this will be called repeatedly with the same parameters until 39038c2ecf20Sopenharmony_ciit returns <= 0. The first call will initiate preparation, subsequent 39048c2ecf20Sopenharmony_ciones will monitor preparation until it completes or fails. 39058c2ecf20Sopenharmony_ci 39068c2ecf20Sopenharmony_ci:: 39078c2ecf20Sopenharmony_ci 39088c2ecf20Sopenharmony_ci struct kvm_ppc_resize_hpt { 39098c2ecf20Sopenharmony_ci __u64 flags; 39108c2ecf20Sopenharmony_ci __u32 shift; 39118c2ecf20Sopenharmony_ci __u32 pad; 39128c2ecf20Sopenharmony_ci }; 39138c2ecf20Sopenharmony_ci 39148c2ecf20Sopenharmony_ci4.103 KVM_PPC_RESIZE_HPT_COMMIT 39158c2ecf20Sopenharmony_ci------------------------------- 39168c2ecf20Sopenharmony_ci 39178c2ecf20Sopenharmony_ci:Capability: KVM_CAP_SPAPR_RESIZE_HPT 39188c2ecf20Sopenharmony_ci:Architectures: powerpc 39198c2ecf20Sopenharmony_ci:Type: vm ioctl 39208c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_resize_hpt (in) 39218c2ecf20Sopenharmony_ci:Returns: 0 on successful completion, 39228c2ecf20Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 39238c2ecf20Sopenharmony_ci -EINVAL if the supplied shift or flags are invalid, 39248c2ecf20Sopenharmony_ci -ENXIO is there is no pending HPT, or the pending HPT doesn't 39258c2ecf20Sopenharmony_ci have the requested size, 39268c2ecf20Sopenharmony_ci -EBUSY if the pending HPT is not fully prepared, 39278c2ecf20Sopenharmony_ci -ENOSPC if there was a hash collision when moving existing 39288c2ecf20Sopenharmony_ci HPT entries to the new HPT, 39298c2ecf20Sopenharmony_ci -EIO on other error conditions 39308c2ecf20Sopenharmony_ci 39318c2ecf20Sopenharmony_ciUsed to implement the PAPR extension for runtime resizing of a guest's 39328c2ecf20Sopenharmony_ciHashed Page Table (HPT). Specifically this requests that the guest be 39338c2ecf20Sopenharmony_citransferred to working with the new HPT, essentially implementing the 39348c2ecf20Sopenharmony_ciH_RESIZE_HPT_COMMIT hypercall. 39358c2ecf20Sopenharmony_ci 39368c2ecf20Sopenharmony_ciThis should only be called after KVM_PPC_RESIZE_HPT_PREPARE has 39378c2ecf20Sopenharmony_cireturned 0 with the same parameters. In other cases 39388c2ecf20Sopenharmony_ciKVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or 39398c2ecf20Sopenharmony_ci-EBUSY, though others may be possible if the preparation was started, 39408c2ecf20Sopenharmony_cibut failed). 39418c2ecf20Sopenharmony_ci 39428c2ecf20Sopenharmony_ciThis will have undefined effects on the guest if it has not already 39438c2ecf20Sopenharmony_ciplaced itself in a quiescent state where no vcpu will make MMU enabled 39448c2ecf20Sopenharmony_cimemory accesses. 39458c2ecf20Sopenharmony_ci 39468c2ecf20Sopenharmony_ciOn succsful completion, the pending HPT will become the guest's active 39478c2ecf20Sopenharmony_ciHPT and the previous HPT will be discarded. 39488c2ecf20Sopenharmony_ci 39498c2ecf20Sopenharmony_ciOn failure, the guest will still be operating on its previous HPT. 39508c2ecf20Sopenharmony_ci 39518c2ecf20Sopenharmony_ci:: 39528c2ecf20Sopenharmony_ci 39538c2ecf20Sopenharmony_ci struct kvm_ppc_resize_hpt { 39548c2ecf20Sopenharmony_ci __u64 flags; 39558c2ecf20Sopenharmony_ci __u32 shift; 39568c2ecf20Sopenharmony_ci __u32 pad; 39578c2ecf20Sopenharmony_ci }; 39588c2ecf20Sopenharmony_ci 39598c2ecf20Sopenharmony_ci4.104 KVM_X86_GET_MCE_CAP_SUPPORTED 39608c2ecf20Sopenharmony_ci----------------------------------- 39618c2ecf20Sopenharmony_ci 39628c2ecf20Sopenharmony_ci:Capability: KVM_CAP_MCE 39638c2ecf20Sopenharmony_ci:Architectures: x86 39648c2ecf20Sopenharmony_ci:Type: system ioctl 39658c2ecf20Sopenharmony_ci:Parameters: u64 mce_cap (out) 39668c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 39678c2ecf20Sopenharmony_ci 39688c2ecf20Sopenharmony_ciReturns supported MCE capabilities. The u64 mce_cap parameter 39698c2ecf20Sopenharmony_cihas the same format as the MSR_IA32_MCG_CAP register. Supported 39708c2ecf20Sopenharmony_cicapabilities will have the corresponding bits set. 39718c2ecf20Sopenharmony_ci 39728c2ecf20Sopenharmony_ci4.105 KVM_X86_SETUP_MCE 39738c2ecf20Sopenharmony_ci----------------------- 39748c2ecf20Sopenharmony_ci 39758c2ecf20Sopenharmony_ci:Capability: KVM_CAP_MCE 39768c2ecf20Sopenharmony_ci:Architectures: x86 39778c2ecf20Sopenharmony_ci:Type: vcpu ioctl 39788c2ecf20Sopenharmony_ci:Parameters: u64 mcg_cap (in) 39798c2ecf20Sopenharmony_ci:Returns: 0 on success, 39808c2ecf20Sopenharmony_ci -EFAULT if u64 mcg_cap cannot be read, 39818c2ecf20Sopenharmony_ci -EINVAL if the requested number of banks is invalid, 39828c2ecf20Sopenharmony_ci -EINVAL if requested MCE capability is not supported. 39838c2ecf20Sopenharmony_ci 39848c2ecf20Sopenharmony_ciInitializes MCE support for use. The u64 mcg_cap parameter 39858c2ecf20Sopenharmony_cihas the same format as the MSR_IA32_MCG_CAP register and 39868c2ecf20Sopenharmony_cispecifies which capabilities should be enabled. The maximum 39878c2ecf20Sopenharmony_cisupported number of error-reporting banks can be retrieved when 39888c2ecf20Sopenharmony_cichecking for KVM_CAP_MCE. The supported capabilities can be 39898c2ecf20Sopenharmony_ciretrieved with KVM_X86_GET_MCE_CAP_SUPPORTED. 39908c2ecf20Sopenharmony_ci 39918c2ecf20Sopenharmony_ci4.106 KVM_X86_SET_MCE 39928c2ecf20Sopenharmony_ci--------------------- 39938c2ecf20Sopenharmony_ci 39948c2ecf20Sopenharmony_ci:Capability: KVM_CAP_MCE 39958c2ecf20Sopenharmony_ci:Architectures: x86 39968c2ecf20Sopenharmony_ci:Type: vcpu ioctl 39978c2ecf20Sopenharmony_ci:Parameters: struct kvm_x86_mce (in) 39988c2ecf20Sopenharmony_ci:Returns: 0 on success, 39998c2ecf20Sopenharmony_ci -EFAULT if struct kvm_x86_mce cannot be read, 40008c2ecf20Sopenharmony_ci -EINVAL if the bank number is invalid, 40018c2ecf20Sopenharmony_ci -EINVAL if VAL bit is not set in status field. 40028c2ecf20Sopenharmony_ci 40038c2ecf20Sopenharmony_ciInject a machine check error (MCE) into the guest. The input 40048c2ecf20Sopenharmony_ciparameter is:: 40058c2ecf20Sopenharmony_ci 40068c2ecf20Sopenharmony_ci struct kvm_x86_mce { 40078c2ecf20Sopenharmony_ci __u64 status; 40088c2ecf20Sopenharmony_ci __u64 addr; 40098c2ecf20Sopenharmony_ci __u64 misc; 40108c2ecf20Sopenharmony_ci __u64 mcg_status; 40118c2ecf20Sopenharmony_ci __u8 bank; 40128c2ecf20Sopenharmony_ci __u8 pad1[7]; 40138c2ecf20Sopenharmony_ci __u64 pad2[3]; 40148c2ecf20Sopenharmony_ci }; 40158c2ecf20Sopenharmony_ci 40168c2ecf20Sopenharmony_ciIf the MCE being reported is an uncorrected error, KVM will 40178c2ecf20Sopenharmony_ciinject it as an MCE exception into the guest. If the guest 40188c2ecf20Sopenharmony_ciMCG_STATUS register reports that an MCE is in progress, KVM 40198c2ecf20Sopenharmony_cicauses an KVM_EXIT_SHUTDOWN vmexit. 40208c2ecf20Sopenharmony_ci 40218c2ecf20Sopenharmony_ciOtherwise, if the MCE is a corrected error, KVM will just 40228c2ecf20Sopenharmony_cistore it in the corresponding bank (provided this bank is 40238c2ecf20Sopenharmony_cinot holding a previously reported uncorrected error). 40248c2ecf20Sopenharmony_ci 40258c2ecf20Sopenharmony_ci4.107 KVM_S390_GET_CMMA_BITS 40268c2ecf20Sopenharmony_ci---------------------------- 40278c2ecf20Sopenharmony_ci 40288c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_CMMA_MIGRATION 40298c2ecf20Sopenharmony_ci:Architectures: s390 40308c2ecf20Sopenharmony_ci:Type: vm ioctl 40318c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_cmma_log (in, out) 40328c2ecf20Sopenharmony_ci:Returns: 0 on success, a negative value on error 40338c2ecf20Sopenharmony_ci 40348c2ecf20Sopenharmony_ciErrors: 40358c2ecf20Sopenharmony_ci 40368c2ecf20Sopenharmony_ci ====== ============================================================= 40378c2ecf20Sopenharmony_ci ENOMEM not enough memory can be allocated to complete the task 40388c2ecf20Sopenharmony_ci ENXIO if CMMA is not enabled 40398c2ecf20Sopenharmony_ci EINVAL if KVM_S390_CMMA_PEEK is not set but migration mode was not enabled 40408c2ecf20Sopenharmony_ci EINVAL if KVM_S390_CMMA_PEEK is not set but dirty tracking has been 40418c2ecf20Sopenharmony_ci disabled (and thus migration mode was automatically disabled) 40428c2ecf20Sopenharmony_ci EFAULT if the userspace address is invalid or if no page table is 40438c2ecf20Sopenharmony_ci present for the addresses (e.g. when using hugepages). 40448c2ecf20Sopenharmony_ci ====== ============================================================= 40458c2ecf20Sopenharmony_ci 40468c2ecf20Sopenharmony_ciThis ioctl is used to get the values of the CMMA bits on the s390 40478c2ecf20Sopenharmony_ciarchitecture. It is meant to be used in two scenarios: 40488c2ecf20Sopenharmony_ci 40498c2ecf20Sopenharmony_ci- During live migration to save the CMMA values. Live migration needs 40508c2ecf20Sopenharmony_ci to be enabled via the KVM_REQ_START_MIGRATION VM property. 40518c2ecf20Sopenharmony_ci- To non-destructively peek at the CMMA values, with the flag 40528c2ecf20Sopenharmony_ci KVM_S390_CMMA_PEEK set. 40538c2ecf20Sopenharmony_ci 40548c2ecf20Sopenharmony_ciThe ioctl takes parameters via the kvm_s390_cmma_log struct. The desired 40558c2ecf20Sopenharmony_civalues are written to a buffer whose location is indicated via the "values" 40568c2ecf20Sopenharmony_cimember in the kvm_s390_cmma_log struct. The values in the input struct are 40578c2ecf20Sopenharmony_cialso updated as needed. 40588c2ecf20Sopenharmony_ci 40598c2ecf20Sopenharmony_ciEach CMMA value takes up one byte. 40608c2ecf20Sopenharmony_ci 40618c2ecf20Sopenharmony_ci:: 40628c2ecf20Sopenharmony_ci 40638c2ecf20Sopenharmony_ci struct kvm_s390_cmma_log { 40648c2ecf20Sopenharmony_ci __u64 start_gfn; 40658c2ecf20Sopenharmony_ci __u32 count; 40668c2ecf20Sopenharmony_ci __u32 flags; 40678c2ecf20Sopenharmony_ci union { 40688c2ecf20Sopenharmony_ci __u64 remaining; 40698c2ecf20Sopenharmony_ci __u64 mask; 40708c2ecf20Sopenharmony_ci }; 40718c2ecf20Sopenharmony_ci __u64 values; 40728c2ecf20Sopenharmony_ci }; 40738c2ecf20Sopenharmony_ci 40748c2ecf20Sopenharmony_cistart_gfn is the number of the first guest frame whose CMMA values are 40758c2ecf20Sopenharmony_cito be retrieved, 40768c2ecf20Sopenharmony_ci 40778c2ecf20Sopenharmony_cicount is the length of the buffer in bytes, 40788c2ecf20Sopenharmony_ci 40798c2ecf20Sopenharmony_civalues points to the buffer where the result will be written to. 40808c2ecf20Sopenharmony_ci 40818c2ecf20Sopenharmony_ciIf count is greater than KVM_S390_SKEYS_MAX, then it is considered to be 40828c2ecf20Sopenharmony_ciKVM_S390_SKEYS_MAX. KVM_S390_SKEYS_MAX is re-used for consistency with 40838c2ecf20Sopenharmony_ciother ioctls. 40848c2ecf20Sopenharmony_ci 40858c2ecf20Sopenharmony_ciThe result is written in the buffer pointed to by the field values, and 40868c2ecf20Sopenharmony_cithe values of the input parameter are updated as follows. 40878c2ecf20Sopenharmony_ci 40888c2ecf20Sopenharmony_ciDepending on the flags, different actions are performed. The only 40898c2ecf20Sopenharmony_cisupported flag so far is KVM_S390_CMMA_PEEK. 40908c2ecf20Sopenharmony_ci 40918c2ecf20Sopenharmony_ciThe default behaviour if KVM_S390_CMMA_PEEK is not set is: 40928c2ecf20Sopenharmony_cistart_gfn will indicate the first page frame whose CMMA bits were dirty. 40938c2ecf20Sopenharmony_ciIt is not necessarily the same as the one passed as input, as clean pages 40948c2ecf20Sopenharmony_ciare skipped. 40958c2ecf20Sopenharmony_ci 40968c2ecf20Sopenharmony_cicount will indicate the number of bytes actually written in the buffer. 40978c2ecf20Sopenharmony_ciIt can (and very often will) be smaller than the input value, since the 40988c2ecf20Sopenharmony_cibuffer is only filled until 16 bytes of clean values are found (which 40998c2ecf20Sopenharmony_ciare then not copied in the buffer). Since a CMMA migration block needs 41008c2ecf20Sopenharmony_cithe base address and the length, for a total of 16 bytes, we will send 41018c2ecf20Sopenharmony_ciback some clean data if there is some dirty data afterwards, as long as 41028c2ecf20Sopenharmony_cithe size of the clean data does not exceed the size of the header. This 41038c2ecf20Sopenharmony_ciallows to minimize the amount of data to be saved or transferred over 41048c2ecf20Sopenharmony_cithe network at the expense of more roundtrips to userspace. The next 41058c2ecf20Sopenharmony_ciinvocation of the ioctl will skip over all the clean values, saving 41068c2ecf20Sopenharmony_cipotentially more than just the 16 bytes we found. 41078c2ecf20Sopenharmony_ci 41088c2ecf20Sopenharmony_ciIf KVM_S390_CMMA_PEEK is set: 41098c2ecf20Sopenharmony_cithe existing storage attributes are read even when not in migration 41108c2ecf20Sopenharmony_cimode, and no other action is performed; 41118c2ecf20Sopenharmony_ci 41128c2ecf20Sopenharmony_cithe output start_gfn will be equal to the input start_gfn, 41138c2ecf20Sopenharmony_ci 41148c2ecf20Sopenharmony_cithe output count will be equal to the input count, except if the end of 41158c2ecf20Sopenharmony_cimemory has been reached. 41168c2ecf20Sopenharmony_ci 41178c2ecf20Sopenharmony_ciIn both cases: 41188c2ecf20Sopenharmony_cithe field "remaining" will indicate the total number of dirty CMMA values 41198c2ecf20Sopenharmony_cistill remaining, or 0 if KVM_S390_CMMA_PEEK is set and migration mode is 41208c2ecf20Sopenharmony_cinot enabled. 41218c2ecf20Sopenharmony_ci 41228c2ecf20Sopenharmony_cimask is unused. 41238c2ecf20Sopenharmony_ci 41248c2ecf20Sopenharmony_civalues points to the userspace buffer where the result will be stored. 41258c2ecf20Sopenharmony_ci 41268c2ecf20Sopenharmony_ci4.108 KVM_S390_SET_CMMA_BITS 41278c2ecf20Sopenharmony_ci---------------------------- 41288c2ecf20Sopenharmony_ci 41298c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_CMMA_MIGRATION 41308c2ecf20Sopenharmony_ci:Architectures: s390 41318c2ecf20Sopenharmony_ci:Type: vm ioctl 41328c2ecf20Sopenharmony_ci:Parameters: struct kvm_s390_cmma_log (in) 41338c2ecf20Sopenharmony_ci:Returns: 0 on success, a negative value on error 41348c2ecf20Sopenharmony_ci 41358c2ecf20Sopenharmony_ciThis ioctl is used to set the values of the CMMA bits on the s390 41368c2ecf20Sopenharmony_ciarchitecture. It is meant to be used during live migration to restore 41378c2ecf20Sopenharmony_cithe CMMA values, but there are no restrictions on its use. 41388c2ecf20Sopenharmony_ciThe ioctl takes parameters via the kvm_s390_cmma_values struct. 41398c2ecf20Sopenharmony_ciEach CMMA value takes up one byte. 41408c2ecf20Sopenharmony_ci 41418c2ecf20Sopenharmony_ci:: 41428c2ecf20Sopenharmony_ci 41438c2ecf20Sopenharmony_ci struct kvm_s390_cmma_log { 41448c2ecf20Sopenharmony_ci __u64 start_gfn; 41458c2ecf20Sopenharmony_ci __u32 count; 41468c2ecf20Sopenharmony_ci __u32 flags; 41478c2ecf20Sopenharmony_ci union { 41488c2ecf20Sopenharmony_ci __u64 remaining; 41498c2ecf20Sopenharmony_ci __u64 mask; 41508c2ecf20Sopenharmony_ci }; 41518c2ecf20Sopenharmony_ci __u64 values; 41528c2ecf20Sopenharmony_ci }; 41538c2ecf20Sopenharmony_ci 41548c2ecf20Sopenharmony_cistart_gfn indicates the starting guest frame number, 41558c2ecf20Sopenharmony_ci 41568c2ecf20Sopenharmony_cicount indicates how many values are to be considered in the buffer, 41578c2ecf20Sopenharmony_ci 41588c2ecf20Sopenharmony_ciflags is not used and must be 0. 41598c2ecf20Sopenharmony_ci 41608c2ecf20Sopenharmony_cimask indicates which PGSTE bits are to be considered. 41618c2ecf20Sopenharmony_ci 41628c2ecf20Sopenharmony_ciremaining is not used. 41638c2ecf20Sopenharmony_ci 41648c2ecf20Sopenharmony_civalues points to the buffer in userspace where to store the values. 41658c2ecf20Sopenharmony_ci 41668c2ecf20Sopenharmony_ciThis ioctl can fail with -ENOMEM if not enough memory can be allocated to 41678c2ecf20Sopenharmony_cicomplete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if 41688c2ecf20Sopenharmony_cithe count field is too large (e.g. more than KVM_S390_CMMA_SIZE_MAX) or 41698c2ecf20Sopenharmony_ciif the flags field was not 0, with -EFAULT if the userspace address is 41708c2ecf20Sopenharmony_ciinvalid, if invalid pages are written to (e.g. after the end of memory) 41718c2ecf20Sopenharmony_cior if no page table is present for the addresses (e.g. when using 41728c2ecf20Sopenharmony_cihugepages). 41738c2ecf20Sopenharmony_ci 41748c2ecf20Sopenharmony_ci4.109 KVM_PPC_GET_CPU_CHAR 41758c2ecf20Sopenharmony_ci-------------------------- 41768c2ecf20Sopenharmony_ci 41778c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PPC_GET_CPU_CHAR 41788c2ecf20Sopenharmony_ci:Architectures: powerpc 41798c2ecf20Sopenharmony_ci:Type: vm ioctl 41808c2ecf20Sopenharmony_ci:Parameters: struct kvm_ppc_cpu_char (out) 41818c2ecf20Sopenharmony_ci:Returns: 0 on successful completion, 41828c2ecf20Sopenharmony_ci -EFAULT if struct kvm_ppc_cpu_char cannot be written 41838c2ecf20Sopenharmony_ci 41848c2ecf20Sopenharmony_ciThis ioctl gives userspace information about certain characteristics 41858c2ecf20Sopenharmony_ciof the CPU relating to speculative execution of instructions and 41868c2ecf20Sopenharmony_cipossible information leakage resulting from speculative execution (see 41878c2ecf20Sopenharmony_ciCVE-2017-5715, CVE-2017-5753 and CVE-2017-5754). The information is 41888c2ecf20Sopenharmony_cireturned in struct kvm_ppc_cpu_char, which looks like this:: 41898c2ecf20Sopenharmony_ci 41908c2ecf20Sopenharmony_ci struct kvm_ppc_cpu_char { 41918c2ecf20Sopenharmony_ci __u64 character; /* characteristics of the CPU */ 41928c2ecf20Sopenharmony_ci __u64 behaviour; /* recommended software behaviour */ 41938c2ecf20Sopenharmony_ci __u64 character_mask; /* valid bits in character */ 41948c2ecf20Sopenharmony_ci __u64 behaviour_mask; /* valid bits in behaviour */ 41958c2ecf20Sopenharmony_ci }; 41968c2ecf20Sopenharmony_ci 41978c2ecf20Sopenharmony_ciFor extensibility, the character_mask and behaviour_mask fields 41988c2ecf20Sopenharmony_ciindicate which bits of character and behaviour have been filled in by 41998c2ecf20Sopenharmony_cithe kernel. If the set of defined bits is extended in future then 42008c2ecf20Sopenharmony_ciuserspace will be able to tell whether it is running on a kernel that 42018c2ecf20Sopenharmony_ciknows about the new bits. 42028c2ecf20Sopenharmony_ci 42038c2ecf20Sopenharmony_ciThe character field describes attributes of the CPU which can help 42048c2ecf20Sopenharmony_ciwith preventing inadvertent information disclosure - specifically, 42058c2ecf20Sopenharmony_ciwhether there is an instruction to flash-invalidate the L1 data cache 42068c2ecf20Sopenharmony_ci(ori 30,30,0 or mtspr SPRN_TRIG2,rN), whether the L1 data cache is set 42078c2ecf20Sopenharmony_cito a mode where entries can only be used by the thread that created 42088c2ecf20Sopenharmony_cithem, whether the bcctr[l] instruction prevents speculation, and 42098c2ecf20Sopenharmony_ciwhether a speculation barrier instruction (ori 31,31,0) is provided. 42108c2ecf20Sopenharmony_ci 42118c2ecf20Sopenharmony_ciThe behaviour field describes actions that software should take to 42128c2ecf20Sopenharmony_ciprevent inadvertent information disclosure, and thus describes which 42138c2ecf20Sopenharmony_civulnerabilities the hardware is subject to; specifically whether the 42148c2ecf20Sopenharmony_ciL1 data cache should be flushed when returning to user mode from the 42158c2ecf20Sopenharmony_cikernel, and whether a speculation barrier should be placed between an 42168c2ecf20Sopenharmony_ciarray bounds check and the array access. 42178c2ecf20Sopenharmony_ci 42188c2ecf20Sopenharmony_ciThese fields use the same bit definitions as the new 42198c2ecf20Sopenharmony_ciH_GET_CPU_CHARACTERISTICS hypercall. 42208c2ecf20Sopenharmony_ci 42218c2ecf20Sopenharmony_ci4.110 KVM_MEMORY_ENCRYPT_OP 42228c2ecf20Sopenharmony_ci--------------------------- 42238c2ecf20Sopenharmony_ci 42248c2ecf20Sopenharmony_ci:Capability: basic 42258c2ecf20Sopenharmony_ci:Architectures: x86 42268c2ecf20Sopenharmony_ci:Type: vm 42278c2ecf20Sopenharmony_ci:Parameters: an opaque platform specific structure (in/out) 42288c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 42298c2ecf20Sopenharmony_ci 42308c2ecf20Sopenharmony_ciIf the platform supports creating encrypted VMs then this ioctl can be used 42318c2ecf20Sopenharmony_cifor issuing platform-specific memory encryption commands to manage those 42328c2ecf20Sopenharmony_ciencrypted VMs. 42338c2ecf20Sopenharmony_ci 42348c2ecf20Sopenharmony_ciCurrently, this ioctl is used for issuing Secure Encrypted Virtualization 42358c2ecf20Sopenharmony_ci(SEV) commands on AMD Processors. The SEV commands are defined in 42368c2ecf20Sopenharmony_ciDocumentation/virt/kvm/amd-memory-encryption.rst. 42378c2ecf20Sopenharmony_ci 42388c2ecf20Sopenharmony_ci4.111 KVM_MEMORY_ENCRYPT_REG_REGION 42398c2ecf20Sopenharmony_ci----------------------------------- 42408c2ecf20Sopenharmony_ci 42418c2ecf20Sopenharmony_ci:Capability: basic 42428c2ecf20Sopenharmony_ci:Architectures: x86 42438c2ecf20Sopenharmony_ci:Type: system 42448c2ecf20Sopenharmony_ci:Parameters: struct kvm_enc_region (in) 42458c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 42468c2ecf20Sopenharmony_ci 42478c2ecf20Sopenharmony_ciThis ioctl can be used to register a guest memory region which may 42488c2ecf20Sopenharmony_cicontain encrypted data (e.g. guest RAM, SMRAM etc). 42498c2ecf20Sopenharmony_ci 42508c2ecf20Sopenharmony_ciIt is used in the SEV-enabled guest. When encryption is enabled, a guest 42518c2ecf20Sopenharmony_cimemory region may contain encrypted data. The SEV memory encryption 42528c2ecf20Sopenharmony_ciengine uses a tweak such that two identical plaintext pages, each at 42538c2ecf20Sopenharmony_cidifferent locations will have differing ciphertexts. So swapping or 42548c2ecf20Sopenharmony_cimoving ciphertext of those pages will not result in plaintext being 42558c2ecf20Sopenharmony_ciswapped. So relocating (or migrating) physical backing pages for the SEV 42568c2ecf20Sopenharmony_ciguest will require some additional steps. 42578c2ecf20Sopenharmony_ci 42588c2ecf20Sopenharmony_ciNote: The current SEV key management spec does not provide commands to 42598c2ecf20Sopenharmony_ciswap or migrate (move) ciphertext pages. Hence, for now we pin the guest 42608c2ecf20Sopenharmony_cimemory region registered with the ioctl. 42618c2ecf20Sopenharmony_ci 42628c2ecf20Sopenharmony_ci4.112 KVM_MEMORY_ENCRYPT_UNREG_REGION 42638c2ecf20Sopenharmony_ci------------------------------------- 42648c2ecf20Sopenharmony_ci 42658c2ecf20Sopenharmony_ci:Capability: basic 42668c2ecf20Sopenharmony_ci:Architectures: x86 42678c2ecf20Sopenharmony_ci:Type: system 42688c2ecf20Sopenharmony_ci:Parameters: struct kvm_enc_region (in) 42698c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 42708c2ecf20Sopenharmony_ci 42718c2ecf20Sopenharmony_ciThis ioctl can be used to unregister the guest memory region registered 42728c2ecf20Sopenharmony_ciwith KVM_MEMORY_ENCRYPT_REG_REGION ioctl above. 42738c2ecf20Sopenharmony_ci 42748c2ecf20Sopenharmony_ci4.113 KVM_HYPERV_EVENTFD 42758c2ecf20Sopenharmony_ci------------------------ 42768c2ecf20Sopenharmony_ci 42778c2ecf20Sopenharmony_ci:Capability: KVM_CAP_HYPERV_EVENTFD 42788c2ecf20Sopenharmony_ci:Architectures: x86 42798c2ecf20Sopenharmony_ci:Type: vm ioctl 42808c2ecf20Sopenharmony_ci:Parameters: struct kvm_hyperv_eventfd (in) 42818c2ecf20Sopenharmony_ci 42828c2ecf20Sopenharmony_ciThis ioctl (un)registers an eventfd to receive notifications from the guest on 42838c2ecf20Sopenharmony_cithe specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without 42848c2ecf20Sopenharmony_cicausing a user exit. SIGNAL_EVENT hypercall with non-zero event flag number 42858c2ecf20Sopenharmony_ci(bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL user exit. 42868c2ecf20Sopenharmony_ci 42878c2ecf20Sopenharmony_ci:: 42888c2ecf20Sopenharmony_ci 42898c2ecf20Sopenharmony_ci struct kvm_hyperv_eventfd { 42908c2ecf20Sopenharmony_ci __u32 conn_id; 42918c2ecf20Sopenharmony_ci __s32 fd; 42928c2ecf20Sopenharmony_ci __u32 flags; 42938c2ecf20Sopenharmony_ci __u32 padding[3]; 42948c2ecf20Sopenharmony_ci }; 42958c2ecf20Sopenharmony_ci 42968c2ecf20Sopenharmony_ciThe conn_id field should fit within 24 bits:: 42978c2ecf20Sopenharmony_ci 42988c2ecf20Sopenharmony_ci #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff 42998c2ecf20Sopenharmony_ci 43008c2ecf20Sopenharmony_ciThe acceptable values for the flags field are:: 43018c2ecf20Sopenharmony_ci 43028c2ecf20Sopenharmony_ci #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) 43038c2ecf20Sopenharmony_ci 43048c2ecf20Sopenharmony_ci:Returns: 0 on success, 43058c2ecf20Sopenharmony_ci -EINVAL if conn_id or flags is outside the allowed range, 43068c2ecf20Sopenharmony_ci -ENOENT on deassign if the conn_id isn't registered, 43078c2ecf20Sopenharmony_ci -EEXIST on assign if the conn_id is already registered 43088c2ecf20Sopenharmony_ci 43098c2ecf20Sopenharmony_ci4.114 KVM_GET_NESTED_STATE 43108c2ecf20Sopenharmony_ci-------------------------- 43118c2ecf20Sopenharmony_ci 43128c2ecf20Sopenharmony_ci:Capability: KVM_CAP_NESTED_STATE 43138c2ecf20Sopenharmony_ci:Architectures: x86 43148c2ecf20Sopenharmony_ci:Type: vcpu ioctl 43158c2ecf20Sopenharmony_ci:Parameters: struct kvm_nested_state (in/out) 43168c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 43178c2ecf20Sopenharmony_ci 43188c2ecf20Sopenharmony_ciErrors: 43198c2ecf20Sopenharmony_ci 43208c2ecf20Sopenharmony_ci ===== ============================================================= 43218c2ecf20Sopenharmony_ci E2BIG the total state size exceeds the value of 'size' specified by 43228c2ecf20Sopenharmony_ci the user; the size required will be written into size. 43238c2ecf20Sopenharmony_ci ===== ============================================================= 43248c2ecf20Sopenharmony_ci 43258c2ecf20Sopenharmony_ci:: 43268c2ecf20Sopenharmony_ci 43278c2ecf20Sopenharmony_ci struct kvm_nested_state { 43288c2ecf20Sopenharmony_ci __u16 flags; 43298c2ecf20Sopenharmony_ci __u16 format; 43308c2ecf20Sopenharmony_ci __u32 size; 43318c2ecf20Sopenharmony_ci 43328c2ecf20Sopenharmony_ci union { 43338c2ecf20Sopenharmony_ci struct kvm_vmx_nested_state_hdr vmx; 43348c2ecf20Sopenharmony_ci struct kvm_svm_nested_state_hdr svm; 43358c2ecf20Sopenharmony_ci 43368c2ecf20Sopenharmony_ci /* Pad the header to 128 bytes. */ 43378c2ecf20Sopenharmony_ci __u8 pad[120]; 43388c2ecf20Sopenharmony_ci } hdr; 43398c2ecf20Sopenharmony_ci 43408c2ecf20Sopenharmony_ci union { 43418c2ecf20Sopenharmony_ci struct kvm_vmx_nested_state_data vmx[0]; 43428c2ecf20Sopenharmony_ci struct kvm_svm_nested_state_data svm[0]; 43438c2ecf20Sopenharmony_ci } data; 43448c2ecf20Sopenharmony_ci }; 43458c2ecf20Sopenharmony_ci 43468c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 43478c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 43488c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_EVMCS 0x00000004 43498c2ecf20Sopenharmony_ci 43508c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_FORMAT_VMX 0 43518c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_FORMAT_SVM 1 43528c2ecf20Sopenharmony_ci 43538c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 43548c2ecf20Sopenharmony_ci 43558c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_VMX_SMM_GUEST_MODE 0x00000001 43568c2ecf20Sopenharmony_ci #define KVM_STATE_NESTED_VMX_SMM_VMXON 0x00000002 43578c2ecf20Sopenharmony_ci 43588c2ecf20Sopenharmony_ci #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 43598c2ecf20Sopenharmony_ci 43608c2ecf20Sopenharmony_ci struct kvm_vmx_nested_state_hdr { 43618c2ecf20Sopenharmony_ci __u64 vmxon_pa; 43628c2ecf20Sopenharmony_ci __u64 vmcs12_pa; 43638c2ecf20Sopenharmony_ci 43648c2ecf20Sopenharmony_ci struct { 43658c2ecf20Sopenharmony_ci __u16 flags; 43668c2ecf20Sopenharmony_ci } smm; 43678c2ecf20Sopenharmony_ci 43688c2ecf20Sopenharmony_ci __u32 flags; 43698c2ecf20Sopenharmony_ci __u64 preemption_timer_deadline; 43708c2ecf20Sopenharmony_ci }; 43718c2ecf20Sopenharmony_ci 43728c2ecf20Sopenharmony_ci struct kvm_vmx_nested_state_data { 43738c2ecf20Sopenharmony_ci __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 43748c2ecf20Sopenharmony_ci __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 43758c2ecf20Sopenharmony_ci }; 43768c2ecf20Sopenharmony_ci 43778c2ecf20Sopenharmony_ciThis ioctl copies the vcpu's nested virtualization state from the kernel to 43788c2ecf20Sopenharmony_ciuserspace. 43798c2ecf20Sopenharmony_ci 43808c2ecf20Sopenharmony_ciThe maximum size of the state can be retrieved by passing KVM_CAP_NESTED_STATE 43818c2ecf20Sopenharmony_cito the KVM_CHECK_EXTENSION ioctl(). 43828c2ecf20Sopenharmony_ci 43838c2ecf20Sopenharmony_ci4.115 KVM_SET_NESTED_STATE 43848c2ecf20Sopenharmony_ci-------------------------- 43858c2ecf20Sopenharmony_ci 43868c2ecf20Sopenharmony_ci:Capability: KVM_CAP_NESTED_STATE 43878c2ecf20Sopenharmony_ci:Architectures: x86 43888c2ecf20Sopenharmony_ci:Type: vcpu ioctl 43898c2ecf20Sopenharmony_ci:Parameters: struct kvm_nested_state (in) 43908c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 43918c2ecf20Sopenharmony_ci 43928c2ecf20Sopenharmony_ciThis copies the vcpu's kvm_nested_state struct from userspace to the kernel. 43938c2ecf20Sopenharmony_ciFor the definition of struct kvm_nested_state, see KVM_GET_NESTED_STATE. 43948c2ecf20Sopenharmony_ci 43958c2ecf20Sopenharmony_ci4.116 KVM_(UN)REGISTER_COALESCED_MMIO 43968c2ecf20Sopenharmony_ci------------------------------------- 43978c2ecf20Sopenharmony_ci 43988c2ecf20Sopenharmony_ci:Capability: KVM_CAP_COALESCED_MMIO (for coalesced mmio) 43998c2ecf20Sopenharmony_ci KVM_CAP_COALESCED_PIO (for coalesced pio) 44008c2ecf20Sopenharmony_ci:Architectures: all 44018c2ecf20Sopenharmony_ci:Type: vm ioctl 44028c2ecf20Sopenharmony_ci:Parameters: struct kvm_coalesced_mmio_zone 44038c2ecf20Sopenharmony_ci:Returns: 0 on success, < 0 on error 44048c2ecf20Sopenharmony_ci 44058c2ecf20Sopenharmony_ciCoalesced I/O is a performance optimization that defers hardware 44068c2ecf20Sopenharmony_ciregister write emulation so that userspace exits are avoided. It is 44078c2ecf20Sopenharmony_citypically used to reduce the overhead of emulating frequently accessed 44088c2ecf20Sopenharmony_cihardware registers. 44098c2ecf20Sopenharmony_ci 44108c2ecf20Sopenharmony_ciWhen a hardware register is configured for coalesced I/O, write accesses 44118c2ecf20Sopenharmony_cido not exit to userspace and their value is recorded in a ring buffer 44128c2ecf20Sopenharmony_cithat is shared between kernel and userspace. 44138c2ecf20Sopenharmony_ci 44148c2ecf20Sopenharmony_ciCoalesced I/O is used if one or more write accesses to a hardware 44158c2ecf20Sopenharmony_ciregister can be deferred until a read or a write to another hardware 44168c2ecf20Sopenharmony_ciregister on the same device. This last access will cause a vmexit and 44178c2ecf20Sopenharmony_ciuserspace will process accesses from the ring buffer before emulating 44188c2ecf20Sopenharmony_ciit. That will avoid exiting to userspace on repeated writes. 44198c2ecf20Sopenharmony_ci 44208c2ecf20Sopenharmony_ciCoalesced pio is based on coalesced mmio. There is little difference 44218c2ecf20Sopenharmony_cibetween coalesced mmio and pio except that coalesced pio records accesses 44228c2ecf20Sopenharmony_cito I/O ports. 44238c2ecf20Sopenharmony_ci 44248c2ecf20Sopenharmony_ci4.117 KVM_CLEAR_DIRTY_LOG (vm ioctl) 44258c2ecf20Sopenharmony_ci------------------------------------ 44268c2ecf20Sopenharmony_ci 44278c2ecf20Sopenharmony_ci:Capability: KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 44288c2ecf20Sopenharmony_ci:Architectures: x86, arm, arm64, mips 44298c2ecf20Sopenharmony_ci:Type: vm ioctl 44308c2ecf20Sopenharmony_ci:Parameters: struct kvm_dirty_log (in) 44318c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 44328c2ecf20Sopenharmony_ci 44338c2ecf20Sopenharmony_ci:: 44348c2ecf20Sopenharmony_ci 44358c2ecf20Sopenharmony_ci /* for KVM_CLEAR_DIRTY_LOG */ 44368c2ecf20Sopenharmony_ci struct kvm_clear_dirty_log { 44378c2ecf20Sopenharmony_ci __u32 slot; 44388c2ecf20Sopenharmony_ci __u32 num_pages; 44398c2ecf20Sopenharmony_ci __u64 first_page; 44408c2ecf20Sopenharmony_ci union { 44418c2ecf20Sopenharmony_ci void __user *dirty_bitmap; /* one bit per page */ 44428c2ecf20Sopenharmony_ci __u64 padding; 44438c2ecf20Sopenharmony_ci }; 44448c2ecf20Sopenharmony_ci }; 44458c2ecf20Sopenharmony_ci 44468c2ecf20Sopenharmony_ciThe ioctl clears the dirty status of pages in a memory slot, according to 44478c2ecf20Sopenharmony_cithe bitmap that is passed in struct kvm_clear_dirty_log's dirty_bitmap 44488c2ecf20Sopenharmony_cifield. Bit 0 of the bitmap corresponds to page "first_page" in the 44498c2ecf20Sopenharmony_cimemory slot, and num_pages is the size in bits of the input bitmap. 44508c2ecf20Sopenharmony_cifirst_page must be a multiple of 64; num_pages must also be a multiple of 44518c2ecf20Sopenharmony_ci64 unless first_page + num_pages is the size of the memory slot. For each 44528c2ecf20Sopenharmony_cibit that is set in the input bitmap, the corresponding page is marked "clean" 44538c2ecf20Sopenharmony_ciin KVM's dirty bitmap, and dirty tracking is re-enabled for that page 44548c2ecf20Sopenharmony_ci(for example via write-protection, or by clearing the dirty bit in 44558c2ecf20Sopenharmony_cia page table entry). 44568c2ecf20Sopenharmony_ci 44578c2ecf20Sopenharmony_ciIf KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies 44588c2ecf20Sopenharmony_cithe address space for which you want to return the dirty bitmap. 44598c2ecf20Sopenharmony_ciThey must be less than the value that KVM_CHECK_EXTENSION returns for 44608c2ecf20Sopenharmony_cithe KVM_CAP_MULTI_ADDRESS_SPACE capability. 44618c2ecf20Sopenharmony_ci 44628c2ecf20Sopenharmony_ciThis ioctl is mostly useful when KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 44638c2ecf20Sopenharmony_ciis enabled; for more information, see the description of the capability. 44648c2ecf20Sopenharmony_ciHowever, it can always be used as long as KVM_CHECK_EXTENSION confirms 44658c2ecf20Sopenharmony_cithat KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is present. 44668c2ecf20Sopenharmony_ci 44678c2ecf20Sopenharmony_ci4.118 KVM_GET_SUPPORTED_HV_CPUID 44688c2ecf20Sopenharmony_ci-------------------------------- 44698c2ecf20Sopenharmony_ci 44708c2ecf20Sopenharmony_ci:Capability: KVM_CAP_HYPERV_CPUID 44718c2ecf20Sopenharmony_ci:Architectures: x86 44728c2ecf20Sopenharmony_ci:Type: vcpu ioctl 44738c2ecf20Sopenharmony_ci:Parameters: struct kvm_cpuid2 (in/out) 44748c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 44758c2ecf20Sopenharmony_ci 44768c2ecf20Sopenharmony_ci:: 44778c2ecf20Sopenharmony_ci 44788c2ecf20Sopenharmony_ci struct kvm_cpuid2 { 44798c2ecf20Sopenharmony_ci __u32 nent; 44808c2ecf20Sopenharmony_ci __u32 padding; 44818c2ecf20Sopenharmony_ci struct kvm_cpuid_entry2 entries[0]; 44828c2ecf20Sopenharmony_ci }; 44838c2ecf20Sopenharmony_ci 44848c2ecf20Sopenharmony_ci struct kvm_cpuid_entry2 { 44858c2ecf20Sopenharmony_ci __u32 function; 44868c2ecf20Sopenharmony_ci __u32 index; 44878c2ecf20Sopenharmony_ci __u32 flags; 44888c2ecf20Sopenharmony_ci __u32 eax; 44898c2ecf20Sopenharmony_ci __u32 ebx; 44908c2ecf20Sopenharmony_ci __u32 ecx; 44918c2ecf20Sopenharmony_ci __u32 edx; 44928c2ecf20Sopenharmony_ci __u32 padding[3]; 44938c2ecf20Sopenharmony_ci }; 44948c2ecf20Sopenharmony_ci 44958c2ecf20Sopenharmony_ciThis ioctl returns x86 cpuid features leaves related to Hyper-V emulation in 44968c2ecf20Sopenharmony_ciKVM. Userspace can use the information returned by this ioctl to construct 44978c2ecf20Sopenharmony_cicpuid information presented to guests consuming Hyper-V enlightenments (e.g. 44988c2ecf20Sopenharmony_ciWindows or Hyper-V guests). 44998c2ecf20Sopenharmony_ci 45008c2ecf20Sopenharmony_ciCPUID feature leaves returned by this ioctl are defined by Hyper-V Top Level 45018c2ecf20Sopenharmony_ciFunctional Specification (TLFS). These leaves can't be obtained with 45028c2ecf20Sopenharmony_ciKVM_GET_SUPPORTED_CPUID ioctl because some of them intersect with KVM feature 45038c2ecf20Sopenharmony_cileaves (0x40000000, 0x40000001). 45048c2ecf20Sopenharmony_ci 45058c2ecf20Sopenharmony_ciCurrently, the following list of CPUID leaves are returned: 45068c2ecf20Sopenharmony_ci - HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS 45078c2ecf20Sopenharmony_ci - HYPERV_CPUID_INTERFACE 45088c2ecf20Sopenharmony_ci - HYPERV_CPUID_VERSION 45098c2ecf20Sopenharmony_ci - HYPERV_CPUID_FEATURES 45108c2ecf20Sopenharmony_ci - HYPERV_CPUID_ENLIGHTMENT_INFO 45118c2ecf20Sopenharmony_ci - HYPERV_CPUID_IMPLEMENT_LIMITS 45128c2ecf20Sopenharmony_ci - HYPERV_CPUID_NESTED_FEATURES 45138c2ecf20Sopenharmony_ci - HYPERV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS 45148c2ecf20Sopenharmony_ci - HYPERV_CPUID_SYNDBG_INTERFACE 45158c2ecf20Sopenharmony_ci - HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES 45168c2ecf20Sopenharmony_ci 45178c2ecf20Sopenharmony_ciHYPERV_CPUID_NESTED_FEATURES leaf is only exposed when Enlightened VMCS was 45188c2ecf20Sopenharmony_cienabled on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS). 45198c2ecf20Sopenharmony_ci 45208c2ecf20Sopenharmony_ciUserspace invokes KVM_GET_SUPPORTED_HV_CPUID by passing a kvm_cpuid2 structure 45218c2ecf20Sopenharmony_ciwith the 'nent' field indicating the number of entries in the variable-size 45228c2ecf20Sopenharmony_ciarray 'entries'. If the number of entries is too low to describe all Hyper-V 45238c2ecf20Sopenharmony_cifeature leaves, an error (E2BIG) is returned. If the number is more or equal 45248c2ecf20Sopenharmony_cito the number of Hyper-V feature leaves, the 'nent' field is adjusted to the 45258c2ecf20Sopenharmony_cinumber of valid entries in the 'entries' array, which is then filled. 45268c2ecf20Sopenharmony_ci 45278c2ecf20Sopenharmony_ci'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved, 45288c2ecf20Sopenharmony_ciuserspace should not expect to get any particular value there. 45298c2ecf20Sopenharmony_ci 45308c2ecf20Sopenharmony_ci4.119 KVM_ARM_VCPU_FINALIZE 45318c2ecf20Sopenharmony_ci--------------------------- 45328c2ecf20Sopenharmony_ci 45338c2ecf20Sopenharmony_ci:Architectures: arm, arm64 45348c2ecf20Sopenharmony_ci:Type: vcpu ioctl 45358c2ecf20Sopenharmony_ci:Parameters: int feature (in) 45368c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 45378c2ecf20Sopenharmony_ci 45388c2ecf20Sopenharmony_ciErrors: 45398c2ecf20Sopenharmony_ci 45408c2ecf20Sopenharmony_ci ====== ============================================================== 45418c2ecf20Sopenharmony_ci EPERM feature not enabled, needs configuration, or already finalized 45428c2ecf20Sopenharmony_ci EINVAL feature unknown or not present 45438c2ecf20Sopenharmony_ci ====== ============================================================== 45448c2ecf20Sopenharmony_ci 45458c2ecf20Sopenharmony_ciRecognised values for feature: 45468c2ecf20Sopenharmony_ci 45478c2ecf20Sopenharmony_ci ===== =========================================== 45488c2ecf20Sopenharmony_ci arm64 KVM_ARM_VCPU_SVE (requires KVM_CAP_ARM_SVE) 45498c2ecf20Sopenharmony_ci ===== =========================================== 45508c2ecf20Sopenharmony_ci 45518c2ecf20Sopenharmony_ciFinalizes the configuration of the specified vcpu feature. 45528c2ecf20Sopenharmony_ci 45538c2ecf20Sopenharmony_ciThe vcpu must already have been initialised, enabling the affected feature, by 45548c2ecf20Sopenharmony_cimeans of a successful KVM_ARM_VCPU_INIT call with the appropriate flag set in 45558c2ecf20Sopenharmony_cifeatures[]. 45568c2ecf20Sopenharmony_ci 45578c2ecf20Sopenharmony_ciFor affected vcpu features, this is a mandatory step that must be performed 45588c2ecf20Sopenharmony_cibefore the vcpu is fully usable. 45598c2ecf20Sopenharmony_ci 45608c2ecf20Sopenharmony_ciBetween KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE, the feature may be 45618c2ecf20Sopenharmony_ciconfigured by use of ioctls such as KVM_SET_ONE_REG. The exact configuration 45628c2ecf20Sopenharmony_cithat should be performaned and how to do it are feature-dependent. 45638c2ecf20Sopenharmony_ci 45648c2ecf20Sopenharmony_ciOther calls that depend on a particular feature being finalized, such as 45658c2ecf20Sopenharmony_ciKVM_RUN, KVM_GET_REG_LIST, KVM_GET_ONE_REG and KVM_SET_ONE_REG, will fail with 45668c2ecf20Sopenharmony_ci-EPERM unless the feature has already been finalized by means of a 45678c2ecf20Sopenharmony_ciKVM_ARM_VCPU_FINALIZE call. 45688c2ecf20Sopenharmony_ci 45698c2ecf20Sopenharmony_ciSee KVM_ARM_VCPU_INIT for details of vcpu features that require finalization 45708c2ecf20Sopenharmony_ciusing this ioctl. 45718c2ecf20Sopenharmony_ci 45728c2ecf20Sopenharmony_ci4.120 KVM_SET_PMU_EVENT_FILTER 45738c2ecf20Sopenharmony_ci------------------------------ 45748c2ecf20Sopenharmony_ci 45758c2ecf20Sopenharmony_ci:Capability: KVM_CAP_PMU_EVENT_FILTER 45768c2ecf20Sopenharmony_ci:Architectures: x86 45778c2ecf20Sopenharmony_ci:Type: vm ioctl 45788c2ecf20Sopenharmony_ci:Parameters: struct kvm_pmu_event_filter (in) 45798c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 45808c2ecf20Sopenharmony_ci 45818c2ecf20Sopenharmony_ci:: 45828c2ecf20Sopenharmony_ci 45838c2ecf20Sopenharmony_ci struct kvm_pmu_event_filter { 45848c2ecf20Sopenharmony_ci __u32 action; 45858c2ecf20Sopenharmony_ci __u32 nevents; 45868c2ecf20Sopenharmony_ci __u32 fixed_counter_bitmap; 45878c2ecf20Sopenharmony_ci __u32 flags; 45888c2ecf20Sopenharmony_ci __u32 pad[4]; 45898c2ecf20Sopenharmony_ci __u64 events[0]; 45908c2ecf20Sopenharmony_ci }; 45918c2ecf20Sopenharmony_ci 45928c2ecf20Sopenharmony_ciThis ioctl restricts the set of PMU events that the guest can program. 45938c2ecf20Sopenharmony_ciThe argument holds a list of events which will be allowed or denied. 45948c2ecf20Sopenharmony_ciThe eventsel+umask of each event the guest attempts to program is compared 45958c2ecf20Sopenharmony_ciagainst the events field to determine whether the guest should have access. 45968c2ecf20Sopenharmony_ciThe events field only controls general purpose counters; fixed purpose 45978c2ecf20Sopenharmony_cicounters are controlled by the fixed_counter_bitmap. 45988c2ecf20Sopenharmony_ci 45998c2ecf20Sopenharmony_ciNo flags are defined yet, the field must be zero. 46008c2ecf20Sopenharmony_ci 46018c2ecf20Sopenharmony_ciValid values for 'action':: 46028c2ecf20Sopenharmony_ci 46038c2ecf20Sopenharmony_ci #define KVM_PMU_EVENT_ALLOW 0 46048c2ecf20Sopenharmony_ci #define KVM_PMU_EVENT_DENY 1 46058c2ecf20Sopenharmony_ci 46068c2ecf20Sopenharmony_ci4.121 KVM_PPC_SVM_OFF 46078c2ecf20Sopenharmony_ci--------------------- 46088c2ecf20Sopenharmony_ci 46098c2ecf20Sopenharmony_ci:Capability: basic 46108c2ecf20Sopenharmony_ci:Architectures: powerpc 46118c2ecf20Sopenharmony_ci:Type: vm ioctl 46128c2ecf20Sopenharmony_ci:Parameters: none 46138c2ecf20Sopenharmony_ci:Returns: 0 on successful completion, 46148c2ecf20Sopenharmony_ci 46158c2ecf20Sopenharmony_ciErrors: 46168c2ecf20Sopenharmony_ci 46178c2ecf20Sopenharmony_ci ====== ================================================================ 46188c2ecf20Sopenharmony_ci EINVAL if ultravisor failed to terminate the secure guest 46198c2ecf20Sopenharmony_ci ENOMEM if hypervisor failed to allocate new radix page tables for guest 46208c2ecf20Sopenharmony_ci ====== ================================================================ 46218c2ecf20Sopenharmony_ci 46228c2ecf20Sopenharmony_ciThis ioctl is used to turn off the secure mode of the guest or transition 46238c2ecf20Sopenharmony_cithe guest from secure mode to normal mode. This is invoked when the guest 46248c2ecf20Sopenharmony_ciis reset. This has no effect if called for a normal guest. 46258c2ecf20Sopenharmony_ci 46268c2ecf20Sopenharmony_ciThis ioctl issues an ultravisor call to terminate the secure guest, 46278c2ecf20Sopenharmony_ciunpins the VPA pages and releases all the device pages that are used to 46288c2ecf20Sopenharmony_citrack the secure pages by hypervisor. 46298c2ecf20Sopenharmony_ci 46308c2ecf20Sopenharmony_ci4.122 KVM_S390_NORMAL_RESET 46318c2ecf20Sopenharmony_ci--------------------------- 46328c2ecf20Sopenharmony_ci 46338c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_VCPU_RESETS 46348c2ecf20Sopenharmony_ci:Architectures: s390 46358c2ecf20Sopenharmony_ci:Type: vcpu ioctl 46368c2ecf20Sopenharmony_ci:Parameters: none 46378c2ecf20Sopenharmony_ci:Returns: 0 46388c2ecf20Sopenharmony_ci 46398c2ecf20Sopenharmony_ciThis ioctl resets VCPU registers and control structures according to 46408c2ecf20Sopenharmony_cithe cpu reset definition in the POP (Principles Of Operation). 46418c2ecf20Sopenharmony_ci 46428c2ecf20Sopenharmony_ci4.123 KVM_S390_INITIAL_RESET 46438c2ecf20Sopenharmony_ci---------------------------- 46448c2ecf20Sopenharmony_ci 46458c2ecf20Sopenharmony_ci:Capability: none 46468c2ecf20Sopenharmony_ci:Architectures: s390 46478c2ecf20Sopenharmony_ci:Type: vcpu ioctl 46488c2ecf20Sopenharmony_ci:Parameters: none 46498c2ecf20Sopenharmony_ci:Returns: 0 46508c2ecf20Sopenharmony_ci 46518c2ecf20Sopenharmony_ciThis ioctl resets VCPU registers and control structures according to 46528c2ecf20Sopenharmony_cithe initial cpu reset definition in the POP. However, the cpu is not 46538c2ecf20Sopenharmony_ciput into ESA mode. This reset is a superset of the normal reset. 46548c2ecf20Sopenharmony_ci 46558c2ecf20Sopenharmony_ci4.124 KVM_S390_CLEAR_RESET 46568c2ecf20Sopenharmony_ci-------------------------- 46578c2ecf20Sopenharmony_ci 46588c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_VCPU_RESETS 46598c2ecf20Sopenharmony_ci:Architectures: s390 46608c2ecf20Sopenharmony_ci:Type: vcpu ioctl 46618c2ecf20Sopenharmony_ci:Parameters: none 46628c2ecf20Sopenharmony_ci:Returns: 0 46638c2ecf20Sopenharmony_ci 46648c2ecf20Sopenharmony_ciThis ioctl resets VCPU registers and control structures according to 46658c2ecf20Sopenharmony_cithe clear cpu reset definition in the POP. However, the cpu is not put 46668c2ecf20Sopenharmony_ciinto ESA mode. This reset is a superset of the initial reset. 46678c2ecf20Sopenharmony_ci 46688c2ecf20Sopenharmony_ci 46698c2ecf20Sopenharmony_ci4.125 KVM_S390_PV_COMMAND 46708c2ecf20Sopenharmony_ci------------------------- 46718c2ecf20Sopenharmony_ci 46728c2ecf20Sopenharmony_ci:Capability: KVM_CAP_S390_PROTECTED 46738c2ecf20Sopenharmony_ci:Architectures: s390 46748c2ecf20Sopenharmony_ci:Type: vm ioctl 46758c2ecf20Sopenharmony_ci:Parameters: struct kvm_pv_cmd 46768c2ecf20Sopenharmony_ci:Returns: 0 on success, < 0 on error 46778c2ecf20Sopenharmony_ci 46788c2ecf20Sopenharmony_ci:: 46798c2ecf20Sopenharmony_ci 46808c2ecf20Sopenharmony_ci struct kvm_pv_cmd { 46818c2ecf20Sopenharmony_ci __u32 cmd; /* Command to be executed */ 46828c2ecf20Sopenharmony_ci __u16 rc; /* Ultravisor return code */ 46838c2ecf20Sopenharmony_ci __u16 rrc; /* Ultravisor return reason code */ 46848c2ecf20Sopenharmony_ci __u64 data; /* Data or address */ 46858c2ecf20Sopenharmony_ci __u32 flags; /* flags for future extensions. Must be 0 for now */ 46868c2ecf20Sopenharmony_ci __u32 reserved[3]; 46878c2ecf20Sopenharmony_ci }; 46888c2ecf20Sopenharmony_ci 46898c2ecf20Sopenharmony_cicmd values: 46908c2ecf20Sopenharmony_ci 46918c2ecf20Sopenharmony_ciKVM_PV_ENABLE 46928c2ecf20Sopenharmony_ci Allocate memory and register the VM with the Ultravisor, thereby 46938c2ecf20Sopenharmony_ci donating memory to the Ultravisor that will become inaccessible to 46948c2ecf20Sopenharmony_ci KVM. All existing CPUs are converted to protected ones. After this 46958c2ecf20Sopenharmony_ci command has succeeded, any CPU added via hotplug will become 46968c2ecf20Sopenharmony_ci protected during its creation as well. 46978c2ecf20Sopenharmony_ci 46988c2ecf20Sopenharmony_ci Errors: 46998c2ecf20Sopenharmony_ci 47008c2ecf20Sopenharmony_ci ===== ============================= 47018c2ecf20Sopenharmony_ci EINTR an unmasked signal is pending 47028c2ecf20Sopenharmony_ci ===== ============================= 47038c2ecf20Sopenharmony_ci 47048c2ecf20Sopenharmony_ciKVM_PV_DISABLE 47058c2ecf20Sopenharmony_ci 47068c2ecf20Sopenharmony_ci Deregister the VM from the Ultravisor and reclaim the memory that 47078c2ecf20Sopenharmony_ci had been donated to the Ultravisor, making it usable by the kernel 47088c2ecf20Sopenharmony_ci again. All registered VCPUs are converted back to non-protected 47098c2ecf20Sopenharmony_ci ones. 47108c2ecf20Sopenharmony_ci 47118c2ecf20Sopenharmony_ciKVM_PV_VM_SET_SEC_PARMS 47128c2ecf20Sopenharmony_ci Pass the image header from VM memory to the Ultravisor in 47138c2ecf20Sopenharmony_ci preparation of image unpacking and verification. 47148c2ecf20Sopenharmony_ci 47158c2ecf20Sopenharmony_ciKVM_PV_VM_UNPACK 47168c2ecf20Sopenharmony_ci Unpack (protect and decrypt) a page of the encrypted boot image. 47178c2ecf20Sopenharmony_ci 47188c2ecf20Sopenharmony_ciKVM_PV_VM_VERIFY 47198c2ecf20Sopenharmony_ci Verify the integrity of the unpacked image. Only if this succeeds, 47208c2ecf20Sopenharmony_ci KVM is allowed to start protected VCPUs. 47218c2ecf20Sopenharmony_ci 47228c2ecf20Sopenharmony_ci4.126 KVM_X86_SET_MSR_FILTER 47238c2ecf20Sopenharmony_ci---------------------------- 47248c2ecf20Sopenharmony_ci 47258c2ecf20Sopenharmony_ci:Capability: KVM_X86_SET_MSR_FILTER 47268c2ecf20Sopenharmony_ci:Architectures: x86 47278c2ecf20Sopenharmony_ci:Type: vm ioctl 47288c2ecf20Sopenharmony_ci:Parameters: struct kvm_msr_filter 47298c2ecf20Sopenharmony_ci:Returns: 0 on success, < 0 on error 47308c2ecf20Sopenharmony_ci 47318c2ecf20Sopenharmony_ci:: 47328c2ecf20Sopenharmony_ci 47338c2ecf20Sopenharmony_ci struct kvm_msr_filter_range { 47348c2ecf20Sopenharmony_ci #define KVM_MSR_FILTER_READ (1 << 0) 47358c2ecf20Sopenharmony_ci #define KVM_MSR_FILTER_WRITE (1 << 1) 47368c2ecf20Sopenharmony_ci __u32 flags; 47378c2ecf20Sopenharmony_ci __u32 nmsrs; /* number of msrs in bitmap */ 47388c2ecf20Sopenharmony_ci __u32 base; /* MSR index the bitmap starts at */ 47398c2ecf20Sopenharmony_ci __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */ 47408c2ecf20Sopenharmony_ci }; 47418c2ecf20Sopenharmony_ci 47428c2ecf20Sopenharmony_ci #define KVM_MSR_FILTER_MAX_RANGES 16 47438c2ecf20Sopenharmony_ci struct kvm_msr_filter { 47448c2ecf20Sopenharmony_ci #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0) 47458c2ecf20Sopenharmony_ci #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0) 47468c2ecf20Sopenharmony_ci __u32 flags; 47478c2ecf20Sopenharmony_ci struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES]; 47488c2ecf20Sopenharmony_ci }; 47498c2ecf20Sopenharmony_ci 47508c2ecf20Sopenharmony_ciflags values for ``struct kvm_msr_filter_range``: 47518c2ecf20Sopenharmony_ci 47528c2ecf20Sopenharmony_ci``KVM_MSR_FILTER_READ`` 47538c2ecf20Sopenharmony_ci 47548c2ecf20Sopenharmony_ci Filter read accesses to MSRs using the given bitmap. A 0 in the bitmap 47558c2ecf20Sopenharmony_ci indicates that a read should immediately fail, while a 1 indicates that 47568c2ecf20Sopenharmony_ci a read for a particular MSR should be handled regardless of the default 47578c2ecf20Sopenharmony_ci filter action. 47588c2ecf20Sopenharmony_ci 47598c2ecf20Sopenharmony_ci``KVM_MSR_FILTER_WRITE`` 47608c2ecf20Sopenharmony_ci 47618c2ecf20Sopenharmony_ci Filter write accesses to MSRs using the given bitmap. A 0 in the bitmap 47628c2ecf20Sopenharmony_ci indicates that a write should immediately fail, while a 1 indicates that 47638c2ecf20Sopenharmony_ci a write for a particular MSR should be handled regardless of the default 47648c2ecf20Sopenharmony_ci filter action. 47658c2ecf20Sopenharmony_ci 47668c2ecf20Sopenharmony_ci``KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE`` 47678c2ecf20Sopenharmony_ci 47688c2ecf20Sopenharmony_ci Filter both read and write accesses to MSRs using the given bitmap. A 0 47698c2ecf20Sopenharmony_ci in the bitmap indicates that both reads and writes should immediately fail, 47708c2ecf20Sopenharmony_ci while a 1 indicates that reads and writes for a particular MSR are not 47718c2ecf20Sopenharmony_ci filtered by this range. 47728c2ecf20Sopenharmony_ci 47738c2ecf20Sopenharmony_ciflags values for ``struct kvm_msr_filter``: 47748c2ecf20Sopenharmony_ci 47758c2ecf20Sopenharmony_ci``KVM_MSR_FILTER_DEFAULT_ALLOW`` 47768c2ecf20Sopenharmony_ci 47778c2ecf20Sopenharmony_ci If no filter range matches an MSR index that is getting accessed, KVM will 47788c2ecf20Sopenharmony_ci fall back to allowing access to the MSR. 47798c2ecf20Sopenharmony_ci 47808c2ecf20Sopenharmony_ci``KVM_MSR_FILTER_DEFAULT_DENY`` 47818c2ecf20Sopenharmony_ci 47828c2ecf20Sopenharmony_ci If no filter range matches an MSR index that is getting accessed, KVM will 47838c2ecf20Sopenharmony_ci fall back to rejecting access to the MSR. In this mode, all MSRs that should 47848c2ecf20Sopenharmony_ci be processed by KVM need to explicitly be marked as allowed in the bitmaps. 47858c2ecf20Sopenharmony_ci 47868c2ecf20Sopenharmony_ciThis ioctl allows user space to define up to 16 bitmaps of MSR ranges to 47878c2ecf20Sopenharmony_cispecify whether a certain MSR access should be explicitly filtered for or not. 47888c2ecf20Sopenharmony_ci 47898c2ecf20Sopenharmony_ciIf this ioctl has never been invoked, MSR accesses are not guarded and the 47908c2ecf20Sopenharmony_cidefault KVM in-kernel emulation behavior is fully preserved. 47918c2ecf20Sopenharmony_ci 47928c2ecf20Sopenharmony_ciCalling this ioctl with an empty set of ranges (all nmsrs == 0) disables MSR 47938c2ecf20Sopenharmony_cifiltering. In that mode, ``KVM_MSR_FILTER_DEFAULT_DENY`` is invalid and causes 47948c2ecf20Sopenharmony_cian error. 47958c2ecf20Sopenharmony_ci 47968c2ecf20Sopenharmony_ciAs soon as the filtering is in place, every MSR access is processed through 47978c2ecf20Sopenharmony_cithe filtering except for accesses to the x2APIC MSRs (from 0x800 to 0x8ff); 47988c2ecf20Sopenharmony_cix2APIC MSRs are always allowed, independent of the ``default_allow`` setting, 47998c2ecf20Sopenharmony_ciand their behavior depends on the ``X2APIC_ENABLE`` bit of the APIC base 48008c2ecf20Sopenharmony_ciregister. 48018c2ecf20Sopenharmony_ci 48028c2ecf20Sopenharmony_ciIf a bit is within one of the defined ranges, read and write accesses are 48038c2ecf20Sopenharmony_ciguarded by the bitmap's value for the MSR index if the kind of access 48048c2ecf20Sopenharmony_ciis included in the ``struct kvm_msr_filter_range`` flags. If no range 48058c2ecf20Sopenharmony_cicover this particular access, the behavior is determined by the flags 48068c2ecf20Sopenharmony_cifield in the kvm_msr_filter struct: ``KVM_MSR_FILTER_DEFAULT_ALLOW`` 48078c2ecf20Sopenharmony_ciand ``KVM_MSR_FILTER_DEFAULT_DENY``. 48088c2ecf20Sopenharmony_ci 48098c2ecf20Sopenharmony_ciEach bitmap range specifies a range of MSRs to potentially allow access on. 48108c2ecf20Sopenharmony_ciThe range goes from MSR index [base .. base+nmsrs]. The flags field 48118c2ecf20Sopenharmony_ciindicates whether reads, writes or both reads and writes are filtered 48128c2ecf20Sopenharmony_ciby setting a 1 bit in the bitmap for the corresponding MSR index. 48138c2ecf20Sopenharmony_ci 48148c2ecf20Sopenharmony_ciIf an MSR access is not permitted through the filtering, it generates a 48158c2ecf20Sopenharmony_ci#GP inside the guest. When combined with KVM_CAP_X86_USER_SPACE_MSR, that 48168c2ecf20Sopenharmony_ciallows user space to deflect and potentially handle various MSR accesses 48178c2ecf20Sopenharmony_ciinto user space. 48188c2ecf20Sopenharmony_ci 48198c2ecf20Sopenharmony_ciNote, invoking this ioctl with a vCPU is running is inherently racy. However, 48208c2ecf20Sopenharmony_ciKVM does guarantee that vCPUs will see either the previous filter or the new 48218c2ecf20Sopenharmony_cifilter, e.g. MSRs with identical settings in both the old and new filter will 48228c2ecf20Sopenharmony_cihave deterministic behavior. 48238c2ecf20Sopenharmony_ci 48248c2ecf20Sopenharmony_ci 48258c2ecf20Sopenharmony_ci5. The kvm_run structure 48268c2ecf20Sopenharmony_ci======================== 48278c2ecf20Sopenharmony_ci 48288c2ecf20Sopenharmony_ciApplication code obtains a pointer to the kvm_run structure by 48298c2ecf20Sopenharmony_cimmap()ing a vcpu fd. From that point, application code can control 48308c2ecf20Sopenharmony_ciexecution by changing fields in kvm_run prior to calling the KVM_RUN 48318c2ecf20Sopenharmony_ciioctl, and obtain information about the reason KVM_RUN returned by 48328c2ecf20Sopenharmony_cilooking up structure members. 48338c2ecf20Sopenharmony_ci 48348c2ecf20Sopenharmony_ci:: 48358c2ecf20Sopenharmony_ci 48368c2ecf20Sopenharmony_ci struct kvm_run { 48378c2ecf20Sopenharmony_ci /* in */ 48388c2ecf20Sopenharmony_ci __u8 request_interrupt_window; 48398c2ecf20Sopenharmony_ci 48408c2ecf20Sopenharmony_ciRequest that KVM_RUN return when it becomes possible to inject external 48418c2ecf20Sopenharmony_ciinterrupts into the guest. Useful in conjunction with KVM_INTERRUPT. 48428c2ecf20Sopenharmony_ci 48438c2ecf20Sopenharmony_ci:: 48448c2ecf20Sopenharmony_ci 48458c2ecf20Sopenharmony_ci __u8 immediate_exit; 48468c2ecf20Sopenharmony_ci 48478c2ecf20Sopenharmony_ciThis field is polled once when KVM_RUN starts; if non-zero, KVM_RUN 48488c2ecf20Sopenharmony_ciexits immediately, returning -EINTR. In the common scenario where a 48498c2ecf20Sopenharmony_cisignal is used to "kick" a VCPU out of KVM_RUN, this field can be used 48508c2ecf20Sopenharmony_cito avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability. 48518c2ecf20Sopenharmony_ciRather than blocking the signal outside KVM_RUN, userspace can set up 48528c2ecf20Sopenharmony_cia signal handler that sets run->immediate_exit to a non-zero value. 48538c2ecf20Sopenharmony_ci 48548c2ecf20Sopenharmony_ciThis field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available. 48558c2ecf20Sopenharmony_ci 48568c2ecf20Sopenharmony_ci:: 48578c2ecf20Sopenharmony_ci 48588c2ecf20Sopenharmony_ci __u8 padding1[6]; 48598c2ecf20Sopenharmony_ci 48608c2ecf20Sopenharmony_ci /* out */ 48618c2ecf20Sopenharmony_ci __u32 exit_reason; 48628c2ecf20Sopenharmony_ci 48638c2ecf20Sopenharmony_ciWhen KVM_RUN has returned successfully (return value 0), this informs 48648c2ecf20Sopenharmony_ciapplication code why KVM_RUN has returned. Allowable values for this 48658c2ecf20Sopenharmony_cifield are detailed below. 48668c2ecf20Sopenharmony_ci 48678c2ecf20Sopenharmony_ci:: 48688c2ecf20Sopenharmony_ci 48698c2ecf20Sopenharmony_ci __u8 ready_for_interrupt_injection; 48708c2ecf20Sopenharmony_ci 48718c2ecf20Sopenharmony_ciIf request_interrupt_window has been specified, this field indicates 48728c2ecf20Sopenharmony_cian interrupt can be injected now with KVM_INTERRUPT. 48738c2ecf20Sopenharmony_ci 48748c2ecf20Sopenharmony_ci:: 48758c2ecf20Sopenharmony_ci 48768c2ecf20Sopenharmony_ci __u8 if_flag; 48778c2ecf20Sopenharmony_ci 48788c2ecf20Sopenharmony_ciThe value of the current interrupt flag. Only valid if in-kernel 48798c2ecf20Sopenharmony_cilocal APIC is not used. 48808c2ecf20Sopenharmony_ci 48818c2ecf20Sopenharmony_ci:: 48828c2ecf20Sopenharmony_ci 48838c2ecf20Sopenharmony_ci __u16 flags; 48848c2ecf20Sopenharmony_ci 48858c2ecf20Sopenharmony_ciMore architecture-specific flags detailing state of the VCPU that may 48868c2ecf20Sopenharmony_ciaffect the device's behavior. The only currently defined flag is 48878c2ecf20Sopenharmony_ciKVM_RUN_X86_SMM, which is valid on x86 machines and is set if the 48888c2ecf20Sopenharmony_ciVCPU is in system management mode. 48898c2ecf20Sopenharmony_ci 48908c2ecf20Sopenharmony_ci:: 48918c2ecf20Sopenharmony_ci 48928c2ecf20Sopenharmony_ci /* in (pre_kvm_run), out (post_kvm_run) */ 48938c2ecf20Sopenharmony_ci __u64 cr8; 48948c2ecf20Sopenharmony_ci 48958c2ecf20Sopenharmony_ciThe value of the cr8 register. Only valid if in-kernel local APIC is 48968c2ecf20Sopenharmony_cinot used. Both input and output. 48978c2ecf20Sopenharmony_ci 48988c2ecf20Sopenharmony_ci:: 48998c2ecf20Sopenharmony_ci 49008c2ecf20Sopenharmony_ci __u64 apic_base; 49018c2ecf20Sopenharmony_ci 49028c2ecf20Sopenharmony_ciThe value of the APIC BASE msr. Only valid if in-kernel local 49038c2ecf20Sopenharmony_ciAPIC is not used. Both input and output. 49048c2ecf20Sopenharmony_ci 49058c2ecf20Sopenharmony_ci:: 49068c2ecf20Sopenharmony_ci 49078c2ecf20Sopenharmony_ci union { 49088c2ecf20Sopenharmony_ci /* KVM_EXIT_UNKNOWN */ 49098c2ecf20Sopenharmony_ci struct { 49108c2ecf20Sopenharmony_ci __u64 hardware_exit_reason; 49118c2ecf20Sopenharmony_ci } hw; 49128c2ecf20Sopenharmony_ci 49138c2ecf20Sopenharmony_ciIf exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown 49148c2ecf20Sopenharmony_cireasons. Further architecture-specific information is available in 49158c2ecf20Sopenharmony_cihardware_exit_reason. 49168c2ecf20Sopenharmony_ci 49178c2ecf20Sopenharmony_ci:: 49188c2ecf20Sopenharmony_ci 49198c2ecf20Sopenharmony_ci /* KVM_EXIT_FAIL_ENTRY */ 49208c2ecf20Sopenharmony_ci struct { 49218c2ecf20Sopenharmony_ci __u64 hardware_entry_failure_reason; 49228c2ecf20Sopenharmony_ci __u32 cpu; /* if KVM_LAST_CPU */ 49238c2ecf20Sopenharmony_ci } fail_entry; 49248c2ecf20Sopenharmony_ci 49258c2ecf20Sopenharmony_ciIf exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due 49268c2ecf20Sopenharmony_cito unknown reasons. Further architecture-specific information is 49278c2ecf20Sopenharmony_ciavailable in hardware_entry_failure_reason. 49288c2ecf20Sopenharmony_ci 49298c2ecf20Sopenharmony_ci:: 49308c2ecf20Sopenharmony_ci 49318c2ecf20Sopenharmony_ci /* KVM_EXIT_EXCEPTION */ 49328c2ecf20Sopenharmony_ci struct { 49338c2ecf20Sopenharmony_ci __u32 exception; 49348c2ecf20Sopenharmony_ci __u32 error_code; 49358c2ecf20Sopenharmony_ci } ex; 49368c2ecf20Sopenharmony_ci 49378c2ecf20Sopenharmony_ciUnused. 49388c2ecf20Sopenharmony_ci 49398c2ecf20Sopenharmony_ci:: 49408c2ecf20Sopenharmony_ci 49418c2ecf20Sopenharmony_ci /* KVM_EXIT_IO */ 49428c2ecf20Sopenharmony_ci struct { 49438c2ecf20Sopenharmony_ci #define KVM_EXIT_IO_IN 0 49448c2ecf20Sopenharmony_ci #define KVM_EXIT_IO_OUT 1 49458c2ecf20Sopenharmony_ci __u8 direction; 49468c2ecf20Sopenharmony_ci __u8 size; /* bytes */ 49478c2ecf20Sopenharmony_ci __u16 port; 49488c2ecf20Sopenharmony_ci __u32 count; 49498c2ecf20Sopenharmony_ci __u64 data_offset; /* relative to kvm_run start */ 49508c2ecf20Sopenharmony_ci } io; 49518c2ecf20Sopenharmony_ci 49528c2ecf20Sopenharmony_ciIf exit_reason is KVM_EXIT_IO, then the vcpu has 49538c2ecf20Sopenharmony_ciexecuted a port I/O instruction which could not be satisfied by kvm. 49548c2ecf20Sopenharmony_cidata_offset describes where the data is located (KVM_EXIT_IO_OUT) or 49558c2ecf20Sopenharmony_ciwhere kvm expects application code to place the data for the next 49568c2ecf20Sopenharmony_ciKVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array. 49578c2ecf20Sopenharmony_ci 49588c2ecf20Sopenharmony_ci:: 49598c2ecf20Sopenharmony_ci 49608c2ecf20Sopenharmony_ci /* KVM_EXIT_DEBUG */ 49618c2ecf20Sopenharmony_ci struct { 49628c2ecf20Sopenharmony_ci struct kvm_debug_exit_arch arch; 49638c2ecf20Sopenharmony_ci } debug; 49648c2ecf20Sopenharmony_ci 49658c2ecf20Sopenharmony_ciIf the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event 49668c2ecf20Sopenharmony_cifor which architecture specific information is returned. 49678c2ecf20Sopenharmony_ci 49688c2ecf20Sopenharmony_ci:: 49698c2ecf20Sopenharmony_ci 49708c2ecf20Sopenharmony_ci /* KVM_EXIT_MMIO */ 49718c2ecf20Sopenharmony_ci struct { 49728c2ecf20Sopenharmony_ci __u64 phys_addr; 49738c2ecf20Sopenharmony_ci __u8 data[8]; 49748c2ecf20Sopenharmony_ci __u32 len; 49758c2ecf20Sopenharmony_ci __u8 is_write; 49768c2ecf20Sopenharmony_ci } mmio; 49778c2ecf20Sopenharmony_ci 49788c2ecf20Sopenharmony_ciIf exit_reason is KVM_EXIT_MMIO, then the vcpu has 49798c2ecf20Sopenharmony_ciexecuted a memory-mapped I/O instruction which could not be satisfied 49808c2ecf20Sopenharmony_ciby kvm. The 'data' member contains the written data if 'is_write' is 49818c2ecf20Sopenharmony_citrue, and should be filled by application code otherwise. 49828c2ecf20Sopenharmony_ci 49838c2ecf20Sopenharmony_ciThe 'data' member contains, in its first 'len' bytes, the value as it would 49848c2ecf20Sopenharmony_ciappear if the VCPU performed a load or store of the appropriate width directly 49858c2ecf20Sopenharmony_cito the byte array. 49868c2ecf20Sopenharmony_ci 49878c2ecf20Sopenharmony_ci.. note:: 49888c2ecf20Sopenharmony_ci 49898c2ecf20Sopenharmony_ci For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR, 49908c2ecf20Sopenharmony_ci KVM_EXIT_EPR, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR the corresponding 49918c2ecf20Sopenharmony_ci operations are complete (and guest state is consistent) only after userspace 49928c2ecf20Sopenharmony_ci has re-entered the kernel with KVM_RUN. The kernel side will first finish 49938c2ecf20Sopenharmony_ci incomplete operations and then check for pending signals. Userspace 49948c2ecf20Sopenharmony_ci can re-enter the guest with an unmasked signal pending to complete 49958c2ecf20Sopenharmony_ci pending operations. 49968c2ecf20Sopenharmony_ci 49978c2ecf20Sopenharmony_ci:: 49988c2ecf20Sopenharmony_ci 49998c2ecf20Sopenharmony_ci /* KVM_EXIT_HYPERCALL */ 50008c2ecf20Sopenharmony_ci struct { 50018c2ecf20Sopenharmony_ci __u64 nr; 50028c2ecf20Sopenharmony_ci __u64 args[6]; 50038c2ecf20Sopenharmony_ci __u64 ret; 50048c2ecf20Sopenharmony_ci __u32 longmode; 50058c2ecf20Sopenharmony_ci __u32 pad; 50068c2ecf20Sopenharmony_ci } hypercall; 50078c2ecf20Sopenharmony_ci 50088c2ecf20Sopenharmony_ciUnused. This was once used for 'hypercall to userspace'. To implement 50098c2ecf20Sopenharmony_cisuch functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390). 50108c2ecf20Sopenharmony_ci 50118c2ecf20Sopenharmony_ci.. note:: KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO. 50128c2ecf20Sopenharmony_ci 50138c2ecf20Sopenharmony_ci:: 50148c2ecf20Sopenharmony_ci 50158c2ecf20Sopenharmony_ci /* KVM_EXIT_TPR_ACCESS */ 50168c2ecf20Sopenharmony_ci struct { 50178c2ecf20Sopenharmony_ci __u64 rip; 50188c2ecf20Sopenharmony_ci __u32 is_write; 50198c2ecf20Sopenharmony_ci __u32 pad; 50208c2ecf20Sopenharmony_ci } tpr_access; 50218c2ecf20Sopenharmony_ci 50228c2ecf20Sopenharmony_ciTo be documented (KVM_TPR_ACCESS_REPORTING). 50238c2ecf20Sopenharmony_ci 50248c2ecf20Sopenharmony_ci:: 50258c2ecf20Sopenharmony_ci 50268c2ecf20Sopenharmony_ci /* KVM_EXIT_S390_SIEIC */ 50278c2ecf20Sopenharmony_ci struct { 50288c2ecf20Sopenharmony_ci __u8 icptcode; 50298c2ecf20Sopenharmony_ci __u64 mask; /* psw upper half */ 50308c2ecf20Sopenharmony_ci __u64 addr; /* psw lower half */ 50318c2ecf20Sopenharmony_ci __u16 ipa; 50328c2ecf20Sopenharmony_ci __u32 ipb; 50338c2ecf20Sopenharmony_ci } s390_sieic; 50348c2ecf20Sopenharmony_ci 50358c2ecf20Sopenharmony_cis390 specific. 50368c2ecf20Sopenharmony_ci 50378c2ecf20Sopenharmony_ci:: 50388c2ecf20Sopenharmony_ci 50398c2ecf20Sopenharmony_ci /* KVM_EXIT_S390_RESET */ 50408c2ecf20Sopenharmony_ci #define KVM_S390_RESET_POR 1 50418c2ecf20Sopenharmony_ci #define KVM_S390_RESET_CLEAR 2 50428c2ecf20Sopenharmony_ci #define KVM_S390_RESET_SUBSYSTEM 4 50438c2ecf20Sopenharmony_ci #define KVM_S390_RESET_CPU_INIT 8 50448c2ecf20Sopenharmony_ci #define KVM_S390_RESET_IPL 16 50458c2ecf20Sopenharmony_ci __u64 s390_reset_flags; 50468c2ecf20Sopenharmony_ci 50478c2ecf20Sopenharmony_cis390 specific. 50488c2ecf20Sopenharmony_ci 50498c2ecf20Sopenharmony_ci:: 50508c2ecf20Sopenharmony_ci 50518c2ecf20Sopenharmony_ci /* KVM_EXIT_S390_UCONTROL */ 50528c2ecf20Sopenharmony_ci struct { 50538c2ecf20Sopenharmony_ci __u64 trans_exc_code; 50548c2ecf20Sopenharmony_ci __u32 pgm_code; 50558c2ecf20Sopenharmony_ci } s390_ucontrol; 50568c2ecf20Sopenharmony_ci 50578c2ecf20Sopenharmony_cis390 specific. A page fault has occurred for a user controlled virtual 50588c2ecf20Sopenharmony_cimachine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be 50598c2ecf20Sopenharmony_ciresolved by the kernel. 50608c2ecf20Sopenharmony_ciThe program code and the translation exception code that were placed 50618c2ecf20Sopenharmony_ciin the cpu's lowcore are presented here as defined by the z Architecture 50628c2ecf20Sopenharmony_ciPrinciples of Operation Book in the Chapter for Dynamic Address Translation 50638c2ecf20Sopenharmony_ci(DAT) 50648c2ecf20Sopenharmony_ci 50658c2ecf20Sopenharmony_ci:: 50668c2ecf20Sopenharmony_ci 50678c2ecf20Sopenharmony_ci /* KVM_EXIT_DCR */ 50688c2ecf20Sopenharmony_ci struct { 50698c2ecf20Sopenharmony_ci __u32 dcrn; 50708c2ecf20Sopenharmony_ci __u32 data; 50718c2ecf20Sopenharmony_ci __u8 is_write; 50728c2ecf20Sopenharmony_ci } dcr; 50738c2ecf20Sopenharmony_ci 50748c2ecf20Sopenharmony_ciDeprecated - was used for 440 KVM. 50758c2ecf20Sopenharmony_ci 50768c2ecf20Sopenharmony_ci:: 50778c2ecf20Sopenharmony_ci 50788c2ecf20Sopenharmony_ci /* KVM_EXIT_OSI */ 50798c2ecf20Sopenharmony_ci struct { 50808c2ecf20Sopenharmony_ci __u64 gprs[32]; 50818c2ecf20Sopenharmony_ci } osi; 50828c2ecf20Sopenharmony_ci 50838c2ecf20Sopenharmony_ciMOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch 50848c2ecf20Sopenharmony_cihypercalls and exit with this exit struct that contains all the guest gprs. 50858c2ecf20Sopenharmony_ci 50868c2ecf20Sopenharmony_ciIf exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall. 50878c2ecf20Sopenharmony_ciUserspace can now handle the hypercall and when it's done modify the gprs as 50888c2ecf20Sopenharmony_cinecessary. Upon guest entry all guest GPRs will then be replaced by the values 50898c2ecf20Sopenharmony_ciin this struct. 50908c2ecf20Sopenharmony_ci 50918c2ecf20Sopenharmony_ci:: 50928c2ecf20Sopenharmony_ci 50938c2ecf20Sopenharmony_ci /* KVM_EXIT_PAPR_HCALL */ 50948c2ecf20Sopenharmony_ci struct { 50958c2ecf20Sopenharmony_ci __u64 nr; 50968c2ecf20Sopenharmony_ci __u64 ret; 50978c2ecf20Sopenharmony_ci __u64 args[9]; 50988c2ecf20Sopenharmony_ci } papr_hcall; 50998c2ecf20Sopenharmony_ci 51008c2ecf20Sopenharmony_ciThis is used on 64-bit PowerPC when emulating a pSeries partition, 51018c2ecf20Sopenharmony_cie.g. with the 'pseries' machine type in qemu. It occurs when the 51028c2ecf20Sopenharmony_ciguest does a hypercall using the 'sc 1' instruction. The 'nr' field 51038c2ecf20Sopenharmony_cicontains the hypercall number (from the guest R3), and 'args' contains 51048c2ecf20Sopenharmony_cithe arguments (from the guest R4 - R12). Userspace should put the 51058c2ecf20Sopenharmony_cireturn code in 'ret' and any extra returned values in args[]. 51068c2ecf20Sopenharmony_ciThe possible hypercalls are defined in the Power Architecture Platform 51078c2ecf20Sopenharmony_ciRequirements (PAPR) document available from www.power.org (free 51088c2ecf20Sopenharmony_cideveloper registration required to access it). 51098c2ecf20Sopenharmony_ci 51108c2ecf20Sopenharmony_ci:: 51118c2ecf20Sopenharmony_ci 51128c2ecf20Sopenharmony_ci /* KVM_EXIT_S390_TSCH */ 51138c2ecf20Sopenharmony_ci struct { 51148c2ecf20Sopenharmony_ci __u16 subchannel_id; 51158c2ecf20Sopenharmony_ci __u16 subchannel_nr; 51168c2ecf20Sopenharmony_ci __u32 io_int_parm; 51178c2ecf20Sopenharmony_ci __u32 io_int_word; 51188c2ecf20Sopenharmony_ci __u32 ipb; 51198c2ecf20Sopenharmony_ci __u8 dequeued; 51208c2ecf20Sopenharmony_ci } s390_tsch; 51218c2ecf20Sopenharmony_ci 51228c2ecf20Sopenharmony_cis390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled 51238c2ecf20Sopenharmony_ciand TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O 51248c2ecf20Sopenharmony_ciinterrupt for the target subchannel has been dequeued and subchannel_id, 51258c2ecf20Sopenharmony_cisubchannel_nr, io_int_parm and io_int_word contain the parameters for that 51268c2ecf20Sopenharmony_ciinterrupt. ipb is needed for instruction parameter decoding. 51278c2ecf20Sopenharmony_ci 51288c2ecf20Sopenharmony_ci:: 51298c2ecf20Sopenharmony_ci 51308c2ecf20Sopenharmony_ci /* KVM_EXIT_EPR */ 51318c2ecf20Sopenharmony_ci struct { 51328c2ecf20Sopenharmony_ci __u32 epr; 51338c2ecf20Sopenharmony_ci } epr; 51348c2ecf20Sopenharmony_ci 51358c2ecf20Sopenharmony_ciOn FSL BookE PowerPC chips, the interrupt controller has a fast patch 51368c2ecf20Sopenharmony_ciinterrupt acknowledge path to the core. When the core successfully 51378c2ecf20Sopenharmony_cidelivers an interrupt, it automatically populates the EPR register with 51388c2ecf20Sopenharmony_cithe interrupt vector number and acknowledges the interrupt inside 51398c2ecf20Sopenharmony_cithe interrupt controller. 51408c2ecf20Sopenharmony_ci 51418c2ecf20Sopenharmony_ciIn case the interrupt controller lives in user space, we need to do 51428c2ecf20Sopenharmony_cithe interrupt acknowledge cycle through it to fetch the next to be 51438c2ecf20Sopenharmony_cidelivered interrupt vector using this exit. 51448c2ecf20Sopenharmony_ci 51458c2ecf20Sopenharmony_ciIt gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an 51468c2ecf20Sopenharmony_ciexternal interrupt has just been delivered into the guest. User space 51478c2ecf20Sopenharmony_cishould put the acknowledged interrupt vector into the 'epr' field. 51488c2ecf20Sopenharmony_ci 51498c2ecf20Sopenharmony_ci:: 51508c2ecf20Sopenharmony_ci 51518c2ecf20Sopenharmony_ci /* KVM_EXIT_SYSTEM_EVENT */ 51528c2ecf20Sopenharmony_ci struct { 51538c2ecf20Sopenharmony_ci #define KVM_SYSTEM_EVENT_SHUTDOWN 1 51548c2ecf20Sopenharmony_ci #define KVM_SYSTEM_EVENT_RESET 2 51558c2ecf20Sopenharmony_ci #define KVM_SYSTEM_EVENT_CRASH 3 51568c2ecf20Sopenharmony_ci __u32 type; 51578c2ecf20Sopenharmony_ci __u64 flags; 51588c2ecf20Sopenharmony_ci } system_event; 51598c2ecf20Sopenharmony_ci 51608c2ecf20Sopenharmony_ciIf exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered 51618c2ecf20Sopenharmony_cia system-level event using some architecture specific mechanism (hypercall 51628c2ecf20Sopenharmony_cior some special instruction). In case of ARM/ARM64, this is triggered using 51638c2ecf20Sopenharmony_ciHVC instruction based PSCI call from the vcpu. The 'type' field describes 51648c2ecf20Sopenharmony_cithe system-level event type. The 'flags' field describes architecture 51658c2ecf20Sopenharmony_cispecific flags for the system-level event. 51668c2ecf20Sopenharmony_ci 51678c2ecf20Sopenharmony_ciValid values for 'type' are: 51688c2ecf20Sopenharmony_ci 51698c2ecf20Sopenharmony_ci - KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the 51708c2ecf20Sopenharmony_ci VM. Userspace is not obliged to honour this, and if it does honour 51718c2ecf20Sopenharmony_ci this does not need to destroy the VM synchronously (ie it may call 51728c2ecf20Sopenharmony_ci KVM_RUN again before shutdown finally occurs). 51738c2ecf20Sopenharmony_ci - KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM. 51748c2ecf20Sopenharmony_ci As with SHUTDOWN, userspace can choose to ignore the request, or 51758c2ecf20Sopenharmony_ci to schedule the reset to occur in the future and may call KVM_RUN again. 51768c2ecf20Sopenharmony_ci - KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest 51778c2ecf20Sopenharmony_ci has requested a crash condition maintenance. Userspace can choose 51788c2ecf20Sopenharmony_ci to ignore the request, or to gather VM memory core dump and/or 51798c2ecf20Sopenharmony_ci reset/shutdown of the VM. 51808c2ecf20Sopenharmony_ci 51818c2ecf20Sopenharmony_ci:: 51828c2ecf20Sopenharmony_ci 51838c2ecf20Sopenharmony_ci /* KVM_EXIT_IOAPIC_EOI */ 51848c2ecf20Sopenharmony_ci struct { 51858c2ecf20Sopenharmony_ci __u8 vector; 51868c2ecf20Sopenharmony_ci } eoi; 51878c2ecf20Sopenharmony_ci 51888c2ecf20Sopenharmony_ciIndicates that the VCPU's in-kernel local APIC received an EOI for a 51898c2ecf20Sopenharmony_cilevel-triggered IOAPIC interrupt. This exit only triggers when the 51908c2ecf20Sopenharmony_ciIOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled); 51918c2ecf20Sopenharmony_cithe userspace IOAPIC should process the EOI and retrigger the interrupt if 51928c2ecf20Sopenharmony_ciit is still asserted. Vector is the LAPIC interrupt vector for which the 51938c2ecf20Sopenharmony_ciEOI was received. 51948c2ecf20Sopenharmony_ci 51958c2ecf20Sopenharmony_ci:: 51968c2ecf20Sopenharmony_ci 51978c2ecf20Sopenharmony_ci struct kvm_hyperv_exit { 51988c2ecf20Sopenharmony_ci #define KVM_EXIT_HYPERV_SYNIC 1 51998c2ecf20Sopenharmony_ci #define KVM_EXIT_HYPERV_HCALL 2 52008c2ecf20Sopenharmony_ci #define KVM_EXIT_HYPERV_SYNDBG 3 52018c2ecf20Sopenharmony_ci __u32 type; 52028c2ecf20Sopenharmony_ci __u32 pad1; 52038c2ecf20Sopenharmony_ci union { 52048c2ecf20Sopenharmony_ci struct { 52058c2ecf20Sopenharmony_ci __u32 msr; 52068c2ecf20Sopenharmony_ci __u32 pad2; 52078c2ecf20Sopenharmony_ci __u64 control; 52088c2ecf20Sopenharmony_ci __u64 evt_page; 52098c2ecf20Sopenharmony_ci __u64 msg_page; 52108c2ecf20Sopenharmony_ci } synic; 52118c2ecf20Sopenharmony_ci struct { 52128c2ecf20Sopenharmony_ci __u64 input; 52138c2ecf20Sopenharmony_ci __u64 result; 52148c2ecf20Sopenharmony_ci __u64 params[2]; 52158c2ecf20Sopenharmony_ci } hcall; 52168c2ecf20Sopenharmony_ci struct { 52178c2ecf20Sopenharmony_ci __u32 msr; 52188c2ecf20Sopenharmony_ci __u32 pad2; 52198c2ecf20Sopenharmony_ci __u64 control; 52208c2ecf20Sopenharmony_ci __u64 status; 52218c2ecf20Sopenharmony_ci __u64 send_page; 52228c2ecf20Sopenharmony_ci __u64 recv_page; 52238c2ecf20Sopenharmony_ci __u64 pending_page; 52248c2ecf20Sopenharmony_ci } syndbg; 52258c2ecf20Sopenharmony_ci } u; 52268c2ecf20Sopenharmony_ci }; 52278c2ecf20Sopenharmony_ci /* KVM_EXIT_HYPERV */ 52288c2ecf20Sopenharmony_ci struct kvm_hyperv_exit hyperv; 52298c2ecf20Sopenharmony_ci 52308c2ecf20Sopenharmony_ciIndicates that the VCPU exits into userspace to process some tasks 52318c2ecf20Sopenharmony_cirelated to Hyper-V emulation. 52328c2ecf20Sopenharmony_ci 52338c2ecf20Sopenharmony_ciValid values for 'type' are: 52348c2ecf20Sopenharmony_ci 52358c2ecf20Sopenharmony_ci - KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about 52368c2ecf20Sopenharmony_ci 52378c2ecf20Sopenharmony_ciHyper-V SynIC state change. Notification is used to remap SynIC 52388c2ecf20Sopenharmony_cievent/message pages and to enable/disable SynIC messages/events processing 52398c2ecf20Sopenharmony_ciin userspace. 52408c2ecf20Sopenharmony_ci 52418c2ecf20Sopenharmony_ci - KVM_EXIT_HYPERV_SYNDBG -- synchronously notify user-space about 52428c2ecf20Sopenharmony_ci 52438c2ecf20Sopenharmony_ciHyper-V Synthetic debugger state change. Notification is used to either update 52448c2ecf20Sopenharmony_cithe pending_page location or to send a control command (send the buffer located 52458c2ecf20Sopenharmony_ciin send_page or recv a buffer to recv_page). 52468c2ecf20Sopenharmony_ci 52478c2ecf20Sopenharmony_ci:: 52488c2ecf20Sopenharmony_ci 52498c2ecf20Sopenharmony_ci /* KVM_EXIT_ARM_NISV */ 52508c2ecf20Sopenharmony_ci struct { 52518c2ecf20Sopenharmony_ci __u64 esr_iss; 52528c2ecf20Sopenharmony_ci __u64 fault_ipa; 52538c2ecf20Sopenharmony_ci } arm_nisv; 52548c2ecf20Sopenharmony_ci 52558c2ecf20Sopenharmony_ciUsed on arm and arm64 systems. If a guest accesses memory not in a memslot, 52568c2ecf20Sopenharmony_ciKVM will typically return to userspace and ask it to do MMIO emulation on its 52578c2ecf20Sopenharmony_cibehalf. However, for certain classes of instructions, no instruction decode 52588c2ecf20Sopenharmony_ci(direction, length of memory access) is provided, and fetching and decoding 52598c2ecf20Sopenharmony_cithe instruction from the VM is overly complicated to live in the kernel. 52608c2ecf20Sopenharmony_ci 52618c2ecf20Sopenharmony_ciHistorically, when this situation occurred, KVM would print a warning and kill 52628c2ecf20Sopenharmony_cithe VM. KVM assumed that if the guest accessed non-memslot memory, it was 52638c2ecf20Sopenharmony_citrying to do I/O, which just couldn't be emulated, and the warning message was 52648c2ecf20Sopenharmony_ciphrased accordingly. However, what happened more often was that a guest bug 52658c2ecf20Sopenharmony_cicaused access outside the guest memory areas which should lead to a more 52668c2ecf20Sopenharmony_cimeaningful warning message and an external abort in the guest, if the access 52678c2ecf20Sopenharmony_cidid not fall within an I/O window. 52688c2ecf20Sopenharmony_ci 52698c2ecf20Sopenharmony_ciUserspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable 52708c2ecf20Sopenharmony_cithis capability at VM creation. Once this is done, these types of errors will 52718c2ecf20Sopenharmony_ciinstead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from 52728c2ecf20Sopenharmony_cithe HSR (arm) and ESR_EL2 (arm64) in the esr_iss field, and the faulting IPA 52738c2ecf20Sopenharmony_ciin the fault_ipa field. Userspace can either fix up the access if it's 52748c2ecf20Sopenharmony_ciactually an I/O access by decoding the instruction from guest memory (if it's 52758c2ecf20Sopenharmony_civery brave) and continue executing the guest, or it can decide to suspend, 52768c2ecf20Sopenharmony_cidump, or restart the guest. 52778c2ecf20Sopenharmony_ci 52788c2ecf20Sopenharmony_ciNote that KVM does not skip the faulting instruction as it does for 52798c2ecf20Sopenharmony_ciKVM_EXIT_MMIO, but userspace has to emulate any change to the processing state 52808c2ecf20Sopenharmony_ciif it decides to decode and emulate the instruction. 52818c2ecf20Sopenharmony_ci 52828c2ecf20Sopenharmony_ci:: 52838c2ecf20Sopenharmony_ci 52848c2ecf20Sopenharmony_ci /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ 52858c2ecf20Sopenharmony_ci struct { 52868c2ecf20Sopenharmony_ci __u8 error; /* user -> kernel */ 52878c2ecf20Sopenharmony_ci __u8 pad[7]; 52888c2ecf20Sopenharmony_ci __u32 reason; /* kernel -> user */ 52898c2ecf20Sopenharmony_ci __u32 index; /* kernel -> user */ 52908c2ecf20Sopenharmony_ci __u64 data; /* kernel <-> user */ 52918c2ecf20Sopenharmony_ci } msr; 52928c2ecf20Sopenharmony_ci 52938c2ecf20Sopenharmony_ciUsed on x86 systems. When the VM capability KVM_CAP_X86_USER_SPACE_MSR is 52948c2ecf20Sopenharmony_cienabled, MSR accesses to registers that would invoke a #GP by KVM kernel code 52958c2ecf20Sopenharmony_ciwill instead trigger a KVM_EXIT_X86_RDMSR exit for reads and KVM_EXIT_X86_WRMSR 52968c2ecf20Sopenharmony_ciexit for writes. 52978c2ecf20Sopenharmony_ci 52988c2ecf20Sopenharmony_ciThe "reason" field specifies why the MSR trap occurred. User space will only 52998c2ecf20Sopenharmony_cireceive MSR exit traps when a particular reason was requested during through 53008c2ecf20Sopenharmony_ciENABLE_CAP. Currently valid exit reasons are: 53018c2ecf20Sopenharmony_ci 53028c2ecf20Sopenharmony_ci KVM_MSR_EXIT_REASON_UNKNOWN - access to MSR that is unknown to KVM 53038c2ecf20Sopenharmony_ci KVM_MSR_EXIT_REASON_INVAL - access to invalid MSRs or reserved bits 53048c2ecf20Sopenharmony_ci KVM_MSR_EXIT_REASON_FILTER - access blocked by KVM_X86_SET_MSR_FILTER 53058c2ecf20Sopenharmony_ci 53068c2ecf20Sopenharmony_ciFor KVM_EXIT_X86_RDMSR, the "index" field tells user space which MSR the guest 53078c2ecf20Sopenharmony_ciwants to read. To respond to this request with a successful read, user space 53088c2ecf20Sopenharmony_ciwrites the respective data into the "data" field and must continue guest 53098c2ecf20Sopenharmony_ciexecution to ensure the read data is transferred into guest register state. 53108c2ecf20Sopenharmony_ci 53118c2ecf20Sopenharmony_ciIf the RDMSR request was unsuccessful, user space indicates that with a "1" in 53128c2ecf20Sopenharmony_cithe "error" field. This will inject a #GP into the guest when the VCPU is 53138c2ecf20Sopenharmony_ciexecuted again. 53148c2ecf20Sopenharmony_ci 53158c2ecf20Sopenharmony_ciFor KVM_EXIT_X86_WRMSR, the "index" field tells user space which MSR the guest 53168c2ecf20Sopenharmony_ciwants to write. Once finished processing the event, user space must continue 53178c2ecf20Sopenharmony_civCPU execution. If the MSR write was unsuccessful, user space also sets the 53188c2ecf20Sopenharmony_ci"error" field to "1". 53198c2ecf20Sopenharmony_ci 53208c2ecf20Sopenharmony_ci:: 53218c2ecf20Sopenharmony_ci 53228c2ecf20Sopenharmony_ci /* Fix the size of the union. */ 53238c2ecf20Sopenharmony_ci char padding[256]; 53248c2ecf20Sopenharmony_ci }; 53258c2ecf20Sopenharmony_ci 53268c2ecf20Sopenharmony_ci /* 53278c2ecf20Sopenharmony_ci * shared registers between kvm and userspace. 53288c2ecf20Sopenharmony_ci * kvm_valid_regs specifies the register classes set by the host 53298c2ecf20Sopenharmony_ci * kvm_dirty_regs specified the register classes dirtied by userspace 53308c2ecf20Sopenharmony_ci * struct kvm_sync_regs is architecture specific, as well as the 53318c2ecf20Sopenharmony_ci * bits for kvm_valid_regs and kvm_dirty_regs 53328c2ecf20Sopenharmony_ci */ 53338c2ecf20Sopenharmony_ci __u64 kvm_valid_regs; 53348c2ecf20Sopenharmony_ci __u64 kvm_dirty_regs; 53358c2ecf20Sopenharmony_ci union { 53368c2ecf20Sopenharmony_ci struct kvm_sync_regs regs; 53378c2ecf20Sopenharmony_ci char padding[SYNC_REGS_SIZE_BYTES]; 53388c2ecf20Sopenharmony_ci } s; 53398c2ecf20Sopenharmony_ci 53408c2ecf20Sopenharmony_ciIf KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access 53418c2ecf20Sopenharmony_cicertain guest registers without having to call SET/GET_*REGS. Thus we can 53428c2ecf20Sopenharmony_ciavoid some system call overhead if userspace has to handle the exit. 53438c2ecf20Sopenharmony_ciUserspace can query the validity of the structure by checking 53448c2ecf20Sopenharmony_cikvm_valid_regs for specific bits. These bits are architecture specific 53458c2ecf20Sopenharmony_ciand usually define the validity of a groups of registers. (e.g. one bit 53468c2ecf20Sopenharmony_cifor general purpose registers) 53478c2ecf20Sopenharmony_ci 53488c2ecf20Sopenharmony_ciPlease note that the kernel is allowed to use the kvm_run structure as the 53498c2ecf20Sopenharmony_ciprimary storage for certain register types. Therefore, the kernel may use the 53508c2ecf20Sopenharmony_civalues in kvm_run even if the corresponding bit in kvm_dirty_regs is not set. 53518c2ecf20Sopenharmony_ci 53528c2ecf20Sopenharmony_ci:: 53538c2ecf20Sopenharmony_ci 53548c2ecf20Sopenharmony_ci }; 53558c2ecf20Sopenharmony_ci 53568c2ecf20Sopenharmony_ci 53578c2ecf20Sopenharmony_ci 53588c2ecf20Sopenharmony_ci6. Capabilities that can be enabled on vCPUs 53598c2ecf20Sopenharmony_ci============================================ 53608c2ecf20Sopenharmony_ci 53618c2ecf20Sopenharmony_ciThere are certain capabilities that change the behavior of the virtual CPU or 53628c2ecf20Sopenharmony_cithe virtual machine when enabled. To enable them, please see section 4.37. 53638c2ecf20Sopenharmony_ciBelow you can find a list of capabilities and what their effect on the vCPU or 53648c2ecf20Sopenharmony_cithe virtual machine is when enabling them. 53658c2ecf20Sopenharmony_ci 53668c2ecf20Sopenharmony_ciThe following information is provided along with the description: 53678c2ecf20Sopenharmony_ci 53688c2ecf20Sopenharmony_ci Architectures: 53698c2ecf20Sopenharmony_ci which instruction set architectures provide this ioctl. 53708c2ecf20Sopenharmony_ci x86 includes both i386 and x86_64. 53718c2ecf20Sopenharmony_ci 53728c2ecf20Sopenharmony_ci Target: 53738c2ecf20Sopenharmony_ci whether this is a per-vcpu or per-vm capability. 53748c2ecf20Sopenharmony_ci 53758c2ecf20Sopenharmony_ci Parameters: 53768c2ecf20Sopenharmony_ci what parameters are accepted by the capability. 53778c2ecf20Sopenharmony_ci 53788c2ecf20Sopenharmony_ci Returns: 53798c2ecf20Sopenharmony_ci the return value. General error numbers (EBADF, ENOMEM, EINVAL) 53808c2ecf20Sopenharmony_ci are not detailed, but errors with specific meanings are. 53818c2ecf20Sopenharmony_ci 53828c2ecf20Sopenharmony_ci 53838c2ecf20Sopenharmony_ci6.1 KVM_CAP_PPC_OSI 53848c2ecf20Sopenharmony_ci------------------- 53858c2ecf20Sopenharmony_ci 53868c2ecf20Sopenharmony_ci:Architectures: ppc 53878c2ecf20Sopenharmony_ci:Target: vcpu 53888c2ecf20Sopenharmony_ci:Parameters: none 53898c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 53908c2ecf20Sopenharmony_ci 53918c2ecf20Sopenharmony_ciThis capability enables interception of OSI hypercalls that otherwise would 53928c2ecf20Sopenharmony_cibe treated as normal system calls to be injected into the guest. OSI hypercalls 53938c2ecf20Sopenharmony_ciwere invented by Mac-on-Linux to have a standardized communication mechanism 53948c2ecf20Sopenharmony_cibetween the guest and the host. 53958c2ecf20Sopenharmony_ci 53968c2ecf20Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_OSI can occur. 53978c2ecf20Sopenharmony_ci 53988c2ecf20Sopenharmony_ci 53998c2ecf20Sopenharmony_ci6.2 KVM_CAP_PPC_PAPR 54008c2ecf20Sopenharmony_ci-------------------- 54018c2ecf20Sopenharmony_ci 54028c2ecf20Sopenharmony_ci:Architectures: ppc 54038c2ecf20Sopenharmony_ci:Target: vcpu 54048c2ecf20Sopenharmony_ci:Parameters: none 54058c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 54068c2ecf20Sopenharmony_ci 54078c2ecf20Sopenharmony_ciThis capability enables interception of PAPR hypercalls. PAPR hypercalls are 54088c2ecf20Sopenharmony_cidone using the hypercall instruction "sc 1". 54098c2ecf20Sopenharmony_ci 54108c2ecf20Sopenharmony_ciIt also sets the guest privilege level to "supervisor" mode. Usually the guest 54118c2ecf20Sopenharmony_ciruns in "hypervisor" privilege mode with a few missing features. 54128c2ecf20Sopenharmony_ci 54138c2ecf20Sopenharmony_ciIn addition to the above, it changes the semantics of SDR1. In this mode, the 54148c2ecf20Sopenharmony_ciHTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the 54158c2ecf20Sopenharmony_ciHTAB invisible to the guest. 54168c2ecf20Sopenharmony_ci 54178c2ecf20Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_PAPR_HCALL can occur. 54188c2ecf20Sopenharmony_ci 54198c2ecf20Sopenharmony_ci 54208c2ecf20Sopenharmony_ci6.3 KVM_CAP_SW_TLB 54218c2ecf20Sopenharmony_ci------------------ 54228c2ecf20Sopenharmony_ci 54238c2ecf20Sopenharmony_ci:Architectures: ppc 54248c2ecf20Sopenharmony_ci:Target: vcpu 54258c2ecf20Sopenharmony_ci:Parameters: args[0] is the address of a struct kvm_config_tlb 54268c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 54278c2ecf20Sopenharmony_ci 54288c2ecf20Sopenharmony_ci:: 54298c2ecf20Sopenharmony_ci 54308c2ecf20Sopenharmony_ci struct kvm_config_tlb { 54318c2ecf20Sopenharmony_ci __u64 params; 54328c2ecf20Sopenharmony_ci __u64 array; 54338c2ecf20Sopenharmony_ci __u32 mmu_type; 54348c2ecf20Sopenharmony_ci __u32 array_len; 54358c2ecf20Sopenharmony_ci }; 54368c2ecf20Sopenharmony_ci 54378c2ecf20Sopenharmony_ciConfigures the virtual CPU's TLB array, establishing a shared memory area 54388c2ecf20Sopenharmony_cibetween userspace and KVM. The "params" and "array" fields are userspace 54398c2ecf20Sopenharmony_ciaddresses of mmu-type-specific data structures. The "array_len" field is an 54408c2ecf20Sopenharmony_cisafety mechanism, and should be set to the size in bytes of the memory that 54418c2ecf20Sopenharmony_ciuserspace has reserved for the array. It must be at least the size dictated 54428c2ecf20Sopenharmony_ciby "mmu_type" and "params". 54438c2ecf20Sopenharmony_ci 54448c2ecf20Sopenharmony_ciWhile KVM_RUN is active, the shared region is under control of KVM. Its 54458c2ecf20Sopenharmony_cicontents are undefined, and any modification by userspace results in 54468c2ecf20Sopenharmony_ciboundedly undefined behavior. 54478c2ecf20Sopenharmony_ci 54488c2ecf20Sopenharmony_ciOn return from KVM_RUN, the shared region will reflect the current state of 54498c2ecf20Sopenharmony_cithe guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB 54508c2ecf20Sopenharmony_cito tell KVM which entries have been changed, prior to calling KVM_RUN again 54518c2ecf20Sopenharmony_cion this vcpu. 54528c2ecf20Sopenharmony_ci 54538c2ecf20Sopenharmony_ciFor mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV: 54548c2ecf20Sopenharmony_ci 54558c2ecf20Sopenharmony_ci - The "params" field is of type "struct kvm_book3e_206_tlb_params". 54568c2ecf20Sopenharmony_ci - The "array" field points to an array of type "struct 54578c2ecf20Sopenharmony_ci kvm_book3e_206_tlb_entry". 54588c2ecf20Sopenharmony_ci - The array consists of all entries in the first TLB, followed by all 54598c2ecf20Sopenharmony_ci entries in the second TLB. 54608c2ecf20Sopenharmony_ci - Within a TLB, entries are ordered first by increasing set number. Within a 54618c2ecf20Sopenharmony_ci set, entries are ordered by way (increasing ESEL). 54628c2ecf20Sopenharmony_ci - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1) 54638c2ecf20Sopenharmony_ci where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value. 54648c2ecf20Sopenharmony_ci - The tsize field of mas1 shall be set to 4K on TLB0, even though the 54658c2ecf20Sopenharmony_ci hardware ignores this value for TLB0. 54668c2ecf20Sopenharmony_ci 54678c2ecf20Sopenharmony_ci6.4 KVM_CAP_S390_CSS_SUPPORT 54688c2ecf20Sopenharmony_ci---------------------------- 54698c2ecf20Sopenharmony_ci 54708c2ecf20Sopenharmony_ci:Architectures: s390 54718c2ecf20Sopenharmony_ci:Target: vcpu 54728c2ecf20Sopenharmony_ci:Parameters: none 54738c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 54748c2ecf20Sopenharmony_ci 54758c2ecf20Sopenharmony_ciThis capability enables support for handling of channel I/O instructions. 54768c2ecf20Sopenharmony_ci 54778c2ecf20Sopenharmony_ciTEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are 54788c2ecf20Sopenharmony_cihandled in-kernel, while the other I/O instructions are passed to userspace. 54798c2ecf20Sopenharmony_ci 54808c2ecf20Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST 54818c2ecf20Sopenharmony_ciSUBCHANNEL intercepts. 54828c2ecf20Sopenharmony_ci 54838c2ecf20Sopenharmony_ciNote that even though this capability is enabled per-vcpu, the complete 54848c2ecf20Sopenharmony_civirtual machine is affected. 54858c2ecf20Sopenharmony_ci 54868c2ecf20Sopenharmony_ci6.5 KVM_CAP_PPC_EPR 54878c2ecf20Sopenharmony_ci------------------- 54888c2ecf20Sopenharmony_ci 54898c2ecf20Sopenharmony_ci:Architectures: ppc 54908c2ecf20Sopenharmony_ci:Target: vcpu 54918c2ecf20Sopenharmony_ci:Parameters: args[0] defines whether the proxy facility is active 54928c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 54938c2ecf20Sopenharmony_ci 54948c2ecf20Sopenharmony_ciThis capability enables or disables the delivery of interrupts through the 54958c2ecf20Sopenharmony_ciexternal proxy facility. 54968c2ecf20Sopenharmony_ci 54978c2ecf20Sopenharmony_ciWhen enabled (args[0] != 0), every time the guest gets an external interrupt 54988c2ecf20Sopenharmony_cidelivered, it automatically exits into user space with a KVM_EXIT_EPR exit 54998c2ecf20Sopenharmony_cito receive the topmost interrupt vector. 55008c2ecf20Sopenharmony_ci 55018c2ecf20Sopenharmony_ciWhen disabled (args[0] == 0), behavior is as if this facility is unsupported. 55028c2ecf20Sopenharmony_ci 55038c2ecf20Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_EPR can occur. 55048c2ecf20Sopenharmony_ci 55058c2ecf20Sopenharmony_ci6.6 KVM_CAP_IRQ_MPIC 55068c2ecf20Sopenharmony_ci-------------------- 55078c2ecf20Sopenharmony_ci 55088c2ecf20Sopenharmony_ci:Architectures: ppc 55098c2ecf20Sopenharmony_ci:Parameters: args[0] is the MPIC device fd; 55108c2ecf20Sopenharmony_ci args[1] is the MPIC CPU number for this vcpu 55118c2ecf20Sopenharmony_ci 55128c2ecf20Sopenharmony_ciThis capability connects the vcpu to an in-kernel MPIC device. 55138c2ecf20Sopenharmony_ci 55148c2ecf20Sopenharmony_ci6.7 KVM_CAP_IRQ_XICS 55158c2ecf20Sopenharmony_ci-------------------- 55168c2ecf20Sopenharmony_ci 55178c2ecf20Sopenharmony_ci:Architectures: ppc 55188c2ecf20Sopenharmony_ci:Target: vcpu 55198c2ecf20Sopenharmony_ci:Parameters: args[0] is the XICS device fd; 55208c2ecf20Sopenharmony_ci args[1] is the XICS CPU number (server ID) for this vcpu 55218c2ecf20Sopenharmony_ci 55228c2ecf20Sopenharmony_ciThis capability connects the vcpu to an in-kernel XICS device. 55238c2ecf20Sopenharmony_ci 55248c2ecf20Sopenharmony_ci6.8 KVM_CAP_S390_IRQCHIP 55258c2ecf20Sopenharmony_ci------------------------ 55268c2ecf20Sopenharmony_ci 55278c2ecf20Sopenharmony_ci:Architectures: s390 55288c2ecf20Sopenharmony_ci:Target: vm 55298c2ecf20Sopenharmony_ci:Parameters: none 55308c2ecf20Sopenharmony_ci 55318c2ecf20Sopenharmony_ciThis capability enables the in-kernel irqchip for s390. Please refer to 55328c2ecf20Sopenharmony_ci"4.24 KVM_CREATE_IRQCHIP" for details. 55338c2ecf20Sopenharmony_ci 55348c2ecf20Sopenharmony_ci6.9 KVM_CAP_MIPS_FPU 55358c2ecf20Sopenharmony_ci-------------------- 55368c2ecf20Sopenharmony_ci 55378c2ecf20Sopenharmony_ci:Architectures: mips 55388c2ecf20Sopenharmony_ci:Target: vcpu 55398c2ecf20Sopenharmony_ci:Parameters: args[0] is reserved for future use (should be 0). 55408c2ecf20Sopenharmony_ci 55418c2ecf20Sopenharmony_ciThis capability allows the use of the host Floating Point Unit by the guest. It 55428c2ecf20Sopenharmony_ciallows the Config1.FP bit to be set to enable the FPU in the guest. Once this is 55438c2ecf20Sopenharmony_cidone the ``KVM_REG_MIPS_FPR_*`` and ``KVM_REG_MIPS_FCR_*`` registers can be 55448c2ecf20Sopenharmony_ciaccessed (depending on the current guest FPU register mode), and the Status.FR, 55458c2ecf20Sopenharmony_ciConfig5.FRE bits are accessible via the KVM API and also from the guest, 55468c2ecf20Sopenharmony_cidepending on them being supported by the FPU. 55478c2ecf20Sopenharmony_ci 55488c2ecf20Sopenharmony_ci6.10 KVM_CAP_MIPS_MSA 55498c2ecf20Sopenharmony_ci--------------------- 55508c2ecf20Sopenharmony_ci 55518c2ecf20Sopenharmony_ci:Architectures: mips 55528c2ecf20Sopenharmony_ci:Target: vcpu 55538c2ecf20Sopenharmony_ci:Parameters: args[0] is reserved for future use (should be 0). 55548c2ecf20Sopenharmony_ci 55558c2ecf20Sopenharmony_ciThis capability allows the use of the MIPS SIMD Architecture (MSA) by the guest. 55568c2ecf20Sopenharmony_ciIt allows the Config3.MSAP bit to be set to enable the use of MSA by the guest. 55578c2ecf20Sopenharmony_ciOnce this is done the ``KVM_REG_MIPS_VEC_*`` and ``KVM_REG_MIPS_MSA_*`` 55588c2ecf20Sopenharmony_ciregisters can be accessed, and the Config5.MSAEn bit is accessible via the 55598c2ecf20Sopenharmony_ciKVM API and also from the guest. 55608c2ecf20Sopenharmony_ci 55618c2ecf20Sopenharmony_ci6.74 KVM_CAP_SYNC_REGS 55628c2ecf20Sopenharmony_ci---------------------- 55638c2ecf20Sopenharmony_ci 55648c2ecf20Sopenharmony_ci:Architectures: s390, x86 55658c2ecf20Sopenharmony_ci:Target: s390: always enabled, x86: vcpu 55668c2ecf20Sopenharmony_ci:Parameters: none 55678c2ecf20Sopenharmony_ci:Returns: x86: KVM_CHECK_EXTENSION returns a bit-array indicating which register 55688c2ecf20Sopenharmony_ci sets are supported 55698c2ecf20Sopenharmony_ci (bitfields defined in arch/x86/include/uapi/asm/kvm.h). 55708c2ecf20Sopenharmony_ci 55718c2ecf20Sopenharmony_ciAs described above in the kvm_sync_regs struct info in section 5 (kvm_run): 55728c2ecf20Sopenharmony_ciKVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers 55738c2ecf20Sopenharmony_ciwithout having to call SET/GET_*REGS". This reduces overhead by eliminating 55748c2ecf20Sopenharmony_cirepeated ioctl calls for setting and/or getting register values. This is 55758c2ecf20Sopenharmony_ciparticularly important when userspace is making synchronous guest state 55768c2ecf20Sopenharmony_cimodifications, e.g. when emulating and/or intercepting instructions in 55778c2ecf20Sopenharmony_ciuserspace. 55788c2ecf20Sopenharmony_ci 55798c2ecf20Sopenharmony_ciFor s390 specifics, please refer to the source code. 55808c2ecf20Sopenharmony_ci 55818c2ecf20Sopenharmony_ciFor x86: 55828c2ecf20Sopenharmony_ci 55838c2ecf20Sopenharmony_ci- the register sets to be copied out to kvm_run are selectable 55848c2ecf20Sopenharmony_ci by userspace (rather that all sets being copied out for every exit). 55858c2ecf20Sopenharmony_ci- vcpu_events are available in addition to regs and sregs. 55868c2ecf20Sopenharmony_ci 55878c2ecf20Sopenharmony_ciFor x86, the 'kvm_valid_regs' field of struct kvm_run is overloaded to 55888c2ecf20Sopenharmony_cifunction as an input bit-array field set by userspace to indicate the 55898c2ecf20Sopenharmony_cispecific register sets to be copied out on the next exit. 55908c2ecf20Sopenharmony_ci 55918c2ecf20Sopenharmony_ciTo indicate when userspace has modified values that should be copied into 55928c2ecf20Sopenharmony_cithe vCPU, the all architecture bitarray field, 'kvm_dirty_regs' must be set. 55938c2ecf20Sopenharmony_ciThis is done using the same bitflags as for the 'kvm_valid_regs' field. 55948c2ecf20Sopenharmony_ciIf the dirty bit is not set, then the register set values will not be copied 55958c2ecf20Sopenharmony_ciinto the vCPU even if they've been modified. 55968c2ecf20Sopenharmony_ci 55978c2ecf20Sopenharmony_ciUnused bitfields in the bitarrays must be set to zero. 55988c2ecf20Sopenharmony_ci 55998c2ecf20Sopenharmony_ci:: 56008c2ecf20Sopenharmony_ci 56018c2ecf20Sopenharmony_ci struct kvm_sync_regs { 56028c2ecf20Sopenharmony_ci struct kvm_regs regs; 56038c2ecf20Sopenharmony_ci struct kvm_sregs sregs; 56048c2ecf20Sopenharmony_ci struct kvm_vcpu_events events; 56058c2ecf20Sopenharmony_ci }; 56068c2ecf20Sopenharmony_ci 56078c2ecf20Sopenharmony_ci6.75 KVM_CAP_PPC_IRQ_XIVE 56088c2ecf20Sopenharmony_ci------------------------- 56098c2ecf20Sopenharmony_ci 56108c2ecf20Sopenharmony_ci:Architectures: ppc 56118c2ecf20Sopenharmony_ci:Target: vcpu 56128c2ecf20Sopenharmony_ci:Parameters: args[0] is the XIVE device fd; 56138c2ecf20Sopenharmony_ci args[1] is the XIVE CPU number (server ID) for this vcpu 56148c2ecf20Sopenharmony_ci 56158c2ecf20Sopenharmony_ciThis capability connects the vcpu to an in-kernel XIVE device. 56168c2ecf20Sopenharmony_ci 56178c2ecf20Sopenharmony_ci7. Capabilities that can be enabled on VMs 56188c2ecf20Sopenharmony_ci========================================== 56198c2ecf20Sopenharmony_ci 56208c2ecf20Sopenharmony_ciThere are certain capabilities that change the behavior of the virtual 56218c2ecf20Sopenharmony_cimachine when enabled. To enable them, please see section 4.37. Below 56228c2ecf20Sopenharmony_ciyou can find a list of capabilities and what their effect on the VM 56238c2ecf20Sopenharmony_ciis when enabling them. 56248c2ecf20Sopenharmony_ci 56258c2ecf20Sopenharmony_ciThe following information is provided along with the description: 56268c2ecf20Sopenharmony_ci 56278c2ecf20Sopenharmony_ci Architectures: 56288c2ecf20Sopenharmony_ci which instruction set architectures provide this ioctl. 56298c2ecf20Sopenharmony_ci x86 includes both i386 and x86_64. 56308c2ecf20Sopenharmony_ci 56318c2ecf20Sopenharmony_ci Parameters: 56328c2ecf20Sopenharmony_ci what parameters are accepted by the capability. 56338c2ecf20Sopenharmony_ci 56348c2ecf20Sopenharmony_ci Returns: 56358c2ecf20Sopenharmony_ci the return value. General error numbers (EBADF, ENOMEM, EINVAL) 56368c2ecf20Sopenharmony_ci are not detailed, but errors with specific meanings are. 56378c2ecf20Sopenharmony_ci 56388c2ecf20Sopenharmony_ci 56398c2ecf20Sopenharmony_ci7.1 KVM_CAP_PPC_ENABLE_HCALL 56408c2ecf20Sopenharmony_ci---------------------------- 56418c2ecf20Sopenharmony_ci 56428c2ecf20Sopenharmony_ci:Architectures: ppc 56438c2ecf20Sopenharmony_ci:Parameters: args[0] is the sPAPR hcall number; 56448c2ecf20Sopenharmony_ci args[1] is 0 to disable, 1 to enable in-kernel handling 56458c2ecf20Sopenharmony_ci 56468c2ecf20Sopenharmony_ciThis capability controls whether individual sPAPR hypercalls (hcalls) 56478c2ecf20Sopenharmony_ciget handled by the kernel or not. Enabling or disabling in-kernel 56488c2ecf20Sopenharmony_cihandling of an hcall is effective across the VM. On creation, an 56498c2ecf20Sopenharmony_ciinitial set of hcalls are enabled for in-kernel handling, which 56508c2ecf20Sopenharmony_ciconsists of those hcalls for which in-kernel handlers were implemented 56518c2ecf20Sopenharmony_cibefore this capability was implemented. If disabled, the kernel will 56528c2ecf20Sopenharmony_cinot to attempt to handle the hcall, but will always exit to userspace 56538c2ecf20Sopenharmony_cito handle it. Note that it may not make sense to enable some and 56548c2ecf20Sopenharmony_cidisable others of a group of related hcalls, but KVM does not prevent 56558c2ecf20Sopenharmony_ciuserspace from doing that. 56568c2ecf20Sopenharmony_ci 56578c2ecf20Sopenharmony_ciIf the hcall number specified is not one that has an in-kernel 56588c2ecf20Sopenharmony_ciimplementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL 56598c2ecf20Sopenharmony_cierror. 56608c2ecf20Sopenharmony_ci 56618c2ecf20Sopenharmony_ci7.2 KVM_CAP_S390_USER_SIGP 56628c2ecf20Sopenharmony_ci-------------------------- 56638c2ecf20Sopenharmony_ci 56648c2ecf20Sopenharmony_ci:Architectures: s390 56658c2ecf20Sopenharmony_ci:Parameters: none 56668c2ecf20Sopenharmony_ci 56678c2ecf20Sopenharmony_ciThis capability controls which SIGP orders will be handled completely in user 56688c2ecf20Sopenharmony_cispace. With this capability enabled, all fast orders will be handled completely 56698c2ecf20Sopenharmony_ciin the kernel: 56708c2ecf20Sopenharmony_ci 56718c2ecf20Sopenharmony_ci- SENSE 56728c2ecf20Sopenharmony_ci- SENSE RUNNING 56738c2ecf20Sopenharmony_ci- EXTERNAL CALL 56748c2ecf20Sopenharmony_ci- EMERGENCY SIGNAL 56758c2ecf20Sopenharmony_ci- CONDITIONAL EMERGENCY SIGNAL 56768c2ecf20Sopenharmony_ci 56778c2ecf20Sopenharmony_ciAll other orders will be handled completely in user space. 56788c2ecf20Sopenharmony_ci 56798c2ecf20Sopenharmony_ciOnly privileged operation exceptions will be checked for in the kernel (or even 56808c2ecf20Sopenharmony_ciin the hardware prior to interception). If this capability is not enabled, the 56818c2ecf20Sopenharmony_ciold way of handling SIGP orders is used (partially in kernel and user space). 56828c2ecf20Sopenharmony_ci 56838c2ecf20Sopenharmony_ci7.3 KVM_CAP_S390_VECTOR_REGISTERS 56848c2ecf20Sopenharmony_ci--------------------------------- 56858c2ecf20Sopenharmony_ci 56868c2ecf20Sopenharmony_ci:Architectures: s390 56878c2ecf20Sopenharmony_ci:Parameters: none 56888c2ecf20Sopenharmony_ci:Returns: 0 on success, negative value on error 56898c2ecf20Sopenharmony_ci 56908c2ecf20Sopenharmony_ciAllows use of the vector registers introduced with z13 processor, and 56918c2ecf20Sopenharmony_ciprovides for the synchronization between host and user space. Will 56928c2ecf20Sopenharmony_cireturn -EINVAL if the machine does not support vectors. 56938c2ecf20Sopenharmony_ci 56948c2ecf20Sopenharmony_ci7.4 KVM_CAP_S390_USER_STSI 56958c2ecf20Sopenharmony_ci-------------------------- 56968c2ecf20Sopenharmony_ci 56978c2ecf20Sopenharmony_ci:Architectures: s390 56988c2ecf20Sopenharmony_ci:Parameters: none 56998c2ecf20Sopenharmony_ci 57008c2ecf20Sopenharmony_ciThis capability allows post-handlers for the STSI instruction. After 57018c2ecf20Sopenharmony_ciinitial handling in the kernel, KVM exits to user space with 57028c2ecf20Sopenharmony_ciKVM_EXIT_S390_STSI to allow user space to insert further data. 57038c2ecf20Sopenharmony_ci 57048c2ecf20Sopenharmony_ciBefore exiting to userspace, kvm handlers should fill in s390_stsi field of 57058c2ecf20Sopenharmony_civcpu->run:: 57068c2ecf20Sopenharmony_ci 57078c2ecf20Sopenharmony_ci struct { 57088c2ecf20Sopenharmony_ci __u64 addr; 57098c2ecf20Sopenharmony_ci __u8 ar; 57108c2ecf20Sopenharmony_ci __u8 reserved; 57118c2ecf20Sopenharmony_ci __u8 fc; 57128c2ecf20Sopenharmony_ci __u8 sel1; 57138c2ecf20Sopenharmony_ci __u16 sel2; 57148c2ecf20Sopenharmony_ci } s390_stsi; 57158c2ecf20Sopenharmony_ci 57168c2ecf20Sopenharmony_ci @addr - guest address of STSI SYSIB 57178c2ecf20Sopenharmony_ci @fc - function code 57188c2ecf20Sopenharmony_ci @sel1 - selector 1 57198c2ecf20Sopenharmony_ci @sel2 - selector 2 57208c2ecf20Sopenharmony_ci @ar - access register number 57218c2ecf20Sopenharmony_ci 57228c2ecf20Sopenharmony_ciKVM handlers should exit to userspace with rc = -EREMOTE. 57238c2ecf20Sopenharmony_ci 57248c2ecf20Sopenharmony_ci7.5 KVM_CAP_SPLIT_IRQCHIP 57258c2ecf20Sopenharmony_ci------------------------- 57268c2ecf20Sopenharmony_ci 57278c2ecf20Sopenharmony_ci:Architectures: x86 57288c2ecf20Sopenharmony_ci:Parameters: args[0] - number of routes reserved for userspace IOAPICs 57298c2ecf20Sopenharmony_ci:Returns: 0 on success, -1 on error 57308c2ecf20Sopenharmony_ci 57318c2ecf20Sopenharmony_ciCreate a local apic for each processor in the kernel. This can be used 57328c2ecf20Sopenharmony_ciinstead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the 57338c2ecf20Sopenharmony_ciIOAPIC and PIC (and also the PIT, even though this has to be enabled 57348c2ecf20Sopenharmony_ciseparately). 57358c2ecf20Sopenharmony_ci 57368c2ecf20Sopenharmony_ciThis capability also enables in kernel routing of interrupt requests; 57378c2ecf20Sopenharmony_ciwhen KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are 57388c2ecf20Sopenharmony_ciused in the IRQ routing table. The first args[0] MSI routes are reserved 57398c2ecf20Sopenharmony_cifor the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes, 57408c2ecf20Sopenharmony_cia KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace. 57418c2ecf20Sopenharmony_ci 57428c2ecf20Sopenharmony_ciFails if VCPU has already been created, or if the irqchip is already in the 57438c2ecf20Sopenharmony_cikernel (i.e. KVM_CREATE_IRQCHIP has already been called). 57448c2ecf20Sopenharmony_ci 57458c2ecf20Sopenharmony_ci7.6 KVM_CAP_S390_RI 57468c2ecf20Sopenharmony_ci------------------- 57478c2ecf20Sopenharmony_ci 57488c2ecf20Sopenharmony_ci:Architectures: s390 57498c2ecf20Sopenharmony_ci:Parameters: none 57508c2ecf20Sopenharmony_ci 57518c2ecf20Sopenharmony_ciAllows use of runtime-instrumentation introduced with zEC12 processor. 57528c2ecf20Sopenharmony_ciWill return -EINVAL if the machine does not support runtime-instrumentation. 57538c2ecf20Sopenharmony_ciWill return -EBUSY if a VCPU has already been created. 57548c2ecf20Sopenharmony_ci 57558c2ecf20Sopenharmony_ci7.7 KVM_CAP_X2APIC_API 57568c2ecf20Sopenharmony_ci---------------------- 57578c2ecf20Sopenharmony_ci 57588c2ecf20Sopenharmony_ci:Architectures: x86 57598c2ecf20Sopenharmony_ci:Parameters: args[0] - features that should be enabled 57608c2ecf20Sopenharmony_ci:Returns: 0 on success, -EINVAL when args[0] contains invalid features 57618c2ecf20Sopenharmony_ci 57628c2ecf20Sopenharmony_ciValid feature flags in args[0] are:: 57638c2ecf20Sopenharmony_ci 57648c2ecf20Sopenharmony_ci #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) 57658c2ecf20Sopenharmony_ci #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) 57668c2ecf20Sopenharmony_ci 57678c2ecf20Sopenharmony_ciEnabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of 57688c2ecf20Sopenharmony_ciKVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC, 57698c2ecf20Sopenharmony_ciallowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their 57708c2ecf20Sopenharmony_cirespective sections. 57718c2ecf20Sopenharmony_ci 57728c2ecf20Sopenharmony_ciKVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work 57738c2ecf20Sopenharmony_ciin logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff 57748c2ecf20Sopenharmony_cias a broadcast even in x2APIC mode in order to support physical x2APIC 57758c2ecf20Sopenharmony_ciwithout interrupt remapping. This is undesirable in logical mode, 57768c2ecf20Sopenharmony_ciwhere 0xff represents CPUs 0-7 in cluster 0. 57778c2ecf20Sopenharmony_ci 57788c2ecf20Sopenharmony_ci7.8 KVM_CAP_S390_USER_INSTR0 57798c2ecf20Sopenharmony_ci---------------------------- 57808c2ecf20Sopenharmony_ci 57818c2ecf20Sopenharmony_ci:Architectures: s390 57828c2ecf20Sopenharmony_ci:Parameters: none 57838c2ecf20Sopenharmony_ci 57848c2ecf20Sopenharmony_ciWith this capability enabled, all illegal instructions 0x0000 (2 bytes) will 57858c2ecf20Sopenharmony_cibe intercepted and forwarded to user space. User space can use this 57868c2ecf20Sopenharmony_cimechanism e.g. to realize 2-byte software breakpoints. The kernel will 57878c2ecf20Sopenharmony_cinot inject an operating exception for these instructions, user space has 57888c2ecf20Sopenharmony_cito take care of that. 57898c2ecf20Sopenharmony_ci 57908c2ecf20Sopenharmony_ciThis capability can be enabled dynamically even if VCPUs were already 57918c2ecf20Sopenharmony_cicreated and are running. 57928c2ecf20Sopenharmony_ci 57938c2ecf20Sopenharmony_ci7.9 KVM_CAP_S390_GS 57948c2ecf20Sopenharmony_ci------------------- 57958c2ecf20Sopenharmony_ci 57968c2ecf20Sopenharmony_ci:Architectures: s390 57978c2ecf20Sopenharmony_ci:Parameters: none 57988c2ecf20Sopenharmony_ci:Returns: 0 on success; -EINVAL if the machine does not support 57998c2ecf20Sopenharmony_ci guarded storage; -EBUSY if a VCPU has already been created. 58008c2ecf20Sopenharmony_ci 58018c2ecf20Sopenharmony_ciAllows use of guarded storage for the KVM guest. 58028c2ecf20Sopenharmony_ci 58038c2ecf20Sopenharmony_ci7.10 KVM_CAP_S390_AIS 58048c2ecf20Sopenharmony_ci--------------------- 58058c2ecf20Sopenharmony_ci 58068c2ecf20Sopenharmony_ci:Architectures: s390 58078c2ecf20Sopenharmony_ci:Parameters: none 58088c2ecf20Sopenharmony_ci 58098c2ecf20Sopenharmony_ciAllow use of adapter-interruption suppression. 58108c2ecf20Sopenharmony_ci:Returns: 0 on success; -EBUSY if a VCPU has already been created. 58118c2ecf20Sopenharmony_ci 58128c2ecf20Sopenharmony_ci7.11 KVM_CAP_PPC_SMT 58138c2ecf20Sopenharmony_ci-------------------- 58148c2ecf20Sopenharmony_ci 58158c2ecf20Sopenharmony_ci:Architectures: ppc 58168c2ecf20Sopenharmony_ci:Parameters: vsmt_mode, flags 58178c2ecf20Sopenharmony_ci 58188c2ecf20Sopenharmony_ciEnabling this capability on a VM provides userspace with a way to set 58198c2ecf20Sopenharmony_cithe desired virtual SMT mode (i.e. the number of virtual CPUs per 58208c2ecf20Sopenharmony_civirtual core). The virtual SMT mode, vsmt_mode, must be a power of 2 58218c2ecf20Sopenharmony_cibetween 1 and 8. On POWER8, vsmt_mode must also be no greater than 58228c2ecf20Sopenharmony_cithe number of threads per subcore for the host. Currently flags must 58238c2ecf20Sopenharmony_cibe 0. A successful call to enable this capability will result in 58248c2ecf20Sopenharmony_civsmt_mode being returned when the KVM_CAP_PPC_SMT capability is 58258c2ecf20Sopenharmony_cisubsequently queried for the VM. This capability is only supported by 58268c2ecf20Sopenharmony_ciHV KVM, and can only be set before any VCPUs have been created. 58278c2ecf20Sopenharmony_ciThe KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT 58288c2ecf20Sopenharmony_cimodes are available. 58298c2ecf20Sopenharmony_ci 58308c2ecf20Sopenharmony_ci7.12 KVM_CAP_PPC_FWNMI 58318c2ecf20Sopenharmony_ci---------------------- 58328c2ecf20Sopenharmony_ci 58338c2ecf20Sopenharmony_ci:Architectures: ppc 58348c2ecf20Sopenharmony_ci:Parameters: none 58358c2ecf20Sopenharmony_ci 58368c2ecf20Sopenharmony_ciWith this capability a machine check exception in the guest address 58378c2ecf20Sopenharmony_cispace will cause KVM to exit the guest with NMI exit reason. This 58388c2ecf20Sopenharmony_cienables QEMU to build error log and branch to guest kernel registered 58398c2ecf20Sopenharmony_cimachine check handling routine. Without this capability KVM will 58408c2ecf20Sopenharmony_cibranch to guests' 0x200 interrupt vector. 58418c2ecf20Sopenharmony_ci 58428c2ecf20Sopenharmony_ci7.13 KVM_CAP_X86_DISABLE_EXITS 58438c2ecf20Sopenharmony_ci------------------------------ 58448c2ecf20Sopenharmony_ci 58458c2ecf20Sopenharmony_ci:Architectures: x86 58468c2ecf20Sopenharmony_ci:Parameters: args[0] defines which exits are disabled 58478c2ecf20Sopenharmony_ci:Returns: 0 on success, -EINVAL when args[0] contains invalid exits 58488c2ecf20Sopenharmony_ci 58498c2ecf20Sopenharmony_ciValid bits in args[0] are:: 58508c2ecf20Sopenharmony_ci 58518c2ecf20Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) 58528c2ecf20Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 58538c2ecf20Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 58548c2ecf20Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) 58558c2ecf20Sopenharmony_ci 58568c2ecf20Sopenharmony_ciEnabling this capability on a VM provides userspace with a way to no 58578c2ecf20Sopenharmony_cilonger intercept some instructions for improved latency in some 58588c2ecf20Sopenharmony_ciworkloads, and is suggested when vCPUs are associated to dedicated 58598c2ecf20Sopenharmony_ciphysical CPUs. More bits can be added in the future; userspace can 58608c2ecf20Sopenharmony_cijust pass the KVM_CHECK_EXTENSION result to KVM_ENABLE_CAP to disable 58618c2ecf20Sopenharmony_ciall such vmexits. 58628c2ecf20Sopenharmony_ci 58638c2ecf20Sopenharmony_ciDo not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits. 58648c2ecf20Sopenharmony_ci 58658c2ecf20Sopenharmony_ci7.14 KVM_CAP_S390_HPAGE_1M 58668c2ecf20Sopenharmony_ci-------------------------- 58678c2ecf20Sopenharmony_ci 58688c2ecf20Sopenharmony_ci:Architectures: s390 58698c2ecf20Sopenharmony_ci:Parameters: none 58708c2ecf20Sopenharmony_ci:Returns: 0 on success, -EINVAL if hpage module parameter was not set 58718c2ecf20Sopenharmony_ci or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL 58728c2ecf20Sopenharmony_ci flag set 58738c2ecf20Sopenharmony_ci 58748c2ecf20Sopenharmony_ciWith this capability the KVM support for memory backing with 1m pages 58758c2ecf20Sopenharmony_cithrough hugetlbfs can be enabled for a VM. After the capability is 58768c2ecf20Sopenharmony_cienabled, cmma can't be enabled anymore and pfmfi and the storage key 58778c2ecf20Sopenharmony_ciinterpretation are disabled. If cmma has already been enabled or the 58788c2ecf20Sopenharmony_cihpage module parameter is not set to 1, -EINVAL is returned. 58798c2ecf20Sopenharmony_ci 58808c2ecf20Sopenharmony_ciWhile it is generally possible to create a huge page backed VM without 58818c2ecf20Sopenharmony_cithis capability, the VM will not be able to run. 58828c2ecf20Sopenharmony_ci 58838c2ecf20Sopenharmony_ci7.15 KVM_CAP_MSR_PLATFORM_INFO 58848c2ecf20Sopenharmony_ci------------------------------ 58858c2ecf20Sopenharmony_ci 58868c2ecf20Sopenharmony_ci:Architectures: x86 58878c2ecf20Sopenharmony_ci:Parameters: args[0] whether feature should be enabled or not 58888c2ecf20Sopenharmony_ci 58898c2ecf20Sopenharmony_ciWith this capability, a guest may read the MSR_PLATFORM_INFO MSR. Otherwise, 58908c2ecf20Sopenharmony_cia #GP would be raised when the guest tries to access. Currently, this 58918c2ecf20Sopenharmony_cicapability does not enable write permissions of this MSR for the guest. 58928c2ecf20Sopenharmony_ci 58938c2ecf20Sopenharmony_ci7.16 KVM_CAP_PPC_NESTED_HV 58948c2ecf20Sopenharmony_ci-------------------------- 58958c2ecf20Sopenharmony_ci 58968c2ecf20Sopenharmony_ci:Architectures: ppc 58978c2ecf20Sopenharmony_ci:Parameters: none 58988c2ecf20Sopenharmony_ci:Returns: 0 on success, -EINVAL when the implementation doesn't support 58998c2ecf20Sopenharmony_ci nested-HV virtualization. 59008c2ecf20Sopenharmony_ci 59018c2ecf20Sopenharmony_ciHV-KVM on POWER9 and later systems allows for "nested-HV" 59028c2ecf20Sopenharmony_civirtualization, which provides a way for a guest VM to run guests that 59038c2ecf20Sopenharmony_cican run using the CPU's supervisor mode (privileged non-hypervisor 59048c2ecf20Sopenharmony_cistate). Enabling this capability on a VM depends on the CPU having 59058c2ecf20Sopenharmony_cithe necessary functionality and on the facility being enabled with a 59068c2ecf20Sopenharmony_cikvm-hv module parameter. 59078c2ecf20Sopenharmony_ci 59088c2ecf20Sopenharmony_ci7.17 KVM_CAP_EXCEPTION_PAYLOAD 59098c2ecf20Sopenharmony_ci------------------------------ 59108c2ecf20Sopenharmony_ci 59118c2ecf20Sopenharmony_ci:Architectures: x86 59128c2ecf20Sopenharmony_ci:Parameters: args[0] whether feature should be enabled or not 59138c2ecf20Sopenharmony_ci 59148c2ecf20Sopenharmony_ciWith this capability enabled, CR2 will not be modified prior to the 59158c2ecf20Sopenharmony_ciemulated VM-exit when L1 intercepts a #PF exception that occurs in 59168c2ecf20Sopenharmony_ciL2. Similarly, for kvm-intel only, DR6 will not be modified prior to 59178c2ecf20Sopenharmony_cithe emulated VM-exit when L1 intercepts a #DB exception that occurs in 59188c2ecf20Sopenharmony_ciL2. As a result, when KVM_GET_VCPU_EVENTS reports a pending #PF (or 59198c2ecf20Sopenharmony_ci#DB) exception for L2, exception.has_payload will be set and the 59208c2ecf20Sopenharmony_cifaulting address (or the new DR6 bits*) will be reported in the 59218c2ecf20Sopenharmony_ciexception_payload field. Similarly, when userspace injects a #PF (or 59228c2ecf20Sopenharmony_ci#DB) into L2 using KVM_SET_VCPU_EVENTS, it is expected to set 59238c2ecf20Sopenharmony_ciexception.has_payload and to put the faulting address - or the new DR6 59248c2ecf20Sopenharmony_cibits\ [#]_ - in the exception_payload field. 59258c2ecf20Sopenharmony_ci 59268c2ecf20Sopenharmony_ciThis capability also enables exception.pending in struct 59278c2ecf20Sopenharmony_cikvm_vcpu_events, which allows userspace to distinguish between pending 59288c2ecf20Sopenharmony_ciand injected exceptions. 59298c2ecf20Sopenharmony_ci 59308c2ecf20Sopenharmony_ci 59318c2ecf20Sopenharmony_ci.. [#] For the new DR6 bits, note that bit 16 is set iff the #DB exception 59328c2ecf20Sopenharmony_ci will clear DR6.RTM. 59338c2ecf20Sopenharmony_ci 59348c2ecf20Sopenharmony_ci7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 59358c2ecf20Sopenharmony_ci 59368c2ecf20Sopenharmony_ci:Architectures: x86, arm, arm64, mips 59378c2ecf20Sopenharmony_ci:Parameters: args[0] whether feature should be enabled or not 59388c2ecf20Sopenharmony_ci 59398c2ecf20Sopenharmony_ciValid flags are:: 59408c2ecf20Sopenharmony_ci 59418c2ecf20Sopenharmony_ci #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) 59428c2ecf20Sopenharmony_ci #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) 59438c2ecf20Sopenharmony_ci 59448c2ecf20Sopenharmony_ciWith KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE is set, KVM_GET_DIRTY_LOG will not 59458c2ecf20Sopenharmony_ciautomatically clear and write-protect all pages that are returned as dirty. 59468c2ecf20Sopenharmony_ciRather, userspace will have to do this operation separately using 59478c2ecf20Sopenharmony_ciKVM_CLEAR_DIRTY_LOG. 59488c2ecf20Sopenharmony_ci 59498c2ecf20Sopenharmony_ciAt the cost of a slightly more complicated operation, this provides better 59508c2ecf20Sopenharmony_ciscalability and responsiveness for two reasons. First, 59518c2ecf20Sopenharmony_ciKVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather 59528c2ecf20Sopenharmony_cithan requiring to sync a full memslot; this ensures that KVM does not 59538c2ecf20Sopenharmony_citake spinlocks for an extended period of time. Second, in some cases a 59548c2ecf20Sopenharmony_cilarge amount of time can pass between a call to KVM_GET_DIRTY_LOG and 59558c2ecf20Sopenharmony_ciuserspace actually using the data in the page. Pages can be modified 59568c2ecf20Sopenharmony_ciduring this time, which is inefficient for both the guest and userspace: 59578c2ecf20Sopenharmony_cithe guest will incur a higher penalty due to write protection faults, 59588c2ecf20Sopenharmony_ciwhile userspace can see false reports of dirty pages. Manual reprotection 59598c2ecf20Sopenharmony_cihelps reducing this time, improving guest performance and reducing the 59608c2ecf20Sopenharmony_cinumber of dirty log false positives. 59618c2ecf20Sopenharmony_ci 59628c2ecf20Sopenharmony_ciWith KVM_DIRTY_LOG_INITIALLY_SET set, all the bits of the dirty bitmap 59638c2ecf20Sopenharmony_ciwill be initialized to 1 when created. This also improves performance because 59648c2ecf20Sopenharmony_cidirty logging can be enabled gradually in small chunks on the first call 59658c2ecf20Sopenharmony_cito KVM_CLEAR_DIRTY_LOG. KVM_DIRTY_LOG_INITIALLY_SET depends on 59668c2ecf20Sopenharmony_ciKVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (it is also only available on 59678c2ecf20Sopenharmony_cix86 and arm64 for now). 59688c2ecf20Sopenharmony_ci 59698c2ecf20Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 was previously available under the name 59708c2ecf20Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT, but the implementation had bugs that make 59718c2ecf20Sopenharmony_ciit hard or impossible to use it correctly. The availability of 59728c2ecf20Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 signals that those bugs are fixed. 59738c2ecf20Sopenharmony_ciUserspace should not try to use KVM_CAP_MANUAL_DIRTY_LOG_PROTECT. 59748c2ecf20Sopenharmony_ci 59758c2ecf20Sopenharmony_ci7.19 KVM_CAP_PPC_SECURE_GUEST 59768c2ecf20Sopenharmony_ci------------------------------ 59778c2ecf20Sopenharmony_ci 59788c2ecf20Sopenharmony_ci:Architectures: ppc 59798c2ecf20Sopenharmony_ci 59808c2ecf20Sopenharmony_ciThis capability indicates that KVM is running on a host that has 59818c2ecf20Sopenharmony_ciultravisor firmware and thus can support a secure guest. On such a 59828c2ecf20Sopenharmony_cisystem, a guest can ask the ultravisor to make it a secure guest, 59838c2ecf20Sopenharmony_cione whose memory is inaccessible to the host except for pages which 59848c2ecf20Sopenharmony_ciare explicitly requested to be shared with the host. The ultravisor 59858c2ecf20Sopenharmony_cinotifies KVM when a guest requests to become a secure guest, and KVM 59868c2ecf20Sopenharmony_cihas the opportunity to veto the transition. 59878c2ecf20Sopenharmony_ci 59888c2ecf20Sopenharmony_ciIf present, this capability can be enabled for a VM, meaning that KVM 59898c2ecf20Sopenharmony_ciwill allow the transition to secure guest mode. Otherwise KVM will 59908c2ecf20Sopenharmony_civeto the transition. 59918c2ecf20Sopenharmony_ci 59928c2ecf20Sopenharmony_ci7.20 KVM_CAP_HALT_POLL 59938c2ecf20Sopenharmony_ci---------------------- 59948c2ecf20Sopenharmony_ci 59958c2ecf20Sopenharmony_ci:Architectures: all 59968c2ecf20Sopenharmony_ci:Target: VM 59978c2ecf20Sopenharmony_ci:Parameters: args[0] is the maximum poll time in nanoseconds 59988c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 59998c2ecf20Sopenharmony_ci 60008c2ecf20Sopenharmony_ciThis capability overrides the kvm module parameter halt_poll_ns for the 60018c2ecf20Sopenharmony_citarget VM. 60028c2ecf20Sopenharmony_ci 60038c2ecf20Sopenharmony_ciVCPU polling allows a VCPU to poll for wakeup events instead of immediately 60048c2ecf20Sopenharmony_cischeduling during guest halts. The maximum time a VCPU can spend polling is 60058c2ecf20Sopenharmony_cicontrolled by the kvm module parameter halt_poll_ns. This capability allows 60068c2ecf20Sopenharmony_cithe maximum halt time to specified on a per-VM basis, effectively overriding 60078c2ecf20Sopenharmony_cithe module parameter for the target VM. 60088c2ecf20Sopenharmony_ci 60098c2ecf20Sopenharmony_ci7.21 KVM_CAP_X86_USER_SPACE_MSR 60108c2ecf20Sopenharmony_ci------------------------------- 60118c2ecf20Sopenharmony_ci 60128c2ecf20Sopenharmony_ci:Architectures: x86 60138c2ecf20Sopenharmony_ci:Target: VM 60148c2ecf20Sopenharmony_ci:Parameters: args[0] contains the mask of KVM_MSR_EXIT_REASON_* events to report 60158c2ecf20Sopenharmony_ci:Returns: 0 on success; -1 on error 60168c2ecf20Sopenharmony_ci 60178c2ecf20Sopenharmony_ciThis capability enables trapping of #GP invoking RDMSR and WRMSR instructions 60188c2ecf20Sopenharmony_ciinto user space. 60198c2ecf20Sopenharmony_ci 60208c2ecf20Sopenharmony_ciWhen a guest requests to read or write an MSR, KVM may not implement all MSRs 60218c2ecf20Sopenharmony_cithat are relevant to a respective system. It also does not differentiate by 60228c2ecf20Sopenharmony_ciCPU type. 60238c2ecf20Sopenharmony_ci 60248c2ecf20Sopenharmony_ciTo allow more fine grained control over MSR handling, user space may enable 60258c2ecf20Sopenharmony_cithis capability. With it enabled, MSR accesses that match the mask specified in 60268c2ecf20Sopenharmony_ciargs[0] and trigger a #GP event inside the guest by KVM will instead trigger 60278c2ecf20Sopenharmony_ciKVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR exit notifications which user space 60288c2ecf20Sopenharmony_cican then handle to implement model specific MSR handling and/or user notifications 60298c2ecf20Sopenharmony_cito inform a user that an MSR was not handled. 60308c2ecf20Sopenharmony_ci 60318c2ecf20Sopenharmony_ci8. Other capabilities. 60328c2ecf20Sopenharmony_ci====================== 60338c2ecf20Sopenharmony_ci 60348c2ecf20Sopenharmony_ciThis section lists capabilities that give information about other 60358c2ecf20Sopenharmony_cifeatures of the KVM implementation. 60368c2ecf20Sopenharmony_ci 60378c2ecf20Sopenharmony_ci8.1 KVM_CAP_PPC_HWRNG 60388c2ecf20Sopenharmony_ci--------------------- 60398c2ecf20Sopenharmony_ci 60408c2ecf20Sopenharmony_ci:Architectures: ppc 60418c2ecf20Sopenharmony_ci 60428c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 60438c2ecf20Sopenharmony_ciavailable, means that the kernel has an implementation of the 60448c2ecf20Sopenharmony_ciH_RANDOM hypercall backed by a hardware random-number generator. 60458c2ecf20Sopenharmony_ciIf present, the kernel H_RANDOM handler can be enabled for guest use 60468c2ecf20Sopenharmony_ciwith the KVM_CAP_PPC_ENABLE_HCALL capability. 60478c2ecf20Sopenharmony_ci 60488c2ecf20Sopenharmony_ci8.2 KVM_CAP_HYPERV_SYNIC 60498c2ecf20Sopenharmony_ci------------------------ 60508c2ecf20Sopenharmony_ci 60518c2ecf20Sopenharmony_ci:Architectures: x86 60528c2ecf20Sopenharmony_ci 60538c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 60548c2ecf20Sopenharmony_ciavailable, means that the kernel has an implementation of the 60558c2ecf20Sopenharmony_ciHyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is 60568c2ecf20Sopenharmony_ciused to support Windows Hyper-V based guest paravirt drivers(VMBus). 60578c2ecf20Sopenharmony_ci 60588c2ecf20Sopenharmony_ciIn order to use SynIC, it has to be activated by setting this 60598c2ecf20Sopenharmony_cicapability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this 60608c2ecf20Sopenharmony_ciwill disable the use of APIC hardware virtualization even if supported 60618c2ecf20Sopenharmony_ciby the CPU, as it's incompatible with SynIC auto-EOI behavior. 60628c2ecf20Sopenharmony_ci 60638c2ecf20Sopenharmony_ci8.3 KVM_CAP_PPC_RADIX_MMU 60648c2ecf20Sopenharmony_ci------------------------- 60658c2ecf20Sopenharmony_ci 60668c2ecf20Sopenharmony_ci:Architectures: ppc 60678c2ecf20Sopenharmony_ci 60688c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 60698c2ecf20Sopenharmony_ciavailable, means that the kernel can support guests using the 60708c2ecf20Sopenharmony_ciradix MMU defined in Power ISA V3.00 (as implemented in the POWER9 60718c2ecf20Sopenharmony_ciprocessor). 60728c2ecf20Sopenharmony_ci 60738c2ecf20Sopenharmony_ci8.4 KVM_CAP_PPC_HASH_MMU_V3 60748c2ecf20Sopenharmony_ci--------------------------- 60758c2ecf20Sopenharmony_ci 60768c2ecf20Sopenharmony_ci:Architectures: ppc 60778c2ecf20Sopenharmony_ci 60788c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 60798c2ecf20Sopenharmony_ciavailable, means that the kernel can support guests using the 60808c2ecf20Sopenharmony_cihashed page table MMU defined in Power ISA V3.00 (as implemented in 60818c2ecf20Sopenharmony_cithe POWER9 processor), including in-memory segment tables. 60828c2ecf20Sopenharmony_ci 60838c2ecf20Sopenharmony_ci8.5 KVM_CAP_MIPS_VZ 60848c2ecf20Sopenharmony_ci------------------- 60858c2ecf20Sopenharmony_ci 60868c2ecf20Sopenharmony_ci:Architectures: mips 60878c2ecf20Sopenharmony_ci 60888c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that 60898c2ecf20Sopenharmony_ciit is available, means that full hardware assisted virtualization capabilities 60908c2ecf20Sopenharmony_ciof the hardware are available for use through KVM. An appropriate 60918c2ecf20Sopenharmony_ciKVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which 60928c2ecf20Sopenharmony_ciutilises it. 60938c2ecf20Sopenharmony_ci 60948c2ecf20Sopenharmony_ciIf KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is 60958c2ecf20Sopenharmony_ciavailable, it means that the VM is using full hardware assisted virtualization 60968c2ecf20Sopenharmony_cicapabilities of the hardware. This is useful to check after creating a VM with 60978c2ecf20Sopenharmony_ciKVM_VM_MIPS_DEFAULT. 60988c2ecf20Sopenharmony_ci 60998c2ecf20Sopenharmony_ciThe value returned by KVM_CHECK_EXTENSION should be compared against known 61008c2ecf20Sopenharmony_civalues (see below). All other values are reserved. This is to allow for the 61018c2ecf20Sopenharmony_cipossibility of other hardware assisted virtualization implementations which 61028c2ecf20Sopenharmony_cimay be incompatible with the MIPS VZ ASE. 61038c2ecf20Sopenharmony_ci 61048c2ecf20Sopenharmony_ci== ========================================================================== 61058c2ecf20Sopenharmony_ci 0 The trap & emulate implementation is in use to run guest code in user 61068c2ecf20Sopenharmony_ci mode. Guest virtual memory segments are rearranged to fit the guest in the 61078c2ecf20Sopenharmony_ci user mode address space. 61088c2ecf20Sopenharmony_ci 61098c2ecf20Sopenharmony_ci 1 The MIPS VZ ASE is in use, providing full hardware assisted 61108c2ecf20Sopenharmony_ci virtualization, including standard guest virtual memory segments. 61118c2ecf20Sopenharmony_ci== ========================================================================== 61128c2ecf20Sopenharmony_ci 61138c2ecf20Sopenharmony_ci8.6 KVM_CAP_MIPS_TE 61148c2ecf20Sopenharmony_ci------------------- 61158c2ecf20Sopenharmony_ci 61168c2ecf20Sopenharmony_ci:Architectures: mips 61178c2ecf20Sopenharmony_ci 61188c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that 61198c2ecf20Sopenharmony_ciit is available, means that the trap & emulate implementation is available to 61208c2ecf20Sopenharmony_cirun guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware 61218c2ecf20Sopenharmony_ciassisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed 61228c2ecf20Sopenharmony_cito KVM_CREATE_VM to create a VM which utilises it. 61238c2ecf20Sopenharmony_ci 61248c2ecf20Sopenharmony_ciIf KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is 61258c2ecf20Sopenharmony_ciavailable, it means that the VM is using trap & emulate. 61268c2ecf20Sopenharmony_ci 61278c2ecf20Sopenharmony_ci8.7 KVM_CAP_MIPS_64BIT 61288c2ecf20Sopenharmony_ci---------------------- 61298c2ecf20Sopenharmony_ci 61308c2ecf20Sopenharmony_ci:Architectures: mips 61318c2ecf20Sopenharmony_ci 61328c2ecf20Sopenharmony_ciThis capability indicates the supported architecture type of the guest, i.e. the 61338c2ecf20Sopenharmony_cisupported register and address width. 61348c2ecf20Sopenharmony_ci 61358c2ecf20Sopenharmony_ciThe values returned when this capability is checked by KVM_CHECK_EXTENSION on a 61368c2ecf20Sopenharmony_cikvm VM handle correspond roughly to the CP0_Config.AT register field, and should 61378c2ecf20Sopenharmony_cibe checked specifically against known values (see below). All other values are 61388c2ecf20Sopenharmony_cireserved. 61398c2ecf20Sopenharmony_ci 61408c2ecf20Sopenharmony_ci== ======================================================================== 61418c2ecf20Sopenharmony_ci 0 MIPS32 or microMIPS32. 61428c2ecf20Sopenharmony_ci Both registers and addresses are 32-bits wide. 61438c2ecf20Sopenharmony_ci It will only be possible to run 32-bit guest code. 61448c2ecf20Sopenharmony_ci 61458c2ecf20Sopenharmony_ci 1 MIPS64 or microMIPS64 with access only to 32-bit compatibility segments. 61468c2ecf20Sopenharmony_ci Registers are 64-bits wide, but addresses are 32-bits wide. 61478c2ecf20Sopenharmony_ci 64-bit guest code may run but cannot access MIPS64 memory segments. 61488c2ecf20Sopenharmony_ci It will also be possible to run 32-bit guest code. 61498c2ecf20Sopenharmony_ci 61508c2ecf20Sopenharmony_ci 2 MIPS64 or microMIPS64 with access to all address segments. 61518c2ecf20Sopenharmony_ci Both registers and addresses are 64-bits wide. 61528c2ecf20Sopenharmony_ci It will be possible to run 64-bit or 32-bit guest code. 61538c2ecf20Sopenharmony_ci== ======================================================================== 61548c2ecf20Sopenharmony_ci 61558c2ecf20Sopenharmony_ci8.9 KVM_CAP_ARM_USER_IRQ 61568c2ecf20Sopenharmony_ci------------------------ 61578c2ecf20Sopenharmony_ci 61588c2ecf20Sopenharmony_ci:Architectures: arm, arm64 61598c2ecf20Sopenharmony_ci 61608c2ecf20Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is available, means 61618c2ecf20Sopenharmony_cithat if userspace creates a VM without an in-kernel interrupt controller, it 61628c2ecf20Sopenharmony_ciwill be notified of changes to the output level of in-kernel emulated devices, 61638c2ecf20Sopenharmony_ciwhich can generate virtual interrupts, presented to the VM. 61648c2ecf20Sopenharmony_ciFor such VMs, on every return to userspace, the kernel 61658c2ecf20Sopenharmony_ciupdates the vcpu's run->s.regs.device_irq_level field to represent the actual 61668c2ecf20Sopenharmony_cioutput level of the device. 61678c2ecf20Sopenharmony_ci 61688c2ecf20Sopenharmony_ciWhenever kvm detects a change in the device output level, kvm guarantees at 61698c2ecf20Sopenharmony_cileast one return to userspace before running the VM. This exit could either 61708c2ecf20Sopenharmony_cibe a KVM_EXIT_INTR or any other exit event, like KVM_EXIT_MMIO. This way, 61718c2ecf20Sopenharmony_ciuserspace can always sample the device output level and re-compute the state of 61728c2ecf20Sopenharmony_cithe userspace interrupt controller. Userspace should always check the state 61738c2ecf20Sopenharmony_ciof run->s.regs.device_irq_level on every kvm exit. 61748c2ecf20Sopenharmony_ciThe value in run->s.regs.device_irq_level can represent both level and edge 61758c2ecf20Sopenharmony_citriggered interrupt signals, depending on the device. Edge triggered interrupt 61768c2ecf20Sopenharmony_cisignals will exit to userspace with the bit in run->s.regs.device_irq_level 61778c2ecf20Sopenharmony_ciset exactly once per edge signal. 61788c2ecf20Sopenharmony_ci 61798c2ecf20Sopenharmony_ciThe field run->s.regs.device_irq_level is available independent of 61808c2ecf20Sopenharmony_cirun->kvm_valid_regs or run->kvm_dirty_regs bits. 61818c2ecf20Sopenharmony_ci 61828c2ecf20Sopenharmony_ciIf KVM_CAP_ARM_USER_IRQ is supported, the KVM_CHECK_EXTENSION ioctl returns a 61838c2ecf20Sopenharmony_cinumber larger than 0 indicating the version of this capability is implemented 61848c2ecf20Sopenharmony_ciand thereby which bits in run->s.regs.device_irq_level can signal values. 61858c2ecf20Sopenharmony_ci 61868c2ecf20Sopenharmony_ciCurrently the following bits are defined for the device_irq_level bitmap:: 61878c2ecf20Sopenharmony_ci 61888c2ecf20Sopenharmony_ci KVM_CAP_ARM_USER_IRQ >= 1: 61898c2ecf20Sopenharmony_ci 61908c2ecf20Sopenharmony_ci KVM_ARM_DEV_EL1_VTIMER - EL1 virtual timer 61918c2ecf20Sopenharmony_ci KVM_ARM_DEV_EL1_PTIMER - EL1 physical timer 61928c2ecf20Sopenharmony_ci KVM_ARM_DEV_PMU - ARM PMU overflow interrupt signal 61938c2ecf20Sopenharmony_ci 61948c2ecf20Sopenharmony_ciFuture versions of kvm may implement additional events. These will get 61958c2ecf20Sopenharmony_ciindicated by returning a higher number from KVM_CHECK_EXTENSION and will be 61968c2ecf20Sopenharmony_cilisted above. 61978c2ecf20Sopenharmony_ci 61988c2ecf20Sopenharmony_ci8.10 KVM_CAP_PPC_SMT_POSSIBLE 61998c2ecf20Sopenharmony_ci----------------------------- 62008c2ecf20Sopenharmony_ci 62018c2ecf20Sopenharmony_ci:Architectures: ppc 62028c2ecf20Sopenharmony_ci 62038c2ecf20Sopenharmony_ciQuerying this capability returns a bitmap indicating the possible 62048c2ecf20Sopenharmony_civirtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N 62058c2ecf20Sopenharmony_ci(counting from the right) is set, then a virtual SMT mode of 2^N is 62068c2ecf20Sopenharmony_ciavailable. 62078c2ecf20Sopenharmony_ci 62088c2ecf20Sopenharmony_ci8.11 KVM_CAP_HYPERV_SYNIC2 62098c2ecf20Sopenharmony_ci-------------------------- 62108c2ecf20Sopenharmony_ci 62118c2ecf20Sopenharmony_ci:Architectures: x86 62128c2ecf20Sopenharmony_ci 62138c2ecf20Sopenharmony_ciThis capability enables a newer version of Hyper-V Synthetic interrupt 62148c2ecf20Sopenharmony_cicontroller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM 62158c2ecf20Sopenharmony_cidoesn't clear SynIC message and event flags pages when they are enabled by 62168c2ecf20Sopenharmony_ciwriting to the respective MSRs. 62178c2ecf20Sopenharmony_ci 62188c2ecf20Sopenharmony_ci8.12 KVM_CAP_HYPERV_VP_INDEX 62198c2ecf20Sopenharmony_ci---------------------------- 62208c2ecf20Sopenharmony_ci 62218c2ecf20Sopenharmony_ci:Architectures: x86 62228c2ecf20Sopenharmony_ci 62238c2ecf20Sopenharmony_ciThis capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its 62248c2ecf20Sopenharmony_civalue is used to denote the target vcpu for a SynIC interrupt. For 62258c2ecf20Sopenharmony_cicompatibilty, KVM initializes this msr to KVM's internal vcpu index. When this 62268c2ecf20Sopenharmony_cicapability is absent, userspace can still query this msr's value. 62278c2ecf20Sopenharmony_ci 62288c2ecf20Sopenharmony_ci8.13 KVM_CAP_S390_AIS_MIGRATION 62298c2ecf20Sopenharmony_ci------------------------------- 62308c2ecf20Sopenharmony_ci 62318c2ecf20Sopenharmony_ci:Architectures: s390 62328c2ecf20Sopenharmony_ci:Parameters: none 62338c2ecf20Sopenharmony_ci 62348c2ecf20Sopenharmony_ciThis capability indicates if the flic device will be able to get/set the 62358c2ecf20Sopenharmony_ciAIS states for migration via the KVM_DEV_FLIC_AISM_ALL attribute and allows 62368c2ecf20Sopenharmony_cito discover this without having to create a flic device. 62378c2ecf20Sopenharmony_ci 62388c2ecf20Sopenharmony_ci8.14 KVM_CAP_S390_PSW 62398c2ecf20Sopenharmony_ci--------------------- 62408c2ecf20Sopenharmony_ci 62418c2ecf20Sopenharmony_ci:Architectures: s390 62428c2ecf20Sopenharmony_ci 62438c2ecf20Sopenharmony_ciThis capability indicates that the PSW is exposed via the kvm_run structure. 62448c2ecf20Sopenharmony_ci 62458c2ecf20Sopenharmony_ci8.15 KVM_CAP_S390_GMAP 62468c2ecf20Sopenharmony_ci---------------------- 62478c2ecf20Sopenharmony_ci 62488c2ecf20Sopenharmony_ci:Architectures: s390 62498c2ecf20Sopenharmony_ci 62508c2ecf20Sopenharmony_ciThis capability indicates that the user space memory used as guest mapping can 62518c2ecf20Sopenharmony_cibe anywhere in the user memory address space, as long as the memory slots are 62528c2ecf20Sopenharmony_cialigned and sized to a segment (1MB) boundary. 62538c2ecf20Sopenharmony_ci 62548c2ecf20Sopenharmony_ci8.16 KVM_CAP_S390_COW 62558c2ecf20Sopenharmony_ci--------------------- 62568c2ecf20Sopenharmony_ci 62578c2ecf20Sopenharmony_ci:Architectures: s390 62588c2ecf20Sopenharmony_ci 62598c2ecf20Sopenharmony_ciThis capability indicates that the user space memory used as guest mapping can 62608c2ecf20Sopenharmony_ciuse copy-on-write semantics as well as dirty pages tracking via read-only page 62618c2ecf20Sopenharmony_citables. 62628c2ecf20Sopenharmony_ci 62638c2ecf20Sopenharmony_ci8.17 KVM_CAP_S390_BPB 62648c2ecf20Sopenharmony_ci--------------------- 62658c2ecf20Sopenharmony_ci 62668c2ecf20Sopenharmony_ci:Architectures: s390 62678c2ecf20Sopenharmony_ci 62688c2ecf20Sopenharmony_ciThis capability indicates that kvm will implement the interfaces to handle 62698c2ecf20Sopenharmony_cireset, migration and nested KVM for branch prediction blocking. The stfle 62708c2ecf20Sopenharmony_cifacility 82 should not be provided to the guest without this capability. 62718c2ecf20Sopenharmony_ci 62728c2ecf20Sopenharmony_ci8.18 KVM_CAP_HYPERV_TLBFLUSH 62738c2ecf20Sopenharmony_ci---------------------------- 62748c2ecf20Sopenharmony_ci 62758c2ecf20Sopenharmony_ci:Architectures: x86 62768c2ecf20Sopenharmony_ci 62778c2ecf20Sopenharmony_ciThis capability indicates that KVM supports paravirtualized Hyper-V TLB Flush 62788c2ecf20Sopenharmony_cihypercalls: 62798c2ecf20Sopenharmony_ciHvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx, 62808c2ecf20Sopenharmony_ciHvFlushVirtualAddressList, HvFlushVirtualAddressListEx. 62818c2ecf20Sopenharmony_ci 62828c2ecf20Sopenharmony_ci8.19 KVM_CAP_ARM_INJECT_SERROR_ESR 62838c2ecf20Sopenharmony_ci---------------------------------- 62848c2ecf20Sopenharmony_ci 62858c2ecf20Sopenharmony_ci:Architectures: arm, arm64 62868c2ecf20Sopenharmony_ci 62878c2ecf20Sopenharmony_ciThis capability indicates that userspace can specify (via the 62888c2ecf20Sopenharmony_ciKVM_SET_VCPU_EVENTS ioctl) the syndrome value reported to the guest when it 62898c2ecf20Sopenharmony_citakes a virtual SError interrupt exception. 62908c2ecf20Sopenharmony_ciIf KVM advertises this capability, userspace can only specify the ISS field for 62918c2ecf20Sopenharmony_cithe ESR syndrome. Other parts of the ESR, such as the EC are generated by the 62928c2ecf20Sopenharmony_ciCPU when the exception is taken. If this virtual SError is taken to EL1 using 62938c2ecf20Sopenharmony_ciAArch64, this value will be reported in the ISS field of ESR_ELx. 62948c2ecf20Sopenharmony_ci 62958c2ecf20Sopenharmony_ciSee KVM_CAP_VCPU_EVENTS for more details. 62968c2ecf20Sopenharmony_ci 62978c2ecf20Sopenharmony_ci8.20 KVM_CAP_HYPERV_SEND_IPI 62988c2ecf20Sopenharmony_ci---------------------------- 62998c2ecf20Sopenharmony_ci 63008c2ecf20Sopenharmony_ci:Architectures: x86 63018c2ecf20Sopenharmony_ci 63028c2ecf20Sopenharmony_ciThis capability indicates that KVM supports paravirtualized Hyper-V IPI send 63038c2ecf20Sopenharmony_cihypercalls: 63048c2ecf20Sopenharmony_ciHvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx. 63058c2ecf20Sopenharmony_ci 63068c2ecf20Sopenharmony_ci8.21 KVM_CAP_HYPERV_DIRECT_TLBFLUSH 63078c2ecf20Sopenharmony_ci----------------------------------- 63088c2ecf20Sopenharmony_ci 63098c2ecf20Sopenharmony_ci:Architectures: x86 63108c2ecf20Sopenharmony_ci 63118c2ecf20Sopenharmony_ciThis capability indicates that KVM running on top of Hyper-V hypervisor 63128c2ecf20Sopenharmony_cienables Direct TLB flush for its guests meaning that TLB flush 63138c2ecf20Sopenharmony_cihypercalls are handled by Level 0 hypervisor (Hyper-V) bypassing KVM. 63148c2ecf20Sopenharmony_ciDue to the different ABI for hypercall parameters between Hyper-V and 63158c2ecf20Sopenharmony_ciKVM, enabling this capability effectively disables all hypercall 63168c2ecf20Sopenharmony_cihandling by KVM (as some KVM hypercall may be mistakenly treated as TLB 63178c2ecf20Sopenharmony_ciflush hypercalls by Hyper-V) so userspace should disable KVM identification 63188c2ecf20Sopenharmony_ciin CPUID and only exposes Hyper-V identification. In this case, guest 63198c2ecf20Sopenharmony_cithinks it's running on Hyper-V and only use Hyper-V hypercalls. 63208c2ecf20Sopenharmony_ci 63218c2ecf20Sopenharmony_ci8.22 KVM_CAP_S390_VCPU_RESETS 63228c2ecf20Sopenharmony_ci----------------------------- 63238c2ecf20Sopenharmony_ci 63248c2ecf20Sopenharmony_ci:Architectures: s390 63258c2ecf20Sopenharmony_ci 63268c2ecf20Sopenharmony_ciThis capability indicates that the KVM_S390_NORMAL_RESET and 63278c2ecf20Sopenharmony_ciKVM_S390_CLEAR_RESET ioctls are available. 63288c2ecf20Sopenharmony_ci 63298c2ecf20Sopenharmony_ci8.23 KVM_CAP_S390_PROTECTED 63308c2ecf20Sopenharmony_ci--------------------------- 63318c2ecf20Sopenharmony_ci 63328c2ecf20Sopenharmony_ci:Architectures: s390 63338c2ecf20Sopenharmony_ci 63348c2ecf20Sopenharmony_ciThis capability indicates that the Ultravisor has been initialized and 63358c2ecf20Sopenharmony_ciKVM can therefore start protected VMs. 63368c2ecf20Sopenharmony_ciThis capability governs the KVM_S390_PV_COMMAND ioctl and the 63378c2ecf20Sopenharmony_ciKVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected 63388c2ecf20Sopenharmony_ciguests when the state change is invalid. 63398c2ecf20Sopenharmony_ci 63408c2ecf20Sopenharmony_ci8.24 KVM_CAP_STEAL_TIME 63418c2ecf20Sopenharmony_ci----------------------- 63428c2ecf20Sopenharmony_ci 63438c2ecf20Sopenharmony_ci:Architectures: arm64, x86 63448c2ecf20Sopenharmony_ci 63458c2ecf20Sopenharmony_ciThis capability indicates that KVM supports steal time accounting. 63468c2ecf20Sopenharmony_ciWhen steal time accounting is supported it may be enabled with 63478c2ecf20Sopenharmony_ciarchitecture-specific interfaces. This capability and the architecture- 63488c2ecf20Sopenharmony_cispecific interfaces must be consistent, i.e. if one says the feature 63498c2ecf20Sopenharmony_ciis supported, than the other should as well and vice versa. For arm64 63508c2ecf20Sopenharmony_cisee Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL". 63518c2ecf20Sopenharmony_ciFor x86 see Documentation/virt/kvm/msr.rst "MSR_KVM_STEAL_TIME". 63528c2ecf20Sopenharmony_ci 63538c2ecf20Sopenharmony_ci8.25 KVM_CAP_S390_DIAG318 63548c2ecf20Sopenharmony_ci------------------------- 63558c2ecf20Sopenharmony_ci 63568c2ecf20Sopenharmony_ci:Architectures: s390 63578c2ecf20Sopenharmony_ci 63588c2ecf20Sopenharmony_ciThis capability enables a guest to set information about its control program 63598c2ecf20Sopenharmony_ci(i.e. guest kernel type and version). The information is helpful during 63608c2ecf20Sopenharmony_cisystem/firmware service events, providing additional data about the guest 63618c2ecf20Sopenharmony_cienvironments running on the machine. 63628c2ecf20Sopenharmony_ci 63638c2ecf20Sopenharmony_ciThe information is associated with the DIAGNOSE 0x318 instruction, which sets 63648c2ecf20Sopenharmony_cian 8-byte value consisting of a one-byte Control Program Name Code (CPNC) and 63658c2ecf20Sopenharmony_cia 7-byte Control Program Version Code (CPVC). The CPNC determines what 63668c2ecf20Sopenharmony_cienvironment the control program is running in (e.g. Linux, z/VM...), and the 63678c2ecf20Sopenharmony_ciCPVC is used for information specific to OS (e.g. Linux version, Linux 63688c2ecf20Sopenharmony_cidistribution...) 63698c2ecf20Sopenharmony_ci 63708c2ecf20Sopenharmony_ciIf this capability is available, then the CPNC and CPVC can be synchronized 63718c2ecf20Sopenharmony_cibetween KVM and userspace via the sync regs mechanism (KVM_SYNC_DIAG318). 63728c2ecf20Sopenharmony_ci 63738c2ecf20Sopenharmony_ci8.26 KVM_CAP_X86_USER_SPACE_MSR 63748c2ecf20Sopenharmony_ci------------------------------- 63758c2ecf20Sopenharmony_ci 63768c2ecf20Sopenharmony_ci:Architectures: x86 63778c2ecf20Sopenharmony_ci 63788c2ecf20Sopenharmony_ciThis capability indicates that KVM supports deflection of MSR reads and 63798c2ecf20Sopenharmony_ciwrites to user space. It can be enabled on a VM level. If enabled, MSR 63808c2ecf20Sopenharmony_ciaccesses that would usually trigger a #GP by KVM into the guest will 63818c2ecf20Sopenharmony_ciinstead get bounced to user space through the KVM_EXIT_X86_RDMSR and 63828c2ecf20Sopenharmony_ciKVM_EXIT_X86_WRMSR exit notifications. 63838c2ecf20Sopenharmony_ci 63848c2ecf20Sopenharmony_ci8.27 KVM_X86_SET_MSR_FILTER 63858c2ecf20Sopenharmony_ci--------------------------- 63868c2ecf20Sopenharmony_ci 63878c2ecf20Sopenharmony_ci:Architectures: x86 63888c2ecf20Sopenharmony_ci 63898c2ecf20Sopenharmony_ciThis capability indicates that KVM supports that accesses to user defined MSRs 63908c2ecf20Sopenharmony_cimay be rejected. With this capability exposed, KVM exports new VM ioctl 63918c2ecf20Sopenharmony_ciKVM_X86_SET_MSR_FILTER which user space can call to specify bitmaps of MSR 63928c2ecf20Sopenharmony_ciranges that KVM should reject access to. 63938c2ecf20Sopenharmony_ci 63948c2ecf20Sopenharmony_ciIn combination with KVM_CAP_X86_USER_SPACE_MSR, this allows user space to 63958c2ecf20Sopenharmony_citrap and emulate MSRs that are outside of the scope of KVM as well as 63968c2ecf20Sopenharmony_cilimit the attack surface on KVM's MSR emulation code. 63978c2ecf20Sopenharmony_ci 63988c2ecf20Sopenharmony_ci8.28 KVM_CAP_ENFORCE_PV_CPUID 63998c2ecf20Sopenharmony_ci----------------------------- 64008c2ecf20Sopenharmony_ci 64018c2ecf20Sopenharmony_ciArchitectures: x86 64028c2ecf20Sopenharmony_ci 64038c2ecf20Sopenharmony_ciWhen enabled, KVM will disable paravirtual features provided to the 64048c2ecf20Sopenharmony_ciguest according to the bits in the KVM_CPUID_FEATURES CPUID leaf 64058c2ecf20Sopenharmony_ci(0x40000001). Otherwise, a guest may use the paravirtual features 64068c2ecf20Sopenharmony_ciregardless of what has actually been exposed through the CPUID leaf. 64078c2ecf20Sopenharmony_ci 64088c2ecf20Sopenharmony_ci9. Known KVM API problems 64098c2ecf20Sopenharmony_ci========================= 64108c2ecf20Sopenharmony_ci 64118c2ecf20Sopenharmony_ciIn some cases, KVM's API has some inconsistencies or common pitfalls 64128c2ecf20Sopenharmony_cithat userspace need to be aware of. This section details some of 64138c2ecf20Sopenharmony_cithese issues. 64148c2ecf20Sopenharmony_ci 64158c2ecf20Sopenharmony_ciMost of them are architecture specific, so the section is split by 64168c2ecf20Sopenharmony_ciarchitecture. 64178c2ecf20Sopenharmony_ci 64188c2ecf20Sopenharmony_ci9.1. x86 64198c2ecf20Sopenharmony_ci-------- 64208c2ecf20Sopenharmony_ci 64218c2ecf20Sopenharmony_ci``KVM_GET_SUPPORTED_CPUID`` issues 64228c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64238c2ecf20Sopenharmony_ci 64248c2ecf20Sopenharmony_ciIn general, ``KVM_GET_SUPPORTED_CPUID`` is designed so that it is possible 64258c2ecf20Sopenharmony_cito take its result and pass it directly to ``KVM_SET_CPUID2``. This section 64268c2ecf20Sopenharmony_cidocuments some cases in which that requires some care. 64278c2ecf20Sopenharmony_ci 64288c2ecf20Sopenharmony_ciLocal APIC features 64298c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~~~~~ 64308c2ecf20Sopenharmony_ci 64318c2ecf20Sopenharmony_ciCPU[EAX=1]:ECX[21] (X2APIC) is reported by ``KVM_GET_SUPPORTED_CPUID``, 64328c2ecf20Sopenharmony_cibut it can only be enabled if ``KVM_CREATE_IRQCHIP`` or 64338c2ecf20Sopenharmony_ci``KVM_ENABLE_CAP(KVM_CAP_IRQCHIP_SPLIT)`` are used to enable in-kernel emulation of 64348c2ecf20Sopenharmony_cithe local APIC. 64358c2ecf20Sopenharmony_ci 64368c2ecf20Sopenharmony_ciThe same is true for the ``KVM_FEATURE_PV_UNHALT`` paravirtualized feature. 64378c2ecf20Sopenharmony_ci 64388c2ecf20Sopenharmony_ciCPU[EAX=1]:ECX[24] (TSC_DEADLINE) is not reported by ``KVM_GET_SUPPORTED_CPUID``. 64398c2ecf20Sopenharmony_ciIt can be enabled if ``KVM_CAP_TSC_DEADLINE_TIMER`` is present and the kernel 64408c2ecf20Sopenharmony_cihas enabled in-kernel emulation of the local APIC. 64418c2ecf20Sopenharmony_ci 64428c2ecf20Sopenharmony_ciCPU topology 64438c2ecf20Sopenharmony_ci~~~~~~~~~~~~ 64448c2ecf20Sopenharmony_ci 64458c2ecf20Sopenharmony_ciSeveral CPUID values include topology information for the host CPU: 64468c2ecf20Sopenharmony_ci0x0b and 0x1f for Intel systems, 0x8000001e for AMD systems. Different 64478c2ecf20Sopenharmony_civersions of KVM return different values for this information and userspace 64488c2ecf20Sopenharmony_cishould not rely on it. Currently they return all zeroes. 64498c2ecf20Sopenharmony_ci 64508c2ecf20Sopenharmony_ciIf userspace wishes to set up a guest topology, it should be careful that 64518c2ecf20Sopenharmony_cithe values of these three leaves differ for each CPU. In particular, 64528c2ecf20Sopenharmony_cithe APIC ID is found in EDX for all subleaves of 0x0b and 0x1f, and in EAX 64538c2ecf20Sopenharmony_cifor 0x8000001e; the latter also encodes the core id and node id in bits 64548c2ecf20Sopenharmony_ci7:0 of EBX and ECX respectively. 64558c2ecf20Sopenharmony_ci 64568c2ecf20Sopenharmony_ciObsolete ioctls and capabilities 64578c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64588c2ecf20Sopenharmony_ci 64598c2ecf20Sopenharmony_ciKVM_CAP_DISABLE_QUIRKS does not let userspace know which quirks are actually 64608c2ecf20Sopenharmony_ciavailable. Use ``KVM_CHECK_EXTENSION(KVM_CAP_DISABLE_QUIRKS2)`` instead if 64618c2ecf20Sopenharmony_ciavailable. 64628c2ecf20Sopenharmony_ci 64638c2ecf20Sopenharmony_ciOrdering of KVM_GET_*/KVM_SET_* ioctls 64648c2ecf20Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64658c2ecf20Sopenharmony_ci 64668c2ecf20Sopenharmony_ciTBD 6467