162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci=================================================================== 462306a36Sopenharmony_ciThe Definitive KVM (Kernel-based Virtual Machine) API Documentation 562306a36Sopenharmony_ci=================================================================== 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci1. General description 862306a36Sopenharmony_ci====================== 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciThe kvm API is a set of ioctls that are issued to control various aspects 1162306a36Sopenharmony_ciof a virtual machine. The ioctls belong to the following classes: 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci - System ioctls: These query and set global attributes which affect the 1462306a36Sopenharmony_ci whole kvm subsystem. In addition a system ioctl is used to create 1562306a36Sopenharmony_ci virtual machines. 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci - VM ioctls: These query and set attributes that affect an entire virtual 1862306a36Sopenharmony_ci machine, for example memory layout. In addition a VM ioctl is used to 1962306a36Sopenharmony_ci create virtual cpus (vcpus) and devices. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci VM ioctls must be issued from the same process (address space) that was 2262306a36Sopenharmony_ci used to create the VM. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci - vcpu ioctls: These query and set attributes that control the operation 2562306a36Sopenharmony_ci of a single virtual cpu. 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci vcpu ioctls should be issued from the same thread that was used to create 2862306a36Sopenharmony_ci the vcpu, except for asynchronous vcpu ioctl that are marked as such in 2962306a36Sopenharmony_ci the documentation. Otherwise, the first ioctl after switching threads 3062306a36Sopenharmony_ci could see a performance impact. 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci - device ioctls: These query and set attributes that control the operation 3362306a36Sopenharmony_ci of a single device. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci device ioctls must be issued from the same process (address space) that 3662306a36Sopenharmony_ci was used to create the VM. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci2. File descriptors 3962306a36Sopenharmony_ci=================== 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ciThe kvm API is centered around file descriptors. An initial 4262306a36Sopenharmony_ciopen("/dev/kvm") obtains a handle to the kvm subsystem; this handle 4362306a36Sopenharmony_cican be used to issue system ioctls. A KVM_CREATE_VM ioctl on this 4462306a36Sopenharmony_cihandle will create a VM file descriptor which can be used to issue VM 4562306a36Sopenharmony_ciioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will 4662306a36Sopenharmony_cicreate a virtual cpu or device and return a file descriptor pointing to 4762306a36Sopenharmony_cithe new resource. Finally, ioctls on a vcpu or device fd can be used 4862306a36Sopenharmony_cito control the vcpu or device. For vcpus, this includes the important 4962306a36Sopenharmony_citask of actually running guest code. 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciIn general file descriptors can be migrated among processes by means 5262306a36Sopenharmony_ciof fork() and the SCM_RIGHTS facility of unix domain socket. These 5362306a36Sopenharmony_cikinds of tricks are explicitly not supported by kvm. While they will 5462306a36Sopenharmony_cinot cause harm to the host, their actual behavior is not guaranteed by 5562306a36Sopenharmony_cithe API. See "General description" for details on the ioctl usage 5662306a36Sopenharmony_cimodel that is supported by KVM. 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ciIt is important to note that although VM ioctls may only be issued from 5962306a36Sopenharmony_cithe process that created the VM, a VM's lifecycle is associated with its 6062306a36Sopenharmony_cifile descriptor, not its creator (process). In other words, the VM and 6162306a36Sopenharmony_ciits resources, *including the associated address space*, are not freed 6262306a36Sopenharmony_ciuntil the last reference to the VM's file descriptor has been released. 6362306a36Sopenharmony_ciFor example, if fork() is issued after ioctl(KVM_CREATE_VM), the VM will 6462306a36Sopenharmony_cinot be freed until both the parent (original) process and its child have 6562306a36Sopenharmony_ciput their references to the VM's file descriptor. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciBecause a VM's resources are not freed until the last reference to its 6862306a36Sopenharmony_cifile descriptor is released, creating additional references to a VM 6962306a36Sopenharmony_civia fork(), dup(), etc... without careful consideration is strongly 7062306a36Sopenharmony_cidiscouraged and may have unwanted side effects, e.g. memory allocated 7162306a36Sopenharmony_ciby and on behalf of the VM's process may not be freed/unaccounted when 7262306a36Sopenharmony_cithe VM is shut down. 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci3. Extensions 7662306a36Sopenharmony_ci============= 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciAs of Linux 2.6.22, the KVM ABI has been stabilized: no backward 7962306a36Sopenharmony_ciincompatible change are allowed. However, there is an extension 8062306a36Sopenharmony_cifacility that allows backward-compatible extensions to the API to be 8162306a36Sopenharmony_ciqueried and used. 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciThe extension mechanism is not based on the Linux version number. 8462306a36Sopenharmony_ciInstead, kvm defines extension identifiers and a facility to query 8562306a36Sopenharmony_ciwhether a particular extension identifier is available. If it is, a 8662306a36Sopenharmony_ciset of ioctls is available for application use. 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci4. API description 9062306a36Sopenharmony_ci================== 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ciThis section describes ioctls that can be used to control kvm guests. 9362306a36Sopenharmony_ciFor each ioctl, the following information is provided along with a 9462306a36Sopenharmony_cidescription: 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci Capability: 9762306a36Sopenharmony_ci which KVM extension provides this ioctl. Can be 'basic', 9862306a36Sopenharmony_ci which means that is will be provided by any kernel that supports 9962306a36Sopenharmony_ci API version 12 (see section 4.1), a KVM_CAP_xyz constant, which 10062306a36Sopenharmony_ci means availability needs to be checked with KVM_CHECK_EXTENSION 10162306a36Sopenharmony_ci (see section 4.4), or 'none' which means that while not all kernels 10262306a36Sopenharmony_ci support this ioctl, there's no capability bit to check its 10362306a36Sopenharmony_ci availability: for kernels that don't support the ioctl, 10462306a36Sopenharmony_ci the ioctl returns -ENOTTY. 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci Architectures: 10762306a36Sopenharmony_ci which instruction set architectures provide this ioctl. 10862306a36Sopenharmony_ci x86 includes both i386 and x86_64. 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci Type: 11162306a36Sopenharmony_ci system, vm, or vcpu. 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci Parameters: 11462306a36Sopenharmony_ci what parameters are accepted by the ioctl. 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci Returns: 11762306a36Sopenharmony_ci the return value. General error numbers (EBADF, ENOMEM, EINVAL) 11862306a36Sopenharmony_ci are not detailed, but errors with specific meanings are. 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci4.1 KVM_GET_API_VERSION 12262306a36Sopenharmony_ci----------------------- 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci:Capability: basic 12562306a36Sopenharmony_ci:Architectures: all 12662306a36Sopenharmony_ci:Type: system ioctl 12762306a36Sopenharmony_ci:Parameters: none 12862306a36Sopenharmony_ci:Returns: the constant KVM_API_VERSION (=12) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ciThis identifies the API version as the stable kvm API. It is not 13162306a36Sopenharmony_ciexpected that this number will change. However, Linux 2.6.20 and 13262306a36Sopenharmony_ci2.6.21 report earlier versions; these are not documented and not 13362306a36Sopenharmony_cisupported. Applications should refuse to run if KVM_GET_API_VERSION 13462306a36Sopenharmony_cireturns a value other than 12. If this check passes, all ioctls 13562306a36Sopenharmony_cidescribed as 'basic' will be available. 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci4.2 KVM_CREATE_VM 13962306a36Sopenharmony_ci----------------- 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci:Capability: basic 14262306a36Sopenharmony_ci:Architectures: all 14362306a36Sopenharmony_ci:Type: system ioctl 14462306a36Sopenharmony_ci:Parameters: machine type identifier (KVM_VM_*) 14562306a36Sopenharmony_ci:Returns: a VM fd that can be used to control the new virtual machine. 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ciThe new VM has no virtual cpus and no memory. 14862306a36Sopenharmony_ciYou probably want to use 0 as machine type. 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ciIn order to create user controlled virtual machines on S390, check 15162306a36Sopenharmony_ciKVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as 15262306a36Sopenharmony_ciprivileged user (CAP_SYS_ADMIN). 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ciOn arm64, the physical address size for a VM (IPA Size limit) is limited 15562306a36Sopenharmony_cito 40bits by default. The limit can be configured if the host supports the 15662306a36Sopenharmony_ciextension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use 15762306a36Sopenharmony_ciKVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type 15862306a36Sopenharmony_ciidentifier, where IPA_Bits is the maximum width of any physical 15962306a36Sopenharmony_ciaddress used by the VM. The IPA_Bits is encoded in bits[7-0] of the 16062306a36Sopenharmony_cimachine type identifier. 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_cie.g, to configure a guest to use 48bit physical address size:: 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48)); 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ciThe requested size (IPA_Bits) must be: 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci == ========================================================= 16962306a36Sopenharmony_ci 0 Implies default size, 40bits (for backward compatibility) 17062306a36Sopenharmony_ci N Implies N bits, where N is a positive integer such that, 17162306a36Sopenharmony_ci 32 <= N <= Host_IPA_Limit 17262306a36Sopenharmony_ci == ========================================================= 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ciHost_IPA_Limit is the maximum possible value for IPA_Bits on the host and 17562306a36Sopenharmony_ciis dependent on the CPU capability and the kernel configuration. The limit can 17662306a36Sopenharmony_cibe retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION 17762306a36Sopenharmony_ciioctl() at run-time. 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ciCreation of the VM will fail if the requested IPA size (whether it is 18062306a36Sopenharmony_ciimplicit or explicit) is unsupported on the host. 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ciPlease note that configuring the IPA size does not affect the capability 18362306a36Sopenharmony_ciexposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects 18462306a36Sopenharmony_cisize of the address translated by the stage2 level (guest physical to 18562306a36Sopenharmony_cihost physical address translations). 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci4.3 KVM_GET_MSR_INDEX_LIST, KVM_GET_MSR_FEATURE_INDEX_LIST 18962306a36Sopenharmony_ci---------------------------------------------------------- 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci:Capability: basic, KVM_CAP_GET_MSR_FEATURES for KVM_GET_MSR_FEATURE_INDEX_LIST 19262306a36Sopenharmony_ci:Architectures: x86 19362306a36Sopenharmony_ci:Type: system ioctl 19462306a36Sopenharmony_ci:Parameters: struct kvm_msr_list (in/out) 19562306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ciErrors: 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci ====== ============================================================ 20062306a36Sopenharmony_ci EFAULT the msr index list cannot be read from or written to 20162306a36Sopenharmony_ci E2BIG the msr index list is too big to fit in the array specified by 20262306a36Sopenharmony_ci the user. 20362306a36Sopenharmony_ci ====== ============================================================ 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci:: 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci struct kvm_msr_list { 20862306a36Sopenharmony_ci __u32 nmsrs; /* number of msrs in entries */ 20962306a36Sopenharmony_ci __u32 indices[0]; 21062306a36Sopenharmony_ci }; 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ciThe user fills in the size of the indices array in nmsrs, and in return 21362306a36Sopenharmony_cikvm adjusts nmsrs to reflect the actual number of msrs and fills in the 21462306a36Sopenharmony_ciindices array with their numbers. 21562306a36Sopenharmony_ci 21662306a36Sopenharmony_ciKVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list 21762306a36Sopenharmony_civaries by kvm version and host processor, but does not change otherwise. 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ciNote: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are 22062306a36Sopenharmony_cinot returned in the MSR list, as different vcpus can have a different number 22162306a36Sopenharmony_ciof banks, as set via the KVM_X86_SETUP_MCE ioctl. 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ciKVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed 22462306a36Sopenharmony_cito the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities 22562306a36Sopenharmony_ciand processor features that are exposed via MSRs (e.g., VMX capabilities). 22662306a36Sopenharmony_ciThis list also varies by kvm version and host processor, but does not change 22762306a36Sopenharmony_ciotherwise. 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci4.4 KVM_CHECK_EXTENSION 23162306a36Sopenharmony_ci----------------------- 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci:Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl 23462306a36Sopenharmony_ci:Architectures: all 23562306a36Sopenharmony_ci:Type: system ioctl, vm ioctl 23662306a36Sopenharmony_ci:Parameters: extension identifier (KVM_CAP_*) 23762306a36Sopenharmony_ci:Returns: 0 if unsupported; 1 (or some other positive integer) if supported 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ciThe API allows the application to query about extensions to the core 24062306a36Sopenharmony_cikvm API. Userspace passes an extension identifier (an integer) and 24162306a36Sopenharmony_cireceives an integer that describes the extension availability. 24262306a36Sopenharmony_ciGenerally 0 means no and 1 means yes, but some extensions may report 24362306a36Sopenharmony_ciadditional information in the integer return value. 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ciBased on their initialization different VMs may have different capabilities. 24662306a36Sopenharmony_ciIt is thus encouraged to use the vm ioctl to query for capabilities (available 24762306a36Sopenharmony_ciwith KVM_CAP_CHECK_EXTENSION_VM on the vm fd) 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci4.5 KVM_GET_VCPU_MMAP_SIZE 25062306a36Sopenharmony_ci-------------------------- 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_ci:Capability: basic 25362306a36Sopenharmony_ci:Architectures: all 25462306a36Sopenharmony_ci:Type: system ioctl 25562306a36Sopenharmony_ci:Parameters: none 25662306a36Sopenharmony_ci:Returns: size of vcpu mmap area, in bytes 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ciThe KVM_RUN ioctl (cf.) communicates with userspace via a shared 25962306a36Sopenharmony_cimemory region. This ioctl returns the size of that region. See the 26062306a36Sopenharmony_ciKVM_RUN documentation for details. 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ciBesides the size of the KVM_RUN communication region, other areas of 26362306a36Sopenharmony_cithe VCPU file descriptor can be mmap-ed, including: 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci- if KVM_CAP_COALESCED_MMIO is available, a page at 26662306a36Sopenharmony_ci KVM_COALESCED_MMIO_PAGE_OFFSET * PAGE_SIZE; for historical reasons, 26762306a36Sopenharmony_ci this page is included in the result of KVM_GET_VCPU_MMAP_SIZE. 26862306a36Sopenharmony_ci KVM_CAP_COALESCED_MMIO is not documented yet. 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci- if KVM_CAP_DIRTY_LOG_RING is available, a number of pages at 27162306a36Sopenharmony_ci KVM_DIRTY_LOG_PAGE_OFFSET * PAGE_SIZE. For more information on 27262306a36Sopenharmony_ci KVM_CAP_DIRTY_LOG_RING, see section 8.3. 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci4.7 KVM_CREATE_VCPU 27662306a36Sopenharmony_ci------------------- 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_ci:Capability: basic 27962306a36Sopenharmony_ci:Architectures: all 28062306a36Sopenharmony_ci:Type: vm ioctl 28162306a36Sopenharmony_ci:Parameters: vcpu id (apic id on x86) 28262306a36Sopenharmony_ci:Returns: vcpu fd on success, -1 on error 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ciThis API adds a vcpu to a virtual machine. No more than max_vcpus may be added. 28562306a36Sopenharmony_ciThe vcpu id is an integer in the range [0, max_vcpu_id). 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ciThe recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of 28862306a36Sopenharmony_cithe KVM_CHECK_EXTENSION ioctl() at run-time. 28962306a36Sopenharmony_ciThe maximum possible value for max_vcpus can be retrieved using the 29062306a36Sopenharmony_ciKVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ciIf the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4 29362306a36Sopenharmony_cicpus max. 29462306a36Sopenharmony_ciIf the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is 29562306a36Sopenharmony_cisame as the value returned from KVM_CAP_NR_VCPUS. 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_ciThe maximum possible value for max_vcpu_id can be retrieved using the 29862306a36Sopenharmony_ciKVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time. 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ciIf the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id 30162306a36Sopenharmony_ciis the same as the value returned from KVM_CAP_MAX_VCPUS. 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ciOn powerpc using book3s_hv mode, the vcpus are mapped onto virtual 30462306a36Sopenharmony_cithreads in one or more virtual CPU cores. (This is because the 30562306a36Sopenharmony_cihardware requires all the hardware threads in a CPU core to be in the 30662306a36Sopenharmony_cisame partition.) The KVM_CAP_PPC_SMT capability indicates the number 30762306a36Sopenharmony_ciof vcpus per virtual core (vcore). The vcore id is obtained by 30862306a36Sopenharmony_cidividing the vcpu id by the number of vcpus per vcore. The vcpus in a 30962306a36Sopenharmony_cigiven vcore will always be in the same physical core as each other 31062306a36Sopenharmony_ci(though that might be a different physical core from time to time). 31162306a36Sopenharmony_ciUserspace can control the threading (SMT) mode of the guest by its 31262306a36Sopenharmony_ciallocation of vcpu ids. For example, if userspace wants 31362306a36Sopenharmony_cisingle-threaded guest vcpus, it should make all vcpu ids be a multiple 31462306a36Sopenharmony_ciof the number of vcpus per vcore. 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ciFor virtual cpus that have been created with S390 user controlled virtual 31762306a36Sopenharmony_cimachines, the resulting vcpu fd can be memory mapped at page offset 31862306a36Sopenharmony_ciKVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual 31962306a36Sopenharmony_cicpu's hardware control block. 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci4.8 KVM_GET_DIRTY_LOG (vm ioctl) 32362306a36Sopenharmony_ci-------------------------------- 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci:Capability: basic 32662306a36Sopenharmony_ci:Architectures: all 32762306a36Sopenharmony_ci:Type: vm ioctl 32862306a36Sopenharmony_ci:Parameters: struct kvm_dirty_log (in/out) 32962306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci:: 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci /* for KVM_GET_DIRTY_LOG */ 33462306a36Sopenharmony_ci struct kvm_dirty_log { 33562306a36Sopenharmony_ci __u32 slot; 33662306a36Sopenharmony_ci __u32 padding; 33762306a36Sopenharmony_ci union { 33862306a36Sopenharmony_ci void __user *dirty_bitmap; /* one bit per page */ 33962306a36Sopenharmony_ci __u64 padding; 34062306a36Sopenharmony_ci }; 34162306a36Sopenharmony_ci }; 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ciGiven a memory slot, return a bitmap containing any pages dirtied 34462306a36Sopenharmony_cisince the last call to this ioctl. Bit 0 is the first page in the 34562306a36Sopenharmony_cimemory slot. Ensure the entire structure is cleared to avoid padding 34662306a36Sopenharmony_ciissues. 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ciIf KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of slot field specifies 34962306a36Sopenharmony_cithe address space for which you want to return the dirty bitmap. See 35062306a36Sopenharmony_ciKVM_SET_USER_MEMORY_REGION for details on the usage of slot field. 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ciThe bits in the dirty bitmap are cleared before the ioctl returns, unless 35362306a36Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is enabled. For more information, 35462306a36Sopenharmony_cisee the description of the capability. 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ciNote that the Xen shared info page, if configured, shall always be assumed 35762306a36Sopenharmony_cito be dirty. KVM will not explicitly mark it such. 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci4.10 KVM_RUN 36162306a36Sopenharmony_ci------------ 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci:Capability: basic 36462306a36Sopenharmony_ci:Architectures: all 36562306a36Sopenharmony_ci:Type: vcpu ioctl 36662306a36Sopenharmony_ci:Parameters: none 36762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ciErrors: 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci ======= ============================================================== 37262306a36Sopenharmony_ci EINTR an unmasked signal is pending 37362306a36Sopenharmony_ci ENOEXEC the vcpu hasn't been initialized or the guest tried to execute 37462306a36Sopenharmony_ci instructions from device memory (arm64) 37562306a36Sopenharmony_ci ENOSYS data abort outside memslots with no syndrome info and 37662306a36Sopenharmony_ci KVM_CAP_ARM_NISV_TO_USER not enabled (arm64) 37762306a36Sopenharmony_ci EPERM SVE feature set but not finalized (arm64) 37862306a36Sopenharmony_ci ======= ============================================================== 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_ciThis ioctl is used to run a guest virtual cpu. While there are no 38162306a36Sopenharmony_ciexplicit parameters, there is an implicit parameter block that can be 38262306a36Sopenharmony_ciobtained by mmap()ing the vcpu fd at offset 0, with the size given by 38362306a36Sopenharmony_ciKVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct 38462306a36Sopenharmony_cikvm_run' (see below). 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci 38762306a36Sopenharmony_ci4.11 KVM_GET_REGS 38862306a36Sopenharmony_ci----------------- 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci:Capability: basic 39162306a36Sopenharmony_ci:Architectures: all except arm64 39262306a36Sopenharmony_ci:Type: vcpu ioctl 39362306a36Sopenharmony_ci:Parameters: struct kvm_regs (out) 39462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 39562306a36Sopenharmony_ci 39662306a36Sopenharmony_ciReads the general purpose registers from the vcpu. 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci:: 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ci /* x86 */ 40162306a36Sopenharmony_ci struct kvm_regs { 40262306a36Sopenharmony_ci /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 40362306a36Sopenharmony_ci __u64 rax, rbx, rcx, rdx; 40462306a36Sopenharmony_ci __u64 rsi, rdi, rsp, rbp; 40562306a36Sopenharmony_ci __u64 r8, r9, r10, r11; 40662306a36Sopenharmony_ci __u64 r12, r13, r14, r15; 40762306a36Sopenharmony_ci __u64 rip, rflags; 40862306a36Sopenharmony_ci }; 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci /* mips */ 41162306a36Sopenharmony_ci struct kvm_regs { 41262306a36Sopenharmony_ci /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 41362306a36Sopenharmony_ci __u64 gpr[32]; 41462306a36Sopenharmony_ci __u64 hi; 41562306a36Sopenharmony_ci __u64 lo; 41662306a36Sopenharmony_ci __u64 pc; 41762306a36Sopenharmony_ci }; 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci4.12 KVM_SET_REGS 42162306a36Sopenharmony_ci----------------- 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ci:Capability: basic 42462306a36Sopenharmony_ci:Architectures: all except arm64 42562306a36Sopenharmony_ci:Type: vcpu ioctl 42662306a36Sopenharmony_ci:Parameters: struct kvm_regs (in) 42762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 42862306a36Sopenharmony_ci 42962306a36Sopenharmony_ciWrites the general purpose registers into the vcpu. 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ciSee KVM_GET_REGS for the data structure. 43262306a36Sopenharmony_ci 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_ci4.13 KVM_GET_SREGS 43562306a36Sopenharmony_ci------------------ 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci:Capability: basic 43862306a36Sopenharmony_ci:Architectures: x86, ppc 43962306a36Sopenharmony_ci:Type: vcpu ioctl 44062306a36Sopenharmony_ci:Parameters: struct kvm_sregs (out) 44162306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_ciReads special registers from the vcpu. 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci:: 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_ci /* x86 */ 44862306a36Sopenharmony_ci struct kvm_sregs { 44962306a36Sopenharmony_ci struct kvm_segment cs, ds, es, fs, gs, ss; 45062306a36Sopenharmony_ci struct kvm_segment tr, ldt; 45162306a36Sopenharmony_ci struct kvm_dtable gdt, idt; 45262306a36Sopenharmony_ci __u64 cr0, cr2, cr3, cr4, cr8; 45362306a36Sopenharmony_ci __u64 efer; 45462306a36Sopenharmony_ci __u64 apic_base; 45562306a36Sopenharmony_ci __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; 45662306a36Sopenharmony_ci }; 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ci /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */ 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ciinterrupt_bitmap is a bitmap of pending external interrupts. At most 46162306a36Sopenharmony_cione bit may be set. This interrupt has been acknowledged by the APIC 46262306a36Sopenharmony_cibut not yet injected into the cpu core. 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ci4.14 KVM_SET_SREGS 46662306a36Sopenharmony_ci------------------ 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ci:Capability: basic 46962306a36Sopenharmony_ci:Architectures: x86, ppc 47062306a36Sopenharmony_ci:Type: vcpu ioctl 47162306a36Sopenharmony_ci:Parameters: struct kvm_sregs (in) 47262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 47362306a36Sopenharmony_ci 47462306a36Sopenharmony_ciWrites special registers into the vcpu. See KVM_GET_SREGS for the 47562306a36Sopenharmony_cidata structures. 47662306a36Sopenharmony_ci 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci4.15 KVM_TRANSLATE 47962306a36Sopenharmony_ci------------------ 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ci:Capability: basic 48262306a36Sopenharmony_ci:Architectures: x86 48362306a36Sopenharmony_ci:Type: vcpu ioctl 48462306a36Sopenharmony_ci:Parameters: struct kvm_translation (in/out) 48562306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_ciTranslates a virtual address according to the vcpu's current address 48862306a36Sopenharmony_citranslation mode. 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_ci:: 49162306a36Sopenharmony_ci 49262306a36Sopenharmony_ci struct kvm_translation { 49362306a36Sopenharmony_ci /* in */ 49462306a36Sopenharmony_ci __u64 linear_address; 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_ci /* out */ 49762306a36Sopenharmony_ci __u64 physical_address; 49862306a36Sopenharmony_ci __u8 valid; 49962306a36Sopenharmony_ci __u8 writeable; 50062306a36Sopenharmony_ci __u8 usermode; 50162306a36Sopenharmony_ci __u8 pad[5]; 50262306a36Sopenharmony_ci }; 50362306a36Sopenharmony_ci 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_ci4.16 KVM_INTERRUPT 50662306a36Sopenharmony_ci------------------ 50762306a36Sopenharmony_ci 50862306a36Sopenharmony_ci:Capability: basic 50962306a36Sopenharmony_ci:Architectures: x86, ppc, mips, riscv 51062306a36Sopenharmony_ci:Type: vcpu ioctl 51162306a36Sopenharmony_ci:Parameters: struct kvm_interrupt (in) 51262306a36Sopenharmony_ci:Returns: 0 on success, negative on failure. 51362306a36Sopenharmony_ci 51462306a36Sopenharmony_ciQueues a hardware interrupt vector to be injected. 51562306a36Sopenharmony_ci 51662306a36Sopenharmony_ci:: 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ci /* for KVM_INTERRUPT */ 51962306a36Sopenharmony_ci struct kvm_interrupt { 52062306a36Sopenharmony_ci /* in */ 52162306a36Sopenharmony_ci __u32 irq; 52262306a36Sopenharmony_ci }; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ciX86: 52562306a36Sopenharmony_ci^^^^ 52662306a36Sopenharmony_ci 52762306a36Sopenharmony_ci:Returns: 52862306a36Sopenharmony_ci 52962306a36Sopenharmony_ci ========= =================================== 53062306a36Sopenharmony_ci 0 on success, 53162306a36Sopenharmony_ci -EEXIST if an interrupt is already enqueued 53262306a36Sopenharmony_ci -EINVAL the irq number is invalid 53362306a36Sopenharmony_ci -ENXIO if the PIC is in the kernel 53462306a36Sopenharmony_ci -EFAULT if the pointer is invalid 53562306a36Sopenharmony_ci ========= =================================== 53662306a36Sopenharmony_ci 53762306a36Sopenharmony_ciNote 'irq' is an interrupt vector, not an interrupt pin or line. This 53862306a36Sopenharmony_ciioctl is useful if the in-kernel PIC is not used. 53962306a36Sopenharmony_ci 54062306a36Sopenharmony_ciPPC: 54162306a36Sopenharmony_ci^^^^ 54262306a36Sopenharmony_ci 54362306a36Sopenharmony_ciQueues an external interrupt to be injected. This ioctl is overleaded 54462306a36Sopenharmony_ciwith 3 different irq values: 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_cia) KVM_INTERRUPT_SET 54762306a36Sopenharmony_ci 54862306a36Sopenharmony_ci This injects an edge type external interrupt into the guest once it's ready 54962306a36Sopenharmony_ci to receive interrupts. When injected, the interrupt is done. 55062306a36Sopenharmony_ci 55162306a36Sopenharmony_cib) KVM_INTERRUPT_UNSET 55262306a36Sopenharmony_ci 55362306a36Sopenharmony_ci This unsets any pending interrupt. 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ci Only available with KVM_CAP_PPC_UNSET_IRQ. 55662306a36Sopenharmony_ci 55762306a36Sopenharmony_cic) KVM_INTERRUPT_SET_LEVEL 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ci This injects a level type external interrupt into the guest context. The 56062306a36Sopenharmony_ci interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET 56162306a36Sopenharmony_ci is triggered. 56262306a36Sopenharmony_ci 56362306a36Sopenharmony_ci Only available with KVM_CAP_PPC_IRQ_LEVEL. 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_ciNote that any value for 'irq' other than the ones stated above is invalid 56662306a36Sopenharmony_ciand incurs unexpected behavior. 56762306a36Sopenharmony_ci 56862306a36Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 56962306a36Sopenharmony_ci 57062306a36Sopenharmony_ciMIPS: 57162306a36Sopenharmony_ci^^^^^ 57262306a36Sopenharmony_ci 57362306a36Sopenharmony_ciQueues an external interrupt to be injected into the virtual CPU. A negative 57462306a36Sopenharmony_ciinterrupt number dequeues the interrupt. 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 57762306a36Sopenharmony_ci 57862306a36Sopenharmony_ciRISC-V: 57962306a36Sopenharmony_ci^^^^^^^ 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_ciQueues an external interrupt to be injected into the virtual CPU. This ioctl 58262306a36Sopenharmony_ciis overloaded with 2 different irq values: 58362306a36Sopenharmony_ci 58462306a36Sopenharmony_cia) KVM_INTERRUPT_SET 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_ci This sets external interrupt for a virtual CPU and it will receive 58762306a36Sopenharmony_ci once it is ready. 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_cib) KVM_INTERRUPT_UNSET 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_ci This clears pending external interrupt for a virtual CPU. 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 59462306a36Sopenharmony_ci 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_ci4.17 KVM_DEBUG_GUEST 59762306a36Sopenharmony_ci-------------------- 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_ci:Capability: basic 60062306a36Sopenharmony_ci:Architectures: none 60162306a36Sopenharmony_ci:Type: vcpu ioctl 60262306a36Sopenharmony_ci:Parameters: none) 60362306a36Sopenharmony_ci:Returns: -1 on error 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_ciSupport for this has been removed. Use KVM_SET_GUEST_DEBUG instead. 60662306a36Sopenharmony_ci 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_ci4.18 KVM_GET_MSRS 60962306a36Sopenharmony_ci----------------- 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_ci:Capability: basic (vcpu), KVM_CAP_GET_MSR_FEATURES (system) 61262306a36Sopenharmony_ci:Architectures: x86 61362306a36Sopenharmony_ci:Type: system ioctl, vcpu ioctl 61462306a36Sopenharmony_ci:Parameters: struct kvm_msrs (in/out) 61562306a36Sopenharmony_ci:Returns: number of msrs successfully returned; 61662306a36Sopenharmony_ci -1 on error 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_ciWhen used as a system ioctl: 61962306a36Sopenharmony_ciReads the values of MSR-based features that are available for the VM. This 62062306a36Sopenharmony_ciis similar to KVM_GET_SUPPORTED_CPUID, but it returns MSR indices and values. 62162306a36Sopenharmony_ciThe list of msr-based features can be obtained using KVM_GET_MSR_FEATURE_INDEX_LIST 62262306a36Sopenharmony_ciin a system ioctl. 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_ciWhen used as a vcpu ioctl: 62562306a36Sopenharmony_ciReads model-specific registers from the vcpu. Supported msr indices can 62662306a36Sopenharmony_cibe obtained using KVM_GET_MSR_INDEX_LIST in a system ioctl. 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_ci:: 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_ci struct kvm_msrs { 63162306a36Sopenharmony_ci __u32 nmsrs; /* number of msrs in entries */ 63262306a36Sopenharmony_ci __u32 pad; 63362306a36Sopenharmony_ci 63462306a36Sopenharmony_ci struct kvm_msr_entry entries[0]; 63562306a36Sopenharmony_ci }; 63662306a36Sopenharmony_ci 63762306a36Sopenharmony_ci struct kvm_msr_entry { 63862306a36Sopenharmony_ci __u32 index; 63962306a36Sopenharmony_ci __u32 reserved; 64062306a36Sopenharmony_ci __u64 data; 64162306a36Sopenharmony_ci }; 64262306a36Sopenharmony_ci 64362306a36Sopenharmony_ciApplication code should set the 'nmsrs' member (which indicates the 64462306a36Sopenharmony_cisize of the entries array) and the 'index' member of each array entry. 64562306a36Sopenharmony_cikvm will fill in the 'data' member. 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_ci 64862306a36Sopenharmony_ci4.19 KVM_SET_MSRS 64962306a36Sopenharmony_ci----------------- 65062306a36Sopenharmony_ci 65162306a36Sopenharmony_ci:Capability: basic 65262306a36Sopenharmony_ci:Architectures: x86 65362306a36Sopenharmony_ci:Type: vcpu ioctl 65462306a36Sopenharmony_ci:Parameters: struct kvm_msrs (in) 65562306a36Sopenharmony_ci:Returns: number of msrs successfully set (see below), -1 on error 65662306a36Sopenharmony_ci 65762306a36Sopenharmony_ciWrites model-specific registers to the vcpu. See KVM_GET_MSRS for the 65862306a36Sopenharmony_cidata structures. 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_ciApplication code should set the 'nmsrs' member (which indicates the 66162306a36Sopenharmony_cisize of the entries array), and the 'index' and 'data' members of each 66262306a36Sopenharmony_ciarray entry. 66362306a36Sopenharmony_ci 66462306a36Sopenharmony_ciIt tries to set the MSRs in array entries[] one by one. If setting an MSR 66562306a36Sopenharmony_cifails, e.g., due to setting reserved bits, the MSR isn't supported/emulated 66662306a36Sopenharmony_ciby KVM, etc..., it stops processing the MSR list and returns the number of 66762306a36Sopenharmony_ciMSRs that have been set successfully. 66862306a36Sopenharmony_ci 66962306a36Sopenharmony_ci 67062306a36Sopenharmony_ci4.20 KVM_SET_CPUID 67162306a36Sopenharmony_ci------------------ 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_ci:Capability: basic 67462306a36Sopenharmony_ci:Architectures: x86 67562306a36Sopenharmony_ci:Type: vcpu ioctl 67662306a36Sopenharmony_ci:Parameters: struct kvm_cpuid (in) 67762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 67862306a36Sopenharmony_ci 67962306a36Sopenharmony_ciDefines the vcpu responses to the cpuid instruction. Applications 68062306a36Sopenharmony_cishould use the KVM_SET_CPUID2 ioctl if available. 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_ciCaveat emptor: 68362306a36Sopenharmony_ci - If this IOCTL fails, KVM gives no guarantees that previous valid CPUID 68462306a36Sopenharmony_ci configuration (if there is) is not corrupted. Userspace can get a copy 68562306a36Sopenharmony_ci of the resulting CPUID configuration through KVM_GET_CPUID2 in case. 68662306a36Sopenharmony_ci - Using KVM_SET_CPUID{,2} after KVM_RUN, i.e. changing the guest vCPU model 68762306a36Sopenharmony_ci after running the guest, may cause guest instability. 68862306a36Sopenharmony_ci - Using heterogeneous CPUID configurations, modulo APIC IDs, topology, etc... 68962306a36Sopenharmony_ci may cause guest instability. 69062306a36Sopenharmony_ci 69162306a36Sopenharmony_ci:: 69262306a36Sopenharmony_ci 69362306a36Sopenharmony_ci struct kvm_cpuid_entry { 69462306a36Sopenharmony_ci __u32 function; 69562306a36Sopenharmony_ci __u32 eax; 69662306a36Sopenharmony_ci __u32 ebx; 69762306a36Sopenharmony_ci __u32 ecx; 69862306a36Sopenharmony_ci __u32 edx; 69962306a36Sopenharmony_ci __u32 padding; 70062306a36Sopenharmony_ci }; 70162306a36Sopenharmony_ci 70262306a36Sopenharmony_ci /* for KVM_SET_CPUID */ 70362306a36Sopenharmony_ci struct kvm_cpuid { 70462306a36Sopenharmony_ci __u32 nent; 70562306a36Sopenharmony_ci __u32 padding; 70662306a36Sopenharmony_ci struct kvm_cpuid_entry entries[0]; 70762306a36Sopenharmony_ci }; 70862306a36Sopenharmony_ci 70962306a36Sopenharmony_ci 71062306a36Sopenharmony_ci4.21 KVM_SET_SIGNAL_MASK 71162306a36Sopenharmony_ci------------------------ 71262306a36Sopenharmony_ci 71362306a36Sopenharmony_ci:Capability: basic 71462306a36Sopenharmony_ci:Architectures: all 71562306a36Sopenharmony_ci:Type: vcpu ioctl 71662306a36Sopenharmony_ci:Parameters: struct kvm_signal_mask (in) 71762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 71862306a36Sopenharmony_ci 71962306a36Sopenharmony_ciDefines which signals are blocked during execution of KVM_RUN. This 72062306a36Sopenharmony_cisignal mask temporarily overrides the threads signal mask. Any 72162306a36Sopenharmony_ciunblocked signal received (except SIGKILL and SIGSTOP, which retain 72262306a36Sopenharmony_citheir traditional behaviour) will cause KVM_RUN to return with -EINTR. 72362306a36Sopenharmony_ci 72462306a36Sopenharmony_ciNote the signal will only be delivered if not blocked by the original 72562306a36Sopenharmony_cisignal mask. 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_ci:: 72862306a36Sopenharmony_ci 72962306a36Sopenharmony_ci /* for KVM_SET_SIGNAL_MASK */ 73062306a36Sopenharmony_ci struct kvm_signal_mask { 73162306a36Sopenharmony_ci __u32 len; 73262306a36Sopenharmony_ci __u8 sigset[0]; 73362306a36Sopenharmony_ci }; 73462306a36Sopenharmony_ci 73562306a36Sopenharmony_ci 73662306a36Sopenharmony_ci4.22 KVM_GET_FPU 73762306a36Sopenharmony_ci---------------- 73862306a36Sopenharmony_ci 73962306a36Sopenharmony_ci:Capability: basic 74062306a36Sopenharmony_ci:Architectures: x86 74162306a36Sopenharmony_ci:Type: vcpu ioctl 74262306a36Sopenharmony_ci:Parameters: struct kvm_fpu (out) 74362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 74462306a36Sopenharmony_ci 74562306a36Sopenharmony_ciReads the floating point state from the vcpu. 74662306a36Sopenharmony_ci 74762306a36Sopenharmony_ci:: 74862306a36Sopenharmony_ci 74962306a36Sopenharmony_ci /* for KVM_GET_FPU and KVM_SET_FPU */ 75062306a36Sopenharmony_ci struct kvm_fpu { 75162306a36Sopenharmony_ci __u8 fpr[8][16]; 75262306a36Sopenharmony_ci __u16 fcw; 75362306a36Sopenharmony_ci __u16 fsw; 75462306a36Sopenharmony_ci __u8 ftwx; /* in fxsave format */ 75562306a36Sopenharmony_ci __u8 pad1; 75662306a36Sopenharmony_ci __u16 last_opcode; 75762306a36Sopenharmony_ci __u64 last_ip; 75862306a36Sopenharmony_ci __u64 last_dp; 75962306a36Sopenharmony_ci __u8 xmm[16][16]; 76062306a36Sopenharmony_ci __u32 mxcsr; 76162306a36Sopenharmony_ci __u32 pad2; 76262306a36Sopenharmony_ci }; 76362306a36Sopenharmony_ci 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci4.23 KVM_SET_FPU 76662306a36Sopenharmony_ci---------------- 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_ci:Capability: basic 76962306a36Sopenharmony_ci:Architectures: x86 77062306a36Sopenharmony_ci:Type: vcpu ioctl 77162306a36Sopenharmony_ci:Parameters: struct kvm_fpu (in) 77262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 77362306a36Sopenharmony_ci 77462306a36Sopenharmony_ciWrites the floating point state to the vcpu. 77562306a36Sopenharmony_ci 77662306a36Sopenharmony_ci:: 77762306a36Sopenharmony_ci 77862306a36Sopenharmony_ci /* for KVM_GET_FPU and KVM_SET_FPU */ 77962306a36Sopenharmony_ci struct kvm_fpu { 78062306a36Sopenharmony_ci __u8 fpr[8][16]; 78162306a36Sopenharmony_ci __u16 fcw; 78262306a36Sopenharmony_ci __u16 fsw; 78362306a36Sopenharmony_ci __u8 ftwx; /* in fxsave format */ 78462306a36Sopenharmony_ci __u8 pad1; 78562306a36Sopenharmony_ci __u16 last_opcode; 78662306a36Sopenharmony_ci __u64 last_ip; 78762306a36Sopenharmony_ci __u64 last_dp; 78862306a36Sopenharmony_ci __u8 xmm[16][16]; 78962306a36Sopenharmony_ci __u32 mxcsr; 79062306a36Sopenharmony_ci __u32 pad2; 79162306a36Sopenharmony_ci }; 79262306a36Sopenharmony_ci 79362306a36Sopenharmony_ci 79462306a36Sopenharmony_ci4.24 KVM_CREATE_IRQCHIP 79562306a36Sopenharmony_ci----------------------- 79662306a36Sopenharmony_ci 79762306a36Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390) 79862306a36Sopenharmony_ci:Architectures: x86, arm64, s390 79962306a36Sopenharmony_ci:Type: vm ioctl 80062306a36Sopenharmony_ci:Parameters: none 80162306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 80262306a36Sopenharmony_ci 80362306a36Sopenharmony_ciCreates an interrupt controller model in the kernel. 80462306a36Sopenharmony_ciOn x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up 80562306a36Sopenharmony_cifuture vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both 80662306a36Sopenharmony_ciPIC and IOAPIC; GSI 16-23 only go to the IOAPIC. 80762306a36Sopenharmony_ciOn arm64, a GICv2 is created. Any other GIC versions require the usage of 80862306a36Sopenharmony_ciKVM_CREATE_DEVICE, which also supports creating a GICv2. Using 80962306a36Sopenharmony_ciKVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2. 81062306a36Sopenharmony_ciOn s390, a dummy irq routing table is created. 81162306a36Sopenharmony_ci 81262306a36Sopenharmony_ciNote that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled 81362306a36Sopenharmony_cibefore KVM_CREATE_IRQCHIP can be used. 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_ci 81662306a36Sopenharmony_ci4.25 KVM_IRQ_LINE 81762306a36Sopenharmony_ci----------------- 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 82062306a36Sopenharmony_ci:Architectures: x86, arm64 82162306a36Sopenharmony_ci:Type: vm ioctl 82262306a36Sopenharmony_ci:Parameters: struct kvm_irq_level 82362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 82462306a36Sopenharmony_ci 82562306a36Sopenharmony_ciSets the level of a GSI input to the interrupt controller model in the kernel. 82662306a36Sopenharmony_ciOn some architectures it is required that an interrupt controller model has 82762306a36Sopenharmony_cibeen previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered 82862306a36Sopenharmony_ciinterrupts require the level to be set to 1 and then back to 0. 82962306a36Sopenharmony_ci 83062306a36Sopenharmony_ciOn real hardware, interrupt pins can be active-low or active-high. This 83162306a36Sopenharmony_cidoes not matter for the level field of struct kvm_irq_level: 1 always 83262306a36Sopenharmony_cimeans active (asserted), 0 means inactive (deasserted). 83362306a36Sopenharmony_ci 83462306a36Sopenharmony_cix86 allows the operating system to program the interrupt polarity 83562306a36Sopenharmony_ci(active-low/active-high) for level-triggered interrupts, and KVM used 83662306a36Sopenharmony_cito consider the polarity. However, due to bitrot in the handling of 83762306a36Sopenharmony_ciactive-low interrupts, the above convention is now valid on x86 too. 83862306a36Sopenharmony_ciThis is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace 83962306a36Sopenharmony_cishould not present interrupts to the guest as active-low unless this 84062306a36Sopenharmony_cicapability is present (or unless it is not using the in-kernel irqchip, 84162306a36Sopenharmony_ciof course). 84262306a36Sopenharmony_ci 84362306a36Sopenharmony_ci 84462306a36Sopenharmony_ciarm64 can signal an interrupt either at the CPU level, or at the 84562306a36Sopenharmony_ciin-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to 84662306a36Sopenharmony_ciuse PPIs designated for specific cpus. The irq field is interpreted 84762306a36Sopenharmony_cilike this:: 84862306a36Sopenharmony_ci 84962306a36Sopenharmony_ci bits: | 31 ... 28 | 27 ... 24 | 23 ... 16 | 15 ... 0 | 85062306a36Sopenharmony_ci field: | vcpu2_index | irq_type | vcpu_index | irq_id | 85162306a36Sopenharmony_ci 85262306a36Sopenharmony_ciThe irq_type field has the following values: 85362306a36Sopenharmony_ci 85462306a36Sopenharmony_ci- irq_type[0]: 85562306a36Sopenharmony_ci out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ 85662306a36Sopenharmony_ci- irq_type[1]: 85762306a36Sopenharmony_ci in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.) 85862306a36Sopenharmony_ci (the vcpu_index field is ignored) 85962306a36Sopenharmony_ci- irq_type[2]: 86062306a36Sopenharmony_ci in-kernel GIC: PPI, irq_id between 16 and 31 (incl.) 86162306a36Sopenharmony_ci 86262306a36Sopenharmony_ci(The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs) 86362306a36Sopenharmony_ci 86462306a36Sopenharmony_ciIn both cases, level is used to assert/deassert the line. 86562306a36Sopenharmony_ci 86662306a36Sopenharmony_ciWhen KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 is supported, the target vcpu is 86762306a36Sopenharmony_ciidentified as (256 * vcpu2_index + vcpu_index). Otherwise, vcpu2_index 86862306a36Sopenharmony_cimust be zero. 86962306a36Sopenharmony_ci 87062306a36Sopenharmony_ciNote that on arm64, the KVM_CAP_IRQCHIP capability only conditions 87162306a36Sopenharmony_ciinjection of interrupts for the in-kernel irqchip. KVM_IRQ_LINE can always 87262306a36Sopenharmony_cibe used for a userspace interrupt controller. 87362306a36Sopenharmony_ci 87462306a36Sopenharmony_ci:: 87562306a36Sopenharmony_ci 87662306a36Sopenharmony_ci struct kvm_irq_level { 87762306a36Sopenharmony_ci union { 87862306a36Sopenharmony_ci __u32 irq; /* GSI */ 87962306a36Sopenharmony_ci __s32 status; /* not used for KVM_IRQ_LEVEL */ 88062306a36Sopenharmony_ci }; 88162306a36Sopenharmony_ci __u32 level; /* 0 or 1 */ 88262306a36Sopenharmony_ci }; 88362306a36Sopenharmony_ci 88462306a36Sopenharmony_ci 88562306a36Sopenharmony_ci4.26 KVM_GET_IRQCHIP 88662306a36Sopenharmony_ci-------------------- 88762306a36Sopenharmony_ci 88862306a36Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 88962306a36Sopenharmony_ci:Architectures: x86 89062306a36Sopenharmony_ci:Type: vm ioctl 89162306a36Sopenharmony_ci:Parameters: struct kvm_irqchip (in/out) 89262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 89362306a36Sopenharmony_ci 89462306a36Sopenharmony_ciReads the state of a kernel interrupt controller created with 89562306a36Sopenharmony_ciKVM_CREATE_IRQCHIP into a buffer provided by the caller. 89662306a36Sopenharmony_ci 89762306a36Sopenharmony_ci:: 89862306a36Sopenharmony_ci 89962306a36Sopenharmony_ci struct kvm_irqchip { 90062306a36Sopenharmony_ci __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ 90162306a36Sopenharmony_ci __u32 pad; 90262306a36Sopenharmony_ci union { 90362306a36Sopenharmony_ci char dummy[512]; /* reserving space */ 90462306a36Sopenharmony_ci struct kvm_pic_state pic; 90562306a36Sopenharmony_ci struct kvm_ioapic_state ioapic; 90662306a36Sopenharmony_ci } chip; 90762306a36Sopenharmony_ci }; 90862306a36Sopenharmony_ci 90962306a36Sopenharmony_ci 91062306a36Sopenharmony_ci4.27 KVM_SET_IRQCHIP 91162306a36Sopenharmony_ci-------------------- 91262306a36Sopenharmony_ci 91362306a36Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 91462306a36Sopenharmony_ci:Architectures: x86 91562306a36Sopenharmony_ci:Type: vm ioctl 91662306a36Sopenharmony_ci:Parameters: struct kvm_irqchip (in) 91762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 91862306a36Sopenharmony_ci 91962306a36Sopenharmony_ciSets the state of a kernel interrupt controller created with 92062306a36Sopenharmony_ciKVM_CREATE_IRQCHIP from a buffer provided by the caller. 92162306a36Sopenharmony_ci 92262306a36Sopenharmony_ci:: 92362306a36Sopenharmony_ci 92462306a36Sopenharmony_ci struct kvm_irqchip { 92562306a36Sopenharmony_ci __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */ 92662306a36Sopenharmony_ci __u32 pad; 92762306a36Sopenharmony_ci union { 92862306a36Sopenharmony_ci char dummy[512]; /* reserving space */ 92962306a36Sopenharmony_ci struct kvm_pic_state pic; 93062306a36Sopenharmony_ci struct kvm_ioapic_state ioapic; 93162306a36Sopenharmony_ci } chip; 93262306a36Sopenharmony_ci }; 93362306a36Sopenharmony_ci 93462306a36Sopenharmony_ci 93562306a36Sopenharmony_ci4.28 KVM_XEN_HVM_CONFIG 93662306a36Sopenharmony_ci----------------------- 93762306a36Sopenharmony_ci 93862306a36Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM 93962306a36Sopenharmony_ci:Architectures: x86 94062306a36Sopenharmony_ci:Type: vm ioctl 94162306a36Sopenharmony_ci:Parameters: struct kvm_xen_hvm_config (in) 94262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 94362306a36Sopenharmony_ci 94462306a36Sopenharmony_ciSets the MSR that the Xen HVM guest uses to initialize its hypercall 94562306a36Sopenharmony_cipage, and provides the starting address and size of the hypercall 94662306a36Sopenharmony_ciblobs in userspace. When the guest writes the MSR, kvm copies one 94762306a36Sopenharmony_cipage of a blob (32- or 64-bit, depending on the vcpu mode) to guest 94862306a36Sopenharmony_cimemory. 94962306a36Sopenharmony_ci 95062306a36Sopenharmony_ci:: 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_ci struct kvm_xen_hvm_config { 95362306a36Sopenharmony_ci __u32 flags; 95462306a36Sopenharmony_ci __u32 msr; 95562306a36Sopenharmony_ci __u64 blob_addr_32; 95662306a36Sopenharmony_ci __u64 blob_addr_64; 95762306a36Sopenharmony_ci __u8 blob_size_32; 95862306a36Sopenharmony_ci __u8 blob_size_64; 95962306a36Sopenharmony_ci __u8 pad2[30]; 96062306a36Sopenharmony_ci }; 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_ciIf certain flags are returned from the KVM_CAP_XEN_HVM check, they may 96362306a36Sopenharmony_cibe set in the flags field of this ioctl: 96462306a36Sopenharmony_ci 96562306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL flag requests KVM to generate 96662306a36Sopenharmony_cithe contents of the hypercall page automatically; hypercalls will be 96762306a36Sopenharmony_ciintercepted and passed to userspace through KVM_EXIT_XEN. In this 96862306a36Sopenharmony_ciase, all of the blob size and address fields must be zero. 96962306a36Sopenharmony_ci 97062306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_EVTCHN_SEND flag indicates to KVM that userspace 97162306a36Sopenharmony_ciwill always use the KVM_XEN_HVM_EVTCHN_SEND ioctl to deliver event 97262306a36Sopenharmony_cichannel interrupts rather than manipulating the guest's shared_info 97362306a36Sopenharmony_cistructures directly. This, in turn, may allow KVM to enable features 97462306a36Sopenharmony_cisuch as intercepting the SCHEDOP_poll hypercall to accelerate PV 97562306a36Sopenharmony_cispinlock operation for the guest. Userspace may still use the ioctl 97662306a36Sopenharmony_cito deliver events if it was advertised, even if userspace does not 97762306a36Sopenharmony_cisend this indication that it will always do so 97862306a36Sopenharmony_ci 97962306a36Sopenharmony_ciNo other flags are currently valid in the struct kvm_xen_hvm_config. 98062306a36Sopenharmony_ci 98162306a36Sopenharmony_ci4.29 KVM_GET_CLOCK 98262306a36Sopenharmony_ci------------------ 98362306a36Sopenharmony_ci 98462306a36Sopenharmony_ci:Capability: KVM_CAP_ADJUST_CLOCK 98562306a36Sopenharmony_ci:Architectures: x86 98662306a36Sopenharmony_ci:Type: vm ioctl 98762306a36Sopenharmony_ci:Parameters: struct kvm_clock_data (out) 98862306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 98962306a36Sopenharmony_ci 99062306a36Sopenharmony_ciGets the current timestamp of kvmclock as seen by the current guest. In 99162306a36Sopenharmony_ciconjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios 99262306a36Sopenharmony_cisuch as migration. 99362306a36Sopenharmony_ci 99462306a36Sopenharmony_ciWhen KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the 99562306a36Sopenharmony_ciset of bits that KVM can return in struct kvm_clock_data's flag member. 99662306a36Sopenharmony_ci 99762306a36Sopenharmony_ciThe following flags are defined: 99862306a36Sopenharmony_ci 99962306a36Sopenharmony_ciKVM_CLOCK_TSC_STABLE 100062306a36Sopenharmony_ci If set, the returned value is the exact kvmclock 100162306a36Sopenharmony_ci value seen by all VCPUs at the instant when KVM_GET_CLOCK was called. 100262306a36Sopenharmony_ci If clear, the returned value is simply CLOCK_MONOTONIC plus a constant 100362306a36Sopenharmony_ci offset; the offset can be modified with KVM_SET_CLOCK. KVM will try 100462306a36Sopenharmony_ci to make all VCPUs follow this clock, but the exact value read by each 100562306a36Sopenharmony_ci VCPU could differ, because the host TSC is not stable. 100662306a36Sopenharmony_ci 100762306a36Sopenharmony_ciKVM_CLOCK_REALTIME 100862306a36Sopenharmony_ci If set, the `realtime` field in the kvm_clock_data 100962306a36Sopenharmony_ci structure is populated with the value of the host's real time 101062306a36Sopenharmony_ci clocksource at the instant when KVM_GET_CLOCK was called. If clear, 101162306a36Sopenharmony_ci the `realtime` field does not contain a value. 101262306a36Sopenharmony_ci 101362306a36Sopenharmony_ciKVM_CLOCK_HOST_TSC 101462306a36Sopenharmony_ci If set, the `host_tsc` field in the kvm_clock_data 101562306a36Sopenharmony_ci structure is populated with the value of the host's timestamp counter (TSC) 101662306a36Sopenharmony_ci at the instant when KVM_GET_CLOCK was called. If clear, the `host_tsc` field 101762306a36Sopenharmony_ci does not contain a value. 101862306a36Sopenharmony_ci 101962306a36Sopenharmony_ci:: 102062306a36Sopenharmony_ci 102162306a36Sopenharmony_ci struct kvm_clock_data { 102262306a36Sopenharmony_ci __u64 clock; /* kvmclock current value */ 102362306a36Sopenharmony_ci __u32 flags; 102462306a36Sopenharmony_ci __u32 pad0; 102562306a36Sopenharmony_ci __u64 realtime; 102662306a36Sopenharmony_ci __u64 host_tsc; 102762306a36Sopenharmony_ci __u32 pad[4]; 102862306a36Sopenharmony_ci }; 102962306a36Sopenharmony_ci 103062306a36Sopenharmony_ci 103162306a36Sopenharmony_ci4.30 KVM_SET_CLOCK 103262306a36Sopenharmony_ci------------------ 103362306a36Sopenharmony_ci 103462306a36Sopenharmony_ci:Capability: KVM_CAP_ADJUST_CLOCK 103562306a36Sopenharmony_ci:Architectures: x86 103662306a36Sopenharmony_ci:Type: vm ioctl 103762306a36Sopenharmony_ci:Parameters: struct kvm_clock_data (in) 103862306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 103962306a36Sopenharmony_ci 104062306a36Sopenharmony_ciSets the current timestamp of kvmclock to the value specified in its parameter. 104162306a36Sopenharmony_ciIn conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios 104262306a36Sopenharmony_cisuch as migration. 104362306a36Sopenharmony_ci 104462306a36Sopenharmony_ciThe following flags can be passed: 104562306a36Sopenharmony_ci 104662306a36Sopenharmony_ciKVM_CLOCK_REALTIME 104762306a36Sopenharmony_ci If set, KVM will compare the value of the `realtime` field 104862306a36Sopenharmony_ci with the value of the host's real time clocksource at the instant when 104962306a36Sopenharmony_ci KVM_SET_CLOCK was called. The difference in elapsed time is added to the final 105062306a36Sopenharmony_ci kvmclock value that will be provided to guests. 105162306a36Sopenharmony_ci 105262306a36Sopenharmony_ciOther flags returned by ``KVM_GET_CLOCK`` are accepted but ignored. 105362306a36Sopenharmony_ci 105462306a36Sopenharmony_ci:: 105562306a36Sopenharmony_ci 105662306a36Sopenharmony_ci struct kvm_clock_data { 105762306a36Sopenharmony_ci __u64 clock; /* kvmclock current value */ 105862306a36Sopenharmony_ci __u32 flags; 105962306a36Sopenharmony_ci __u32 pad0; 106062306a36Sopenharmony_ci __u64 realtime; 106162306a36Sopenharmony_ci __u64 host_tsc; 106262306a36Sopenharmony_ci __u32 pad[4]; 106362306a36Sopenharmony_ci }; 106462306a36Sopenharmony_ci 106562306a36Sopenharmony_ci 106662306a36Sopenharmony_ci4.31 KVM_GET_VCPU_EVENTS 106762306a36Sopenharmony_ci------------------------ 106862306a36Sopenharmony_ci 106962306a36Sopenharmony_ci:Capability: KVM_CAP_VCPU_EVENTS 107062306a36Sopenharmony_ci:Extended by: KVM_CAP_INTR_SHADOW 107162306a36Sopenharmony_ci:Architectures: x86, arm64 107262306a36Sopenharmony_ci:Type: vcpu ioctl 107362306a36Sopenharmony_ci:Parameters: struct kvm_vcpu_event (out) 107462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 107562306a36Sopenharmony_ci 107662306a36Sopenharmony_ciX86: 107762306a36Sopenharmony_ci^^^^ 107862306a36Sopenharmony_ci 107962306a36Sopenharmony_ciGets currently pending exceptions, interrupts, and NMIs as well as related 108062306a36Sopenharmony_cistates of the vcpu. 108162306a36Sopenharmony_ci 108262306a36Sopenharmony_ci:: 108362306a36Sopenharmony_ci 108462306a36Sopenharmony_ci struct kvm_vcpu_events { 108562306a36Sopenharmony_ci struct { 108662306a36Sopenharmony_ci __u8 injected; 108762306a36Sopenharmony_ci __u8 nr; 108862306a36Sopenharmony_ci __u8 has_error_code; 108962306a36Sopenharmony_ci __u8 pending; 109062306a36Sopenharmony_ci __u32 error_code; 109162306a36Sopenharmony_ci } exception; 109262306a36Sopenharmony_ci struct { 109362306a36Sopenharmony_ci __u8 injected; 109462306a36Sopenharmony_ci __u8 nr; 109562306a36Sopenharmony_ci __u8 soft; 109662306a36Sopenharmony_ci __u8 shadow; 109762306a36Sopenharmony_ci } interrupt; 109862306a36Sopenharmony_ci struct { 109962306a36Sopenharmony_ci __u8 injected; 110062306a36Sopenharmony_ci __u8 pending; 110162306a36Sopenharmony_ci __u8 masked; 110262306a36Sopenharmony_ci __u8 pad; 110362306a36Sopenharmony_ci } nmi; 110462306a36Sopenharmony_ci __u32 sipi_vector; 110562306a36Sopenharmony_ci __u32 flags; 110662306a36Sopenharmony_ci struct { 110762306a36Sopenharmony_ci __u8 smm; 110862306a36Sopenharmony_ci __u8 pending; 110962306a36Sopenharmony_ci __u8 smm_inside_nmi; 111062306a36Sopenharmony_ci __u8 latched_init; 111162306a36Sopenharmony_ci } smi; 111262306a36Sopenharmony_ci __u8 reserved[27]; 111362306a36Sopenharmony_ci __u8 exception_has_payload; 111462306a36Sopenharmony_ci __u64 exception_payload; 111562306a36Sopenharmony_ci }; 111662306a36Sopenharmony_ci 111762306a36Sopenharmony_ciThe following bits are defined in the flags field: 111862306a36Sopenharmony_ci 111962306a36Sopenharmony_ci- KVM_VCPUEVENT_VALID_SHADOW may be set to signal that 112062306a36Sopenharmony_ci interrupt.shadow contains a valid state. 112162306a36Sopenharmony_ci 112262306a36Sopenharmony_ci- KVM_VCPUEVENT_VALID_SMM may be set to signal that smi contains a 112362306a36Sopenharmony_ci valid state. 112462306a36Sopenharmony_ci 112562306a36Sopenharmony_ci- KVM_VCPUEVENT_VALID_PAYLOAD may be set to signal that the 112662306a36Sopenharmony_ci exception_has_payload, exception_payload, and exception.pending 112762306a36Sopenharmony_ci fields contain a valid state. This bit will be set whenever 112862306a36Sopenharmony_ci KVM_CAP_EXCEPTION_PAYLOAD is enabled. 112962306a36Sopenharmony_ci 113062306a36Sopenharmony_ci- KVM_VCPUEVENT_VALID_TRIPLE_FAULT may be set to signal that the 113162306a36Sopenharmony_ci triple_fault_pending field contains a valid state. This bit will 113262306a36Sopenharmony_ci be set whenever KVM_CAP_X86_TRIPLE_FAULT_EVENT is enabled. 113362306a36Sopenharmony_ci 113462306a36Sopenharmony_ciARM64: 113562306a36Sopenharmony_ci^^^^^^ 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ciIf the guest accesses a device that is being emulated by the host kernel in 113862306a36Sopenharmony_cisuch a way that a real device would generate a physical SError, KVM may make 113962306a36Sopenharmony_cia virtual SError pending for that VCPU. This system error interrupt remains 114062306a36Sopenharmony_cipending until the guest takes the exception by unmasking PSTATE.A. 114162306a36Sopenharmony_ci 114262306a36Sopenharmony_ciRunning the VCPU may cause it to take a pending SError, or make an access that 114362306a36Sopenharmony_cicauses an SError to become pending. The event's description is only valid while 114462306a36Sopenharmony_cithe VPCU is not running. 114562306a36Sopenharmony_ci 114662306a36Sopenharmony_ciThis API provides a way to read and write the pending 'event' state that is not 114762306a36Sopenharmony_civisible to the guest. To save, restore or migrate a VCPU the struct representing 114862306a36Sopenharmony_cithe state can be read then written using this GET/SET API, along with the other 114962306a36Sopenharmony_ciguest-visible registers. It is not possible to 'cancel' an SError that has been 115062306a36Sopenharmony_cimade pending. 115162306a36Sopenharmony_ci 115262306a36Sopenharmony_ciA device being emulated in user-space may also wish to generate an SError. To do 115362306a36Sopenharmony_cithis the events structure can be populated by user-space. The current state 115462306a36Sopenharmony_cishould be read first, to ensure no existing SError is pending. If an existing 115562306a36Sopenharmony_ciSError is pending, the architecture's 'Multiple SError interrupts' rules should 115662306a36Sopenharmony_cibe followed. (2.5.3 of DDI0587.a "ARM Reliability, Availability, and 115762306a36Sopenharmony_ciServiceability (RAS) Specification"). 115862306a36Sopenharmony_ci 115962306a36Sopenharmony_ciSError exceptions always have an ESR value. Some CPUs have the ability to 116062306a36Sopenharmony_cispecify what the virtual SError's ESR value should be. These systems will 116162306a36Sopenharmony_ciadvertise KVM_CAP_ARM_INJECT_SERROR_ESR. In this case exception.has_esr will 116262306a36Sopenharmony_cialways have a non-zero value when read, and the agent making an SError pending 116362306a36Sopenharmony_cishould specify the ISS field in the lower 24 bits of exception.serror_esr. If 116462306a36Sopenharmony_cithe system supports KVM_CAP_ARM_INJECT_SERROR_ESR, but user-space sets the events 116562306a36Sopenharmony_ciwith exception.has_esr as zero, KVM will choose an ESR. 116662306a36Sopenharmony_ci 116762306a36Sopenharmony_ciSpecifying exception.has_esr on a system that does not support it will return 116862306a36Sopenharmony_ci-EINVAL. Setting anything other than the lower 24bits of exception.serror_esr 116962306a36Sopenharmony_ciwill return -EINVAL. 117062306a36Sopenharmony_ci 117162306a36Sopenharmony_ciIt is not possible to read back a pending external abort (injected via 117262306a36Sopenharmony_ciKVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered 117362306a36Sopenharmony_cidirectly to the virtual CPU). 117462306a36Sopenharmony_ci 117562306a36Sopenharmony_ci:: 117662306a36Sopenharmony_ci 117762306a36Sopenharmony_ci struct kvm_vcpu_events { 117862306a36Sopenharmony_ci struct { 117962306a36Sopenharmony_ci __u8 serror_pending; 118062306a36Sopenharmony_ci __u8 serror_has_esr; 118162306a36Sopenharmony_ci __u8 ext_dabt_pending; 118262306a36Sopenharmony_ci /* Align it to 8 bytes */ 118362306a36Sopenharmony_ci __u8 pad[5]; 118462306a36Sopenharmony_ci __u64 serror_esr; 118562306a36Sopenharmony_ci } exception; 118662306a36Sopenharmony_ci __u32 reserved[12]; 118762306a36Sopenharmony_ci }; 118862306a36Sopenharmony_ci 118962306a36Sopenharmony_ci4.32 KVM_SET_VCPU_EVENTS 119062306a36Sopenharmony_ci------------------------ 119162306a36Sopenharmony_ci 119262306a36Sopenharmony_ci:Capability: KVM_CAP_VCPU_EVENTS 119362306a36Sopenharmony_ci:Extended by: KVM_CAP_INTR_SHADOW 119462306a36Sopenharmony_ci:Architectures: x86, arm64 119562306a36Sopenharmony_ci:Type: vcpu ioctl 119662306a36Sopenharmony_ci:Parameters: struct kvm_vcpu_event (in) 119762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 119862306a36Sopenharmony_ci 119962306a36Sopenharmony_ciX86: 120062306a36Sopenharmony_ci^^^^ 120162306a36Sopenharmony_ci 120262306a36Sopenharmony_ciSet pending exceptions, interrupts, and NMIs as well as related states of the 120362306a36Sopenharmony_civcpu. 120462306a36Sopenharmony_ci 120562306a36Sopenharmony_ciSee KVM_GET_VCPU_EVENTS for the data structure. 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_ciFields that may be modified asynchronously by running VCPUs can be excluded 120862306a36Sopenharmony_cifrom the update. These fields are nmi.pending, sipi_vector, smi.smm, 120962306a36Sopenharmony_cismi.pending. Keep the corresponding bits in the flags field cleared to 121062306a36Sopenharmony_cisuppress overwriting the current in-kernel state. The bits are: 121162306a36Sopenharmony_ci 121262306a36Sopenharmony_ci=============================== ================================== 121362306a36Sopenharmony_ciKVM_VCPUEVENT_VALID_NMI_PENDING transfer nmi.pending to the kernel 121462306a36Sopenharmony_ciKVM_VCPUEVENT_VALID_SIPI_VECTOR transfer sipi_vector 121562306a36Sopenharmony_ciKVM_VCPUEVENT_VALID_SMM transfer the smi sub-struct. 121662306a36Sopenharmony_ci=============================== ================================== 121762306a36Sopenharmony_ci 121862306a36Sopenharmony_ciIf KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in 121962306a36Sopenharmony_cithe flags field to signal that interrupt.shadow contains a valid state and 122062306a36Sopenharmony_cishall be written into the VCPU. 122162306a36Sopenharmony_ci 122262306a36Sopenharmony_ciKVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available. 122362306a36Sopenharmony_ci 122462306a36Sopenharmony_ciIf KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_VCPUEVENT_VALID_PAYLOAD 122562306a36Sopenharmony_cican be set in the flags field to signal that the 122662306a36Sopenharmony_ciexception_has_payload, exception_payload, and exception.pending fields 122762306a36Sopenharmony_cicontain a valid state and shall be written into the VCPU. 122862306a36Sopenharmony_ci 122962306a36Sopenharmony_ciIf KVM_CAP_X86_TRIPLE_FAULT_EVENT is enabled, KVM_VCPUEVENT_VALID_TRIPLE_FAULT 123062306a36Sopenharmony_cican be set in flags field to signal that the triple_fault field contains 123162306a36Sopenharmony_cia valid state and shall be written into the VCPU. 123262306a36Sopenharmony_ci 123362306a36Sopenharmony_ciARM64: 123462306a36Sopenharmony_ci^^^^^^ 123562306a36Sopenharmony_ci 123662306a36Sopenharmony_ciUser space may need to inject several types of events to the guest. 123762306a36Sopenharmony_ci 123862306a36Sopenharmony_ciSet the pending SError exception state for this VCPU. It is not possible to 123962306a36Sopenharmony_ci'cancel' an Serror that has been made pending. 124062306a36Sopenharmony_ci 124162306a36Sopenharmony_ciIf the guest performed an access to I/O memory which could not be handled by 124262306a36Sopenharmony_ciuserspace, for example because of missing instruction syndrome decode 124362306a36Sopenharmony_ciinformation or because there is no device mapped at the accessed IPA, then 124462306a36Sopenharmony_ciuserspace can ask the kernel to inject an external abort using the address 124562306a36Sopenharmony_cifrom the exiting fault on the VCPU. It is a programming error to set 124662306a36Sopenharmony_ciext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or 124762306a36Sopenharmony_ciKVM_EXIT_ARM_NISV. This feature is only available if the system supports 124862306a36Sopenharmony_ciKVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in 124962306a36Sopenharmony_cihow userspace reports accesses for the above cases to guests, across different 125062306a36Sopenharmony_ciuserspace implementations. Nevertheless, userspace can still emulate all Arm 125162306a36Sopenharmony_ciexceptions by manipulating individual registers using the KVM_SET_ONE_REG API. 125262306a36Sopenharmony_ci 125362306a36Sopenharmony_ciSee KVM_GET_VCPU_EVENTS for the data structure. 125462306a36Sopenharmony_ci 125562306a36Sopenharmony_ci 125662306a36Sopenharmony_ci4.33 KVM_GET_DEBUGREGS 125762306a36Sopenharmony_ci---------------------- 125862306a36Sopenharmony_ci 125962306a36Sopenharmony_ci:Capability: KVM_CAP_DEBUGREGS 126062306a36Sopenharmony_ci:Architectures: x86 126162306a36Sopenharmony_ci:Type: vm ioctl 126262306a36Sopenharmony_ci:Parameters: struct kvm_debugregs (out) 126362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 126462306a36Sopenharmony_ci 126562306a36Sopenharmony_ciReads debug registers from the vcpu. 126662306a36Sopenharmony_ci 126762306a36Sopenharmony_ci:: 126862306a36Sopenharmony_ci 126962306a36Sopenharmony_ci struct kvm_debugregs { 127062306a36Sopenharmony_ci __u64 db[4]; 127162306a36Sopenharmony_ci __u64 dr6; 127262306a36Sopenharmony_ci __u64 dr7; 127362306a36Sopenharmony_ci __u64 flags; 127462306a36Sopenharmony_ci __u64 reserved[9]; 127562306a36Sopenharmony_ci }; 127662306a36Sopenharmony_ci 127762306a36Sopenharmony_ci 127862306a36Sopenharmony_ci4.34 KVM_SET_DEBUGREGS 127962306a36Sopenharmony_ci---------------------- 128062306a36Sopenharmony_ci 128162306a36Sopenharmony_ci:Capability: KVM_CAP_DEBUGREGS 128262306a36Sopenharmony_ci:Architectures: x86 128362306a36Sopenharmony_ci:Type: vm ioctl 128462306a36Sopenharmony_ci:Parameters: struct kvm_debugregs (in) 128562306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 128662306a36Sopenharmony_ci 128762306a36Sopenharmony_ciWrites debug registers into the vcpu. 128862306a36Sopenharmony_ci 128962306a36Sopenharmony_ciSee KVM_GET_DEBUGREGS for the data structure. The flags field is unused 129062306a36Sopenharmony_ciyet and must be cleared on entry. 129162306a36Sopenharmony_ci 129262306a36Sopenharmony_ci 129362306a36Sopenharmony_ci4.35 KVM_SET_USER_MEMORY_REGION 129462306a36Sopenharmony_ci------------------------------- 129562306a36Sopenharmony_ci 129662306a36Sopenharmony_ci:Capability: KVM_CAP_USER_MEMORY 129762306a36Sopenharmony_ci:Architectures: all 129862306a36Sopenharmony_ci:Type: vm ioctl 129962306a36Sopenharmony_ci:Parameters: struct kvm_userspace_memory_region (in) 130062306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 130162306a36Sopenharmony_ci 130262306a36Sopenharmony_ci:: 130362306a36Sopenharmony_ci 130462306a36Sopenharmony_ci struct kvm_userspace_memory_region { 130562306a36Sopenharmony_ci __u32 slot; 130662306a36Sopenharmony_ci __u32 flags; 130762306a36Sopenharmony_ci __u64 guest_phys_addr; 130862306a36Sopenharmony_ci __u64 memory_size; /* bytes */ 130962306a36Sopenharmony_ci __u64 userspace_addr; /* start of the userspace allocated memory */ 131062306a36Sopenharmony_ci }; 131162306a36Sopenharmony_ci 131262306a36Sopenharmony_ci /* for kvm_userspace_memory_region::flags */ 131362306a36Sopenharmony_ci #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 131462306a36Sopenharmony_ci #define KVM_MEM_READONLY (1UL << 1) 131562306a36Sopenharmony_ci 131662306a36Sopenharmony_ciThis ioctl allows the user to create, modify or delete a guest physical 131762306a36Sopenharmony_cimemory slot. Bits 0-15 of "slot" specify the slot id and this value 131862306a36Sopenharmony_cishould be less than the maximum number of user memory slots supported per 131962306a36Sopenharmony_ciVM. The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS. 132062306a36Sopenharmony_ciSlots may not overlap in guest physical address space. 132162306a36Sopenharmony_ci 132262306a36Sopenharmony_ciIf KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot" 132362306a36Sopenharmony_cispecifies the address space which is being modified. They must be 132462306a36Sopenharmony_ciless than the value that KVM_CHECK_EXTENSION returns for the 132562306a36Sopenharmony_ciKVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces 132662306a36Sopenharmony_ciare unrelated; the restriction on overlapping slots only applies within 132762306a36Sopenharmony_cieach address space. 132862306a36Sopenharmony_ci 132962306a36Sopenharmony_ciDeleting a slot is done by passing zero for memory_size. When changing 133062306a36Sopenharmony_cian existing slot, it may be moved in the guest physical memory space, 133162306a36Sopenharmony_cior its flags may be modified, but it may not be resized. 133262306a36Sopenharmony_ci 133362306a36Sopenharmony_ciMemory for the region is taken starting at the address denoted by the 133462306a36Sopenharmony_cifield userspace_addr, which must point at user addressable memory for 133562306a36Sopenharmony_cithe entire memory slot size. Any object may back this memory, including 133662306a36Sopenharmony_cianonymous memory, ordinary files, and hugetlbfs. 133762306a36Sopenharmony_ci 133862306a36Sopenharmony_ciOn architectures that support a form of address tagging, userspace_addr must 133962306a36Sopenharmony_cibe an untagged address. 134062306a36Sopenharmony_ci 134162306a36Sopenharmony_ciIt is recommended that the lower 21 bits of guest_phys_addr and userspace_addr 134262306a36Sopenharmony_cibe identical. This allows large pages in the guest to be backed by large 134362306a36Sopenharmony_cipages in the host. 134462306a36Sopenharmony_ci 134562306a36Sopenharmony_ciThe flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and 134662306a36Sopenharmony_ciKVM_MEM_READONLY. The former can be set to instruct KVM to keep track of 134762306a36Sopenharmony_ciwrites to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to 134862306a36Sopenharmony_ciuse it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it, 134962306a36Sopenharmony_cito make a new slot read-only. In this case, writes to this memory will be 135062306a36Sopenharmony_ciposted to userspace as KVM_EXIT_MMIO exits. 135162306a36Sopenharmony_ci 135262306a36Sopenharmony_ciWhen the KVM_CAP_SYNC_MMU capability is available, changes in the backing of 135362306a36Sopenharmony_cithe memory region are automatically reflected into the guest. For example, an 135462306a36Sopenharmony_cimmap() that affects the region will be made visible immediately. Another 135562306a36Sopenharmony_ciexample is madvise(MADV_DROP). 135662306a36Sopenharmony_ci 135762306a36Sopenharmony_ciNote: On arm64, a write generated by the page-table walker (to update 135862306a36Sopenharmony_cithe Access and Dirty flags, for example) never results in a 135962306a36Sopenharmony_ciKVM_EXIT_MMIO exit when the slot has the KVM_MEM_READONLY flag. This 136062306a36Sopenharmony_ciis because KVM cannot provide the data that would be written by the 136162306a36Sopenharmony_cipage-table walker, making it impossible to emulate the access. 136262306a36Sopenharmony_ciInstead, an abort (data abort if the cause of the page-table update 136362306a36Sopenharmony_ciwas a load or a store, instruction abort if it was an instruction 136462306a36Sopenharmony_cifetch) is injected in the guest. 136562306a36Sopenharmony_ci 136662306a36Sopenharmony_ci4.36 KVM_SET_TSS_ADDR 136762306a36Sopenharmony_ci--------------------- 136862306a36Sopenharmony_ci 136962306a36Sopenharmony_ci:Capability: KVM_CAP_SET_TSS_ADDR 137062306a36Sopenharmony_ci:Architectures: x86 137162306a36Sopenharmony_ci:Type: vm ioctl 137262306a36Sopenharmony_ci:Parameters: unsigned long tss_address (in) 137362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 137462306a36Sopenharmony_ci 137562306a36Sopenharmony_ciThis ioctl defines the physical address of a three-page region in the guest 137662306a36Sopenharmony_ciphysical address space. The region must be within the first 4GB of the 137762306a36Sopenharmony_ciguest physical address space and must not conflict with any memory slot 137862306a36Sopenharmony_cior any mmio address. The guest may malfunction if it accesses this memory 137962306a36Sopenharmony_ciregion. 138062306a36Sopenharmony_ci 138162306a36Sopenharmony_ciThis ioctl is required on Intel-based hosts. This is needed on Intel hardware 138262306a36Sopenharmony_cibecause of a quirk in the virtualization implementation (see the internals 138362306a36Sopenharmony_cidocumentation when it pops into existence). 138462306a36Sopenharmony_ci 138562306a36Sopenharmony_ci 138662306a36Sopenharmony_ci4.37 KVM_ENABLE_CAP 138762306a36Sopenharmony_ci------------------- 138862306a36Sopenharmony_ci 138962306a36Sopenharmony_ci:Capability: KVM_CAP_ENABLE_CAP 139062306a36Sopenharmony_ci:Architectures: mips, ppc, s390, x86 139162306a36Sopenharmony_ci:Type: vcpu ioctl 139262306a36Sopenharmony_ci:Parameters: struct kvm_enable_cap (in) 139362306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 139462306a36Sopenharmony_ci 139562306a36Sopenharmony_ci:Capability: KVM_CAP_ENABLE_CAP_VM 139662306a36Sopenharmony_ci:Architectures: all 139762306a36Sopenharmony_ci:Type: vm ioctl 139862306a36Sopenharmony_ci:Parameters: struct kvm_enable_cap (in) 139962306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 140062306a36Sopenharmony_ci 140162306a36Sopenharmony_ci.. note:: 140262306a36Sopenharmony_ci 140362306a36Sopenharmony_ci Not all extensions are enabled by default. Using this ioctl the application 140462306a36Sopenharmony_ci can enable an extension, making it available to the guest. 140562306a36Sopenharmony_ci 140662306a36Sopenharmony_ciOn systems that do not support this ioctl, it always fails. On systems that 140762306a36Sopenharmony_cido support it, it only works for extensions that are supported for enablement. 140862306a36Sopenharmony_ci 140962306a36Sopenharmony_ciTo check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should 141062306a36Sopenharmony_cibe used. 141162306a36Sopenharmony_ci 141262306a36Sopenharmony_ci:: 141362306a36Sopenharmony_ci 141462306a36Sopenharmony_ci struct kvm_enable_cap { 141562306a36Sopenharmony_ci /* in */ 141662306a36Sopenharmony_ci __u32 cap; 141762306a36Sopenharmony_ci 141862306a36Sopenharmony_ciThe capability that is supposed to get enabled. 141962306a36Sopenharmony_ci 142062306a36Sopenharmony_ci:: 142162306a36Sopenharmony_ci 142262306a36Sopenharmony_ci __u32 flags; 142362306a36Sopenharmony_ci 142462306a36Sopenharmony_ciA bitfield indicating future enhancements. Has to be 0 for now. 142562306a36Sopenharmony_ci 142662306a36Sopenharmony_ci:: 142762306a36Sopenharmony_ci 142862306a36Sopenharmony_ci __u64 args[4]; 142962306a36Sopenharmony_ci 143062306a36Sopenharmony_ciArguments for enabling a feature. If a feature needs initial values to 143162306a36Sopenharmony_cifunction properly, this is the place to put them. 143262306a36Sopenharmony_ci 143362306a36Sopenharmony_ci:: 143462306a36Sopenharmony_ci 143562306a36Sopenharmony_ci __u8 pad[64]; 143662306a36Sopenharmony_ci }; 143762306a36Sopenharmony_ci 143862306a36Sopenharmony_ciThe vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl 143962306a36Sopenharmony_cifor vm-wide capabilities. 144062306a36Sopenharmony_ci 144162306a36Sopenharmony_ci4.38 KVM_GET_MP_STATE 144262306a36Sopenharmony_ci--------------------- 144362306a36Sopenharmony_ci 144462306a36Sopenharmony_ci:Capability: KVM_CAP_MP_STATE 144562306a36Sopenharmony_ci:Architectures: x86, s390, arm64, riscv 144662306a36Sopenharmony_ci:Type: vcpu ioctl 144762306a36Sopenharmony_ci:Parameters: struct kvm_mp_state (out) 144862306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 144962306a36Sopenharmony_ci 145062306a36Sopenharmony_ci:: 145162306a36Sopenharmony_ci 145262306a36Sopenharmony_ci struct kvm_mp_state { 145362306a36Sopenharmony_ci __u32 mp_state; 145462306a36Sopenharmony_ci }; 145562306a36Sopenharmony_ci 145662306a36Sopenharmony_ciReturns the vcpu's current "multiprocessing state" (though also valid on 145762306a36Sopenharmony_ciuniprocessor guests). 145862306a36Sopenharmony_ci 145962306a36Sopenharmony_ciPossible values are: 146062306a36Sopenharmony_ci 146162306a36Sopenharmony_ci ========================== =============================================== 146262306a36Sopenharmony_ci KVM_MP_STATE_RUNNABLE the vcpu is currently running 146362306a36Sopenharmony_ci [x86,arm64,riscv] 146462306a36Sopenharmony_ci KVM_MP_STATE_UNINITIALIZED the vcpu is an application processor (AP) 146562306a36Sopenharmony_ci which has not yet received an INIT signal [x86] 146662306a36Sopenharmony_ci KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, and is 146762306a36Sopenharmony_ci now ready for a SIPI [x86] 146862306a36Sopenharmony_ci KVM_MP_STATE_HALTED the vcpu has executed a HLT instruction and 146962306a36Sopenharmony_ci is waiting for an interrupt [x86] 147062306a36Sopenharmony_ci KVM_MP_STATE_SIPI_RECEIVED the vcpu has just received a SIPI (vector 147162306a36Sopenharmony_ci accessible via KVM_GET_VCPU_EVENTS) [x86] 147262306a36Sopenharmony_ci KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm64,riscv] 147362306a36Sopenharmony_ci KVM_MP_STATE_CHECK_STOP the vcpu is in a special error state [s390] 147462306a36Sopenharmony_ci KVM_MP_STATE_OPERATING the vcpu is operating (running or halted) 147562306a36Sopenharmony_ci [s390] 147662306a36Sopenharmony_ci KVM_MP_STATE_LOAD the vcpu is in a special load/startup state 147762306a36Sopenharmony_ci [s390] 147862306a36Sopenharmony_ci KVM_MP_STATE_SUSPENDED the vcpu is in a suspend state and is waiting 147962306a36Sopenharmony_ci for a wakeup event [arm64] 148062306a36Sopenharmony_ci ========================== =============================================== 148162306a36Sopenharmony_ci 148262306a36Sopenharmony_ciOn x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an 148362306a36Sopenharmony_ciin-kernel irqchip, the multiprocessing state must be maintained by userspace on 148462306a36Sopenharmony_cithese architectures. 148562306a36Sopenharmony_ci 148662306a36Sopenharmony_ciFor arm64: 148762306a36Sopenharmony_ci^^^^^^^^^^ 148862306a36Sopenharmony_ci 148962306a36Sopenharmony_ciIf a vCPU is in the KVM_MP_STATE_SUSPENDED state, KVM will emulate the 149062306a36Sopenharmony_ciarchitectural execution of a WFI instruction. 149162306a36Sopenharmony_ci 149262306a36Sopenharmony_ciIf a wakeup event is recognized, KVM will exit to userspace with a 149362306a36Sopenharmony_ciKVM_SYSTEM_EVENT exit, where the event type is KVM_SYSTEM_EVENT_WAKEUP. If 149462306a36Sopenharmony_ciuserspace wants to honor the wakeup, it must set the vCPU's MP state to 149562306a36Sopenharmony_ciKVM_MP_STATE_RUNNABLE. If it does not, KVM will continue to await a wakeup 149662306a36Sopenharmony_cievent in subsequent calls to KVM_RUN. 149762306a36Sopenharmony_ci 149862306a36Sopenharmony_ci.. warning:: 149962306a36Sopenharmony_ci 150062306a36Sopenharmony_ci If userspace intends to keep the vCPU in a SUSPENDED state, it is 150162306a36Sopenharmony_ci strongly recommended that userspace take action to suppress the 150262306a36Sopenharmony_ci wakeup event (such as masking an interrupt). Otherwise, subsequent 150362306a36Sopenharmony_ci calls to KVM_RUN will immediately exit with a KVM_SYSTEM_EVENT_WAKEUP 150462306a36Sopenharmony_ci event and inadvertently waste CPU cycles. 150562306a36Sopenharmony_ci 150662306a36Sopenharmony_ci Additionally, if userspace takes action to suppress a wakeup event, 150762306a36Sopenharmony_ci it is strongly recommended that it also restores the vCPU to its 150862306a36Sopenharmony_ci original state when the vCPU is made RUNNABLE again. For example, 150962306a36Sopenharmony_ci if userspace masked a pending interrupt to suppress the wakeup, 151062306a36Sopenharmony_ci the interrupt should be unmasked before returning control to the 151162306a36Sopenharmony_ci guest. 151262306a36Sopenharmony_ci 151362306a36Sopenharmony_ciFor riscv: 151462306a36Sopenharmony_ci^^^^^^^^^^ 151562306a36Sopenharmony_ci 151662306a36Sopenharmony_ciThe only states that are valid are KVM_MP_STATE_STOPPED and 151762306a36Sopenharmony_ciKVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not. 151862306a36Sopenharmony_ci 151962306a36Sopenharmony_ci4.39 KVM_SET_MP_STATE 152062306a36Sopenharmony_ci--------------------- 152162306a36Sopenharmony_ci 152262306a36Sopenharmony_ci:Capability: KVM_CAP_MP_STATE 152362306a36Sopenharmony_ci:Architectures: x86, s390, arm64, riscv 152462306a36Sopenharmony_ci:Type: vcpu ioctl 152562306a36Sopenharmony_ci:Parameters: struct kvm_mp_state (in) 152662306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 152762306a36Sopenharmony_ci 152862306a36Sopenharmony_ciSets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for 152962306a36Sopenharmony_ciarguments. 153062306a36Sopenharmony_ci 153162306a36Sopenharmony_ciOn x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an 153262306a36Sopenharmony_ciin-kernel irqchip, the multiprocessing state must be maintained by userspace on 153362306a36Sopenharmony_cithese architectures. 153462306a36Sopenharmony_ci 153562306a36Sopenharmony_ciFor arm64/riscv: 153662306a36Sopenharmony_ci^^^^^^^^^^^^^^^^ 153762306a36Sopenharmony_ci 153862306a36Sopenharmony_ciThe only states that are valid are KVM_MP_STATE_STOPPED and 153962306a36Sopenharmony_ciKVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not. 154062306a36Sopenharmony_ci 154162306a36Sopenharmony_ci4.40 KVM_SET_IDENTITY_MAP_ADDR 154262306a36Sopenharmony_ci------------------------------ 154362306a36Sopenharmony_ci 154462306a36Sopenharmony_ci:Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR 154562306a36Sopenharmony_ci:Architectures: x86 154662306a36Sopenharmony_ci:Type: vm ioctl 154762306a36Sopenharmony_ci:Parameters: unsigned long identity (in) 154862306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 154962306a36Sopenharmony_ci 155062306a36Sopenharmony_ciThis ioctl defines the physical address of a one-page region in the guest 155162306a36Sopenharmony_ciphysical address space. The region must be within the first 4GB of the 155262306a36Sopenharmony_ciguest physical address space and must not conflict with any memory slot 155362306a36Sopenharmony_cior any mmio address. The guest may malfunction if it accesses this memory 155462306a36Sopenharmony_ciregion. 155562306a36Sopenharmony_ci 155662306a36Sopenharmony_ciSetting the address to 0 will result in resetting the address to its default 155762306a36Sopenharmony_ci(0xfffbc000). 155862306a36Sopenharmony_ci 155962306a36Sopenharmony_ciThis ioctl is required on Intel-based hosts. This is needed on Intel hardware 156062306a36Sopenharmony_cibecause of a quirk in the virtualization implementation (see the internals 156162306a36Sopenharmony_cidocumentation when it pops into existence). 156262306a36Sopenharmony_ci 156362306a36Sopenharmony_ciFails if any VCPU has already been created. 156462306a36Sopenharmony_ci 156562306a36Sopenharmony_ci4.41 KVM_SET_BOOT_CPU_ID 156662306a36Sopenharmony_ci------------------------ 156762306a36Sopenharmony_ci 156862306a36Sopenharmony_ci:Capability: KVM_CAP_SET_BOOT_CPU_ID 156962306a36Sopenharmony_ci:Architectures: x86 157062306a36Sopenharmony_ci:Type: vm ioctl 157162306a36Sopenharmony_ci:Parameters: unsigned long vcpu_id 157262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 157362306a36Sopenharmony_ci 157462306a36Sopenharmony_ciDefine which vcpu is the Bootstrap Processor (BSP). Values are the same 157562306a36Sopenharmony_cias the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default 157662306a36Sopenharmony_ciis vcpu 0. This ioctl has to be called before vcpu creation, 157762306a36Sopenharmony_ciotherwise it will return EBUSY error. 157862306a36Sopenharmony_ci 157962306a36Sopenharmony_ci 158062306a36Sopenharmony_ci4.42 KVM_GET_XSAVE 158162306a36Sopenharmony_ci------------------ 158262306a36Sopenharmony_ci 158362306a36Sopenharmony_ci:Capability: KVM_CAP_XSAVE 158462306a36Sopenharmony_ci:Architectures: x86 158562306a36Sopenharmony_ci:Type: vcpu ioctl 158662306a36Sopenharmony_ci:Parameters: struct kvm_xsave (out) 158762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 158862306a36Sopenharmony_ci 158962306a36Sopenharmony_ci 159062306a36Sopenharmony_ci:: 159162306a36Sopenharmony_ci 159262306a36Sopenharmony_ci struct kvm_xsave { 159362306a36Sopenharmony_ci __u32 region[1024]; 159462306a36Sopenharmony_ci __u32 extra[0]; 159562306a36Sopenharmony_ci }; 159662306a36Sopenharmony_ci 159762306a36Sopenharmony_ciThis ioctl would copy current vcpu's xsave struct to the userspace. 159862306a36Sopenharmony_ci 159962306a36Sopenharmony_ci 160062306a36Sopenharmony_ci4.43 KVM_SET_XSAVE 160162306a36Sopenharmony_ci------------------ 160262306a36Sopenharmony_ci 160362306a36Sopenharmony_ci:Capability: KVM_CAP_XSAVE and KVM_CAP_XSAVE2 160462306a36Sopenharmony_ci:Architectures: x86 160562306a36Sopenharmony_ci:Type: vcpu ioctl 160662306a36Sopenharmony_ci:Parameters: struct kvm_xsave (in) 160762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 160862306a36Sopenharmony_ci 160962306a36Sopenharmony_ci:: 161062306a36Sopenharmony_ci 161162306a36Sopenharmony_ci 161262306a36Sopenharmony_ci struct kvm_xsave { 161362306a36Sopenharmony_ci __u32 region[1024]; 161462306a36Sopenharmony_ci __u32 extra[0]; 161562306a36Sopenharmony_ci }; 161662306a36Sopenharmony_ci 161762306a36Sopenharmony_ciThis ioctl would copy userspace's xsave struct to the kernel. It copies 161862306a36Sopenharmony_cias many bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2), 161962306a36Sopenharmony_ciwhen invoked on the vm file descriptor. The size value returned by 162062306a36Sopenharmony_ciKVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will always be at least 4096. 162162306a36Sopenharmony_ciCurrently, it is only greater than 4096 if a dynamic feature has been 162262306a36Sopenharmony_cienabled with ``arch_prctl()``, but this may change in the future. 162362306a36Sopenharmony_ci 162462306a36Sopenharmony_ciThe offsets of the state save areas in struct kvm_xsave follow the 162562306a36Sopenharmony_cicontents of CPUID leaf 0xD on the host. 162662306a36Sopenharmony_ci 162762306a36Sopenharmony_ci 162862306a36Sopenharmony_ci4.44 KVM_GET_XCRS 162962306a36Sopenharmony_ci----------------- 163062306a36Sopenharmony_ci 163162306a36Sopenharmony_ci:Capability: KVM_CAP_XCRS 163262306a36Sopenharmony_ci:Architectures: x86 163362306a36Sopenharmony_ci:Type: vcpu ioctl 163462306a36Sopenharmony_ci:Parameters: struct kvm_xcrs (out) 163562306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 163662306a36Sopenharmony_ci 163762306a36Sopenharmony_ci:: 163862306a36Sopenharmony_ci 163962306a36Sopenharmony_ci struct kvm_xcr { 164062306a36Sopenharmony_ci __u32 xcr; 164162306a36Sopenharmony_ci __u32 reserved; 164262306a36Sopenharmony_ci __u64 value; 164362306a36Sopenharmony_ci }; 164462306a36Sopenharmony_ci 164562306a36Sopenharmony_ci struct kvm_xcrs { 164662306a36Sopenharmony_ci __u32 nr_xcrs; 164762306a36Sopenharmony_ci __u32 flags; 164862306a36Sopenharmony_ci struct kvm_xcr xcrs[KVM_MAX_XCRS]; 164962306a36Sopenharmony_ci __u64 padding[16]; 165062306a36Sopenharmony_ci }; 165162306a36Sopenharmony_ci 165262306a36Sopenharmony_ciThis ioctl would copy current vcpu's xcrs to the userspace. 165362306a36Sopenharmony_ci 165462306a36Sopenharmony_ci 165562306a36Sopenharmony_ci4.45 KVM_SET_XCRS 165662306a36Sopenharmony_ci----------------- 165762306a36Sopenharmony_ci 165862306a36Sopenharmony_ci:Capability: KVM_CAP_XCRS 165962306a36Sopenharmony_ci:Architectures: x86 166062306a36Sopenharmony_ci:Type: vcpu ioctl 166162306a36Sopenharmony_ci:Parameters: struct kvm_xcrs (in) 166262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 166362306a36Sopenharmony_ci 166462306a36Sopenharmony_ci:: 166562306a36Sopenharmony_ci 166662306a36Sopenharmony_ci struct kvm_xcr { 166762306a36Sopenharmony_ci __u32 xcr; 166862306a36Sopenharmony_ci __u32 reserved; 166962306a36Sopenharmony_ci __u64 value; 167062306a36Sopenharmony_ci }; 167162306a36Sopenharmony_ci 167262306a36Sopenharmony_ci struct kvm_xcrs { 167362306a36Sopenharmony_ci __u32 nr_xcrs; 167462306a36Sopenharmony_ci __u32 flags; 167562306a36Sopenharmony_ci struct kvm_xcr xcrs[KVM_MAX_XCRS]; 167662306a36Sopenharmony_ci __u64 padding[16]; 167762306a36Sopenharmony_ci }; 167862306a36Sopenharmony_ci 167962306a36Sopenharmony_ciThis ioctl would set vcpu's xcr to the value userspace specified. 168062306a36Sopenharmony_ci 168162306a36Sopenharmony_ci 168262306a36Sopenharmony_ci4.46 KVM_GET_SUPPORTED_CPUID 168362306a36Sopenharmony_ci---------------------------- 168462306a36Sopenharmony_ci 168562306a36Sopenharmony_ci:Capability: KVM_CAP_EXT_CPUID 168662306a36Sopenharmony_ci:Architectures: x86 168762306a36Sopenharmony_ci:Type: system ioctl 168862306a36Sopenharmony_ci:Parameters: struct kvm_cpuid2 (in/out) 168962306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 169062306a36Sopenharmony_ci 169162306a36Sopenharmony_ci:: 169262306a36Sopenharmony_ci 169362306a36Sopenharmony_ci struct kvm_cpuid2 { 169462306a36Sopenharmony_ci __u32 nent; 169562306a36Sopenharmony_ci __u32 padding; 169662306a36Sopenharmony_ci struct kvm_cpuid_entry2 entries[0]; 169762306a36Sopenharmony_ci }; 169862306a36Sopenharmony_ci 169962306a36Sopenharmony_ci #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) 170062306a36Sopenharmony_ci #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */ 170162306a36Sopenharmony_ci #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */ 170262306a36Sopenharmony_ci 170362306a36Sopenharmony_ci struct kvm_cpuid_entry2 { 170462306a36Sopenharmony_ci __u32 function; 170562306a36Sopenharmony_ci __u32 index; 170662306a36Sopenharmony_ci __u32 flags; 170762306a36Sopenharmony_ci __u32 eax; 170862306a36Sopenharmony_ci __u32 ebx; 170962306a36Sopenharmony_ci __u32 ecx; 171062306a36Sopenharmony_ci __u32 edx; 171162306a36Sopenharmony_ci __u32 padding[3]; 171262306a36Sopenharmony_ci }; 171362306a36Sopenharmony_ci 171462306a36Sopenharmony_ciThis ioctl returns x86 cpuid features which are supported by both the 171562306a36Sopenharmony_cihardware and kvm in its default configuration. Userspace can use the 171662306a36Sopenharmony_ciinformation returned by this ioctl to construct cpuid information (for 171762306a36Sopenharmony_ciKVM_SET_CPUID2) that is consistent with hardware, kernel, and 171862306a36Sopenharmony_ciuserspace capabilities, and with user requirements (for example, the 171962306a36Sopenharmony_ciuser may wish to constrain cpuid to emulate older hardware, or for 172062306a36Sopenharmony_cifeature consistency across a cluster). 172162306a36Sopenharmony_ci 172262306a36Sopenharmony_ciDynamically-enabled feature bits need to be requested with 172362306a36Sopenharmony_ci``arch_prctl()`` before calling this ioctl. Feature bits that have not 172462306a36Sopenharmony_cibeen requested are excluded from the result. 172562306a36Sopenharmony_ci 172662306a36Sopenharmony_ciNote that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may 172762306a36Sopenharmony_ciexpose cpuid features (e.g. MONITOR) which are not supported by kvm in 172862306a36Sopenharmony_ciits default configuration. If userspace enables such capabilities, it 172962306a36Sopenharmony_ciis responsible for modifying the results of this ioctl appropriately. 173062306a36Sopenharmony_ci 173162306a36Sopenharmony_ciUserspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure 173262306a36Sopenharmony_ciwith the 'nent' field indicating the number of entries in the variable-size 173362306a36Sopenharmony_ciarray 'entries'. If the number of entries is too low to describe the cpu 173462306a36Sopenharmony_cicapabilities, an error (E2BIG) is returned. If the number is too high, 173562306a36Sopenharmony_cithe 'nent' field is adjusted and an error (ENOMEM) is returned. If the 173662306a36Sopenharmony_cinumber is just right, the 'nent' field is adjusted to the number of valid 173762306a36Sopenharmony_cientries in the 'entries' array, which is then filled. 173862306a36Sopenharmony_ci 173962306a36Sopenharmony_ciThe entries returned are the host cpuid as returned by the cpuid instruction, 174062306a36Sopenharmony_ciwith unknown or unsupported features masked out. Some features (for example, 174162306a36Sopenharmony_cix2apic), may not be present in the host cpu, but are exposed by kvm if it can 174262306a36Sopenharmony_ciemulate them efficiently. The fields in each entry are defined as follows: 174362306a36Sopenharmony_ci 174462306a36Sopenharmony_ci function: 174562306a36Sopenharmony_ci the eax value used to obtain the entry 174662306a36Sopenharmony_ci 174762306a36Sopenharmony_ci index: 174862306a36Sopenharmony_ci the ecx value used to obtain the entry (for entries that are 174962306a36Sopenharmony_ci affected by ecx) 175062306a36Sopenharmony_ci 175162306a36Sopenharmony_ci flags: 175262306a36Sopenharmony_ci an OR of zero or more of the following: 175362306a36Sopenharmony_ci 175462306a36Sopenharmony_ci KVM_CPUID_FLAG_SIGNIFCANT_INDEX: 175562306a36Sopenharmony_ci if the index field is valid 175662306a36Sopenharmony_ci 175762306a36Sopenharmony_ci eax, ebx, ecx, edx: 175862306a36Sopenharmony_ci the values returned by the cpuid instruction for 175962306a36Sopenharmony_ci this function/index combination 176062306a36Sopenharmony_ci 176162306a36Sopenharmony_ciThe TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned 176262306a36Sopenharmony_cias false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC 176362306a36Sopenharmony_cisupport. Instead it is reported via:: 176462306a36Sopenharmony_ci 176562306a36Sopenharmony_ci ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) 176662306a36Sopenharmony_ci 176762306a36Sopenharmony_ciif that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the 176862306a36Sopenharmony_cifeature in userspace, then you can enable the feature for KVM_SET_CPUID2. 176962306a36Sopenharmony_ci 177062306a36Sopenharmony_ci 177162306a36Sopenharmony_ci4.47 KVM_PPC_GET_PVINFO 177262306a36Sopenharmony_ci----------------------- 177362306a36Sopenharmony_ci 177462306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_GET_PVINFO 177562306a36Sopenharmony_ci:Architectures: ppc 177662306a36Sopenharmony_ci:Type: vm ioctl 177762306a36Sopenharmony_ci:Parameters: struct kvm_ppc_pvinfo (out) 177862306a36Sopenharmony_ci:Returns: 0 on success, !0 on error 177962306a36Sopenharmony_ci 178062306a36Sopenharmony_ci:: 178162306a36Sopenharmony_ci 178262306a36Sopenharmony_ci struct kvm_ppc_pvinfo { 178362306a36Sopenharmony_ci __u32 flags; 178462306a36Sopenharmony_ci __u32 hcall[4]; 178562306a36Sopenharmony_ci __u8 pad[108]; 178662306a36Sopenharmony_ci }; 178762306a36Sopenharmony_ci 178862306a36Sopenharmony_ciThis ioctl fetches PV specific information that need to be passed to the guest 178962306a36Sopenharmony_ciusing the device tree or other means from vm context. 179062306a36Sopenharmony_ci 179162306a36Sopenharmony_ciThe hcall array defines 4 instructions that make up a hypercall. 179262306a36Sopenharmony_ci 179362306a36Sopenharmony_ciIf any additional field gets added to this structure later on, a bit for that 179462306a36Sopenharmony_ciadditional piece of information will be set in the flags bitmap. 179562306a36Sopenharmony_ci 179662306a36Sopenharmony_ciThe flags bitmap is defined as:: 179762306a36Sopenharmony_ci 179862306a36Sopenharmony_ci /* the host supports the ePAPR idle hcall 179962306a36Sopenharmony_ci #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 180062306a36Sopenharmony_ci 180162306a36Sopenharmony_ci4.52 KVM_SET_GSI_ROUTING 180262306a36Sopenharmony_ci------------------------ 180362306a36Sopenharmony_ci 180462306a36Sopenharmony_ci:Capability: KVM_CAP_IRQ_ROUTING 180562306a36Sopenharmony_ci:Architectures: x86 s390 arm64 180662306a36Sopenharmony_ci:Type: vm ioctl 180762306a36Sopenharmony_ci:Parameters: struct kvm_irq_routing (in) 180862306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 180962306a36Sopenharmony_ci 181062306a36Sopenharmony_ciSets the GSI routing table entries, overwriting any previously set entries. 181162306a36Sopenharmony_ci 181262306a36Sopenharmony_ciOn arm64, GSI routing has the following limitation: 181362306a36Sopenharmony_ci 181462306a36Sopenharmony_ci- GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD. 181562306a36Sopenharmony_ci 181662306a36Sopenharmony_ci:: 181762306a36Sopenharmony_ci 181862306a36Sopenharmony_ci struct kvm_irq_routing { 181962306a36Sopenharmony_ci __u32 nr; 182062306a36Sopenharmony_ci __u32 flags; 182162306a36Sopenharmony_ci struct kvm_irq_routing_entry entries[0]; 182262306a36Sopenharmony_ci }; 182362306a36Sopenharmony_ci 182462306a36Sopenharmony_ciNo flags are specified so far, the corresponding field must be set to zero. 182562306a36Sopenharmony_ci 182662306a36Sopenharmony_ci:: 182762306a36Sopenharmony_ci 182862306a36Sopenharmony_ci struct kvm_irq_routing_entry { 182962306a36Sopenharmony_ci __u32 gsi; 183062306a36Sopenharmony_ci __u32 type; 183162306a36Sopenharmony_ci __u32 flags; 183262306a36Sopenharmony_ci __u32 pad; 183362306a36Sopenharmony_ci union { 183462306a36Sopenharmony_ci struct kvm_irq_routing_irqchip irqchip; 183562306a36Sopenharmony_ci struct kvm_irq_routing_msi msi; 183662306a36Sopenharmony_ci struct kvm_irq_routing_s390_adapter adapter; 183762306a36Sopenharmony_ci struct kvm_irq_routing_hv_sint hv_sint; 183862306a36Sopenharmony_ci struct kvm_irq_routing_xen_evtchn xen_evtchn; 183962306a36Sopenharmony_ci __u32 pad[8]; 184062306a36Sopenharmony_ci } u; 184162306a36Sopenharmony_ci }; 184262306a36Sopenharmony_ci 184362306a36Sopenharmony_ci /* gsi routing entry types */ 184462306a36Sopenharmony_ci #define KVM_IRQ_ROUTING_IRQCHIP 1 184562306a36Sopenharmony_ci #define KVM_IRQ_ROUTING_MSI 2 184662306a36Sopenharmony_ci #define KVM_IRQ_ROUTING_S390_ADAPTER 3 184762306a36Sopenharmony_ci #define KVM_IRQ_ROUTING_HV_SINT 4 184862306a36Sopenharmony_ci #define KVM_IRQ_ROUTING_XEN_EVTCHN 5 184962306a36Sopenharmony_ci 185062306a36Sopenharmony_ciflags: 185162306a36Sopenharmony_ci 185262306a36Sopenharmony_ci- KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry 185362306a36Sopenharmony_ci type, specifies that the devid field contains a valid value. The per-VM 185462306a36Sopenharmony_ci KVM_CAP_MSI_DEVID capability advertises the requirement to provide 185562306a36Sopenharmony_ci the device ID. If this capability is not available, userspace should 185662306a36Sopenharmony_ci never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. 185762306a36Sopenharmony_ci- zero otherwise 185862306a36Sopenharmony_ci 185962306a36Sopenharmony_ci:: 186062306a36Sopenharmony_ci 186162306a36Sopenharmony_ci struct kvm_irq_routing_irqchip { 186262306a36Sopenharmony_ci __u32 irqchip; 186362306a36Sopenharmony_ci __u32 pin; 186462306a36Sopenharmony_ci }; 186562306a36Sopenharmony_ci 186662306a36Sopenharmony_ci struct kvm_irq_routing_msi { 186762306a36Sopenharmony_ci __u32 address_lo; 186862306a36Sopenharmony_ci __u32 address_hi; 186962306a36Sopenharmony_ci __u32 data; 187062306a36Sopenharmony_ci union { 187162306a36Sopenharmony_ci __u32 pad; 187262306a36Sopenharmony_ci __u32 devid; 187362306a36Sopenharmony_ci }; 187462306a36Sopenharmony_ci }; 187562306a36Sopenharmony_ci 187662306a36Sopenharmony_ciIf KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier 187762306a36Sopenharmony_cifor the device that wrote the MSI message. For PCI, this is usually a 187862306a36Sopenharmony_ciBFD identifier in the lower 16 bits. 187962306a36Sopenharmony_ci 188062306a36Sopenharmony_ciOn x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS 188162306a36Sopenharmony_cifeature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, 188262306a36Sopenharmony_ciaddress_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of 188362306a36Sopenharmony_ciaddress_hi must be zero. 188462306a36Sopenharmony_ci 188562306a36Sopenharmony_ci:: 188662306a36Sopenharmony_ci 188762306a36Sopenharmony_ci struct kvm_irq_routing_s390_adapter { 188862306a36Sopenharmony_ci __u64 ind_addr; 188962306a36Sopenharmony_ci __u64 summary_addr; 189062306a36Sopenharmony_ci __u64 ind_offset; 189162306a36Sopenharmony_ci __u32 summary_offset; 189262306a36Sopenharmony_ci __u32 adapter_id; 189362306a36Sopenharmony_ci }; 189462306a36Sopenharmony_ci 189562306a36Sopenharmony_ci struct kvm_irq_routing_hv_sint { 189662306a36Sopenharmony_ci __u32 vcpu; 189762306a36Sopenharmony_ci __u32 sint; 189862306a36Sopenharmony_ci }; 189962306a36Sopenharmony_ci 190062306a36Sopenharmony_ci struct kvm_irq_routing_xen_evtchn { 190162306a36Sopenharmony_ci __u32 port; 190262306a36Sopenharmony_ci __u32 vcpu; 190362306a36Sopenharmony_ci __u32 priority; 190462306a36Sopenharmony_ci }; 190562306a36Sopenharmony_ci 190662306a36Sopenharmony_ci 190762306a36Sopenharmony_ciWhen KVM_CAP_XEN_HVM includes the KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL bit 190862306a36Sopenharmony_ciin its indication of supported features, routing to Xen event channels 190962306a36Sopenharmony_ciis supported. Although the priority field is present, only the value 191062306a36Sopenharmony_ciKVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL is supported, which means delivery by 191162306a36Sopenharmony_ci2 level event channels. FIFO event channel support may be added in 191262306a36Sopenharmony_cithe future. 191362306a36Sopenharmony_ci 191462306a36Sopenharmony_ci 191562306a36Sopenharmony_ci4.55 KVM_SET_TSC_KHZ 191662306a36Sopenharmony_ci-------------------- 191762306a36Sopenharmony_ci 191862306a36Sopenharmony_ci:Capability: KVM_CAP_TSC_CONTROL / KVM_CAP_VM_TSC_CONTROL 191962306a36Sopenharmony_ci:Architectures: x86 192062306a36Sopenharmony_ci:Type: vcpu ioctl / vm ioctl 192162306a36Sopenharmony_ci:Parameters: virtual tsc_khz 192262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 192362306a36Sopenharmony_ci 192462306a36Sopenharmony_ciSpecifies the tsc frequency for the virtual machine. The unit of the 192562306a36Sopenharmony_cifrequency is KHz. 192662306a36Sopenharmony_ci 192762306a36Sopenharmony_ciIf the KVM_CAP_VM_TSC_CONTROL capability is advertised, this can also 192862306a36Sopenharmony_cibe used as a vm ioctl to set the initial tsc frequency of subsequently 192962306a36Sopenharmony_cicreated vCPUs. 193062306a36Sopenharmony_ci 193162306a36Sopenharmony_ci4.56 KVM_GET_TSC_KHZ 193262306a36Sopenharmony_ci-------------------- 193362306a36Sopenharmony_ci 193462306a36Sopenharmony_ci:Capability: KVM_CAP_GET_TSC_KHZ / KVM_CAP_VM_TSC_CONTROL 193562306a36Sopenharmony_ci:Architectures: x86 193662306a36Sopenharmony_ci:Type: vcpu ioctl / vm ioctl 193762306a36Sopenharmony_ci:Parameters: none 193862306a36Sopenharmony_ci:Returns: virtual tsc-khz on success, negative value on error 193962306a36Sopenharmony_ci 194062306a36Sopenharmony_ciReturns the tsc frequency of the guest. The unit of the return value is 194162306a36Sopenharmony_ciKHz. If the host has unstable tsc this ioctl returns -EIO instead as an 194262306a36Sopenharmony_cierror. 194362306a36Sopenharmony_ci 194462306a36Sopenharmony_ci 194562306a36Sopenharmony_ci4.57 KVM_GET_LAPIC 194662306a36Sopenharmony_ci------------------ 194762306a36Sopenharmony_ci 194862306a36Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 194962306a36Sopenharmony_ci:Architectures: x86 195062306a36Sopenharmony_ci:Type: vcpu ioctl 195162306a36Sopenharmony_ci:Parameters: struct kvm_lapic_state (out) 195262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 195362306a36Sopenharmony_ci 195462306a36Sopenharmony_ci:: 195562306a36Sopenharmony_ci 195662306a36Sopenharmony_ci #define KVM_APIC_REG_SIZE 0x400 195762306a36Sopenharmony_ci struct kvm_lapic_state { 195862306a36Sopenharmony_ci char regs[KVM_APIC_REG_SIZE]; 195962306a36Sopenharmony_ci }; 196062306a36Sopenharmony_ci 196162306a36Sopenharmony_ciReads the Local APIC registers and copies them into the input argument. The 196262306a36Sopenharmony_cidata format and layout are the same as documented in the architecture manual. 196362306a36Sopenharmony_ci 196462306a36Sopenharmony_ciIf KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is 196562306a36Sopenharmony_cienabled, then the format of APIC_ID register depends on the APIC mode 196662306a36Sopenharmony_ci(reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in 196762306a36Sopenharmony_cithe APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID 196862306a36Sopenharmony_ciwhich is stored in bits 31-24 of the APIC register, or equivalently in 196962306a36Sopenharmony_cibyte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then 197062306a36Sopenharmony_cibe called after MSR_IA32_APICBASE has been set with KVM_SET_MSR. 197162306a36Sopenharmony_ci 197262306a36Sopenharmony_ciIf KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state 197362306a36Sopenharmony_cialways uses xAPIC format. 197462306a36Sopenharmony_ci 197562306a36Sopenharmony_ci 197662306a36Sopenharmony_ci4.58 KVM_SET_LAPIC 197762306a36Sopenharmony_ci------------------ 197862306a36Sopenharmony_ci 197962306a36Sopenharmony_ci:Capability: KVM_CAP_IRQCHIP 198062306a36Sopenharmony_ci:Architectures: x86 198162306a36Sopenharmony_ci:Type: vcpu ioctl 198262306a36Sopenharmony_ci:Parameters: struct kvm_lapic_state (in) 198362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 198462306a36Sopenharmony_ci 198562306a36Sopenharmony_ci:: 198662306a36Sopenharmony_ci 198762306a36Sopenharmony_ci #define KVM_APIC_REG_SIZE 0x400 198862306a36Sopenharmony_ci struct kvm_lapic_state { 198962306a36Sopenharmony_ci char regs[KVM_APIC_REG_SIZE]; 199062306a36Sopenharmony_ci }; 199162306a36Sopenharmony_ci 199262306a36Sopenharmony_ciCopies the input argument into the Local APIC registers. The data format 199362306a36Sopenharmony_ciand layout are the same as documented in the architecture manual. 199462306a36Sopenharmony_ci 199562306a36Sopenharmony_ciThe format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's 199662306a36Sopenharmony_ciregs field) depends on the state of the KVM_CAP_X2APIC_API capability. 199762306a36Sopenharmony_ciSee the note in KVM_GET_LAPIC. 199862306a36Sopenharmony_ci 199962306a36Sopenharmony_ci 200062306a36Sopenharmony_ci4.59 KVM_IOEVENTFD 200162306a36Sopenharmony_ci------------------ 200262306a36Sopenharmony_ci 200362306a36Sopenharmony_ci:Capability: KVM_CAP_IOEVENTFD 200462306a36Sopenharmony_ci:Architectures: all 200562306a36Sopenharmony_ci:Type: vm ioctl 200662306a36Sopenharmony_ci:Parameters: struct kvm_ioeventfd (in) 200762306a36Sopenharmony_ci:Returns: 0 on success, !0 on error 200862306a36Sopenharmony_ci 200962306a36Sopenharmony_ciThis ioctl attaches or detaches an ioeventfd to a legal pio/mmio address 201062306a36Sopenharmony_ciwithin the guest. A guest write in the registered address will signal the 201162306a36Sopenharmony_ciprovided event instead of triggering an exit. 201262306a36Sopenharmony_ci 201362306a36Sopenharmony_ci:: 201462306a36Sopenharmony_ci 201562306a36Sopenharmony_ci struct kvm_ioeventfd { 201662306a36Sopenharmony_ci __u64 datamatch; 201762306a36Sopenharmony_ci __u64 addr; /* legal pio/mmio address */ 201862306a36Sopenharmony_ci __u32 len; /* 0, 1, 2, 4, or 8 bytes */ 201962306a36Sopenharmony_ci __s32 fd; 202062306a36Sopenharmony_ci __u32 flags; 202162306a36Sopenharmony_ci __u8 pad[36]; 202262306a36Sopenharmony_ci }; 202362306a36Sopenharmony_ci 202462306a36Sopenharmony_ciFor the special case of virtio-ccw devices on s390, the ioevent is matched 202562306a36Sopenharmony_cito a subchannel/virtqueue tuple instead. 202662306a36Sopenharmony_ci 202762306a36Sopenharmony_ciThe following flags are defined:: 202862306a36Sopenharmony_ci 202962306a36Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 203062306a36Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 203162306a36Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 203262306a36Sopenharmony_ci #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 203362306a36Sopenharmony_ci (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 203462306a36Sopenharmony_ci 203562306a36Sopenharmony_ciIf datamatch flag is set, the event will be signaled only if the written value 203662306a36Sopenharmony_cito the registered address is equal to datamatch in struct kvm_ioeventfd. 203762306a36Sopenharmony_ci 203862306a36Sopenharmony_ciFor virtio-ccw devices, addr contains the subchannel id and datamatch the 203962306a36Sopenharmony_civirtqueue index. 204062306a36Sopenharmony_ci 204162306a36Sopenharmony_ciWith KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and 204262306a36Sopenharmony_cithe kernel will ignore the length of guest write and may get a faster vmexit. 204362306a36Sopenharmony_ciThe speedup may only apply to specific architectures, but the ioeventfd will 204462306a36Sopenharmony_ciwork anyway. 204562306a36Sopenharmony_ci 204662306a36Sopenharmony_ci4.60 KVM_DIRTY_TLB 204762306a36Sopenharmony_ci------------------ 204862306a36Sopenharmony_ci 204962306a36Sopenharmony_ci:Capability: KVM_CAP_SW_TLB 205062306a36Sopenharmony_ci:Architectures: ppc 205162306a36Sopenharmony_ci:Type: vcpu ioctl 205262306a36Sopenharmony_ci:Parameters: struct kvm_dirty_tlb (in) 205362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 205462306a36Sopenharmony_ci 205562306a36Sopenharmony_ci:: 205662306a36Sopenharmony_ci 205762306a36Sopenharmony_ci struct kvm_dirty_tlb { 205862306a36Sopenharmony_ci __u64 bitmap; 205962306a36Sopenharmony_ci __u32 num_dirty; 206062306a36Sopenharmony_ci }; 206162306a36Sopenharmony_ci 206262306a36Sopenharmony_ciThis must be called whenever userspace has changed an entry in the shared 206362306a36Sopenharmony_ciTLB, prior to calling KVM_RUN on the associated vcpu. 206462306a36Sopenharmony_ci 206562306a36Sopenharmony_ciThe "bitmap" field is the userspace address of an array. This array 206662306a36Sopenharmony_ciconsists of a number of bits, equal to the total number of TLB entries as 206762306a36Sopenharmony_cidetermined by the last successful call to KVM_CONFIG_TLB, rounded up to the 206862306a36Sopenharmony_cinearest multiple of 64. 206962306a36Sopenharmony_ci 207062306a36Sopenharmony_ciEach bit corresponds to one TLB entry, ordered the same as in the shared TLB 207162306a36Sopenharmony_ciarray. 207262306a36Sopenharmony_ci 207362306a36Sopenharmony_ciThe array is little-endian: the bit 0 is the least significant bit of the 207462306a36Sopenharmony_cifirst byte, bit 8 is the least significant bit of the second byte, etc. 207562306a36Sopenharmony_ciThis avoids any complications with differing word sizes. 207662306a36Sopenharmony_ci 207762306a36Sopenharmony_ciThe "num_dirty" field is a performance hint for KVM to determine whether it 207862306a36Sopenharmony_cishould skip processing the bitmap and just invalidate everything. It must 207962306a36Sopenharmony_cibe set to the number of set bits in the bitmap. 208062306a36Sopenharmony_ci 208162306a36Sopenharmony_ci 208262306a36Sopenharmony_ci4.62 KVM_CREATE_SPAPR_TCE 208362306a36Sopenharmony_ci------------------------- 208462306a36Sopenharmony_ci 208562306a36Sopenharmony_ci:Capability: KVM_CAP_SPAPR_TCE 208662306a36Sopenharmony_ci:Architectures: powerpc 208762306a36Sopenharmony_ci:Type: vm ioctl 208862306a36Sopenharmony_ci:Parameters: struct kvm_create_spapr_tce (in) 208962306a36Sopenharmony_ci:Returns: file descriptor for manipulating the created TCE table 209062306a36Sopenharmony_ci 209162306a36Sopenharmony_ciThis creates a virtual TCE (translation control entry) table, which 209262306a36Sopenharmony_ciis an IOMMU for PAPR-style virtual I/O. It is used to translate 209362306a36Sopenharmony_cilogical addresses used in virtual I/O into guest physical addresses, 209462306a36Sopenharmony_ciand provides a scatter/gather capability for PAPR virtual I/O. 209562306a36Sopenharmony_ci 209662306a36Sopenharmony_ci:: 209762306a36Sopenharmony_ci 209862306a36Sopenharmony_ci /* for KVM_CAP_SPAPR_TCE */ 209962306a36Sopenharmony_ci struct kvm_create_spapr_tce { 210062306a36Sopenharmony_ci __u64 liobn; 210162306a36Sopenharmony_ci __u32 window_size; 210262306a36Sopenharmony_ci }; 210362306a36Sopenharmony_ci 210462306a36Sopenharmony_ciThe liobn field gives the logical IO bus number for which to create a 210562306a36Sopenharmony_ciTCE table. The window_size field specifies the size of the DMA window 210662306a36Sopenharmony_ciwhich this TCE table will translate - the table will contain one 64 210762306a36Sopenharmony_cibit TCE entry for every 4kiB of the DMA window. 210862306a36Sopenharmony_ci 210962306a36Sopenharmony_ciWhen the guest issues an H_PUT_TCE hcall on a liobn for which a TCE 211062306a36Sopenharmony_citable has been created using this ioctl(), the kernel will handle it 211162306a36Sopenharmony_ciin real mode, updating the TCE table. H_PUT_TCE calls for other 211262306a36Sopenharmony_ciliobns will cause a vm exit and must be handled by userspace. 211362306a36Sopenharmony_ci 211462306a36Sopenharmony_ciThe return value is a file descriptor which can be passed to mmap(2) 211562306a36Sopenharmony_cito map the created TCE table into userspace. This lets userspace read 211662306a36Sopenharmony_cithe entries written by kernel-handled H_PUT_TCE calls, and also lets 211762306a36Sopenharmony_ciuserspace update the TCE table directly which is useful in some 211862306a36Sopenharmony_cicircumstances. 211962306a36Sopenharmony_ci 212062306a36Sopenharmony_ci 212162306a36Sopenharmony_ci4.63 KVM_ALLOCATE_RMA 212262306a36Sopenharmony_ci--------------------- 212362306a36Sopenharmony_ci 212462306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_RMA 212562306a36Sopenharmony_ci:Architectures: powerpc 212662306a36Sopenharmony_ci:Type: vm ioctl 212762306a36Sopenharmony_ci:Parameters: struct kvm_allocate_rma (out) 212862306a36Sopenharmony_ci:Returns: file descriptor for mapping the allocated RMA 212962306a36Sopenharmony_ci 213062306a36Sopenharmony_ciThis allocates a Real Mode Area (RMA) from the pool allocated at boot 213162306a36Sopenharmony_citime by the kernel. An RMA is a physically-contiguous, aligned region 213262306a36Sopenharmony_ciof memory used on older POWER processors to provide the memory which 213362306a36Sopenharmony_ciwill be accessed by real-mode (MMU off) accesses in a KVM guest. 213462306a36Sopenharmony_ciPOWER processors support a set of sizes for the RMA that usually 213562306a36Sopenharmony_ciincludes 64MB, 128MB, 256MB and some larger powers of two. 213662306a36Sopenharmony_ci 213762306a36Sopenharmony_ci:: 213862306a36Sopenharmony_ci 213962306a36Sopenharmony_ci /* for KVM_ALLOCATE_RMA */ 214062306a36Sopenharmony_ci struct kvm_allocate_rma { 214162306a36Sopenharmony_ci __u64 rma_size; 214262306a36Sopenharmony_ci }; 214362306a36Sopenharmony_ci 214462306a36Sopenharmony_ciThe return value is a file descriptor which can be passed to mmap(2) 214562306a36Sopenharmony_cito map the allocated RMA into userspace. The mapped area can then be 214662306a36Sopenharmony_cipassed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the 214762306a36Sopenharmony_ciRMA for a virtual machine. The size of the RMA in bytes (which is 214862306a36Sopenharmony_cifixed at host kernel boot time) is returned in the rma_size field of 214962306a36Sopenharmony_cithe argument structure. 215062306a36Sopenharmony_ci 215162306a36Sopenharmony_ciThe KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl 215262306a36Sopenharmony_ciis supported; 2 if the processor requires all virtual machines to have 215362306a36Sopenharmony_cian RMA, or 1 if the processor can use an RMA but doesn't require it, 215462306a36Sopenharmony_cibecause it supports the Virtual RMA (VRMA) facility. 215562306a36Sopenharmony_ci 215662306a36Sopenharmony_ci 215762306a36Sopenharmony_ci4.64 KVM_NMI 215862306a36Sopenharmony_ci------------ 215962306a36Sopenharmony_ci 216062306a36Sopenharmony_ci:Capability: KVM_CAP_USER_NMI 216162306a36Sopenharmony_ci:Architectures: x86 216262306a36Sopenharmony_ci:Type: vcpu ioctl 216362306a36Sopenharmony_ci:Parameters: none 216462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 216562306a36Sopenharmony_ci 216662306a36Sopenharmony_ciQueues an NMI on the thread's vcpu. Note this is well defined only 216762306a36Sopenharmony_ciwhen KVM_CREATE_IRQCHIP has not been called, since this is an interface 216862306a36Sopenharmony_cibetween the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP 216962306a36Sopenharmony_cihas been called, this interface is completely emulated within the kernel. 217062306a36Sopenharmony_ci 217162306a36Sopenharmony_ciTo use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the 217262306a36Sopenharmony_cifollowing algorithm: 217362306a36Sopenharmony_ci 217462306a36Sopenharmony_ci - pause the vcpu 217562306a36Sopenharmony_ci - read the local APIC's state (KVM_GET_LAPIC) 217662306a36Sopenharmony_ci - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1) 217762306a36Sopenharmony_ci - if so, issue KVM_NMI 217862306a36Sopenharmony_ci - resume the vcpu 217962306a36Sopenharmony_ci 218062306a36Sopenharmony_ciSome guests configure the LINT1 NMI input to cause a panic, aiding in 218162306a36Sopenharmony_cidebugging. 218262306a36Sopenharmony_ci 218362306a36Sopenharmony_ci 218462306a36Sopenharmony_ci4.65 KVM_S390_UCAS_MAP 218562306a36Sopenharmony_ci---------------------- 218662306a36Sopenharmony_ci 218762306a36Sopenharmony_ci:Capability: KVM_CAP_S390_UCONTROL 218862306a36Sopenharmony_ci:Architectures: s390 218962306a36Sopenharmony_ci:Type: vcpu ioctl 219062306a36Sopenharmony_ci:Parameters: struct kvm_s390_ucas_mapping (in) 219162306a36Sopenharmony_ci:Returns: 0 in case of success 219262306a36Sopenharmony_ci 219362306a36Sopenharmony_ciThe parameter is defined like this:: 219462306a36Sopenharmony_ci 219562306a36Sopenharmony_ci struct kvm_s390_ucas_mapping { 219662306a36Sopenharmony_ci __u64 user_addr; 219762306a36Sopenharmony_ci __u64 vcpu_addr; 219862306a36Sopenharmony_ci __u64 length; 219962306a36Sopenharmony_ci }; 220062306a36Sopenharmony_ci 220162306a36Sopenharmony_ciThis ioctl maps the memory at "user_addr" with the length "length" to 220262306a36Sopenharmony_cithe vcpu's address space starting at "vcpu_addr". All parameters need to 220362306a36Sopenharmony_cibe aligned by 1 megabyte. 220462306a36Sopenharmony_ci 220562306a36Sopenharmony_ci 220662306a36Sopenharmony_ci4.66 KVM_S390_UCAS_UNMAP 220762306a36Sopenharmony_ci------------------------ 220862306a36Sopenharmony_ci 220962306a36Sopenharmony_ci:Capability: KVM_CAP_S390_UCONTROL 221062306a36Sopenharmony_ci:Architectures: s390 221162306a36Sopenharmony_ci:Type: vcpu ioctl 221262306a36Sopenharmony_ci:Parameters: struct kvm_s390_ucas_mapping (in) 221362306a36Sopenharmony_ci:Returns: 0 in case of success 221462306a36Sopenharmony_ci 221562306a36Sopenharmony_ciThe parameter is defined like this:: 221662306a36Sopenharmony_ci 221762306a36Sopenharmony_ci struct kvm_s390_ucas_mapping { 221862306a36Sopenharmony_ci __u64 user_addr; 221962306a36Sopenharmony_ci __u64 vcpu_addr; 222062306a36Sopenharmony_ci __u64 length; 222162306a36Sopenharmony_ci }; 222262306a36Sopenharmony_ci 222362306a36Sopenharmony_ciThis ioctl unmaps the memory in the vcpu's address space starting at 222462306a36Sopenharmony_ci"vcpu_addr" with the length "length". The field "user_addr" is ignored. 222562306a36Sopenharmony_ciAll parameters need to be aligned by 1 megabyte. 222662306a36Sopenharmony_ci 222762306a36Sopenharmony_ci 222862306a36Sopenharmony_ci4.67 KVM_S390_VCPU_FAULT 222962306a36Sopenharmony_ci------------------------ 223062306a36Sopenharmony_ci 223162306a36Sopenharmony_ci:Capability: KVM_CAP_S390_UCONTROL 223262306a36Sopenharmony_ci:Architectures: s390 223362306a36Sopenharmony_ci:Type: vcpu ioctl 223462306a36Sopenharmony_ci:Parameters: vcpu absolute address (in) 223562306a36Sopenharmony_ci:Returns: 0 in case of success 223662306a36Sopenharmony_ci 223762306a36Sopenharmony_ciThis call creates a page table entry on the virtual cpu's address space 223862306a36Sopenharmony_ci(for user controlled virtual machines) or the virtual machine's address 223962306a36Sopenharmony_cispace (for regular virtual machines). This only works for minor faults, 224062306a36Sopenharmony_cithus it's recommended to access subject memory page via the user page 224162306a36Sopenharmony_citable upfront. This is useful to handle validity intercepts for user 224262306a36Sopenharmony_cicontrolled virtual machines to fault in the virtual cpu's lowcore pages 224362306a36Sopenharmony_ciprior to calling the KVM_RUN ioctl. 224462306a36Sopenharmony_ci 224562306a36Sopenharmony_ci 224662306a36Sopenharmony_ci4.68 KVM_SET_ONE_REG 224762306a36Sopenharmony_ci-------------------- 224862306a36Sopenharmony_ci 224962306a36Sopenharmony_ci:Capability: KVM_CAP_ONE_REG 225062306a36Sopenharmony_ci:Architectures: all 225162306a36Sopenharmony_ci:Type: vcpu ioctl 225262306a36Sopenharmony_ci:Parameters: struct kvm_one_reg (in) 225362306a36Sopenharmony_ci:Returns: 0 on success, negative value on failure 225462306a36Sopenharmony_ci 225562306a36Sopenharmony_ciErrors: 225662306a36Sopenharmony_ci 225762306a36Sopenharmony_ci ====== ============================================================ 225862306a36Sopenharmony_ci ENOENT no such register 225962306a36Sopenharmony_ci EINVAL invalid register ID, or no such register or used with VMs in 226062306a36Sopenharmony_ci protected virtualization mode on s390 226162306a36Sopenharmony_ci EPERM (arm64) register access not allowed before vcpu finalization 226262306a36Sopenharmony_ci EBUSY (riscv) changing register value not allowed after the vcpu 226362306a36Sopenharmony_ci has run at least once 226462306a36Sopenharmony_ci ====== ============================================================ 226562306a36Sopenharmony_ci 226662306a36Sopenharmony_ci(These error codes are indicative only: do not rely on a specific error 226762306a36Sopenharmony_cicode being returned in a specific situation.) 226862306a36Sopenharmony_ci 226962306a36Sopenharmony_ci:: 227062306a36Sopenharmony_ci 227162306a36Sopenharmony_ci struct kvm_one_reg { 227262306a36Sopenharmony_ci __u64 id; 227362306a36Sopenharmony_ci __u64 addr; 227462306a36Sopenharmony_ci }; 227562306a36Sopenharmony_ci 227662306a36Sopenharmony_ciUsing this ioctl, a single vcpu register can be set to a specific value 227762306a36Sopenharmony_cidefined by user space with the passed in struct kvm_one_reg, where id 227862306a36Sopenharmony_cirefers to the register identifier as described below and addr is a pointer 227962306a36Sopenharmony_cito a variable with the respective size. There can be architecture agnostic 228062306a36Sopenharmony_ciand architecture specific registers. Each have their own range of operation 228162306a36Sopenharmony_ciand their own constants and width. To keep track of the implemented 228262306a36Sopenharmony_ciregisters, find a list below: 228362306a36Sopenharmony_ci 228462306a36Sopenharmony_ci ======= =============================== ============ 228562306a36Sopenharmony_ci Arch Register Width (bits) 228662306a36Sopenharmony_ci ======= =============================== ============ 228762306a36Sopenharmony_ci PPC KVM_REG_PPC_HIOR 64 228862306a36Sopenharmony_ci PPC KVM_REG_PPC_IAC1 64 228962306a36Sopenharmony_ci PPC KVM_REG_PPC_IAC2 64 229062306a36Sopenharmony_ci PPC KVM_REG_PPC_IAC3 64 229162306a36Sopenharmony_ci PPC KVM_REG_PPC_IAC4 64 229262306a36Sopenharmony_ci PPC KVM_REG_PPC_DAC1 64 229362306a36Sopenharmony_ci PPC KVM_REG_PPC_DAC2 64 229462306a36Sopenharmony_ci PPC KVM_REG_PPC_DABR 64 229562306a36Sopenharmony_ci PPC KVM_REG_PPC_DSCR 64 229662306a36Sopenharmony_ci PPC KVM_REG_PPC_PURR 64 229762306a36Sopenharmony_ci PPC KVM_REG_PPC_SPURR 64 229862306a36Sopenharmony_ci PPC KVM_REG_PPC_DAR 64 229962306a36Sopenharmony_ci PPC KVM_REG_PPC_DSISR 32 230062306a36Sopenharmony_ci PPC KVM_REG_PPC_AMR 64 230162306a36Sopenharmony_ci PPC KVM_REG_PPC_UAMOR 64 230262306a36Sopenharmony_ci PPC KVM_REG_PPC_MMCR0 64 230362306a36Sopenharmony_ci PPC KVM_REG_PPC_MMCR1 64 230462306a36Sopenharmony_ci PPC KVM_REG_PPC_MMCRA 64 230562306a36Sopenharmony_ci PPC KVM_REG_PPC_MMCR2 64 230662306a36Sopenharmony_ci PPC KVM_REG_PPC_MMCRS 64 230762306a36Sopenharmony_ci PPC KVM_REG_PPC_MMCR3 64 230862306a36Sopenharmony_ci PPC KVM_REG_PPC_SIAR 64 230962306a36Sopenharmony_ci PPC KVM_REG_PPC_SDAR 64 231062306a36Sopenharmony_ci PPC KVM_REG_PPC_SIER 64 231162306a36Sopenharmony_ci PPC KVM_REG_PPC_SIER2 64 231262306a36Sopenharmony_ci PPC KVM_REG_PPC_SIER3 64 231362306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC1 32 231462306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC2 32 231562306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC3 32 231662306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC4 32 231762306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC5 32 231862306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC6 32 231962306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC7 32 232062306a36Sopenharmony_ci PPC KVM_REG_PPC_PMC8 32 232162306a36Sopenharmony_ci PPC KVM_REG_PPC_FPR0 64 232262306a36Sopenharmony_ci ... 232362306a36Sopenharmony_ci PPC KVM_REG_PPC_FPR31 64 232462306a36Sopenharmony_ci PPC KVM_REG_PPC_VR0 128 232562306a36Sopenharmony_ci ... 232662306a36Sopenharmony_ci PPC KVM_REG_PPC_VR31 128 232762306a36Sopenharmony_ci PPC KVM_REG_PPC_VSR0 128 232862306a36Sopenharmony_ci ... 232962306a36Sopenharmony_ci PPC KVM_REG_PPC_VSR31 128 233062306a36Sopenharmony_ci PPC KVM_REG_PPC_FPSCR 64 233162306a36Sopenharmony_ci PPC KVM_REG_PPC_VSCR 32 233262306a36Sopenharmony_ci PPC KVM_REG_PPC_VPA_ADDR 64 233362306a36Sopenharmony_ci PPC KVM_REG_PPC_VPA_SLB 128 233462306a36Sopenharmony_ci PPC KVM_REG_PPC_VPA_DTL 128 233562306a36Sopenharmony_ci PPC KVM_REG_PPC_EPCR 32 233662306a36Sopenharmony_ci PPC KVM_REG_PPC_EPR 32 233762306a36Sopenharmony_ci PPC KVM_REG_PPC_TCR 32 233862306a36Sopenharmony_ci PPC KVM_REG_PPC_TSR 32 233962306a36Sopenharmony_ci PPC KVM_REG_PPC_OR_TSR 32 234062306a36Sopenharmony_ci PPC KVM_REG_PPC_CLEAR_TSR 32 234162306a36Sopenharmony_ci PPC KVM_REG_PPC_MAS0 32 234262306a36Sopenharmony_ci PPC KVM_REG_PPC_MAS1 32 234362306a36Sopenharmony_ci PPC KVM_REG_PPC_MAS2 64 234462306a36Sopenharmony_ci PPC KVM_REG_PPC_MAS7_3 64 234562306a36Sopenharmony_ci PPC KVM_REG_PPC_MAS4 32 234662306a36Sopenharmony_ci PPC KVM_REG_PPC_MAS6 32 234762306a36Sopenharmony_ci PPC KVM_REG_PPC_MMUCFG 32 234862306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB0CFG 32 234962306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB1CFG 32 235062306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB2CFG 32 235162306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB3CFG 32 235262306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB0PS 32 235362306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB1PS 32 235462306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB2PS 32 235562306a36Sopenharmony_ci PPC KVM_REG_PPC_TLB3PS 32 235662306a36Sopenharmony_ci PPC KVM_REG_PPC_EPTCFG 32 235762306a36Sopenharmony_ci PPC KVM_REG_PPC_ICP_STATE 64 235862306a36Sopenharmony_ci PPC KVM_REG_PPC_VP_STATE 128 235962306a36Sopenharmony_ci PPC KVM_REG_PPC_TB_OFFSET 64 236062306a36Sopenharmony_ci PPC KVM_REG_PPC_SPMC1 32 236162306a36Sopenharmony_ci PPC KVM_REG_PPC_SPMC2 32 236262306a36Sopenharmony_ci PPC KVM_REG_PPC_IAMR 64 236362306a36Sopenharmony_ci PPC KVM_REG_PPC_TFHAR 64 236462306a36Sopenharmony_ci PPC KVM_REG_PPC_TFIAR 64 236562306a36Sopenharmony_ci PPC KVM_REG_PPC_TEXASR 64 236662306a36Sopenharmony_ci PPC KVM_REG_PPC_FSCR 64 236762306a36Sopenharmony_ci PPC KVM_REG_PPC_PSPB 32 236862306a36Sopenharmony_ci PPC KVM_REG_PPC_EBBHR 64 236962306a36Sopenharmony_ci PPC KVM_REG_PPC_EBBRR 64 237062306a36Sopenharmony_ci PPC KVM_REG_PPC_BESCR 64 237162306a36Sopenharmony_ci PPC KVM_REG_PPC_TAR 64 237262306a36Sopenharmony_ci PPC KVM_REG_PPC_DPDES 64 237362306a36Sopenharmony_ci PPC KVM_REG_PPC_DAWR 64 237462306a36Sopenharmony_ci PPC KVM_REG_PPC_DAWRX 64 237562306a36Sopenharmony_ci PPC KVM_REG_PPC_CIABR 64 237662306a36Sopenharmony_ci PPC KVM_REG_PPC_IC 64 237762306a36Sopenharmony_ci PPC KVM_REG_PPC_VTB 64 237862306a36Sopenharmony_ci PPC KVM_REG_PPC_CSIGR 64 237962306a36Sopenharmony_ci PPC KVM_REG_PPC_TACR 64 238062306a36Sopenharmony_ci PPC KVM_REG_PPC_TCSCR 64 238162306a36Sopenharmony_ci PPC KVM_REG_PPC_PID 64 238262306a36Sopenharmony_ci PPC KVM_REG_PPC_ACOP 64 238362306a36Sopenharmony_ci PPC KVM_REG_PPC_VRSAVE 32 238462306a36Sopenharmony_ci PPC KVM_REG_PPC_LPCR 32 238562306a36Sopenharmony_ci PPC KVM_REG_PPC_LPCR_64 64 238662306a36Sopenharmony_ci PPC KVM_REG_PPC_PPR 64 238762306a36Sopenharmony_ci PPC KVM_REG_PPC_ARCH_COMPAT 32 238862306a36Sopenharmony_ci PPC KVM_REG_PPC_DABRX 32 238962306a36Sopenharmony_ci PPC KVM_REG_PPC_WORT 64 239062306a36Sopenharmony_ci PPC KVM_REG_PPC_SPRG9 64 239162306a36Sopenharmony_ci PPC KVM_REG_PPC_DBSR 32 239262306a36Sopenharmony_ci PPC KVM_REG_PPC_TIDR 64 239362306a36Sopenharmony_ci PPC KVM_REG_PPC_PSSCR 64 239462306a36Sopenharmony_ci PPC KVM_REG_PPC_DEC_EXPIRY 64 239562306a36Sopenharmony_ci PPC KVM_REG_PPC_PTCR 64 239662306a36Sopenharmony_ci PPC KVM_REG_PPC_DAWR1 64 239762306a36Sopenharmony_ci PPC KVM_REG_PPC_DAWRX1 64 239862306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_GPR0 64 239962306a36Sopenharmony_ci ... 240062306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_GPR31 64 240162306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_VSR0 128 240262306a36Sopenharmony_ci ... 240362306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_VSR63 128 240462306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_CR 64 240562306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_LR 64 240662306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_CTR 64 240762306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_FPSCR 64 240862306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_AMR 64 240962306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_PPR 64 241062306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_VRSAVE 64 241162306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_VSCR 32 241262306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_DSCR 64 241362306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_TAR 64 241462306a36Sopenharmony_ci PPC KVM_REG_PPC_TM_XER 64 241562306a36Sopenharmony_ci 241662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_R0 64 241762306a36Sopenharmony_ci ... 241862306a36Sopenharmony_ci MIPS KVM_REG_MIPS_R31 64 241962306a36Sopenharmony_ci MIPS KVM_REG_MIPS_HI 64 242062306a36Sopenharmony_ci MIPS KVM_REG_MIPS_LO 64 242162306a36Sopenharmony_ci MIPS KVM_REG_MIPS_PC 64 242262306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_INDEX 32 242362306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ENTRYLO0 64 242462306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ENTRYLO1 64 242562306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONTEXT 64 242662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONTEXTCONFIG 32 242762306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_USERLOCAL 64 242862306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_XCONTEXTCONFIG 64 242962306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PAGEMASK 32 243062306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PAGEGRAIN 32 243162306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_SEGCTL0 64 243262306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_SEGCTL1 64 243362306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_SEGCTL2 64 243462306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWBASE 64 243562306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWFIELD 64 243662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWSIZE 64 243762306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_WIRED 32 243862306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PWCTL 32 243962306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_HWRENA 32 244062306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_BADVADDR 64 244162306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_BADINSTR 32 244262306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_BADINSTRP 32 244362306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_COUNT 32 244462306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ENTRYHI 64 244562306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_COMPARE 32 244662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_STATUS 32 244762306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_INTCTL 32 244862306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CAUSE 32 244962306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_EPC 64 245062306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_PRID 32 245162306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_EBASE 64 245262306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG 32 245362306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG1 32 245462306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG2 32 245562306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG3 32 245662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG4 32 245762306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG5 32 245862306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_CONFIG7 32 245962306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_XCONTEXT 64 246062306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_ERROREPC 64 246162306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH1 64 246262306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH2 64 246362306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH3 64 246462306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH4 64 246562306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH5 64 246662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_KSCRATCH6 64 246762306a36Sopenharmony_ci MIPS KVM_REG_MIPS_CP0_MAAR(0..63) 64 246862306a36Sopenharmony_ci MIPS KVM_REG_MIPS_COUNT_CTL 64 246962306a36Sopenharmony_ci MIPS KVM_REG_MIPS_COUNT_RESUME 64 247062306a36Sopenharmony_ci MIPS KVM_REG_MIPS_COUNT_HZ 64 247162306a36Sopenharmony_ci MIPS KVM_REG_MIPS_FPR_32(0..31) 32 247262306a36Sopenharmony_ci MIPS KVM_REG_MIPS_FPR_64(0..31) 64 247362306a36Sopenharmony_ci MIPS KVM_REG_MIPS_VEC_128(0..31) 128 247462306a36Sopenharmony_ci MIPS KVM_REG_MIPS_FCR_IR 32 247562306a36Sopenharmony_ci MIPS KVM_REG_MIPS_FCR_CSR 32 247662306a36Sopenharmony_ci MIPS KVM_REG_MIPS_MSA_IR 32 247762306a36Sopenharmony_ci MIPS KVM_REG_MIPS_MSA_CSR 32 247862306a36Sopenharmony_ci ======= =============================== ============ 247962306a36Sopenharmony_ci 248062306a36Sopenharmony_ciARM registers are mapped using the lower 32 bits. The upper 16 of that 248162306a36Sopenharmony_ciis the register group type, or coprocessor number: 248262306a36Sopenharmony_ci 248362306a36Sopenharmony_ciARM core registers have the following id bit patterns:: 248462306a36Sopenharmony_ci 248562306a36Sopenharmony_ci 0x4020 0000 0010 <index into the kvm_regs struct:16> 248662306a36Sopenharmony_ci 248762306a36Sopenharmony_ciARM 32-bit CP15 registers have the following id bit patterns:: 248862306a36Sopenharmony_ci 248962306a36Sopenharmony_ci 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3> 249062306a36Sopenharmony_ci 249162306a36Sopenharmony_ciARM 64-bit CP15 registers have the following id bit patterns:: 249262306a36Sopenharmony_ci 249362306a36Sopenharmony_ci 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3> 249462306a36Sopenharmony_ci 249562306a36Sopenharmony_ciARM CCSIDR registers are demultiplexed by CSSELR value:: 249662306a36Sopenharmony_ci 249762306a36Sopenharmony_ci 0x4020 0000 0011 00 <csselr:8> 249862306a36Sopenharmony_ci 249962306a36Sopenharmony_ciARM 32-bit VFP control registers have the following id bit patterns:: 250062306a36Sopenharmony_ci 250162306a36Sopenharmony_ci 0x4020 0000 0012 1 <regno:12> 250262306a36Sopenharmony_ci 250362306a36Sopenharmony_ciARM 64-bit FP registers have the following id bit patterns:: 250462306a36Sopenharmony_ci 250562306a36Sopenharmony_ci 0x4030 0000 0012 0 <regno:12> 250662306a36Sopenharmony_ci 250762306a36Sopenharmony_ciARM firmware pseudo-registers have the following bit pattern:: 250862306a36Sopenharmony_ci 250962306a36Sopenharmony_ci 0x4030 0000 0014 <regno:16> 251062306a36Sopenharmony_ci 251162306a36Sopenharmony_ci 251262306a36Sopenharmony_ciarm64 registers are mapped using the lower 32 bits. The upper 16 of 251362306a36Sopenharmony_cithat is the register group type, or coprocessor number: 251462306a36Sopenharmony_ci 251562306a36Sopenharmony_ciarm64 core/FP-SIMD registers have the following id bit patterns. Note 251662306a36Sopenharmony_cithat the size of the access is variable, as the kvm_regs structure 251762306a36Sopenharmony_cicontains elements ranging from 32 to 128 bits. The index is a 32bit 251862306a36Sopenharmony_civalue in the kvm_regs structure seen as a 32bit array:: 251962306a36Sopenharmony_ci 252062306a36Sopenharmony_ci 0x60x0 0000 0010 <index into the kvm_regs struct:16> 252162306a36Sopenharmony_ci 252262306a36Sopenharmony_ciSpecifically: 252362306a36Sopenharmony_ci 252462306a36Sopenharmony_ci======================= ========= ===== ======================================= 252562306a36Sopenharmony_ci Encoding Register Bits kvm_regs member 252662306a36Sopenharmony_ci======================= ========= ===== ======================================= 252762306a36Sopenharmony_ci 0x6030 0000 0010 0000 X0 64 regs.regs[0] 252862306a36Sopenharmony_ci 0x6030 0000 0010 0002 X1 64 regs.regs[1] 252962306a36Sopenharmony_ci ... 253062306a36Sopenharmony_ci 0x6030 0000 0010 003c X30 64 regs.regs[30] 253162306a36Sopenharmony_ci 0x6030 0000 0010 003e SP 64 regs.sp 253262306a36Sopenharmony_ci 0x6030 0000 0010 0040 PC 64 regs.pc 253362306a36Sopenharmony_ci 0x6030 0000 0010 0042 PSTATE 64 regs.pstate 253462306a36Sopenharmony_ci 0x6030 0000 0010 0044 SP_EL1 64 sp_el1 253562306a36Sopenharmony_ci 0x6030 0000 0010 0046 ELR_EL1 64 elr_el1 253662306a36Sopenharmony_ci 0x6030 0000 0010 0048 SPSR_EL1 64 spsr[KVM_SPSR_EL1] (alias SPSR_SVC) 253762306a36Sopenharmony_ci 0x6030 0000 0010 004a SPSR_ABT 64 spsr[KVM_SPSR_ABT] 253862306a36Sopenharmony_ci 0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND] 253962306a36Sopenharmony_ci 0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ] 254062306a36Sopenharmony_ci 0x6060 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ] 254162306a36Sopenharmony_ci 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] [1]_ 254262306a36Sopenharmony_ci 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] [1]_ 254362306a36Sopenharmony_ci ... 254462306a36Sopenharmony_ci 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31] [1]_ 254562306a36Sopenharmony_ci 0x6020 0000 0010 00d4 FPSR 32 fp_regs.fpsr 254662306a36Sopenharmony_ci 0x6020 0000 0010 00d5 FPCR 32 fp_regs.fpcr 254762306a36Sopenharmony_ci======================= ========= ===== ======================================= 254862306a36Sopenharmony_ci 254962306a36Sopenharmony_ci.. [1] These encodings are not accepted for SVE-enabled vcpus. See 255062306a36Sopenharmony_ci KVM_ARM_VCPU_INIT. 255162306a36Sopenharmony_ci 255262306a36Sopenharmony_ci The equivalent register content can be accessed via bits [127:0] of 255362306a36Sopenharmony_ci the corresponding SVE Zn registers instead for vcpus that have SVE 255462306a36Sopenharmony_ci enabled (see below). 255562306a36Sopenharmony_ci 255662306a36Sopenharmony_ciarm64 CCSIDR registers are demultiplexed by CSSELR value:: 255762306a36Sopenharmony_ci 255862306a36Sopenharmony_ci 0x6020 0000 0011 00 <csselr:8> 255962306a36Sopenharmony_ci 256062306a36Sopenharmony_ciarm64 system registers have the following id bit patterns:: 256162306a36Sopenharmony_ci 256262306a36Sopenharmony_ci 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3> 256362306a36Sopenharmony_ci 256462306a36Sopenharmony_ci.. warning:: 256562306a36Sopenharmony_ci 256662306a36Sopenharmony_ci Two system register IDs do not follow the specified pattern. These 256762306a36Sopenharmony_ci are KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT, which map to 256862306a36Sopenharmony_ci system registers CNTV_CVAL_EL0 and CNTVCT_EL0 respectively. These 256962306a36Sopenharmony_ci two had their values accidentally swapped, which means TIMER_CVAL is 257062306a36Sopenharmony_ci derived from the register encoding for CNTVCT_EL0 and TIMER_CNT is 257162306a36Sopenharmony_ci derived from the register encoding for CNTV_CVAL_EL0. As this is 257262306a36Sopenharmony_ci API, it must remain this way. 257362306a36Sopenharmony_ci 257462306a36Sopenharmony_ciarm64 firmware pseudo-registers have the following bit pattern:: 257562306a36Sopenharmony_ci 257662306a36Sopenharmony_ci 0x6030 0000 0014 <regno:16> 257762306a36Sopenharmony_ci 257862306a36Sopenharmony_ciarm64 SVE registers have the following bit patterns:: 257962306a36Sopenharmony_ci 258062306a36Sopenharmony_ci 0x6080 0000 0015 00 <n:5> <slice:5> Zn bits[2048*slice + 2047 : 2048*slice] 258162306a36Sopenharmony_ci 0x6050 0000 0015 04 <n:4> <slice:5> Pn bits[256*slice + 255 : 256*slice] 258262306a36Sopenharmony_ci 0x6050 0000 0015 060 <slice:5> FFR bits[256*slice + 255 : 256*slice] 258362306a36Sopenharmony_ci 0x6060 0000 0015 ffff KVM_REG_ARM64_SVE_VLS pseudo-register 258462306a36Sopenharmony_ci 258562306a36Sopenharmony_ciAccess to register IDs where 2048 * slice >= 128 * max_vq will fail with 258662306a36Sopenharmony_ciENOENT. max_vq is the vcpu's maximum supported vector length in 128-bit 258762306a36Sopenharmony_ciquadwords: see [2]_ below. 258862306a36Sopenharmony_ci 258962306a36Sopenharmony_ciThese registers are only accessible on vcpus for which SVE is enabled. 259062306a36Sopenharmony_ciSee KVM_ARM_VCPU_INIT for details. 259162306a36Sopenharmony_ci 259262306a36Sopenharmony_ciIn addition, except for KVM_REG_ARM64_SVE_VLS, these registers are not 259362306a36Sopenharmony_ciaccessible until the vcpu's SVE configuration has been finalized 259462306a36Sopenharmony_ciusing KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). See KVM_ARM_VCPU_INIT 259562306a36Sopenharmony_ciand KVM_ARM_VCPU_FINALIZE for more information about this procedure. 259662306a36Sopenharmony_ci 259762306a36Sopenharmony_ciKVM_REG_ARM64_SVE_VLS is a pseudo-register that allows the set of vector 259862306a36Sopenharmony_cilengths supported by the vcpu to be discovered and configured by 259962306a36Sopenharmony_ciuserspace. When transferred to or from user memory via KVM_GET_ONE_REG 260062306a36Sopenharmony_cior KVM_SET_ONE_REG, the value of this register is of type 260162306a36Sopenharmony_ci__u64[KVM_ARM64_SVE_VLS_WORDS], and encodes the set of vector lengths as 260262306a36Sopenharmony_cifollows:: 260362306a36Sopenharmony_ci 260462306a36Sopenharmony_ci __u64 vector_lengths[KVM_ARM64_SVE_VLS_WORDS]; 260562306a36Sopenharmony_ci 260662306a36Sopenharmony_ci if (vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX && 260762306a36Sopenharmony_ci ((vector_lengths[(vq - KVM_ARM64_SVE_VQ_MIN) / 64] >> 260862306a36Sopenharmony_ci ((vq - KVM_ARM64_SVE_VQ_MIN) % 64)) & 1)) 260962306a36Sopenharmony_ci /* Vector length vq * 16 bytes supported */ 261062306a36Sopenharmony_ci else 261162306a36Sopenharmony_ci /* Vector length vq * 16 bytes not supported */ 261262306a36Sopenharmony_ci 261362306a36Sopenharmony_ci.. [2] The maximum value vq for which the above condition is true is 261462306a36Sopenharmony_ci max_vq. This is the maximum vector length available to the guest on 261562306a36Sopenharmony_ci this vcpu, and determines which register slices are visible through 261662306a36Sopenharmony_ci this ioctl interface. 261762306a36Sopenharmony_ci 261862306a36Sopenharmony_ci(See Documentation/arch/arm64/sve.rst for an explanation of the "vq" 261962306a36Sopenharmony_cinomenclature.) 262062306a36Sopenharmony_ci 262162306a36Sopenharmony_ciKVM_REG_ARM64_SVE_VLS is only accessible after KVM_ARM_VCPU_INIT. 262262306a36Sopenharmony_ciKVM_ARM_VCPU_INIT initialises it to the best set of vector lengths that 262362306a36Sopenharmony_cithe host supports. 262462306a36Sopenharmony_ci 262562306a36Sopenharmony_ciUserspace may subsequently modify it if desired until the vcpu's SVE 262662306a36Sopenharmony_ciconfiguration is finalized using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). 262762306a36Sopenharmony_ci 262862306a36Sopenharmony_ciApart from simply removing all vector lengths from the host set that 262962306a36Sopenharmony_ciexceed some value, support for arbitrarily chosen sets of vector lengths 263062306a36Sopenharmony_ciis hardware-dependent and may not be available. Attempting to configure 263162306a36Sopenharmony_cian invalid set of vector lengths via KVM_SET_ONE_REG will fail with 263262306a36Sopenharmony_ciEINVAL. 263362306a36Sopenharmony_ci 263462306a36Sopenharmony_ciAfter the vcpu's SVE configuration is finalized, further attempts to 263562306a36Sopenharmony_ciwrite this register will fail with EPERM. 263662306a36Sopenharmony_ci 263762306a36Sopenharmony_ciarm64 bitmap feature firmware pseudo-registers have the following bit pattern:: 263862306a36Sopenharmony_ci 263962306a36Sopenharmony_ci 0x6030 0000 0016 <regno:16> 264062306a36Sopenharmony_ci 264162306a36Sopenharmony_ciThe bitmap feature firmware registers exposes the hypercall services that 264262306a36Sopenharmony_ciare available for userspace to configure. The set bits corresponds to the 264362306a36Sopenharmony_ciservices that are available for the guests to access. By default, KVM 264462306a36Sopenharmony_cisets all the supported bits during VM initialization. The userspace can 264562306a36Sopenharmony_cidiscover the available services via KVM_GET_ONE_REG, and write back the 264662306a36Sopenharmony_cibitmap corresponding to the features that it wishes guests to see via 264762306a36Sopenharmony_ciKVM_SET_ONE_REG. 264862306a36Sopenharmony_ci 264962306a36Sopenharmony_ciNote: These registers are immutable once any of the vCPUs of the VM has 265062306a36Sopenharmony_cirun at least once. A KVM_SET_ONE_REG in such a scenario will return 265162306a36Sopenharmony_cia -EBUSY to userspace. 265262306a36Sopenharmony_ci 265362306a36Sopenharmony_ci(See Documentation/virt/kvm/arm/hypercalls.rst for more details.) 265462306a36Sopenharmony_ci 265562306a36Sopenharmony_ci 265662306a36Sopenharmony_ciMIPS registers are mapped using the lower 32 bits. The upper 16 of that is 265762306a36Sopenharmony_cithe register group type: 265862306a36Sopenharmony_ci 265962306a36Sopenharmony_ciMIPS core registers (see above) have the following id bit patterns:: 266062306a36Sopenharmony_ci 266162306a36Sopenharmony_ci 0x7030 0000 0000 <reg:16> 266262306a36Sopenharmony_ci 266362306a36Sopenharmony_ciMIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit 266462306a36Sopenharmony_cipatterns depending on whether they're 32-bit or 64-bit registers:: 266562306a36Sopenharmony_ci 266662306a36Sopenharmony_ci 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit) 266762306a36Sopenharmony_ci 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit) 266862306a36Sopenharmony_ci 266962306a36Sopenharmony_ciNote: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64 267062306a36Sopenharmony_civersions of the EntryLo registers regardless of the word size of the host 267162306a36Sopenharmony_cihardware, host kernel, guest, and whether XPA is present in the guest, i.e. 267262306a36Sopenharmony_ciwith the RI and XI bits (if they exist) in bits 63 and 62 respectively, and 267362306a36Sopenharmony_cithe PFNX field starting at bit 30. 267462306a36Sopenharmony_ci 267562306a36Sopenharmony_ciMIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit 267662306a36Sopenharmony_cipatterns:: 267762306a36Sopenharmony_ci 267862306a36Sopenharmony_ci 0x7030 0000 0001 01 <reg:8> 267962306a36Sopenharmony_ci 268062306a36Sopenharmony_ciMIPS KVM control registers (see above) have the following id bit patterns:: 268162306a36Sopenharmony_ci 268262306a36Sopenharmony_ci 0x7030 0000 0002 <reg:16> 268362306a36Sopenharmony_ci 268462306a36Sopenharmony_ciMIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following 268562306a36Sopenharmony_ciid bit patterns depending on the size of the register being accessed. They are 268662306a36Sopenharmony_cialways accessed according to the current guest FPU mode (Status.FR and 268762306a36Sopenharmony_ciConfig5.FRE), i.e. as the guest would see them, and they become unpredictable 268862306a36Sopenharmony_ciif the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector 268962306a36Sopenharmony_ciregisters (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they 269062306a36Sopenharmony_cioverlap the FPU registers:: 269162306a36Sopenharmony_ci 269262306a36Sopenharmony_ci 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers) 269362306a36Sopenharmony_ci 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers) 269462306a36Sopenharmony_ci 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers) 269562306a36Sopenharmony_ci 269662306a36Sopenharmony_ciMIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the 269762306a36Sopenharmony_cifollowing id bit patterns:: 269862306a36Sopenharmony_ci 269962306a36Sopenharmony_ci 0x7020 0000 0003 01 <0:3> <reg:5> 270062306a36Sopenharmony_ci 270162306a36Sopenharmony_ciMIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the 270262306a36Sopenharmony_cifollowing id bit patterns:: 270362306a36Sopenharmony_ci 270462306a36Sopenharmony_ci 0x7020 0000 0003 02 <0:3> <reg:5> 270562306a36Sopenharmony_ci 270662306a36Sopenharmony_ciRISC-V registers are mapped using the lower 32 bits. The upper 8 bits of 270762306a36Sopenharmony_cithat is the register group type. 270862306a36Sopenharmony_ci 270962306a36Sopenharmony_ciRISC-V config registers are meant for configuring a Guest VCPU and it has 271062306a36Sopenharmony_cithe following id bit patterns:: 271162306a36Sopenharmony_ci 271262306a36Sopenharmony_ci 0x8020 0000 01 <index into the kvm_riscv_config struct:24> (32bit Host) 271362306a36Sopenharmony_ci 0x8030 0000 01 <index into the kvm_riscv_config struct:24> (64bit Host) 271462306a36Sopenharmony_ci 271562306a36Sopenharmony_ciFollowing are the RISC-V config registers: 271662306a36Sopenharmony_ci 271762306a36Sopenharmony_ci======================= ========= ============================================= 271862306a36Sopenharmony_ci Encoding Register Description 271962306a36Sopenharmony_ci======================= ========= ============================================= 272062306a36Sopenharmony_ci 0x80x0 0000 0100 0000 isa ISA feature bitmap of Guest VCPU 272162306a36Sopenharmony_ci======================= ========= ============================================= 272262306a36Sopenharmony_ci 272362306a36Sopenharmony_ciThe isa config register can be read anytime but can only be written before 272462306a36Sopenharmony_cia Guest VCPU runs. It will have ISA feature bits matching underlying host 272562306a36Sopenharmony_ciset by default. 272662306a36Sopenharmony_ci 272762306a36Sopenharmony_ciRISC-V core registers represent the general execution state of a Guest VCPU 272862306a36Sopenharmony_ciand it has the following id bit patterns:: 272962306a36Sopenharmony_ci 273062306a36Sopenharmony_ci 0x8020 0000 02 <index into the kvm_riscv_core struct:24> (32bit Host) 273162306a36Sopenharmony_ci 0x8030 0000 02 <index into the kvm_riscv_core struct:24> (64bit Host) 273262306a36Sopenharmony_ci 273362306a36Sopenharmony_ciFollowing are the RISC-V core registers: 273462306a36Sopenharmony_ci 273562306a36Sopenharmony_ci======================= ========= ============================================= 273662306a36Sopenharmony_ci Encoding Register Description 273762306a36Sopenharmony_ci======================= ========= ============================================= 273862306a36Sopenharmony_ci 0x80x0 0000 0200 0000 regs.pc Program counter 273962306a36Sopenharmony_ci 0x80x0 0000 0200 0001 regs.ra Return address 274062306a36Sopenharmony_ci 0x80x0 0000 0200 0002 regs.sp Stack pointer 274162306a36Sopenharmony_ci 0x80x0 0000 0200 0003 regs.gp Global pointer 274262306a36Sopenharmony_ci 0x80x0 0000 0200 0004 regs.tp Task pointer 274362306a36Sopenharmony_ci 0x80x0 0000 0200 0005 regs.t0 Caller saved register 0 274462306a36Sopenharmony_ci 0x80x0 0000 0200 0006 regs.t1 Caller saved register 1 274562306a36Sopenharmony_ci 0x80x0 0000 0200 0007 regs.t2 Caller saved register 2 274662306a36Sopenharmony_ci 0x80x0 0000 0200 0008 regs.s0 Callee saved register 0 274762306a36Sopenharmony_ci 0x80x0 0000 0200 0009 regs.s1 Callee saved register 1 274862306a36Sopenharmony_ci 0x80x0 0000 0200 000a regs.a0 Function argument (or return value) 0 274962306a36Sopenharmony_ci 0x80x0 0000 0200 000b regs.a1 Function argument (or return value) 1 275062306a36Sopenharmony_ci 0x80x0 0000 0200 000c regs.a2 Function argument 2 275162306a36Sopenharmony_ci 0x80x0 0000 0200 000d regs.a3 Function argument 3 275262306a36Sopenharmony_ci 0x80x0 0000 0200 000e regs.a4 Function argument 4 275362306a36Sopenharmony_ci 0x80x0 0000 0200 000f regs.a5 Function argument 5 275462306a36Sopenharmony_ci 0x80x0 0000 0200 0010 regs.a6 Function argument 6 275562306a36Sopenharmony_ci 0x80x0 0000 0200 0011 regs.a7 Function argument 7 275662306a36Sopenharmony_ci 0x80x0 0000 0200 0012 regs.s2 Callee saved register 2 275762306a36Sopenharmony_ci 0x80x0 0000 0200 0013 regs.s3 Callee saved register 3 275862306a36Sopenharmony_ci 0x80x0 0000 0200 0014 regs.s4 Callee saved register 4 275962306a36Sopenharmony_ci 0x80x0 0000 0200 0015 regs.s5 Callee saved register 5 276062306a36Sopenharmony_ci 0x80x0 0000 0200 0016 regs.s6 Callee saved register 6 276162306a36Sopenharmony_ci 0x80x0 0000 0200 0017 regs.s7 Callee saved register 7 276262306a36Sopenharmony_ci 0x80x0 0000 0200 0018 regs.s8 Callee saved register 8 276362306a36Sopenharmony_ci 0x80x0 0000 0200 0019 regs.s9 Callee saved register 9 276462306a36Sopenharmony_ci 0x80x0 0000 0200 001a regs.s10 Callee saved register 10 276562306a36Sopenharmony_ci 0x80x0 0000 0200 001b regs.s11 Callee saved register 11 276662306a36Sopenharmony_ci 0x80x0 0000 0200 001c regs.t3 Caller saved register 3 276762306a36Sopenharmony_ci 0x80x0 0000 0200 001d regs.t4 Caller saved register 4 276862306a36Sopenharmony_ci 0x80x0 0000 0200 001e regs.t5 Caller saved register 5 276962306a36Sopenharmony_ci 0x80x0 0000 0200 001f regs.t6 Caller saved register 6 277062306a36Sopenharmony_ci 0x80x0 0000 0200 0020 mode Privilege mode (1 = S-mode or 0 = U-mode) 277162306a36Sopenharmony_ci======================= ========= ============================================= 277262306a36Sopenharmony_ci 277362306a36Sopenharmony_ciRISC-V csr registers represent the supervisor mode control/status registers 277462306a36Sopenharmony_ciof a Guest VCPU and it has the following id bit patterns:: 277562306a36Sopenharmony_ci 277662306a36Sopenharmony_ci 0x8020 0000 03 <index into the kvm_riscv_csr struct:24> (32bit Host) 277762306a36Sopenharmony_ci 0x8030 0000 03 <index into the kvm_riscv_csr struct:24> (64bit Host) 277862306a36Sopenharmony_ci 277962306a36Sopenharmony_ciFollowing are the RISC-V csr registers: 278062306a36Sopenharmony_ci 278162306a36Sopenharmony_ci======================= ========= ============================================= 278262306a36Sopenharmony_ci Encoding Register Description 278362306a36Sopenharmony_ci======================= ========= ============================================= 278462306a36Sopenharmony_ci 0x80x0 0000 0300 0000 sstatus Supervisor status 278562306a36Sopenharmony_ci 0x80x0 0000 0300 0001 sie Supervisor interrupt enable 278662306a36Sopenharmony_ci 0x80x0 0000 0300 0002 stvec Supervisor trap vector base 278762306a36Sopenharmony_ci 0x80x0 0000 0300 0003 sscratch Supervisor scratch register 278862306a36Sopenharmony_ci 0x80x0 0000 0300 0004 sepc Supervisor exception program counter 278962306a36Sopenharmony_ci 0x80x0 0000 0300 0005 scause Supervisor trap cause 279062306a36Sopenharmony_ci 0x80x0 0000 0300 0006 stval Supervisor bad address or instruction 279162306a36Sopenharmony_ci 0x80x0 0000 0300 0007 sip Supervisor interrupt pending 279262306a36Sopenharmony_ci 0x80x0 0000 0300 0008 satp Supervisor address translation and protection 279362306a36Sopenharmony_ci======================= ========= ============================================= 279462306a36Sopenharmony_ci 279562306a36Sopenharmony_ciRISC-V timer registers represent the timer state of a Guest VCPU and it has 279662306a36Sopenharmony_cithe following id bit patterns:: 279762306a36Sopenharmony_ci 279862306a36Sopenharmony_ci 0x8030 0000 04 <index into the kvm_riscv_timer struct:24> 279962306a36Sopenharmony_ci 280062306a36Sopenharmony_ciFollowing are the RISC-V timer registers: 280162306a36Sopenharmony_ci 280262306a36Sopenharmony_ci======================= ========= ============================================= 280362306a36Sopenharmony_ci Encoding Register Description 280462306a36Sopenharmony_ci======================= ========= ============================================= 280562306a36Sopenharmony_ci 0x8030 0000 0400 0000 frequency Time base frequency (read-only) 280662306a36Sopenharmony_ci 0x8030 0000 0400 0001 time Time value visible to Guest 280762306a36Sopenharmony_ci 0x8030 0000 0400 0002 compare Time compare programmed by Guest 280862306a36Sopenharmony_ci 0x8030 0000 0400 0003 state Time compare state (1 = ON or 0 = OFF) 280962306a36Sopenharmony_ci======================= ========= ============================================= 281062306a36Sopenharmony_ci 281162306a36Sopenharmony_ciRISC-V F-extension registers represent the single precision floating point 281262306a36Sopenharmony_cistate of a Guest VCPU and it has the following id bit patterns:: 281362306a36Sopenharmony_ci 281462306a36Sopenharmony_ci 0x8020 0000 05 <index into the __riscv_f_ext_state struct:24> 281562306a36Sopenharmony_ci 281662306a36Sopenharmony_ciFollowing are the RISC-V F-extension registers: 281762306a36Sopenharmony_ci 281862306a36Sopenharmony_ci======================= ========= ============================================= 281962306a36Sopenharmony_ci Encoding Register Description 282062306a36Sopenharmony_ci======================= ========= ============================================= 282162306a36Sopenharmony_ci 0x8020 0000 0500 0000 f[0] Floating point register 0 282262306a36Sopenharmony_ci ... 282362306a36Sopenharmony_ci 0x8020 0000 0500 001f f[31] Floating point register 31 282462306a36Sopenharmony_ci 0x8020 0000 0500 0020 fcsr Floating point control and status register 282562306a36Sopenharmony_ci======================= ========= ============================================= 282662306a36Sopenharmony_ci 282762306a36Sopenharmony_ciRISC-V D-extension registers represent the double precision floating point 282862306a36Sopenharmony_cistate of a Guest VCPU and it has the following id bit patterns:: 282962306a36Sopenharmony_ci 283062306a36Sopenharmony_ci 0x8020 0000 06 <index into the __riscv_d_ext_state struct:24> (fcsr) 283162306a36Sopenharmony_ci 0x8030 0000 06 <index into the __riscv_d_ext_state struct:24> (non-fcsr) 283262306a36Sopenharmony_ci 283362306a36Sopenharmony_ciFollowing are the RISC-V D-extension registers: 283462306a36Sopenharmony_ci 283562306a36Sopenharmony_ci======================= ========= ============================================= 283662306a36Sopenharmony_ci Encoding Register Description 283762306a36Sopenharmony_ci======================= ========= ============================================= 283862306a36Sopenharmony_ci 0x8030 0000 0600 0000 f[0] Floating point register 0 283962306a36Sopenharmony_ci ... 284062306a36Sopenharmony_ci 0x8030 0000 0600 001f f[31] Floating point register 31 284162306a36Sopenharmony_ci 0x8020 0000 0600 0020 fcsr Floating point control and status register 284262306a36Sopenharmony_ci======================= ========= ============================================= 284362306a36Sopenharmony_ci 284462306a36Sopenharmony_ci 284562306a36Sopenharmony_ci4.69 KVM_GET_ONE_REG 284662306a36Sopenharmony_ci-------------------- 284762306a36Sopenharmony_ci 284862306a36Sopenharmony_ci:Capability: KVM_CAP_ONE_REG 284962306a36Sopenharmony_ci:Architectures: all 285062306a36Sopenharmony_ci:Type: vcpu ioctl 285162306a36Sopenharmony_ci:Parameters: struct kvm_one_reg (in and out) 285262306a36Sopenharmony_ci:Returns: 0 on success, negative value on failure 285362306a36Sopenharmony_ci 285462306a36Sopenharmony_ciErrors include: 285562306a36Sopenharmony_ci 285662306a36Sopenharmony_ci ======== ============================================================ 285762306a36Sopenharmony_ci ENOENT no such register 285862306a36Sopenharmony_ci EINVAL invalid register ID, or no such register or used with VMs in 285962306a36Sopenharmony_ci protected virtualization mode on s390 286062306a36Sopenharmony_ci EPERM (arm64) register access not allowed before vcpu finalization 286162306a36Sopenharmony_ci ======== ============================================================ 286262306a36Sopenharmony_ci 286362306a36Sopenharmony_ci(These error codes are indicative only: do not rely on a specific error 286462306a36Sopenharmony_cicode being returned in a specific situation.) 286562306a36Sopenharmony_ci 286662306a36Sopenharmony_ciThis ioctl allows to receive the value of a single register implemented 286762306a36Sopenharmony_ciin a vcpu. The register to read is indicated by the "id" field of the 286862306a36Sopenharmony_cikvm_one_reg struct passed in. On success, the register value can be found 286962306a36Sopenharmony_ciat the memory location pointed to by "addr". 287062306a36Sopenharmony_ci 287162306a36Sopenharmony_ciThe list of registers accessible using this interface is identical to the 287262306a36Sopenharmony_cilist in 4.68. 287362306a36Sopenharmony_ci 287462306a36Sopenharmony_ci 287562306a36Sopenharmony_ci4.70 KVM_KVMCLOCK_CTRL 287662306a36Sopenharmony_ci---------------------- 287762306a36Sopenharmony_ci 287862306a36Sopenharmony_ci:Capability: KVM_CAP_KVMCLOCK_CTRL 287962306a36Sopenharmony_ci:Architectures: Any that implement pvclocks (currently x86 only) 288062306a36Sopenharmony_ci:Type: vcpu ioctl 288162306a36Sopenharmony_ci:Parameters: None 288262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 288362306a36Sopenharmony_ci 288462306a36Sopenharmony_ciThis ioctl sets a flag accessible to the guest indicating that the specified 288562306a36Sopenharmony_civCPU has been paused by the host userspace. 288662306a36Sopenharmony_ci 288762306a36Sopenharmony_ciThe host will set a flag in the pvclock structure that is checked from the 288862306a36Sopenharmony_cisoft lockup watchdog. The flag is part of the pvclock structure that is 288962306a36Sopenharmony_cishared between guest and host, specifically the second bit of the flags 289062306a36Sopenharmony_cifield of the pvclock_vcpu_time_info structure. It will be set exclusively by 289162306a36Sopenharmony_cithe host and read/cleared exclusively by the guest. The guest operation of 289262306a36Sopenharmony_cichecking and clearing the flag must be an atomic operation so 289362306a36Sopenharmony_ciload-link/store-conditional, or equivalent must be used. There are two cases 289462306a36Sopenharmony_ciwhere the guest will clear the flag: when the soft lockup watchdog timer resets 289562306a36Sopenharmony_ciitself or when a soft lockup is detected. This ioctl can be called any time 289662306a36Sopenharmony_ciafter pausing the vcpu, but before it is resumed. 289762306a36Sopenharmony_ci 289862306a36Sopenharmony_ci 289962306a36Sopenharmony_ci4.71 KVM_SIGNAL_MSI 290062306a36Sopenharmony_ci------------------- 290162306a36Sopenharmony_ci 290262306a36Sopenharmony_ci:Capability: KVM_CAP_SIGNAL_MSI 290362306a36Sopenharmony_ci:Architectures: x86 arm64 290462306a36Sopenharmony_ci:Type: vm ioctl 290562306a36Sopenharmony_ci:Parameters: struct kvm_msi (in) 290662306a36Sopenharmony_ci:Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error 290762306a36Sopenharmony_ci 290862306a36Sopenharmony_ciDirectly inject a MSI message. Only valid with in-kernel irqchip that handles 290962306a36Sopenharmony_ciMSI messages. 291062306a36Sopenharmony_ci 291162306a36Sopenharmony_ci:: 291262306a36Sopenharmony_ci 291362306a36Sopenharmony_ci struct kvm_msi { 291462306a36Sopenharmony_ci __u32 address_lo; 291562306a36Sopenharmony_ci __u32 address_hi; 291662306a36Sopenharmony_ci __u32 data; 291762306a36Sopenharmony_ci __u32 flags; 291862306a36Sopenharmony_ci __u32 devid; 291962306a36Sopenharmony_ci __u8 pad[12]; 292062306a36Sopenharmony_ci }; 292162306a36Sopenharmony_ci 292262306a36Sopenharmony_ciflags: 292362306a36Sopenharmony_ci KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM 292462306a36Sopenharmony_ci KVM_CAP_MSI_DEVID capability advertises the requirement to provide 292562306a36Sopenharmony_ci the device ID. If this capability is not available, userspace 292662306a36Sopenharmony_ci should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail. 292762306a36Sopenharmony_ci 292862306a36Sopenharmony_ciIf KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier 292962306a36Sopenharmony_cifor the device that wrote the MSI message. For PCI, this is usually a 293062306a36Sopenharmony_ciBFD identifier in the lower 16 bits. 293162306a36Sopenharmony_ci 293262306a36Sopenharmony_ciOn x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS 293362306a36Sopenharmony_cifeature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled, 293462306a36Sopenharmony_ciaddress_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of 293562306a36Sopenharmony_ciaddress_hi must be zero. 293662306a36Sopenharmony_ci 293762306a36Sopenharmony_ci 293862306a36Sopenharmony_ci4.71 KVM_CREATE_PIT2 293962306a36Sopenharmony_ci-------------------- 294062306a36Sopenharmony_ci 294162306a36Sopenharmony_ci:Capability: KVM_CAP_PIT2 294262306a36Sopenharmony_ci:Architectures: x86 294362306a36Sopenharmony_ci:Type: vm ioctl 294462306a36Sopenharmony_ci:Parameters: struct kvm_pit_config (in) 294562306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 294662306a36Sopenharmony_ci 294762306a36Sopenharmony_ciCreates an in-kernel device model for the i8254 PIT. This call is only valid 294862306a36Sopenharmony_ciafter enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following 294962306a36Sopenharmony_ciparameters have to be passed:: 295062306a36Sopenharmony_ci 295162306a36Sopenharmony_ci struct kvm_pit_config { 295262306a36Sopenharmony_ci __u32 flags; 295362306a36Sopenharmony_ci __u32 pad[15]; 295462306a36Sopenharmony_ci }; 295562306a36Sopenharmony_ci 295662306a36Sopenharmony_ciValid flags are:: 295762306a36Sopenharmony_ci 295862306a36Sopenharmony_ci #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */ 295962306a36Sopenharmony_ci 296062306a36Sopenharmony_ciPIT timer interrupts may use a per-VM kernel thread for injection. If it 296162306a36Sopenharmony_ciexists, this thread will have a name of the following pattern:: 296262306a36Sopenharmony_ci 296362306a36Sopenharmony_ci kvm-pit/<owner-process-pid> 296462306a36Sopenharmony_ci 296562306a36Sopenharmony_ciWhen running a guest with elevated priorities, the scheduling parameters of 296662306a36Sopenharmony_cithis thread may have to be adjusted accordingly. 296762306a36Sopenharmony_ci 296862306a36Sopenharmony_ciThis IOCTL replaces the obsolete KVM_CREATE_PIT. 296962306a36Sopenharmony_ci 297062306a36Sopenharmony_ci 297162306a36Sopenharmony_ci4.72 KVM_GET_PIT2 297262306a36Sopenharmony_ci----------------- 297362306a36Sopenharmony_ci 297462306a36Sopenharmony_ci:Capability: KVM_CAP_PIT_STATE2 297562306a36Sopenharmony_ci:Architectures: x86 297662306a36Sopenharmony_ci:Type: vm ioctl 297762306a36Sopenharmony_ci:Parameters: struct kvm_pit_state2 (out) 297862306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 297962306a36Sopenharmony_ci 298062306a36Sopenharmony_ciRetrieves the state of the in-kernel PIT model. Only valid after 298162306a36Sopenharmony_ciKVM_CREATE_PIT2. The state is returned in the following structure:: 298262306a36Sopenharmony_ci 298362306a36Sopenharmony_ci struct kvm_pit_state2 { 298462306a36Sopenharmony_ci struct kvm_pit_channel_state channels[3]; 298562306a36Sopenharmony_ci __u32 flags; 298662306a36Sopenharmony_ci __u32 reserved[9]; 298762306a36Sopenharmony_ci }; 298862306a36Sopenharmony_ci 298962306a36Sopenharmony_ciValid flags are:: 299062306a36Sopenharmony_ci 299162306a36Sopenharmony_ci /* disable PIT in HPET legacy mode */ 299262306a36Sopenharmony_ci #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 299362306a36Sopenharmony_ci /* speaker port data bit enabled */ 299462306a36Sopenharmony_ci #define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002 299562306a36Sopenharmony_ci 299662306a36Sopenharmony_ciThis IOCTL replaces the obsolete KVM_GET_PIT. 299762306a36Sopenharmony_ci 299862306a36Sopenharmony_ci 299962306a36Sopenharmony_ci4.73 KVM_SET_PIT2 300062306a36Sopenharmony_ci----------------- 300162306a36Sopenharmony_ci 300262306a36Sopenharmony_ci:Capability: KVM_CAP_PIT_STATE2 300362306a36Sopenharmony_ci:Architectures: x86 300462306a36Sopenharmony_ci:Type: vm ioctl 300562306a36Sopenharmony_ci:Parameters: struct kvm_pit_state2 (in) 300662306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 300762306a36Sopenharmony_ci 300862306a36Sopenharmony_ciSets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2. 300962306a36Sopenharmony_ciSee KVM_GET_PIT2 for details on struct kvm_pit_state2. 301062306a36Sopenharmony_ci 301162306a36Sopenharmony_ciThis IOCTL replaces the obsolete KVM_SET_PIT. 301262306a36Sopenharmony_ci 301362306a36Sopenharmony_ci 301462306a36Sopenharmony_ci4.74 KVM_PPC_GET_SMMU_INFO 301562306a36Sopenharmony_ci-------------------------- 301662306a36Sopenharmony_ci 301762306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_GET_SMMU_INFO 301862306a36Sopenharmony_ci:Architectures: powerpc 301962306a36Sopenharmony_ci:Type: vm ioctl 302062306a36Sopenharmony_ci:Parameters: None 302162306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 302262306a36Sopenharmony_ci 302362306a36Sopenharmony_ciThis populates and returns a structure describing the features of 302462306a36Sopenharmony_cithe "Server" class MMU emulation supported by KVM. 302562306a36Sopenharmony_ciThis can in turn be used by userspace to generate the appropriate 302662306a36Sopenharmony_cidevice-tree properties for the guest operating system. 302762306a36Sopenharmony_ci 302862306a36Sopenharmony_ciThe structure contains some global information, followed by an 302962306a36Sopenharmony_ciarray of supported segment page sizes:: 303062306a36Sopenharmony_ci 303162306a36Sopenharmony_ci struct kvm_ppc_smmu_info { 303262306a36Sopenharmony_ci __u64 flags; 303362306a36Sopenharmony_ci __u32 slb_size; 303462306a36Sopenharmony_ci __u32 pad; 303562306a36Sopenharmony_ci struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 303662306a36Sopenharmony_ci }; 303762306a36Sopenharmony_ci 303862306a36Sopenharmony_ciThe supported flags are: 303962306a36Sopenharmony_ci 304062306a36Sopenharmony_ci - KVM_PPC_PAGE_SIZES_REAL: 304162306a36Sopenharmony_ci When that flag is set, guest page sizes must "fit" the backing 304262306a36Sopenharmony_ci store page sizes. When not set, any page size in the list can 304362306a36Sopenharmony_ci be used regardless of how they are backed by userspace. 304462306a36Sopenharmony_ci 304562306a36Sopenharmony_ci - KVM_PPC_1T_SEGMENTS 304662306a36Sopenharmony_ci The emulated MMU supports 1T segments in addition to the 304762306a36Sopenharmony_ci standard 256M ones. 304862306a36Sopenharmony_ci 304962306a36Sopenharmony_ci - KVM_PPC_NO_HASH 305062306a36Sopenharmony_ci This flag indicates that HPT guests are not supported by KVM, 305162306a36Sopenharmony_ci thus all guests must use radix MMU mode. 305262306a36Sopenharmony_ci 305362306a36Sopenharmony_ciThe "slb_size" field indicates how many SLB entries are supported 305462306a36Sopenharmony_ci 305562306a36Sopenharmony_ciThe "sps" array contains 8 entries indicating the supported base 305662306a36Sopenharmony_cipage sizes for a segment in increasing order. Each entry is defined 305762306a36Sopenharmony_cias follow:: 305862306a36Sopenharmony_ci 305962306a36Sopenharmony_ci struct kvm_ppc_one_seg_page_size { 306062306a36Sopenharmony_ci __u32 page_shift; /* Base page shift of segment (or 0) */ 306162306a36Sopenharmony_ci __u32 slb_enc; /* SLB encoding for BookS */ 306262306a36Sopenharmony_ci struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 306362306a36Sopenharmony_ci }; 306462306a36Sopenharmony_ci 306562306a36Sopenharmony_ciAn entry with a "page_shift" of 0 is unused. Because the array is 306662306a36Sopenharmony_ciorganized in increasing order, a lookup can stop when encoutering 306762306a36Sopenharmony_cisuch an entry. 306862306a36Sopenharmony_ci 306962306a36Sopenharmony_ciThe "slb_enc" field provides the encoding to use in the SLB for the 307062306a36Sopenharmony_cipage size. The bits are in positions such as the value can directly 307162306a36Sopenharmony_cibe OR'ed into the "vsid" argument of the slbmte instruction. 307262306a36Sopenharmony_ci 307362306a36Sopenharmony_ciThe "enc" array is a list which for each of those segment base page 307462306a36Sopenharmony_cisize provides the list of supported actual page sizes (which can be 307562306a36Sopenharmony_cionly larger or equal to the base page size), along with the 307662306a36Sopenharmony_cicorresponding encoding in the hash PTE. Similarly, the array is 307762306a36Sopenharmony_ci8 entries sorted by increasing sizes and an entry with a "0" shift 307862306a36Sopenharmony_ciis an empty entry and a terminator:: 307962306a36Sopenharmony_ci 308062306a36Sopenharmony_ci struct kvm_ppc_one_page_size { 308162306a36Sopenharmony_ci __u32 page_shift; /* Page shift (or 0) */ 308262306a36Sopenharmony_ci __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 308362306a36Sopenharmony_ci }; 308462306a36Sopenharmony_ci 308562306a36Sopenharmony_ciThe "pte_enc" field provides a value that can OR'ed into the hash 308662306a36Sopenharmony_ciPTE's RPN field (ie, it needs to be shifted left by 12 to OR it 308762306a36Sopenharmony_ciinto the hash PTE second double word). 308862306a36Sopenharmony_ci 308962306a36Sopenharmony_ci4.75 KVM_IRQFD 309062306a36Sopenharmony_ci-------------- 309162306a36Sopenharmony_ci 309262306a36Sopenharmony_ci:Capability: KVM_CAP_IRQFD 309362306a36Sopenharmony_ci:Architectures: x86 s390 arm64 309462306a36Sopenharmony_ci:Type: vm ioctl 309562306a36Sopenharmony_ci:Parameters: struct kvm_irqfd (in) 309662306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 309762306a36Sopenharmony_ci 309862306a36Sopenharmony_ciAllows setting an eventfd to directly trigger a guest interrupt. 309962306a36Sopenharmony_cikvm_irqfd.fd specifies the file descriptor to use as the eventfd and 310062306a36Sopenharmony_cikvm_irqfd.gsi specifies the irqchip pin toggled by this event. When 310162306a36Sopenharmony_cian event is triggered on the eventfd, an interrupt is injected into 310262306a36Sopenharmony_cithe guest using the specified gsi pin. The irqfd is removed using 310362306a36Sopenharmony_cithe KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd 310462306a36Sopenharmony_ciand kvm_irqfd.gsi. 310562306a36Sopenharmony_ci 310662306a36Sopenharmony_ciWith KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify 310762306a36Sopenharmony_cimechanism allowing emulation of level-triggered, irqfd-based 310862306a36Sopenharmony_ciinterrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an 310962306a36Sopenharmony_ciadditional eventfd in the kvm_irqfd.resamplefd field. When operating 311062306a36Sopenharmony_ciin resample mode, posting of an interrupt through kvm_irq.fd asserts 311162306a36Sopenharmony_cithe specified gsi in the irqchip. When the irqchip is resampled, such 311262306a36Sopenharmony_cias from an EOI, the gsi is de-asserted and the user is notified via 311362306a36Sopenharmony_cikvm_irqfd.resamplefd. It is the user's responsibility to re-queue 311462306a36Sopenharmony_cithe interrupt if the device making use of it still requires service. 311562306a36Sopenharmony_ciNote that closing the resamplefd is not sufficient to disable the 311662306a36Sopenharmony_ciirqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment 311762306a36Sopenharmony_ciand need not be specified with KVM_IRQFD_FLAG_DEASSIGN. 311862306a36Sopenharmony_ci 311962306a36Sopenharmony_ciOn arm64, gsi routing being supported, the following can happen: 312062306a36Sopenharmony_ci 312162306a36Sopenharmony_ci- in case no routing entry is associated to this gsi, injection fails 312262306a36Sopenharmony_ci- in case the gsi is associated to an irqchip routing entry, 312362306a36Sopenharmony_ci irqchip.pin + 32 corresponds to the injected SPI ID. 312462306a36Sopenharmony_ci- in case the gsi is associated to an MSI routing entry, the MSI 312562306a36Sopenharmony_ci message and device ID are translated into an LPI (support restricted 312662306a36Sopenharmony_ci to GICv3 ITS in-kernel emulation). 312762306a36Sopenharmony_ci 312862306a36Sopenharmony_ci4.76 KVM_PPC_ALLOCATE_HTAB 312962306a36Sopenharmony_ci-------------------------- 313062306a36Sopenharmony_ci 313162306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_ALLOC_HTAB 313262306a36Sopenharmony_ci:Architectures: powerpc 313362306a36Sopenharmony_ci:Type: vm ioctl 313462306a36Sopenharmony_ci:Parameters: Pointer to u32 containing hash table order (in/out) 313562306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 313662306a36Sopenharmony_ci 313762306a36Sopenharmony_ciThis requests the host kernel to allocate an MMU hash table for a 313862306a36Sopenharmony_ciguest using the PAPR paravirtualization interface. This only does 313962306a36Sopenharmony_cianything if the kernel is configured to use the Book 3S HV style of 314062306a36Sopenharmony_civirtualization. Otherwise the capability doesn't exist and the ioctl 314162306a36Sopenharmony_cireturns an ENOTTY error. The rest of this description assumes Book 3S 314262306a36Sopenharmony_ciHV. 314362306a36Sopenharmony_ci 314462306a36Sopenharmony_ciThere must be no vcpus running when this ioctl is called; if there 314562306a36Sopenharmony_ciare, it will do nothing and return an EBUSY error. 314662306a36Sopenharmony_ci 314762306a36Sopenharmony_ciThe parameter is a pointer to a 32-bit unsigned integer variable 314862306a36Sopenharmony_cicontaining the order (log base 2) of the desired size of the hash 314962306a36Sopenharmony_citable, which must be between 18 and 46. On successful return from the 315062306a36Sopenharmony_ciioctl, the value will not be changed by the kernel. 315162306a36Sopenharmony_ci 315262306a36Sopenharmony_ciIf no hash table has been allocated when any vcpu is asked to run 315362306a36Sopenharmony_ci(with the KVM_RUN ioctl), the host kernel will allocate a 315462306a36Sopenharmony_cidefault-sized hash table (16 MB). 315562306a36Sopenharmony_ci 315662306a36Sopenharmony_ciIf this ioctl is called when a hash table has already been allocated, 315762306a36Sopenharmony_ciwith a different order from the existing hash table, the existing hash 315862306a36Sopenharmony_citable will be freed and a new one allocated. If this is ioctl is 315962306a36Sopenharmony_cicalled when a hash table has already been allocated of the same order 316062306a36Sopenharmony_cias specified, the kernel will clear out the existing hash table (zero 316162306a36Sopenharmony_ciall HPTEs). In either case, if the guest is using the virtualized 316262306a36Sopenharmony_cireal-mode area (VRMA) facility, the kernel will re-create the VMRA 316362306a36Sopenharmony_ciHPTEs on the next KVM_RUN of any vcpu. 316462306a36Sopenharmony_ci 316562306a36Sopenharmony_ci4.77 KVM_S390_INTERRUPT 316662306a36Sopenharmony_ci----------------------- 316762306a36Sopenharmony_ci 316862306a36Sopenharmony_ci:Capability: basic 316962306a36Sopenharmony_ci:Architectures: s390 317062306a36Sopenharmony_ci:Type: vm ioctl, vcpu ioctl 317162306a36Sopenharmony_ci:Parameters: struct kvm_s390_interrupt (in) 317262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 317362306a36Sopenharmony_ci 317462306a36Sopenharmony_ciAllows to inject an interrupt to the guest. Interrupts can be floating 317562306a36Sopenharmony_ci(vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type. 317662306a36Sopenharmony_ci 317762306a36Sopenharmony_ciInterrupt parameters are passed via kvm_s390_interrupt:: 317862306a36Sopenharmony_ci 317962306a36Sopenharmony_ci struct kvm_s390_interrupt { 318062306a36Sopenharmony_ci __u32 type; 318162306a36Sopenharmony_ci __u32 parm; 318262306a36Sopenharmony_ci __u64 parm64; 318362306a36Sopenharmony_ci }; 318462306a36Sopenharmony_ci 318562306a36Sopenharmony_citype can be one of the following: 318662306a36Sopenharmony_ci 318762306a36Sopenharmony_ciKVM_S390_SIGP_STOP (vcpu) 318862306a36Sopenharmony_ci - sigp stop; optional flags in parm 318962306a36Sopenharmony_ciKVM_S390_PROGRAM_INT (vcpu) 319062306a36Sopenharmony_ci - program check; code in parm 319162306a36Sopenharmony_ciKVM_S390_SIGP_SET_PREFIX (vcpu) 319262306a36Sopenharmony_ci - sigp set prefix; prefix address in parm 319362306a36Sopenharmony_ciKVM_S390_RESTART (vcpu) 319462306a36Sopenharmony_ci - restart 319562306a36Sopenharmony_ciKVM_S390_INT_CLOCK_COMP (vcpu) 319662306a36Sopenharmony_ci - clock comparator interrupt 319762306a36Sopenharmony_ciKVM_S390_INT_CPU_TIMER (vcpu) 319862306a36Sopenharmony_ci - CPU timer interrupt 319962306a36Sopenharmony_ciKVM_S390_INT_VIRTIO (vm) 320062306a36Sopenharmony_ci - virtio external interrupt; external interrupt 320162306a36Sopenharmony_ci parameters in parm and parm64 320262306a36Sopenharmony_ciKVM_S390_INT_SERVICE (vm) 320362306a36Sopenharmony_ci - sclp external interrupt; sclp parameter in parm 320462306a36Sopenharmony_ciKVM_S390_INT_EMERGENCY (vcpu) 320562306a36Sopenharmony_ci - sigp emergency; source cpu in parm 320662306a36Sopenharmony_ciKVM_S390_INT_EXTERNAL_CALL (vcpu) 320762306a36Sopenharmony_ci - sigp external call; source cpu in parm 320862306a36Sopenharmony_ciKVM_S390_INT_IO(ai,cssid,ssid,schid) (vm) 320962306a36Sopenharmony_ci - compound value to indicate an 321062306a36Sopenharmony_ci I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel); 321162306a36Sopenharmony_ci I/O interruption parameters in parm (subchannel) and parm64 (intparm, 321262306a36Sopenharmony_ci interruption subclass) 321362306a36Sopenharmony_ciKVM_S390_MCHK (vm, vcpu) 321462306a36Sopenharmony_ci - machine check interrupt; cr 14 bits in parm, machine check interrupt 321562306a36Sopenharmony_ci code in parm64 (note that machine checks needing further payload are not 321662306a36Sopenharmony_ci supported by this ioctl) 321762306a36Sopenharmony_ci 321862306a36Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 321962306a36Sopenharmony_ci 322062306a36Sopenharmony_ci4.78 KVM_PPC_GET_HTAB_FD 322162306a36Sopenharmony_ci------------------------ 322262306a36Sopenharmony_ci 322362306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_HTAB_FD 322462306a36Sopenharmony_ci:Architectures: powerpc 322562306a36Sopenharmony_ci:Type: vm ioctl 322662306a36Sopenharmony_ci:Parameters: Pointer to struct kvm_get_htab_fd (in) 322762306a36Sopenharmony_ci:Returns: file descriptor number (>= 0) on success, -1 on error 322862306a36Sopenharmony_ci 322962306a36Sopenharmony_ciThis returns a file descriptor that can be used either to read out the 323062306a36Sopenharmony_cientries in the guest's hashed page table (HPT), or to write entries to 323162306a36Sopenharmony_ciinitialize the HPT. The returned fd can only be written to if the 323262306a36Sopenharmony_ciKVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and 323362306a36Sopenharmony_cican only be read if that bit is clear. The argument struct looks like 323462306a36Sopenharmony_cithis:: 323562306a36Sopenharmony_ci 323662306a36Sopenharmony_ci /* For KVM_PPC_GET_HTAB_FD */ 323762306a36Sopenharmony_ci struct kvm_get_htab_fd { 323862306a36Sopenharmony_ci __u64 flags; 323962306a36Sopenharmony_ci __u64 start_index; 324062306a36Sopenharmony_ci __u64 reserved[2]; 324162306a36Sopenharmony_ci }; 324262306a36Sopenharmony_ci 324362306a36Sopenharmony_ci /* Values for kvm_get_htab_fd.flags */ 324462306a36Sopenharmony_ci #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1) 324562306a36Sopenharmony_ci #define KVM_GET_HTAB_WRITE ((__u64)0x2) 324662306a36Sopenharmony_ci 324762306a36Sopenharmony_ciThe 'start_index' field gives the index in the HPT of the entry at 324862306a36Sopenharmony_ciwhich to start reading. It is ignored when writing. 324962306a36Sopenharmony_ci 325062306a36Sopenharmony_ciReads on the fd will initially supply information about all 325162306a36Sopenharmony_ci"interesting" HPT entries. Interesting entries are those with the 325262306a36Sopenharmony_cibolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise 325362306a36Sopenharmony_ciall entries. When the end of the HPT is reached, the read() will 325462306a36Sopenharmony_cireturn. If read() is called again on the fd, it will start again from 325562306a36Sopenharmony_cithe beginning of the HPT, but will only return HPT entries that have 325662306a36Sopenharmony_cichanged since they were last read. 325762306a36Sopenharmony_ci 325862306a36Sopenharmony_ciData read or written is structured as a header (8 bytes) followed by a 325962306a36Sopenharmony_ciseries of valid HPT entries (16 bytes) each. The header indicates how 326062306a36Sopenharmony_cimany valid HPT entries there are and how many invalid entries follow 326162306a36Sopenharmony_cithe valid entries. The invalid entries are not represented explicitly 326262306a36Sopenharmony_ciin the stream. The header format is:: 326362306a36Sopenharmony_ci 326462306a36Sopenharmony_ci struct kvm_get_htab_header { 326562306a36Sopenharmony_ci __u32 index; 326662306a36Sopenharmony_ci __u16 n_valid; 326762306a36Sopenharmony_ci __u16 n_invalid; 326862306a36Sopenharmony_ci }; 326962306a36Sopenharmony_ci 327062306a36Sopenharmony_ciWrites to the fd create HPT entries starting at the index given in the 327162306a36Sopenharmony_ciheader; first 'n_valid' valid entries with contents from the data 327262306a36Sopenharmony_ciwritten, then 'n_invalid' invalid entries, invalidating any previously 327362306a36Sopenharmony_civalid entries found. 327462306a36Sopenharmony_ci 327562306a36Sopenharmony_ci4.79 KVM_CREATE_DEVICE 327662306a36Sopenharmony_ci---------------------- 327762306a36Sopenharmony_ci 327862306a36Sopenharmony_ci:Capability: KVM_CAP_DEVICE_CTRL 327962306a36Sopenharmony_ci:Architectures: all 328062306a36Sopenharmony_ci:Type: vm ioctl 328162306a36Sopenharmony_ci:Parameters: struct kvm_create_device (in/out) 328262306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 328362306a36Sopenharmony_ci 328462306a36Sopenharmony_ciErrors: 328562306a36Sopenharmony_ci 328662306a36Sopenharmony_ci ====== ======================================================= 328762306a36Sopenharmony_ci ENODEV The device type is unknown or unsupported 328862306a36Sopenharmony_ci EEXIST Device already created, and this type of device may not 328962306a36Sopenharmony_ci be instantiated multiple times 329062306a36Sopenharmony_ci ====== ======================================================= 329162306a36Sopenharmony_ci 329262306a36Sopenharmony_ci Other error conditions may be defined by individual device types or 329362306a36Sopenharmony_ci have their standard meanings. 329462306a36Sopenharmony_ci 329562306a36Sopenharmony_ciCreates an emulated device in the kernel. The file descriptor returned 329662306a36Sopenharmony_ciin fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR. 329762306a36Sopenharmony_ci 329862306a36Sopenharmony_ciIf the KVM_CREATE_DEVICE_TEST flag is set, only test whether the 329962306a36Sopenharmony_cidevice type is supported (not necessarily whether it can be created 330062306a36Sopenharmony_ciin the current vm). 330162306a36Sopenharmony_ci 330262306a36Sopenharmony_ciIndividual devices should not define flags. Attributes should be used 330362306a36Sopenharmony_cifor specifying any behavior that is not implied by the device type 330462306a36Sopenharmony_cinumber. 330562306a36Sopenharmony_ci 330662306a36Sopenharmony_ci:: 330762306a36Sopenharmony_ci 330862306a36Sopenharmony_ci struct kvm_create_device { 330962306a36Sopenharmony_ci __u32 type; /* in: KVM_DEV_TYPE_xxx */ 331062306a36Sopenharmony_ci __u32 fd; /* out: device handle */ 331162306a36Sopenharmony_ci __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 331262306a36Sopenharmony_ci }; 331362306a36Sopenharmony_ci 331462306a36Sopenharmony_ci4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR 331562306a36Sopenharmony_ci-------------------------------------------- 331662306a36Sopenharmony_ci 331762306a36Sopenharmony_ci:Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, 331862306a36Sopenharmony_ci KVM_CAP_VCPU_ATTRIBUTES for vcpu device 331962306a36Sopenharmony_ci KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device (no set) 332062306a36Sopenharmony_ci:Architectures: x86, arm64, s390 332162306a36Sopenharmony_ci:Type: device ioctl, vm ioctl, vcpu ioctl 332262306a36Sopenharmony_ci:Parameters: struct kvm_device_attr 332362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 332462306a36Sopenharmony_ci 332562306a36Sopenharmony_ciErrors: 332662306a36Sopenharmony_ci 332762306a36Sopenharmony_ci ===== ============================================================= 332862306a36Sopenharmony_ci ENXIO The group or attribute is unknown/unsupported for this device 332962306a36Sopenharmony_ci or hardware support is missing. 333062306a36Sopenharmony_ci EPERM The attribute cannot (currently) be accessed this way 333162306a36Sopenharmony_ci (e.g. read-only attribute, or attribute that only makes 333262306a36Sopenharmony_ci sense when the device is in a different state) 333362306a36Sopenharmony_ci ===== ============================================================= 333462306a36Sopenharmony_ci 333562306a36Sopenharmony_ci Other error conditions may be defined by individual device types. 333662306a36Sopenharmony_ci 333762306a36Sopenharmony_ciGets/sets a specified piece of device configuration and/or state. The 333862306a36Sopenharmony_cisemantics are device-specific. See individual device documentation in 333962306a36Sopenharmony_cithe "devices" directory. As with ONE_REG, the size of the data 334062306a36Sopenharmony_citransferred is defined by the particular attribute. 334162306a36Sopenharmony_ci 334262306a36Sopenharmony_ci:: 334362306a36Sopenharmony_ci 334462306a36Sopenharmony_ci struct kvm_device_attr { 334562306a36Sopenharmony_ci __u32 flags; /* no flags currently defined */ 334662306a36Sopenharmony_ci __u32 group; /* device-defined */ 334762306a36Sopenharmony_ci __u64 attr; /* group-defined */ 334862306a36Sopenharmony_ci __u64 addr; /* userspace address of attr data */ 334962306a36Sopenharmony_ci }; 335062306a36Sopenharmony_ci 335162306a36Sopenharmony_ci4.81 KVM_HAS_DEVICE_ATTR 335262306a36Sopenharmony_ci------------------------ 335362306a36Sopenharmony_ci 335462306a36Sopenharmony_ci:Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device, 335562306a36Sopenharmony_ci KVM_CAP_VCPU_ATTRIBUTES for vcpu device 335662306a36Sopenharmony_ci KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device 335762306a36Sopenharmony_ci:Type: device ioctl, vm ioctl, vcpu ioctl 335862306a36Sopenharmony_ci:Parameters: struct kvm_device_attr 335962306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 336062306a36Sopenharmony_ci 336162306a36Sopenharmony_ciErrors: 336262306a36Sopenharmony_ci 336362306a36Sopenharmony_ci ===== ============================================================= 336462306a36Sopenharmony_ci ENXIO The group or attribute is unknown/unsupported for this device 336562306a36Sopenharmony_ci or hardware support is missing. 336662306a36Sopenharmony_ci ===== ============================================================= 336762306a36Sopenharmony_ci 336862306a36Sopenharmony_ciTests whether a device supports a particular attribute. A successful 336962306a36Sopenharmony_cireturn indicates the attribute is implemented. It does not necessarily 337062306a36Sopenharmony_ciindicate that the attribute can be read or written in the device's 337162306a36Sopenharmony_cicurrent state. "addr" is ignored. 337262306a36Sopenharmony_ci 337362306a36Sopenharmony_ci4.82 KVM_ARM_VCPU_INIT 337462306a36Sopenharmony_ci---------------------- 337562306a36Sopenharmony_ci 337662306a36Sopenharmony_ci:Capability: basic 337762306a36Sopenharmony_ci:Architectures: arm64 337862306a36Sopenharmony_ci:Type: vcpu ioctl 337962306a36Sopenharmony_ci:Parameters: struct kvm_vcpu_init (in) 338062306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 338162306a36Sopenharmony_ci 338262306a36Sopenharmony_ciErrors: 338362306a36Sopenharmony_ci 338462306a36Sopenharmony_ci ====== ================================================================= 338562306a36Sopenharmony_ci EINVAL the target is unknown, or the combination of features is invalid. 338662306a36Sopenharmony_ci ENOENT a features bit specified is unknown. 338762306a36Sopenharmony_ci ====== ================================================================= 338862306a36Sopenharmony_ci 338962306a36Sopenharmony_ciThis tells KVM what type of CPU to present to the guest, and what 339062306a36Sopenharmony_cioptional features it should have. This will cause a reset of the cpu 339162306a36Sopenharmony_ciregisters to their initial values. If this is not called, KVM_RUN will 339262306a36Sopenharmony_cireturn ENOEXEC for that vcpu. 339362306a36Sopenharmony_ci 339462306a36Sopenharmony_ciThe initial values are defined as: 339562306a36Sopenharmony_ci - Processor state: 339662306a36Sopenharmony_ci * AArch64: EL1h, D, A, I and F bits set. All other bits 339762306a36Sopenharmony_ci are cleared. 339862306a36Sopenharmony_ci * AArch32: SVC, A, I and F bits set. All other bits are 339962306a36Sopenharmony_ci cleared. 340062306a36Sopenharmony_ci - General Purpose registers, including PC and SP: set to 0 340162306a36Sopenharmony_ci - FPSIMD/NEON registers: set to 0 340262306a36Sopenharmony_ci - SVE registers: set to 0 340362306a36Sopenharmony_ci - System registers: Reset to their architecturally defined 340462306a36Sopenharmony_ci values as for a warm reset to EL1 (resp. SVC) 340562306a36Sopenharmony_ci 340662306a36Sopenharmony_ciNote that because some registers reflect machine topology, all vcpus 340762306a36Sopenharmony_cishould be created before this ioctl is invoked. 340862306a36Sopenharmony_ci 340962306a36Sopenharmony_ciUserspace can call this function multiple times for a given vcpu, including 341062306a36Sopenharmony_ciafter the vcpu has been run. This will reset the vcpu to its initial 341162306a36Sopenharmony_cistate. All calls to this function after the initial call must use the same 341262306a36Sopenharmony_citarget and same set of feature flags, otherwise EINVAL will be returned. 341362306a36Sopenharmony_ci 341462306a36Sopenharmony_ciPossible features: 341562306a36Sopenharmony_ci 341662306a36Sopenharmony_ci - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state. 341762306a36Sopenharmony_ci Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on 341862306a36Sopenharmony_ci and execute guest code when KVM_RUN is called. 341962306a36Sopenharmony_ci - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode. 342062306a36Sopenharmony_ci Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only). 342162306a36Sopenharmony_ci - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision 342262306a36Sopenharmony_ci backward compatible with v0.2) for the CPU. 342362306a36Sopenharmony_ci Depends on KVM_CAP_ARM_PSCI_0_2. 342462306a36Sopenharmony_ci - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU. 342562306a36Sopenharmony_ci Depends on KVM_CAP_ARM_PMU_V3. 342662306a36Sopenharmony_ci 342762306a36Sopenharmony_ci - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication 342862306a36Sopenharmony_ci for arm64 only. 342962306a36Sopenharmony_ci Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS. 343062306a36Sopenharmony_ci If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are 343162306a36Sopenharmony_ci both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and 343262306a36Sopenharmony_ci KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be 343362306a36Sopenharmony_ci requested. 343462306a36Sopenharmony_ci 343562306a36Sopenharmony_ci - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication 343662306a36Sopenharmony_ci for arm64 only. 343762306a36Sopenharmony_ci Depends on KVM_CAP_ARM_PTRAUTH_GENERIC. 343862306a36Sopenharmony_ci If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are 343962306a36Sopenharmony_ci both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and 344062306a36Sopenharmony_ci KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be 344162306a36Sopenharmony_ci requested. 344262306a36Sopenharmony_ci 344362306a36Sopenharmony_ci - KVM_ARM_VCPU_SVE: Enables SVE for the CPU (arm64 only). 344462306a36Sopenharmony_ci Depends on KVM_CAP_ARM_SVE. 344562306a36Sopenharmony_ci Requires KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE): 344662306a36Sopenharmony_ci 344762306a36Sopenharmony_ci * After KVM_ARM_VCPU_INIT: 344862306a36Sopenharmony_ci 344962306a36Sopenharmony_ci - KVM_REG_ARM64_SVE_VLS may be read using KVM_GET_ONE_REG: the 345062306a36Sopenharmony_ci initial value of this pseudo-register indicates the best set of 345162306a36Sopenharmony_ci vector lengths possible for a vcpu on this host. 345262306a36Sopenharmony_ci 345362306a36Sopenharmony_ci * Before KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE): 345462306a36Sopenharmony_ci 345562306a36Sopenharmony_ci - KVM_RUN and KVM_GET_REG_LIST are not available; 345662306a36Sopenharmony_ci 345762306a36Sopenharmony_ci - KVM_GET_ONE_REG and KVM_SET_ONE_REG cannot be used to access 345862306a36Sopenharmony_ci the scalable archietctural SVE registers 345962306a36Sopenharmony_ci KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() or 346062306a36Sopenharmony_ci KVM_REG_ARM64_SVE_FFR; 346162306a36Sopenharmony_ci 346262306a36Sopenharmony_ci - KVM_REG_ARM64_SVE_VLS may optionally be written using 346362306a36Sopenharmony_ci KVM_SET_ONE_REG, to modify the set of vector lengths available 346462306a36Sopenharmony_ci for the vcpu. 346562306a36Sopenharmony_ci 346662306a36Sopenharmony_ci * After KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE): 346762306a36Sopenharmony_ci 346862306a36Sopenharmony_ci - the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can 346962306a36Sopenharmony_ci no longer be written using KVM_SET_ONE_REG. 347062306a36Sopenharmony_ci 347162306a36Sopenharmony_ci4.83 KVM_ARM_PREFERRED_TARGET 347262306a36Sopenharmony_ci----------------------------- 347362306a36Sopenharmony_ci 347462306a36Sopenharmony_ci:Capability: basic 347562306a36Sopenharmony_ci:Architectures: arm64 347662306a36Sopenharmony_ci:Type: vm ioctl 347762306a36Sopenharmony_ci:Parameters: struct kvm_vcpu_init (out) 347862306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 347962306a36Sopenharmony_ci 348062306a36Sopenharmony_ciErrors: 348162306a36Sopenharmony_ci 348262306a36Sopenharmony_ci ====== ========================================== 348362306a36Sopenharmony_ci ENODEV no preferred target available for the host 348462306a36Sopenharmony_ci ====== ========================================== 348562306a36Sopenharmony_ci 348662306a36Sopenharmony_ciThis queries KVM for preferred CPU target type which can be emulated 348762306a36Sopenharmony_ciby KVM on underlying host. 348862306a36Sopenharmony_ci 348962306a36Sopenharmony_ciThe ioctl returns struct kvm_vcpu_init instance containing information 349062306a36Sopenharmony_ciabout preferred CPU target type and recommended features for it. The 349162306a36Sopenharmony_cikvm_vcpu_init->features bitmap returned will have feature bits set if 349262306a36Sopenharmony_cithe preferred target recommends setting these features, but this is 349362306a36Sopenharmony_cinot mandatory. 349462306a36Sopenharmony_ci 349562306a36Sopenharmony_ciThe information returned by this ioctl can be used to prepare an instance 349662306a36Sopenharmony_ciof struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in 349762306a36Sopenharmony_ciVCPU matching underlying host. 349862306a36Sopenharmony_ci 349962306a36Sopenharmony_ci 350062306a36Sopenharmony_ci4.84 KVM_GET_REG_LIST 350162306a36Sopenharmony_ci--------------------- 350262306a36Sopenharmony_ci 350362306a36Sopenharmony_ci:Capability: basic 350462306a36Sopenharmony_ci:Architectures: arm64, mips, riscv 350562306a36Sopenharmony_ci:Type: vcpu ioctl 350662306a36Sopenharmony_ci:Parameters: struct kvm_reg_list (in/out) 350762306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 350862306a36Sopenharmony_ci 350962306a36Sopenharmony_ciErrors: 351062306a36Sopenharmony_ci 351162306a36Sopenharmony_ci ===== ============================================================== 351262306a36Sopenharmony_ci E2BIG the reg index list is too big to fit in the array specified by 351362306a36Sopenharmony_ci the user (the number required will be written into n). 351462306a36Sopenharmony_ci ===== ============================================================== 351562306a36Sopenharmony_ci 351662306a36Sopenharmony_ci:: 351762306a36Sopenharmony_ci 351862306a36Sopenharmony_ci struct kvm_reg_list { 351962306a36Sopenharmony_ci __u64 n; /* number of registers in reg[] */ 352062306a36Sopenharmony_ci __u64 reg[0]; 352162306a36Sopenharmony_ci }; 352262306a36Sopenharmony_ci 352362306a36Sopenharmony_ciThis ioctl returns the guest registers that are supported for the 352462306a36Sopenharmony_ciKVM_GET_ONE_REG/KVM_SET_ONE_REG calls. 352562306a36Sopenharmony_ci 352662306a36Sopenharmony_ci 352762306a36Sopenharmony_ci4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated) 352862306a36Sopenharmony_ci----------------------------------------- 352962306a36Sopenharmony_ci 353062306a36Sopenharmony_ci:Capability: KVM_CAP_ARM_SET_DEVICE_ADDR 353162306a36Sopenharmony_ci:Architectures: arm64 353262306a36Sopenharmony_ci:Type: vm ioctl 353362306a36Sopenharmony_ci:Parameters: struct kvm_arm_device_address (in) 353462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 353562306a36Sopenharmony_ci 353662306a36Sopenharmony_ciErrors: 353762306a36Sopenharmony_ci 353862306a36Sopenharmony_ci ====== ============================================ 353962306a36Sopenharmony_ci ENODEV The device id is unknown 354062306a36Sopenharmony_ci ENXIO Device not supported on current system 354162306a36Sopenharmony_ci EEXIST Address already set 354262306a36Sopenharmony_ci E2BIG Address outside guest physical address space 354362306a36Sopenharmony_ci EBUSY Address overlaps with other device range 354462306a36Sopenharmony_ci ====== ============================================ 354562306a36Sopenharmony_ci 354662306a36Sopenharmony_ci:: 354762306a36Sopenharmony_ci 354862306a36Sopenharmony_ci struct kvm_arm_device_addr { 354962306a36Sopenharmony_ci __u64 id; 355062306a36Sopenharmony_ci __u64 addr; 355162306a36Sopenharmony_ci }; 355262306a36Sopenharmony_ci 355362306a36Sopenharmony_ciSpecify a device address in the guest's physical address space where guests 355462306a36Sopenharmony_cican access emulated or directly exposed devices, which the host kernel needs 355562306a36Sopenharmony_cito know about. The id field is an architecture specific identifier for a 355662306a36Sopenharmony_cispecific device. 355762306a36Sopenharmony_ci 355862306a36Sopenharmony_ciarm64 divides the id field into two parts, a device id and an 355962306a36Sopenharmony_ciaddress type id specific to the individual device:: 356062306a36Sopenharmony_ci 356162306a36Sopenharmony_ci bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 | 356262306a36Sopenharmony_ci field: | 0x00000000 | device id | addr type id | 356362306a36Sopenharmony_ci 356462306a36Sopenharmony_ciarm64 currently only require this when using the in-kernel GIC 356562306a36Sopenharmony_cisupport for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2 356662306a36Sopenharmony_cias the device id. When setting the base address for the guest's 356762306a36Sopenharmony_cimapping of the VGIC virtual CPU and distributor interface, the ioctl 356862306a36Sopenharmony_cimust be called after calling KVM_CREATE_IRQCHIP, but before calling 356962306a36Sopenharmony_ciKVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the 357062306a36Sopenharmony_cibase addresses will return -EEXIST. 357162306a36Sopenharmony_ci 357262306a36Sopenharmony_ciNote, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API 357362306a36Sopenharmony_cishould be used instead. 357462306a36Sopenharmony_ci 357562306a36Sopenharmony_ci 357662306a36Sopenharmony_ci4.86 KVM_PPC_RTAS_DEFINE_TOKEN 357762306a36Sopenharmony_ci------------------------------ 357862306a36Sopenharmony_ci 357962306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_RTAS 358062306a36Sopenharmony_ci:Architectures: ppc 358162306a36Sopenharmony_ci:Type: vm ioctl 358262306a36Sopenharmony_ci:Parameters: struct kvm_rtas_token_args 358362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 358462306a36Sopenharmony_ci 358562306a36Sopenharmony_ciDefines a token value for a RTAS (Run Time Abstraction Services) 358662306a36Sopenharmony_ciservice in order to allow it to be handled in the kernel. The 358762306a36Sopenharmony_ciargument struct gives the name of the service, which must be the name 358862306a36Sopenharmony_ciof a service that has a kernel-side implementation. If the token 358962306a36Sopenharmony_civalue is non-zero, it will be associated with that service, and 359062306a36Sopenharmony_cisubsequent RTAS calls by the guest specifying that token will be 359162306a36Sopenharmony_cihandled by the kernel. If the token value is 0, then any token 359262306a36Sopenharmony_ciassociated with the service will be forgotten, and subsequent RTAS 359362306a36Sopenharmony_cicalls by the guest for that service will be passed to userspace to be 359462306a36Sopenharmony_cihandled. 359562306a36Sopenharmony_ci 359662306a36Sopenharmony_ci4.87 KVM_SET_GUEST_DEBUG 359762306a36Sopenharmony_ci------------------------ 359862306a36Sopenharmony_ci 359962306a36Sopenharmony_ci:Capability: KVM_CAP_SET_GUEST_DEBUG 360062306a36Sopenharmony_ci:Architectures: x86, s390, ppc, arm64 360162306a36Sopenharmony_ci:Type: vcpu ioctl 360262306a36Sopenharmony_ci:Parameters: struct kvm_guest_debug (in) 360362306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 360462306a36Sopenharmony_ci 360562306a36Sopenharmony_ci:: 360662306a36Sopenharmony_ci 360762306a36Sopenharmony_ci struct kvm_guest_debug { 360862306a36Sopenharmony_ci __u32 control; 360962306a36Sopenharmony_ci __u32 pad; 361062306a36Sopenharmony_ci struct kvm_guest_debug_arch arch; 361162306a36Sopenharmony_ci }; 361262306a36Sopenharmony_ci 361362306a36Sopenharmony_ciSet up the processor specific debug registers and configure vcpu for 361462306a36Sopenharmony_cihandling guest debug events. There are two parts to the structure, the 361562306a36Sopenharmony_cifirst a control bitfield indicates the type of debug events to handle 361662306a36Sopenharmony_ciwhen running. Common control bits are: 361762306a36Sopenharmony_ci 361862306a36Sopenharmony_ci - KVM_GUESTDBG_ENABLE: guest debugging is enabled 361962306a36Sopenharmony_ci - KVM_GUESTDBG_SINGLESTEP: the next run should single-step 362062306a36Sopenharmony_ci 362162306a36Sopenharmony_ciThe top 16 bits of the control field are architecture specific control 362262306a36Sopenharmony_ciflags which can include the following: 362362306a36Sopenharmony_ci 362462306a36Sopenharmony_ci - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64] 362562306a36Sopenharmony_ci - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390] 362662306a36Sopenharmony_ci - KVM_GUESTDBG_USE_HW: using hardware debug events [arm64] 362762306a36Sopenharmony_ci - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86] 362862306a36Sopenharmony_ci - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86] 362962306a36Sopenharmony_ci - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390] 363062306a36Sopenharmony_ci - KVM_GUESTDBG_BLOCKIRQ: avoid injecting interrupts/NMI/SMI [x86] 363162306a36Sopenharmony_ci 363262306a36Sopenharmony_ciFor example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints 363362306a36Sopenharmony_ciare enabled in memory so we need to ensure breakpoint exceptions are 363462306a36Sopenharmony_cicorrectly trapped and the KVM run loop exits at the breakpoint and not 363562306a36Sopenharmony_cirunning off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP 363662306a36Sopenharmony_ciwe need to ensure the guest vCPUs architecture specific registers are 363762306a36Sopenharmony_ciupdated to the correct (supplied) values. 363862306a36Sopenharmony_ci 363962306a36Sopenharmony_ciThe second part of the structure is architecture specific and 364062306a36Sopenharmony_citypically contains a set of debug registers. 364162306a36Sopenharmony_ci 364262306a36Sopenharmony_ciFor arm64 the number of debug registers is implementation defined and 364362306a36Sopenharmony_cican be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and 364462306a36Sopenharmony_ciKVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number 364562306a36Sopenharmony_ciindicating the number of supported registers. 364662306a36Sopenharmony_ci 364762306a36Sopenharmony_ciFor ppc, the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability indicates whether 364862306a36Sopenharmony_cithe single-step debug event (KVM_GUESTDBG_SINGLESTEP) is supported. 364962306a36Sopenharmony_ci 365062306a36Sopenharmony_ciAlso when supported, KVM_CAP_SET_GUEST_DEBUG2 capability indicates the 365162306a36Sopenharmony_cisupported KVM_GUESTDBG_* bits in the control field. 365262306a36Sopenharmony_ci 365362306a36Sopenharmony_ciWhen debug events exit the main run loop with the reason 365462306a36Sopenharmony_ciKVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run 365562306a36Sopenharmony_cistructure containing architecture specific debug information. 365662306a36Sopenharmony_ci 365762306a36Sopenharmony_ci4.88 KVM_GET_EMULATED_CPUID 365862306a36Sopenharmony_ci--------------------------- 365962306a36Sopenharmony_ci 366062306a36Sopenharmony_ci:Capability: KVM_CAP_EXT_EMUL_CPUID 366162306a36Sopenharmony_ci:Architectures: x86 366262306a36Sopenharmony_ci:Type: system ioctl 366362306a36Sopenharmony_ci:Parameters: struct kvm_cpuid2 (in/out) 366462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 366562306a36Sopenharmony_ci 366662306a36Sopenharmony_ci:: 366762306a36Sopenharmony_ci 366862306a36Sopenharmony_ci struct kvm_cpuid2 { 366962306a36Sopenharmony_ci __u32 nent; 367062306a36Sopenharmony_ci __u32 flags; 367162306a36Sopenharmony_ci struct kvm_cpuid_entry2 entries[0]; 367262306a36Sopenharmony_ci }; 367362306a36Sopenharmony_ci 367462306a36Sopenharmony_ciThe member 'flags' is used for passing flags from userspace. 367562306a36Sopenharmony_ci 367662306a36Sopenharmony_ci:: 367762306a36Sopenharmony_ci 367862306a36Sopenharmony_ci #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0) 367962306a36Sopenharmony_ci #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */ 368062306a36Sopenharmony_ci #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */ 368162306a36Sopenharmony_ci 368262306a36Sopenharmony_ci struct kvm_cpuid_entry2 { 368362306a36Sopenharmony_ci __u32 function; 368462306a36Sopenharmony_ci __u32 index; 368562306a36Sopenharmony_ci __u32 flags; 368662306a36Sopenharmony_ci __u32 eax; 368762306a36Sopenharmony_ci __u32 ebx; 368862306a36Sopenharmony_ci __u32 ecx; 368962306a36Sopenharmony_ci __u32 edx; 369062306a36Sopenharmony_ci __u32 padding[3]; 369162306a36Sopenharmony_ci }; 369262306a36Sopenharmony_ci 369362306a36Sopenharmony_ciThis ioctl returns x86 cpuid features which are emulated by 369462306a36Sopenharmony_cikvm.Userspace can use the information returned by this ioctl to query 369562306a36Sopenharmony_ciwhich features are emulated by kvm instead of being present natively. 369662306a36Sopenharmony_ci 369762306a36Sopenharmony_ciUserspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2 369862306a36Sopenharmony_cistructure with the 'nent' field indicating the number of entries in 369962306a36Sopenharmony_cithe variable-size array 'entries'. If the number of entries is too low 370062306a36Sopenharmony_cito describe the cpu capabilities, an error (E2BIG) is returned. If the 370162306a36Sopenharmony_cinumber is too high, the 'nent' field is adjusted and an error (ENOMEM) 370262306a36Sopenharmony_ciis returned. If the number is just right, the 'nent' field is adjusted 370362306a36Sopenharmony_cito the number of valid entries in the 'entries' array, which is then 370462306a36Sopenharmony_cifilled. 370562306a36Sopenharmony_ci 370662306a36Sopenharmony_ciThe entries returned are the set CPUID bits of the respective features 370762306a36Sopenharmony_ciwhich kvm emulates, as returned by the CPUID instruction, with unknown 370862306a36Sopenharmony_cior unsupported feature bits cleared. 370962306a36Sopenharmony_ci 371062306a36Sopenharmony_ciFeatures like x2apic, for example, may not be present in the host cpu 371162306a36Sopenharmony_cibut are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be 371262306a36Sopenharmony_ciemulated efficiently and thus not included here. 371362306a36Sopenharmony_ci 371462306a36Sopenharmony_ciThe fields in each entry are defined as follows: 371562306a36Sopenharmony_ci 371662306a36Sopenharmony_ci function: 371762306a36Sopenharmony_ci the eax value used to obtain the entry 371862306a36Sopenharmony_ci index: 371962306a36Sopenharmony_ci the ecx value used to obtain the entry (for entries that are 372062306a36Sopenharmony_ci affected by ecx) 372162306a36Sopenharmony_ci flags: 372262306a36Sopenharmony_ci an OR of zero or more of the following: 372362306a36Sopenharmony_ci 372462306a36Sopenharmony_ci KVM_CPUID_FLAG_SIGNIFCANT_INDEX: 372562306a36Sopenharmony_ci if the index field is valid 372662306a36Sopenharmony_ci 372762306a36Sopenharmony_ci eax, ebx, ecx, edx: 372862306a36Sopenharmony_ci 372962306a36Sopenharmony_ci the values returned by the cpuid instruction for 373062306a36Sopenharmony_ci this function/index combination 373162306a36Sopenharmony_ci 373262306a36Sopenharmony_ci4.89 KVM_S390_MEM_OP 373362306a36Sopenharmony_ci-------------------- 373462306a36Sopenharmony_ci 373562306a36Sopenharmony_ci:Capability: KVM_CAP_S390_MEM_OP, KVM_CAP_S390_PROTECTED, KVM_CAP_S390_MEM_OP_EXTENSION 373662306a36Sopenharmony_ci:Architectures: s390 373762306a36Sopenharmony_ci:Type: vm ioctl, vcpu ioctl 373862306a36Sopenharmony_ci:Parameters: struct kvm_s390_mem_op (in) 373962306a36Sopenharmony_ci:Returns: = 0 on success, 374062306a36Sopenharmony_ci < 0 on generic error (e.g. -EFAULT or -ENOMEM), 374162306a36Sopenharmony_ci 16 bit program exception code if the access causes such an exception 374262306a36Sopenharmony_ci 374362306a36Sopenharmony_ciRead or write data from/to the VM's memory. 374462306a36Sopenharmony_ciThe KVM_CAP_S390_MEM_OP_EXTENSION capability specifies what functionality is 374562306a36Sopenharmony_cisupported. 374662306a36Sopenharmony_ci 374762306a36Sopenharmony_ciParameters are specified via the following structure:: 374862306a36Sopenharmony_ci 374962306a36Sopenharmony_ci struct kvm_s390_mem_op { 375062306a36Sopenharmony_ci __u64 gaddr; /* the guest address */ 375162306a36Sopenharmony_ci __u64 flags; /* flags */ 375262306a36Sopenharmony_ci __u32 size; /* amount of bytes */ 375362306a36Sopenharmony_ci __u32 op; /* type of operation */ 375462306a36Sopenharmony_ci __u64 buf; /* buffer in userspace */ 375562306a36Sopenharmony_ci union { 375662306a36Sopenharmony_ci struct { 375762306a36Sopenharmony_ci __u8 ar; /* the access register number */ 375862306a36Sopenharmony_ci __u8 key; /* access key, ignored if flag unset */ 375962306a36Sopenharmony_ci __u8 pad1[6]; /* ignored */ 376062306a36Sopenharmony_ci __u64 old_addr; /* ignored if flag unset */ 376162306a36Sopenharmony_ci }; 376262306a36Sopenharmony_ci __u32 sida_offset; /* offset into the sida */ 376362306a36Sopenharmony_ci __u8 reserved[32]; /* ignored */ 376462306a36Sopenharmony_ci }; 376562306a36Sopenharmony_ci }; 376662306a36Sopenharmony_ci 376762306a36Sopenharmony_ciThe start address of the memory region has to be specified in the "gaddr" 376862306a36Sopenharmony_cifield, and the length of the region in the "size" field (which must not 376962306a36Sopenharmony_cibe 0). The maximum value for "size" can be obtained by checking the 377062306a36Sopenharmony_ciKVM_CAP_S390_MEM_OP capability. "buf" is the buffer supplied by the 377162306a36Sopenharmony_ciuserspace application where the read data should be written to for 377262306a36Sopenharmony_cia read access, or where the data that should be written is stored for 377362306a36Sopenharmony_cia write access. The "reserved" field is meant for future extensions. 377462306a36Sopenharmony_ciReserved and unused values are ignored. Future extension that add members must 377562306a36Sopenharmony_ciintroduce new flags. 377662306a36Sopenharmony_ci 377762306a36Sopenharmony_ciThe type of operation is specified in the "op" field. Flags modifying 377862306a36Sopenharmony_citheir behavior can be set in the "flags" field. Undefined flag bits must 377962306a36Sopenharmony_cibe set to 0. 378062306a36Sopenharmony_ci 378162306a36Sopenharmony_ciPossible operations are: 378262306a36Sopenharmony_ci * ``KVM_S390_MEMOP_LOGICAL_READ`` 378362306a36Sopenharmony_ci * ``KVM_S390_MEMOP_LOGICAL_WRITE`` 378462306a36Sopenharmony_ci * ``KVM_S390_MEMOP_ABSOLUTE_READ`` 378562306a36Sopenharmony_ci * ``KVM_S390_MEMOP_ABSOLUTE_WRITE`` 378662306a36Sopenharmony_ci * ``KVM_S390_MEMOP_SIDA_READ`` 378762306a36Sopenharmony_ci * ``KVM_S390_MEMOP_SIDA_WRITE`` 378862306a36Sopenharmony_ci * ``KVM_S390_MEMOP_ABSOLUTE_CMPXCHG`` 378962306a36Sopenharmony_ci 379062306a36Sopenharmony_ciLogical read/write: 379162306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^ 379262306a36Sopenharmony_ci 379362306a36Sopenharmony_ciAccess logical memory, i.e. translate the given guest address to an absolute 379462306a36Sopenharmony_ciaddress given the state of the VCPU and use the absolute address as target of 379562306a36Sopenharmony_cithe access. "ar" designates the access register number to be used; the valid 379662306a36Sopenharmony_cirange is 0..15. 379762306a36Sopenharmony_ciLogical accesses are permitted for the VCPU ioctl only. 379862306a36Sopenharmony_ciLogical accesses are permitted for non-protected guests only. 379962306a36Sopenharmony_ci 380062306a36Sopenharmony_ciSupported flags: 380162306a36Sopenharmony_ci * ``KVM_S390_MEMOP_F_CHECK_ONLY`` 380262306a36Sopenharmony_ci * ``KVM_S390_MEMOP_F_INJECT_EXCEPTION`` 380362306a36Sopenharmony_ci * ``KVM_S390_MEMOP_F_SKEY_PROTECTION`` 380462306a36Sopenharmony_ci 380562306a36Sopenharmony_ciThe KVM_S390_MEMOP_F_CHECK_ONLY flag can be set to check whether the 380662306a36Sopenharmony_cicorresponding memory access would cause an access exception; however, 380762306a36Sopenharmony_cino actual access to the data in memory at the destination is performed. 380862306a36Sopenharmony_ciIn this case, "buf" is unused and can be NULL. 380962306a36Sopenharmony_ci 381062306a36Sopenharmony_ciIn case an access exception occurred during the access (or would occur 381162306a36Sopenharmony_ciin case of KVM_S390_MEMOP_F_CHECK_ONLY), the ioctl returns a positive 381262306a36Sopenharmony_cierror number indicating the type of exception. This exception is also 381362306a36Sopenharmony_ciraised directly at the corresponding VCPU if the flag 381462306a36Sopenharmony_ciKVM_S390_MEMOP_F_INJECT_EXCEPTION is set. 381562306a36Sopenharmony_ciOn protection exceptions, unless specified otherwise, the injected 381662306a36Sopenharmony_citranslation-exception identifier (TEID) indicates suppression. 381762306a36Sopenharmony_ci 381862306a36Sopenharmony_ciIf the KVM_S390_MEMOP_F_SKEY_PROTECTION flag is set, storage key 381962306a36Sopenharmony_ciprotection is also in effect and may cause exceptions if accesses are 382062306a36Sopenharmony_ciprohibited given the access key designated by "key"; the valid range is 0..15. 382162306a36Sopenharmony_ciKVM_S390_MEMOP_F_SKEY_PROTECTION is available if KVM_CAP_S390_MEM_OP_EXTENSION 382262306a36Sopenharmony_ciis > 0. 382362306a36Sopenharmony_ciSince the accessed memory may span multiple pages and those pages might have 382462306a36Sopenharmony_cidifferent storage keys, it is possible that a protection exception occurs 382562306a36Sopenharmony_ciafter memory has been modified. In this case, if the exception is injected, 382662306a36Sopenharmony_cithe TEID does not indicate suppression. 382762306a36Sopenharmony_ci 382862306a36Sopenharmony_ciAbsolute read/write: 382962306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^ 383062306a36Sopenharmony_ci 383162306a36Sopenharmony_ciAccess absolute memory. This operation is intended to be used with the 383262306a36Sopenharmony_ciKVM_S390_MEMOP_F_SKEY_PROTECTION flag, to allow accessing memory and performing 383362306a36Sopenharmony_cithe checks required for storage key protection as one operation (as opposed to 383462306a36Sopenharmony_ciuser space getting the storage keys, performing the checks, and accessing 383562306a36Sopenharmony_cimemory thereafter, which could lead to a delay between check and access). 383662306a36Sopenharmony_ciAbsolute accesses are permitted for the VM ioctl if KVM_CAP_S390_MEM_OP_EXTENSION 383762306a36Sopenharmony_cihas the KVM_S390_MEMOP_EXTENSION_CAP_BASE bit set. 383862306a36Sopenharmony_ciCurrently absolute accesses are not permitted for VCPU ioctls. 383962306a36Sopenharmony_ciAbsolute accesses are permitted for non-protected guests only. 384062306a36Sopenharmony_ci 384162306a36Sopenharmony_ciSupported flags: 384262306a36Sopenharmony_ci * ``KVM_S390_MEMOP_F_CHECK_ONLY`` 384362306a36Sopenharmony_ci * ``KVM_S390_MEMOP_F_SKEY_PROTECTION`` 384462306a36Sopenharmony_ci 384562306a36Sopenharmony_ciThe semantics of the flags common with logical accesses are as for logical 384662306a36Sopenharmony_ciaccesses. 384762306a36Sopenharmony_ci 384862306a36Sopenharmony_ciAbsolute cmpxchg: 384962306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^ 385062306a36Sopenharmony_ci 385162306a36Sopenharmony_ciPerform cmpxchg on absolute guest memory. Intended for use with the 385262306a36Sopenharmony_ciKVM_S390_MEMOP_F_SKEY_PROTECTION flag. 385362306a36Sopenharmony_ciInstead of doing an unconditional write, the access occurs only if the target 385462306a36Sopenharmony_cilocation contains the value pointed to by "old_addr". 385562306a36Sopenharmony_ciThis is performed as an atomic cmpxchg with the length specified by the "size" 385662306a36Sopenharmony_ciparameter. "size" must be a power of two up to and including 16. 385762306a36Sopenharmony_ciIf the exchange did not take place because the target value doesn't match the 385862306a36Sopenharmony_ciold value, the value "old_addr" points to is replaced by the target value. 385962306a36Sopenharmony_ciUser space can tell if an exchange took place by checking if this replacement 386062306a36Sopenharmony_cioccurred. The cmpxchg op is permitted for the VM ioctl if 386162306a36Sopenharmony_ciKVM_CAP_S390_MEM_OP_EXTENSION has flag KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG set. 386262306a36Sopenharmony_ci 386362306a36Sopenharmony_ciSupported flags: 386462306a36Sopenharmony_ci * ``KVM_S390_MEMOP_F_SKEY_PROTECTION`` 386562306a36Sopenharmony_ci 386662306a36Sopenharmony_ciSIDA read/write: 386762306a36Sopenharmony_ci^^^^^^^^^^^^^^^^ 386862306a36Sopenharmony_ci 386962306a36Sopenharmony_ciAccess the secure instruction data area which contains memory operands necessary 387062306a36Sopenharmony_cifor instruction emulation for protected guests. 387162306a36Sopenharmony_ciSIDA accesses are available if the KVM_CAP_S390_PROTECTED capability is available. 387262306a36Sopenharmony_ciSIDA accesses are permitted for the VCPU ioctl only. 387362306a36Sopenharmony_ciSIDA accesses are permitted for protected guests only. 387462306a36Sopenharmony_ci 387562306a36Sopenharmony_ciNo flags are supported. 387662306a36Sopenharmony_ci 387762306a36Sopenharmony_ci4.90 KVM_S390_GET_SKEYS 387862306a36Sopenharmony_ci----------------------- 387962306a36Sopenharmony_ci 388062306a36Sopenharmony_ci:Capability: KVM_CAP_S390_SKEYS 388162306a36Sopenharmony_ci:Architectures: s390 388262306a36Sopenharmony_ci:Type: vm ioctl 388362306a36Sopenharmony_ci:Parameters: struct kvm_s390_skeys 388462306a36Sopenharmony_ci:Returns: 0 on success, KVM_S390_GET_SKEYS_NONE if guest is not using storage 388562306a36Sopenharmony_ci keys, negative value on error 388662306a36Sopenharmony_ci 388762306a36Sopenharmony_ciThis ioctl is used to get guest storage key values on the s390 388862306a36Sopenharmony_ciarchitecture. The ioctl takes parameters via the kvm_s390_skeys struct:: 388962306a36Sopenharmony_ci 389062306a36Sopenharmony_ci struct kvm_s390_skeys { 389162306a36Sopenharmony_ci __u64 start_gfn; 389262306a36Sopenharmony_ci __u64 count; 389362306a36Sopenharmony_ci __u64 skeydata_addr; 389462306a36Sopenharmony_ci __u32 flags; 389562306a36Sopenharmony_ci __u32 reserved[9]; 389662306a36Sopenharmony_ci }; 389762306a36Sopenharmony_ci 389862306a36Sopenharmony_ciThe start_gfn field is the number of the first guest frame whose storage keys 389962306a36Sopenharmony_ciyou want to get. 390062306a36Sopenharmony_ci 390162306a36Sopenharmony_ciThe count field is the number of consecutive frames (starting from start_gfn) 390262306a36Sopenharmony_ciwhose storage keys to get. The count field must be at least 1 and the maximum 390362306a36Sopenharmony_ciallowed value is defined as KVM_S390_SKEYS_MAX. Values outside this range 390462306a36Sopenharmony_ciwill cause the ioctl to return -EINVAL. 390562306a36Sopenharmony_ci 390662306a36Sopenharmony_ciThe skeydata_addr field is the address to a buffer large enough to hold count 390762306a36Sopenharmony_cibytes. This buffer will be filled with storage key data by the ioctl. 390862306a36Sopenharmony_ci 390962306a36Sopenharmony_ci4.91 KVM_S390_SET_SKEYS 391062306a36Sopenharmony_ci----------------------- 391162306a36Sopenharmony_ci 391262306a36Sopenharmony_ci:Capability: KVM_CAP_S390_SKEYS 391362306a36Sopenharmony_ci:Architectures: s390 391462306a36Sopenharmony_ci:Type: vm ioctl 391562306a36Sopenharmony_ci:Parameters: struct kvm_s390_skeys 391662306a36Sopenharmony_ci:Returns: 0 on success, negative value on error 391762306a36Sopenharmony_ci 391862306a36Sopenharmony_ciThis ioctl is used to set guest storage key values on the s390 391962306a36Sopenharmony_ciarchitecture. The ioctl takes parameters via the kvm_s390_skeys struct. 392062306a36Sopenharmony_ciSee section on KVM_S390_GET_SKEYS for struct definition. 392162306a36Sopenharmony_ci 392262306a36Sopenharmony_ciThe start_gfn field is the number of the first guest frame whose storage keys 392362306a36Sopenharmony_ciyou want to set. 392462306a36Sopenharmony_ci 392562306a36Sopenharmony_ciThe count field is the number of consecutive frames (starting from start_gfn) 392662306a36Sopenharmony_ciwhose storage keys to get. The count field must be at least 1 and the maximum 392762306a36Sopenharmony_ciallowed value is defined as KVM_S390_SKEYS_MAX. Values outside this range 392862306a36Sopenharmony_ciwill cause the ioctl to return -EINVAL. 392962306a36Sopenharmony_ci 393062306a36Sopenharmony_ciThe skeydata_addr field is the address to a buffer containing count bytes of 393162306a36Sopenharmony_cistorage keys. Each byte in the buffer will be set as the storage key for a 393262306a36Sopenharmony_cisingle frame starting at start_gfn for count frames. 393362306a36Sopenharmony_ci 393462306a36Sopenharmony_ciNote: If any architecturally invalid key value is found in the given data then 393562306a36Sopenharmony_cithe ioctl will return -EINVAL. 393662306a36Sopenharmony_ci 393762306a36Sopenharmony_ci4.92 KVM_S390_IRQ 393862306a36Sopenharmony_ci----------------- 393962306a36Sopenharmony_ci 394062306a36Sopenharmony_ci:Capability: KVM_CAP_S390_INJECT_IRQ 394162306a36Sopenharmony_ci:Architectures: s390 394262306a36Sopenharmony_ci:Type: vcpu ioctl 394362306a36Sopenharmony_ci:Parameters: struct kvm_s390_irq (in) 394462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 394562306a36Sopenharmony_ci 394662306a36Sopenharmony_ciErrors: 394762306a36Sopenharmony_ci 394862306a36Sopenharmony_ci 394962306a36Sopenharmony_ci ====== ================================================================= 395062306a36Sopenharmony_ci EINVAL interrupt type is invalid 395162306a36Sopenharmony_ci type is KVM_S390_SIGP_STOP and flag parameter is invalid value, 395262306a36Sopenharmony_ci type is KVM_S390_INT_EXTERNAL_CALL and code is bigger 395362306a36Sopenharmony_ci than the maximum of VCPUs 395462306a36Sopenharmony_ci EBUSY type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped, 395562306a36Sopenharmony_ci type is KVM_S390_SIGP_STOP and a stop irq is already pending, 395662306a36Sopenharmony_ci type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt 395762306a36Sopenharmony_ci is already pending 395862306a36Sopenharmony_ci ====== ================================================================= 395962306a36Sopenharmony_ci 396062306a36Sopenharmony_ciAllows to inject an interrupt to the guest. 396162306a36Sopenharmony_ci 396262306a36Sopenharmony_ciUsing struct kvm_s390_irq as a parameter allows 396362306a36Sopenharmony_cito inject additional payload which is not 396462306a36Sopenharmony_cipossible via KVM_S390_INTERRUPT. 396562306a36Sopenharmony_ci 396662306a36Sopenharmony_ciInterrupt parameters are passed via kvm_s390_irq:: 396762306a36Sopenharmony_ci 396862306a36Sopenharmony_ci struct kvm_s390_irq { 396962306a36Sopenharmony_ci __u64 type; 397062306a36Sopenharmony_ci union { 397162306a36Sopenharmony_ci struct kvm_s390_io_info io; 397262306a36Sopenharmony_ci struct kvm_s390_ext_info ext; 397362306a36Sopenharmony_ci struct kvm_s390_pgm_info pgm; 397462306a36Sopenharmony_ci struct kvm_s390_emerg_info emerg; 397562306a36Sopenharmony_ci struct kvm_s390_extcall_info extcall; 397662306a36Sopenharmony_ci struct kvm_s390_prefix_info prefix; 397762306a36Sopenharmony_ci struct kvm_s390_stop_info stop; 397862306a36Sopenharmony_ci struct kvm_s390_mchk_info mchk; 397962306a36Sopenharmony_ci char reserved[64]; 398062306a36Sopenharmony_ci } u; 398162306a36Sopenharmony_ci }; 398262306a36Sopenharmony_ci 398362306a36Sopenharmony_citype can be one of the following: 398462306a36Sopenharmony_ci 398562306a36Sopenharmony_ci- KVM_S390_SIGP_STOP - sigp stop; parameter in .stop 398662306a36Sopenharmony_ci- KVM_S390_PROGRAM_INT - program check; parameters in .pgm 398762306a36Sopenharmony_ci- KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix 398862306a36Sopenharmony_ci- KVM_S390_RESTART - restart; no parameters 398962306a36Sopenharmony_ci- KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters 399062306a36Sopenharmony_ci- KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters 399162306a36Sopenharmony_ci- KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg 399262306a36Sopenharmony_ci- KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall 399362306a36Sopenharmony_ci- KVM_S390_MCHK - machine check interrupt; parameters in .mchk 399462306a36Sopenharmony_ci 399562306a36Sopenharmony_ciThis is an asynchronous vcpu ioctl and can be invoked from any thread. 399662306a36Sopenharmony_ci 399762306a36Sopenharmony_ci4.94 KVM_S390_GET_IRQ_STATE 399862306a36Sopenharmony_ci--------------------------- 399962306a36Sopenharmony_ci 400062306a36Sopenharmony_ci:Capability: KVM_CAP_S390_IRQ_STATE 400162306a36Sopenharmony_ci:Architectures: s390 400262306a36Sopenharmony_ci:Type: vcpu ioctl 400362306a36Sopenharmony_ci:Parameters: struct kvm_s390_irq_state (out) 400462306a36Sopenharmony_ci:Returns: >= number of bytes copied into buffer, 400562306a36Sopenharmony_ci -EINVAL if buffer size is 0, 400662306a36Sopenharmony_ci -ENOBUFS if buffer size is too small to fit all pending interrupts, 400762306a36Sopenharmony_ci -EFAULT if the buffer address was invalid 400862306a36Sopenharmony_ci 400962306a36Sopenharmony_ciThis ioctl allows userspace to retrieve the complete state of all currently 401062306a36Sopenharmony_cipending interrupts in a single buffer. Use cases include migration 401162306a36Sopenharmony_ciand introspection. The parameter structure contains the address of a 401262306a36Sopenharmony_ciuserspace buffer and its length:: 401362306a36Sopenharmony_ci 401462306a36Sopenharmony_ci struct kvm_s390_irq_state { 401562306a36Sopenharmony_ci __u64 buf; 401662306a36Sopenharmony_ci __u32 flags; /* will stay unused for compatibility reasons */ 401762306a36Sopenharmony_ci __u32 len; 401862306a36Sopenharmony_ci __u32 reserved[4]; /* will stay unused for compatibility reasons */ 401962306a36Sopenharmony_ci }; 402062306a36Sopenharmony_ci 402162306a36Sopenharmony_ciUserspace passes in the above struct and for each pending interrupt a 402262306a36Sopenharmony_cistruct kvm_s390_irq is copied to the provided buffer. 402362306a36Sopenharmony_ci 402462306a36Sopenharmony_ciThe structure contains a flags and a reserved field for future extensions. As 402562306a36Sopenharmony_cithe kernel never checked for flags == 0 and QEMU never pre-zeroed flags and 402662306a36Sopenharmony_cireserved, these fields can not be used in the future without breaking 402762306a36Sopenharmony_cicompatibility. 402862306a36Sopenharmony_ci 402962306a36Sopenharmony_ciIf -ENOBUFS is returned the buffer provided was too small and userspace 403062306a36Sopenharmony_cimay retry with a bigger buffer. 403162306a36Sopenharmony_ci 403262306a36Sopenharmony_ci4.95 KVM_S390_SET_IRQ_STATE 403362306a36Sopenharmony_ci--------------------------- 403462306a36Sopenharmony_ci 403562306a36Sopenharmony_ci:Capability: KVM_CAP_S390_IRQ_STATE 403662306a36Sopenharmony_ci:Architectures: s390 403762306a36Sopenharmony_ci:Type: vcpu ioctl 403862306a36Sopenharmony_ci:Parameters: struct kvm_s390_irq_state (in) 403962306a36Sopenharmony_ci:Returns: 0 on success, 404062306a36Sopenharmony_ci -EFAULT if the buffer address was invalid, 404162306a36Sopenharmony_ci -EINVAL for an invalid buffer length (see below), 404262306a36Sopenharmony_ci -EBUSY if there were already interrupts pending, 404362306a36Sopenharmony_ci errors occurring when actually injecting the 404462306a36Sopenharmony_ci interrupt. See KVM_S390_IRQ. 404562306a36Sopenharmony_ci 404662306a36Sopenharmony_ciThis ioctl allows userspace to set the complete state of all cpu-local 404762306a36Sopenharmony_ciinterrupts currently pending for the vcpu. It is intended for restoring 404862306a36Sopenharmony_ciinterrupt state after a migration. The input parameter is a userspace buffer 404962306a36Sopenharmony_cicontaining a struct kvm_s390_irq_state:: 405062306a36Sopenharmony_ci 405162306a36Sopenharmony_ci struct kvm_s390_irq_state { 405262306a36Sopenharmony_ci __u64 buf; 405362306a36Sopenharmony_ci __u32 flags; /* will stay unused for compatibility reasons */ 405462306a36Sopenharmony_ci __u32 len; 405562306a36Sopenharmony_ci __u32 reserved[4]; /* will stay unused for compatibility reasons */ 405662306a36Sopenharmony_ci }; 405762306a36Sopenharmony_ci 405862306a36Sopenharmony_ciThe restrictions for flags and reserved apply as well. 405962306a36Sopenharmony_ci(see KVM_S390_GET_IRQ_STATE) 406062306a36Sopenharmony_ci 406162306a36Sopenharmony_ciThe userspace memory referenced by buf contains a struct kvm_s390_irq 406262306a36Sopenharmony_cifor each interrupt to be injected into the guest. 406362306a36Sopenharmony_ciIf one of the interrupts could not be injected for some reason the 406462306a36Sopenharmony_ciioctl aborts. 406562306a36Sopenharmony_ci 406662306a36Sopenharmony_cilen must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0 406762306a36Sopenharmony_ciand it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq), 406862306a36Sopenharmony_ciwhich is the maximum number of possibly pending cpu-local interrupts. 406962306a36Sopenharmony_ci 407062306a36Sopenharmony_ci4.96 KVM_SMI 407162306a36Sopenharmony_ci------------ 407262306a36Sopenharmony_ci 407362306a36Sopenharmony_ci:Capability: KVM_CAP_X86_SMM 407462306a36Sopenharmony_ci:Architectures: x86 407562306a36Sopenharmony_ci:Type: vcpu ioctl 407662306a36Sopenharmony_ci:Parameters: none 407762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 407862306a36Sopenharmony_ci 407962306a36Sopenharmony_ciQueues an SMI on the thread's vcpu. 408062306a36Sopenharmony_ci 408162306a36Sopenharmony_ci4.97 KVM_X86_SET_MSR_FILTER 408262306a36Sopenharmony_ci---------------------------- 408362306a36Sopenharmony_ci 408462306a36Sopenharmony_ci:Capability: KVM_CAP_X86_MSR_FILTER 408562306a36Sopenharmony_ci:Architectures: x86 408662306a36Sopenharmony_ci:Type: vm ioctl 408762306a36Sopenharmony_ci:Parameters: struct kvm_msr_filter 408862306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 408962306a36Sopenharmony_ci 409062306a36Sopenharmony_ci:: 409162306a36Sopenharmony_ci 409262306a36Sopenharmony_ci struct kvm_msr_filter_range { 409362306a36Sopenharmony_ci #define KVM_MSR_FILTER_READ (1 << 0) 409462306a36Sopenharmony_ci #define KVM_MSR_FILTER_WRITE (1 << 1) 409562306a36Sopenharmony_ci __u32 flags; 409662306a36Sopenharmony_ci __u32 nmsrs; /* number of msrs in bitmap */ 409762306a36Sopenharmony_ci __u32 base; /* MSR index the bitmap starts at */ 409862306a36Sopenharmony_ci __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */ 409962306a36Sopenharmony_ci }; 410062306a36Sopenharmony_ci 410162306a36Sopenharmony_ci #define KVM_MSR_FILTER_MAX_RANGES 16 410262306a36Sopenharmony_ci struct kvm_msr_filter { 410362306a36Sopenharmony_ci #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0) 410462306a36Sopenharmony_ci #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0) 410562306a36Sopenharmony_ci __u32 flags; 410662306a36Sopenharmony_ci struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES]; 410762306a36Sopenharmony_ci }; 410862306a36Sopenharmony_ci 410962306a36Sopenharmony_ciflags values for ``struct kvm_msr_filter_range``: 411062306a36Sopenharmony_ci 411162306a36Sopenharmony_ci``KVM_MSR_FILTER_READ`` 411262306a36Sopenharmony_ci 411362306a36Sopenharmony_ci Filter read accesses to MSRs using the given bitmap. A 0 in the bitmap 411462306a36Sopenharmony_ci indicates that read accesses should be denied, while a 1 indicates that 411562306a36Sopenharmony_ci a read for a particular MSR should be allowed regardless of the default 411662306a36Sopenharmony_ci filter action. 411762306a36Sopenharmony_ci 411862306a36Sopenharmony_ci``KVM_MSR_FILTER_WRITE`` 411962306a36Sopenharmony_ci 412062306a36Sopenharmony_ci Filter write accesses to MSRs using the given bitmap. A 0 in the bitmap 412162306a36Sopenharmony_ci indicates that write accesses should be denied, while a 1 indicates that 412262306a36Sopenharmony_ci a write for a particular MSR should be allowed regardless of the default 412362306a36Sopenharmony_ci filter action. 412462306a36Sopenharmony_ci 412562306a36Sopenharmony_ciflags values for ``struct kvm_msr_filter``: 412662306a36Sopenharmony_ci 412762306a36Sopenharmony_ci``KVM_MSR_FILTER_DEFAULT_ALLOW`` 412862306a36Sopenharmony_ci 412962306a36Sopenharmony_ci If no filter range matches an MSR index that is getting accessed, KVM will 413062306a36Sopenharmony_ci allow accesses to all MSRs by default. 413162306a36Sopenharmony_ci 413262306a36Sopenharmony_ci``KVM_MSR_FILTER_DEFAULT_DENY`` 413362306a36Sopenharmony_ci 413462306a36Sopenharmony_ci If no filter range matches an MSR index that is getting accessed, KVM will 413562306a36Sopenharmony_ci deny accesses to all MSRs by default. 413662306a36Sopenharmony_ci 413762306a36Sopenharmony_ciThis ioctl allows userspace to define up to 16 bitmaps of MSR ranges to deny 413862306a36Sopenharmony_ciguest MSR accesses that would normally be allowed by KVM. If an MSR is not 413962306a36Sopenharmony_cicovered by a specific range, the "default" filtering behavior applies. Each 414062306a36Sopenharmony_cibitmap range covers MSRs from [base .. base+nmsrs). 414162306a36Sopenharmony_ci 414262306a36Sopenharmony_ciIf an MSR access is denied by userspace, the resulting KVM behavior depends on 414362306a36Sopenharmony_ciwhether or not KVM_CAP_X86_USER_SPACE_MSR's KVM_MSR_EXIT_REASON_FILTER is 414462306a36Sopenharmony_cienabled. If KVM_MSR_EXIT_REASON_FILTER is enabled, KVM will exit to userspace 414562306a36Sopenharmony_cion denied accesses, i.e. userspace effectively intercepts the MSR access. If 414662306a36Sopenharmony_ciKVM_MSR_EXIT_REASON_FILTER is not enabled, KVM will inject a #GP into the guest 414762306a36Sopenharmony_cion denied accesses. 414862306a36Sopenharmony_ci 414962306a36Sopenharmony_ciIf an MSR access is allowed by userspace, KVM will emulate and/or virtualize 415062306a36Sopenharmony_cithe access in accordance with the vCPU model. Note, KVM may still ultimately 415162306a36Sopenharmony_ciinject a #GP if an access is allowed by userspace, e.g. if KVM doesn't support 415262306a36Sopenharmony_cithe MSR, or to follow architectural behavior for the MSR. 415362306a36Sopenharmony_ci 415462306a36Sopenharmony_ciBy default, KVM operates in KVM_MSR_FILTER_DEFAULT_ALLOW mode with no MSR range 415562306a36Sopenharmony_cifilters. 415662306a36Sopenharmony_ci 415762306a36Sopenharmony_ciCalling this ioctl with an empty set of ranges (all nmsrs == 0) disables MSR 415862306a36Sopenharmony_cifiltering. In that mode, ``KVM_MSR_FILTER_DEFAULT_DENY`` is invalid and causes 415962306a36Sopenharmony_cian error. 416062306a36Sopenharmony_ci 416162306a36Sopenharmony_ci.. warning:: 416262306a36Sopenharmony_ci MSR accesses as part of nested VM-Enter/VM-Exit are not filtered. 416362306a36Sopenharmony_ci This includes both writes to individual VMCS fields and reads/writes 416462306a36Sopenharmony_ci through the MSR lists pointed to by the VMCS. 416562306a36Sopenharmony_ci 416662306a36Sopenharmony_ci x2APIC MSR accesses cannot be filtered (KVM silently ignores filters that 416762306a36Sopenharmony_ci cover any x2APIC MSRs). 416862306a36Sopenharmony_ci 416962306a36Sopenharmony_ciNote, invoking this ioctl while a vCPU is running is inherently racy. However, 417062306a36Sopenharmony_ciKVM does guarantee that vCPUs will see either the previous filter or the new 417162306a36Sopenharmony_cifilter, e.g. MSRs with identical settings in both the old and new filter will 417262306a36Sopenharmony_cihave deterministic behavior. 417362306a36Sopenharmony_ci 417462306a36Sopenharmony_ciSimilarly, if userspace wishes to intercept on denied accesses, 417562306a36Sopenharmony_ciKVM_MSR_EXIT_REASON_FILTER must be enabled before activating any filters, and 417662306a36Sopenharmony_cileft enabled until after all filters are deactivated. Failure to do so may 417762306a36Sopenharmony_ciresult in KVM injecting a #GP instead of exiting to userspace. 417862306a36Sopenharmony_ci 417962306a36Sopenharmony_ci4.98 KVM_CREATE_SPAPR_TCE_64 418062306a36Sopenharmony_ci---------------------------- 418162306a36Sopenharmony_ci 418262306a36Sopenharmony_ci:Capability: KVM_CAP_SPAPR_TCE_64 418362306a36Sopenharmony_ci:Architectures: powerpc 418462306a36Sopenharmony_ci:Type: vm ioctl 418562306a36Sopenharmony_ci:Parameters: struct kvm_create_spapr_tce_64 (in) 418662306a36Sopenharmony_ci:Returns: file descriptor for manipulating the created TCE table 418762306a36Sopenharmony_ci 418862306a36Sopenharmony_ciThis is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit 418962306a36Sopenharmony_ciwindows, described in 4.62 KVM_CREATE_SPAPR_TCE 419062306a36Sopenharmony_ci 419162306a36Sopenharmony_ciThis capability uses extended struct in ioctl interface:: 419262306a36Sopenharmony_ci 419362306a36Sopenharmony_ci /* for KVM_CAP_SPAPR_TCE_64 */ 419462306a36Sopenharmony_ci struct kvm_create_spapr_tce_64 { 419562306a36Sopenharmony_ci __u64 liobn; 419662306a36Sopenharmony_ci __u32 page_shift; 419762306a36Sopenharmony_ci __u32 flags; 419862306a36Sopenharmony_ci __u64 offset; /* in pages */ 419962306a36Sopenharmony_ci __u64 size; /* in pages */ 420062306a36Sopenharmony_ci }; 420162306a36Sopenharmony_ci 420262306a36Sopenharmony_ciThe aim of extension is to support an additional bigger DMA window with 420362306a36Sopenharmony_cia variable page size. 420462306a36Sopenharmony_ciKVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and 420562306a36Sopenharmony_cia bus offset of the corresponding DMA window, @size and @offset are numbers 420662306a36Sopenharmony_ciof IOMMU pages. 420762306a36Sopenharmony_ci 420862306a36Sopenharmony_ci@flags are not used at the moment. 420962306a36Sopenharmony_ci 421062306a36Sopenharmony_ciThe rest of functionality is identical to KVM_CREATE_SPAPR_TCE. 421162306a36Sopenharmony_ci 421262306a36Sopenharmony_ci4.99 KVM_REINJECT_CONTROL 421362306a36Sopenharmony_ci------------------------- 421462306a36Sopenharmony_ci 421562306a36Sopenharmony_ci:Capability: KVM_CAP_REINJECT_CONTROL 421662306a36Sopenharmony_ci:Architectures: x86 421762306a36Sopenharmony_ci:Type: vm ioctl 421862306a36Sopenharmony_ci:Parameters: struct kvm_reinject_control (in) 421962306a36Sopenharmony_ci:Returns: 0 on success, 422062306a36Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 422162306a36Sopenharmony_ci -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier. 422262306a36Sopenharmony_ci 422362306a36Sopenharmony_cii8254 (PIT) has two modes, reinject and !reinject. The default is reinject, 422462306a36Sopenharmony_ciwhere KVM queues elapsed i8254 ticks and monitors completion of interrupt from 422562306a36Sopenharmony_civector(s) that i8254 injects. Reinject mode dequeues a tick and injects its 422662306a36Sopenharmony_ciinterrupt whenever there isn't a pending interrupt from i8254. 422762306a36Sopenharmony_ci!reinject mode injects an interrupt as soon as a tick arrives. 422862306a36Sopenharmony_ci 422962306a36Sopenharmony_ci:: 423062306a36Sopenharmony_ci 423162306a36Sopenharmony_ci struct kvm_reinject_control { 423262306a36Sopenharmony_ci __u8 pit_reinject; 423362306a36Sopenharmony_ci __u8 reserved[31]; 423462306a36Sopenharmony_ci }; 423562306a36Sopenharmony_ci 423662306a36Sopenharmony_cipit_reinject = 0 (!reinject mode) is recommended, unless running an old 423762306a36Sopenharmony_cioperating system that uses the PIT for timing (e.g. Linux 2.4.x). 423862306a36Sopenharmony_ci 423962306a36Sopenharmony_ci4.100 KVM_PPC_CONFIGURE_V3_MMU 424062306a36Sopenharmony_ci------------------------------ 424162306a36Sopenharmony_ci 424262306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 424362306a36Sopenharmony_ci:Architectures: ppc 424462306a36Sopenharmony_ci:Type: vm ioctl 424562306a36Sopenharmony_ci:Parameters: struct kvm_ppc_mmuv3_cfg (in) 424662306a36Sopenharmony_ci:Returns: 0 on success, 424762306a36Sopenharmony_ci -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read, 424862306a36Sopenharmony_ci -EINVAL if the configuration is invalid 424962306a36Sopenharmony_ci 425062306a36Sopenharmony_ciThis ioctl controls whether the guest will use radix or HPT (hashed 425162306a36Sopenharmony_cipage table) translation, and sets the pointer to the process table for 425262306a36Sopenharmony_cithe guest. 425362306a36Sopenharmony_ci 425462306a36Sopenharmony_ci:: 425562306a36Sopenharmony_ci 425662306a36Sopenharmony_ci struct kvm_ppc_mmuv3_cfg { 425762306a36Sopenharmony_ci __u64 flags; 425862306a36Sopenharmony_ci __u64 process_table; 425962306a36Sopenharmony_ci }; 426062306a36Sopenharmony_ci 426162306a36Sopenharmony_ciThere are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and 426262306a36Sopenharmony_ciKVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest 426362306a36Sopenharmony_cito use radix tree translation, and if clear, to use HPT translation. 426462306a36Sopenharmony_ciKVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest 426562306a36Sopenharmony_cito be able to use the global TLB and SLB invalidation instructions; 426662306a36Sopenharmony_ciif clear, the guest may not use these instructions. 426762306a36Sopenharmony_ci 426862306a36Sopenharmony_ciThe process_table field specifies the address and size of the guest 426962306a36Sopenharmony_ciprocess table, which is in the guest's space. This field is formatted 427062306a36Sopenharmony_cias the second doubleword of the partition table entry, as defined in 427162306a36Sopenharmony_cithe Power ISA V3.00, Book III section 5.7.6.1. 427262306a36Sopenharmony_ci 427362306a36Sopenharmony_ci4.101 KVM_PPC_GET_RMMU_INFO 427462306a36Sopenharmony_ci--------------------------- 427562306a36Sopenharmony_ci 427662306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_RADIX_MMU 427762306a36Sopenharmony_ci:Architectures: ppc 427862306a36Sopenharmony_ci:Type: vm ioctl 427962306a36Sopenharmony_ci:Parameters: struct kvm_ppc_rmmu_info (out) 428062306a36Sopenharmony_ci:Returns: 0 on success, 428162306a36Sopenharmony_ci -EFAULT if struct kvm_ppc_rmmu_info cannot be written, 428262306a36Sopenharmony_ci -EINVAL if no useful information can be returned 428362306a36Sopenharmony_ci 428462306a36Sopenharmony_ciThis ioctl returns a structure containing two things: (a) a list 428562306a36Sopenharmony_cicontaining supported radix tree geometries, and (b) a list that maps 428662306a36Sopenharmony_cipage sizes to put in the "AP" (actual page size) field for the tlbie 428762306a36Sopenharmony_ci(TLB invalidate entry) instruction. 428862306a36Sopenharmony_ci 428962306a36Sopenharmony_ci:: 429062306a36Sopenharmony_ci 429162306a36Sopenharmony_ci struct kvm_ppc_rmmu_info { 429262306a36Sopenharmony_ci struct kvm_ppc_radix_geom { 429362306a36Sopenharmony_ci __u8 page_shift; 429462306a36Sopenharmony_ci __u8 level_bits[4]; 429562306a36Sopenharmony_ci __u8 pad[3]; 429662306a36Sopenharmony_ci } geometries[8]; 429762306a36Sopenharmony_ci __u32 ap_encodings[8]; 429862306a36Sopenharmony_ci }; 429962306a36Sopenharmony_ci 430062306a36Sopenharmony_ciThe geometries[] field gives up to 8 supported geometries for the 430162306a36Sopenharmony_ciradix page table, in terms of the log base 2 of the smallest page 430262306a36Sopenharmony_cisize, and the number of bits indexed at each level of the tree, from 430362306a36Sopenharmony_cithe PTE level up to the PGD level in that order. Any unused entries 430462306a36Sopenharmony_ciwill have 0 in the page_shift field. 430562306a36Sopenharmony_ci 430662306a36Sopenharmony_ciThe ap_encodings gives the supported page sizes and their AP field 430762306a36Sopenharmony_ciencodings, encoded with the AP value in the top 3 bits and the log 430862306a36Sopenharmony_cibase 2 of the page size in the bottom 6 bits. 430962306a36Sopenharmony_ci 431062306a36Sopenharmony_ci4.102 KVM_PPC_RESIZE_HPT_PREPARE 431162306a36Sopenharmony_ci-------------------------------- 431262306a36Sopenharmony_ci 431362306a36Sopenharmony_ci:Capability: KVM_CAP_SPAPR_RESIZE_HPT 431462306a36Sopenharmony_ci:Architectures: powerpc 431562306a36Sopenharmony_ci:Type: vm ioctl 431662306a36Sopenharmony_ci:Parameters: struct kvm_ppc_resize_hpt (in) 431762306a36Sopenharmony_ci:Returns: 0 on successful completion, 431862306a36Sopenharmony_ci >0 if a new HPT is being prepared, the value is an estimated 431962306a36Sopenharmony_ci number of milliseconds until preparation is complete, 432062306a36Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 432162306a36Sopenharmony_ci -EINVAL if the supplied shift or flags are invalid, 432262306a36Sopenharmony_ci -ENOMEM if unable to allocate the new HPT, 432362306a36Sopenharmony_ci 432462306a36Sopenharmony_ciUsed to implement the PAPR extension for runtime resizing of a guest's 432562306a36Sopenharmony_ciHashed Page Table (HPT). Specifically this starts, stops or monitors 432662306a36Sopenharmony_cithe preparation of a new potential HPT for the guest, essentially 432762306a36Sopenharmony_ciimplementing the H_RESIZE_HPT_PREPARE hypercall. 432862306a36Sopenharmony_ci 432962306a36Sopenharmony_ci:: 433062306a36Sopenharmony_ci 433162306a36Sopenharmony_ci struct kvm_ppc_resize_hpt { 433262306a36Sopenharmony_ci __u64 flags; 433362306a36Sopenharmony_ci __u32 shift; 433462306a36Sopenharmony_ci __u32 pad; 433562306a36Sopenharmony_ci }; 433662306a36Sopenharmony_ci 433762306a36Sopenharmony_ciIf called with shift > 0 when there is no pending HPT for the guest, 433862306a36Sopenharmony_cithis begins preparation of a new pending HPT of size 2^(shift) bytes. 433962306a36Sopenharmony_ciIt then returns a positive integer with the estimated number of 434062306a36Sopenharmony_cimilliseconds until preparation is complete. 434162306a36Sopenharmony_ci 434262306a36Sopenharmony_ciIf called when there is a pending HPT whose size does not match that 434362306a36Sopenharmony_cirequested in the parameters, discards the existing pending HPT and 434462306a36Sopenharmony_cicreates a new one as above. 434562306a36Sopenharmony_ci 434662306a36Sopenharmony_ciIf called when there is a pending HPT of the size requested, will: 434762306a36Sopenharmony_ci 434862306a36Sopenharmony_ci * If preparation of the pending HPT is already complete, return 0 434962306a36Sopenharmony_ci * If preparation of the pending HPT has failed, return an error 435062306a36Sopenharmony_ci code, then discard the pending HPT. 435162306a36Sopenharmony_ci * If preparation of the pending HPT is still in progress, return an 435262306a36Sopenharmony_ci estimated number of milliseconds until preparation is complete. 435362306a36Sopenharmony_ci 435462306a36Sopenharmony_ciIf called with shift == 0, discards any currently pending HPT and 435562306a36Sopenharmony_cireturns 0 (i.e. cancels any in-progress preparation). 435662306a36Sopenharmony_ci 435762306a36Sopenharmony_ciflags is reserved for future expansion, currently setting any bits in 435862306a36Sopenharmony_ciflags will result in an -EINVAL. 435962306a36Sopenharmony_ci 436062306a36Sopenharmony_ciNormally this will be called repeatedly with the same parameters until 436162306a36Sopenharmony_ciit returns <= 0. The first call will initiate preparation, subsequent 436262306a36Sopenharmony_ciones will monitor preparation until it completes or fails. 436362306a36Sopenharmony_ci 436462306a36Sopenharmony_ci4.103 KVM_PPC_RESIZE_HPT_COMMIT 436562306a36Sopenharmony_ci------------------------------- 436662306a36Sopenharmony_ci 436762306a36Sopenharmony_ci:Capability: KVM_CAP_SPAPR_RESIZE_HPT 436862306a36Sopenharmony_ci:Architectures: powerpc 436962306a36Sopenharmony_ci:Type: vm ioctl 437062306a36Sopenharmony_ci:Parameters: struct kvm_ppc_resize_hpt (in) 437162306a36Sopenharmony_ci:Returns: 0 on successful completion, 437262306a36Sopenharmony_ci -EFAULT if struct kvm_reinject_control cannot be read, 437362306a36Sopenharmony_ci -EINVAL if the supplied shift or flags are invalid, 437462306a36Sopenharmony_ci -ENXIO is there is no pending HPT, or the pending HPT doesn't 437562306a36Sopenharmony_ci have the requested size, 437662306a36Sopenharmony_ci -EBUSY if the pending HPT is not fully prepared, 437762306a36Sopenharmony_ci -ENOSPC if there was a hash collision when moving existing 437862306a36Sopenharmony_ci HPT entries to the new HPT, 437962306a36Sopenharmony_ci -EIO on other error conditions 438062306a36Sopenharmony_ci 438162306a36Sopenharmony_ciUsed to implement the PAPR extension for runtime resizing of a guest's 438262306a36Sopenharmony_ciHashed Page Table (HPT). Specifically this requests that the guest be 438362306a36Sopenharmony_citransferred to working with the new HPT, essentially implementing the 438462306a36Sopenharmony_ciH_RESIZE_HPT_COMMIT hypercall. 438562306a36Sopenharmony_ci 438662306a36Sopenharmony_ci:: 438762306a36Sopenharmony_ci 438862306a36Sopenharmony_ci struct kvm_ppc_resize_hpt { 438962306a36Sopenharmony_ci __u64 flags; 439062306a36Sopenharmony_ci __u32 shift; 439162306a36Sopenharmony_ci __u32 pad; 439262306a36Sopenharmony_ci }; 439362306a36Sopenharmony_ci 439462306a36Sopenharmony_ciThis should only be called after KVM_PPC_RESIZE_HPT_PREPARE has 439562306a36Sopenharmony_cireturned 0 with the same parameters. In other cases 439662306a36Sopenharmony_ciKVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or 439762306a36Sopenharmony_ci-EBUSY, though others may be possible if the preparation was started, 439862306a36Sopenharmony_cibut failed). 439962306a36Sopenharmony_ci 440062306a36Sopenharmony_ciThis will have undefined effects on the guest if it has not already 440162306a36Sopenharmony_ciplaced itself in a quiescent state where no vcpu will make MMU enabled 440262306a36Sopenharmony_cimemory accesses. 440362306a36Sopenharmony_ci 440462306a36Sopenharmony_ciOn succsful completion, the pending HPT will become the guest's active 440562306a36Sopenharmony_ciHPT and the previous HPT will be discarded. 440662306a36Sopenharmony_ci 440762306a36Sopenharmony_ciOn failure, the guest will still be operating on its previous HPT. 440862306a36Sopenharmony_ci 440962306a36Sopenharmony_ci4.104 KVM_X86_GET_MCE_CAP_SUPPORTED 441062306a36Sopenharmony_ci----------------------------------- 441162306a36Sopenharmony_ci 441262306a36Sopenharmony_ci:Capability: KVM_CAP_MCE 441362306a36Sopenharmony_ci:Architectures: x86 441462306a36Sopenharmony_ci:Type: system ioctl 441562306a36Sopenharmony_ci:Parameters: u64 mce_cap (out) 441662306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 441762306a36Sopenharmony_ci 441862306a36Sopenharmony_ciReturns supported MCE capabilities. The u64 mce_cap parameter 441962306a36Sopenharmony_cihas the same format as the MSR_IA32_MCG_CAP register. Supported 442062306a36Sopenharmony_cicapabilities will have the corresponding bits set. 442162306a36Sopenharmony_ci 442262306a36Sopenharmony_ci4.105 KVM_X86_SETUP_MCE 442362306a36Sopenharmony_ci----------------------- 442462306a36Sopenharmony_ci 442562306a36Sopenharmony_ci:Capability: KVM_CAP_MCE 442662306a36Sopenharmony_ci:Architectures: x86 442762306a36Sopenharmony_ci:Type: vcpu ioctl 442862306a36Sopenharmony_ci:Parameters: u64 mcg_cap (in) 442962306a36Sopenharmony_ci:Returns: 0 on success, 443062306a36Sopenharmony_ci -EFAULT if u64 mcg_cap cannot be read, 443162306a36Sopenharmony_ci -EINVAL if the requested number of banks is invalid, 443262306a36Sopenharmony_ci -EINVAL if requested MCE capability is not supported. 443362306a36Sopenharmony_ci 443462306a36Sopenharmony_ciInitializes MCE support for use. The u64 mcg_cap parameter 443562306a36Sopenharmony_cihas the same format as the MSR_IA32_MCG_CAP register and 443662306a36Sopenharmony_cispecifies which capabilities should be enabled. The maximum 443762306a36Sopenharmony_cisupported number of error-reporting banks can be retrieved when 443862306a36Sopenharmony_cichecking for KVM_CAP_MCE. The supported capabilities can be 443962306a36Sopenharmony_ciretrieved with KVM_X86_GET_MCE_CAP_SUPPORTED. 444062306a36Sopenharmony_ci 444162306a36Sopenharmony_ci4.106 KVM_X86_SET_MCE 444262306a36Sopenharmony_ci--------------------- 444362306a36Sopenharmony_ci 444462306a36Sopenharmony_ci:Capability: KVM_CAP_MCE 444562306a36Sopenharmony_ci:Architectures: x86 444662306a36Sopenharmony_ci:Type: vcpu ioctl 444762306a36Sopenharmony_ci:Parameters: struct kvm_x86_mce (in) 444862306a36Sopenharmony_ci:Returns: 0 on success, 444962306a36Sopenharmony_ci -EFAULT if struct kvm_x86_mce cannot be read, 445062306a36Sopenharmony_ci -EINVAL if the bank number is invalid, 445162306a36Sopenharmony_ci -EINVAL if VAL bit is not set in status field. 445262306a36Sopenharmony_ci 445362306a36Sopenharmony_ciInject a machine check error (MCE) into the guest. The input 445462306a36Sopenharmony_ciparameter is:: 445562306a36Sopenharmony_ci 445662306a36Sopenharmony_ci struct kvm_x86_mce { 445762306a36Sopenharmony_ci __u64 status; 445862306a36Sopenharmony_ci __u64 addr; 445962306a36Sopenharmony_ci __u64 misc; 446062306a36Sopenharmony_ci __u64 mcg_status; 446162306a36Sopenharmony_ci __u8 bank; 446262306a36Sopenharmony_ci __u8 pad1[7]; 446362306a36Sopenharmony_ci __u64 pad2[3]; 446462306a36Sopenharmony_ci }; 446562306a36Sopenharmony_ci 446662306a36Sopenharmony_ciIf the MCE being reported is an uncorrected error, KVM will 446762306a36Sopenharmony_ciinject it as an MCE exception into the guest. If the guest 446862306a36Sopenharmony_ciMCG_STATUS register reports that an MCE is in progress, KVM 446962306a36Sopenharmony_cicauses an KVM_EXIT_SHUTDOWN vmexit. 447062306a36Sopenharmony_ci 447162306a36Sopenharmony_ciOtherwise, if the MCE is a corrected error, KVM will just 447262306a36Sopenharmony_cistore it in the corresponding bank (provided this bank is 447362306a36Sopenharmony_cinot holding a previously reported uncorrected error). 447462306a36Sopenharmony_ci 447562306a36Sopenharmony_ci4.107 KVM_S390_GET_CMMA_BITS 447662306a36Sopenharmony_ci---------------------------- 447762306a36Sopenharmony_ci 447862306a36Sopenharmony_ci:Capability: KVM_CAP_S390_CMMA_MIGRATION 447962306a36Sopenharmony_ci:Architectures: s390 448062306a36Sopenharmony_ci:Type: vm ioctl 448162306a36Sopenharmony_ci:Parameters: struct kvm_s390_cmma_log (in, out) 448262306a36Sopenharmony_ci:Returns: 0 on success, a negative value on error 448362306a36Sopenharmony_ci 448462306a36Sopenharmony_ciErrors: 448562306a36Sopenharmony_ci 448662306a36Sopenharmony_ci ====== ============================================================= 448762306a36Sopenharmony_ci ENOMEM not enough memory can be allocated to complete the task 448862306a36Sopenharmony_ci ENXIO if CMMA is not enabled 448962306a36Sopenharmony_ci EINVAL if KVM_S390_CMMA_PEEK is not set but migration mode was not enabled 449062306a36Sopenharmony_ci EINVAL if KVM_S390_CMMA_PEEK is not set but dirty tracking has been 449162306a36Sopenharmony_ci disabled (and thus migration mode was automatically disabled) 449262306a36Sopenharmony_ci EFAULT if the userspace address is invalid or if no page table is 449362306a36Sopenharmony_ci present for the addresses (e.g. when using hugepages). 449462306a36Sopenharmony_ci ====== ============================================================= 449562306a36Sopenharmony_ci 449662306a36Sopenharmony_ciThis ioctl is used to get the values of the CMMA bits on the s390 449762306a36Sopenharmony_ciarchitecture. It is meant to be used in two scenarios: 449862306a36Sopenharmony_ci 449962306a36Sopenharmony_ci- During live migration to save the CMMA values. Live migration needs 450062306a36Sopenharmony_ci to be enabled via the KVM_REQ_START_MIGRATION VM property. 450162306a36Sopenharmony_ci- To non-destructively peek at the CMMA values, with the flag 450262306a36Sopenharmony_ci KVM_S390_CMMA_PEEK set. 450362306a36Sopenharmony_ci 450462306a36Sopenharmony_ciThe ioctl takes parameters via the kvm_s390_cmma_log struct. The desired 450562306a36Sopenharmony_civalues are written to a buffer whose location is indicated via the "values" 450662306a36Sopenharmony_cimember in the kvm_s390_cmma_log struct. The values in the input struct are 450762306a36Sopenharmony_cialso updated as needed. 450862306a36Sopenharmony_ci 450962306a36Sopenharmony_ciEach CMMA value takes up one byte. 451062306a36Sopenharmony_ci 451162306a36Sopenharmony_ci:: 451262306a36Sopenharmony_ci 451362306a36Sopenharmony_ci struct kvm_s390_cmma_log { 451462306a36Sopenharmony_ci __u64 start_gfn; 451562306a36Sopenharmony_ci __u32 count; 451662306a36Sopenharmony_ci __u32 flags; 451762306a36Sopenharmony_ci union { 451862306a36Sopenharmony_ci __u64 remaining; 451962306a36Sopenharmony_ci __u64 mask; 452062306a36Sopenharmony_ci }; 452162306a36Sopenharmony_ci __u64 values; 452262306a36Sopenharmony_ci }; 452362306a36Sopenharmony_ci 452462306a36Sopenharmony_cistart_gfn is the number of the first guest frame whose CMMA values are 452562306a36Sopenharmony_cito be retrieved, 452662306a36Sopenharmony_ci 452762306a36Sopenharmony_cicount is the length of the buffer in bytes, 452862306a36Sopenharmony_ci 452962306a36Sopenharmony_civalues points to the buffer where the result will be written to. 453062306a36Sopenharmony_ci 453162306a36Sopenharmony_ciIf count is greater than KVM_S390_SKEYS_MAX, then it is considered to be 453262306a36Sopenharmony_ciKVM_S390_SKEYS_MAX. KVM_S390_SKEYS_MAX is re-used for consistency with 453362306a36Sopenharmony_ciother ioctls. 453462306a36Sopenharmony_ci 453562306a36Sopenharmony_ciThe result is written in the buffer pointed to by the field values, and 453662306a36Sopenharmony_cithe values of the input parameter are updated as follows. 453762306a36Sopenharmony_ci 453862306a36Sopenharmony_ciDepending on the flags, different actions are performed. The only 453962306a36Sopenharmony_cisupported flag so far is KVM_S390_CMMA_PEEK. 454062306a36Sopenharmony_ci 454162306a36Sopenharmony_ciThe default behaviour if KVM_S390_CMMA_PEEK is not set is: 454262306a36Sopenharmony_cistart_gfn will indicate the first page frame whose CMMA bits were dirty. 454362306a36Sopenharmony_ciIt is not necessarily the same as the one passed as input, as clean pages 454462306a36Sopenharmony_ciare skipped. 454562306a36Sopenharmony_ci 454662306a36Sopenharmony_cicount will indicate the number of bytes actually written in the buffer. 454762306a36Sopenharmony_ciIt can (and very often will) be smaller than the input value, since the 454862306a36Sopenharmony_cibuffer is only filled until 16 bytes of clean values are found (which 454962306a36Sopenharmony_ciare then not copied in the buffer). Since a CMMA migration block needs 455062306a36Sopenharmony_cithe base address and the length, for a total of 16 bytes, we will send 455162306a36Sopenharmony_ciback some clean data if there is some dirty data afterwards, as long as 455262306a36Sopenharmony_cithe size of the clean data does not exceed the size of the header. This 455362306a36Sopenharmony_ciallows to minimize the amount of data to be saved or transferred over 455462306a36Sopenharmony_cithe network at the expense of more roundtrips to userspace. The next 455562306a36Sopenharmony_ciinvocation of the ioctl will skip over all the clean values, saving 455662306a36Sopenharmony_cipotentially more than just the 16 bytes we found. 455762306a36Sopenharmony_ci 455862306a36Sopenharmony_ciIf KVM_S390_CMMA_PEEK is set: 455962306a36Sopenharmony_cithe existing storage attributes are read even when not in migration 456062306a36Sopenharmony_cimode, and no other action is performed; 456162306a36Sopenharmony_ci 456262306a36Sopenharmony_cithe output start_gfn will be equal to the input start_gfn, 456362306a36Sopenharmony_ci 456462306a36Sopenharmony_cithe output count will be equal to the input count, except if the end of 456562306a36Sopenharmony_cimemory has been reached. 456662306a36Sopenharmony_ci 456762306a36Sopenharmony_ciIn both cases: 456862306a36Sopenharmony_cithe field "remaining" will indicate the total number of dirty CMMA values 456962306a36Sopenharmony_cistill remaining, or 0 if KVM_S390_CMMA_PEEK is set and migration mode is 457062306a36Sopenharmony_cinot enabled. 457162306a36Sopenharmony_ci 457262306a36Sopenharmony_cimask is unused. 457362306a36Sopenharmony_ci 457462306a36Sopenharmony_civalues points to the userspace buffer where the result will be stored. 457562306a36Sopenharmony_ci 457662306a36Sopenharmony_ci4.108 KVM_S390_SET_CMMA_BITS 457762306a36Sopenharmony_ci---------------------------- 457862306a36Sopenharmony_ci 457962306a36Sopenharmony_ci:Capability: KVM_CAP_S390_CMMA_MIGRATION 458062306a36Sopenharmony_ci:Architectures: s390 458162306a36Sopenharmony_ci:Type: vm ioctl 458262306a36Sopenharmony_ci:Parameters: struct kvm_s390_cmma_log (in) 458362306a36Sopenharmony_ci:Returns: 0 on success, a negative value on error 458462306a36Sopenharmony_ci 458562306a36Sopenharmony_ciThis ioctl is used to set the values of the CMMA bits on the s390 458662306a36Sopenharmony_ciarchitecture. It is meant to be used during live migration to restore 458762306a36Sopenharmony_cithe CMMA values, but there are no restrictions on its use. 458862306a36Sopenharmony_ciThe ioctl takes parameters via the kvm_s390_cmma_values struct. 458962306a36Sopenharmony_ciEach CMMA value takes up one byte. 459062306a36Sopenharmony_ci 459162306a36Sopenharmony_ci:: 459262306a36Sopenharmony_ci 459362306a36Sopenharmony_ci struct kvm_s390_cmma_log { 459462306a36Sopenharmony_ci __u64 start_gfn; 459562306a36Sopenharmony_ci __u32 count; 459662306a36Sopenharmony_ci __u32 flags; 459762306a36Sopenharmony_ci union { 459862306a36Sopenharmony_ci __u64 remaining; 459962306a36Sopenharmony_ci __u64 mask; 460062306a36Sopenharmony_ci }; 460162306a36Sopenharmony_ci __u64 values; 460262306a36Sopenharmony_ci }; 460362306a36Sopenharmony_ci 460462306a36Sopenharmony_cistart_gfn indicates the starting guest frame number, 460562306a36Sopenharmony_ci 460662306a36Sopenharmony_cicount indicates how many values are to be considered in the buffer, 460762306a36Sopenharmony_ci 460862306a36Sopenharmony_ciflags is not used and must be 0. 460962306a36Sopenharmony_ci 461062306a36Sopenharmony_cimask indicates which PGSTE bits are to be considered. 461162306a36Sopenharmony_ci 461262306a36Sopenharmony_ciremaining is not used. 461362306a36Sopenharmony_ci 461462306a36Sopenharmony_civalues points to the buffer in userspace where to store the values. 461562306a36Sopenharmony_ci 461662306a36Sopenharmony_ciThis ioctl can fail with -ENOMEM if not enough memory can be allocated to 461762306a36Sopenharmony_cicomplete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if 461862306a36Sopenharmony_cithe count field is too large (e.g. more than KVM_S390_CMMA_SIZE_MAX) or 461962306a36Sopenharmony_ciif the flags field was not 0, with -EFAULT if the userspace address is 462062306a36Sopenharmony_ciinvalid, if invalid pages are written to (e.g. after the end of memory) 462162306a36Sopenharmony_cior if no page table is present for the addresses (e.g. when using 462262306a36Sopenharmony_cihugepages). 462362306a36Sopenharmony_ci 462462306a36Sopenharmony_ci4.109 KVM_PPC_GET_CPU_CHAR 462562306a36Sopenharmony_ci-------------------------- 462662306a36Sopenharmony_ci 462762306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_GET_CPU_CHAR 462862306a36Sopenharmony_ci:Architectures: powerpc 462962306a36Sopenharmony_ci:Type: vm ioctl 463062306a36Sopenharmony_ci:Parameters: struct kvm_ppc_cpu_char (out) 463162306a36Sopenharmony_ci:Returns: 0 on successful completion, 463262306a36Sopenharmony_ci -EFAULT if struct kvm_ppc_cpu_char cannot be written 463362306a36Sopenharmony_ci 463462306a36Sopenharmony_ciThis ioctl gives userspace information about certain characteristics 463562306a36Sopenharmony_ciof the CPU relating to speculative execution of instructions and 463662306a36Sopenharmony_cipossible information leakage resulting from speculative execution (see 463762306a36Sopenharmony_ciCVE-2017-5715, CVE-2017-5753 and CVE-2017-5754). The information is 463862306a36Sopenharmony_cireturned in struct kvm_ppc_cpu_char, which looks like this:: 463962306a36Sopenharmony_ci 464062306a36Sopenharmony_ci struct kvm_ppc_cpu_char { 464162306a36Sopenharmony_ci __u64 character; /* characteristics of the CPU */ 464262306a36Sopenharmony_ci __u64 behaviour; /* recommended software behaviour */ 464362306a36Sopenharmony_ci __u64 character_mask; /* valid bits in character */ 464462306a36Sopenharmony_ci __u64 behaviour_mask; /* valid bits in behaviour */ 464562306a36Sopenharmony_ci }; 464662306a36Sopenharmony_ci 464762306a36Sopenharmony_ciFor extensibility, the character_mask and behaviour_mask fields 464862306a36Sopenharmony_ciindicate which bits of character and behaviour have been filled in by 464962306a36Sopenharmony_cithe kernel. If the set of defined bits is extended in future then 465062306a36Sopenharmony_ciuserspace will be able to tell whether it is running on a kernel that 465162306a36Sopenharmony_ciknows about the new bits. 465262306a36Sopenharmony_ci 465362306a36Sopenharmony_ciThe character field describes attributes of the CPU which can help 465462306a36Sopenharmony_ciwith preventing inadvertent information disclosure - specifically, 465562306a36Sopenharmony_ciwhether there is an instruction to flash-invalidate the L1 data cache 465662306a36Sopenharmony_ci(ori 30,30,0 or mtspr SPRN_TRIG2,rN), whether the L1 data cache is set 465762306a36Sopenharmony_cito a mode where entries can only be used by the thread that created 465862306a36Sopenharmony_cithem, whether the bcctr[l] instruction prevents speculation, and 465962306a36Sopenharmony_ciwhether a speculation barrier instruction (ori 31,31,0) is provided. 466062306a36Sopenharmony_ci 466162306a36Sopenharmony_ciThe behaviour field describes actions that software should take to 466262306a36Sopenharmony_ciprevent inadvertent information disclosure, and thus describes which 466362306a36Sopenharmony_civulnerabilities the hardware is subject to; specifically whether the 466462306a36Sopenharmony_ciL1 data cache should be flushed when returning to user mode from the 466562306a36Sopenharmony_cikernel, and whether a speculation barrier should be placed between an 466662306a36Sopenharmony_ciarray bounds check and the array access. 466762306a36Sopenharmony_ci 466862306a36Sopenharmony_ciThese fields use the same bit definitions as the new 466962306a36Sopenharmony_ciH_GET_CPU_CHARACTERISTICS hypercall. 467062306a36Sopenharmony_ci 467162306a36Sopenharmony_ci4.110 KVM_MEMORY_ENCRYPT_OP 467262306a36Sopenharmony_ci--------------------------- 467362306a36Sopenharmony_ci 467462306a36Sopenharmony_ci:Capability: basic 467562306a36Sopenharmony_ci:Architectures: x86 467662306a36Sopenharmony_ci:Type: vm 467762306a36Sopenharmony_ci:Parameters: an opaque platform specific structure (in/out) 467862306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 467962306a36Sopenharmony_ci 468062306a36Sopenharmony_ciIf the platform supports creating encrypted VMs then this ioctl can be used 468162306a36Sopenharmony_cifor issuing platform-specific memory encryption commands to manage those 468262306a36Sopenharmony_ciencrypted VMs. 468362306a36Sopenharmony_ci 468462306a36Sopenharmony_ciCurrently, this ioctl is used for issuing Secure Encrypted Virtualization 468562306a36Sopenharmony_ci(SEV) commands on AMD Processors. The SEV commands are defined in 468662306a36Sopenharmony_ciDocumentation/virt/kvm/x86/amd-memory-encryption.rst. 468762306a36Sopenharmony_ci 468862306a36Sopenharmony_ci4.111 KVM_MEMORY_ENCRYPT_REG_REGION 468962306a36Sopenharmony_ci----------------------------------- 469062306a36Sopenharmony_ci 469162306a36Sopenharmony_ci:Capability: basic 469262306a36Sopenharmony_ci:Architectures: x86 469362306a36Sopenharmony_ci:Type: system 469462306a36Sopenharmony_ci:Parameters: struct kvm_enc_region (in) 469562306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 469662306a36Sopenharmony_ci 469762306a36Sopenharmony_ciThis ioctl can be used to register a guest memory region which may 469862306a36Sopenharmony_cicontain encrypted data (e.g. guest RAM, SMRAM etc). 469962306a36Sopenharmony_ci 470062306a36Sopenharmony_ciIt is used in the SEV-enabled guest. When encryption is enabled, a guest 470162306a36Sopenharmony_cimemory region may contain encrypted data. The SEV memory encryption 470262306a36Sopenharmony_ciengine uses a tweak such that two identical plaintext pages, each at 470362306a36Sopenharmony_cidifferent locations will have differing ciphertexts. So swapping or 470462306a36Sopenharmony_cimoving ciphertext of those pages will not result in plaintext being 470562306a36Sopenharmony_ciswapped. So relocating (or migrating) physical backing pages for the SEV 470662306a36Sopenharmony_ciguest will require some additional steps. 470762306a36Sopenharmony_ci 470862306a36Sopenharmony_ciNote: The current SEV key management spec does not provide commands to 470962306a36Sopenharmony_ciswap or migrate (move) ciphertext pages. Hence, for now we pin the guest 471062306a36Sopenharmony_cimemory region registered with the ioctl. 471162306a36Sopenharmony_ci 471262306a36Sopenharmony_ci4.112 KVM_MEMORY_ENCRYPT_UNREG_REGION 471362306a36Sopenharmony_ci------------------------------------- 471462306a36Sopenharmony_ci 471562306a36Sopenharmony_ci:Capability: basic 471662306a36Sopenharmony_ci:Architectures: x86 471762306a36Sopenharmony_ci:Type: system 471862306a36Sopenharmony_ci:Parameters: struct kvm_enc_region (in) 471962306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 472062306a36Sopenharmony_ci 472162306a36Sopenharmony_ciThis ioctl can be used to unregister the guest memory region registered 472262306a36Sopenharmony_ciwith KVM_MEMORY_ENCRYPT_REG_REGION ioctl above. 472362306a36Sopenharmony_ci 472462306a36Sopenharmony_ci4.113 KVM_HYPERV_EVENTFD 472562306a36Sopenharmony_ci------------------------ 472662306a36Sopenharmony_ci 472762306a36Sopenharmony_ci:Capability: KVM_CAP_HYPERV_EVENTFD 472862306a36Sopenharmony_ci:Architectures: x86 472962306a36Sopenharmony_ci:Type: vm ioctl 473062306a36Sopenharmony_ci:Parameters: struct kvm_hyperv_eventfd (in) 473162306a36Sopenharmony_ci 473262306a36Sopenharmony_ciThis ioctl (un)registers an eventfd to receive notifications from the guest on 473362306a36Sopenharmony_cithe specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without 473462306a36Sopenharmony_cicausing a user exit. SIGNAL_EVENT hypercall with non-zero event flag number 473562306a36Sopenharmony_ci(bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL user exit. 473662306a36Sopenharmony_ci 473762306a36Sopenharmony_ci:: 473862306a36Sopenharmony_ci 473962306a36Sopenharmony_ci struct kvm_hyperv_eventfd { 474062306a36Sopenharmony_ci __u32 conn_id; 474162306a36Sopenharmony_ci __s32 fd; 474262306a36Sopenharmony_ci __u32 flags; 474362306a36Sopenharmony_ci __u32 padding[3]; 474462306a36Sopenharmony_ci }; 474562306a36Sopenharmony_ci 474662306a36Sopenharmony_ciThe conn_id field should fit within 24 bits:: 474762306a36Sopenharmony_ci 474862306a36Sopenharmony_ci #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff 474962306a36Sopenharmony_ci 475062306a36Sopenharmony_ciThe acceptable values for the flags field are:: 475162306a36Sopenharmony_ci 475262306a36Sopenharmony_ci #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) 475362306a36Sopenharmony_ci 475462306a36Sopenharmony_ci:Returns: 0 on success, 475562306a36Sopenharmony_ci -EINVAL if conn_id or flags is outside the allowed range, 475662306a36Sopenharmony_ci -ENOENT on deassign if the conn_id isn't registered, 475762306a36Sopenharmony_ci -EEXIST on assign if the conn_id is already registered 475862306a36Sopenharmony_ci 475962306a36Sopenharmony_ci4.114 KVM_GET_NESTED_STATE 476062306a36Sopenharmony_ci-------------------------- 476162306a36Sopenharmony_ci 476262306a36Sopenharmony_ci:Capability: KVM_CAP_NESTED_STATE 476362306a36Sopenharmony_ci:Architectures: x86 476462306a36Sopenharmony_ci:Type: vcpu ioctl 476562306a36Sopenharmony_ci:Parameters: struct kvm_nested_state (in/out) 476662306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 476762306a36Sopenharmony_ci 476862306a36Sopenharmony_ciErrors: 476962306a36Sopenharmony_ci 477062306a36Sopenharmony_ci ===== ============================================================= 477162306a36Sopenharmony_ci E2BIG the total state size exceeds the value of 'size' specified by 477262306a36Sopenharmony_ci the user; the size required will be written into size. 477362306a36Sopenharmony_ci ===== ============================================================= 477462306a36Sopenharmony_ci 477562306a36Sopenharmony_ci:: 477662306a36Sopenharmony_ci 477762306a36Sopenharmony_ci struct kvm_nested_state { 477862306a36Sopenharmony_ci __u16 flags; 477962306a36Sopenharmony_ci __u16 format; 478062306a36Sopenharmony_ci __u32 size; 478162306a36Sopenharmony_ci 478262306a36Sopenharmony_ci union { 478362306a36Sopenharmony_ci struct kvm_vmx_nested_state_hdr vmx; 478462306a36Sopenharmony_ci struct kvm_svm_nested_state_hdr svm; 478562306a36Sopenharmony_ci 478662306a36Sopenharmony_ci /* Pad the header to 128 bytes. */ 478762306a36Sopenharmony_ci __u8 pad[120]; 478862306a36Sopenharmony_ci } hdr; 478962306a36Sopenharmony_ci 479062306a36Sopenharmony_ci union { 479162306a36Sopenharmony_ci struct kvm_vmx_nested_state_data vmx[0]; 479262306a36Sopenharmony_ci struct kvm_svm_nested_state_data svm[0]; 479362306a36Sopenharmony_ci } data; 479462306a36Sopenharmony_ci }; 479562306a36Sopenharmony_ci 479662306a36Sopenharmony_ci #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 479762306a36Sopenharmony_ci #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 479862306a36Sopenharmony_ci #define KVM_STATE_NESTED_EVMCS 0x00000004 479962306a36Sopenharmony_ci 480062306a36Sopenharmony_ci #define KVM_STATE_NESTED_FORMAT_VMX 0 480162306a36Sopenharmony_ci #define KVM_STATE_NESTED_FORMAT_SVM 1 480262306a36Sopenharmony_ci 480362306a36Sopenharmony_ci #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 480462306a36Sopenharmony_ci 480562306a36Sopenharmony_ci #define KVM_STATE_NESTED_VMX_SMM_GUEST_MODE 0x00000001 480662306a36Sopenharmony_ci #define KVM_STATE_NESTED_VMX_SMM_VMXON 0x00000002 480762306a36Sopenharmony_ci 480862306a36Sopenharmony_ci #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 480962306a36Sopenharmony_ci 481062306a36Sopenharmony_ci struct kvm_vmx_nested_state_hdr { 481162306a36Sopenharmony_ci __u64 vmxon_pa; 481262306a36Sopenharmony_ci __u64 vmcs12_pa; 481362306a36Sopenharmony_ci 481462306a36Sopenharmony_ci struct { 481562306a36Sopenharmony_ci __u16 flags; 481662306a36Sopenharmony_ci } smm; 481762306a36Sopenharmony_ci 481862306a36Sopenharmony_ci __u32 flags; 481962306a36Sopenharmony_ci __u64 preemption_timer_deadline; 482062306a36Sopenharmony_ci }; 482162306a36Sopenharmony_ci 482262306a36Sopenharmony_ci struct kvm_vmx_nested_state_data { 482362306a36Sopenharmony_ci __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 482462306a36Sopenharmony_ci __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; 482562306a36Sopenharmony_ci }; 482662306a36Sopenharmony_ci 482762306a36Sopenharmony_ciThis ioctl copies the vcpu's nested virtualization state from the kernel to 482862306a36Sopenharmony_ciuserspace. 482962306a36Sopenharmony_ci 483062306a36Sopenharmony_ciThe maximum size of the state can be retrieved by passing KVM_CAP_NESTED_STATE 483162306a36Sopenharmony_cito the KVM_CHECK_EXTENSION ioctl(). 483262306a36Sopenharmony_ci 483362306a36Sopenharmony_ci4.115 KVM_SET_NESTED_STATE 483462306a36Sopenharmony_ci-------------------------- 483562306a36Sopenharmony_ci 483662306a36Sopenharmony_ci:Capability: KVM_CAP_NESTED_STATE 483762306a36Sopenharmony_ci:Architectures: x86 483862306a36Sopenharmony_ci:Type: vcpu ioctl 483962306a36Sopenharmony_ci:Parameters: struct kvm_nested_state (in) 484062306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 484162306a36Sopenharmony_ci 484262306a36Sopenharmony_ciThis copies the vcpu's kvm_nested_state struct from userspace to the kernel. 484362306a36Sopenharmony_ciFor the definition of struct kvm_nested_state, see KVM_GET_NESTED_STATE. 484462306a36Sopenharmony_ci 484562306a36Sopenharmony_ci4.116 KVM_(UN)REGISTER_COALESCED_MMIO 484662306a36Sopenharmony_ci------------------------------------- 484762306a36Sopenharmony_ci 484862306a36Sopenharmony_ci:Capability: KVM_CAP_COALESCED_MMIO (for coalesced mmio) 484962306a36Sopenharmony_ci KVM_CAP_COALESCED_PIO (for coalesced pio) 485062306a36Sopenharmony_ci:Architectures: all 485162306a36Sopenharmony_ci:Type: vm ioctl 485262306a36Sopenharmony_ci:Parameters: struct kvm_coalesced_mmio_zone 485362306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 485462306a36Sopenharmony_ci 485562306a36Sopenharmony_ciCoalesced I/O is a performance optimization that defers hardware 485662306a36Sopenharmony_ciregister write emulation so that userspace exits are avoided. It is 485762306a36Sopenharmony_citypically used to reduce the overhead of emulating frequently accessed 485862306a36Sopenharmony_cihardware registers. 485962306a36Sopenharmony_ci 486062306a36Sopenharmony_ciWhen a hardware register is configured for coalesced I/O, write accesses 486162306a36Sopenharmony_cido not exit to userspace and their value is recorded in a ring buffer 486262306a36Sopenharmony_cithat is shared between kernel and userspace. 486362306a36Sopenharmony_ci 486462306a36Sopenharmony_ciCoalesced I/O is used if one or more write accesses to a hardware 486562306a36Sopenharmony_ciregister can be deferred until a read or a write to another hardware 486662306a36Sopenharmony_ciregister on the same device. This last access will cause a vmexit and 486762306a36Sopenharmony_ciuserspace will process accesses from the ring buffer before emulating 486862306a36Sopenharmony_ciit. That will avoid exiting to userspace on repeated writes. 486962306a36Sopenharmony_ci 487062306a36Sopenharmony_ciCoalesced pio is based on coalesced mmio. There is little difference 487162306a36Sopenharmony_cibetween coalesced mmio and pio except that coalesced pio records accesses 487262306a36Sopenharmony_cito I/O ports. 487362306a36Sopenharmony_ci 487462306a36Sopenharmony_ci4.117 KVM_CLEAR_DIRTY_LOG (vm ioctl) 487562306a36Sopenharmony_ci------------------------------------ 487662306a36Sopenharmony_ci 487762306a36Sopenharmony_ci:Capability: KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 487862306a36Sopenharmony_ci:Architectures: x86, arm64, mips 487962306a36Sopenharmony_ci:Type: vm ioctl 488062306a36Sopenharmony_ci:Parameters: struct kvm_clear_dirty_log (in) 488162306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 488262306a36Sopenharmony_ci 488362306a36Sopenharmony_ci:: 488462306a36Sopenharmony_ci 488562306a36Sopenharmony_ci /* for KVM_CLEAR_DIRTY_LOG */ 488662306a36Sopenharmony_ci struct kvm_clear_dirty_log { 488762306a36Sopenharmony_ci __u32 slot; 488862306a36Sopenharmony_ci __u32 num_pages; 488962306a36Sopenharmony_ci __u64 first_page; 489062306a36Sopenharmony_ci union { 489162306a36Sopenharmony_ci void __user *dirty_bitmap; /* one bit per page */ 489262306a36Sopenharmony_ci __u64 padding; 489362306a36Sopenharmony_ci }; 489462306a36Sopenharmony_ci }; 489562306a36Sopenharmony_ci 489662306a36Sopenharmony_ciThe ioctl clears the dirty status of pages in a memory slot, according to 489762306a36Sopenharmony_cithe bitmap that is passed in struct kvm_clear_dirty_log's dirty_bitmap 489862306a36Sopenharmony_cifield. Bit 0 of the bitmap corresponds to page "first_page" in the 489962306a36Sopenharmony_cimemory slot, and num_pages is the size in bits of the input bitmap. 490062306a36Sopenharmony_cifirst_page must be a multiple of 64; num_pages must also be a multiple of 490162306a36Sopenharmony_ci64 unless first_page + num_pages is the size of the memory slot. For each 490262306a36Sopenharmony_cibit that is set in the input bitmap, the corresponding page is marked "clean" 490362306a36Sopenharmony_ciin KVM's dirty bitmap, and dirty tracking is re-enabled for that page 490462306a36Sopenharmony_ci(for example via write-protection, or by clearing the dirty bit in 490562306a36Sopenharmony_cia page table entry). 490662306a36Sopenharmony_ci 490762306a36Sopenharmony_ciIf KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of slot field specifies 490862306a36Sopenharmony_cithe address space for which you want to clear the dirty status. See 490962306a36Sopenharmony_ciKVM_SET_USER_MEMORY_REGION for details on the usage of slot field. 491062306a36Sopenharmony_ci 491162306a36Sopenharmony_ciThis ioctl is mostly useful when KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 491262306a36Sopenharmony_ciis enabled; for more information, see the description of the capability. 491362306a36Sopenharmony_ciHowever, it can always be used as long as KVM_CHECK_EXTENSION confirms 491462306a36Sopenharmony_cithat KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is present. 491562306a36Sopenharmony_ci 491662306a36Sopenharmony_ci4.118 KVM_GET_SUPPORTED_HV_CPUID 491762306a36Sopenharmony_ci-------------------------------- 491862306a36Sopenharmony_ci 491962306a36Sopenharmony_ci:Capability: KVM_CAP_HYPERV_CPUID (vcpu), KVM_CAP_SYS_HYPERV_CPUID (system) 492062306a36Sopenharmony_ci:Architectures: x86 492162306a36Sopenharmony_ci:Type: system ioctl, vcpu ioctl 492262306a36Sopenharmony_ci:Parameters: struct kvm_cpuid2 (in/out) 492362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 492462306a36Sopenharmony_ci 492562306a36Sopenharmony_ci:: 492662306a36Sopenharmony_ci 492762306a36Sopenharmony_ci struct kvm_cpuid2 { 492862306a36Sopenharmony_ci __u32 nent; 492962306a36Sopenharmony_ci __u32 padding; 493062306a36Sopenharmony_ci struct kvm_cpuid_entry2 entries[0]; 493162306a36Sopenharmony_ci }; 493262306a36Sopenharmony_ci 493362306a36Sopenharmony_ci struct kvm_cpuid_entry2 { 493462306a36Sopenharmony_ci __u32 function; 493562306a36Sopenharmony_ci __u32 index; 493662306a36Sopenharmony_ci __u32 flags; 493762306a36Sopenharmony_ci __u32 eax; 493862306a36Sopenharmony_ci __u32 ebx; 493962306a36Sopenharmony_ci __u32 ecx; 494062306a36Sopenharmony_ci __u32 edx; 494162306a36Sopenharmony_ci __u32 padding[3]; 494262306a36Sopenharmony_ci }; 494362306a36Sopenharmony_ci 494462306a36Sopenharmony_ciThis ioctl returns x86 cpuid features leaves related to Hyper-V emulation in 494562306a36Sopenharmony_ciKVM. Userspace can use the information returned by this ioctl to construct 494662306a36Sopenharmony_cicpuid information presented to guests consuming Hyper-V enlightenments (e.g. 494762306a36Sopenharmony_ciWindows or Hyper-V guests). 494862306a36Sopenharmony_ci 494962306a36Sopenharmony_ciCPUID feature leaves returned by this ioctl are defined by Hyper-V Top Level 495062306a36Sopenharmony_ciFunctional Specification (TLFS). These leaves can't be obtained with 495162306a36Sopenharmony_ciKVM_GET_SUPPORTED_CPUID ioctl because some of them intersect with KVM feature 495262306a36Sopenharmony_cileaves (0x40000000, 0x40000001). 495362306a36Sopenharmony_ci 495462306a36Sopenharmony_ciCurrently, the following list of CPUID leaves are returned: 495562306a36Sopenharmony_ci 495662306a36Sopenharmony_ci - HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS 495762306a36Sopenharmony_ci - HYPERV_CPUID_INTERFACE 495862306a36Sopenharmony_ci - HYPERV_CPUID_VERSION 495962306a36Sopenharmony_ci - HYPERV_CPUID_FEATURES 496062306a36Sopenharmony_ci - HYPERV_CPUID_ENLIGHTMENT_INFO 496162306a36Sopenharmony_ci - HYPERV_CPUID_IMPLEMENT_LIMITS 496262306a36Sopenharmony_ci - HYPERV_CPUID_NESTED_FEATURES 496362306a36Sopenharmony_ci - HYPERV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS 496462306a36Sopenharmony_ci - HYPERV_CPUID_SYNDBG_INTERFACE 496562306a36Sopenharmony_ci - HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES 496662306a36Sopenharmony_ci 496762306a36Sopenharmony_ciUserspace invokes KVM_GET_SUPPORTED_HV_CPUID by passing a kvm_cpuid2 structure 496862306a36Sopenharmony_ciwith the 'nent' field indicating the number of entries in the variable-size 496962306a36Sopenharmony_ciarray 'entries'. If the number of entries is too low to describe all Hyper-V 497062306a36Sopenharmony_cifeature leaves, an error (E2BIG) is returned. If the number is more or equal 497162306a36Sopenharmony_cito the number of Hyper-V feature leaves, the 'nent' field is adjusted to the 497262306a36Sopenharmony_cinumber of valid entries in the 'entries' array, which is then filled. 497362306a36Sopenharmony_ci 497462306a36Sopenharmony_ci'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved, 497562306a36Sopenharmony_ciuserspace should not expect to get any particular value there. 497662306a36Sopenharmony_ci 497762306a36Sopenharmony_ciNote, vcpu version of KVM_GET_SUPPORTED_HV_CPUID is currently deprecated. Unlike 497862306a36Sopenharmony_cisystem ioctl which exposes all supported feature bits unconditionally, vcpu 497962306a36Sopenharmony_civersion has the following quirks: 498062306a36Sopenharmony_ci 498162306a36Sopenharmony_ci- HYPERV_CPUID_NESTED_FEATURES leaf and HV_X64_ENLIGHTENED_VMCS_RECOMMENDED 498262306a36Sopenharmony_ci feature bit are only exposed when Enlightened VMCS was previously enabled 498362306a36Sopenharmony_ci on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS). 498462306a36Sopenharmony_ci- HV_STIMER_DIRECT_MODE_AVAILABLE bit is only exposed with in-kernel LAPIC. 498562306a36Sopenharmony_ci (presumes KVM_CREATE_IRQCHIP has already been called). 498662306a36Sopenharmony_ci 498762306a36Sopenharmony_ci4.119 KVM_ARM_VCPU_FINALIZE 498862306a36Sopenharmony_ci--------------------------- 498962306a36Sopenharmony_ci 499062306a36Sopenharmony_ci:Architectures: arm64 499162306a36Sopenharmony_ci:Type: vcpu ioctl 499262306a36Sopenharmony_ci:Parameters: int feature (in) 499362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 499462306a36Sopenharmony_ci 499562306a36Sopenharmony_ciErrors: 499662306a36Sopenharmony_ci 499762306a36Sopenharmony_ci ====== ============================================================== 499862306a36Sopenharmony_ci EPERM feature not enabled, needs configuration, or already finalized 499962306a36Sopenharmony_ci EINVAL feature unknown or not present 500062306a36Sopenharmony_ci ====== ============================================================== 500162306a36Sopenharmony_ci 500262306a36Sopenharmony_ciRecognised values for feature: 500362306a36Sopenharmony_ci 500462306a36Sopenharmony_ci ===== =========================================== 500562306a36Sopenharmony_ci arm64 KVM_ARM_VCPU_SVE (requires KVM_CAP_ARM_SVE) 500662306a36Sopenharmony_ci ===== =========================================== 500762306a36Sopenharmony_ci 500862306a36Sopenharmony_ciFinalizes the configuration of the specified vcpu feature. 500962306a36Sopenharmony_ci 501062306a36Sopenharmony_ciThe vcpu must already have been initialised, enabling the affected feature, by 501162306a36Sopenharmony_cimeans of a successful KVM_ARM_VCPU_INIT call with the appropriate flag set in 501262306a36Sopenharmony_cifeatures[]. 501362306a36Sopenharmony_ci 501462306a36Sopenharmony_ciFor affected vcpu features, this is a mandatory step that must be performed 501562306a36Sopenharmony_cibefore the vcpu is fully usable. 501662306a36Sopenharmony_ci 501762306a36Sopenharmony_ciBetween KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE, the feature may be 501862306a36Sopenharmony_ciconfigured by use of ioctls such as KVM_SET_ONE_REG. The exact configuration 501962306a36Sopenharmony_cithat should be performaned and how to do it are feature-dependent. 502062306a36Sopenharmony_ci 502162306a36Sopenharmony_ciOther calls that depend on a particular feature being finalized, such as 502262306a36Sopenharmony_ciKVM_RUN, KVM_GET_REG_LIST, KVM_GET_ONE_REG and KVM_SET_ONE_REG, will fail with 502362306a36Sopenharmony_ci-EPERM unless the feature has already been finalized by means of a 502462306a36Sopenharmony_ciKVM_ARM_VCPU_FINALIZE call. 502562306a36Sopenharmony_ci 502662306a36Sopenharmony_ciSee KVM_ARM_VCPU_INIT for details of vcpu features that require finalization 502762306a36Sopenharmony_ciusing this ioctl. 502862306a36Sopenharmony_ci 502962306a36Sopenharmony_ci4.120 KVM_SET_PMU_EVENT_FILTER 503062306a36Sopenharmony_ci------------------------------ 503162306a36Sopenharmony_ci 503262306a36Sopenharmony_ci:Capability: KVM_CAP_PMU_EVENT_FILTER 503362306a36Sopenharmony_ci:Architectures: x86 503462306a36Sopenharmony_ci:Type: vm ioctl 503562306a36Sopenharmony_ci:Parameters: struct kvm_pmu_event_filter (in) 503662306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 503762306a36Sopenharmony_ci 503862306a36Sopenharmony_ciErrors: 503962306a36Sopenharmony_ci 504062306a36Sopenharmony_ci ====== ============================================================ 504162306a36Sopenharmony_ci EFAULT args[0] cannot be accessed 504262306a36Sopenharmony_ci EINVAL args[0] contains invalid data in the filter or filter events 504362306a36Sopenharmony_ci E2BIG nevents is too large 504462306a36Sopenharmony_ci EBUSY not enough memory to allocate the filter 504562306a36Sopenharmony_ci ====== ============================================================ 504662306a36Sopenharmony_ci 504762306a36Sopenharmony_ci:: 504862306a36Sopenharmony_ci 504962306a36Sopenharmony_ci struct kvm_pmu_event_filter { 505062306a36Sopenharmony_ci __u32 action; 505162306a36Sopenharmony_ci __u32 nevents; 505262306a36Sopenharmony_ci __u32 fixed_counter_bitmap; 505362306a36Sopenharmony_ci __u32 flags; 505462306a36Sopenharmony_ci __u32 pad[4]; 505562306a36Sopenharmony_ci __u64 events[0]; 505662306a36Sopenharmony_ci }; 505762306a36Sopenharmony_ci 505862306a36Sopenharmony_ciThis ioctl restricts the set of PMU events the guest can program by limiting 505962306a36Sopenharmony_ciwhich event select and unit mask combinations are permitted. 506062306a36Sopenharmony_ci 506162306a36Sopenharmony_ciThe argument holds a list of filter events which will be allowed or denied. 506262306a36Sopenharmony_ci 506362306a36Sopenharmony_ciFilter events only control general purpose counters; fixed purpose counters 506462306a36Sopenharmony_ciare controlled by the fixed_counter_bitmap. 506562306a36Sopenharmony_ci 506662306a36Sopenharmony_ciValid values for 'flags':: 506762306a36Sopenharmony_ci 506862306a36Sopenharmony_ci``0`` 506962306a36Sopenharmony_ci 507062306a36Sopenharmony_ciTo use this mode, clear the 'flags' field. 507162306a36Sopenharmony_ci 507262306a36Sopenharmony_ciIn this mode each event will contain an event select + unit mask. 507362306a36Sopenharmony_ci 507462306a36Sopenharmony_ciWhen the guest attempts to program the PMU the guest's event select + 507562306a36Sopenharmony_ciunit mask is compared against the filter events to determine whether the 507662306a36Sopenharmony_ciguest should have access. 507762306a36Sopenharmony_ci 507862306a36Sopenharmony_ci``KVM_PMU_EVENT_FLAG_MASKED_EVENTS`` 507962306a36Sopenharmony_ci:Capability: KVM_CAP_PMU_EVENT_MASKED_EVENTS 508062306a36Sopenharmony_ci 508162306a36Sopenharmony_ciIn this mode each filter event will contain an event select, mask, match, and 508262306a36Sopenharmony_ciexclude value. To encode a masked event use:: 508362306a36Sopenharmony_ci 508462306a36Sopenharmony_ci KVM_PMU_ENCODE_MASKED_ENTRY() 508562306a36Sopenharmony_ci 508662306a36Sopenharmony_ciAn encoded event will follow this layout:: 508762306a36Sopenharmony_ci 508862306a36Sopenharmony_ci Bits Description 508962306a36Sopenharmony_ci ---- ----------- 509062306a36Sopenharmony_ci 7:0 event select (low bits) 509162306a36Sopenharmony_ci 15:8 umask match 509262306a36Sopenharmony_ci 31:16 unused 509362306a36Sopenharmony_ci 35:32 event select (high bits) 509462306a36Sopenharmony_ci 36:54 unused 509562306a36Sopenharmony_ci 55 exclude bit 509662306a36Sopenharmony_ci 63:56 umask mask 509762306a36Sopenharmony_ci 509862306a36Sopenharmony_ciWhen the guest attempts to program the PMU, these steps are followed in 509962306a36Sopenharmony_cidetermining if the guest should have access: 510062306a36Sopenharmony_ci 510162306a36Sopenharmony_ci 1. Match the event select from the guest against the filter events. 510262306a36Sopenharmony_ci 2. If a match is found, match the guest's unit mask to the mask and match 510362306a36Sopenharmony_ci values of the included filter events. 510462306a36Sopenharmony_ci I.e. (unit mask & mask) == match && !exclude. 510562306a36Sopenharmony_ci 3. If a match is found, match the guest's unit mask to the mask and match 510662306a36Sopenharmony_ci values of the excluded filter events. 510762306a36Sopenharmony_ci I.e. (unit mask & mask) == match && exclude. 510862306a36Sopenharmony_ci 4. 510962306a36Sopenharmony_ci a. If an included match is found and an excluded match is not found, filter 511062306a36Sopenharmony_ci the event. 511162306a36Sopenharmony_ci b. For everything else, do not filter the event. 511262306a36Sopenharmony_ci 5. 511362306a36Sopenharmony_ci a. If the event is filtered and it's an allow list, allow the guest to 511462306a36Sopenharmony_ci program the event. 511562306a36Sopenharmony_ci b. If the event is filtered and it's a deny list, do not allow the guest to 511662306a36Sopenharmony_ci program the event. 511762306a36Sopenharmony_ci 511862306a36Sopenharmony_ciWhen setting a new pmu event filter, -EINVAL will be returned if any of the 511962306a36Sopenharmony_ciunused fields are set or if any of the high bits (35:32) in the event 512062306a36Sopenharmony_ciselect are set when called on Intel. 512162306a36Sopenharmony_ci 512262306a36Sopenharmony_ciValid values for 'action':: 512362306a36Sopenharmony_ci 512462306a36Sopenharmony_ci #define KVM_PMU_EVENT_ALLOW 0 512562306a36Sopenharmony_ci #define KVM_PMU_EVENT_DENY 1 512662306a36Sopenharmony_ci 512762306a36Sopenharmony_ci4.121 KVM_PPC_SVM_OFF 512862306a36Sopenharmony_ci--------------------- 512962306a36Sopenharmony_ci 513062306a36Sopenharmony_ci:Capability: basic 513162306a36Sopenharmony_ci:Architectures: powerpc 513262306a36Sopenharmony_ci:Type: vm ioctl 513362306a36Sopenharmony_ci:Parameters: none 513462306a36Sopenharmony_ci:Returns: 0 on successful completion, 513562306a36Sopenharmony_ci 513662306a36Sopenharmony_ciErrors: 513762306a36Sopenharmony_ci 513862306a36Sopenharmony_ci ====== ================================================================ 513962306a36Sopenharmony_ci EINVAL if ultravisor failed to terminate the secure guest 514062306a36Sopenharmony_ci ENOMEM if hypervisor failed to allocate new radix page tables for guest 514162306a36Sopenharmony_ci ====== ================================================================ 514262306a36Sopenharmony_ci 514362306a36Sopenharmony_ciThis ioctl is used to turn off the secure mode of the guest or transition 514462306a36Sopenharmony_cithe guest from secure mode to normal mode. This is invoked when the guest 514562306a36Sopenharmony_ciis reset. This has no effect if called for a normal guest. 514662306a36Sopenharmony_ci 514762306a36Sopenharmony_ciThis ioctl issues an ultravisor call to terminate the secure guest, 514862306a36Sopenharmony_ciunpins the VPA pages and releases all the device pages that are used to 514962306a36Sopenharmony_citrack the secure pages by hypervisor. 515062306a36Sopenharmony_ci 515162306a36Sopenharmony_ci4.122 KVM_S390_NORMAL_RESET 515262306a36Sopenharmony_ci--------------------------- 515362306a36Sopenharmony_ci 515462306a36Sopenharmony_ci:Capability: KVM_CAP_S390_VCPU_RESETS 515562306a36Sopenharmony_ci:Architectures: s390 515662306a36Sopenharmony_ci:Type: vcpu ioctl 515762306a36Sopenharmony_ci:Parameters: none 515862306a36Sopenharmony_ci:Returns: 0 515962306a36Sopenharmony_ci 516062306a36Sopenharmony_ciThis ioctl resets VCPU registers and control structures according to 516162306a36Sopenharmony_cithe cpu reset definition in the POP (Principles Of Operation). 516262306a36Sopenharmony_ci 516362306a36Sopenharmony_ci4.123 KVM_S390_INITIAL_RESET 516462306a36Sopenharmony_ci---------------------------- 516562306a36Sopenharmony_ci 516662306a36Sopenharmony_ci:Capability: none 516762306a36Sopenharmony_ci:Architectures: s390 516862306a36Sopenharmony_ci:Type: vcpu ioctl 516962306a36Sopenharmony_ci:Parameters: none 517062306a36Sopenharmony_ci:Returns: 0 517162306a36Sopenharmony_ci 517262306a36Sopenharmony_ciThis ioctl resets VCPU registers and control structures according to 517362306a36Sopenharmony_cithe initial cpu reset definition in the POP. However, the cpu is not 517462306a36Sopenharmony_ciput into ESA mode. This reset is a superset of the normal reset. 517562306a36Sopenharmony_ci 517662306a36Sopenharmony_ci4.124 KVM_S390_CLEAR_RESET 517762306a36Sopenharmony_ci-------------------------- 517862306a36Sopenharmony_ci 517962306a36Sopenharmony_ci:Capability: KVM_CAP_S390_VCPU_RESETS 518062306a36Sopenharmony_ci:Architectures: s390 518162306a36Sopenharmony_ci:Type: vcpu ioctl 518262306a36Sopenharmony_ci:Parameters: none 518362306a36Sopenharmony_ci:Returns: 0 518462306a36Sopenharmony_ci 518562306a36Sopenharmony_ciThis ioctl resets VCPU registers and control structures according to 518662306a36Sopenharmony_cithe clear cpu reset definition in the POP. However, the cpu is not put 518762306a36Sopenharmony_ciinto ESA mode. This reset is a superset of the initial reset. 518862306a36Sopenharmony_ci 518962306a36Sopenharmony_ci 519062306a36Sopenharmony_ci4.125 KVM_S390_PV_COMMAND 519162306a36Sopenharmony_ci------------------------- 519262306a36Sopenharmony_ci 519362306a36Sopenharmony_ci:Capability: KVM_CAP_S390_PROTECTED 519462306a36Sopenharmony_ci:Architectures: s390 519562306a36Sopenharmony_ci:Type: vm ioctl 519662306a36Sopenharmony_ci:Parameters: struct kvm_pv_cmd 519762306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 519862306a36Sopenharmony_ci 519962306a36Sopenharmony_ci:: 520062306a36Sopenharmony_ci 520162306a36Sopenharmony_ci struct kvm_pv_cmd { 520262306a36Sopenharmony_ci __u32 cmd; /* Command to be executed */ 520362306a36Sopenharmony_ci __u16 rc; /* Ultravisor return code */ 520462306a36Sopenharmony_ci __u16 rrc; /* Ultravisor return reason code */ 520562306a36Sopenharmony_ci __u64 data; /* Data or address */ 520662306a36Sopenharmony_ci __u32 flags; /* flags for future extensions. Must be 0 for now */ 520762306a36Sopenharmony_ci __u32 reserved[3]; 520862306a36Sopenharmony_ci }; 520962306a36Sopenharmony_ci 521062306a36Sopenharmony_ci**Ultravisor return codes** 521162306a36Sopenharmony_ciThe Ultravisor return (reason) codes are provided by the kernel if a 521262306a36Sopenharmony_ciUltravisor call has been executed to achieve the results expected by 521362306a36Sopenharmony_cithe command. Therefore they are independent of the IOCTL return 521462306a36Sopenharmony_cicode. If KVM changes `rc`, its value will always be greater than 0 521562306a36Sopenharmony_cihence setting it to 0 before issuing a PV command is advised to be 521662306a36Sopenharmony_ciable to detect a change of `rc`. 521762306a36Sopenharmony_ci 521862306a36Sopenharmony_ci**cmd values:** 521962306a36Sopenharmony_ci 522062306a36Sopenharmony_ciKVM_PV_ENABLE 522162306a36Sopenharmony_ci Allocate memory and register the VM with the Ultravisor, thereby 522262306a36Sopenharmony_ci donating memory to the Ultravisor that will become inaccessible to 522362306a36Sopenharmony_ci KVM. All existing CPUs are converted to protected ones. After this 522462306a36Sopenharmony_ci command has succeeded, any CPU added via hotplug will become 522562306a36Sopenharmony_ci protected during its creation as well. 522662306a36Sopenharmony_ci 522762306a36Sopenharmony_ci Errors: 522862306a36Sopenharmony_ci 522962306a36Sopenharmony_ci ===== ============================= 523062306a36Sopenharmony_ci EINTR an unmasked signal is pending 523162306a36Sopenharmony_ci ===== ============================= 523262306a36Sopenharmony_ci 523362306a36Sopenharmony_ciKVM_PV_DISABLE 523462306a36Sopenharmony_ci Deregister the VM from the Ultravisor and reclaim the memory that had 523562306a36Sopenharmony_ci been donated to the Ultravisor, making it usable by the kernel again. 523662306a36Sopenharmony_ci All registered VCPUs are converted back to non-protected ones. If a 523762306a36Sopenharmony_ci previous protected VM had been prepared for asynchronous teardown with 523862306a36Sopenharmony_ci KVM_PV_ASYNC_CLEANUP_PREPARE and not subsequently torn down with 523962306a36Sopenharmony_ci KVM_PV_ASYNC_CLEANUP_PERFORM, it will be torn down in this call 524062306a36Sopenharmony_ci together with the current protected VM. 524162306a36Sopenharmony_ci 524262306a36Sopenharmony_ciKVM_PV_VM_SET_SEC_PARMS 524362306a36Sopenharmony_ci Pass the image header from VM memory to the Ultravisor in 524462306a36Sopenharmony_ci preparation of image unpacking and verification. 524562306a36Sopenharmony_ci 524662306a36Sopenharmony_ciKVM_PV_VM_UNPACK 524762306a36Sopenharmony_ci Unpack (protect and decrypt) a page of the encrypted boot image. 524862306a36Sopenharmony_ci 524962306a36Sopenharmony_ciKVM_PV_VM_VERIFY 525062306a36Sopenharmony_ci Verify the integrity of the unpacked image. Only if this succeeds, 525162306a36Sopenharmony_ci KVM is allowed to start protected VCPUs. 525262306a36Sopenharmony_ci 525362306a36Sopenharmony_ciKVM_PV_INFO 525462306a36Sopenharmony_ci :Capability: KVM_CAP_S390_PROTECTED_DUMP 525562306a36Sopenharmony_ci 525662306a36Sopenharmony_ci Presents an API that provides Ultravisor related data to userspace 525762306a36Sopenharmony_ci via subcommands. len_max is the size of the user space buffer, 525862306a36Sopenharmony_ci len_written is KVM's indication of how much bytes of that buffer 525962306a36Sopenharmony_ci were actually written to. len_written can be used to determine the 526062306a36Sopenharmony_ci valid fields if more response fields are added in the future. 526162306a36Sopenharmony_ci 526262306a36Sopenharmony_ci :: 526362306a36Sopenharmony_ci 526462306a36Sopenharmony_ci enum pv_cmd_info_id { 526562306a36Sopenharmony_ci KVM_PV_INFO_VM, 526662306a36Sopenharmony_ci KVM_PV_INFO_DUMP, 526762306a36Sopenharmony_ci }; 526862306a36Sopenharmony_ci 526962306a36Sopenharmony_ci struct kvm_s390_pv_info_header { 527062306a36Sopenharmony_ci __u32 id; 527162306a36Sopenharmony_ci __u32 len_max; 527262306a36Sopenharmony_ci __u32 len_written; 527362306a36Sopenharmony_ci __u32 reserved; 527462306a36Sopenharmony_ci }; 527562306a36Sopenharmony_ci 527662306a36Sopenharmony_ci struct kvm_s390_pv_info { 527762306a36Sopenharmony_ci struct kvm_s390_pv_info_header header; 527862306a36Sopenharmony_ci struct kvm_s390_pv_info_dump dump; 527962306a36Sopenharmony_ci struct kvm_s390_pv_info_vm vm; 528062306a36Sopenharmony_ci }; 528162306a36Sopenharmony_ci 528262306a36Sopenharmony_ci**subcommands:** 528362306a36Sopenharmony_ci 528462306a36Sopenharmony_ci KVM_PV_INFO_VM 528562306a36Sopenharmony_ci This subcommand provides basic Ultravisor information for PV 528662306a36Sopenharmony_ci hosts. These values are likely also exported as files in the sysfs 528762306a36Sopenharmony_ci firmware UV query interface but they are more easily available to 528862306a36Sopenharmony_ci programs in this API. 528962306a36Sopenharmony_ci 529062306a36Sopenharmony_ci The installed calls and feature_indication members provide the 529162306a36Sopenharmony_ci installed UV calls and the UV's other feature indications. 529262306a36Sopenharmony_ci 529362306a36Sopenharmony_ci The max_* members provide information about the maximum number of PV 529462306a36Sopenharmony_ci vcpus, PV guests and PV guest memory size. 529562306a36Sopenharmony_ci 529662306a36Sopenharmony_ci :: 529762306a36Sopenharmony_ci 529862306a36Sopenharmony_ci struct kvm_s390_pv_info_vm { 529962306a36Sopenharmony_ci __u64 inst_calls_list[4]; 530062306a36Sopenharmony_ci __u64 max_cpus; 530162306a36Sopenharmony_ci __u64 max_guests; 530262306a36Sopenharmony_ci __u64 max_guest_addr; 530362306a36Sopenharmony_ci __u64 feature_indication; 530462306a36Sopenharmony_ci }; 530562306a36Sopenharmony_ci 530662306a36Sopenharmony_ci 530762306a36Sopenharmony_ci KVM_PV_INFO_DUMP 530862306a36Sopenharmony_ci This subcommand provides information related to dumping PV guests. 530962306a36Sopenharmony_ci 531062306a36Sopenharmony_ci :: 531162306a36Sopenharmony_ci 531262306a36Sopenharmony_ci struct kvm_s390_pv_info_dump { 531362306a36Sopenharmony_ci __u64 dump_cpu_buffer_len; 531462306a36Sopenharmony_ci __u64 dump_config_mem_buffer_per_1m; 531562306a36Sopenharmony_ci __u64 dump_config_finalize_len; 531662306a36Sopenharmony_ci }; 531762306a36Sopenharmony_ci 531862306a36Sopenharmony_ciKVM_PV_DUMP 531962306a36Sopenharmony_ci :Capability: KVM_CAP_S390_PROTECTED_DUMP 532062306a36Sopenharmony_ci 532162306a36Sopenharmony_ci Presents an API that provides calls which facilitate dumping a 532262306a36Sopenharmony_ci protected VM. 532362306a36Sopenharmony_ci 532462306a36Sopenharmony_ci :: 532562306a36Sopenharmony_ci 532662306a36Sopenharmony_ci struct kvm_s390_pv_dmp { 532762306a36Sopenharmony_ci __u64 subcmd; 532862306a36Sopenharmony_ci __u64 buff_addr; 532962306a36Sopenharmony_ci __u64 buff_len; 533062306a36Sopenharmony_ci __u64 gaddr; /* For dump storage state */ 533162306a36Sopenharmony_ci }; 533262306a36Sopenharmony_ci 533362306a36Sopenharmony_ci **subcommands:** 533462306a36Sopenharmony_ci 533562306a36Sopenharmony_ci KVM_PV_DUMP_INIT 533662306a36Sopenharmony_ci Initializes the dump process of a protected VM. If this call does 533762306a36Sopenharmony_ci not succeed all other subcommands will fail with -EINVAL. This 533862306a36Sopenharmony_ci subcommand will return -EINVAL if a dump process has not yet been 533962306a36Sopenharmony_ci completed. 534062306a36Sopenharmony_ci 534162306a36Sopenharmony_ci Not all PV vms can be dumped, the owner needs to set `dump 534262306a36Sopenharmony_ci allowed` PCF bit 34 in the SE header to allow dumping. 534362306a36Sopenharmony_ci 534462306a36Sopenharmony_ci KVM_PV_DUMP_CONFIG_STOR_STATE 534562306a36Sopenharmony_ci Stores `buff_len` bytes of tweak component values starting with 534662306a36Sopenharmony_ci the 1MB block specified by the absolute guest address 534762306a36Sopenharmony_ci (`gaddr`). `buff_len` needs to be `conf_dump_storage_state_len` 534862306a36Sopenharmony_ci aligned and at least >= the `conf_dump_storage_state_len` value 534962306a36Sopenharmony_ci provided by the dump uv_info data. buff_user might be written to 535062306a36Sopenharmony_ci even if an error rc is returned. For instance if we encounter a 535162306a36Sopenharmony_ci fault after writing the first page of data. 535262306a36Sopenharmony_ci 535362306a36Sopenharmony_ci KVM_PV_DUMP_COMPLETE 535462306a36Sopenharmony_ci If the subcommand succeeds it completes the dump process and lets 535562306a36Sopenharmony_ci KVM_PV_DUMP_INIT be called again. 535662306a36Sopenharmony_ci 535762306a36Sopenharmony_ci On success `conf_dump_finalize_len` bytes of completion data will be 535862306a36Sopenharmony_ci stored to the `buff_addr`. The completion data contains a key 535962306a36Sopenharmony_ci derivation seed, IV, tweak nonce and encryption keys as well as an 536062306a36Sopenharmony_ci authentication tag all of which are needed to decrypt the dump at a 536162306a36Sopenharmony_ci later time. 536262306a36Sopenharmony_ci 536362306a36Sopenharmony_ciKVM_PV_ASYNC_CLEANUP_PREPARE 536462306a36Sopenharmony_ci :Capability: KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 536562306a36Sopenharmony_ci 536662306a36Sopenharmony_ci Prepare the current protected VM for asynchronous teardown. Most 536762306a36Sopenharmony_ci resources used by the current protected VM will be set aside for a 536862306a36Sopenharmony_ci subsequent asynchronous teardown. The current protected VM will then 536962306a36Sopenharmony_ci resume execution immediately as non-protected. There can be at most 537062306a36Sopenharmony_ci one protected VM prepared for asynchronous teardown at any time. If 537162306a36Sopenharmony_ci a protected VM had already been prepared for teardown without 537262306a36Sopenharmony_ci subsequently calling KVM_PV_ASYNC_CLEANUP_PERFORM, this call will 537362306a36Sopenharmony_ci fail. In that case, the userspace process should issue a normal 537462306a36Sopenharmony_ci KVM_PV_DISABLE. The resources set aside with this call will need to 537562306a36Sopenharmony_ci be cleaned up with a subsequent call to KVM_PV_ASYNC_CLEANUP_PERFORM 537662306a36Sopenharmony_ci or KVM_PV_DISABLE, otherwise they will be cleaned up when KVM 537762306a36Sopenharmony_ci terminates. KVM_PV_ASYNC_CLEANUP_PREPARE can be called again as soon 537862306a36Sopenharmony_ci as cleanup starts, i.e. before KVM_PV_ASYNC_CLEANUP_PERFORM finishes. 537962306a36Sopenharmony_ci 538062306a36Sopenharmony_ciKVM_PV_ASYNC_CLEANUP_PERFORM 538162306a36Sopenharmony_ci :Capability: KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 538262306a36Sopenharmony_ci 538362306a36Sopenharmony_ci Tear down the protected VM previously prepared for teardown with 538462306a36Sopenharmony_ci KVM_PV_ASYNC_CLEANUP_PREPARE. The resources that had been set aside 538562306a36Sopenharmony_ci will be freed during the execution of this command. This PV command 538662306a36Sopenharmony_ci should ideally be issued by userspace from a separate thread. If a 538762306a36Sopenharmony_ci fatal signal is received (or the process terminates naturally), the 538862306a36Sopenharmony_ci command will terminate immediately without completing, and the normal 538962306a36Sopenharmony_ci KVM shutdown procedure will take care of cleaning up all remaining 539062306a36Sopenharmony_ci protected VMs, including the ones whose teardown was interrupted by 539162306a36Sopenharmony_ci process termination. 539262306a36Sopenharmony_ci 539362306a36Sopenharmony_ci4.126 KVM_XEN_HVM_SET_ATTR 539462306a36Sopenharmony_ci-------------------------- 539562306a36Sopenharmony_ci 539662306a36Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO 539762306a36Sopenharmony_ci:Architectures: x86 539862306a36Sopenharmony_ci:Type: vm ioctl 539962306a36Sopenharmony_ci:Parameters: struct kvm_xen_hvm_attr 540062306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 540162306a36Sopenharmony_ci 540262306a36Sopenharmony_ci:: 540362306a36Sopenharmony_ci 540462306a36Sopenharmony_ci struct kvm_xen_hvm_attr { 540562306a36Sopenharmony_ci __u16 type; 540662306a36Sopenharmony_ci __u16 pad[3]; 540762306a36Sopenharmony_ci union { 540862306a36Sopenharmony_ci __u8 long_mode; 540962306a36Sopenharmony_ci __u8 vector; 541062306a36Sopenharmony_ci __u8 runstate_update_flag; 541162306a36Sopenharmony_ci struct { 541262306a36Sopenharmony_ci __u64 gfn; 541362306a36Sopenharmony_ci } shared_info; 541462306a36Sopenharmony_ci struct { 541562306a36Sopenharmony_ci __u32 send_port; 541662306a36Sopenharmony_ci __u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */ 541762306a36Sopenharmony_ci __u32 flags; 541862306a36Sopenharmony_ci union { 541962306a36Sopenharmony_ci struct { 542062306a36Sopenharmony_ci __u32 port; 542162306a36Sopenharmony_ci __u32 vcpu; 542262306a36Sopenharmony_ci __u32 priority; 542362306a36Sopenharmony_ci } port; 542462306a36Sopenharmony_ci struct { 542562306a36Sopenharmony_ci __u32 port; /* Zero for eventfd */ 542662306a36Sopenharmony_ci __s32 fd; 542762306a36Sopenharmony_ci } eventfd; 542862306a36Sopenharmony_ci __u32 padding[4]; 542962306a36Sopenharmony_ci } deliver; 543062306a36Sopenharmony_ci } evtchn; 543162306a36Sopenharmony_ci __u32 xen_version; 543262306a36Sopenharmony_ci __u64 pad[8]; 543362306a36Sopenharmony_ci } u; 543462306a36Sopenharmony_ci }; 543562306a36Sopenharmony_ci 543662306a36Sopenharmony_citype values: 543762306a36Sopenharmony_ci 543862306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_LONG_MODE 543962306a36Sopenharmony_ci Sets the ABI mode of the VM to 32-bit or 64-bit (long mode). This 544062306a36Sopenharmony_ci determines the layout of the shared info pages exposed to the VM. 544162306a36Sopenharmony_ci 544262306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_SHARED_INFO 544362306a36Sopenharmony_ci Sets the guest physical frame number at which the Xen "shared info" 544462306a36Sopenharmony_ci page resides. Note that although Xen places vcpu_info for the first 544562306a36Sopenharmony_ci 32 vCPUs in the shared_info page, KVM does not automatically do so 544662306a36Sopenharmony_ci and instead requires that KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO be used 544762306a36Sopenharmony_ci explicitly even when the vcpu_info for a given vCPU resides at the 544862306a36Sopenharmony_ci "default" location in the shared_info page. This is because KVM may 544962306a36Sopenharmony_ci not be aware of the Xen CPU id which is used as the index into the 545062306a36Sopenharmony_ci vcpu_info[] array, so may know the correct default location. 545162306a36Sopenharmony_ci 545262306a36Sopenharmony_ci Note that the shared info page may be constantly written to by KVM; 545362306a36Sopenharmony_ci it contains the event channel bitmap used to deliver interrupts to 545462306a36Sopenharmony_ci a Xen guest, amongst other things. It is exempt from dirty tracking 545562306a36Sopenharmony_ci mechanisms — KVM will not explicitly mark the page as dirty each 545662306a36Sopenharmony_ci time an event channel interrupt is delivered to the guest! Thus, 545762306a36Sopenharmony_ci userspace should always assume that the designated GFN is dirty if 545862306a36Sopenharmony_ci any vCPU has been running or any event channel interrupts can be 545962306a36Sopenharmony_ci routed to the guest. 546062306a36Sopenharmony_ci 546162306a36Sopenharmony_ci Setting the gfn to KVM_XEN_INVALID_GFN will disable the shared info 546262306a36Sopenharmony_ci page. 546362306a36Sopenharmony_ci 546462306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_UPCALL_VECTOR 546562306a36Sopenharmony_ci Sets the exception vector used to deliver Xen event channel upcalls. 546662306a36Sopenharmony_ci This is the HVM-wide vector injected directly by the hypervisor 546762306a36Sopenharmony_ci (not through the local APIC), typically configured by a guest via 546862306a36Sopenharmony_ci HVM_PARAM_CALLBACK_IRQ. This can be disabled again (e.g. for guest 546962306a36Sopenharmony_ci SHUTDOWN_soft_reset) by setting it to zero. 547062306a36Sopenharmony_ci 547162306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_EVTCHN 547262306a36Sopenharmony_ci This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 547362306a36Sopenharmony_ci support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures 547462306a36Sopenharmony_ci an outbound port number for interception of EVTCHNOP_send requests 547562306a36Sopenharmony_ci from the guest. A given sending port number may be directed back to 547662306a36Sopenharmony_ci a specified vCPU (by APIC ID) / port / priority on the guest, or to 547762306a36Sopenharmony_ci trigger events on an eventfd. The vCPU and priority can be changed 547862306a36Sopenharmony_ci by setting KVM_XEN_EVTCHN_UPDATE in a subsequent call, but but other 547962306a36Sopenharmony_ci fields cannot change for a given sending port. A port mapping is 548062306a36Sopenharmony_ci removed by using KVM_XEN_EVTCHN_DEASSIGN in the flags field. Passing 548162306a36Sopenharmony_ci KVM_XEN_EVTCHN_RESET in the flags field removes all interception of 548262306a36Sopenharmony_ci outbound event channels. The values of the flags field are mutually 548362306a36Sopenharmony_ci exclusive and cannot be combined as a bitmask. 548462306a36Sopenharmony_ci 548562306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_XEN_VERSION 548662306a36Sopenharmony_ci This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 548762306a36Sopenharmony_ci support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures 548862306a36Sopenharmony_ci the 32-bit version code returned to the guest when it invokes the 548962306a36Sopenharmony_ci XENVER_version call; typically (XEN_MAJOR << 16 | XEN_MINOR). PV 549062306a36Sopenharmony_ci Xen guests will often use this to as a dummy hypercall to trigger 549162306a36Sopenharmony_ci event channel delivery, so responding within the kernel without 549262306a36Sopenharmony_ci exiting to userspace is beneficial. 549362306a36Sopenharmony_ci 549462306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 549562306a36Sopenharmony_ci This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 549662306a36Sopenharmony_ci support for KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG. It enables the 549762306a36Sopenharmony_ci XEN_RUNSTATE_UPDATE flag which allows guest vCPUs to safely read 549862306a36Sopenharmony_ci other vCPUs' vcpu_runstate_info. Xen guests enable this feature via 549962306a36Sopenharmony_ci the VMASST_TYPE_runstate_update_flag of the HYPERVISOR_vm_assist 550062306a36Sopenharmony_ci hypercall. 550162306a36Sopenharmony_ci 550262306a36Sopenharmony_ci4.127 KVM_XEN_HVM_GET_ATTR 550362306a36Sopenharmony_ci-------------------------- 550462306a36Sopenharmony_ci 550562306a36Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO 550662306a36Sopenharmony_ci:Architectures: x86 550762306a36Sopenharmony_ci:Type: vm ioctl 550862306a36Sopenharmony_ci:Parameters: struct kvm_xen_hvm_attr 550962306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 551062306a36Sopenharmony_ci 551162306a36Sopenharmony_ciAllows Xen VM attributes to be read. For the structure and types, 551262306a36Sopenharmony_cisee KVM_XEN_HVM_SET_ATTR above. The KVM_XEN_ATTR_TYPE_EVTCHN 551362306a36Sopenharmony_ciattribute cannot be read. 551462306a36Sopenharmony_ci 551562306a36Sopenharmony_ci4.128 KVM_XEN_VCPU_SET_ATTR 551662306a36Sopenharmony_ci--------------------------- 551762306a36Sopenharmony_ci 551862306a36Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO 551962306a36Sopenharmony_ci:Architectures: x86 552062306a36Sopenharmony_ci:Type: vcpu ioctl 552162306a36Sopenharmony_ci:Parameters: struct kvm_xen_vcpu_attr 552262306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 552362306a36Sopenharmony_ci 552462306a36Sopenharmony_ci:: 552562306a36Sopenharmony_ci 552662306a36Sopenharmony_ci struct kvm_xen_vcpu_attr { 552762306a36Sopenharmony_ci __u16 type; 552862306a36Sopenharmony_ci __u16 pad[3]; 552962306a36Sopenharmony_ci union { 553062306a36Sopenharmony_ci __u64 gpa; 553162306a36Sopenharmony_ci __u64 pad[4]; 553262306a36Sopenharmony_ci struct { 553362306a36Sopenharmony_ci __u64 state; 553462306a36Sopenharmony_ci __u64 state_entry_time; 553562306a36Sopenharmony_ci __u64 time_running; 553662306a36Sopenharmony_ci __u64 time_runnable; 553762306a36Sopenharmony_ci __u64 time_blocked; 553862306a36Sopenharmony_ci __u64 time_offline; 553962306a36Sopenharmony_ci } runstate; 554062306a36Sopenharmony_ci __u32 vcpu_id; 554162306a36Sopenharmony_ci struct { 554262306a36Sopenharmony_ci __u32 port; 554362306a36Sopenharmony_ci __u32 priority; 554462306a36Sopenharmony_ci __u64 expires_ns; 554562306a36Sopenharmony_ci } timer; 554662306a36Sopenharmony_ci __u8 vector; 554762306a36Sopenharmony_ci } u; 554862306a36Sopenharmony_ci }; 554962306a36Sopenharmony_ci 555062306a36Sopenharmony_citype values: 555162306a36Sopenharmony_ci 555262306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 555362306a36Sopenharmony_ci Sets the guest physical address of the vcpu_info for a given vCPU. 555462306a36Sopenharmony_ci As with the shared_info page for the VM, the corresponding page may be 555562306a36Sopenharmony_ci dirtied at any time if event channel interrupt delivery is enabled, so 555662306a36Sopenharmony_ci userspace should always assume that the page is dirty without relying 555762306a36Sopenharmony_ci on dirty logging. Setting the gpa to KVM_XEN_INVALID_GPA will disable 555862306a36Sopenharmony_ci the vcpu_info. 555962306a36Sopenharmony_ci 556062306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 556162306a36Sopenharmony_ci Sets the guest physical address of an additional pvclock structure 556262306a36Sopenharmony_ci for a given vCPU. This is typically used for guest vsyscall support. 556362306a36Sopenharmony_ci Setting the gpa to KVM_XEN_INVALID_GPA will disable the structure. 556462306a36Sopenharmony_ci 556562306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 556662306a36Sopenharmony_ci Sets the guest physical address of the vcpu_runstate_info for a given 556762306a36Sopenharmony_ci vCPU. This is how a Xen guest tracks CPU state such as steal time. 556862306a36Sopenharmony_ci Setting the gpa to KVM_XEN_INVALID_GPA will disable the runstate area. 556962306a36Sopenharmony_ci 557062306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 557162306a36Sopenharmony_ci Sets the runstate (RUNSTATE_running/_runnable/_blocked/_offline) of 557262306a36Sopenharmony_ci the given vCPU from the .u.runstate.state member of the structure. 557362306a36Sopenharmony_ci KVM automatically accounts running and runnable time but blocked 557462306a36Sopenharmony_ci and offline states are only entered explicitly. 557562306a36Sopenharmony_ci 557662306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 557762306a36Sopenharmony_ci Sets all fields of the vCPU runstate data from the .u.runstate member 557862306a36Sopenharmony_ci of the structure, including the current runstate. The state_entry_time 557962306a36Sopenharmony_ci must equal the sum of the other four times. 558062306a36Sopenharmony_ci 558162306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 558262306a36Sopenharmony_ci This *adds* the contents of the .u.runstate members of the structure 558362306a36Sopenharmony_ci to the corresponding members of the given vCPU's runstate data, thus 558462306a36Sopenharmony_ci permitting atomic adjustments to the runstate times. The adjustment 558562306a36Sopenharmony_ci to the state_entry_time must equal the sum of the adjustments to the 558662306a36Sopenharmony_ci other four times. The state field must be set to -1, or to a valid 558762306a36Sopenharmony_ci runstate value (RUNSTATE_running, RUNSTATE_runnable, RUNSTATE_blocked 558862306a36Sopenharmony_ci or RUNSTATE_offline) to set the current accounted state as of the 558962306a36Sopenharmony_ci adjusted state_entry_time. 559062306a36Sopenharmony_ci 559162306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 559262306a36Sopenharmony_ci This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 559362306a36Sopenharmony_ci support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the Xen 559462306a36Sopenharmony_ci vCPU ID of the given vCPU, to allow timer-related VCPU operations to 559562306a36Sopenharmony_ci be intercepted by KVM. 559662306a36Sopenharmony_ci 559762306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_TIMER 559862306a36Sopenharmony_ci This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 559962306a36Sopenharmony_ci support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the 560062306a36Sopenharmony_ci event channel port/priority for the VIRQ_TIMER of the vCPU, as well 560162306a36Sopenharmony_ci as allowing a pending timer to be saved/restored. Setting the timer 560262306a36Sopenharmony_ci port to zero disables kernel handling of the singleshot timer. 560362306a36Sopenharmony_ci 560462306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 560562306a36Sopenharmony_ci This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates 560662306a36Sopenharmony_ci support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the 560762306a36Sopenharmony_ci per-vCPU local APIC upcall vector, configured by a Xen guest with 560862306a36Sopenharmony_ci the HVMOP_set_evtchn_upcall_vector hypercall. This is typically 560962306a36Sopenharmony_ci used by Windows guests, and is distinct from the HVM-wide upcall 561062306a36Sopenharmony_ci vector configured with HVM_PARAM_CALLBACK_IRQ. It is disabled by 561162306a36Sopenharmony_ci setting the vector to zero. 561262306a36Sopenharmony_ci 561362306a36Sopenharmony_ci 561462306a36Sopenharmony_ci4.129 KVM_XEN_VCPU_GET_ATTR 561562306a36Sopenharmony_ci--------------------------- 561662306a36Sopenharmony_ci 561762306a36Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO 561862306a36Sopenharmony_ci:Architectures: x86 561962306a36Sopenharmony_ci:Type: vcpu ioctl 562062306a36Sopenharmony_ci:Parameters: struct kvm_xen_vcpu_attr 562162306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 562262306a36Sopenharmony_ci 562362306a36Sopenharmony_ciAllows Xen vCPU attributes to be read. For the structure and types, 562462306a36Sopenharmony_cisee KVM_XEN_VCPU_SET_ATTR above. 562562306a36Sopenharmony_ci 562662306a36Sopenharmony_ciThe KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST type may not be used 562762306a36Sopenharmony_ciwith the KVM_XEN_VCPU_GET_ATTR ioctl. 562862306a36Sopenharmony_ci 562962306a36Sopenharmony_ci4.130 KVM_ARM_MTE_COPY_TAGS 563062306a36Sopenharmony_ci--------------------------- 563162306a36Sopenharmony_ci 563262306a36Sopenharmony_ci:Capability: KVM_CAP_ARM_MTE 563362306a36Sopenharmony_ci:Architectures: arm64 563462306a36Sopenharmony_ci:Type: vm ioctl 563562306a36Sopenharmony_ci:Parameters: struct kvm_arm_copy_mte_tags 563662306a36Sopenharmony_ci:Returns: number of bytes copied, < 0 on error (-EINVAL for incorrect 563762306a36Sopenharmony_ci arguments, -EFAULT if memory cannot be accessed). 563862306a36Sopenharmony_ci 563962306a36Sopenharmony_ci:: 564062306a36Sopenharmony_ci 564162306a36Sopenharmony_ci struct kvm_arm_copy_mte_tags { 564262306a36Sopenharmony_ci __u64 guest_ipa; 564362306a36Sopenharmony_ci __u64 length; 564462306a36Sopenharmony_ci void __user *addr; 564562306a36Sopenharmony_ci __u64 flags; 564662306a36Sopenharmony_ci __u64 reserved[2]; 564762306a36Sopenharmony_ci }; 564862306a36Sopenharmony_ci 564962306a36Sopenharmony_ciCopies Memory Tagging Extension (MTE) tags to/from guest tag memory. The 565062306a36Sopenharmony_ci``guest_ipa`` and ``length`` fields must be ``PAGE_SIZE`` aligned. 565162306a36Sopenharmony_ci``length`` must not be bigger than 2^31 - PAGE_SIZE bytes. The ``addr`` 565262306a36Sopenharmony_cifield must point to a buffer which the tags will be copied to or from. 565362306a36Sopenharmony_ci 565462306a36Sopenharmony_ci``flags`` specifies the direction of copy, either ``KVM_ARM_TAGS_TO_GUEST`` or 565562306a36Sopenharmony_ci``KVM_ARM_TAGS_FROM_GUEST``. 565662306a36Sopenharmony_ci 565762306a36Sopenharmony_ciThe size of the buffer to store the tags is ``(length / 16)`` bytes 565862306a36Sopenharmony_ci(granules in MTE are 16 bytes long). Each byte contains a single tag 565962306a36Sopenharmony_civalue. This matches the format of ``PTRACE_PEEKMTETAGS`` and 566062306a36Sopenharmony_ci``PTRACE_POKEMTETAGS``. 566162306a36Sopenharmony_ci 566262306a36Sopenharmony_ciIf an error occurs before any data is copied then a negative error code is 566362306a36Sopenharmony_cireturned. If some tags have been copied before an error occurs then the number 566462306a36Sopenharmony_ciof bytes successfully copied is returned. If the call completes successfully 566562306a36Sopenharmony_cithen ``length`` is returned. 566662306a36Sopenharmony_ci 566762306a36Sopenharmony_ci4.131 KVM_GET_SREGS2 566862306a36Sopenharmony_ci-------------------- 566962306a36Sopenharmony_ci 567062306a36Sopenharmony_ci:Capability: KVM_CAP_SREGS2 567162306a36Sopenharmony_ci:Architectures: x86 567262306a36Sopenharmony_ci:Type: vcpu ioctl 567362306a36Sopenharmony_ci:Parameters: struct kvm_sregs2 (out) 567462306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 567562306a36Sopenharmony_ci 567662306a36Sopenharmony_ciReads special registers from the vcpu. 567762306a36Sopenharmony_ciThis ioctl (when supported) replaces the KVM_GET_SREGS. 567862306a36Sopenharmony_ci 567962306a36Sopenharmony_ci:: 568062306a36Sopenharmony_ci 568162306a36Sopenharmony_ci struct kvm_sregs2 { 568262306a36Sopenharmony_ci /* out (KVM_GET_SREGS2) / in (KVM_SET_SREGS2) */ 568362306a36Sopenharmony_ci struct kvm_segment cs, ds, es, fs, gs, ss; 568462306a36Sopenharmony_ci struct kvm_segment tr, ldt; 568562306a36Sopenharmony_ci struct kvm_dtable gdt, idt; 568662306a36Sopenharmony_ci __u64 cr0, cr2, cr3, cr4, cr8; 568762306a36Sopenharmony_ci __u64 efer; 568862306a36Sopenharmony_ci __u64 apic_base; 568962306a36Sopenharmony_ci __u64 flags; 569062306a36Sopenharmony_ci __u64 pdptrs[4]; 569162306a36Sopenharmony_ci }; 569262306a36Sopenharmony_ci 569362306a36Sopenharmony_ciflags values for ``kvm_sregs2``: 569462306a36Sopenharmony_ci 569562306a36Sopenharmony_ci``KVM_SREGS2_FLAGS_PDPTRS_VALID`` 569662306a36Sopenharmony_ci 569762306a36Sopenharmony_ci Indicates that the struct contains valid PDPTR values. 569862306a36Sopenharmony_ci 569962306a36Sopenharmony_ci 570062306a36Sopenharmony_ci4.132 KVM_SET_SREGS2 570162306a36Sopenharmony_ci-------------------- 570262306a36Sopenharmony_ci 570362306a36Sopenharmony_ci:Capability: KVM_CAP_SREGS2 570462306a36Sopenharmony_ci:Architectures: x86 570562306a36Sopenharmony_ci:Type: vcpu ioctl 570662306a36Sopenharmony_ci:Parameters: struct kvm_sregs2 (in) 570762306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 570862306a36Sopenharmony_ci 570962306a36Sopenharmony_ciWrites special registers into the vcpu. 571062306a36Sopenharmony_ciSee KVM_GET_SREGS2 for the data structures. 571162306a36Sopenharmony_ciThis ioctl (when supported) replaces the KVM_SET_SREGS. 571262306a36Sopenharmony_ci 571362306a36Sopenharmony_ci4.133 KVM_GET_STATS_FD 571462306a36Sopenharmony_ci---------------------- 571562306a36Sopenharmony_ci 571662306a36Sopenharmony_ci:Capability: KVM_CAP_STATS_BINARY_FD 571762306a36Sopenharmony_ci:Architectures: all 571862306a36Sopenharmony_ci:Type: vm ioctl, vcpu ioctl 571962306a36Sopenharmony_ci:Parameters: none 572062306a36Sopenharmony_ci:Returns: statistics file descriptor on success, < 0 on error 572162306a36Sopenharmony_ci 572262306a36Sopenharmony_ciErrors: 572362306a36Sopenharmony_ci 572462306a36Sopenharmony_ci ====== ====================================================== 572562306a36Sopenharmony_ci ENOMEM if the fd could not be created due to lack of memory 572662306a36Sopenharmony_ci EMFILE if the number of opened files exceeds the limit 572762306a36Sopenharmony_ci ====== ====================================================== 572862306a36Sopenharmony_ci 572962306a36Sopenharmony_ciThe returned file descriptor can be used to read VM/vCPU statistics data in 573062306a36Sopenharmony_cibinary format. The data in the file descriptor consists of four blocks 573162306a36Sopenharmony_ciorganized as follows: 573262306a36Sopenharmony_ci 573362306a36Sopenharmony_ci+-------------+ 573462306a36Sopenharmony_ci| Header | 573562306a36Sopenharmony_ci+-------------+ 573662306a36Sopenharmony_ci| id string | 573762306a36Sopenharmony_ci+-------------+ 573862306a36Sopenharmony_ci| Descriptors | 573962306a36Sopenharmony_ci+-------------+ 574062306a36Sopenharmony_ci| Stats Data | 574162306a36Sopenharmony_ci+-------------+ 574262306a36Sopenharmony_ci 574362306a36Sopenharmony_ciApart from the header starting at offset 0, please be aware that it is 574462306a36Sopenharmony_cinot guaranteed that the four blocks are adjacent or in the above order; 574562306a36Sopenharmony_cithe offsets of the id, descriptors and data blocks are found in the 574662306a36Sopenharmony_ciheader. However, all four blocks are aligned to 64 bit offsets in the 574762306a36Sopenharmony_cifile and they do not overlap. 574862306a36Sopenharmony_ci 574962306a36Sopenharmony_ciAll blocks except the data block are immutable. Userspace can read them 575062306a36Sopenharmony_cionly one time after retrieving the file descriptor, and then use ``pread`` or 575162306a36Sopenharmony_ci``lseek`` to read the statistics repeatedly. 575262306a36Sopenharmony_ci 575362306a36Sopenharmony_ciAll data is in system endianness. 575462306a36Sopenharmony_ci 575562306a36Sopenharmony_ciThe format of the header is as follows:: 575662306a36Sopenharmony_ci 575762306a36Sopenharmony_ci struct kvm_stats_header { 575862306a36Sopenharmony_ci __u32 flags; 575962306a36Sopenharmony_ci __u32 name_size; 576062306a36Sopenharmony_ci __u32 num_desc; 576162306a36Sopenharmony_ci __u32 id_offset; 576262306a36Sopenharmony_ci __u32 desc_offset; 576362306a36Sopenharmony_ci __u32 data_offset; 576462306a36Sopenharmony_ci }; 576562306a36Sopenharmony_ci 576662306a36Sopenharmony_ciThe ``flags`` field is not used at the moment. It is always read as 0. 576762306a36Sopenharmony_ci 576862306a36Sopenharmony_ciThe ``name_size`` field is the size (in byte) of the statistics name string 576962306a36Sopenharmony_ci(including trailing '\0') which is contained in the "id string" block and 577062306a36Sopenharmony_ciappended at the end of every descriptor. 577162306a36Sopenharmony_ci 577262306a36Sopenharmony_ciThe ``num_desc`` field is the number of descriptors that are included in the 577362306a36Sopenharmony_cidescriptor block. (The actual number of values in the data block may be 577462306a36Sopenharmony_cilarger, since each descriptor may comprise more than one value). 577562306a36Sopenharmony_ci 577662306a36Sopenharmony_ciThe ``id_offset`` field is the offset of the id string from the start of the 577762306a36Sopenharmony_cifile indicated by the file descriptor. It is a multiple of 8. 577862306a36Sopenharmony_ci 577962306a36Sopenharmony_ciThe ``desc_offset`` field is the offset of the Descriptors block from the start 578062306a36Sopenharmony_ciof the file indicated by the file descriptor. It is a multiple of 8. 578162306a36Sopenharmony_ci 578262306a36Sopenharmony_ciThe ``data_offset`` field is the offset of the Stats Data block from the start 578362306a36Sopenharmony_ciof the file indicated by the file descriptor. It is a multiple of 8. 578462306a36Sopenharmony_ci 578562306a36Sopenharmony_ciThe id string block contains a string which identifies the file descriptor on 578662306a36Sopenharmony_ciwhich KVM_GET_STATS_FD was invoked. The size of the block, including the 578762306a36Sopenharmony_citrailing ``'\0'``, is indicated by the ``name_size`` field in the header. 578862306a36Sopenharmony_ci 578962306a36Sopenharmony_ciThe descriptors block is only needed to be read once for the lifetime of the 579062306a36Sopenharmony_cifile descriptor contains a sequence of ``struct kvm_stats_desc``, each followed 579162306a36Sopenharmony_ciby a string of size ``name_size``. 579262306a36Sopenharmony_ci:: 579362306a36Sopenharmony_ci 579462306a36Sopenharmony_ci #define KVM_STATS_TYPE_SHIFT 0 579562306a36Sopenharmony_ci #define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT) 579662306a36Sopenharmony_ci #define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT) 579762306a36Sopenharmony_ci #define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT) 579862306a36Sopenharmony_ci #define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT) 579962306a36Sopenharmony_ci #define KVM_STATS_TYPE_LINEAR_HIST (0x3 << KVM_STATS_TYPE_SHIFT) 580062306a36Sopenharmony_ci #define KVM_STATS_TYPE_LOG_HIST (0x4 << KVM_STATS_TYPE_SHIFT) 580162306a36Sopenharmony_ci #define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_LOG_HIST 580262306a36Sopenharmony_ci 580362306a36Sopenharmony_ci #define KVM_STATS_UNIT_SHIFT 4 580462306a36Sopenharmony_ci #define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT) 580562306a36Sopenharmony_ci #define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT) 580662306a36Sopenharmony_ci #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT) 580762306a36Sopenharmony_ci #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) 580862306a36Sopenharmony_ci #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) 580962306a36Sopenharmony_ci #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) 581062306a36Sopenharmony_ci #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN 581162306a36Sopenharmony_ci 581262306a36Sopenharmony_ci #define KVM_STATS_BASE_SHIFT 8 581362306a36Sopenharmony_ci #define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT) 581462306a36Sopenharmony_ci #define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT) 581562306a36Sopenharmony_ci #define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT) 581662306a36Sopenharmony_ci #define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2 581762306a36Sopenharmony_ci 581862306a36Sopenharmony_ci struct kvm_stats_desc { 581962306a36Sopenharmony_ci __u32 flags; 582062306a36Sopenharmony_ci __s16 exponent; 582162306a36Sopenharmony_ci __u16 size; 582262306a36Sopenharmony_ci __u32 offset; 582362306a36Sopenharmony_ci __u32 bucket_size; 582462306a36Sopenharmony_ci char name[]; 582562306a36Sopenharmony_ci }; 582662306a36Sopenharmony_ci 582762306a36Sopenharmony_ciThe ``flags`` field contains the type and unit of the statistics data described 582862306a36Sopenharmony_ciby this descriptor. Its endianness is CPU native. 582962306a36Sopenharmony_ciThe following flags are supported: 583062306a36Sopenharmony_ci 583162306a36Sopenharmony_ciBits 0-3 of ``flags`` encode the type: 583262306a36Sopenharmony_ci 583362306a36Sopenharmony_ci * ``KVM_STATS_TYPE_CUMULATIVE`` 583462306a36Sopenharmony_ci The statistics reports a cumulative count. The value of data can only be increased. 583562306a36Sopenharmony_ci Most of the counters used in KVM are of this type. 583662306a36Sopenharmony_ci The corresponding ``size`` field for this type is always 1. 583762306a36Sopenharmony_ci All cumulative statistics data are read/write. 583862306a36Sopenharmony_ci * ``KVM_STATS_TYPE_INSTANT`` 583962306a36Sopenharmony_ci The statistics reports an instantaneous value. Its value can be increased or 584062306a36Sopenharmony_ci decreased. This type is usually used as a measurement of some resources, 584162306a36Sopenharmony_ci like the number of dirty pages, the number of large pages, etc. 584262306a36Sopenharmony_ci All instant statistics are read only. 584362306a36Sopenharmony_ci The corresponding ``size`` field for this type is always 1. 584462306a36Sopenharmony_ci * ``KVM_STATS_TYPE_PEAK`` 584562306a36Sopenharmony_ci The statistics data reports a peak value, for example the maximum number 584662306a36Sopenharmony_ci of items in a hash table bucket, the longest time waited and so on. 584762306a36Sopenharmony_ci The value of data can only be increased. 584862306a36Sopenharmony_ci The corresponding ``size`` field for this type is always 1. 584962306a36Sopenharmony_ci * ``KVM_STATS_TYPE_LINEAR_HIST`` 585062306a36Sopenharmony_ci The statistic is reported as a linear histogram. The number of 585162306a36Sopenharmony_ci buckets is specified by the ``size`` field. The size of buckets is specified 585262306a36Sopenharmony_ci by the ``hist_param`` field. The range of the Nth bucket (1 <= N < ``size``) 585362306a36Sopenharmony_ci is [``hist_param``*(N-1), ``hist_param``*N), while the range of the last 585462306a36Sopenharmony_ci bucket is [``hist_param``*(``size``-1), +INF). (+INF means positive infinity 585562306a36Sopenharmony_ci value.) 585662306a36Sopenharmony_ci * ``KVM_STATS_TYPE_LOG_HIST`` 585762306a36Sopenharmony_ci The statistic is reported as a logarithmic histogram. The number of 585862306a36Sopenharmony_ci buckets is specified by the ``size`` field. The range of the first bucket is 585962306a36Sopenharmony_ci [0, 1), while the range of the last bucket is [pow(2, ``size``-2), +INF). 586062306a36Sopenharmony_ci Otherwise, The Nth bucket (1 < N < ``size``) covers 586162306a36Sopenharmony_ci [pow(2, N-2), pow(2, N-1)). 586262306a36Sopenharmony_ci 586362306a36Sopenharmony_ciBits 4-7 of ``flags`` encode the unit: 586462306a36Sopenharmony_ci 586562306a36Sopenharmony_ci * ``KVM_STATS_UNIT_NONE`` 586662306a36Sopenharmony_ci There is no unit for the value of statistics data. This usually means that 586762306a36Sopenharmony_ci the value is a simple counter of an event. 586862306a36Sopenharmony_ci * ``KVM_STATS_UNIT_BYTES`` 586962306a36Sopenharmony_ci It indicates that the statistics data is used to measure memory size, in the 587062306a36Sopenharmony_ci unit of Byte, KiByte, MiByte, GiByte, etc. The unit of the data is 587162306a36Sopenharmony_ci determined by the ``exponent`` field in the descriptor. 587262306a36Sopenharmony_ci * ``KVM_STATS_UNIT_SECONDS`` 587362306a36Sopenharmony_ci It indicates that the statistics data is used to measure time or latency. 587462306a36Sopenharmony_ci * ``KVM_STATS_UNIT_CYCLES`` 587562306a36Sopenharmony_ci It indicates that the statistics data is used to measure CPU clock cycles. 587662306a36Sopenharmony_ci * ``KVM_STATS_UNIT_BOOLEAN`` 587762306a36Sopenharmony_ci It indicates that the statistic will always be either 0 or 1. Boolean 587862306a36Sopenharmony_ci statistics of "peak" type will never go back from 1 to 0. Boolean 587962306a36Sopenharmony_ci statistics can be linear histograms (with two buckets) but not logarithmic 588062306a36Sopenharmony_ci histograms. 588162306a36Sopenharmony_ci 588262306a36Sopenharmony_ciNote that, in the case of histograms, the unit applies to the bucket 588362306a36Sopenharmony_ciranges, while the bucket value indicates how many samples fell in the 588462306a36Sopenharmony_cibucket's range. 588562306a36Sopenharmony_ci 588662306a36Sopenharmony_ciBits 8-11 of ``flags``, together with ``exponent``, encode the scale of the 588762306a36Sopenharmony_ciunit: 588862306a36Sopenharmony_ci 588962306a36Sopenharmony_ci * ``KVM_STATS_BASE_POW10`` 589062306a36Sopenharmony_ci The scale is based on power of 10. It is used for measurement of time and 589162306a36Sopenharmony_ci CPU clock cycles. For example, an exponent of -9 can be used with 589262306a36Sopenharmony_ci ``KVM_STATS_UNIT_SECONDS`` to express that the unit is nanoseconds. 589362306a36Sopenharmony_ci * ``KVM_STATS_BASE_POW2`` 589462306a36Sopenharmony_ci The scale is based on power of 2. It is used for measurement of memory size. 589562306a36Sopenharmony_ci For example, an exponent of 20 can be used with ``KVM_STATS_UNIT_BYTES`` to 589662306a36Sopenharmony_ci express that the unit is MiB. 589762306a36Sopenharmony_ci 589862306a36Sopenharmony_ciThe ``size`` field is the number of values of this statistics data. Its 589962306a36Sopenharmony_civalue is usually 1 for most of simple statistics. 1 means it contains an 590062306a36Sopenharmony_ciunsigned 64bit data. 590162306a36Sopenharmony_ci 590262306a36Sopenharmony_ciThe ``offset`` field is the offset from the start of Data Block to the start of 590362306a36Sopenharmony_cithe corresponding statistics data. 590462306a36Sopenharmony_ci 590562306a36Sopenharmony_ciThe ``bucket_size`` field is used as a parameter for histogram statistics data. 590662306a36Sopenharmony_ciIt is only used by linear histogram statistics data, specifying the size of a 590762306a36Sopenharmony_cibucket in the unit expressed by bits 4-11 of ``flags`` together with ``exponent``. 590862306a36Sopenharmony_ci 590962306a36Sopenharmony_ciThe ``name`` field is the name string of the statistics data. The name string 591062306a36Sopenharmony_cistarts at the end of ``struct kvm_stats_desc``. The maximum length including 591162306a36Sopenharmony_cithe trailing ``'\0'``, is indicated by ``name_size`` in the header. 591262306a36Sopenharmony_ci 591362306a36Sopenharmony_ciThe Stats Data block contains an array of 64-bit values in the same order 591462306a36Sopenharmony_cias the descriptors in Descriptors block. 591562306a36Sopenharmony_ci 591662306a36Sopenharmony_ci4.134 KVM_GET_XSAVE2 591762306a36Sopenharmony_ci-------------------- 591862306a36Sopenharmony_ci 591962306a36Sopenharmony_ci:Capability: KVM_CAP_XSAVE2 592062306a36Sopenharmony_ci:Architectures: x86 592162306a36Sopenharmony_ci:Type: vcpu ioctl 592262306a36Sopenharmony_ci:Parameters: struct kvm_xsave (out) 592362306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 592462306a36Sopenharmony_ci 592562306a36Sopenharmony_ci 592662306a36Sopenharmony_ci:: 592762306a36Sopenharmony_ci 592862306a36Sopenharmony_ci struct kvm_xsave { 592962306a36Sopenharmony_ci __u32 region[1024]; 593062306a36Sopenharmony_ci __u32 extra[0]; 593162306a36Sopenharmony_ci }; 593262306a36Sopenharmony_ci 593362306a36Sopenharmony_ciThis ioctl would copy current vcpu's xsave struct to the userspace. It 593462306a36Sopenharmony_cicopies as many bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) 593562306a36Sopenharmony_ciwhen invoked on the vm file descriptor. The size value returned by 593662306a36Sopenharmony_ciKVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will always be at least 4096. 593762306a36Sopenharmony_ciCurrently, it is only greater than 4096 if a dynamic feature has been 593862306a36Sopenharmony_cienabled with ``arch_prctl()``, but this may change in the future. 593962306a36Sopenharmony_ci 594062306a36Sopenharmony_ciThe offsets of the state save areas in struct kvm_xsave follow the contents 594162306a36Sopenharmony_ciof CPUID leaf 0xD on the host. 594262306a36Sopenharmony_ci 594362306a36Sopenharmony_ci4.135 KVM_XEN_HVM_EVTCHN_SEND 594462306a36Sopenharmony_ci----------------------------- 594562306a36Sopenharmony_ci 594662306a36Sopenharmony_ci:Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND 594762306a36Sopenharmony_ci:Architectures: x86 594862306a36Sopenharmony_ci:Type: vm ioctl 594962306a36Sopenharmony_ci:Parameters: struct kvm_irq_routing_xen_evtchn 595062306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 595162306a36Sopenharmony_ci 595262306a36Sopenharmony_ci 595362306a36Sopenharmony_ci:: 595462306a36Sopenharmony_ci 595562306a36Sopenharmony_ci struct kvm_irq_routing_xen_evtchn { 595662306a36Sopenharmony_ci __u32 port; 595762306a36Sopenharmony_ci __u32 vcpu; 595862306a36Sopenharmony_ci __u32 priority; 595962306a36Sopenharmony_ci }; 596062306a36Sopenharmony_ci 596162306a36Sopenharmony_ciThis ioctl injects an event channel interrupt directly to the guest vCPU. 596262306a36Sopenharmony_ci 596362306a36Sopenharmony_ci4.136 KVM_S390_PV_CPU_COMMAND 596462306a36Sopenharmony_ci----------------------------- 596562306a36Sopenharmony_ci 596662306a36Sopenharmony_ci:Capability: KVM_CAP_S390_PROTECTED_DUMP 596762306a36Sopenharmony_ci:Architectures: s390 596862306a36Sopenharmony_ci:Type: vcpu ioctl 596962306a36Sopenharmony_ci:Parameters: none 597062306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 597162306a36Sopenharmony_ci 597262306a36Sopenharmony_ciThis ioctl closely mirrors `KVM_S390_PV_COMMAND` but handles requests 597362306a36Sopenharmony_cifor vcpus. It re-uses the kvm_s390_pv_dmp struct and hence also shares 597462306a36Sopenharmony_cithe command ids. 597562306a36Sopenharmony_ci 597662306a36Sopenharmony_ci**command:** 597762306a36Sopenharmony_ci 597862306a36Sopenharmony_ciKVM_PV_DUMP 597962306a36Sopenharmony_ci Presents an API that provides calls which facilitate dumping a vcpu 598062306a36Sopenharmony_ci of a protected VM. 598162306a36Sopenharmony_ci 598262306a36Sopenharmony_ci**subcommand:** 598362306a36Sopenharmony_ci 598462306a36Sopenharmony_ciKVM_PV_DUMP_CPU 598562306a36Sopenharmony_ci Provides encrypted dump data like register values. 598662306a36Sopenharmony_ci The length of the returned data is provided by uv_info.guest_cpu_stor_len. 598762306a36Sopenharmony_ci 598862306a36Sopenharmony_ci4.137 KVM_S390_ZPCI_OP 598962306a36Sopenharmony_ci---------------------- 599062306a36Sopenharmony_ci 599162306a36Sopenharmony_ci:Capability: KVM_CAP_S390_ZPCI_OP 599262306a36Sopenharmony_ci:Architectures: s390 599362306a36Sopenharmony_ci:Type: vm ioctl 599462306a36Sopenharmony_ci:Parameters: struct kvm_s390_zpci_op (in) 599562306a36Sopenharmony_ci:Returns: 0 on success, <0 on error 599662306a36Sopenharmony_ci 599762306a36Sopenharmony_ciUsed to manage hardware-assisted virtualization features for zPCI devices. 599862306a36Sopenharmony_ci 599962306a36Sopenharmony_ciParameters are specified via the following structure:: 600062306a36Sopenharmony_ci 600162306a36Sopenharmony_ci struct kvm_s390_zpci_op { 600262306a36Sopenharmony_ci /* in */ 600362306a36Sopenharmony_ci __u32 fh; /* target device */ 600462306a36Sopenharmony_ci __u8 op; /* operation to perform */ 600562306a36Sopenharmony_ci __u8 pad[3]; 600662306a36Sopenharmony_ci union { 600762306a36Sopenharmony_ci /* for KVM_S390_ZPCIOP_REG_AEN */ 600862306a36Sopenharmony_ci struct { 600962306a36Sopenharmony_ci __u64 ibv; /* Guest addr of interrupt bit vector */ 601062306a36Sopenharmony_ci __u64 sb; /* Guest addr of summary bit */ 601162306a36Sopenharmony_ci __u32 flags; 601262306a36Sopenharmony_ci __u32 noi; /* Number of interrupts */ 601362306a36Sopenharmony_ci __u8 isc; /* Guest interrupt subclass */ 601462306a36Sopenharmony_ci __u8 sbo; /* Offset of guest summary bit vector */ 601562306a36Sopenharmony_ci __u16 pad; 601662306a36Sopenharmony_ci } reg_aen; 601762306a36Sopenharmony_ci __u64 reserved[8]; 601862306a36Sopenharmony_ci } u; 601962306a36Sopenharmony_ci }; 602062306a36Sopenharmony_ci 602162306a36Sopenharmony_ciThe type of operation is specified in the "op" field. 602262306a36Sopenharmony_ciKVM_S390_ZPCIOP_REG_AEN is used to register the VM for adapter event 602362306a36Sopenharmony_cinotification interpretation, which will allow firmware delivery of adapter 602462306a36Sopenharmony_cievents directly to the vm, with KVM providing a backup delivery mechanism; 602562306a36Sopenharmony_ciKVM_S390_ZPCIOP_DEREG_AEN is used to subsequently disable interpretation of 602662306a36Sopenharmony_ciadapter event notifications. 602762306a36Sopenharmony_ci 602862306a36Sopenharmony_ciThe target zPCI function must also be specified via the "fh" field. For the 602962306a36Sopenharmony_ciKVM_S390_ZPCIOP_REG_AEN operation, additional information to establish firmware 603062306a36Sopenharmony_cidelivery must be provided via the "reg_aen" struct. 603162306a36Sopenharmony_ci 603262306a36Sopenharmony_ciThe "pad" and "reserved" fields may be used for future extensions and should be 603362306a36Sopenharmony_ciset to 0s by userspace. 603462306a36Sopenharmony_ci 603562306a36Sopenharmony_ci4.138 KVM_ARM_SET_COUNTER_OFFSET 603662306a36Sopenharmony_ci-------------------------------- 603762306a36Sopenharmony_ci 603862306a36Sopenharmony_ci:Capability: KVM_CAP_COUNTER_OFFSET 603962306a36Sopenharmony_ci:Architectures: arm64 604062306a36Sopenharmony_ci:Type: vm ioctl 604162306a36Sopenharmony_ci:Parameters: struct kvm_arm_counter_offset (in) 604262306a36Sopenharmony_ci:Returns: 0 on success, < 0 on error 604362306a36Sopenharmony_ci 604462306a36Sopenharmony_ciThis capability indicates that userspace is able to apply a single VM-wide 604562306a36Sopenharmony_cioffset to both the virtual and physical counters as viewed by the guest 604662306a36Sopenharmony_ciusing the KVM_ARM_SET_CNT_OFFSET ioctl and the following data structure: 604762306a36Sopenharmony_ci 604862306a36Sopenharmony_ci:: 604962306a36Sopenharmony_ci 605062306a36Sopenharmony_ci struct kvm_arm_counter_offset { 605162306a36Sopenharmony_ci __u64 counter_offset; 605262306a36Sopenharmony_ci __u64 reserved; 605362306a36Sopenharmony_ci }; 605462306a36Sopenharmony_ci 605562306a36Sopenharmony_ciThe offset describes a number of counter cycles that are subtracted from 605662306a36Sopenharmony_ciboth virtual and physical counter views (similar to the effects of the 605762306a36Sopenharmony_ciCNTVOFF_EL2 and CNTPOFF_EL2 system registers, but only global). The offset 605862306a36Sopenharmony_cialways applies to all vcpus (already created or created after this ioctl) 605962306a36Sopenharmony_cifor this VM. 606062306a36Sopenharmony_ci 606162306a36Sopenharmony_ciIt is userspace's responsibility to compute the offset based, for example, 606262306a36Sopenharmony_cion previous values of the guest counters. 606362306a36Sopenharmony_ci 606462306a36Sopenharmony_ciAny value other than 0 for the "reserved" field may result in an error 606562306a36Sopenharmony_ci(-EINVAL) being returned. This ioctl can also return -EBUSY if any vcpu 606662306a36Sopenharmony_ciioctl is issued concurrently. 606762306a36Sopenharmony_ci 606862306a36Sopenharmony_ciNote that using this ioctl results in KVM ignoring subsequent userspace 606962306a36Sopenharmony_ciwrites to the CNTVCT_EL0 and CNTPCT_EL0 registers using the SET_ONE_REG 607062306a36Sopenharmony_ciinterface. No error will be returned, but the resulting offset will not be 607162306a36Sopenharmony_ciapplied. 607262306a36Sopenharmony_ci 607362306a36Sopenharmony_ci5. The kvm_run structure 607462306a36Sopenharmony_ci======================== 607562306a36Sopenharmony_ci 607662306a36Sopenharmony_ciApplication code obtains a pointer to the kvm_run structure by 607762306a36Sopenharmony_cimmap()ing a vcpu fd. From that point, application code can control 607862306a36Sopenharmony_ciexecution by changing fields in kvm_run prior to calling the KVM_RUN 607962306a36Sopenharmony_ciioctl, and obtain information about the reason KVM_RUN returned by 608062306a36Sopenharmony_cilooking up structure members. 608162306a36Sopenharmony_ci 608262306a36Sopenharmony_ci:: 608362306a36Sopenharmony_ci 608462306a36Sopenharmony_ci struct kvm_run { 608562306a36Sopenharmony_ci /* in */ 608662306a36Sopenharmony_ci __u8 request_interrupt_window; 608762306a36Sopenharmony_ci 608862306a36Sopenharmony_ciRequest that KVM_RUN return when it becomes possible to inject external 608962306a36Sopenharmony_ciinterrupts into the guest. Useful in conjunction with KVM_INTERRUPT. 609062306a36Sopenharmony_ci 609162306a36Sopenharmony_ci:: 609262306a36Sopenharmony_ci 609362306a36Sopenharmony_ci __u8 immediate_exit; 609462306a36Sopenharmony_ci 609562306a36Sopenharmony_ciThis field is polled once when KVM_RUN starts; if non-zero, KVM_RUN 609662306a36Sopenharmony_ciexits immediately, returning -EINTR. In the common scenario where a 609762306a36Sopenharmony_cisignal is used to "kick" a VCPU out of KVM_RUN, this field can be used 609862306a36Sopenharmony_cito avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability. 609962306a36Sopenharmony_ciRather than blocking the signal outside KVM_RUN, userspace can set up 610062306a36Sopenharmony_cia signal handler that sets run->immediate_exit to a non-zero value. 610162306a36Sopenharmony_ci 610262306a36Sopenharmony_ciThis field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available. 610362306a36Sopenharmony_ci 610462306a36Sopenharmony_ci:: 610562306a36Sopenharmony_ci 610662306a36Sopenharmony_ci __u8 padding1[6]; 610762306a36Sopenharmony_ci 610862306a36Sopenharmony_ci /* out */ 610962306a36Sopenharmony_ci __u32 exit_reason; 611062306a36Sopenharmony_ci 611162306a36Sopenharmony_ciWhen KVM_RUN has returned successfully (return value 0), this informs 611262306a36Sopenharmony_ciapplication code why KVM_RUN has returned. Allowable values for this 611362306a36Sopenharmony_cifield are detailed below. 611462306a36Sopenharmony_ci 611562306a36Sopenharmony_ci:: 611662306a36Sopenharmony_ci 611762306a36Sopenharmony_ci __u8 ready_for_interrupt_injection; 611862306a36Sopenharmony_ci 611962306a36Sopenharmony_ciIf request_interrupt_window has been specified, this field indicates 612062306a36Sopenharmony_cian interrupt can be injected now with KVM_INTERRUPT. 612162306a36Sopenharmony_ci 612262306a36Sopenharmony_ci:: 612362306a36Sopenharmony_ci 612462306a36Sopenharmony_ci __u8 if_flag; 612562306a36Sopenharmony_ci 612662306a36Sopenharmony_ciThe value of the current interrupt flag. Only valid if in-kernel 612762306a36Sopenharmony_cilocal APIC is not used. 612862306a36Sopenharmony_ci 612962306a36Sopenharmony_ci:: 613062306a36Sopenharmony_ci 613162306a36Sopenharmony_ci __u16 flags; 613262306a36Sopenharmony_ci 613362306a36Sopenharmony_ciMore architecture-specific flags detailing state of the VCPU that may 613462306a36Sopenharmony_ciaffect the device's behavior. Current defined flags:: 613562306a36Sopenharmony_ci 613662306a36Sopenharmony_ci /* x86, set if the VCPU is in system management mode */ 613762306a36Sopenharmony_ci #define KVM_RUN_X86_SMM (1 << 0) 613862306a36Sopenharmony_ci /* x86, set if bus lock detected in VM */ 613962306a36Sopenharmony_ci #define KVM_RUN_BUS_LOCK (1 << 1) 614062306a36Sopenharmony_ci /* arm64, set for KVM_EXIT_DEBUG */ 614162306a36Sopenharmony_ci #define KVM_DEBUG_ARCH_HSR_HIGH_VALID (1 << 0) 614262306a36Sopenharmony_ci 614362306a36Sopenharmony_ci:: 614462306a36Sopenharmony_ci 614562306a36Sopenharmony_ci /* in (pre_kvm_run), out (post_kvm_run) */ 614662306a36Sopenharmony_ci __u64 cr8; 614762306a36Sopenharmony_ci 614862306a36Sopenharmony_ciThe value of the cr8 register. Only valid if in-kernel local APIC is 614962306a36Sopenharmony_cinot used. Both input and output. 615062306a36Sopenharmony_ci 615162306a36Sopenharmony_ci:: 615262306a36Sopenharmony_ci 615362306a36Sopenharmony_ci __u64 apic_base; 615462306a36Sopenharmony_ci 615562306a36Sopenharmony_ciThe value of the APIC BASE msr. Only valid if in-kernel local 615662306a36Sopenharmony_ciAPIC is not used. Both input and output. 615762306a36Sopenharmony_ci 615862306a36Sopenharmony_ci:: 615962306a36Sopenharmony_ci 616062306a36Sopenharmony_ci union { 616162306a36Sopenharmony_ci /* KVM_EXIT_UNKNOWN */ 616262306a36Sopenharmony_ci struct { 616362306a36Sopenharmony_ci __u64 hardware_exit_reason; 616462306a36Sopenharmony_ci } hw; 616562306a36Sopenharmony_ci 616662306a36Sopenharmony_ciIf exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown 616762306a36Sopenharmony_cireasons. Further architecture-specific information is available in 616862306a36Sopenharmony_cihardware_exit_reason. 616962306a36Sopenharmony_ci 617062306a36Sopenharmony_ci:: 617162306a36Sopenharmony_ci 617262306a36Sopenharmony_ci /* KVM_EXIT_FAIL_ENTRY */ 617362306a36Sopenharmony_ci struct { 617462306a36Sopenharmony_ci __u64 hardware_entry_failure_reason; 617562306a36Sopenharmony_ci __u32 cpu; /* if KVM_LAST_CPU */ 617662306a36Sopenharmony_ci } fail_entry; 617762306a36Sopenharmony_ci 617862306a36Sopenharmony_ciIf exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due 617962306a36Sopenharmony_cito unknown reasons. Further architecture-specific information is 618062306a36Sopenharmony_ciavailable in hardware_entry_failure_reason. 618162306a36Sopenharmony_ci 618262306a36Sopenharmony_ci:: 618362306a36Sopenharmony_ci 618462306a36Sopenharmony_ci /* KVM_EXIT_EXCEPTION */ 618562306a36Sopenharmony_ci struct { 618662306a36Sopenharmony_ci __u32 exception; 618762306a36Sopenharmony_ci __u32 error_code; 618862306a36Sopenharmony_ci } ex; 618962306a36Sopenharmony_ci 619062306a36Sopenharmony_ciUnused. 619162306a36Sopenharmony_ci 619262306a36Sopenharmony_ci:: 619362306a36Sopenharmony_ci 619462306a36Sopenharmony_ci /* KVM_EXIT_IO */ 619562306a36Sopenharmony_ci struct { 619662306a36Sopenharmony_ci #define KVM_EXIT_IO_IN 0 619762306a36Sopenharmony_ci #define KVM_EXIT_IO_OUT 1 619862306a36Sopenharmony_ci __u8 direction; 619962306a36Sopenharmony_ci __u8 size; /* bytes */ 620062306a36Sopenharmony_ci __u16 port; 620162306a36Sopenharmony_ci __u32 count; 620262306a36Sopenharmony_ci __u64 data_offset; /* relative to kvm_run start */ 620362306a36Sopenharmony_ci } io; 620462306a36Sopenharmony_ci 620562306a36Sopenharmony_ciIf exit_reason is KVM_EXIT_IO, then the vcpu has 620662306a36Sopenharmony_ciexecuted a port I/O instruction which could not be satisfied by kvm. 620762306a36Sopenharmony_cidata_offset describes where the data is located (KVM_EXIT_IO_OUT) or 620862306a36Sopenharmony_ciwhere kvm expects application code to place the data for the next 620962306a36Sopenharmony_ciKVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array. 621062306a36Sopenharmony_ci 621162306a36Sopenharmony_ci:: 621262306a36Sopenharmony_ci 621362306a36Sopenharmony_ci /* KVM_EXIT_DEBUG */ 621462306a36Sopenharmony_ci struct { 621562306a36Sopenharmony_ci struct kvm_debug_exit_arch arch; 621662306a36Sopenharmony_ci } debug; 621762306a36Sopenharmony_ci 621862306a36Sopenharmony_ciIf the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event 621962306a36Sopenharmony_cifor which architecture specific information is returned. 622062306a36Sopenharmony_ci 622162306a36Sopenharmony_ci:: 622262306a36Sopenharmony_ci 622362306a36Sopenharmony_ci /* KVM_EXIT_MMIO */ 622462306a36Sopenharmony_ci struct { 622562306a36Sopenharmony_ci __u64 phys_addr; 622662306a36Sopenharmony_ci __u8 data[8]; 622762306a36Sopenharmony_ci __u32 len; 622862306a36Sopenharmony_ci __u8 is_write; 622962306a36Sopenharmony_ci } mmio; 623062306a36Sopenharmony_ci 623162306a36Sopenharmony_ciIf exit_reason is KVM_EXIT_MMIO, then the vcpu has 623262306a36Sopenharmony_ciexecuted a memory-mapped I/O instruction which could not be satisfied 623362306a36Sopenharmony_ciby kvm. The 'data' member contains the written data if 'is_write' is 623462306a36Sopenharmony_citrue, and should be filled by application code otherwise. 623562306a36Sopenharmony_ci 623662306a36Sopenharmony_ciThe 'data' member contains, in its first 'len' bytes, the value as it would 623762306a36Sopenharmony_ciappear if the VCPU performed a load or store of the appropriate width directly 623862306a36Sopenharmony_cito the byte array. 623962306a36Sopenharmony_ci 624062306a36Sopenharmony_ci.. note:: 624162306a36Sopenharmony_ci 624262306a36Sopenharmony_ci For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR, KVM_EXIT_XEN, 624362306a36Sopenharmony_ci KVM_EXIT_EPR, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR the corresponding 624462306a36Sopenharmony_ci operations are complete (and guest state is consistent) only after userspace 624562306a36Sopenharmony_ci has re-entered the kernel with KVM_RUN. The kernel side will first finish 624662306a36Sopenharmony_ci incomplete operations and then check for pending signals. 624762306a36Sopenharmony_ci 624862306a36Sopenharmony_ci The pending state of the operation is not preserved in state which is 624962306a36Sopenharmony_ci visible to userspace, thus userspace should ensure that the operation is 625062306a36Sopenharmony_ci completed before performing a live migration. Userspace can re-enter the 625162306a36Sopenharmony_ci guest with an unmasked signal pending or with the immediate_exit field set 625262306a36Sopenharmony_ci to complete pending operations without allowing any further instructions 625362306a36Sopenharmony_ci to be executed. 625462306a36Sopenharmony_ci 625562306a36Sopenharmony_ci:: 625662306a36Sopenharmony_ci 625762306a36Sopenharmony_ci /* KVM_EXIT_HYPERCALL */ 625862306a36Sopenharmony_ci struct { 625962306a36Sopenharmony_ci __u64 nr; 626062306a36Sopenharmony_ci __u64 args[6]; 626162306a36Sopenharmony_ci __u64 ret; 626262306a36Sopenharmony_ci __u64 flags; 626362306a36Sopenharmony_ci } hypercall; 626462306a36Sopenharmony_ci 626562306a36Sopenharmony_ci 626662306a36Sopenharmony_ciIt is strongly recommended that userspace use ``KVM_EXIT_IO`` (x86) or 626762306a36Sopenharmony_ci``KVM_EXIT_MMIO`` (all except s390) to implement functionality that 626862306a36Sopenharmony_cirequires a guest to interact with host userspace. 626962306a36Sopenharmony_ci 627062306a36Sopenharmony_ci.. note:: KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO. 627162306a36Sopenharmony_ci 627262306a36Sopenharmony_ciFor arm64: 627362306a36Sopenharmony_ci---------- 627462306a36Sopenharmony_ci 627562306a36Sopenharmony_ciSMCCC exits can be enabled depending on the configuration of the SMCCC 627662306a36Sopenharmony_cifilter. See the Documentation/virt/kvm/devices/vm.rst 627762306a36Sopenharmony_ci``KVM_ARM_SMCCC_FILTER`` for more details. 627862306a36Sopenharmony_ci 627962306a36Sopenharmony_ci``nr`` contains the function ID of the guest's SMCCC call. Userspace is 628062306a36Sopenharmony_ciexpected to use the ``KVM_GET_ONE_REG`` ioctl to retrieve the call 628162306a36Sopenharmony_ciparameters from the vCPU's GPRs. 628262306a36Sopenharmony_ci 628362306a36Sopenharmony_ciDefinition of ``flags``: 628462306a36Sopenharmony_ci - ``KVM_HYPERCALL_EXIT_SMC``: Indicates that the guest used the SMC 628562306a36Sopenharmony_ci conduit to initiate the SMCCC call. If this bit is 0 then the guest 628662306a36Sopenharmony_ci used the HVC conduit for the SMCCC call. 628762306a36Sopenharmony_ci 628862306a36Sopenharmony_ci - ``KVM_HYPERCALL_EXIT_16BIT``: Indicates that the guest used a 16bit 628962306a36Sopenharmony_ci instruction to initiate the SMCCC call. If this bit is 0 then the 629062306a36Sopenharmony_ci guest used a 32bit instruction. An AArch64 guest always has this 629162306a36Sopenharmony_ci bit set to 0. 629262306a36Sopenharmony_ci 629362306a36Sopenharmony_ciAt the point of exit, PC points to the instruction immediately following 629462306a36Sopenharmony_cithe trapping instruction. 629562306a36Sopenharmony_ci 629662306a36Sopenharmony_ci:: 629762306a36Sopenharmony_ci 629862306a36Sopenharmony_ci /* KVM_EXIT_TPR_ACCESS */ 629962306a36Sopenharmony_ci struct { 630062306a36Sopenharmony_ci __u64 rip; 630162306a36Sopenharmony_ci __u32 is_write; 630262306a36Sopenharmony_ci __u32 pad; 630362306a36Sopenharmony_ci } tpr_access; 630462306a36Sopenharmony_ci 630562306a36Sopenharmony_ciTo be documented (KVM_TPR_ACCESS_REPORTING). 630662306a36Sopenharmony_ci 630762306a36Sopenharmony_ci:: 630862306a36Sopenharmony_ci 630962306a36Sopenharmony_ci /* KVM_EXIT_S390_SIEIC */ 631062306a36Sopenharmony_ci struct { 631162306a36Sopenharmony_ci __u8 icptcode; 631262306a36Sopenharmony_ci __u64 mask; /* psw upper half */ 631362306a36Sopenharmony_ci __u64 addr; /* psw lower half */ 631462306a36Sopenharmony_ci __u16 ipa; 631562306a36Sopenharmony_ci __u32 ipb; 631662306a36Sopenharmony_ci } s390_sieic; 631762306a36Sopenharmony_ci 631862306a36Sopenharmony_cis390 specific. 631962306a36Sopenharmony_ci 632062306a36Sopenharmony_ci:: 632162306a36Sopenharmony_ci 632262306a36Sopenharmony_ci /* KVM_EXIT_S390_RESET */ 632362306a36Sopenharmony_ci #define KVM_S390_RESET_POR 1 632462306a36Sopenharmony_ci #define KVM_S390_RESET_CLEAR 2 632562306a36Sopenharmony_ci #define KVM_S390_RESET_SUBSYSTEM 4 632662306a36Sopenharmony_ci #define KVM_S390_RESET_CPU_INIT 8 632762306a36Sopenharmony_ci #define KVM_S390_RESET_IPL 16 632862306a36Sopenharmony_ci __u64 s390_reset_flags; 632962306a36Sopenharmony_ci 633062306a36Sopenharmony_cis390 specific. 633162306a36Sopenharmony_ci 633262306a36Sopenharmony_ci:: 633362306a36Sopenharmony_ci 633462306a36Sopenharmony_ci /* KVM_EXIT_S390_UCONTROL */ 633562306a36Sopenharmony_ci struct { 633662306a36Sopenharmony_ci __u64 trans_exc_code; 633762306a36Sopenharmony_ci __u32 pgm_code; 633862306a36Sopenharmony_ci } s390_ucontrol; 633962306a36Sopenharmony_ci 634062306a36Sopenharmony_cis390 specific. A page fault has occurred for a user controlled virtual 634162306a36Sopenharmony_cimachine (KVM_VM_S390_UNCONTROL) on its host page table that cannot be 634262306a36Sopenharmony_ciresolved by the kernel. 634362306a36Sopenharmony_ciThe program code and the translation exception code that were placed 634462306a36Sopenharmony_ciin the cpu's lowcore are presented here as defined by the z Architecture 634562306a36Sopenharmony_ciPrinciples of Operation Book in the Chapter for Dynamic Address Translation 634662306a36Sopenharmony_ci(DAT) 634762306a36Sopenharmony_ci 634862306a36Sopenharmony_ci:: 634962306a36Sopenharmony_ci 635062306a36Sopenharmony_ci /* KVM_EXIT_DCR */ 635162306a36Sopenharmony_ci struct { 635262306a36Sopenharmony_ci __u32 dcrn; 635362306a36Sopenharmony_ci __u32 data; 635462306a36Sopenharmony_ci __u8 is_write; 635562306a36Sopenharmony_ci } dcr; 635662306a36Sopenharmony_ci 635762306a36Sopenharmony_ciDeprecated - was used for 440 KVM. 635862306a36Sopenharmony_ci 635962306a36Sopenharmony_ci:: 636062306a36Sopenharmony_ci 636162306a36Sopenharmony_ci /* KVM_EXIT_OSI */ 636262306a36Sopenharmony_ci struct { 636362306a36Sopenharmony_ci __u64 gprs[32]; 636462306a36Sopenharmony_ci } osi; 636562306a36Sopenharmony_ci 636662306a36Sopenharmony_ciMOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch 636762306a36Sopenharmony_cihypercalls and exit with this exit struct that contains all the guest gprs. 636862306a36Sopenharmony_ci 636962306a36Sopenharmony_ciIf exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall. 637062306a36Sopenharmony_ciUserspace can now handle the hypercall and when it's done modify the gprs as 637162306a36Sopenharmony_cinecessary. Upon guest entry all guest GPRs will then be replaced by the values 637262306a36Sopenharmony_ciin this struct. 637362306a36Sopenharmony_ci 637462306a36Sopenharmony_ci:: 637562306a36Sopenharmony_ci 637662306a36Sopenharmony_ci /* KVM_EXIT_PAPR_HCALL */ 637762306a36Sopenharmony_ci struct { 637862306a36Sopenharmony_ci __u64 nr; 637962306a36Sopenharmony_ci __u64 ret; 638062306a36Sopenharmony_ci __u64 args[9]; 638162306a36Sopenharmony_ci } papr_hcall; 638262306a36Sopenharmony_ci 638362306a36Sopenharmony_ciThis is used on 64-bit PowerPC when emulating a pSeries partition, 638462306a36Sopenharmony_cie.g. with the 'pseries' machine type in qemu. It occurs when the 638562306a36Sopenharmony_ciguest does a hypercall using the 'sc 1' instruction. The 'nr' field 638662306a36Sopenharmony_cicontains the hypercall number (from the guest R3), and 'args' contains 638762306a36Sopenharmony_cithe arguments (from the guest R4 - R12). Userspace should put the 638862306a36Sopenharmony_cireturn code in 'ret' and any extra returned values in args[]. 638962306a36Sopenharmony_ciThe possible hypercalls are defined in the Power Architecture Platform 639062306a36Sopenharmony_ciRequirements (PAPR) document available from www.power.org (free 639162306a36Sopenharmony_cideveloper registration required to access it). 639262306a36Sopenharmony_ci 639362306a36Sopenharmony_ci:: 639462306a36Sopenharmony_ci 639562306a36Sopenharmony_ci /* KVM_EXIT_S390_TSCH */ 639662306a36Sopenharmony_ci struct { 639762306a36Sopenharmony_ci __u16 subchannel_id; 639862306a36Sopenharmony_ci __u16 subchannel_nr; 639962306a36Sopenharmony_ci __u32 io_int_parm; 640062306a36Sopenharmony_ci __u32 io_int_word; 640162306a36Sopenharmony_ci __u32 ipb; 640262306a36Sopenharmony_ci __u8 dequeued; 640362306a36Sopenharmony_ci } s390_tsch; 640462306a36Sopenharmony_ci 640562306a36Sopenharmony_cis390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled 640662306a36Sopenharmony_ciand TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O 640762306a36Sopenharmony_ciinterrupt for the target subchannel has been dequeued and subchannel_id, 640862306a36Sopenharmony_cisubchannel_nr, io_int_parm and io_int_word contain the parameters for that 640962306a36Sopenharmony_ciinterrupt. ipb is needed for instruction parameter decoding. 641062306a36Sopenharmony_ci 641162306a36Sopenharmony_ci:: 641262306a36Sopenharmony_ci 641362306a36Sopenharmony_ci /* KVM_EXIT_EPR */ 641462306a36Sopenharmony_ci struct { 641562306a36Sopenharmony_ci __u32 epr; 641662306a36Sopenharmony_ci } epr; 641762306a36Sopenharmony_ci 641862306a36Sopenharmony_ciOn FSL BookE PowerPC chips, the interrupt controller has a fast patch 641962306a36Sopenharmony_ciinterrupt acknowledge path to the core. When the core successfully 642062306a36Sopenharmony_cidelivers an interrupt, it automatically populates the EPR register with 642162306a36Sopenharmony_cithe interrupt vector number and acknowledges the interrupt inside 642262306a36Sopenharmony_cithe interrupt controller. 642362306a36Sopenharmony_ci 642462306a36Sopenharmony_ciIn case the interrupt controller lives in user space, we need to do 642562306a36Sopenharmony_cithe interrupt acknowledge cycle through it to fetch the next to be 642662306a36Sopenharmony_cidelivered interrupt vector using this exit. 642762306a36Sopenharmony_ci 642862306a36Sopenharmony_ciIt gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an 642962306a36Sopenharmony_ciexternal interrupt has just been delivered into the guest. User space 643062306a36Sopenharmony_cishould put the acknowledged interrupt vector into the 'epr' field. 643162306a36Sopenharmony_ci 643262306a36Sopenharmony_ci:: 643362306a36Sopenharmony_ci 643462306a36Sopenharmony_ci /* KVM_EXIT_SYSTEM_EVENT */ 643562306a36Sopenharmony_ci struct { 643662306a36Sopenharmony_ci #define KVM_SYSTEM_EVENT_SHUTDOWN 1 643762306a36Sopenharmony_ci #define KVM_SYSTEM_EVENT_RESET 2 643862306a36Sopenharmony_ci #define KVM_SYSTEM_EVENT_CRASH 3 643962306a36Sopenharmony_ci #define KVM_SYSTEM_EVENT_WAKEUP 4 644062306a36Sopenharmony_ci #define KVM_SYSTEM_EVENT_SUSPEND 5 644162306a36Sopenharmony_ci #define KVM_SYSTEM_EVENT_SEV_TERM 6 644262306a36Sopenharmony_ci __u32 type; 644362306a36Sopenharmony_ci __u32 ndata; 644462306a36Sopenharmony_ci __u64 data[16]; 644562306a36Sopenharmony_ci } system_event; 644662306a36Sopenharmony_ci 644762306a36Sopenharmony_ciIf exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered 644862306a36Sopenharmony_cia system-level event using some architecture specific mechanism (hypercall 644962306a36Sopenharmony_cior some special instruction). In case of ARM64, this is triggered using 645062306a36Sopenharmony_ciHVC instruction based PSCI call from the vcpu. 645162306a36Sopenharmony_ci 645262306a36Sopenharmony_ciThe 'type' field describes the system-level event type. 645362306a36Sopenharmony_ciValid values for 'type' are: 645462306a36Sopenharmony_ci 645562306a36Sopenharmony_ci - KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the 645662306a36Sopenharmony_ci VM. Userspace is not obliged to honour this, and if it does honour 645762306a36Sopenharmony_ci this does not need to destroy the VM synchronously (ie it may call 645862306a36Sopenharmony_ci KVM_RUN again before shutdown finally occurs). 645962306a36Sopenharmony_ci - KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM. 646062306a36Sopenharmony_ci As with SHUTDOWN, userspace can choose to ignore the request, or 646162306a36Sopenharmony_ci to schedule the reset to occur in the future and may call KVM_RUN again. 646262306a36Sopenharmony_ci - KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest 646362306a36Sopenharmony_ci has requested a crash condition maintenance. Userspace can choose 646462306a36Sopenharmony_ci to ignore the request, or to gather VM memory core dump and/or 646562306a36Sopenharmony_ci reset/shutdown of the VM. 646662306a36Sopenharmony_ci - KVM_SYSTEM_EVENT_SEV_TERM -- an AMD SEV guest requested termination. 646762306a36Sopenharmony_ci The guest physical address of the guest's GHCB is stored in `data[0]`. 646862306a36Sopenharmony_ci - KVM_SYSTEM_EVENT_WAKEUP -- the exiting vCPU is in a suspended state and 646962306a36Sopenharmony_ci KVM has recognized a wakeup event. Userspace may honor this event by 647062306a36Sopenharmony_ci marking the exiting vCPU as runnable, or deny it and call KVM_RUN again. 647162306a36Sopenharmony_ci - KVM_SYSTEM_EVENT_SUSPEND -- the guest has requested a suspension of 647262306a36Sopenharmony_ci the VM. 647362306a36Sopenharmony_ci 647462306a36Sopenharmony_ciIf KVM_CAP_SYSTEM_EVENT_DATA is present, the 'data' field can contain 647562306a36Sopenharmony_ciarchitecture specific information for the system-level event. Only 647662306a36Sopenharmony_cithe first `ndata` items (possibly zero) of the data array are valid. 647762306a36Sopenharmony_ci 647862306a36Sopenharmony_ci - for arm64, data[0] is set to KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 if 647962306a36Sopenharmony_ci the guest issued a SYSTEM_RESET2 call according to v1.1 of the PSCI 648062306a36Sopenharmony_ci specification. 648162306a36Sopenharmony_ci 648262306a36Sopenharmony_ci - for RISC-V, data[0] is set to the value of the second argument of the 648362306a36Sopenharmony_ci ``sbi_system_reset`` call. 648462306a36Sopenharmony_ci 648562306a36Sopenharmony_ciPrevious versions of Linux defined a `flags` member in this struct. The 648662306a36Sopenharmony_cifield is now aliased to `data[0]`. Userspace can assume that it is only 648762306a36Sopenharmony_ciwritten if ndata is greater than 0. 648862306a36Sopenharmony_ci 648962306a36Sopenharmony_ciFor arm/arm64: 649062306a36Sopenharmony_ci-------------- 649162306a36Sopenharmony_ci 649262306a36Sopenharmony_ciKVM_SYSTEM_EVENT_SUSPEND exits are enabled with the 649362306a36Sopenharmony_ciKVM_CAP_ARM_SYSTEM_SUSPEND VM capability. If a guest invokes the PSCI 649462306a36Sopenharmony_ciSYSTEM_SUSPEND function, KVM will exit to userspace with this event 649562306a36Sopenharmony_citype. 649662306a36Sopenharmony_ci 649762306a36Sopenharmony_ciIt is the sole responsibility of userspace to implement the PSCI 649862306a36Sopenharmony_ciSYSTEM_SUSPEND call according to ARM DEN0022D.b 5.19 "SYSTEM_SUSPEND". 649962306a36Sopenharmony_ciKVM does not change the vCPU's state before exiting to userspace, so 650062306a36Sopenharmony_cithe call parameters are left in-place in the vCPU registers. 650162306a36Sopenharmony_ci 650262306a36Sopenharmony_ciUserspace is _required_ to take action for such an exit. It must 650362306a36Sopenharmony_cieither: 650462306a36Sopenharmony_ci 650562306a36Sopenharmony_ci - Honor the guest request to suspend the VM. Userspace can request 650662306a36Sopenharmony_ci in-kernel emulation of suspension by setting the calling vCPU's 650762306a36Sopenharmony_ci state to KVM_MP_STATE_SUSPENDED. Userspace must configure the vCPU's 650862306a36Sopenharmony_ci state according to the parameters passed to the PSCI function when 650962306a36Sopenharmony_ci the calling vCPU is resumed. See ARM DEN0022D.b 5.19.1 "Intended use" 651062306a36Sopenharmony_ci for details on the function parameters. 651162306a36Sopenharmony_ci 651262306a36Sopenharmony_ci - Deny the guest request to suspend the VM. See ARM DEN0022D.b 5.19.2 651362306a36Sopenharmony_ci "Caller responsibilities" for possible return values. 651462306a36Sopenharmony_ci 651562306a36Sopenharmony_ci:: 651662306a36Sopenharmony_ci 651762306a36Sopenharmony_ci /* KVM_EXIT_IOAPIC_EOI */ 651862306a36Sopenharmony_ci struct { 651962306a36Sopenharmony_ci __u8 vector; 652062306a36Sopenharmony_ci } eoi; 652162306a36Sopenharmony_ci 652262306a36Sopenharmony_ciIndicates that the VCPU's in-kernel local APIC received an EOI for a 652362306a36Sopenharmony_cilevel-triggered IOAPIC interrupt. This exit only triggers when the 652462306a36Sopenharmony_ciIOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled); 652562306a36Sopenharmony_cithe userspace IOAPIC should process the EOI and retrigger the interrupt if 652662306a36Sopenharmony_ciit is still asserted. Vector is the LAPIC interrupt vector for which the 652762306a36Sopenharmony_ciEOI was received. 652862306a36Sopenharmony_ci 652962306a36Sopenharmony_ci:: 653062306a36Sopenharmony_ci 653162306a36Sopenharmony_ci struct kvm_hyperv_exit { 653262306a36Sopenharmony_ci #define KVM_EXIT_HYPERV_SYNIC 1 653362306a36Sopenharmony_ci #define KVM_EXIT_HYPERV_HCALL 2 653462306a36Sopenharmony_ci #define KVM_EXIT_HYPERV_SYNDBG 3 653562306a36Sopenharmony_ci __u32 type; 653662306a36Sopenharmony_ci __u32 pad1; 653762306a36Sopenharmony_ci union { 653862306a36Sopenharmony_ci struct { 653962306a36Sopenharmony_ci __u32 msr; 654062306a36Sopenharmony_ci __u32 pad2; 654162306a36Sopenharmony_ci __u64 control; 654262306a36Sopenharmony_ci __u64 evt_page; 654362306a36Sopenharmony_ci __u64 msg_page; 654462306a36Sopenharmony_ci } synic; 654562306a36Sopenharmony_ci struct { 654662306a36Sopenharmony_ci __u64 input; 654762306a36Sopenharmony_ci __u64 result; 654862306a36Sopenharmony_ci __u64 params[2]; 654962306a36Sopenharmony_ci } hcall; 655062306a36Sopenharmony_ci struct { 655162306a36Sopenharmony_ci __u32 msr; 655262306a36Sopenharmony_ci __u32 pad2; 655362306a36Sopenharmony_ci __u64 control; 655462306a36Sopenharmony_ci __u64 status; 655562306a36Sopenharmony_ci __u64 send_page; 655662306a36Sopenharmony_ci __u64 recv_page; 655762306a36Sopenharmony_ci __u64 pending_page; 655862306a36Sopenharmony_ci } syndbg; 655962306a36Sopenharmony_ci } u; 656062306a36Sopenharmony_ci }; 656162306a36Sopenharmony_ci /* KVM_EXIT_HYPERV */ 656262306a36Sopenharmony_ci struct kvm_hyperv_exit hyperv; 656362306a36Sopenharmony_ci 656462306a36Sopenharmony_ciIndicates that the VCPU exits into userspace to process some tasks 656562306a36Sopenharmony_cirelated to Hyper-V emulation. 656662306a36Sopenharmony_ci 656762306a36Sopenharmony_ciValid values for 'type' are: 656862306a36Sopenharmony_ci 656962306a36Sopenharmony_ci - KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about 657062306a36Sopenharmony_ci 657162306a36Sopenharmony_ciHyper-V SynIC state change. Notification is used to remap SynIC 657262306a36Sopenharmony_cievent/message pages and to enable/disable SynIC messages/events processing 657362306a36Sopenharmony_ciin userspace. 657462306a36Sopenharmony_ci 657562306a36Sopenharmony_ci - KVM_EXIT_HYPERV_SYNDBG -- synchronously notify user-space about 657662306a36Sopenharmony_ci 657762306a36Sopenharmony_ciHyper-V Synthetic debugger state change. Notification is used to either update 657862306a36Sopenharmony_cithe pending_page location or to send a control command (send the buffer located 657962306a36Sopenharmony_ciin send_page or recv a buffer to recv_page). 658062306a36Sopenharmony_ci 658162306a36Sopenharmony_ci:: 658262306a36Sopenharmony_ci 658362306a36Sopenharmony_ci /* KVM_EXIT_ARM_NISV */ 658462306a36Sopenharmony_ci struct { 658562306a36Sopenharmony_ci __u64 esr_iss; 658662306a36Sopenharmony_ci __u64 fault_ipa; 658762306a36Sopenharmony_ci } arm_nisv; 658862306a36Sopenharmony_ci 658962306a36Sopenharmony_ciUsed on arm64 systems. If a guest accesses memory not in a memslot, 659062306a36Sopenharmony_ciKVM will typically return to userspace and ask it to do MMIO emulation on its 659162306a36Sopenharmony_cibehalf. However, for certain classes of instructions, no instruction decode 659262306a36Sopenharmony_ci(direction, length of memory access) is provided, and fetching and decoding 659362306a36Sopenharmony_cithe instruction from the VM is overly complicated to live in the kernel. 659462306a36Sopenharmony_ci 659562306a36Sopenharmony_ciHistorically, when this situation occurred, KVM would print a warning and kill 659662306a36Sopenharmony_cithe VM. KVM assumed that if the guest accessed non-memslot memory, it was 659762306a36Sopenharmony_citrying to do I/O, which just couldn't be emulated, and the warning message was 659862306a36Sopenharmony_ciphrased accordingly. However, what happened more often was that a guest bug 659962306a36Sopenharmony_cicaused access outside the guest memory areas which should lead to a more 660062306a36Sopenharmony_cimeaningful warning message and an external abort in the guest, if the access 660162306a36Sopenharmony_cidid not fall within an I/O window. 660262306a36Sopenharmony_ci 660362306a36Sopenharmony_ciUserspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable 660462306a36Sopenharmony_cithis capability at VM creation. Once this is done, these types of errors will 660562306a36Sopenharmony_ciinstead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from 660662306a36Sopenharmony_cithe ESR_EL2 in the esr_iss field, and the faulting IPA in the fault_ipa field. 660762306a36Sopenharmony_ciUserspace can either fix up the access if it's actually an I/O access by 660862306a36Sopenharmony_cidecoding the instruction from guest memory (if it's very brave) and continue 660962306a36Sopenharmony_ciexecuting the guest, or it can decide to suspend, dump, or restart the guest. 661062306a36Sopenharmony_ci 661162306a36Sopenharmony_ciNote that KVM does not skip the faulting instruction as it does for 661262306a36Sopenharmony_ciKVM_EXIT_MMIO, but userspace has to emulate any change to the processing state 661362306a36Sopenharmony_ciif it decides to decode and emulate the instruction. 661462306a36Sopenharmony_ci 661562306a36Sopenharmony_ci:: 661662306a36Sopenharmony_ci 661762306a36Sopenharmony_ci /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ 661862306a36Sopenharmony_ci struct { 661962306a36Sopenharmony_ci __u8 error; /* user -> kernel */ 662062306a36Sopenharmony_ci __u8 pad[7]; 662162306a36Sopenharmony_ci __u32 reason; /* kernel -> user */ 662262306a36Sopenharmony_ci __u32 index; /* kernel -> user */ 662362306a36Sopenharmony_ci __u64 data; /* kernel <-> user */ 662462306a36Sopenharmony_ci } msr; 662562306a36Sopenharmony_ci 662662306a36Sopenharmony_ciUsed on x86 systems. When the VM capability KVM_CAP_X86_USER_SPACE_MSR is 662762306a36Sopenharmony_cienabled, MSR accesses to registers that would invoke a #GP by KVM kernel code 662862306a36Sopenharmony_cimay instead trigger a KVM_EXIT_X86_RDMSR exit for reads and KVM_EXIT_X86_WRMSR 662962306a36Sopenharmony_ciexit for writes. 663062306a36Sopenharmony_ci 663162306a36Sopenharmony_ciThe "reason" field specifies why the MSR interception occurred. Userspace will 663262306a36Sopenharmony_cionly receive MSR exits when a particular reason was requested during through 663362306a36Sopenharmony_ciENABLE_CAP. Currently valid exit reasons are: 663462306a36Sopenharmony_ci 663562306a36Sopenharmony_ci============================ ======================================== 663662306a36Sopenharmony_ci KVM_MSR_EXIT_REASON_UNKNOWN access to MSR that is unknown to KVM 663762306a36Sopenharmony_ci KVM_MSR_EXIT_REASON_INVAL access to invalid MSRs or reserved bits 663862306a36Sopenharmony_ci KVM_MSR_EXIT_REASON_FILTER access blocked by KVM_X86_SET_MSR_FILTER 663962306a36Sopenharmony_ci============================ ======================================== 664062306a36Sopenharmony_ci 664162306a36Sopenharmony_ciFor KVM_EXIT_X86_RDMSR, the "index" field tells userspace which MSR the guest 664262306a36Sopenharmony_ciwants to read. To respond to this request with a successful read, userspace 664362306a36Sopenharmony_ciwrites the respective data into the "data" field and must continue guest 664462306a36Sopenharmony_ciexecution to ensure the read data is transferred into guest register state. 664562306a36Sopenharmony_ci 664662306a36Sopenharmony_ciIf the RDMSR request was unsuccessful, userspace indicates that with a "1" in 664762306a36Sopenharmony_cithe "error" field. This will inject a #GP into the guest when the VCPU is 664862306a36Sopenharmony_ciexecuted again. 664962306a36Sopenharmony_ci 665062306a36Sopenharmony_ciFor KVM_EXIT_X86_WRMSR, the "index" field tells userspace which MSR the guest 665162306a36Sopenharmony_ciwants to write. Once finished processing the event, userspace must continue 665262306a36Sopenharmony_civCPU execution. If the MSR write was unsuccessful, userspace also sets the 665362306a36Sopenharmony_ci"error" field to "1". 665462306a36Sopenharmony_ci 665562306a36Sopenharmony_ciSee KVM_X86_SET_MSR_FILTER for details on the interaction with MSR filtering. 665662306a36Sopenharmony_ci 665762306a36Sopenharmony_ci:: 665862306a36Sopenharmony_ci 665962306a36Sopenharmony_ci 666062306a36Sopenharmony_ci struct kvm_xen_exit { 666162306a36Sopenharmony_ci #define KVM_EXIT_XEN_HCALL 1 666262306a36Sopenharmony_ci __u32 type; 666362306a36Sopenharmony_ci union { 666462306a36Sopenharmony_ci struct { 666562306a36Sopenharmony_ci __u32 longmode; 666662306a36Sopenharmony_ci __u32 cpl; 666762306a36Sopenharmony_ci __u64 input; 666862306a36Sopenharmony_ci __u64 result; 666962306a36Sopenharmony_ci __u64 params[6]; 667062306a36Sopenharmony_ci } hcall; 667162306a36Sopenharmony_ci } u; 667262306a36Sopenharmony_ci }; 667362306a36Sopenharmony_ci /* KVM_EXIT_XEN */ 667462306a36Sopenharmony_ci struct kvm_hyperv_exit xen; 667562306a36Sopenharmony_ci 667662306a36Sopenharmony_ciIndicates that the VCPU exits into userspace to process some tasks 667762306a36Sopenharmony_cirelated to Xen emulation. 667862306a36Sopenharmony_ci 667962306a36Sopenharmony_ciValid values for 'type' are: 668062306a36Sopenharmony_ci 668162306a36Sopenharmony_ci - KVM_EXIT_XEN_HCALL -- synchronously notify user-space about Xen hypercall. 668262306a36Sopenharmony_ci Userspace is expected to place the hypercall result into the appropriate 668362306a36Sopenharmony_ci field before invoking KVM_RUN again. 668462306a36Sopenharmony_ci 668562306a36Sopenharmony_ci:: 668662306a36Sopenharmony_ci 668762306a36Sopenharmony_ci /* KVM_EXIT_RISCV_SBI */ 668862306a36Sopenharmony_ci struct { 668962306a36Sopenharmony_ci unsigned long extension_id; 669062306a36Sopenharmony_ci unsigned long function_id; 669162306a36Sopenharmony_ci unsigned long args[6]; 669262306a36Sopenharmony_ci unsigned long ret[2]; 669362306a36Sopenharmony_ci } riscv_sbi; 669462306a36Sopenharmony_ci 669562306a36Sopenharmony_ciIf exit reason is KVM_EXIT_RISCV_SBI then it indicates that the VCPU has 669662306a36Sopenharmony_cidone a SBI call which is not handled by KVM RISC-V kernel module. The details 669762306a36Sopenharmony_ciof the SBI call are available in 'riscv_sbi' member of kvm_run structure. The 669862306a36Sopenharmony_ci'extension_id' field of 'riscv_sbi' represents SBI extension ID whereas the 669962306a36Sopenharmony_ci'function_id' field represents function ID of given SBI extension. The 'args' 670062306a36Sopenharmony_ciarray field of 'riscv_sbi' represents parameters for the SBI call and 'ret' 670162306a36Sopenharmony_ciarray field represents return values. The userspace should update the return 670262306a36Sopenharmony_civalues of SBI call before resuming the VCPU. For more details on RISC-V SBI 670362306a36Sopenharmony_cispec refer, https://github.com/riscv/riscv-sbi-doc. 670462306a36Sopenharmony_ci 670562306a36Sopenharmony_ci:: 670662306a36Sopenharmony_ci 670762306a36Sopenharmony_ci /* KVM_EXIT_NOTIFY */ 670862306a36Sopenharmony_ci struct { 670962306a36Sopenharmony_ci #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0) 671062306a36Sopenharmony_ci __u32 flags; 671162306a36Sopenharmony_ci } notify; 671262306a36Sopenharmony_ci 671362306a36Sopenharmony_ciUsed on x86 systems. When the VM capability KVM_CAP_X86_NOTIFY_VMEXIT is 671462306a36Sopenharmony_cienabled, a VM exit generated if no event window occurs in VM non-root mode 671562306a36Sopenharmony_cifor a specified amount of time. Once KVM_X86_NOTIFY_VMEXIT_USER is set when 671662306a36Sopenharmony_cienabling the cap, it would exit to userspace with the exit reason 671762306a36Sopenharmony_ciKVM_EXIT_NOTIFY for further handling. The "flags" field contains more 671862306a36Sopenharmony_cidetailed info. 671962306a36Sopenharmony_ci 672062306a36Sopenharmony_ciThe valid value for 'flags' is: 672162306a36Sopenharmony_ci 672262306a36Sopenharmony_ci - KVM_NOTIFY_CONTEXT_INVALID -- the VM context is corrupted and not valid 672362306a36Sopenharmony_ci in VMCS. It would run into unknown result if resume the target VM. 672462306a36Sopenharmony_ci 672562306a36Sopenharmony_ci:: 672662306a36Sopenharmony_ci 672762306a36Sopenharmony_ci /* Fix the size of the union. */ 672862306a36Sopenharmony_ci char padding[256]; 672962306a36Sopenharmony_ci }; 673062306a36Sopenharmony_ci 673162306a36Sopenharmony_ci /* 673262306a36Sopenharmony_ci * shared registers between kvm and userspace. 673362306a36Sopenharmony_ci * kvm_valid_regs specifies the register classes set by the host 673462306a36Sopenharmony_ci * kvm_dirty_regs specified the register classes dirtied by userspace 673562306a36Sopenharmony_ci * struct kvm_sync_regs is architecture specific, as well as the 673662306a36Sopenharmony_ci * bits for kvm_valid_regs and kvm_dirty_regs 673762306a36Sopenharmony_ci */ 673862306a36Sopenharmony_ci __u64 kvm_valid_regs; 673962306a36Sopenharmony_ci __u64 kvm_dirty_regs; 674062306a36Sopenharmony_ci union { 674162306a36Sopenharmony_ci struct kvm_sync_regs regs; 674262306a36Sopenharmony_ci char padding[SYNC_REGS_SIZE_BYTES]; 674362306a36Sopenharmony_ci } s; 674462306a36Sopenharmony_ci 674562306a36Sopenharmony_ciIf KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access 674662306a36Sopenharmony_cicertain guest registers without having to call SET/GET_*REGS. Thus we can 674762306a36Sopenharmony_ciavoid some system call overhead if userspace has to handle the exit. 674862306a36Sopenharmony_ciUserspace can query the validity of the structure by checking 674962306a36Sopenharmony_cikvm_valid_regs for specific bits. These bits are architecture specific 675062306a36Sopenharmony_ciand usually define the validity of a groups of registers. (e.g. one bit 675162306a36Sopenharmony_cifor general purpose registers) 675262306a36Sopenharmony_ci 675362306a36Sopenharmony_ciPlease note that the kernel is allowed to use the kvm_run structure as the 675462306a36Sopenharmony_ciprimary storage for certain register types. Therefore, the kernel may use the 675562306a36Sopenharmony_civalues in kvm_run even if the corresponding bit in kvm_dirty_regs is not set. 675662306a36Sopenharmony_ci 675762306a36Sopenharmony_ci 675862306a36Sopenharmony_ci6. Capabilities that can be enabled on vCPUs 675962306a36Sopenharmony_ci============================================ 676062306a36Sopenharmony_ci 676162306a36Sopenharmony_ciThere are certain capabilities that change the behavior of the virtual CPU or 676262306a36Sopenharmony_cithe virtual machine when enabled. To enable them, please see section 4.37. 676362306a36Sopenharmony_ciBelow you can find a list of capabilities and what their effect on the vCPU or 676462306a36Sopenharmony_cithe virtual machine is when enabling them. 676562306a36Sopenharmony_ci 676662306a36Sopenharmony_ciThe following information is provided along with the description: 676762306a36Sopenharmony_ci 676862306a36Sopenharmony_ci Architectures: 676962306a36Sopenharmony_ci which instruction set architectures provide this ioctl. 677062306a36Sopenharmony_ci x86 includes both i386 and x86_64. 677162306a36Sopenharmony_ci 677262306a36Sopenharmony_ci Target: 677362306a36Sopenharmony_ci whether this is a per-vcpu or per-vm capability. 677462306a36Sopenharmony_ci 677562306a36Sopenharmony_ci Parameters: 677662306a36Sopenharmony_ci what parameters are accepted by the capability. 677762306a36Sopenharmony_ci 677862306a36Sopenharmony_ci Returns: 677962306a36Sopenharmony_ci the return value. General error numbers (EBADF, ENOMEM, EINVAL) 678062306a36Sopenharmony_ci are not detailed, but errors with specific meanings are. 678162306a36Sopenharmony_ci 678262306a36Sopenharmony_ci 678362306a36Sopenharmony_ci6.1 KVM_CAP_PPC_OSI 678462306a36Sopenharmony_ci------------------- 678562306a36Sopenharmony_ci 678662306a36Sopenharmony_ci:Architectures: ppc 678762306a36Sopenharmony_ci:Target: vcpu 678862306a36Sopenharmony_ci:Parameters: none 678962306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 679062306a36Sopenharmony_ci 679162306a36Sopenharmony_ciThis capability enables interception of OSI hypercalls that otherwise would 679262306a36Sopenharmony_cibe treated as normal system calls to be injected into the guest. OSI hypercalls 679362306a36Sopenharmony_ciwere invented by Mac-on-Linux to have a standardized communication mechanism 679462306a36Sopenharmony_cibetween the guest and the host. 679562306a36Sopenharmony_ci 679662306a36Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_OSI can occur. 679762306a36Sopenharmony_ci 679862306a36Sopenharmony_ci 679962306a36Sopenharmony_ci6.2 KVM_CAP_PPC_PAPR 680062306a36Sopenharmony_ci-------------------- 680162306a36Sopenharmony_ci 680262306a36Sopenharmony_ci:Architectures: ppc 680362306a36Sopenharmony_ci:Target: vcpu 680462306a36Sopenharmony_ci:Parameters: none 680562306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 680662306a36Sopenharmony_ci 680762306a36Sopenharmony_ciThis capability enables interception of PAPR hypercalls. PAPR hypercalls are 680862306a36Sopenharmony_cidone using the hypercall instruction "sc 1". 680962306a36Sopenharmony_ci 681062306a36Sopenharmony_ciIt also sets the guest privilege level to "supervisor" mode. Usually the guest 681162306a36Sopenharmony_ciruns in "hypervisor" privilege mode with a few missing features. 681262306a36Sopenharmony_ci 681362306a36Sopenharmony_ciIn addition to the above, it changes the semantics of SDR1. In this mode, the 681462306a36Sopenharmony_ciHTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the 681562306a36Sopenharmony_ciHTAB invisible to the guest. 681662306a36Sopenharmony_ci 681762306a36Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_PAPR_HCALL can occur. 681862306a36Sopenharmony_ci 681962306a36Sopenharmony_ci 682062306a36Sopenharmony_ci6.3 KVM_CAP_SW_TLB 682162306a36Sopenharmony_ci------------------ 682262306a36Sopenharmony_ci 682362306a36Sopenharmony_ci:Architectures: ppc 682462306a36Sopenharmony_ci:Target: vcpu 682562306a36Sopenharmony_ci:Parameters: args[0] is the address of a struct kvm_config_tlb 682662306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 682762306a36Sopenharmony_ci 682862306a36Sopenharmony_ci:: 682962306a36Sopenharmony_ci 683062306a36Sopenharmony_ci struct kvm_config_tlb { 683162306a36Sopenharmony_ci __u64 params; 683262306a36Sopenharmony_ci __u64 array; 683362306a36Sopenharmony_ci __u32 mmu_type; 683462306a36Sopenharmony_ci __u32 array_len; 683562306a36Sopenharmony_ci }; 683662306a36Sopenharmony_ci 683762306a36Sopenharmony_ciConfigures the virtual CPU's TLB array, establishing a shared memory area 683862306a36Sopenharmony_cibetween userspace and KVM. The "params" and "array" fields are userspace 683962306a36Sopenharmony_ciaddresses of mmu-type-specific data structures. The "array_len" field is an 684062306a36Sopenharmony_cisafety mechanism, and should be set to the size in bytes of the memory that 684162306a36Sopenharmony_ciuserspace has reserved for the array. It must be at least the size dictated 684262306a36Sopenharmony_ciby "mmu_type" and "params". 684362306a36Sopenharmony_ci 684462306a36Sopenharmony_ciWhile KVM_RUN is active, the shared region is under control of KVM. Its 684562306a36Sopenharmony_cicontents are undefined, and any modification by userspace results in 684662306a36Sopenharmony_ciboundedly undefined behavior. 684762306a36Sopenharmony_ci 684862306a36Sopenharmony_ciOn return from KVM_RUN, the shared region will reflect the current state of 684962306a36Sopenharmony_cithe guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB 685062306a36Sopenharmony_cito tell KVM which entries have been changed, prior to calling KVM_RUN again 685162306a36Sopenharmony_cion this vcpu. 685262306a36Sopenharmony_ci 685362306a36Sopenharmony_ciFor mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV: 685462306a36Sopenharmony_ci 685562306a36Sopenharmony_ci - The "params" field is of type "struct kvm_book3e_206_tlb_params". 685662306a36Sopenharmony_ci - The "array" field points to an array of type "struct 685762306a36Sopenharmony_ci kvm_book3e_206_tlb_entry". 685862306a36Sopenharmony_ci - The array consists of all entries in the first TLB, followed by all 685962306a36Sopenharmony_ci entries in the second TLB. 686062306a36Sopenharmony_ci - Within a TLB, entries are ordered first by increasing set number. Within a 686162306a36Sopenharmony_ci set, entries are ordered by way (increasing ESEL). 686262306a36Sopenharmony_ci - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1) 686362306a36Sopenharmony_ci where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value. 686462306a36Sopenharmony_ci - The tsize field of mas1 shall be set to 4K on TLB0, even though the 686562306a36Sopenharmony_ci hardware ignores this value for TLB0. 686662306a36Sopenharmony_ci 686762306a36Sopenharmony_ci6.4 KVM_CAP_S390_CSS_SUPPORT 686862306a36Sopenharmony_ci---------------------------- 686962306a36Sopenharmony_ci 687062306a36Sopenharmony_ci:Architectures: s390 687162306a36Sopenharmony_ci:Target: vcpu 687262306a36Sopenharmony_ci:Parameters: none 687362306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 687462306a36Sopenharmony_ci 687562306a36Sopenharmony_ciThis capability enables support for handling of channel I/O instructions. 687662306a36Sopenharmony_ci 687762306a36Sopenharmony_ciTEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are 687862306a36Sopenharmony_cihandled in-kernel, while the other I/O instructions are passed to userspace. 687962306a36Sopenharmony_ci 688062306a36Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST 688162306a36Sopenharmony_ciSUBCHANNEL intercepts. 688262306a36Sopenharmony_ci 688362306a36Sopenharmony_ciNote that even though this capability is enabled per-vcpu, the complete 688462306a36Sopenharmony_civirtual machine is affected. 688562306a36Sopenharmony_ci 688662306a36Sopenharmony_ci6.5 KVM_CAP_PPC_EPR 688762306a36Sopenharmony_ci------------------- 688862306a36Sopenharmony_ci 688962306a36Sopenharmony_ci:Architectures: ppc 689062306a36Sopenharmony_ci:Target: vcpu 689162306a36Sopenharmony_ci:Parameters: args[0] defines whether the proxy facility is active 689262306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 689362306a36Sopenharmony_ci 689462306a36Sopenharmony_ciThis capability enables or disables the delivery of interrupts through the 689562306a36Sopenharmony_ciexternal proxy facility. 689662306a36Sopenharmony_ci 689762306a36Sopenharmony_ciWhen enabled (args[0] != 0), every time the guest gets an external interrupt 689862306a36Sopenharmony_cidelivered, it automatically exits into user space with a KVM_EXIT_EPR exit 689962306a36Sopenharmony_cito receive the topmost interrupt vector. 690062306a36Sopenharmony_ci 690162306a36Sopenharmony_ciWhen disabled (args[0] == 0), behavior is as if this facility is unsupported. 690262306a36Sopenharmony_ci 690362306a36Sopenharmony_ciWhen this capability is enabled, KVM_EXIT_EPR can occur. 690462306a36Sopenharmony_ci 690562306a36Sopenharmony_ci6.6 KVM_CAP_IRQ_MPIC 690662306a36Sopenharmony_ci-------------------- 690762306a36Sopenharmony_ci 690862306a36Sopenharmony_ci:Architectures: ppc 690962306a36Sopenharmony_ci:Parameters: args[0] is the MPIC device fd; 691062306a36Sopenharmony_ci args[1] is the MPIC CPU number for this vcpu 691162306a36Sopenharmony_ci 691262306a36Sopenharmony_ciThis capability connects the vcpu to an in-kernel MPIC device. 691362306a36Sopenharmony_ci 691462306a36Sopenharmony_ci6.7 KVM_CAP_IRQ_XICS 691562306a36Sopenharmony_ci-------------------- 691662306a36Sopenharmony_ci 691762306a36Sopenharmony_ci:Architectures: ppc 691862306a36Sopenharmony_ci:Target: vcpu 691962306a36Sopenharmony_ci:Parameters: args[0] is the XICS device fd; 692062306a36Sopenharmony_ci args[1] is the XICS CPU number (server ID) for this vcpu 692162306a36Sopenharmony_ci 692262306a36Sopenharmony_ciThis capability connects the vcpu to an in-kernel XICS device. 692362306a36Sopenharmony_ci 692462306a36Sopenharmony_ci6.8 KVM_CAP_S390_IRQCHIP 692562306a36Sopenharmony_ci------------------------ 692662306a36Sopenharmony_ci 692762306a36Sopenharmony_ci:Architectures: s390 692862306a36Sopenharmony_ci:Target: vm 692962306a36Sopenharmony_ci:Parameters: none 693062306a36Sopenharmony_ci 693162306a36Sopenharmony_ciThis capability enables the in-kernel irqchip for s390. Please refer to 693262306a36Sopenharmony_ci"4.24 KVM_CREATE_IRQCHIP" for details. 693362306a36Sopenharmony_ci 693462306a36Sopenharmony_ci6.9 KVM_CAP_MIPS_FPU 693562306a36Sopenharmony_ci-------------------- 693662306a36Sopenharmony_ci 693762306a36Sopenharmony_ci:Architectures: mips 693862306a36Sopenharmony_ci:Target: vcpu 693962306a36Sopenharmony_ci:Parameters: args[0] is reserved for future use (should be 0). 694062306a36Sopenharmony_ci 694162306a36Sopenharmony_ciThis capability allows the use of the host Floating Point Unit by the guest. It 694262306a36Sopenharmony_ciallows the Config1.FP bit to be set to enable the FPU in the guest. Once this is 694362306a36Sopenharmony_cidone the ``KVM_REG_MIPS_FPR_*`` and ``KVM_REG_MIPS_FCR_*`` registers can be 694462306a36Sopenharmony_ciaccessed (depending on the current guest FPU register mode), and the Status.FR, 694562306a36Sopenharmony_ciConfig5.FRE bits are accessible via the KVM API and also from the guest, 694662306a36Sopenharmony_cidepending on them being supported by the FPU. 694762306a36Sopenharmony_ci 694862306a36Sopenharmony_ci6.10 KVM_CAP_MIPS_MSA 694962306a36Sopenharmony_ci--------------------- 695062306a36Sopenharmony_ci 695162306a36Sopenharmony_ci:Architectures: mips 695262306a36Sopenharmony_ci:Target: vcpu 695362306a36Sopenharmony_ci:Parameters: args[0] is reserved for future use (should be 0). 695462306a36Sopenharmony_ci 695562306a36Sopenharmony_ciThis capability allows the use of the MIPS SIMD Architecture (MSA) by the guest. 695662306a36Sopenharmony_ciIt allows the Config3.MSAP bit to be set to enable the use of MSA by the guest. 695762306a36Sopenharmony_ciOnce this is done the ``KVM_REG_MIPS_VEC_*`` and ``KVM_REG_MIPS_MSA_*`` 695862306a36Sopenharmony_ciregisters can be accessed, and the Config5.MSAEn bit is accessible via the 695962306a36Sopenharmony_ciKVM API and also from the guest. 696062306a36Sopenharmony_ci 696162306a36Sopenharmony_ci6.74 KVM_CAP_SYNC_REGS 696262306a36Sopenharmony_ci---------------------- 696362306a36Sopenharmony_ci 696462306a36Sopenharmony_ci:Architectures: s390, x86 696562306a36Sopenharmony_ci:Target: s390: always enabled, x86: vcpu 696662306a36Sopenharmony_ci:Parameters: none 696762306a36Sopenharmony_ci:Returns: x86: KVM_CHECK_EXTENSION returns a bit-array indicating which register 696862306a36Sopenharmony_ci sets are supported 696962306a36Sopenharmony_ci (bitfields defined in arch/x86/include/uapi/asm/kvm.h). 697062306a36Sopenharmony_ci 697162306a36Sopenharmony_ciAs described above in the kvm_sync_regs struct info in section 5 (kvm_run): 697262306a36Sopenharmony_ciKVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers 697362306a36Sopenharmony_ciwithout having to call SET/GET_*REGS". This reduces overhead by eliminating 697462306a36Sopenharmony_cirepeated ioctl calls for setting and/or getting register values. This is 697562306a36Sopenharmony_ciparticularly important when userspace is making synchronous guest state 697662306a36Sopenharmony_cimodifications, e.g. when emulating and/or intercepting instructions in 697762306a36Sopenharmony_ciuserspace. 697862306a36Sopenharmony_ci 697962306a36Sopenharmony_ciFor s390 specifics, please refer to the source code. 698062306a36Sopenharmony_ci 698162306a36Sopenharmony_ciFor x86: 698262306a36Sopenharmony_ci 698362306a36Sopenharmony_ci- the register sets to be copied out to kvm_run are selectable 698462306a36Sopenharmony_ci by userspace (rather that all sets being copied out for every exit). 698562306a36Sopenharmony_ci- vcpu_events are available in addition to regs and sregs. 698662306a36Sopenharmony_ci 698762306a36Sopenharmony_ciFor x86, the 'kvm_valid_regs' field of struct kvm_run is overloaded to 698862306a36Sopenharmony_cifunction as an input bit-array field set by userspace to indicate the 698962306a36Sopenharmony_cispecific register sets to be copied out on the next exit. 699062306a36Sopenharmony_ci 699162306a36Sopenharmony_ciTo indicate when userspace has modified values that should be copied into 699262306a36Sopenharmony_cithe vCPU, the all architecture bitarray field, 'kvm_dirty_regs' must be set. 699362306a36Sopenharmony_ciThis is done using the same bitflags as for the 'kvm_valid_regs' field. 699462306a36Sopenharmony_ciIf the dirty bit is not set, then the register set values will not be copied 699562306a36Sopenharmony_ciinto the vCPU even if they've been modified. 699662306a36Sopenharmony_ci 699762306a36Sopenharmony_ciUnused bitfields in the bitarrays must be set to zero. 699862306a36Sopenharmony_ci 699962306a36Sopenharmony_ci:: 700062306a36Sopenharmony_ci 700162306a36Sopenharmony_ci struct kvm_sync_regs { 700262306a36Sopenharmony_ci struct kvm_regs regs; 700362306a36Sopenharmony_ci struct kvm_sregs sregs; 700462306a36Sopenharmony_ci struct kvm_vcpu_events events; 700562306a36Sopenharmony_ci }; 700662306a36Sopenharmony_ci 700762306a36Sopenharmony_ci6.75 KVM_CAP_PPC_IRQ_XIVE 700862306a36Sopenharmony_ci------------------------- 700962306a36Sopenharmony_ci 701062306a36Sopenharmony_ci:Architectures: ppc 701162306a36Sopenharmony_ci:Target: vcpu 701262306a36Sopenharmony_ci:Parameters: args[0] is the XIVE device fd; 701362306a36Sopenharmony_ci args[1] is the XIVE CPU number (server ID) for this vcpu 701462306a36Sopenharmony_ci 701562306a36Sopenharmony_ciThis capability connects the vcpu to an in-kernel XIVE device. 701662306a36Sopenharmony_ci 701762306a36Sopenharmony_ci7. Capabilities that can be enabled on VMs 701862306a36Sopenharmony_ci========================================== 701962306a36Sopenharmony_ci 702062306a36Sopenharmony_ciThere are certain capabilities that change the behavior of the virtual 702162306a36Sopenharmony_cimachine when enabled. To enable them, please see section 4.37. Below 702262306a36Sopenharmony_ciyou can find a list of capabilities and what their effect on the VM 702362306a36Sopenharmony_ciis when enabling them. 702462306a36Sopenharmony_ci 702562306a36Sopenharmony_ciThe following information is provided along with the description: 702662306a36Sopenharmony_ci 702762306a36Sopenharmony_ci Architectures: 702862306a36Sopenharmony_ci which instruction set architectures provide this ioctl. 702962306a36Sopenharmony_ci x86 includes both i386 and x86_64. 703062306a36Sopenharmony_ci 703162306a36Sopenharmony_ci Parameters: 703262306a36Sopenharmony_ci what parameters are accepted by the capability. 703362306a36Sopenharmony_ci 703462306a36Sopenharmony_ci Returns: 703562306a36Sopenharmony_ci the return value. General error numbers (EBADF, ENOMEM, EINVAL) 703662306a36Sopenharmony_ci are not detailed, but errors with specific meanings are. 703762306a36Sopenharmony_ci 703862306a36Sopenharmony_ci 703962306a36Sopenharmony_ci7.1 KVM_CAP_PPC_ENABLE_HCALL 704062306a36Sopenharmony_ci---------------------------- 704162306a36Sopenharmony_ci 704262306a36Sopenharmony_ci:Architectures: ppc 704362306a36Sopenharmony_ci:Parameters: args[0] is the sPAPR hcall number; 704462306a36Sopenharmony_ci args[1] is 0 to disable, 1 to enable in-kernel handling 704562306a36Sopenharmony_ci 704662306a36Sopenharmony_ciThis capability controls whether individual sPAPR hypercalls (hcalls) 704762306a36Sopenharmony_ciget handled by the kernel or not. Enabling or disabling in-kernel 704862306a36Sopenharmony_cihandling of an hcall is effective across the VM. On creation, an 704962306a36Sopenharmony_ciinitial set of hcalls are enabled for in-kernel handling, which 705062306a36Sopenharmony_ciconsists of those hcalls for which in-kernel handlers were implemented 705162306a36Sopenharmony_cibefore this capability was implemented. If disabled, the kernel will 705262306a36Sopenharmony_cinot to attempt to handle the hcall, but will always exit to userspace 705362306a36Sopenharmony_cito handle it. Note that it may not make sense to enable some and 705462306a36Sopenharmony_cidisable others of a group of related hcalls, but KVM does not prevent 705562306a36Sopenharmony_ciuserspace from doing that. 705662306a36Sopenharmony_ci 705762306a36Sopenharmony_ciIf the hcall number specified is not one that has an in-kernel 705862306a36Sopenharmony_ciimplementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL 705962306a36Sopenharmony_cierror. 706062306a36Sopenharmony_ci 706162306a36Sopenharmony_ci7.2 KVM_CAP_S390_USER_SIGP 706262306a36Sopenharmony_ci-------------------------- 706362306a36Sopenharmony_ci 706462306a36Sopenharmony_ci:Architectures: s390 706562306a36Sopenharmony_ci:Parameters: none 706662306a36Sopenharmony_ci 706762306a36Sopenharmony_ciThis capability controls which SIGP orders will be handled completely in user 706862306a36Sopenharmony_cispace. With this capability enabled, all fast orders will be handled completely 706962306a36Sopenharmony_ciin the kernel: 707062306a36Sopenharmony_ci 707162306a36Sopenharmony_ci- SENSE 707262306a36Sopenharmony_ci- SENSE RUNNING 707362306a36Sopenharmony_ci- EXTERNAL CALL 707462306a36Sopenharmony_ci- EMERGENCY SIGNAL 707562306a36Sopenharmony_ci- CONDITIONAL EMERGENCY SIGNAL 707662306a36Sopenharmony_ci 707762306a36Sopenharmony_ciAll other orders will be handled completely in user space. 707862306a36Sopenharmony_ci 707962306a36Sopenharmony_ciOnly privileged operation exceptions will be checked for in the kernel (or even 708062306a36Sopenharmony_ciin the hardware prior to interception). If this capability is not enabled, the 708162306a36Sopenharmony_ciold way of handling SIGP orders is used (partially in kernel and user space). 708262306a36Sopenharmony_ci 708362306a36Sopenharmony_ci7.3 KVM_CAP_S390_VECTOR_REGISTERS 708462306a36Sopenharmony_ci--------------------------------- 708562306a36Sopenharmony_ci 708662306a36Sopenharmony_ci:Architectures: s390 708762306a36Sopenharmony_ci:Parameters: none 708862306a36Sopenharmony_ci:Returns: 0 on success, negative value on error 708962306a36Sopenharmony_ci 709062306a36Sopenharmony_ciAllows use of the vector registers introduced with z13 processor, and 709162306a36Sopenharmony_ciprovides for the synchronization between host and user space. Will 709262306a36Sopenharmony_cireturn -EINVAL if the machine does not support vectors. 709362306a36Sopenharmony_ci 709462306a36Sopenharmony_ci7.4 KVM_CAP_S390_USER_STSI 709562306a36Sopenharmony_ci-------------------------- 709662306a36Sopenharmony_ci 709762306a36Sopenharmony_ci:Architectures: s390 709862306a36Sopenharmony_ci:Parameters: none 709962306a36Sopenharmony_ci 710062306a36Sopenharmony_ciThis capability allows post-handlers for the STSI instruction. After 710162306a36Sopenharmony_ciinitial handling in the kernel, KVM exits to user space with 710262306a36Sopenharmony_ciKVM_EXIT_S390_STSI to allow user space to insert further data. 710362306a36Sopenharmony_ci 710462306a36Sopenharmony_ciBefore exiting to userspace, kvm handlers should fill in s390_stsi field of 710562306a36Sopenharmony_civcpu->run:: 710662306a36Sopenharmony_ci 710762306a36Sopenharmony_ci struct { 710862306a36Sopenharmony_ci __u64 addr; 710962306a36Sopenharmony_ci __u8 ar; 711062306a36Sopenharmony_ci __u8 reserved; 711162306a36Sopenharmony_ci __u8 fc; 711262306a36Sopenharmony_ci __u8 sel1; 711362306a36Sopenharmony_ci __u16 sel2; 711462306a36Sopenharmony_ci } s390_stsi; 711562306a36Sopenharmony_ci 711662306a36Sopenharmony_ci @addr - guest address of STSI SYSIB 711762306a36Sopenharmony_ci @fc - function code 711862306a36Sopenharmony_ci @sel1 - selector 1 711962306a36Sopenharmony_ci @sel2 - selector 2 712062306a36Sopenharmony_ci @ar - access register number 712162306a36Sopenharmony_ci 712262306a36Sopenharmony_ciKVM handlers should exit to userspace with rc = -EREMOTE. 712362306a36Sopenharmony_ci 712462306a36Sopenharmony_ci7.5 KVM_CAP_SPLIT_IRQCHIP 712562306a36Sopenharmony_ci------------------------- 712662306a36Sopenharmony_ci 712762306a36Sopenharmony_ci:Architectures: x86 712862306a36Sopenharmony_ci:Parameters: args[0] - number of routes reserved for userspace IOAPICs 712962306a36Sopenharmony_ci:Returns: 0 on success, -1 on error 713062306a36Sopenharmony_ci 713162306a36Sopenharmony_ciCreate a local apic for each processor in the kernel. This can be used 713262306a36Sopenharmony_ciinstead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the 713362306a36Sopenharmony_ciIOAPIC and PIC (and also the PIT, even though this has to be enabled 713462306a36Sopenharmony_ciseparately). 713562306a36Sopenharmony_ci 713662306a36Sopenharmony_ciThis capability also enables in kernel routing of interrupt requests; 713762306a36Sopenharmony_ciwhen KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are 713862306a36Sopenharmony_ciused in the IRQ routing table. The first args[0] MSI routes are reserved 713962306a36Sopenharmony_cifor the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes, 714062306a36Sopenharmony_cia KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace. 714162306a36Sopenharmony_ci 714262306a36Sopenharmony_ciFails if VCPU has already been created, or if the irqchip is already in the 714362306a36Sopenharmony_cikernel (i.e. KVM_CREATE_IRQCHIP has already been called). 714462306a36Sopenharmony_ci 714562306a36Sopenharmony_ci7.6 KVM_CAP_S390_RI 714662306a36Sopenharmony_ci------------------- 714762306a36Sopenharmony_ci 714862306a36Sopenharmony_ci:Architectures: s390 714962306a36Sopenharmony_ci:Parameters: none 715062306a36Sopenharmony_ci 715162306a36Sopenharmony_ciAllows use of runtime-instrumentation introduced with zEC12 processor. 715262306a36Sopenharmony_ciWill return -EINVAL if the machine does not support runtime-instrumentation. 715362306a36Sopenharmony_ciWill return -EBUSY if a VCPU has already been created. 715462306a36Sopenharmony_ci 715562306a36Sopenharmony_ci7.7 KVM_CAP_X2APIC_API 715662306a36Sopenharmony_ci---------------------- 715762306a36Sopenharmony_ci 715862306a36Sopenharmony_ci:Architectures: x86 715962306a36Sopenharmony_ci:Parameters: args[0] - features that should be enabled 716062306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL when args[0] contains invalid features 716162306a36Sopenharmony_ci 716262306a36Sopenharmony_ciValid feature flags in args[0] are:: 716362306a36Sopenharmony_ci 716462306a36Sopenharmony_ci #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) 716562306a36Sopenharmony_ci #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) 716662306a36Sopenharmony_ci 716762306a36Sopenharmony_ciEnabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of 716862306a36Sopenharmony_ciKVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC, 716962306a36Sopenharmony_ciallowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their 717062306a36Sopenharmony_cirespective sections. 717162306a36Sopenharmony_ci 717262306a36Sopenharmony_ciKVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work 717362306a36Sopenharmony_ciin logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff 717462306a36Sopenharmony_cias a broadcast even in x2APIC mode in order to support physical x2APIC 717562306a36Sopenharmony_ciwithout interrupt remapping. This is undesirable in logical mode, 717662306a36Sopenharmony_ciwhere 0xff represents CPUs 0-7 in cluster 0. 717762306a36Sopenharmony_ci 717862306a36Sopenharmony_ci7.8 KVM_CAP_S390_USER_INSTR0 717962306a36Sopenharmony_ci---------------------------- 718062306a36Sopenharmony_ci 718162306a36Sopenharmony_ci:Architectures: s390 718262306a36Sopenharmony_ci:Parameters: none 718362306a36Sopenharmony_ci 718462306a36Sopenharmony_ciWith this capability enabled, all illegal instructions 0x0000 (2 bytes) will 718562306a36Sopenharmony_cibe intercepted and forwarded to user space. User space can use this 718662306a36Sopenharmony_cimechanism e.g. to realize 2-byte software breakpoints. The kernel will 718762306a36Sopenharmony_cinot inject an operating exception for these instructions, user space has 718862306a36Sopenharmony_cito take care of that. 718962306a36Sopenharmony_ci 719062306a36Sopenharmony_ciThis capability can be enabled dynamically even if VCPUs were already 719162306a36Sopenharmony_cicreated and are running. 719262306a36Sopenharmony_ci 719362306a36Sopenharmony_ci7.9 KVM_CAP_S390_GS 719462306a36Sopenharmony_ci------------------- 719562306a36Sopenharmony_ci 719662306a36Sopenharmony_ci:Architectures: s390 719762306a36Sopenharmony_ci:Parameters: none 719862306a36Sopenharmony_ci:Returns: 0 on success; -EINVAL if the machine does not support 719962306a36Sopenharmony_ci guarded storage; -EBUSY if a VCPU has already been created. 720062306a36Sopenharmony_ci 720162306a36Sopenharmony_ciAllows use of guarded storage for the KVM guest. 720262306a36Sopenharmony_ci 720362306a36Sopenharmony_ci7.10 KVM_CAP_S390_AIS 720462306a36Sopenharmony_ci--------------------- 720562306a36Sopenharmony_ci 720662306a36Sopenharmony_ci:Architectures: s390 720762306a36Sopenharmony_ci:Parameters: none 720862306a36Sopenharmony_ci 720962306a36Sopenharmony_ciAllow use of adapter-interruption suppression. 721062306a36Sopenharmony_ci:Returns: 0 on success; -EBUSY if a VCPU has already been created. 721162306a36Sopenharmony_ci 721262306a36Sopenharmony_ci7.11 KVM_CAP_PPC_SMT 721362306a36Sopenharmony_ci-------------------- 721462306a36Sopenharmony_ci 721562306a36Sopenharmony_ci:Architectures: ppc 721662306a36Sopenharmony_ci:Parameters: vsmt_mode, flags 721762306a36Sopenharmony_ci 721862306a36Sopenharmony_ciEnabling this capability on a VM provides userspace with a way to set 721962306a36Sopenharmony_cithe desired virtual SMT mode (i.e. the number of virtual CPUs per 722062306a36Sopenharmony_civirtual core). The virtual SMT mode, vsmt_mode, must be a power of 2 722162306a36Sopenharmony_cibetween 1 and 8. On POWER8, vsmt_mode must also be no greater than 722262306a36Sopenharmony_cithe number of threads per subcore for the host. Currently flags must 722362306a36Sopenharmony_cibe 0. A successful call to enable this capability will result in 722462306a36Sopenharmony_civsmt_mode being returned when the KVM_CAP_PPC_SMT capability is 722562306a36Sopenharmony_cisubsequently queried for the VM. This capability is only supported by 722662306a36Sopenharmony_ciHV KVM, and can only be set before any VCPUs have been created. 722762306a36Sopenharmony_ciThe KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT 722862306a36Sopenharmony_cimodes are available. 722962306a36Sopenharmony_ci 723062306a36Sopenharmony_ci7.12 KVM_CAP_PPC_FWNMI 723162306a36Sopenharmony_ci---------------------- 723262306a36Sopenharmony_ci 723362306a36Sopenharmony_ci:Architectures: ppc 723462306a36Sopenharmony_ci:Parameters: none 723562306a36Sopenharmony_ci 723662306a36Sopenharmony_ciWith this capability a machine check exception in the guest address 723762306a36Sopenharmony_cispace will cause KVM to exit the guest with NMI exit reason. This 723862306a36Sopenharmony_cienables QEMU to build error log and branch to guest kernel registered 723962306a36Sopenharmony_cimachine check handling routine. Without this capability KVM will 724062306a36Sopenharmony_cibranch to guests' 0x200 interrupt vector. 724162306a36Sopenharmony_ci 724262306a36Sopenharmony_ci7.13 KVM_CAP_X86_DISABLE_EXITS 724362306a36Sopenharmony_ci------------------------------ 724462306a36Sopenharmony_ci 724562306a36Sopenharmony_ci:Architectures: x86 724662306a36Sopenharmony_ci:Parameters: args[0] defines which exits are disabled 724762306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL when args[0] contains invalid exits 724862306a36Sopenharmony_ci 724962306a36Sopenharmony_ciValid bits in args[0] are:: 725062306a36Sopenharmony_ci 725162306a36Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) 725262306a36Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 725362306a36Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 725462306a36Sopenharmony_ci #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) 725562306a36Sopenharmony_ci 725662306a36Sopenharmony_ciEnabling this capability on a VM provides userspace with a way to no 725762306a36Sopenharmony_cilonger intercept some instructions for improved latency in some 725862306a36Sopenharmony_ciworkloads, and is suggested when vCPUs are associated to dedicated 725962306a36Sopenharmony_ciphysical CPUs. More bits can be added in the future; userspace can 726062306a36Sopenharmony_cijust pass the KVM_CHECK_EXTENSION result to KVM_ENABLE_CAP to disable 726162306a36Sopenharmony_ciall such vmexits. 726262306a36Sopenharmony_ci 726362306a36Sopenharmony_ciDo not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits. 726462306a36Sopenharmony_ci 726562306a36Sopenharmony_ci7.14 KVM_CAP_S390_HPAGE_1M 726662306a36Sopenharmony_ci-------------------------- 726762306a36Sopenharmony_ci 726862306a36Sopenharmony_ci:Architectures: s390 726962306a36Sopenharmony_ci:Parameters: none 727062306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL if hpage module parameter was not set 727162306a36Sopenharmony_ci or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL 727262306a36Sopenharmony_ci flag set 727362306a36Sopenharmony_ci 727462306a36Sopenharmony_ciWith this capability the KVM support for memory backing with 1m pages 727562306a36Sopenharmony_cithrough hugetlbfs can be enabled for a VM. After the capability is 727662306a36Sopenharmony_cienabled, cmma can't be enabled anymore and pfmfi and the storage key 727762306a36Sopenharmony_ciinterpretation are disabled. If cmma has already been enabled or the 727862306a36Sopenharmony_cihpage module parameter is not set to 1, -EINVAL is returned. 727962306a36Sopenharmony_ci 728062306a36Sopenharmony_ciWhile it is generally possible to create a huge page backed VM without 728162306a36Sopenharmony_cithis capability, the VM will not be able to run. 728262306a36Sopenharmony_ci 728362306a36Sopenharmony_ci7.15 KVM_CAP_MSR_PLATFORM_INFO 728462306a36Sopenharmony_ci------------------------------ 728562306a36Sopenharmony_ci 728662306a36Sopenharmony_ci:Architectures: x86 728762306a36Sopenharmony_ci:Parameters: args[0] whether feature should be enabled or not 728862306a36Sopenharmony_ci 728962306a36Sopenharmony_ciWith this capability, a guest may read the MSR_PLATFORM_INFO MSR. Otherwise, 729062306a36Sopenharmony_cia #GP would be raised when the guest tries to access. Currently, this 729162306a36Sopenharmony_cicapability does not enable write permissions of this MSR for the guest. 729262306a36Sopenharmony_ci 729362306a36Sopenharmony_ci7.16 KVM_CAP_PPC_NESTED_HV 729462306a36Sopenharmony_ci-------------------------- 729562306a36Sopenharmony_ci 729662306a36Sopenharmony_ci:Architectures: ppc 729762306a36Sopenharmony_ci:Parameters: none 729862306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL when the implementation doesn't support 729962306a36Sopenharmony_ci nested-HV virtualization. 730062306a36Sopenharmony_ci 730162306a36Sopenharmony_ciHV-KVM on POWER9 and later systems allows for "nested-HV" 730262306a36Sopenharmony_civirtualization, which provides a way for a guest VM to run guests that 730362306a36Sopenharmony_cican run using the CPU's supervisor mode (privileged non-hypervisor 730462306a36Sopenharmony_cistate). Enabling this capability on a VM depends on the CPU having 730562306a36Sopenharmony_cithe necessary functionality and on the facility being enabled with a 730662306a36Sopenharmony_cikvm-hv module parameter. 730762306a36Sopenharmony_ci 730862306a36Sopenharmony_ci7.17 KVM_CAP_EXCEPTION_PAYLOAD 730962306a36Sopenharmony_ci------------------------------ 731062306a36Sopenharmony_ci 731162306a36Sopenharmony_ci:Architectures: x86 731262306a36Sopenharmony_ci:Parameters: args[0] whether feature should be enabled or not 731362306a36Sopenharmony_ci 731462306a36Sopenharmony_ciWith this capability enabled, CR2 will not be modified prior to the 731562306a36Sopenharmony_ciemulated VM-exit when L1 intercepts a #PF exception that occurs in 731662306a36Sopenharmony_ciL2. Similarly, for kvm-intel only, DR6 will not be modified prior to 731762306a36Sopenharmony_cithe emulated VM-exit when L1 intercepts a #DB exception that occurs in 731862306a36Sopenharmony_ciL2. As a result, when KVM_GET_VCPU_EVENTS reports a pending #PF (or 731962306a36Sopenharmony_ci#DB) exception for L2, exception.has_payload will be set and the 732062306a36Sopenharmony_cifaulting address (or the new DR6 bits*) will be reported in the 732162306a36Sopenharmony_ciexception_payload field. Similarly, when userspace injects a #PF (or 732262306a36Sopenharmony_ci#DB) into L2 using KVM_SET_VCPU_EVENTS, it is expected to set 732362306a36Sopenharmony_ciexception.has_payload and to put the faulting address - or the new DR6 732462306a36Sopenharmony_cibits\ [#]_ - in the exception_payload field. 732562306a36Sopenharmony_ci 732662306a36Sopenharmony_ciThis capability also enables exception.pending in struct 732762306a36Sopenharmony_cikvm_vcpu_events, which allows userspace to distinguish between pending 732862306a36Sopenharmony_ciand injected exceptions. 732962306a36Sopenharmony_ci 733062306a36Sopenharmony_ci 733162306a36Sopenharmony_ci.. [#] For the new DR6 bits, note that bit 16 is set iff the #DB exception 733262306a36Sopenharmony_ci will clear DR6.RTM. 733362306a36Sopenharmony_ci 733462306a36Sopenharmony_ci7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 733562306a36Sopenharmony_ci-------------------------------------- 733662306a36Sopenharmony_ci 733762306a36Sopenharmony_ci:Architectures: x86, arm64, mips 733862306a36Sopenharmony_ci:Parameters: args[0] whether feature should be enabled or not 733962306a36Sopenharmony_ci 734062306a36Sopenharmony_ciValid flags are:: 734162306a36Sopenharmony_ci 734262306a36Sopenharmony_ci #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) 734362306a36Sopenharmony_ci #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) 734462306a36Sopenharmony_ci 734562306a36Sopenharmony_ciWith KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE is set, KVM_GET_DIRTY_LOG will not 734662306a36Sopenharmony_ciautomatically clear and write-protect all pages that are returned as dirty. 734762306a36Sopenharmony_ciRather, userspace will have to do this operation separately using 734862306a36Sopenharmony_ciKVM_CLEAR_DIRTY_LOG. 734962306a36Sopenharmony_ci 735062306a36Sopenharmony_ciAt the cost of a slightly more complicated operation, this provides better 735162306a36Sopenharmony_ciscalability and responsiveness for two reasons. First, 735262306a36Sopenharmony_ciKVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather 735362306a36Sopenharmony_cithan requiring to sync a full memslot; this ensures that KVM does not 735462306a36Sopenharmony_citake spinlocks for an extended period of time. Second, in some cases a 735562306a36Sopenharmony_cilarge amount of time can pass between a call to KVM_GET_DIRTY_LOG and 735662306a36Sopenharmony_ciuserspace actually using the data in the page. Pages can be modified 735762306a36Sopenharmony_ciduring this time, which is inefficient for both the guest and userspace: 735862306a36Sopenharmony_cithe guest will incur a higher penalty due to write protection faults, 735962306a36Sopenharmony_ciwhile userspace can see false reports of dirty pages. Manual reprotection 736062306a36Sopenharmony_cihelps reducing this time, improving guest performance and reducing the 736162306a36Sopenharmony_cinumber of dirty log false positives. 736262306a36Sopenharmony_ci 736362306a36Sopenharmony_ciWith KVM_DIRTY_LOG_INITIALLY_SET set, all the bits of the dirty bitmap 736462306a36Sopenharmony_ciwill be initialized to 1 when created. This also improves performance because 736562306a36Sopenharmony_cidirty logging can be enabled gradually in small chunks on the first call 736662306a36Sopenharmony_cito KVM_CLEAR_DIRTY_LOG. KVM_DIRTY_LOG_INITIALLY_SET depends on 736762306a36Sopenharmony_ciKVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (it is also only available on 736862306a36Sopenharmony_cix86 and arm64 for now). 736962306a36Sopenharmony_ci 737062306a36Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 was previously available under the name 737162306a36Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT, but the implementation had bugs that make 737262306a36Sopenharmony_ciit hard or impossible to use it correctly. The availability of 737362306a36Sopenharmony_ciKVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 signals that those bugs are fixed. 737462306a36Sopenharmony_ciUserspace should not try to use KVM_CAP_MANUAL_DIRTY_LOG_PROTECT. 737562306a36Sopenharmony_ci 737662306a36Sopenharmony_ci7.19 KVM_CAP_PPC_SECURE_GUEST 737762306a36Sopenharmony_ci------------------------------ 737862306a36Sopenharmony_ci 737962306a36Sopenharmony_ci:Architectures: ppc 738062306a36Sopenharmony_ci 738162306a36Sopenharmony_ciThis capability indicates that KVM is running on a host that has 738262306a36Sopenharmony_ciultravisor firmware and thus can support a secure guest. On such a 738362306a36Sopenharmony_cisystem, a guest can ask the ultravisor to make it a secure guest, 738462306a36Sopenharmony_cione whose memory is inaccessible to the host except for pages which 738562306a36Sopenharmony_ciare explicitly requested to be shared with the host. The ultravisor 738662306a36Sopenharmony_cinotifies KVM when a guest requests to become a secure guest, and KVM 738762306a36Sopenharmony_cihas the opportunity to veto the transition. 738862306a36Sopenharmony_ci 738962306a36Sopenharmony_ciIf present, this capability can be enabled for a VM, meaning that KVM 739062306a36Sopenharmony_ciwill allow the transition to secure guest mode. Otherwise KVM will 739162306a36Sopenharmony_civeto the transition. 739262306a36Sopenharmony_ci 739362306a36Sopenharmony_ci7.20 KVM_CAP_HALT_POLL 739462306a36Sopenharmony_ci---------------------- 739562306a36Sopenharmony_ci 739662306a36Sopenharmony_ci:Architectures: all 739762306a36Sopenharmony_ci:Target: VM 739862306a36Sopenharmony_ci:Parameters: args[0] is the maximum poll time in nanoseconds 739962306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 740062306a36Sopenharmony_ci 740162306a36Sopenharmony_ciKVM_CAP_HALT_POLL overrides the kvm.halt_poll_ns module parameter to set the 740262306a36Sopenharmony_cimaximum halt-polling time for all vCPUs in the target VM. This capability can 740362306a36Sopenharmony_cibe invoked at any time and any number of times to dynamically change the 740462306a36Sopenharmony_cimaximum halt-polling time. 740562306a36Sopenharmony_ci 740662306a36Sopenharmony_ciSee Documentation/virt/kvm/halt-polling.rst for more information on halt 740762306a36Sopenharmony_cipolling. 740862306a36Sopenharmony_ci 740962306a36Sopenharmony_ci7.21 KVM_CAP_X86_USER_SPACE_MSR 741062306a36Sopenharmony_ci------------------------------- 741162306a36Sopenharmony_ci 741262306a36Sopenharmony_ci:Architectures: x86 741362306a36Sopenharmony_ci:Target: VM 741462306a36Sopenharmony_ci:Parameters: args[0] contains the mask of KVM_MSR_EXIT_REASON_* events to report 741562306a36Sopenharmony_ci:Returns: 0 on success; -1 on error 741662306a36Sopenharmony_ci 741762306a36Sopenharmony_ciThis capability allows userspace to intercept RDMSR and WRMSR instructions if 741862306a36Sopenharmony_ciaccess to an MSR is denied. By default, KVM injects #GP on denied accesses. 741962306a36Sopenharmony_ci 742062306a36Sopenharmony_ciWhen a guest requests to read or write an MSR, KVM may not implement all MSRs 742162306a36Sopenharmony_cithat are relevant to a respective system. It also does not differentiate by 742262306a36Sopenharmony_ciCPU type. 742362306a36Sopenharmony_ci 742462306a36Sopenharmony_ciTo allow more fine grained control over MSR handling, userspace may enable 742562306a36Sopenharmony_cithis capability. With it enabled, MSR accesses that match the mask specified in 742662306a36Sopenharmony_ciargs[0] and would trigger a #GP inside the guest will instead trigger 742762306a36Sopenharmony_ciKVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR exit notifications. Userspace 742862306a36Sopenharmony_cican then implement model specific MSR handling and/or user notifications 742962306a36Sopenharmony_cito inform a user that an MSR was not emulated/virtualized by KVM. 743062306a36Sopenharmony_ci 743162306a36Sopenharmony_ciThe valid mask flags are: 743262306a36Sopenharmony_ci 743362306a36Sopenharmony_ci============================ =============================================== 743462306a36Sopenharmony_ci KVM_MSR_EXIT_REASON_UNKNOWN intercept accesses to unknown (to KVM) MSRs 743562306a36Sopenharmony_ci KVM_MSR_EXIT_REASON_INVAL intercept accesses that are architecturally 743662306a36Sopenharmony_ci invalid according to the vCPU model and/or mode 743762306a36Sopenharmony_ci KVM_MSR_EXIT_REASON_FILTER intercept accesses that are denied by userspace 743862306a36Sopenharmony_ci via KVM_X86_SET_MSR_FILTER 743962306a36Sopenharmony_ci============================ =============================================== 744062306a36Sopenharmony_ci 744162306a36Sopenharmony_ci7.22 KVM_CAP_X86_BUS_LOCK_EXIT 744262306a36Sopenharmony_ci------------------------------- 744362306a36Sopenharmony_ci 744462306a36Sopenharmony_ci:Architectures: x86 744562306a36Sopenharmony_ci:Target: VM 744662306a36Sopenharmony_ci:Parameters: args[0] defines the policy used when bus locks detected in guest 744762306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL when args[0] contains invalid bits 744862306a36Sopenharmony_ci 744962306a36Sopenharmony_ciValid bits in args[0] are:: 745062306a36Sopenharmony_ci 745162306a36Sopenharmony_ci #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0) 745262306a36Sopenharmony_ci #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1) 745362306a36Sopenharmony_ci 745462306a36Sopenharmony_ciEnabling this capability on a VM provides userspace with a way to select 745562306a36Sopenharmony_cia policy to handle the bus locks detected in guest. Userspace can obtain 745662306a36Sopenharmony_cithe supported modes from the result of KVM_CHECK_EXTENSION and define it 745762306a36Sopenharmony_cithrough the KVM_ENABLE_CAP. 745862306a36Sopenharmony_ci 745962306a36Sopenharmony_ciKVM_BUS_LOCK_DETECTION_OFF and KVM_BUS_LOCK_DETECTION_EXIT are supported 746062306a36Sopenharmony_cicurrently and mutually exclusive with each other. More bits can be added in 746162306a36Sopenharmony_cithe future. 746262306a36Sopenharmony_ci 746362306a36Sopenharmony_ciWith KVM_BUS_LOCK_DETECTION_OFF set, bus locks in guest will not cause vm exits 746462306a36Sopenharmony_ciso that no additional actions are needed. This is the default mode. 746562306a36Sopenharmony_ci 746662306a36Sopenharmony_ciWith KVM_BUS_LOCK_DETECTION_EXIT set, vm exits happen when bus lock detected 746762306a36Sopenharmony_ciin VM. KVM just exits to userspace when handling them. Userspace can enforce 746862306a36Sopenharmony_ciits own throttling or other policy based mitigations. 746962306a36Sopenharmony_ci 747062306a36Sopenharmony_ciThis capability is aimed to address the thread that VM can exploit bus locks to 747162306a36Sopenharmony_cidegree the performance of the whole system. Once the userspace enable this 747262306a36Sopenharmony_cicapability and select the KVM_BUS_LOCK_DETECTION_EXIT mode, KVM will set the 747362306a36Sopenharmony_ciKVM_RUN_BUS_LOCK flag in vcpu-run->flags field and exit to userspace. Concerning 747462306a36Sopenharmony_cithe bus lock vm exit can be preempted by a higher priority VM exit, the exit 747562306a36Sopenharmony_cinotifications to userspace can be KVM_EXIT_BUS_LOCK or other reasons. 747662306a36Sopenharmony_ciKVM_RUN_BUS_LOCK flag is used to distinguish between them. 747762306a36Sopenharmony_ci 747862306a36Sopenharmony_ci7.23 KVM_CAP_PPC_DAWR1 747962306a36Sopenharmony_ci---------------------- 748062306a36Sopenharmony_ci 748162306a36Sopenharmony_ci:Architectures: ppc 748262306a36Sopenharmony_ci:Parameters: none 748362306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL when CPU doesn't support 2nd DAWR 748462306a36Sopenharmony_ci 748562306a36Sopenharmony_ciThis capability can be used to check / enable 2nd DAWR feature provided 748662306a36Sopenharmony_ciby POWER10 processor. 748762306a36Sopenharmony_ci 748862306a36Sopenharmony_ci 748962306a36Sopenharmony_ci7.24 KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 749062306a36Sopenharmony_ci------------------------------------- 749162306a36Sopenharmony_ci 749262306a36Sopenharmony_ciArchitectures: x86 SEV enabled 749362306a36Sopenharmony_ciType: vm 749462306a36Sopenharmony_ciParameters: args[0] is the fd of the source vm 749562306a36Sopenharmony_ciReturns: 0 on success; ENOTTY on error 749662306a36Sopenharmony_ci 749762306a36Sopenharmony_ciThis capability enables userspace to copy encryption context from the vm 749862306a36Sopenharmony_ciindicated by the fd to the vm this is called on. 749962306a36Sopenharmony_ci 750062306a36Sopenharmony_ciThis is intended to support in-guest workloads scheduled by the host. This 750162306a36Sopenharmony_ciallows the in-guest workload to maintain its own NPTs and keeps the two vms 750262306a36Sopenharmony_cifrom accidentally clobbering each other with interrupts and the like (separate 750362306a36Sopenharmony_ciAPIC/MSRs/etc). 750462306a36Sopenharmony_ci 750562306a36Sopenharmony_ci7.25 KVM_CAP_SGX_ATTRIBUTE 750662306a36Sopenharmony_ci-------------------------- 750762306a36Sopenharmony_ci 750862306a36Sopenharmony_ci:Architectures: x86 750962306a36Sopenharmony_ci:Target: VM 751062306a36Sopenharmony_ci:Parameters: args[0] is a file handle of a SGX attribute file in securityfs 751162306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL if the file handle is invalid or if a requested 751262306a36Sopenharmony_ci attribute is not supported by KVM. 751362306a36Sopenharmony_ci 751462306a36Sopenharmony_ciKVM_CAP_SGX_ATTRIBUTE enables a userspace VMM to grant a VM access to one or 751562306a36Sopenharmony_cimore privileged enclave attributes. args[0] must hold a file handle to a valid 751662306a36Sopenharmony_ciSGX attribute file corresponding to an attribute that is supported/restricted 751762306a36Sopenharmony_ciby KVM (currently only PROVISIONKEY). 751862306a36Sopenharmony_ci 751962306a36Sopenharmony_ciThe SGX subsystem restricts access to a subset of enclave attributes to provide 752062306a36Sopenharmony_ciadditional security for an uncompromised kernel, e.g. use of the PROVISIONKEY 752162306a36Sopenharmony_ciis restricted to deter malware from using the PROVISIONKEY to obtain a stable 752262306a36Sopenharmony_cisystem fingerprint. To prevent userspace from circumventing such restrictions 752362306a36Sopenharmony_ciby running an enclave in a VM, KVM prevents access to privileged attributes by 752462306a36Sopenharmony_cidefault. 752562306a36Sopenharmony_ci 752662306a36Sopenharmony_ciSee Documentation/arch/x86/sgx.rst for more details. 752762306a36Sopenharmony_ci 752862306a36Sopenharmony_ci7.26 KVM_CAP_PPC_RPT_INVALIDATE 752962306a36Sopenharmony_ci------------------------------- 753062306a36Sopenharmony_ci 753162306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_RPT_INVALIDATE 753262306a36Sopenharmony_ci:Architectures: ppc 753362306a36Sopenharmony_ci:Type: vm 753462306a36Sopenharmony_ci 753562306a36Sopenharmony_ciThis capability indicates that the kernel is capable of handling 753662306a36Sopenharmony_ciH_RPT_INVALIDATE hcall. 753762306a36Sopenharmony_ci 753862306a36Sopenharmony_ciIn order to enable the use of H_RPT_INVALIDATE in the guest, 753962306a36Sopenharmony_ciuser space might have to advertise it for the guest. For example, 754062306a36Sopenharmony_ciIBM pSeries (sPAPR) guest starts using it if "hcall-rpt-invalidate" is 754162306a36Sopenharmony_cipresent in the "ibm,hypertas-functions" device-tree property. 754262306a36Sopenharmony_ci 754362306a36Sopenharmony_ciThis capability is enabled for hypervisors on platforms like POWER9 754462306a36Sopenharmony_cithat support radix MMU. 754562306a36Sopenharmony_ci 754662306a36Sopenharmony_ci7.27 KVM_CAP_EXIT_ON_EMULATION_FAILURE 754762306a36Sopenharmony_ci-------------------------------------- 754862306a36Sopenharmony_ci 754962306a36Sopenharmony_ci:Architectures: x86 755062306a36Sopenharmony_ci:Parameters: args[0] whether the feature should be enabled or not 755162306a36Sopenharmony_ci 755262306a36Sopenharmony_ciWhen this capability is enabled, an emulation failure will result in an exit 755362306a36Sopenharmony_cito userspace with KVM_INTERNAL_ERROR (except when the emulator was invoked 755462306a36Sopenharmony_cito handle a VMware backdoor instruction). Furthermore, KVM will now provide up 755562306a36Sopenharmony_cito 15 instruction bytes for any exit to userspace resulting from an emulation 755662306a36Sopenharmony_cifailure. When these exits to userspace occur use the emulation_failure struct 755762306a36Sopenharmony_ciinstead of the internal struct. They both have the same layout, but the 755862306a36Sopenharmony_ciemulation_failure struct matches the content better. It also explicitly 755962306a36Sopenharmony_cidefines the 'flags' field which is used to describe the fields in the struct 756062306a36Sopenharmony_cithat are valid (ie: if KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES is 756162306a36Sopenharmony_ciset in the 'flags' field then both 'insn_size' and 'insn_bytes' have valid data 756262306a36Sopenharmony_ciin them.) 756362306a36Sopenharmony_ci 756462306a36Sopenharmony_ci7.28 KVM_CAP_ARM_MTE 756562306a36Sopenharmony_ci-------------------- 756662306a36Sopenharmony_ci 756762306a36Sopenharmony_ci:Architectures: arm64 756862306a36Sopenharmony_ci:Parameters: none 756962306a36Sopenharmony_ci 757062306a36Sopenharmony_ciThis capability indicates that KVM (and the hardware) supports exposing the 757162306a36Sopenharmony_ciMemory Tagging Extensions (MTE) to the guest. It must also be enabled by the 757262306a36Sopenharmony_ciVMM before creating any VCPUs to allow the guest access. Note that MTE is only 757362306a36Sopenharmony_ciavailable to a guest running in AArch64 mode and enabling this capability will 757462306a36Sopenharmony_cicause attempts to create AArch32 VCPUs to fail. 757562306a36Sopenharmony_ci 757662306a36Sopenharmony_ciWhen enabled the guest is able to access tags associated with any memory given 757762306a36Sopenharmony_cito the guest. KVM will ensure that the tags are maintained during swap or 757862306a36Sopenharmony_cihibernation of the host; however the VMM needs to manually save/restore the 757962306a36Sopenharmony_citags as appropriate if the VM is migrated. 758062306a36Sopenharmony_ci 758162306a36Sopenharmony_ciWhen this capability is enabled all memory in memslots must be mapped as 758262306a36Sopenharmony_ci``MAP_ANONYMOUS`` or with a RAM-based file mapping (``tmpfs``, ``memfd``), 758362306a36Sopenharmony_ciattempts to create a memslot with an invalid mmap will result in an 758462306a36Sopenharmony_ci-EINVAL return. 758562306a36Sopenharmony_ci 758662306a36Sopenharmony_ciWhen enabled the VMM may make use of the ``KVM_ARM_MTE_COPY_TAGS`` ioctl to 758762306a36Sopenharmony_ciperform a bulk copy of tags to/from the guest. 758862306a36Sopenharmony_ci 758962306a36Sopenharmony_ci7.29 KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 759062306a36Sopenharmony_ci------------------------------------- 759162306a36Sopenharmony_ci 759262306a36Sopenharmony_ciArchitectures: x86 SEV enabled 759362306a36Sopenharmony_ciType: vm 759462306a36Sopenharmony_ciParameters: args[0] is the fd of the source vm 759562306a36Sopenharmony_ciReturns: 0 on success 759662306a36Sopenharmony_ci 759762306a36Sopenharmony_ciThis capability enables userspace to migrate the encryption context from the VM 759862306a36Sopenharmony_ciindicated by the fd to the VM this is called on. 759962306a36Sopenharmony_ci 760062306a36Sopenharmony_ciThis is intended to support intra-host migration of VMs between userspace VMMs, 760162306a36Sopenharmony_ciupgrading the VMM process without interrupting the guest. 760262306a36Sopenharmony_ci 760362306a36Sopenharmony_ci7.30 KVM_CAP_PPC_AIL_MODE_3 760462306a36Sopenharmony_ci------------------------------- 760562306a36Sopenharmony_ci 760662306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_AIL_MODE_3 760762306a36Sopenharmony_ci:Architectures: ppc 760862306a36Sopenharmony_ci:Type: vm 760962306a36Sopenharmony_ci 761062306a36Sopenharmony_ciThis capability indicates that the kernel supports the mode 3 setting for the 761162306a36Sopenharmony_ci"Address Translation Mode on Interrupt" aka "Alternate Interrupt Location" 761262306a36Sopenharmony_ciresource that is controlled with the H_SET_MODE hypercall. 761362306a36Sopenharmony_ci 761462306a36Sopenharmony_ciThis capability allows a guest kernel to use a better-performance mode for 761562306a36Sopenharmony_cihandling interrupts and system calls. 761662306a36Sopenharmony_ci 761762306a36Sopenharmony_ci7.31 KVM_CAP_DISABLE_QUIRKS2 761862306a36Sopenharmony_ci---------------------------- 761962306a36Sopenharmony_ci 762062306a36Sopenharmony_ci:Capability: KVM_CAP_DISABLE_QUIRKS2 762162306a36Sopenharmony_ci:Parameters: args[0] - set of KVM quirks to disable 762262306a36Sopenharmony_ci:Architectures: x86 762362306a36Sopenharmony_ci:Type: vm 762462306a36Sopenharmony_ci 762562306a36Sopenharmony_ciThis capability, if enabled, will cause KVM to disable some behavior 762662306a36Sopenharmony_ciquirks. 762762306a36Sopenharmony_ci 762862306a36Sopenharmony_ciCalling KVM_CHECK_EXTENSION for this capability returns a bitmask of 762962306a36Sopenharmony_ciquirks that can be disabled in KVM. 763062306a36Sopenharmony_ci 763162306a36Sopenharmony_ciThe argument to KVM_ENABLE_CAP for this capability is a bitmask of 763262306a36Sopenharmony_ciquirks to disable, and must be a subset of the bitmask returned by 763362306a36Sopenharmony_ciKVM_CHECK_EXTENSION. 763462306a36Sopenharmony_ci 763562306a36Sopenharmony_ciThe valid bits in cap.args[0] are: 763662306a36Sopenharmony_ci 763762306a36Sopenharmony_ci=================================== ============================================ 763862306a36Sopenharmony_ci KVM_X86_QUIRK_LINT0_REENABLED By default, the reset value for the LVT 763962306a36Sopenharmony_ci LINT0 register is 0x700 (APIC_MODE_EXTINT). 764062306a36Sopenharmony_ci When this quirk is disabled, the reset value 764162306a36Sopenharmony_ci is 0x10000 (APIC_LVT_MASKED). 764262306a36Sopenharmony_ci 764362306a36Sopenharmony_ci KVM_X86_QUIRK_CD_NW_CLEARED By default, KVM clears CR0.CD and CR0.NW. 764462306a36Sopenharmony_ci When this quirk is disabled, KVM does not 764562306a36Sopenharmony_ci change the value of CR0.CD and CR0.NW. 764662306a36Sopenharmony_ci 764762306a36Sopenharmony_ci KVM_X86_QUIRK_LAPIC_MMIO_HOLE By default, the MMIO LAPIC interface is 764862306a36Sopenharmony_ci available even when configured for x2APIC 764962306a36Sopenharmony_ci mode. When this quirk is disabled, KVM 765062306a36Sopenharmony_ci disables the MMIO LAPIC interface if the 765162306a36Sopenharmony_ci LAPIC is in x2APIC mode. 765262306a36Sopenharmony_ci 765362306a36Sopenharmony_ci KVM_X86_QUIRK_OUT_7E_INC_RIP By default, KVM pre-increments %rip before 765462306a36Sopenharmony_ci exiting to userspace for an OUT instruction 765562306a36Sopenharmony_ci to port 0x7e. When this quirk is disabled, 765662306a36Sopenharmony_ci KVM does not pre-increment %rip before 765762306a36Sopenharmony_ci exiting to userspace. 765862306a36Sopenharmony_ci 765962306a36Sopenharmony_ci KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT When this quirk is disabled, KVM sets 766062306a36Sopenharmony_ci CPUID.01H:ECX[bit 3] (MONITOR/MWAIT) if 766162306a36Sopenharmony_ci IA32_MISC_ENABLE[bit 18] (MWAIT) is set. 766262306a36Sopenharmony_ci Additionally, when this quirk is disabled, 766362306a36Sopenharmony_ci KVM clears CPUID.01H:ECX[bit 3] if 766462306a36Sopenharmony_ci IA32_MISC_ENABLE[bit 18] is cleared. 766562306a36Sopenharmony_ci 766662306a36Sopenharmony_ci KVM_X86_QUIRK_FIX_HYPERCALL_INSN By default, KVM rewrites guest 766762306a36Sopenharmony_ci VMMCALL/VMCALL instructions to match the 766862306a36Sopenharmony_ci vendor's hypercall instruction for the 766962306a36Sopenharmony_ci system. When this quirk is disabled, KVM 767062306a36Sopenharmony_ci will no longer rewrite invalid guest 767162306a36Sopenharmony_ci hypercall instructions. Executing the 767262306a36Sopenharmony_ci incorrect hypercall instruction will 767362306a36Sopenharmony_ci generate a #UD within the guest. 767462306a36Sopenharmony_ci 767562306a36Sopenharmony_ciKVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS By default, KVM emulates MONITOR/MWAIT (if 767662306a36Sopenharmony_ci they are intercepted) as NOPs regardless of 767762306a36Sopenharmony_ci whether or not MONITOR/MWAIT are supported 767862306a36Sopenharmony_ci according to guest CPUID. When this quirk 767962306a36Sopenharmony_ci is disabled and KVM_X86_DISABLE_EXITS_MWAIT 768062306a36Sopenharmony_ci is not set (MONITOR/MWAIT are intercepted), 768162306a36Sopenharmony_ci KVM will inject a #UD on MONITOR/MWAIT if 768262306a36Sopenharmony_ci they're unsupported per guest CPUID. Note, 768362306a36Sopenharmony_ci KVM will modify MONITOR/MWAIT support in 768462306a36Sopenharmony_ci guest CPUID on writes to MISC_ENABLE if 768562306a36Sopenharmony_ci KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT is 768662306a36Sopenharmony_ci disabled. 768762306a36Sopenharmony_ci=================================== ============================================ 768862306a36Sopenharmony_ci 768962306a36Sopenharmony_ci7.32 KVM_CAP_MAX_VCPU_ID 769062306a36Sopenharmony_ci------------------------ 769162306a36Sopenharmony_ci 769262306a36Sopenharmony_ci:Architectures: x86 769362306a36Sopenharmony_ci:Target: VM 769462306a36Sopenharmony_ci:Parameters: args[0] - maximum APIC ID value set for current VM 769562306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL if args[0] is beyond KVM_MAX_VCPU_IDS 769662306a36Sopenharmony_ci supported in KVM or if it has been set. 769762306a36Sopenharmony_ci 769862306a36Sopenharmony_ciThis capability allows userspace to specify maximum possible APIC ID 769962306a36Sopenharmony_ciassigned for current VM session prior to the creation of vCPUs, saving 770062306a36Sopenharmony_cimemory for data structures indexed by the APIC ID. Userspace is able 770162306a36Sopenharmony_cito calculate the limit to APIC ID values from designated 770262306a36Sopenharmony_ciCPU topology. 770362306a36Sopenharmony_ci 770462306a36Sopenharmony_ciThe value can be changed only until KVM_ENABLE_CAP is set to a nonzero 770562306a36Sopenharmony_civalue or until a vCPU is created. Upon creation of the first vCPU, 770662306a36Sopenharmony_ciif the value was set to zero or KVM_ENABLE_CAP was not invoked, KVM 770762306a36Sopenharmony_ciuses the return value of KVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPU_ID) as 770862306a36Sopenharmony_cithe maximum APIC ID. 770962306a36Sopenharmony_ci 771062306a36Sopenharmony_ci7.33 KVM_CAP_X86_NOTIFY_VMEXIT 771162306a36Sopenharmony_ci------------------------------ 771262306a36Sopenharmony_ci 771362306a36Sopenharmony_ci:Architectures: x86 771462306a36Sopenharmony_ci:Target: VM 771562306a36Sopenharmony_ci:Parameters: args[0] is the value of notify window as well as some flags 771662306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL if args[0] contains invalid flags or notify 771762306a36Sopenharmony_ci VM exit is unsupported. 771862306a36Sopenharmony_ci 771962306a36Sopenharmony_ciBits 63:32 of args[0] are used for notify window. 772062306a36Sopenharmony_ciBits 31:0 of args[0] are for some flags. Valid bits are:: 772162306a36Sopenharmony_ci 772262306a36Sopenharmony_ci #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1 << 0) 772362306a36Sopenharmony_ci #define KVM_X86_NOTIFY_VMEXIT_USER (1 << 1) 772462306a36Sopenharmony_ci 772562306a36Sopenharmony_ciThis capability allows userspace to configure the notify VM exit on/off 772662306a36Sopenharmony_ciin per-VM scope during VM creation. Notify VM exit is disabled by default. 772762306a36Sopenharmony_ciWhen userspace sets KVM_X86_NOTIFY_VMEXIT_ENABLED bit in args[0], VMM will 772862306a36Sopenharmony_cienable this feature with the notify window provided, which will generate 772962306a36Sopenharmony_cia VM exit if no event window occurs in VM non-root mode for a specified of 773062306a36Sopenharmony_citime (notify window). 773162306a36Sopenharmony_ci 773262306a36Sopenharmony_ciIf KVM_X86_NOTIFY_VMEXIT_USER is set in args[0], upon notify VM exits happen, 773362306a36Sopenharmony_ciKVM would exit to userspace for handling. 773462306a36Sopenharmony_ci 773562306a36Sopenharmony_ciThis capability is aimed to mitigate the threat that malicious VMs can 773662306a36Sopenharmony_cicause CPU stuck (due to event windows don't open up) and make the CPU 773762306a36Sopenharmony_ciunavailable to host or other VMs. 773862306a36Sopenharmony_ci 773962306a36Sopenharmony_ci8. Other capabilities. 774062306a36Sopenharmony_ci====================== 774162306a36Sopenharmony_ci 774262306a36Sopenharmony_ciThis section lists capabilities that give information about other 774362306a36Sopenharmony_cifeatures of the KVM implementation. 774462306a36Sopenharmony_ci 774562306a36Sopenharmony_ci8.1 KVM_CAP_PPC_HWRNG 774662306a36Sopenharmony_ci--------------------- 774762306a36Sopenharmony_ci 774862306a36Sopenharmony_ci:Architectures: ppc 774962306a36Sopenharmony_ci 775062306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 775162306a36Sopenharmony_ciavailable, means that the kernel has an implementation of the 775262306a36Sopenharmony_ciH_RANDOM hypercall backed by a hardware random-number generator. 775362306a36Sopenharmony_ciIf present, the kernel H_RANDOM handler can be enabled for guest use 775462306a36Sopenharmony_ciwith the KVM_CAP_PPC_ENABLE_HCALL capability. 775562306a36Sopenharmony_ci 775662306a36Sopenharmony_ci8.2 KVM_CAP_HYPERV_SYNIC 775762306a36Sopenharmony_ci------------------------ 775862306a36Sopenharmony_ci 775962306a36Sopenharmony_ci:Architectures: x86 776062306a36Sopenharmony_ci 776162306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 776262306a36Sopenharmony_ciavailable, means that the kernel has an implementation of the 776362306a36Sopenharmony_ciHyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is 776462306a36Sopenharmony_ciused to support Windows Hyper-V based guest paravirt drivers(VMBus). 776562306a36Sopenharmony_ci 776662306a36Sopenharmony_ciIn order to use SynIC, it has to be activated by setting this 776762306a36Sopenharmony_cicapability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this 776862306a36Sopenharmony_ciwill disable the use of APIC hardware virtualization even if supported 776962306a36Sopenharmony_ciby the CPU, as it's incompatible with SynIC auto-EOI behavior. 777062306a36Sopenharmony_ci 777162306a36Sopenharmony_ci8.3 KVM_CAP_PPC_RADIX_MMU 777262306a36Sopenharmony_ci------------------------- 777362306a36Sopenharmony_ci 777462306a36Sopenharmony_ci:Architectures: ppc 777562306a36Sopenharmony_ci 777662306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 777762306a36Sopenharmony_ciavailable, means that the kernel can support guests using the 777862306a36Sopenharmony_ciradix MMU defined in Power ISA V3.00 (as implemented in the POWER9 777962306a36Sopenharmony_ciprocessor). 778062306a36Sopenharmony_ci 778162306a36Sopenharmony_ci8.4 KVM_CAP_PPC_HASH_MMU_V3 778262306a36Sopenharmony_ci--------------------------- 778362306a36Sopenharmony_ci 778462306a36Sopenharmony_ci:Architectures: ppc 778562306a36Sopenharmony_ci 778662306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is 778762306a36Sopenharmony_ciavailable, means that the kernel can support guests using the 778862306a36Sopenharmony_cihashed page table MMU defined in Power ISA V3.00 (as implemented in 778962306a36Sopenharmony_cithe POWER9 processor), including in-memory segment tables. 779062306a36Sopenharmony_ci 779162306a36Sopenharmony_ci8.5 KVM_CAP_MIPS_VZ 779262306a36Sopenharmony_ci------------------- 779362306a36Sopenharmony_ci 779462306a36Sopenharmony_ci:Architectures: mips 779562306a36Sopenharmony_ci 779662306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that 779762306a36Sopenharmony_ciit is available, means that full hardware assisted virtualization capabilities 779862306a36Sopenharmony_ciof the hardware are available for use through KVM. An appropriate 779962306a36Sopenharmony_ciKVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which 780062306a36Sopenharmony_ciutilises it. 780162306a36Sopenharmony_ci 780262306a36Sopenharmony_ciIf KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is 780362306a36Sopenharmony_ciavailable, it means that the VM is using full hardware assisted virtualization 780462306a36Sopenharmony_cicapabilities of the hardware. This is useful to check after creating a VM with 780562306a36Sopenharmony_ciKVM_VM_MIPS_DEFAULT. 780662306a36Sopenharmony_ci 780762306a36Sopenharmony_ciThe value returned by KVM_CHECK_EXTENSION should be compared against known 780862306a36Sopenharmony_civalues (see below). All other values are reserved. This is to allow for the 780962306a36Sopenharmony_cipossibility of other hardware assisted virtualization implementations which 781062306a36Sopenharmony_cimay be incompatible with the MIPS VZ ASE. 781162306a36Sopenharmony_ci 781262306a36Sopenharmony_ci== ========================================================================== 781362306a36Sopenharmony_ci 0 The trap & emulate implementation is in use to run guest code in user 781462306a36Sopenharmony_ci mode. Guest virtual memory segments are rearranged to fit the guest in the 781562306a36Sopenharmony_ci user mode address space. 781662306a36Sopenharmony_ci 781762306a36Sopenharmony_ci 1 The MIPS VZ ASE is in use, providing full hardware assisted 781862306a36Sopenharmony_ci virtualization, including standard guest virtual memory segments. 781962306a36Sopenharmony_ci== ========================================================================== 782062306a36Sopenharmony_ci 782162306a36Sopenharmony_ci8.6 KVM_CAP_MIPS_TE 782262306a36Sopenharmony_ci------------------- 782362306a36Sopenharmony_ci 782462306a36Sopenharmony_ci:Architectures: mips 782562306a36Sopenharmony_ci 782662306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that 782762306a36Sopenharmony_ciit is available, means that the trap & emulate implementation is available to 782862306a36Sopenharmony_cirun guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware 782962306a36Sopenharmony_ciassisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed 783062306a36Sopenharmony_cito KVM_CREATE_VM to create a VM which utilises it. 783162306a36Sopenharmony_ci 783262306a36Sopenharmony_ciIf KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is 783362306a36Sopenharmony_ciavailable, it means that the VM is using trap & emulate. 783462306a36Sopenharmony_ci 783562306a36Sopenharmony_ci8.7 KVM_CAP_MIPS_64BIT 783662306a36Sopenharmony_ci---------------------- 783762306a36Sopenharmony_ci 783862306a36Sopenharmony_ci:Architectures: mips 783962306a36Sopenharmony_ci 784062306a36Sopenharmony_ciThis capability indicates the supported architecture type of the guest, i.e. the 784162306a36Sopenharmony_cisupported register and address width. 784262306a36Sopenharmony_ci 784362306a36Sopenharmony_ciThe values returned when this capability is checked by KVM_CHECK_EXTENSION on a 784462306a36Sopenharmony_cikvm VM handle correspond roughly to the CP0_Config.AT register field, and should 784562306a36Sopenharmony_cibe checked specifically against known values (see below). All other values are 784662306a36Sopenharmony_cireserved. 784762306a36Sopenharmony_ci 784862306a36Sopenharmony_ci== ======================================================================== 784962306a36Sopenharmony_ci 0 MIPS32 or microMIPS32. 785062306a36Sopenharmony_ci Both registers and addresses are 32-bits wide. 785162306a36Sopenharmony_ci It will only be possible to run 32-bit guest code. 785262306a36Sopenharmony_ci 785362306a36Sopenharmony_ci 1 MIPS64 or microMIPS64 with access only to 32-bit compatibility segments. 785462306a36Sopenharmony_ci Registers are 64-bits wide, but addresses are 32-bits wide. 785562306a36Sopenharmony_ci 64-bit guest code may run but cannot access MIPS64 memory segments. 785662306a36Sopenharmony_ci It will also be possible to run 32-bit guest code. 785762306a36Sopenharmony_ci 785862306a36Sopenharmony_ci 2 MIPS64 or microMIPS64 with access to all address segments. 785962306a36Sopenharmony_ci Both registers and addresses are 64-bits wide. 786062306a36Sopenharmony_ci It will be possible to run 64-bit or 32-bit guest code. 786162306a36Sopenharmony_ci== ======================================================================== 786262306a36Sopenharmony_ci 786362306a36Sopenharmony_ci8.9 KVM_CAP_ARM_USER_IRQ 786462306a36Sopenharmony_ci------------------------ 786562306a36Sopenharmony_ci 786662306a36Sopenharmony_ci:Architectures: arm64 786762306a36Sopenharmony_ci 786862306a36Sopenharmony_ciThis capability, if KVM_CHECK_EXTENSION indicates that it is available, means 786962306a36Sopenharmony_cithat if userspace creates a VM without an in-kernel interrupt controller, it 787062306a36Sopenharmony_ciwill be notified of changes to the output level of in-kernel emulated devices, 787162306a36Sopenharmony_ciwhich can generate virtual interrupts, presented to the VM. 787262306a36Sopenharmony_ciFor such VMs, on every return to userspace, the kernel 787362306a36Sopenharmony_ciupdates the vcpu's run->s.regs.device_irq_level field to represent the actual 787462306a36Sopenharmony_cioutput level of the device. 787562306a36Sopenharmony_ci 787662306a36Sopenharmony_ciWhenever kvm detects a change in the device output level, kvm guarantees at 787762306a36Sopenharmony_cileast one return to userspace before running the VM. This exit could either 787862306a36Sopenharmony_cibe a KVM_EXIT_INTR or any other exit event, like KVM_EXIT_MMIO. This way, 787962306a36Sopenharmony_ciuserspace can always sample the device output level and re-compute the state of 788062306a36Sopenharmony_cithe userspace interrupt controller. Userspace should always check the state 788162306a36Sopenharmony_ciof run->s.regs.device_irq_level on every kvm exit. 788262306a36Sopenharmony_ciThe value in run->s.regs.device_irq_level can represent both level and edge 788362306a36Sopenharmony_citriggered interrupt signals, depending on the device. Edge triggered interrupt 788462306a36Sopenharmony_cisignals will exit to userspace with the bit in run->s.regs.device_irq_level 788562306a36Sopenharmony_ciset exactly once per edge signal. 788662306a36Sopenharmony_ci 788762306a36Sopenharmony_ciThe field run->s.regs.device_irq_level is available independent of 788862306a36Sopenharmony_cirun->kvm_valid_regs or run->kvm_dirty_regs bits. 788962306a36Sopenharmony_ci 789062306a36Sopenharmony_ciIf KVM_CAP_ARM_USER_IRQ is supported, the KVM_CHECK_EXTENSION ioctl returns a 789162306a36Sopenharmony_cinumber larger than 0 indicating the version of this capability is implemented 789262306a36Sopenharmony_ciand thereby which bits in run->s.regs.device_irq_level can signal values. 789362306a36Sopenharmony_ci 789462306a36Sopenharmony_ciCurrently the following bits are defined for the device_irq_level bitmap:: 789562306a36Sopenharmony_ci 789662306a36Sopenharmony_ci KVM_CAP_ARM_USER_IRQ >= 1: 789762306a36Sopenharmony_ci 789862306a36Sopenharmony_ci KVM_ARM_DEV_EL1_VTIMER - EL1 virtual timer 789962306a36Sopenharmony_ci KVM_ARM_DEV_EL1_PTIMER - EL1 physical timer 790062306a36Sopenharmony_ci KVM_ARM_DEV_PMU - ARM PMU overflow interrupt signal 790162306a36Sopenharmony_ci 790262306a36Sopenharmony_ciFuture versions of kvm may implement additional events. These will get 790362306a36Sopenharmony_ciindicated by returning a higher number from KVM_CHECK_EXTENSION and will be 790462306a36Sopenharmony_cilisted above. 790562306a36Sopenharmony_ci 790662306a36Sopenharmony_ci8.10 KVM_CAP_PPC_SMT_POSSIBLE 790762306a36Sopenharmony_ci----------------------------- 790862306a36Sopenharmony_ci 790962306a36Sopenharmony_ci:Architectures: ppc 791062306a36Sopenharmony_ci 791162306a36Sopenharmony_ciQuerying this capability returns a bitmap indicating the possible 791262306a36Sopenharmony_civirtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N 791362306a36Sopenharmony_ci(counting from the right) is set, then a virtual SMT mode of 2^N is 791462306a36Sopenharmony_ciavailable. 791562306a36Sopenharmony_ci 791662306a36Sopenharmony_ci8.11 KVM_CAP_HYPERV_SYNIC2 791762306a36Sopenharmony_ci-------------------------- 791862306a36Sopenharmony_ci 791962306a36Sopenharmony_ci:Architectures: x86 792062306a36Sopenharmony_ci 792162306a36Sopenharmony_ciThis capability enables a newer version of Hyper-V Synthetic interrupt 792262306a36Sopenharmony_cicontroller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM 792362306a36Sopenharmony_cidoesn't clear SynIC message and event flags pages when they are enabled by 792462306a36Sopenharmony_ciwriting to the respective MSRs. 792562306a36Sopenharmony_ci 792662306a36Sopenharmony_ci8.12 KVM_CAP_HYPERV_VP_INDEX 792762306a36Sopenharmony_ci---------------------------- 792862306a36Sopenharmony_ci 792962306a36Sopenharmony_ci:Architectures: x86 793062306a36Sopenharmony_ci 793162306a36Sopenharmony_ciThis capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its 793262306a36Sopenharmony_civalue is used to denote the target vcpu for a SynIC interrupt. For 793362306a36Sopenharmony_cicompatibility, KVM initializes this msr to KVM's internal vcpu index. When this 793462306a36Sopenharmony_cicapability is absent, userspace can still query this msr's value. 793562306a36Sopenharmony_ci 793662306a36Sopenharmony_ci8.13 KVM_CAP_S390_AIS_MIGRATION 793762306a36Sopenharmony_ci------------------------------- 793862306a36Sopenharmony_ci 793962306a36Sopenharmony_ci:Architectures: s390 794062306a36Sopenharmony_ci:Parameters: none 794162306a36Sopenharmony_ci 794262306a36Sopenharmony_ciThis capability indicates if the flic device will be able to get/set the 794362306a36Sopenharmony_ciAIS states for migration via the KVM_DEV_FLIC_AISM_ALL attribute and allows 794462306a36Sopenharmony_cito discover this without having to create a flic device. 794562306a36Sopenharmony_ci 794662306a36Sopenharmony_ci8.14 KVM_CAP_S390_PSW 794762306a36Sopenharmony_ci--------------------- 794862306a36Sopenharmony_ci 794962306a36Sopenharmony_ci:Architectures: s390 795062306a36Sopenharmony_ci 795162306a36Sopenharmony_ciThis capability indicates that the PSW is exposed via the kvm_run structure. 795262306a36Sopenharmony_ci 795362306a36Sopenharmony_ci8.15 KVM_CAP_S390_GMAP 795462306a36Sopenharmony_ci---------------------- 795562306a36Sopenharmony_ci 795662306a36Sopenharmony_ci:Architectures: s390 795762306a36Sopenharmony_ci 795862306a36Sopenharmony_ciThis capability indicates that the user space memory used as guest mapping can 795962306a36Sopenharmony_cibe anywhere in the user memory address space, as long as the memory slots are 796062306a36Sopenharmony_cialigned and sized to a segment (1MB) boundary. 796162306a36Sopenharmony_ci 796262306a36Sopenharmony_ci8.16 KVM_CAP_S390_COW 796362306a36Sopenharmony_ci--------------------- 796462306a36Sopenharmony_ci 796562306a36Sopenharmony_ci:Architectures: s390 796662306a36Sopenharmony_ci 796762306a36Sopenharmony_ciThis capability indicates that the user space memory used as guest mapping can 796862306a36Sopenharmony_ciuse copy-on-write semantics as well as dirty pages tracking via read-only page 796962306a36Sopenharmony_citables. 797062306a36Sopenharmony_ci 797162306a36Sopenharmony_ci8.17 KVM_CAP_S390_BPB 797262306a36Sopenharmony_ci--------------------- 797362306a36Sopenharmony_ci 797462306a36Sopenharmony_ci:Architectures: s390 797562306a36Sopenharmony_ci 797662306a36Sopenharmony_ciThis capability indicates that kvm will implement the interfaces to handle 797762306a36Sopenharmony_cireset, migration and nested KVM for branch prediction blocking. The stfle 797862306a36Sopenharmony_cifacility 82 should not be provided to the guest without this capability. 797962306a36Sopenharmony_ci 798062306a36Sopenharmony_ci8.18 KVM_CAP_HYPERV_TLBFLUSH 798162306a36Sopenharmony_ci---------------------------- 798262306a36Sopenharmony_ci 798362306a36Sopenharmony_ci:Architectures: x86 798462306a36Sopenharmony_ci 798562306a36Sopenharmony_ciThis capability indicates that KVM supports paravirtualized Hyper-V TLB Flush 798662306a36Sopenharmony_cihypercalls: 798762306a36Sopenharmony_ciHvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx, 798862306a36Sopenharmony_ciHvFlushVirtualAddressList, HvFlushVirtualAddressListEx. 798962306a36Sopenharmony_ci 799062306a36Sopenharmony_ci8.19 KVM_CAP_ARM_INJECT_SERROR_ESR 799162306a36Sopenharmony_ci---------------------------------- 799262306a36Sopenharmony_ci 799362306a36Sopenharmony_ci:Architectures: arm64 799462306a36Sopenharmony_ci 799562306a36Sopenharmony_ciThis capability indicates that userspace can specify (via the 799662306a36Sopenharmony_ciKVM_SET_VCPU_EVENTS ioctl) the syndrome value reported to the guest when it 799762306a36Sopenharmony_citakes a virtual SError interrupt exception. 799862306a36Sopenharmony_ciIf KVM advertises this capability, userspace can only specify the ISS field for 799962306a36Sopenharmony_cithe ESR syndrome. Other parts of the ESR, such as the EC are generated by the 800062306a36Sopenharmony_ciCPU when the exception is taken. If this virtual SError is taken to EL1 using 800162306a36Sopenharmony_ciAArch64, this value will be reported in the ISS field of ESR_ELx. 800262306a36Sopenharmony_ci 800362306a36Sopenharmony_ciSee KVM_CAP_VCPU_EVENTS for more details. 800462306a36Sopenharmony_ci 800562306a36Sopenharmony_ci8.20 KVM_CAP_HYPERV_SEND_IPI 800662306a36Sopenharmony_ci---------------------------- 800762306a36Sopenharmony_ci 800862306a36Sopenharmony_ci:Architectures: x86 800962306a36Sopenharmony_ci 801062306a36Sopenharmony_ciThis capability indicates that KVM supports paravirtualized Hyper-V IPI send 801162306a36Sopenharmony_cihypercalls: 801262306a36Sopenharmony_ciHvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx. 801362306a36Sopenharmony_ci 801462306a36Sopenharmony_ci8.21 KVM_CAP_HYPERV_DIRECT_TLBFLUSH 801562306a36Sopenharmony_ci----------------------------------- 801662306a36Sopenharmony_ci 801762306a36Sopenharmony_ci:Architectures: x86 801862306a36Sopenharmony_ci 801962306a36Sopenharmony_ciThis capability indicates that KVM running on top of Hyper-V hypervisor 802062306a36Sopenharmony_cienables Direct TLB flush for its guests meaning that TLB flush 802162306a36Sopenharmony_cihypercalls are handled by Level 0 hypervisor (Hyper-V) bypassing KVM. 802262306a36Sopenharmony_ciDue to the different ABI for hypercall parameters between Hyper-V and 802362306a36Sopenharmony_ciKVM, enabling this capability effectively disables all hypercall 802462306a36Sopenharmony_cihandling by KVM (as some KVM hypercall may be mistakenly treated as TLB 802562306a36Sopenharmony_ciflush hypercalls by Hyper-V) so userspace should disable KVM identification 802662306a36Sopenharmony_ciin CPUID and only exposes Hyper-V identification. In this case, guest 802762306a36Sopenharmony_cithinks it's running on Hyper-V and only use Hyper-V hypercalls. 802862306a36Sopenharmony_ci 802962306a36Sopenharmony_ci8.22 KVM_CAP_S390_VCPU_RESETS 803062306a36Sopenharmony_ci----------------------------- 803162306a36Sopenharmony_ci 803262306a36Sopenharmony_ci:Architectures: s390 803362306a36Sopenharmony_ci 803462306a36Sopenharmony_ciThis capability indicates that the KVM_S390_NORMAL_RESET and 803562306a36Sopenharmony_ciKVM_S390_CLEAR_RESET ioctls are available. 803662306a36Sopenharmony_ci 803762306a36Sopenharmony_ci8.23 KVM_CAP_S390_PROTECTED 803862306a36Sopenharmony_ci--------------------------- 803962306a36Sopenharmony_ci 804062306a36Sopenharmony_ci:Architectures: s390 804162306a36Sopenharmony_ci 804262306a36Sopenharmony_ciThis capability indicates that the Ultravisor has been initialized and 804362306a36Sopenharmony_ciKVM can therefore start protected VMs. 804462306a36Sopenharmony_ciThis capability governs the KVM_S390_PV_COMMAND ioctl and the 804562306a36Sopenharmony_ciKVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected 804662306a36Sopenharmony_ciguests when the state change is invalid. 804762306a36Sopenharmony_ci 804862306a36Sopenharmony_ci8.24 KVM_CAP_STEAL_TIME 804962306a36Sopenharmony_ci----------------------- 805062306a36Sopenharmony_ci 805162306a36Sopenharmony_ci:Architectures: arm64, x86 805262306a36Sopenharmony_ci 805362306a36Sopenharmony_ciThis capability indicates that KVM supports steal time accounting. 805462306a36Sopenharmony_ciWhen steal time accounting is supported it may be enabled with 805562306a36Sopenharmony_ciarchitecture-specific interfaces. This capability and the architecture- 805662306a36Sopenharmony_cispecific interfaces must be consistent, i.e. if one says the feature 805762306a36Sopenharmony_ciis supported, than the other should as well and vice versa. For arm64 805862306a36Sopenharmony_cisee Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL". 805962306a36Sopenharmony_ciFor x86 see Documentation/virt/kvm/x86/msr.rst "MSR_KVM_STEAL_TIME". 806062306a36Sopenharmony_ci 806162306a36Sopenharmony_ci8.25 KVM_CAP_S390_DIAG318 806262306a36Sopenharmony_ci------------------------- 806362306a36Sopenharmony_ci 806462306a36Sopenharmony_ci:Architectures: s390 806562306a36Sopenharmony_ci 806662306a36Sopenharmony_ciThis capability enables a guest to set information about its control program 806762306a36Sopenharmony_ci(i.e. guest kernel type and version). The information is helpful during 806862306a36Sopenharmony_cisystem/firmware service events, providing additional data about the guest 806962306a36Sopenharmony_cienvironments running on the machine. 807062306a36Sopenharmony_ci 807162306a36Sopenharmony_ciThe information is associated with the DIAGNOSE 0x318 instruction, which sets 807262306a36Sopenharmony_cian 8-byte value consisting of a one-byte Control Program Name Code (CPNC) and 807362306a36Sopenharmony_cia 7-byte Control Program Version Code (CPVC). The CPNC determines what 807462306a36Sopenharmony_cienvironment the control program is running in (e.g. Linux, z/VM...), and the 807562306a36Sopenharmony_ciCPVC is used for information specific to OS (e.g. Linux version, Linux 807662306a36Sopenharmony_cidistribution...) 807762306a36Sopenharmony_ci 807862306a36Sopenharmony_ciIf this capability is available, then the CPNC and CPVC can be synchronized 807962306a36Sopenharmony_cibetween KVM and userspace via the sync regs mechanism (KVM_SYNC_DIAG318). 808062306a36Sopenharmony_ci 808162306a36Sopenharmony_ci8.26 KVM_CAP_X86_USER_SPACE_MSR 808262306a36Sopenharmony_ci------------------------------- 808362306a36Sopenharmony_ci 808462306a36Sopenharmony_ci:Architectures: x86 808562306a36Sopenharmony_ci 808662306a36Sopenharmony_ciThis capability indicates that KVM supports deflection of MSR reads and 808762306a36Sopenharmony_ciwrites to user space. It can be enabled on a VM level. If enabled, MSR 808862306a36Sopenharmony_ciaccesses that would usually trigger a #GP by KVM into the guest will 808962306a36Sopenharmony_ciinstead get bounced to user space through the KVM_EXIT_X86_RDMSR and 809062306a36Sopenharmony_ciKVM_EXIT_X86_WRMSR exit notifications. 809162306a36Sopenharmony_ci 809262306a36Sopenharmony_ci8.27 KVM_CAP_X86_MSR_FILTER 809362306a36Sopenharmony_ci--------------------------- 809462306a36Sopenharmony_ci 809562306a36Sopenharmony_ci:Architectures: x86 809662306a36Sopenharmony_ci 809762306a36Sopenharmony_ciThis capability indicates that KVM supports that accesses to user defined MSRs 809862306a36Sopenharmony_cimay be rejected. With this capability exposed, KVM exports new VM ioctl 809962306a36Sopenharmony_ciKVM_X86_SET_MSR_FILTER which user space can call to specify bitmaps of MSR 810062306a36Sopenharmony_ciranges that KVM should deny access to. 810162306a36Sopenharmony_ci 810262306a36Sopenharmony_ciIn combination with KVM_CAP_X86_USER_SPACE_MSR, this allows user space to 810362306a36Sopenharmony_citrap and emulate MSRs that are outside of the scope of KVM as well as 810462306a36Sopenharmony_cilimit the attack surface on KVM's MSR emulation code. 810562306a36Sopenharmony_ci 810662306a36Sopenharmony_ci8.28 KVM_CAP_ENFORCE_PV_FEATURE_CPUID 810762306a36Sopenharmony_ci------------------------------------- 810862306a36Sopenharmony_ci 810962306a36Sopenharmony_ciArchitectures: x86 811062306a36Sopenharmony_ci 811162306a36Sopenharmony_ciWhen enabled, KVM will disable paravirtual features provided to the 811262306a36Sopenharmony_ciguest according to the bits in the KVM_CPUID_FEATURES CPUID leaf 811362306a36Sopenharmony_ci(0x40000001). Otherwise, a guest may use the paravirtual features 811462306a36Sopenharmony_ciregardless of what has actually been exposed through the CPUID leaf. 811562306a36Sopenharmony_ci 811662306a36Sopenharmony_ci8.29 KVM_CAP_DIRTY_LOG_RING/KVM_CAP_DIRTY_LOG_RING_ACQ_REL 811762306a36Sopenharmony_ci---------------------------------------------------------- 811862306a36Sopenharmony_ci 811962306a36Sopenharmony_ci:Architectures: x86, arm64 812062306a36Sopenharmony_ci:Parameters: args[0] - size of the dirty log ring 812162306a36Sopenharmony_ci 812262306a36Sopenharmony_ciKVM is capable of tracking dirty memory using ring buffers that are 812362306a36Sopenharmony_cimmapped into userspace; there is one dirty ring per vcpu. 812462306a36Sopenharmony_ci 812562306a36Sopenharmony_ciThe dirty ring is available to userspace as an array of 812662306a36Sopenharmony_ci``struct kvm_dirty_gfn``. Each dirty entry is defined as:: 812762306a36Sopenharmony_ci 812862306a36Sopenharmony_ci struct kvm_dirty_gfn { 812962306a36Sopenharmony_ci __u32 flags; 813062306a36Sopenharmony_ci __u32 slot; /* as_id | slot_id */ 813162306a36Sopenharmony_ci __u64 offset; 813262306a36Sopenharmony_ci }; 813362306a36Sopenharmony_ci 813462306a36Sopenharmony_ciThe following values are defined for the flags field to define the 813562306a36Sopenharmony_cicurrent state of the entry:: 813662306a36Sopenharmony_ci 813762306a36Sopenharmony_ci #define KVM_DIRTY_GFN_F_DIRTY BIT(0) 813862306a36Sopenharmony_ci #define KVM_DIRTY_GFN_F_RESET BIT(1) 813962306a36Sopenharmony_ci #define KVM_DIRTY_GFN_F_MASK 0x3 814062306a36Sopenharmony_ci 814162306a36Sopenharmony_ciUserspace should call KVM_ENABLE_CAP ioctl right after KVM_CREATE_VM 814262306a36Sopenharmony_ciioctl to enable this capability for the new guest and set the size of 814362306a36Sopenharmony_cithe rings. Enabling the capability is only allowed before creating any 814462306a36Sopenharmony_civCPU, and the size of the ring must be a power of two. The larger the 814562306a36Sopenharmony_ciring buffer, the less likely the ring is full and the VM is forced to 814662306a36Sopenharmony_ciexit to userspace. The optimal size depends on the workload, but it is 814762306a36Sopenharmony_cirecommended that it be at least 64 KiB (4096 entries). 814862306a36Sopenharmony_ci 814962306a36Sopenharmony_ciJust like for dirty page bitmaps, the buffer tracks writes to 815062306a36Sopenharmony_ciall user memory regions for which the KVM_MEM_LOG_DIRTY_PAGES flag was 815162306a36Sopenharmony_ciset in KVM_SET_USER_MEMORY_REGION. Once a memory region is registered 815262306a36Sopenharmony_ciwith the flag set, userspace can start harvesting dirty pages from the 815362306a36Sopenharmony_ciring buffer. 815462306a36Sopenharmony_ci 815562306a36Sopenharmony_ciAn entry in the ring buffer can be unused (flag bits ``00``), 815662306a36Sopenharmony_cidirty (flag bits ``01``) or harvested (flag bits ``1X``). The 815762306a36Sopenharmony_cistate machine for the entry is as follows:: 815862306a36Sopenharmony_ci 815962306a36Sopenharmony_ci dirtied harvested reset 816062306a36Sopenharmony_ci 00 -----------> 01 -------------> 1X -------+ 816162306a36Sopenharmony_ci ^ | 816262306a36Sopenharmony_ci | | 816362306a36Sopenharmony_ci +------------------------------------------+ 816462306a36Sopenharmony_ci 816562306a36Sopenharmony_ciTo harvest the dirty pages, userspace accesses the mmapped ring buffer 816662306a36Sopenharmony_cito read the dirty GFNs. If the flags has the DIRTY bit set (at this stage 816762306a36Sopenharmony_cithe RESET bit must be cleared), then it means this GFN is a dirty GFN. 816862306a36Sopenharmony_ciThe userspace should harvest this GFN and mark the flags from state 816962306a36Sopenharmony_ci``01b`` to ``1Xb`` (bit 0 will be ignored by KVM, but bit 1 must be set 817062306a36Sopenharmony_cito show that this GFN is harvested and waiting for a reset), and move 817162306a36Sopenharmony_cion to the next GFN. The userspace should continue to do this until the 817262306a36Sopenharmony_ciflags of a GFN have the DIRTY bit cleared, meaning that it has harvested 817362306a36Sopenharmony_ciall the dirty GFNs that were available. 817462306a36Sopenharmony_ci 817562306a36Sopenharmony_ciNote that on weakly ordered architectures, userspace accesses to the 817662306a36Sopenharmony_ciring buffer (and more specifically the 'flags' field) must be ordered, 817762306a36Sopenharmony_ciusing load-acquire/store-release accessors when available, or any 817862306a36Sopenharmony_ciother memory barrier that will ensure this ordering. 817962306a36Sopenharmony_ci 818062306a36Sopenharmony_ciIt's not necessary for userspace to harvest the all dirty GFNs at once. 818162306a36Sopenharmony_ciHowever it must collect the dirty GFNs in sequence, i.e., the userspace 818262306a36Sopenharmony_ciprogram cannot skip one dirty GFN to collect the one next to it. 818362306a36Sopenharmony_ci 818462306a36Sopenharmony_ciAfter processing one or more entries in the ring buffer, userspace 818562306a36Sopenharmony_cicalls the VM ioctl KVM_RESET_DIRTY_RINGS to notify the kernel about 818662306a36Sopenharmony_ciit, so that the kernel will reprotect those collected GFNs. 818762306a36Sopenharmony_ciTherefore, the ioctl must be called *before* reading the content of 818862306a36Sopenharmony_cithe dirty pages. 818962306a36Sopenharmony_ci 819062306a36Sopenharmony_ciThe dirty ring can get full. When it happens, the KVM_RUN of the 819162306a36Sopenharmony_civcpu will return with exit reason KVM_EXIT_DIRTY_LOG_FULL. 819262306a36Sopenharmony_ci 819362306a36Sopenharmony_ciThe dirty ring interface has a major difference comparing to the 819462306a36Sopenharmony_ciKVM_GET_DIRTY_LOG interface in that, when reading the dirty ring from 819562306a36Sopenharmony_ciuserspace, it's still possible that the kernel has not yet flushed the 819662306a36Sopenharmony_ciprocessor's dirty page buffers into the kernel buffer (with dirty bitmaps, the 819762306a36Sopenharmony_ciflushing is done by the KVM_GET_DIRTY_LOG ioctl). To achieve that, one 819862306a36Sopenharmony_cineeds to kick the vcpu out of KVM_RUN using a signal. The resulting 819962306a36Sopenharmony_civmexit ensures that all dirty GFNs are flushed to the dirty rings. 820062306a36Sopenharmony_ci 820162306a36Sopenharmony_ciNOTE: KVM_CAP_DIRTY_LOG_RING_ACQ_REL is the only capability that 820262306a36Sopenharmony_cishould be exposed by weakly ordered architecture, in order to indicate 820362306a36Sopenharmony_cithe additional memory ordering requirements imposed on userspace when 820462306a36Sopenharmony_cireading the state of an entry and mutating it from DIRTY to HARVESTED. 820562306a36Sopenharmony_ciArchitecture with TSO-like ordering (such as x86) are allowed to 820662306a36Sopenharmony_ciexpose both KVM_CAP_DIRTY_LOG_RING and KVM_CAP_DIRTY_LOG_RING_ACQ_REL 820762306a36Sopenharmony_cito userspace. 820862306a36Sopenharmony_ci 820962306a36Sopenharmony_ciAfter enabling the dirty rings, the userspace needs to detect the 821062306a36Sopenharmony_cicapability of KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP to see whether the 821162306a36Sopenharmony_ciring structures can be backed by per-slot bitmaps. With this capability 821262306a36Sopenharmony_ciadvertised, it means the architecture can dirty guest pages without 821362306a36Sopenharmony_civcpu/ring context, so that some of the dirty information will still be 821462306a36Sopenharmony_cimaintained in the bitmap structure. KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 821562306a36Sopenharmony_cican't be enabled if the capability of KVM_CAP_DIRTY_LOG_RING_ACQ_REL 821662306a36Sopenharmony_cihasn't been enabled, or any memslot has been existing. 821762306a36Sopenharmony_ci 821862306a36Sopenharmony_ciNote that the bitmap here is only a backup of the ring structure. The 821962306a36Sopenharmony_ciuse of the ring and bitmap combination is only beneficial if there is 822062306a36Sopenharmony_cionly a very small amount of memory that is dirtied out of vcpu/ring 822162306a36Sopenharmony_cicontext. Otherwise, the stand-alone per-slot bitmap mechanism needs to 822262306a36Sopenharmony_cibe considered. 822362306a36Sopenharmony_ci 822462306a36Sopenharmony_ciTo collect dirty bits in the backup bitmap, userspace can use the same 822562306a36Sopenharmony_ciKVM_GET_DIRTY_LOG ioctl. KVM_CLEAR_DIRTY_LOG isn't needed as long as all 822662306a36Sopenharmony_cithe generation of the dirty bits is done in a single pass. Collecting 822762306a36Sopenharmony_cithe dirty bitmap should be the very last thing that the VMM does before 822862306a36Sopenharmony_ciconsidering the state as complete. VMM needs to ensure that the dirty 822962306a36Sopenharmony_cistate is final and avoid missing dirty pages from another ioctl ordered 823062306a36Sopenharmony_ciafter the bitmap collection. 823162306a36Sopenharmony_ci 823262306a36Sopenharmony_ciNOTE: Multiple examples of using the backup bitmap: (1) save vgic/its 823362306a36Sopenharmony_citables through command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} on 823462306a36Sopenharmony_ciKVM device "kvm-arm-vgic-its". (2) restore vgic/its tables through 823562306a36Sopenharmony_cicommand KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} on KVM device 823662306a36Sopenharmony_ci"kvm-arm-vgic-its". VGICv3 LPI pending status is restored. (3) save 823762306a36Sopenharmony_civgic3 pending table through KVM_DEV_ARM_VGIC_{GRP_CTRL, SAVE_PENDING_TABLES} 823862306a36Sopenharmony_cicommand on KVM device "kvm-arm-vgic-v3". 823962306a36Sopenharmony_ci 824062306a36Sopenharmony_ci8.30 KVM_CAP_XEN_HVM 824162306a36Sopenharmony_ci-------------------- 824262306a36Sopenharmony_ci 824362306a36Sopenharmony_ci:Architectures: x86 824462306a36Sopenharmony_ci 824562306a36Sopenharmony_ciThis capability indicates the features that Xen supports for hosting Xen 824662306a36Sopenharmony_ciPVHVM guests. Valid flags are:: 824762306a36Sopenharmony_ci 824862306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0) 824962306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1) 825062306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2) 825162306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3) 825262306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4) 825362306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5) 825462306a36Sopenharmony_ci #define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6) 825562306a36Sopenharmony_ci 825662306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_HYPERCALL_MSR flag indicates that the KVM_XEN_HVM_CONFIG 825762306a36Sopenharmony_ciioctl is available, for the guest to set its hypercall page. 825862306a36Sopenharmony_ci 825962306a36Sopenharmony_ciIf KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL is also set, the same flag may also be 826062306a36Sopenharmony_ciprovided in the flags to KVM_XEN_HVM_CONFIG, without providing hypercall page 826162306a36Sopenharmony_cicontents, to request that KVM generate hypercall page content automatically 826262306a36Sopenharmony_ciand also enable interception of guest hypercalls with KVM_EXIT_XEN. 826362306a36Sopenharmony_ci 826462306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_SHARED_INFO flag indicates the availability of the 826562306a36Sopenharmony_ciKVM_XEN_HVM_SET_ATTR, KVM_XEN_HVM_GET_ATTR, KVM_XEN_VCPU_SET_ATTR and 826662306a36Sopenharmony_ciKVM_XEN_VCPU_GET_ATTR ioctls, as well as the delivery of exception vectors 826762306a36Sopenharmony_cifor event channel upcalls when the evtchn_upcall_pending field of a vcpu's 826862306a36Sopenharmony_civcpu_info is set. 826962306a36Sopenharmony_ci 827062306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_RUNSTATE flag indicates that the runstate-related 827162306a36Sopenharmony_cifeatures KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR/_CURRENT/_DATA/_ADJUST are 827262306a36Sopenharmony_cisupported by the KVM_XEN_VCPU_SET_ATTR/KVM_XEN_VCPU_GET_ATTR ioctls. 827362306a36Sopenharmony_ci 827462306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL flag indicates that IRQ routing entries 827562306a36Sopenharmony_ciof the type KVM_IRQ_ROUTING_XEN_EVTCHN are supported, with the priority 827662306a36Sopenharmony_cifield set to indicate 2 level event channel delivery. 827762306a36Sopenharmony_ci 827862306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_EVTCHN_SEND flag indicates that KVM supports 827962306a36Sopenharmony_ciinjecting event channel events directly into the guest with the 828062306a36Sopenharmony_ciKVM_XEN_HVM_EVTCHN_SEND ioctl. It also indicates support for the 828162306a36Sopenharmony_ciKVM_XEN_ATTR_TYPE_EVTCHN/XEN_VERSION HVM attributes and the 828262306a36Sopenharmony_ciKVM_XEN_VCPU_ATTR_TYPE_VCPU_ID/TIMER/UPCALL_VECTOR vCPU attributes. 828362306a36Sopenharmony_cirelated to event channel delivery, timers, and the XENVER_version 828462306a36Sopenharmony_ciinterception. 828562306a36Sopenharmony_ci 828662306a36Sopenharmony_ciThe KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG flag indicates that KVM supports 828762306a36Sopenharmony_cithe KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG attribute in the KVM_XEN_SET_ATTR 828862306a36Sopenharmony_ciand KVM_XEN_GET_ATTR ioctls. This controls whether KVM will set the 828962306a36Sopenharmony_ciXEN_RUNSTATE_UPDATE flag in guest memory mapped vcpu_runstate_info during 829062306a36Sopenharmony_ciupdates of the runstate information. Note that versions of KVM which support 829162306a36Sopenharmony_cithe RUNSTATE feature above, but not the RUNSTATE_UPDATE_FLAG feature, will 829262306a36Sopenharmony_cialways set the XEN_RUNSTATE_UPDATE flag when updating the guest structure, 829362306a36Sopenharmony_ciwhich is perhaps counterintuitive. When this flag is advertised, KVM will 829462306a36Sopenharmony_cibehave more correctly, not using the XEN_RUNSTATE_UPDATE flag until/unless 829562306a36Sopenharmony_cispecifically enabled (by the guest making the hypercall, causing the VMM 829662306a36Sopenharmony_cito enable the KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG attribute). 829762306a36Sopenharmony_ci 829862306a36Sopenharmony_ci8.31 KVM_CAP_PPC_MULTITCE 829962306a36Sopenharmony_ci------------------------- 830062306a36Sopenharmony_ci 830162306a36Sopenharmony_ci:Capability: KVM_CAP_PPC_MULTITCE 830262306a36Sopenharmony_ci:Architectures: ppc 830362306a36Sopenharmony_ci:Type: vm 830462306a36Sopenharmony_ci 830562306a36Sopenharmony_ciThis capability means the kernel is capable of handling hypercalls 830662306a36Sopenharmony_ciH_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user 830762306a36Sopenharmony_cispace. This significantly accelerates DMA operations for PPC KVM guests. 830862306a36Sopenharmony_ciUser space should expect that its handlers for these hypercalls 830962306a36Sopenharmony_ciare not going to be called if user space previously registered LIOBN 831062306a36Sopenharmony_ciin KVM (via KVM_CREATE_SPAPR_TCE or similar calls). 831162306a36Sopenharmony_ci 831262306a36Sopenharmony_ciIn order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest, 831362306a36Sopenharmony_ciuser space might have to advertise it for the guest. For example, 831462306a36Sopenharmony_ciIBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is 831562306a36Sopenharmony_cipresent in the "ibm,hypertas-functions" device-tree property. 831662306a36Sopenharmony_ci 831762306a36Sopenharmony_ciThe hypercalls mentioned above may or may not be processed successfully 831862306a36Sopenharmony_ciin the kernel based fast path. If they can not be handled by the kernel, 831962306a36Sopenharmony_cithey will get passed on to user space. So user space still has to have 832062306a36Sopenharmony_cian implementation for these despite the in kernel acceleration. 832162306a36Sopenharmony_ci 832262306a36Sopenharmony_ciThis capability is always enabled. 832362306a36Sopenharmony_ci 832462306a36Sopenharmony_ci8.32 KVM_CAP_PTP_KVM 832562306a36Sopenharmony_ci-------------------- 832662306a36Sopenharmony_ci 832762306a36Sopenharmony_ci:Architectures: arm64 832862306a36Sopenharmony_ci 832962306a36Sopenharmony_ciThis capability indicates that the KVM virtual PTP service is 833062306a36Sopenharmony_cisupported in the host. A VMM can check whether the service is 833162306a36Sopenharmony_ciavailable to the guest on migration. 833262306a36Sopenharmony_ci 833362306a36Sopenharmony_ci8.33 KVM_CAP_HYPERV_ENFORCE_CPUID 833462306a36Sopenharmony_ci--------------------------------- 833562306a36Sopenharmony_ci 833662306a36Sopenharmony_ciArchitectures: x86 833762306a36Sopenharmony_ci 833862306a36Sopenharmony_ciWhen enabled, KVM will disable emulated Hyper-V features provided to the 833962306a36Sopenharmony_ciguest according to the bits Hyper-V CPUID feature leaves. Otherwise, all 834062306a36Sopenharmony_cicurrently implemented Hyper-V features are provided unconditionally when 834162306a36Sopenharmony_ciHyper-V identification is set in the HYPERV_CPUID_INTERFACE (0x40000001) 834262306a36Sopenharmony_cileaf. 834362306a36Sopenharmony_ci 834462306a36Sopenharmony_ci8.34 KVM_CAP_EXIT_HYPERCALL 834562306a36Sopenharmony_ci--------------------------- 834662306a36Sopenharmony_ci 834762306a36Sopenharmony_ci:Capability: KVM_CAP_EXIT_HYPERCALL 834862306a36Sopenharmony_ci:Architectures: x86 834962306a36Sopenharmony_ci:Type: vm 835062306a36Sopenharmony_ci 835162306a36Sopenharmony_ciThis capability, if enabled, will cause KVM to exit to userspace 835262306a36Sopenharmony_ciwith KVM_EXIT_HYPERCALL exit reason to process some hypercalls. 835362306a36Sopenharmony_ci 835462306a36Sopenharmony_ciCalling KVM_CHECK_EXTENSION for this capability will return a bitmask 835562306a36Sopenharmony_ciof hypercalls that can be configured to exit to userspace. 835662306a36Sopenharmony_ciRight now, the only such hypercall is KVM_HC_MAP_GPA_RANGE. 835762306a36Sopenharmony_ci 835862306a36Sopenharmony_ciThe argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset 835962306a36Sopenharmony_ciof the result of KVM_CHECK_EXTENSION. KVM will forward to userspace 836062306a36Sopenharmony_cithe hypercalls whose corresponding bit is in the argument, and return 836162306a36Sopenharmony_ciENOSYS for the others. 836262306a36Sopenharmony_ci 836362306a36Sopenharmony_ci8.35 KVM_CAP_PMU_CAPABILITY 836462306a36Sopenharmony_ci--------------------------- 836562306a36Sopenharmony_ci 836662306a36Sopenharmony_ci:Capability: KVM_CAP_PMU_CAPABILITY 836762306a36Sopenharmony_ci:Architectures: x86 836862306a36Sopenharmony_ci:Type: vm 836962306a36Sopenharmony_ci:Parameters: arg[0] is bitmask of PMU virtualization capabilities. 837062306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL when arg[0] contains invalid bits 837162306a36Sopenharmony_ci 837262306a36Sopenharmony_ciThis capability alters PMU virtualization in KVM. 837362306a36Sopenharmony_ci 837462306a36Sopenharmony_ciCalling KVM_CHECK_EXTENSION for this capability returns a bitmask of 837562306a36Sopenharmony_ciPMU virtualization capabilities that can be adjusted on a VM. 837662306a36Sopenharmony_ci 837762306a36Sopenharmony_ciThe argument to KVM_ENABLE_CAP is also a bitmask and selects specific 837862306a36Sopenharmony_ciPMU virtualization capabilities to be applied to the VM. This can 837962306a36Sopenharmony_cionly be invoked on a VM prior to the creation of VCPUs. 838062306a36Sopenharmony_ci 838162306a36Sopenharmony_ciAt this time, KVM_PMU_CAP_DISABLE is the only capability. Setting 838262306a36Sopenharmony_cithis capability will disable PMU virtualization for that VM. Usermode 838362306a36Sopenharmony_cishould adjust CPUID leaf 0xA to reflect that the PMU is disabled. 838462306a36Sopenharmony_ci 838562306a36Sopenharmony_ci8.36 KVM_CAP_ARM_SYSTEM_SUSPEND 838662306a36Sopenharmony_ci------------------------------- 838762306a36Sopenharmony_ci 838862306a36Sopenharmony_ci:Capability: KVM_CAP_ARM_SYSTEM_SUSPEND 838962306a36Sopenharmony_ci:Architectures: arm64 839062306a36Sopenharmony_ci:Type: vm 839162306a36Sopenharmony_ci 839262306a36Sopenharmony_ciWhen enabled, KVM will exit to userspace with KVM_EXIT_SYSTEM_EVENT of 839362306a36Sopenharmony_citype KVM_SYSTEM_EVENT_SUSPEND to process the guest suspend request. 839462306a36Sopenharmony_ci 839562306a36Sopenharmony_ci8.37 KVM_CAP_S390_PROTECTED_DUMP 839662306a36Sopenharmony_ci-------------------------------- 839762306a36Sopenharmony_ci 839862306a36Sopenharmony_ci:Capability: KVM_CAP_S390_PROTECTED_DUMP 839962306a36Sopenharmony_ci:Architectures: s390 840062306a36Sopenharmony_ci:Type: vm 840162306a36Sopenharmony_ci 840262306a36Sopenharmony_ciThis capability indicates that KVM and the Ultravisor support dumping 840362306a36Sopenharmony_ciPV guests. The `KVM_PV_DUMP` command is available for the 840462306a36Sopenharmony_ci`KVM_S390_PV_COMMAND` ioctl and the `KVM_PV_INFO` command provides 840562306a36Sopenharmony_cidump related UV data. Also the vcpu ioctl `KVM_S390_PV_CPU_COMMAND` is 840662306a36Sopenharmony_ciavailable and supports the `KVM_PV_DUMP_CPU` subcommand. 840762306a36Sopenharmony_ci 840862306a36Sopenharmony_ci8.38 KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 840962306a36Sopenharmony_ci------------------------------------- 841062306a36Sopenharmony_ci 841162306a36Sopenharmony_ci:Capability: KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 841262306a36Sopenharmony_ci:Architectures: x86 841362306a36Sopenharmony_ci:Type: vm 841462306a36Sopenharmony_ci:Parameters: arg[0] must be 0. 841562306a36Sopenharmony_ci:Returns: 0 on success, -EPERM if the userspace process does not 841662306a36Sopenharmony_ci have CAP_SYS_BOOT, -EINVAL if args[0] is not 0 or any vCPUs have been 841762306a36Sopenharmony_ci created. 841862306a36Sopenharmony_ci 841962306a36Sopenharmony_ciThis capability disables the NX huge pages mitigation for iTLB MULTIHIT. 842062306a36Sopenharmony_ci 842162306a36Sopenharmony_ciThe capability has no effect if the nx_huge_pages module parameter is not set. 842262306a36Sopenharmony_ci 842362306a36Sopenharmony_ciThis capability may only be set before any vCPUs are created. 842462306a36Sopenharmony_ci 842562306a36Sopenharmony_ci8.39 KVM_CAP_S390_CPU_TOPOLOGY 842662306a36Sopenharmony_ci------------------------------ 842762306a36Sopenharmony_ci 842862306a36Sopenharmony_ci:Capability: KVM_CAP_S390_CPU_TOPOLOGY 842962306a36Sopenharmony_ci:Architectures: s390 843062306a36Sopenharmony_ci:Type: vm 843162306a36Sopenharmony_ci 843262306a36Sopenharmony_ciThis capability indicates that KVM will provide the S390 CPU Topology 843362306a36Sopenharmony_cifacility which consist of the interpretation of the PTF instruction for 843462306a36Sopenharmony_cithe function code 2 along with interception and forwarding of both the 843562306a36Sopenharmony_ciPTF instruction with function codes 0 or 1 and the STSI(15,1,x) 843662306a36Sopenharmony_ciinstruction to the userland hypervisor. 843762306a36Sopenharmony_ci 843862306a36Sopenharmony_ciThe stfle facility 11, CPU Topology facility, should not be indicated 843962306a36Sopenharmony_cito the guest without this capability. 844062306a36Sopenharmony_ci 844162306a36Sopenharmony_ciWhen this capability is present, KVM provides a new attribute group 844262306a36Sopenharmony_cion vm fd, KVM_S390_VM_CPU_TOPOLOGY. 844362306a36Sopenharmony_ciThis new attribute allows to get, set or clear the Modified Change 844462306a36Sopenharmony_ciTopology Report (MTCR) bit of the SCA through the kvm_device_attr 844562306a36Sopenharmony_cistructure. 844662306a36Sopenharmony_ci 844762306a36Sopenharmony_ciWhen getting the Modified Change Topology Report value, the attr->addr 844862306a36Sopenharmony_cimust point to a byte where the value will be stored or retrieved from. 844962306a36Sopenharmony_ci 845062306a36Sopenharmony_ci8.40 KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 845162306a36Sopenharmony_ci--------------------------------------- 845262306a36Sopenharmony_ci 845362306a36Sopenharmony_ci:Capability: KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 845462306a36Sopenharmony_ci:Architectures: arm64 845562306a36Sopenharmony_ci:Type: vm 845662306a36Sopenharmony_ci:Parameters: arg[0] is the new split chunk size. 845762306a36Sopenharmony_ci:Returns: 0 on success, -EINVAL if any memslot was already created. 845862306a36Sopenharmony_ci 845962306a36Sopenharmony_ciThis capability sets the chunk size used in Eager Page Splitting. 846062306a36Sopenharmony_ci 846162306a36Sopenharmony_ciEager Page Splitting improves the performance of dirty-logging (used 846262306a36Sopenharmony_ciin live migrations) when guest memory is backed by huge-pages. It 846362306a36Sopenharmony_ciavoids splitting huge-pages (into PAGE_SIZE pages) on fault, by doing 846462306a36Sopenharmony_ciit eagerly when enabling dirty logging (with the 846562306a36Sopenharmony_ciKVM_MEM_LOG_DIRTY_PAGES flag for a memory region), or when using 846662306a36Sopenharmony_ciKVM_CLEAR_DIRTY_LOG. 846762306a36Sopenharmony_ci 846862306a36Sopenharmony_ciThe chunk size specifies how many pages to break at a time, using a 846962306a36Sopenharmony_cisingle allocation for each chunk. Bigger the chunk size, more pages 847062306a36Sopenharmony_cineed to be allocated ahead of time. 847162306a36Sopenharmony_ci 847262306a36Sopenharmony_ciThe chunk size needs to be a valid block size. The list of acceptable 847362306a36Sopenharmony_ciblock sizes is exposed in KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES as a 847462306a36Sopenharmony_ci64-bit bitmap (each bit describing a block size). The default value is 847562306a36Sopenharmony_ci0, to disable the eager page splitting. 847662306a36Sopenharmony_ci 847762306a36Sopenharmony_ci9. Known KVM API problems 847862306a36Sopenharmony_ci========================= 847962306a36Sopenharmony_ci 848062306a36Sopenharmony_ciIn some cases, KVM's API has some inconsistencies or common pitfalls 848162306a36Sopenharmony_cithat userspace need to be aware of. This section details some of 848262306a36Sopenharmony_cithese issues. 848362306a36Sopenharmony_ci 848462306a36Sopenharmony_ciMost of them are architecture specific, so the section is split by 848562306a36Sopenharmony_ciarchitecture. 848662306a36Sopenharmony_ci 848762306a36Sopenharmony_ci9.1. x86 848862306a36Sopenharmony_ci-------- 848962306a36Sopenharmony_ci 849062306a36Sopenharmony_ci``KVM_GET_SUPPORTED_CPUID`` issues 849162306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 849262306a36Sopenharmony_ci 849362306a36Sopenharmony_ciIn general, ``KVM_GET_SUPPORTED_CPUID`` is designed so that it is possible 849462306a36Sopenharmony_cito take its result and pass it directly to ``KVM_SET_CPUID2``. This section 849562306a36Sopenharmony_cidocuments some cases in which that requires some care. 849662306a36Sopenharmony_ci 849762306a36Sopenharmony_ciLocal APIC features 849862306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~ 849962306a36Sopenharmony_ci 850062306a36Sopenharmony_ciCPU[EAX=1]:ECX[21] (X2APIC) is reported by ``KVM_GET_SUPPORTED_CPUID``, 850162306a36Sopenharmony_cibut it can only be enabled if ``KVM_CREATE_IRQCHIP`` or 850262306a36Sopenharmony_ci``KVM_ENABLE_CAP(KVM_CAP_IRQCHIP_SPLIT)`` are used to enable in-kernel emulation of 850362306a36Sopenharmony_cithe local APIC. 850462306a36Sopenharmony_ci 850562306a36Sopenharmony_ciThe same is true for the ``KVM_FEATURE_PV_UNHALT`` paravirtualized feature. 850662306a36Sopenharmony_ci 850762306a36Sopenharmony_ciCPU[EAX=1]:ECX[24] (TSC_DEADLINE) is not reported by ``KVM_GET_SUPPORTED_CPUID``. 850862306a36Sopenharmony_ciIt can be enabled if ``KVM_CAP_TSC_DEADLINE_TIMER`` is present and the kernel 850962306a36Sopenharmony_cihas enabled in-kernel emulation of the local APIC. 851062306a36Sopenharmony_ci 851162306a36Sopenharmony_ciCPU topology 851262306a36Sopenharmony_ci~~~~~~~~~~~~ 851362306a36Sopenharmony_ci 851462306a36Sopenharmony_ciSeveral CPUID values include topology information for the host CPU: 851562306a36Sopenharmony_ci0x0b and 0x1f for Intel systems, 0x8000001e for AMD systems. Different 851662306a36Sopenharmony_civersions of KVM return different values for this information and userspace 851762306a36Sopenharmony_cishould not rely on it. Currently they return all zeroes. 851862306a36Sopenharmony_ci 851962306a36Sopenharmony_ciIf userspace wishes to set up a guest topology, it should be careful that 852062306a36Sopenharmony_cithe values of these three leaves differ for each CPU. In particular, 852162306a36Sopenharmony_cithe APIC ID is found in EDX for all subleaves of 0x0b and 0x1f, and in EAX 852262306a36Sopenharmony_cifor 0x8000001e; the latter also encodes the core id and node id in bits 852362306a36Sopenharmony_ci7:0 of EBX and ECX respectively. 852462306a36Sopenharmony_ci 852562306a36Sopenharmony_ciObsolete ioctls and capabilities 852662306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 852762306a36Sopenharmony_ci 852862306a36Sopenharmony_ciKVM_CAP_DISABLE_QUIRKS does not let userspace know which quirks are actually 852962306a36Sopenharmony_ciavailable. Use ``KVM_CHECK_EXTENSION(KVM_CAP_DISABLE_QUIRKS2)`` instead if 853062306a36Sopenharmony_ciavailable. 853162306a36Sopenharmony_ci 853262306a36Sopenharmony_ciOrdering of KVM_GET_*/KVM_SET_* ioctls 853362306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 853462306a36Sopenharmony_ci 853562306a36Sopenharmony_ciTBD 8536