^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ===================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) The Definitive KVM (Kernel-based Virtual Machine) API Documentation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ===================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) 1. General description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) The kvm API is a set of ioctls that are issued to control various aspects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) of a virtual machine. The ioctls belong to the following classes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) - System ioctls: These query and set global attributes which affect the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) whole kvm subsystem. In addition a system ioctl is used to create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) virtual machines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) - VM ioctls: These query and set attributes that affect an entire virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) machine, for example memory layout. In addition a VM ioctl is used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) create virtual cpus (vcpus) and devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) VM ioctls must be issued from the same process (address space) that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) used to create the VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) - vcpu ioctls: These query and set attributes that control the operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) of a single virtual cpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) vcpu ioctls should be issued from the same thread that was used to create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) the vcpu, except for asynchronous vcpu ioctl that are marked as such in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) the documentation. Otherwise, the first ioctl after switching threads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) could see a performance impact.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) - device ioctls: These query and set attributes that control the operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) of a single device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) device ioctls must be issued from the same process (address space) that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) was used to create the VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 2. File descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) ===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) The kvm API is centered around file descriptors. An initial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) handle will create a VM file descriptor which can be used to issue VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) create a virtual cpu or device and return a file descriptor pointing to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) the new resource. Finally, ioctls on a vcpu or device fd can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) to control the vcpu or device. For vcpus, this includes the important
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) task of actually running guest code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) In general file descriptors can be migrated among processes by means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) of fork() and the SCM_RIGHTS facility of unix domain socket. These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) kinds of tricks are explicitly not supported by kvm. While they will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) not cause harm to the host, their actual behavior is not guaranteed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) the API. See "General description" for details on the ioctl usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) model that is supported by KVM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) It is important to note that althought VM ioctls may only be issued from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) the process that created the VM, a VM's lifecycle is associated with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) file descriptor, not its creator (process). In other words, the VM and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) its resources, *including the associated address space*, are not freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) until the last reference to the VM's file descriptor has been released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) For example, if fork() is issued after ioctl(KVM_CREATE_VM), the VM will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) not be freed until both the parent (original) process and its child have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) put their references to the VM's file descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) Because a VM's resources are not freed until the last reference to its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) file descriptor is released, creating additional references to a VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) via fork(), dup(), etc... without careful consideration is strongly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) discouraged and may have unwanted side effects, e.g. memory allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) by and on behalf of the VM's process may not be freed/unaccounted when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) the VM is shut down.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 3. Extensions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) As of Linux 2.6.22, the KVM ABI has been stabilized: no backward
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) incompatible change are allowed. However, there is an extension
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) facility that allows backward-compatible extensions to the API to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) queried and used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) The extension mechanism is not based on the Linux version number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) Instead, kvm defines extension identifiers and a facility to query
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) whether a particular extension identifier is available. If it is, a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) set of ioctls is available for application use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 4. API description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) This section describes ioctls that can be used to control kvm guests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) For each ioctl, the following information is provided along with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) Capability:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) which KVM extension provides this ioctl. Can be 'basic',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) which means that is will be provided by any kernel that supports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) API version 12 (see section 4.1), a KVM_CAP_xyz constant, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) means availability needs to be checked with KVM_CHECK_EXTENSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) (see section 4.4), or 'none' which means that while not all kernels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) support this ioctl, there's no capability bit to check its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) availability: for kernels that don't support the ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) the ioctl returns -ENOTTY.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) Architectures:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) which instruction set architectures provide this ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) x86 includes both i386 and x86_64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) Type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) system, vm, or vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) Parameters:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) what parameters are accepted by the ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) the return value. General error numbers (EBADF, ENOMEM, EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) are not detailed, but errors with specific meanings are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 4.1 KVM_GET_API_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) :Returns: the constant KVM_API_VERSION (=12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) This identifies the API version as the stable kvm API. It is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) expected that this number will change. However, Linux 2.6.20 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 2.6.21 report earlier versions; these are not documented and not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) supported. Applications should refuse to run if KVM_GET_API_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) returns a value other than 12. If this check passes, all ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) described as 'basic' will be available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 4.2 KVM_CREATE_VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) :Parameters: machine type identifier (KVM_VM_*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) :Returns: a VM fd that can be used to control the new virtual machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) The new VM has no virtual cpus and no memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) You probably want to use 0 as machine type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) In order to create user controlled virtual machines on S390, check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) privileged user (CAP_SYS_ADMIN).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) To use hardware assisted virtualization on MIPS (VZ ASE) rather than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) the default trap & emulate implementation (which changes the virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) memory layout to fit in user mode), check KVM_CAP_MIPS_VZ and use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) flag KVM_VM_MIPS_VZ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) On arm64, the physical address size for a VM (IPA Size limit) is limited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) to 40bits by default. The limit can be configured if the host supports the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) extension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) KVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) identifier, where IPA_Bits is the maximum width of any physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) address used by the VM. The IPA_Bits is encoded in bits[7-0] of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) machine type identifier.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) e.g, to configure a guest to use 48bit physical address size::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) The requested size (IPA_Bits) must be:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) == =========================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 0 Implies default size, 40bits (for backward compatibility)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) N Implies N bits, where N is a positive integer such that,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 32 <= N <= Host_IPA_Limit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) == =========================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) Host_IPA_Limit is the maximum possible value for IPA_Bits on the host and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) is dependent on the CPU capability and the kernel configuration. The limit can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ioctl() at run-time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) Creation of the VM will fail if the requested IPA size (whether it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) implicit or explicit) is unsupported on the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) Please note that configuring the IPA size does not affect the capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) size of the address translated by the stage2 level (guest physical to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) host physical address translations).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 4.3 KVM_GET_MSR_INDEX_LIST, KVM_GET_MSR_FEATURE_INDEX_LIST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ----------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) :Capability: basic, KVM_CAP_GET_MSR_FEATURES for KVM_GET_MSR_FEATURE_INDEX_LIST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) :Parameters: struct kvm_msr_list (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ====== ============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) EFAULT the msr index list cannot be read from or written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) E2BIG the msr index list is to be to fit in the array specified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) the user.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) ====== ============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct kvm_msr_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) __u32 nmsrs; /* number of msrs in entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) __u32 indices[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) The user fills in the size of the indices array in nmsrs, and in return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) kvm adjusts nmsrs to reflect the actual number of msrs and fills in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) indices array with their numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) KVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) varies by kvm version and host processor, but does not change otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) not returned in the MSR list, as different vcpus can have a different number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) of banks, as set via the KVM_X86_SETUP_MCE ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) KVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) to the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) and processor features that are exposed via MSRs (e.g., VMX capabilities).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) This list also varies by kvm version and host processor, but does not change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 4.4 KVM_CHECK_EXTENSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) :Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) :Type: system ioctl, vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) :Parameters: extension identifier (KVM_CAP_*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) :Returns: 0 if unsupported; 1 (or some other positive integer) if supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) The API allows the application to query about extensions to the core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) kvm API. Userspace passes an extension identifier (an integer) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) receives an integer that describes the extension availability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) Generally 0 means no and 1 means yes, but some extensions may report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) additional information in the integer return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) Based on their initialization different VMs may have different capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) It is thus encouraged to use the vm ioctl to query for capabilities (available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) with KVM_CAP_CHECK_EXTENSION_VM on the vm fd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 4.5 KVM_GET_VCPU_MMAP_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) :Returns: size of vcpu mmap area, in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) The KVM_RUN ioctl (cf.) communicates with userspace via a shared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) memory region. This ioctl returns the size of that region. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) KVM_RUN documentation for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 4.6 KVM_SET_MEMORY_REGION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) :Parameters: struct kvm_memory_region (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) This ioctl is obsolete and has been removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 4.7 KVM_CREATE_VCPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) :Parameters: vcpu id (apic id on x86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) :Returns: vcpu fd on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) This API adds a vcpu to a virtual machine. No more than max_vcpus may be added.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) The vcpu id is an integer in the range [0, max_vcpu_id).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) the KVM_CHECK_EXTENSION ioctl() at run-time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) The maximum possible value for max_vcpus can be retrieved using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) cpus max.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) same as the value returned from KVM_CAP_NR_VCPUS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) The maximum possible value for max_vcpu_id can be retrieved using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) is the same as the value returned from KVM_CAP_MAX_VCPUS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) threads in one or more virtual CPU cores. (This is because the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) hardware requires all the hardware threads in a CPU core to be in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) same partition.) The KVM_CAP_PPC_SMT capability indicates the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) of vcpus per virtual core (vcore). The vcore id is obtained by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) given vcore will always be in the same physical core as each other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) (though that might be a different physical core from time to time).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) Userspace can control the threading (SMT) mode of the guest by its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) allocation of vcpu ids. For example, if userspace wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) single-threaded guest vcpus, it should make all vcpu ids be a multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) of the number of vcpus per vcore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) For virtual cpus that have been created with S390 user controlled virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) machines, the resulting vcpu fd can be memory mapped at page offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) cpu's hardware control block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 4.8 KVM_GET_DIRTY_LOG (vm ioctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) --------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) :Parameters: struct kvm_dirty_log (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /* for KVM_GET_DIRTY_LOG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) struct kvm_dirty_log {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) __u32 slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) __u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) void __user *dirty_bitmap; /* one bit per page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) __u64 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) Given a memory slot, return a bitmap containing any pages dirtied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) since the last call to this ioctl. Bit 0 is the first page in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) memory slot. Ensure the entire structure is cleared to avoid padding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) issues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) the address space for which you want to return the dirty bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) They must be less than the value that KVM_CHECK_EXTENSION returns for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) the KVM_CAP_MULTI_ADDRESS_SPACE capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) The bits in the dirty bitmap are cleared before the ioctl returns, unless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is enabled. For more information,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) see the description of the capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 4.9 KVM_SET_MEMORY_ALIAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) :Parameters: struct kvm_memory_alias (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) :Returns: 0 (success), -1 (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) This ioctl is obsolete and has been removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 4.10 KVM_RUN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) ------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) ======= ==============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) EINTR an unmasked signal is pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) ENOEXEC the vcpu hasn't been initialized or the guest tried to execute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) instructions from device memory (arm64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) ENOSYS data abort outside memslots with no syndrome info and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) KVM_CAP_ARM_NISV_TO_USER not enabled (arm64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) EPERM SVE feature set but not finalized (arm64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) ======= ==============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) This ioctl is used to run a guest virtual cpu. While there are no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) explicit parameters, there is an implicit parameter block that can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) obtained by mmap()ing the vcpu fd at offset 0, with the size given by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) kvm_run' (see below).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 4.11 KVM_GET_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) :Architectures: all except ARM, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) :Parameters: struct kvm_regs (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) Reads the general purpose registers from the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /* x86 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) struct kvm_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) __u64 rax, rbx, rcx, rdx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) __u64 rsi, rdi, rsp, rbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) __u64 r8, r9, r10, r11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) __u64 r12, r13, r14, r15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) __u64 rip, rflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /* mips */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) struct kvm_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) __u64 gpr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) __u64 hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) __u64 lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) __u64 pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 4.12 KVM_SET_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) :Architectures: all except ARM, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) :Parameters: struct kvm_regs (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) Writes the general purpose registers into the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) See KVM_GET_REGS for the data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 4.13 KVM_GET_SREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) :Architectures: x86, ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) :Parameters: struct kvm_sregs (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) Reads special registers from the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* x86 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) struct kvm_sregs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct kvm_segment cs, ds, es, fs, gs, ss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) struct kvm_segment tr, ldt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct kvm_dtable gdt, idt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) __u64 cr0, cr2, cr3, cr4, cr8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) __u64 efer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) __u64 apic_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) interrupt_bitmap is a bitmap of pending external interrupts. At most
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) one bit may be set. This interrupt has been acknowledged by the APIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) but not yet injected into the cpu core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 4.14 KVM_SET_SREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) :Architectures: x86, ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) :Parameters: struct kvm_sregs (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) Writes special registers into the vcpu. See KVM_GET_SREGS for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) data structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 4.15 KVM_TRANSLATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) :Parameters: struct kvm_translation (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) Translates a virtual address according to the vcpu's current address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) translation mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) struct kvm_translation {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) /* in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) __u64 linear_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) /* out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) __u64 physical_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) __u8 valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) __u8 writeable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) __u8 usermode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) __u8 pad[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 4.16 KVM_INTERRUPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) :Architectures: x86, ppc, mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) :Parameters: struct kvm_interrupt (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) :Returns: 0 on success, negative on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) Queues a hardware interrupt vector to be injected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) /* for KVM_INTERRUPT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) struct kvm_interrupt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) /* in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) __u32 irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) X86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) ^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) :Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) ========= ===================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) -EEXIST if an interrupt is already enqueued
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) -EINVAL the irq number is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) -ENXIO if the PIC is in the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) -EFAULT if the pointer is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) ========= ===================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) Note 'irq' is an interrupt vector, not an interrupt pin or line. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) ioctl is useful if the in-kernel PIC is not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) PPC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) ^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) Queues an external interrupt to be injected. This ioctl is overleaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) with 3 different irq values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) a) KVM_INTERRUPT_SET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) This injects an edge type external interrupt into the guest once it's ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) to receive interrupts. When injected, the interrupt is done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) b) KVM_INTERRUPT_UNSET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) This unsets any pending interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) Only available with KVM_CAP_PPC_UNSET_IRQ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) c) KVM_INTERRUPT_SET_LEVEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) This injects a level type external interrupt into the guest context. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) is triggered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) Only available with KVM_CAP_PPC_IRQ_LEVEL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) Note that any value for 'irq' other than the ones stated above is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) and incurs unexpected behavior.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) This is an asynchronous vcpu ioctl and can be invoked from any thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) MIPS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) ^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) Queues an external interrupt to be injected into the virtual CPU. A negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) interrupt number dequeues the interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) This is an asynchronous vcpu ioctl and can be invoked from any thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 4.17 KVM_DEBUG_GUEST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) :Architectures: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) :Parameters: none)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) :Returns: -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) Support for this has been removed. Use KVM_SET_GUEST_DEBUG instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 4.18 KVM_GET_MSRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) :Capability: basic (vcpu), KVM_CAP_GET_MSR_FEATURES (system)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) :Type: system ioctl, vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) :Parameters: struct kvm_msrs (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) :Returns: number of msrs successfully returned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) When used as a system ioctl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) Reads the values of MSR-based features that are available for the VM. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) is similar to KVM_GET_SUPPORTED_CPUID, but it returns MSR indices and values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) The list of msr-based features can be obtained using KVM_GET_MSR_FEATURE_INDEX_LIST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) in a system ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) When used as a vcpu ioctl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) Reads model-specific registers from the vcpu. Supported msr indices can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) be obtained using KVM_GET_MSR_INDEX_LIST in a system ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) struct kvm_msrs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) __u32 nmsrs; /* number of msrs in entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) struct kvm_msr_entry entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) struct kvm_msr_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) __u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) __u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) __u64 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) Application code should set the 'nmsrs' member (which indicates the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) size of the entries array) and the 'index' member of each array entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) kvm will fill in the 'data' member.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 4.19 KVM_SET_MSRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) :Parameters: struct kvm_msrs (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) :Returns: number of msrs successfully set (see below), -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) data structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) Application code should set the 'nmsrs' member (which indicates the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) size of the entries array), and the 'index' and 'data' members of each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) array entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) It tries to set the MSRs in array entries[] one by one. If setting an MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) fails, e.g., due to setting reserved bits, the MSR isn't supported/emulated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) by KVM, etc..., it stops processing the MSR list and returns the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) MSRs that have been set successfully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 4.20 KVM_SET_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) :Parameters: struct kvm_cpuid (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) Defines the vcpu responses to the cpuid instruction. Applications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) should use the KVM_SET_CPUID2 ioctl if available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) Note, when this IOCTL fails, KVM gives no guarantees that previous valid CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) configuration (if there is) is not corrupted. Userspace can get a copy of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) resulting CPUID configuration through KVM_GET_CPUID2 in case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) struct kvm_cpuid_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) __u32 function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) __u32 eax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) __u32 ebx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) __u32 ecx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) __u32 edx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) __u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) /* for KVM_SET_CPUID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) struct kvm_cpuid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) __u32 nent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) __u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) struct kvm_cpuid_entry entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 4.21 KVM_SET_SIGNAL_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) :Parameters: struct kvm_signal_mask (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) Defines which signals are blocked during execution of KVM_RUN. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) signal mask temporarily overrides the threads signal mask. Any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) unblocked signal received (except SIGKILL and SIGSTOP, which retain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) their traditional behaviour) will cause KVM_RUN to return with -EINTR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) Note the signal will only be delivered if not blocked by the original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) signal mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) /* for KVM_SET_SIGNAL_MASK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) struct kvm_signal_mask {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) __u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) __u8 sigset[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 4.22 KVM_GET_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) :Parameters: struct kvm_fpu (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) Reads the floating point state from the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) /* for KVM_GET_FPU and KVM_SET_FPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) struct kvm_fpu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) __u8 fpr[8][16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) __u16 fcw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) __u16 fsw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) __u8 ftwx; /* in fxsave format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) __u8 pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) __u16 last_opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) __u64 last_ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) __u64 last_dp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) __u8 xmm[16][16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) __u32 mxcsr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) __u32 pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 4.23 KVM_SET_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) :Parameters: struct kvm_fpu (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) Writes the floating point state to the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) /* for KVM_GET_FPU and KVM_SET_FPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) struct kvm_fpu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) __u8 fpr[8][16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) __u16 fcw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) __u16 fsw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) __u8 ftwx; /* in fxsave format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) __u8 pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) __u16 last_opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) __u64 last_ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) __u64 last_dp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) __u8 xmm[16][16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) __u32 mxcsr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) __u32 pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 4.24 KVM_CREATE_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) :Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) :Architectures: x86, ARM, arm64, s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) Creates an interrupt controller model in the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) On x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) future vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) PIC and IOAPIC; GSI 16-23 only go to the IOAPIC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) On ARM/arm64, a GICv2 is created. Any other GIC versions require the usage of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) KVM_CREATE_DEVICE, which also supports creating a GICv2. Using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) KVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) On s390, a dummy irq routing table is created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) before KVM_CREATE_IRQCHIP can be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 4.25 KVM_IRQ_LINE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) :Capability: KVM_CAP_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) :Architectures: x86, arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) :Parameters: struct kvm_irq_level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) Sets the level of a GSI input to the interrupt controller model in the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) On some architectures it is required that an interrupt controller model has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) been previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) interrupts require the level to be set to 1 and then back to 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) On real hardware, interrupt pins can be active-low or active-high. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) does not matter for the level field of struct kvm_irq_level: 1 always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) means active (asserted), 0 means inactive (deasserted).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) x86 allows the operating system to program the interrupt polarity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) (active-low/active-high) for level-triggered interrupts, and KVM used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) to consider the polarity. However, due to bitrot in the handling of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) active-low interrupts, the above convention is now valid on x86 too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) should not present interrupts to the guest as active-low unless this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) capability is present (or unless it is not using the in-kernel irqchip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) of course).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) ARM/arm64 can signal an interrupt either at the CPU level, or at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) in-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) use PPIs designated for specific cpus. The irq field is interpreted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) like this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) bits: | 31 ... 28 | 27 ... 24 | 23 ... 16 | 15 ... 0 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) field: | vcpu2_index | irq_type | vcpu_index | irq_id |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) The irq_type field has the following values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) - irq_type[0]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) - irq_type[1]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) (the vcpu_index field is ignored)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) - irq_type[2]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) in-kernel GIC: PPI, irq_id between 16 and 31 (incl.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) (The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) In both cases, level is used to assert/deassert the line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) When KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 is supported, the target vcpu is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) identified as (256 * vcpu2_index + vcpu_index). Otherwise, vcpu2_index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) must be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) Note that on arm/arm64, the KVM_CAP_IRQCHIP capability only conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) injection of interrupts for the in-kernel irqchip. KVM_IRQ_LINE can always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) be used for a userspace interrupt controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) struct kvm_irq_level {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) __u32 irq; /* GSI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) __s32 status; /* not used for KVM_IRQ_LEVEL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) __u32 level; /* 0 or 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) 4.26 KVM_GET_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) :Capability: KVM_CAP_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) :Parameters: struct kvm_irqchip (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) Reads the state of a kernel interrupt controller created with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) KVM_CREATE_IRQCHIP into a buffer provided by the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) struct kvm_irqchip {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) char dummy[512]; /* reserving space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) struct kvm_pic_state pic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) struct kvm_ioapic_state ioapic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) } chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) 4.27 KVM_SET_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) :Capability: KVM_CAP_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) :Parameters: struct kvm_irqchip (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) Sets the state of a kernel interrupt controller created with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) KVM_CREATE_IRQCHIP from a buffer provided by the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) struct kvm_irqchip {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) char dummy[512]; /* reserving space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) struct kvm_pic_state pic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) struct kvm_ioapic_state ioapic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) } chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) 4.28 KVM_XEN_HVM_CONFIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) :Capability: KVM_CAP_XEN_HVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) :Parameters: struct kvm_xen_hvm_config (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) Sets the MSR that the Xen HVM guest uses to initialize its hypercall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) page, and provides the starting address and size of the hypercall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) blobs in userspace. When the guest writes the MSR, kvm copies one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) page of a blob (32- or 64-bit, depending on the vcpu mode) to guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) struct kvm_xen_hvm_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) __u32 msr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) __u64 blob_addr_32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) __u64 blob_addr_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) __u8 blob_size_32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) __u8 blob_size_64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) __u8 pad2[30];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) 4.29 KVM_GET_CLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) :Capability: KVM_CAP_ADJUST_CLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) :Parameters: struct kvm_clock_data (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) Gets the current timestamp of kvmclock as seen by the current guest. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) such as migration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) When KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) set of bits that KVM can return in struct kvm_clock_data's flag member.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) The only flag defined now is KVM_CLOCK_TSC_STABLE. If set, the returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) value is the exact kvmclock value seen by all VCPUs at the instant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) when KVM_GET_CLOCK was called. If clear, the returned value is simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) CLOCK_MONOTONIC plus a constant offset; the offset can be modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) with KVM_SET_CLOCK. KVM will try to make all VCPUs follow this clock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) but the exact value read by each VCPU could differ, because the host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) TSC is not stable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) struct kvm_clock_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) __u64 clock; /* kvmclock current value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) __u32 pad[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) 4.30 KVM_SET_CLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) :Capability: KVM_CAP_ADJUST_CLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) :Parameters: struct kvm_clock_data (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) Sets the current timestamp of kvmclock to the value specified in its parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) such as migration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) struct kvm_clock_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) __u64 clock; /* kvmclock current value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) __u32 pad[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 4.31 KVM_GET_VCPU_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) :Capability: KVM_CAP_VCPU_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) :Extended by: KVM_CAP_INTR_SHADOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) :Architectures: x86, arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) :Parameters: struct kvm_vcpu_event (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) X86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) ^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) Gets currently pending exceptions, interrupts, and NMIs as well as related
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) states of the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) struct kvm_vcpu_events {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) __u8 injected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) __u8 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) __u8 has_error_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) __u8 pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) __u32 error_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) } exception;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) __u8 injected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) __u8 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) __u8 soft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) __u8 shadow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) } interrupt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) __u8 injected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) __u8 pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) __u8 masked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) __u8 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) } nmi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) __u32 sipi_vector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) __u8 smm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) __u8 pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) __u8 smm_inside_nmi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) __u8 latched_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) } smi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) __u8 reserved[27];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) __u8 exception_has_payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) __u64 exception_payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) The following bits are defined in the flags field:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) - KVM_VCPUEVENT_VALID_SHADOW may be set to signal that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) interrupt.shadow contains a valid state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) - KVM_VCPUEVENT_VALID_SMM may be set to signal that smi contains a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) valid state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) - KVM_VCPUEVENT_VALID_PAYLOAD may be set to signal that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) exception_has_payload, exception_payload, and exception.pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) fields contain a valid state. This bit will be set whenever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) KVM_CAP_EXCEPTION_PAYLOAD is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) ARM/ARM64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) ^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) If the guest accesses a device that is being emulated by the host kernel in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) such a way that a real device would generate a physical SError, KVM may make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) a virtual SError pending for that VCPU. This system error interrupt remains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) pending until the guest takes the exception by unmasking PSTATE.A.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) Running the VCPU may cause it to take a pending SError, or make an access that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) causes an SError to become pending. The event's description is only valid while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) the VPCU is not running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) This API provides a way to read and write the pending 'event' state that is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) visible to the guest. To save, restore or migrate a VCPU the struct representing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) the state can be read then written using this GET/SET API, along with the other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) guest-visible registers. It is not possible to 'cancel' an SError that has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) made pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) A device being emulated in user-space may also wish to generate an SError. To do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) this the events structure can be populated by user-space. The current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) should be read first, to ensure no existing SError is pending. If an existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) SError is pending, the architecture's 'Multiple SError interrupts' rules should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) be followed. (2.5.3 of DDI0587.a "ARM Reliability, Availability, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) Serviceability (RAS) Specification").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) SError exceptions always have an ESR value. Some CPUs have the ability to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) specify what the virtual SError's ESR value should be. These systems will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) advertise KVM_CAP_ARM_INJECT_SERROR_ESR. In this case exception.has_esr will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) always have a non-zero value when read, and the agent making an SError pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) should specify the ISS field in the lower 24 bits of exception.serror_esr. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) the system supports KVM_CAP_ARM_INJECT_SERROR_ESR, but user-space sets the events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) with exception.has_esr as zero, KVM will choose an ESR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) Specifying exception.has_esr on a system that does not support it will return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) -EINVAL. Setting anything other than the lower 24bits of exception.serror_esr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) will return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) It is not possible to read back a pending external abort (injected via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) KVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) directly to the virtual CPU).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) struct kvm_vcpu_events {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) __u8 serror_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) __u8 serror_has_esr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) __u8 ext_dabt_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) /* Align it to 8 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) __u8 pad[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) __u64 serror_esr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) } exception;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) __u32 reserved[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 4.32 KVM_SET_VCPU_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) :Capability: KVM_CAP_VCPU_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) :Extended by: KVM_CAP_INTR_SHADOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) :Architectures: x86, arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) :Parameters: struct kvm_vcpu_event (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) X86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) ^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) Set pending exceptions, interrupts, and NMIs as well as related states of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) See KVM_GET_VCPU_EVENTS for the data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) Fields that may be modified asynchronously by running VCPUs can be excluded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) from the update. These fields are nmi.pending, sipi_vector, smi.smm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) smi.pending. Keep the corresponding bits in the flags field cleared to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) suppress overwriting the current in-kernel state. The bits are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) =============================== ==================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) KVM_VCPUEVENT_VALID_NMI_PENDING transfer nmi.pending to the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) KVM_VCPUEVENT_VALID_SIPI_VECTOR transfer sipi_vector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) KVM_VCPUEVENT_VALID_SMM transfer the smi sub-struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) =============================== ==================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) the flags field to signal that interrupt.shadow contains a valid state and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) shall be written into the VCPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) KVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) If KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_VCPUEVENT_VALID_PAYLOAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) can be set in the flags field to signal that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) exception_has_payload, exception_payload, and exception.pending fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) contain a valid state and shall be written into the VCPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) ARM/ARM64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) ^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) User space may need to inject several types of events to the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) Set the pending SError exception state for this VCPU. It is not possible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 'cancel' an Serror that has been made pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) If the guest performed an access to I/O memory which could not be handled by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) userspace, for example because of missing instruction syndrome decode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) information or because there is no device mapped at the accessed IPA, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) userspace can ask the kernel to inject an external abort using the address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) from the exiting fault on the VCPU. It is a programming error to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) ext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) KVM_EXIT_ARM_NISV. This feature is only available if the system supports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) KVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) how userspace reports accesses for the above cases to guests, across different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) userspace implementations. Nevertheless, userspace can still emulate all Arm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) exceptions by manipulating individual registers using the KVM_SET_ONE_REG API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) See KVM_GET_VCPU_EVENTS for the data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 4.33 KVM_GET_DEBUGREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) :Capability: KVM_CAP_DEBUGREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) :Parameters: struct kvm_debugregs (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) Reads debug registers from the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) struct kvm_debugregs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) __u64 db[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) __u64 dr6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) __u64 dr7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) __u64 reserved[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 4.34 KVM_SET_DEBUGREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) :Capability: KVM_CAP_DEBUGREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) :Parameters: struct kvm_debugregs (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) Writes debug registers into the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) See KVM_GET_DEBUGREGS for the data structure. The flags field is unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) yet and must be cleared on entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 4.35 KVM_SET_USER_MEMORY_REGION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) -------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) :Capability: KVM_CAP_USER_MEMORY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) :Parameters: struct kvm_userspace_memory_region (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) struct kvm_userspace_memory_region {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) __u32 slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) __u64 guest_phys_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) __u64 memory_size; /* bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) __u64 userspace_addr; /* start of the userspace allocated memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) /* for kvm_memory_region::flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) #define KVM_MEM_READONLY (1UL << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) This ioctl allows the user to create, modify or delete a guest physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) memory slot. Bits 0-15 of "slot" specify the slot id and this value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) should be less than the maximum number of user memory slots supported per
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) VM. The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) Slots may not overlap in guest physical address space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) specifies the address space which is being modified. They must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) less than the value that KVM_CHECK_EXTENSION returns for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) KVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) are unrelated; the restriction on overlapping slots only applies within
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) each address space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) Deleting a slot is done by passing zero for memory_size. When changing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) an existing slot, it may be moved in the guest physical memory space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) or its flags may be modified, but it may not be resized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) Memory for the region is taken starting at the address denoted by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) field userspace_addr, which must point at user addressable memory for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) the entire memory slot size. Any object may back this memory, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) anonymous memory, ordinary files, and hugetlbfs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) On architectures that support a form of address tagging, userspace_addr must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) be an untagged address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) be identical. This allows large pages in the guest to be backed by large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) pages in the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) to make a new slot read-only. In this case, writes to this memory will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) posted to userspace as KVM_EXIT_MMIO exits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) the memory region are automatically reflected into the guest. For example, an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) mmap() that affects the region will be made visible immediately. Another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) example is madvise(MADV_DROP).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) The KVM_SET_MEMORY_REGION does not allow fine grained control over memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) allocation and is deprecated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 4.36 KVM_SET_TSS_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) :Capability: KVM_CAP_SET_TSS_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) :Parameters: unsigned long tss_address (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) This ioctl defines the physical address of a three-page region in the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) physical address space. The region must be within the first 4GB of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) guest physical address space and must not conflict with any memory slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) or any mmio address. The guest may malfunction if it accesses this memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) This ioctl is required on Intel-based hosts. This is needed on Intel hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) because of a quirk in the virtualization implementation (see the internals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) documentation when it pops into existence).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 4.37 KVM_ENABLE_CAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) :Capability: KVM_CAP_ENABLE_CAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) :Architectures: mips, ppc, s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) :Parameters: struct kvm_enable_cap (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) :Capability: KVM_CAP_ENABLE_CAP_VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) :Parameters: struct kvm_enable_cap (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) Not all extensions are enabled by default. Using this ioctl the application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) can enable an extension, making it available to the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) On systems that do not support this ioctl, it always fails. On systems that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) do support it, it only works for extensions that are supported for enablement.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) struct kvm_enable_cap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) /* in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) __u32 cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) The capability that is supposed to get enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) A bitfield indicating future enhancements. Has to be 0 for now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) __u64 args[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) Arguments for enabling a feature. If a feature needs initial values to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) function properly, this is the place to put them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) __u8 pad[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) for vm-wide capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 4.38 KVM_GET_MP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) :Capability: KVM_CAP_MP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) :Architectures: x86, s390, arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) :Parameters: struct kvm_mp_state (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) struct kvm_mp_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) __u32 mp_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) Returns the vcpu's current "multiprocessing state" (though also valid on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) uniprocessor guests).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) Possible values are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) ========================== ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) KVM_MP_STATE_RUNNABLE the vcpu is currently running [x86,arm/arm64]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) KVM_MP_STATE_UNINITIALIZED the vcpu is an application processor (AP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) which has not yet received an INIT signal [x86]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, and is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) now ready for a SIPI [x86]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) KVM_MP_STATE_HALTED the vcpu has executed a HLT instruction and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) is waiting for an interrupt [x86]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) KVM_MP_STATE_SIPI_RECEIVED the vcpu has just received a SIPI (vector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) accessible via KVM_GET_VCPU_EVENTS) [x86]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm/arm64]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) KVM_MP_STATE_CHECK_STOP the vcpu is in a special error state [s390]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) KVM_MP_STATE_OPERATING the vcpu is operating (running or halted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) [s390]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) KVM_MP_STATE_LOAD the vcpu is in a special load/startup state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) [s390]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) ========================== ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) in-kernel irqchip, the multiprocessing state must be maintained by userspace on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) these architectures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) For arm/arm64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) ^^^^^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) The only states that are valid are KVM_MP_STATE_STOPPED and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 4.39 KVM_SET_MP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) :Capability: KVM_CAP_MP_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) :Architectures: x86, s390, arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) :Parameters: struct kvm_mp_state (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) in-kernel irqchip, the multiprocessing state must be maintained by userspace on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) these architectures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) For arm/arm64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) ^^^^^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) The only states that are valid are KVM_MP_STATE_STOPPED and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 4.40 KVM_SET_IDENTITY_MAP_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) :Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) :Parameters: unsigned long identity (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) This ioctl defines the physical address of a one-page region in the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) physical address space. The region must be within the first 4GB of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) guest physical address space and must not conflict with any memory slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) or any mmio address. The guest may malfunction if it accesses this memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) Setting the address to 0 will result in resetting the address to its default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) (0xfffbc000).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) This ioctl is required on Intel-based hosts. This is needed on Intel hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) because of a quirk in the virtualization implementation (see the internals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) documentation when it pops into existence).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) Fails if any VCPU has already been created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 4.41 KVM_SET_BOOT_CPU_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) :Capability: KVM_CAP_SET_BOOT_CPU_ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) :Parameters: unsigned long vcpu_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) Define which vcpu is the Bootstrap Processor (BSP). Values are the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) is vcpu 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 4.42 KVM_GET_XSAVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) :Capability: KVM_CAP_XSAVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) :Parameters: struct kvm_xsave (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) struct kvm_xsave {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) __u32 region[1024];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) This ioctl would copy current vcpu's xsave struct to the userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 4.43 KVM_SET_XSAVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) :Capability: KVM_CAP_XSAVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) :Parameters: struct kvm_xsave (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) struct kvm_xsave {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) __u32 region[1024];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) This ioctl would copy userspace's xsave struct to the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 4.44 KVM_GET_XCRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) :Capability: KVM_CAP_XCRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) :Parameters: struct kvm_xcrs (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) struct kvm_xcr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) __u32 xcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) __u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) __u64 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) struct kvm_xcrs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) __u32 nr_xcrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) struct kvm_xcr xcrs[KVM_MAX_XCRS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) __u64 padding[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) This ioctl would copy current vcpu's xcrs to the userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 4.45 KVM_SET_XCRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) :Capability: KVM_CAP_XCRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) :Parameters: struct kvm_xcrs (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) struct kvm_xcr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) __u32 xcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) __u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) __u64 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) struct kvm_xcrs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) __u32 nr_xcrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) struct kvm_xcr xcrs[KVM_MAX_XCRS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) __u64 padding[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) This ioctl would set vcpu's xcr to the value userspace specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 4.46 KVM_GET_SUPPORTED_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) :Capability: KVM_CAP_EXT_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) :Parameters: struct kvm_cpuid2 (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) struct kvm_cpuid2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) __u32 nent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) __u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) struct kvm_cpuid_entry2 entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) struct kvm_cpuid_entry2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) __u32 function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) __u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) __u32 eax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) __u32 ebx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) __u32 ecx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) __u32 edx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) __u32 padding[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) This ioctl returns x86 cpuid features which are supported by both the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) hardware and kvm in its default configuration. Userspace can use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) information returned by this ioctl to construct cpuid information (for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) KVM_SET_CPUID2) that is consistent with hardware, kernel, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) userspace capabilities, and with user requirements (for example, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) user may wish to constrain cpuid to emulate older hardware, or for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) feature consistency across a cluster).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) Note that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) expose cpuid features (e.g. MONITOR) which are not supported by kvm in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) its default configuration. If userspace enables such capabilities, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) is responsible for modifying the results of this ioctl appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) with the 'nent' field indicating the number of entries in the variable-size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) array 'entries'. If the number of entries is too low to describe the cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) capabilities, an error (E2BIG) is returned. If the number is too high,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) the 'nent' field is adjusted and an error (ENOMEM) is returned. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) number is just right, the 'nent' field is adjusted to the number of valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) entries in the 'entries' array, which is then filled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) The entries returned are the host cpuid as returned by the cpuid instruction,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) with unknown or unsupported features masked out. Some features (for example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) x2apic), may not be present in the host cpu, but are exposed by kvm if it can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) emulate them efficiently. The fields in each entry are defined as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) function:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) the eax value used to obtain the entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) index:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) the ecx value used to obtain the entry (for entries that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) affected by ecx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) an OR of zero or more of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) if the index field is valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) eax, ebx, ecx, edx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) the values returned by the cpuid instruction for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) this function/index combination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) support. Instead it is reported via::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 4.47 KVM_PPC_GET_PVINFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) :Capability: KVM_CAP_PPC_GET_PVINFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) :Parameters: struct kvm_ppc_pvinfo (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) :Returns: 0 on success, !0 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) struct kvm_ppc_pvinfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) __u32 hcall[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) __u8 pad[108];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) This ioctl fetches PV specific information that need to be passed to the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) using the device tree or other means from vm context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) The hcall array defines 4 instructions that make up a hypercall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) If any additional field gets added to this structure later on, a bit for that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) additional piece of information will be set in the flags bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) The flags bitmap is defined as::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) /* the host supports the ePAPR idle hcall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) 4.52 KVM_SET_GSI_ROUTING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) :Capability: KVM_CAP_IRQ_ROUTING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) :Architectures: x86 s390 arm arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) :Parameters: struct kvm_irq_routing (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) Sets the GSI routing table entries, overwriting any previously set entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) On arm/arm64, GSI routing has the following limitation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) struct kvm_irq_routing {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) __u32 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) struct kvm_irq_routing_entry entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) No flags are specified so far, the corresponding field must be set to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) struct kvm_irq_routing_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) __u32 gsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) __u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) struct kvm_irq_routing_irqchip irqchip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) struct kvm_irq_routing_msi msi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) struct kvm_irq_routing_s390_adapter adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) struct kvm_irq_routing_hv_sint hv_sint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) __u32 pad[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) /* gsi routing entry types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) #define KVM_IRQ_ROUTING_IRQCHIP 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) #define KVM_IRQ_ROUTING_MSI 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) #define KVM_IRQ_ROUTING_S390_ADAPTER 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) #define KVM_IRQ_ROUTING_HV_SINT 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) - KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) type, specifies that the devid field contains a valid value. The per-VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) KVM_CAP_MSI_DEVID capability advertises the requirement to provide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) the device ID. If this capability is not available, userspace should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) - zero otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) struct kvm_irq_routing_irqchip {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) __u32 irqchip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) __u32 pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) struct kvm_irq_routing_msi {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) __u32 address_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) __u32 address_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) __u32 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) __u32 devid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) for the device that wrote the MSI message. For PCI, this is usually a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) BFD identifier in the lower 16 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) address_hi must be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) struct kvm_irq_routing_s390_adapter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) __u64 ind_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) __u64 summary_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) __u64 ind_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) __u32 summary_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) __u32 adapter_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) struct kvm_irq_routing_hv_sint {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) __u32 vcpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) __u32 sint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 4.55 KVM_SET_TSC_KHZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) :Capability: KVM_CAP_TSC_CONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) :Parameters: virtual tsc_khz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) Specifies the tsc frequency for the virtual machine. The unit of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) frequency is KHz.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) 4.56 KVM_GET_TSC_KHZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) :Capability: KVM_CAP_GET_TSC_KHZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) :Returns: virtual tsc-khz on success, negative value on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) Returns the tsc frequency of the guest. The unit of the return value is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) 4.57 KVM_GET_LAPIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) :Capability: KVM_CAP_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) :Parameters: struct kvm_lapic_state (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) #define KVM_APIC_REG_SIZE 0x400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) struct kvm_lapic_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) char regs[KVM_APIC_REG_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) Reads the Local APIC registers and copies them into the input argument. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) data format and layout are the same as documented in the architecture manual.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) If KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) enabled, then the format of APIC_ID register depends on the APIC mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) (reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) the APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) which is stored in bits 31-24 of the APIC register, or equivalently in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) byte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) be called after MSR_IA32_APICBASE has been set with KVM_SET_MSR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) If KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) always uses xAPIC format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) 4.58 KVM_SET_LAPIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) :Capability: KVM_CAP_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) :Parameters: struct kvm_lapic_state (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) #define KVM_APIC_REG_SIZE 0x400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) struct kvm_lapic_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) char regs[KVM_APIC_REG_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) Copies the input argument into the Local APIC registers. The data format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) and layout are the same as documented in the architecture manual.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) The format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) regs field) depends on the state of the KVM_CAP_X2APIC_API capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) See the note in KVM_GET_LAPIC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) 4.59 KVM_IOEVENTFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) :Capability: KVM_CAP_IOEVENTFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) :Parameters: struct kvm_ioeventfd (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) :Returns: 0 on success, !0 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) within the guest. A guest write in the registered address will signal the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) provided event instead of triggering an exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) struct kvm_ioeventfd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) __u64 datamatch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) __u64 addr; /* legal pio/mmio address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) __u32 len; /* 0, 1, 2, 4, or 8 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) __s32 fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) __u8 pad[36];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) For the special case of virtio-ccw devices on s390, the ioevent is matched
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) to a subchannel/virtqueue tuple instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) The following flags are defined::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) If datamatch flag is set, the event will be signaled only if the written value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) to the registered address is equal to datamatch in struct kvm_ioeventfd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) For virtio-ccw devices, addr contains the subchannel id and datamatch the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) virtqueue index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) With KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) the kernel will ignore the length of guest write and may get a faster vmexit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) The speedup may only apply to specific architectures, but the ioeventfd will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) work anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) 4.60 KVM_DIRTY_TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) :Capability: KVM_CAP_SW_TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) :Parameters: struct kvm_dirty_tlb (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) struct kvm_dirty_tlb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) __u64 bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) __u32 num_dirty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) This must be called whenever userspace has changed an entry in the shared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) TLB, prior to calling KVM_RUN on the associated vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) The "bitmap" field is the userspace address of an array. This array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) consists of a number of bits, equal to the total number of TLB entries as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) nearest multiple of 64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) The array is little-endian: the bit 0 is the least significant bit of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) first byte, bit 8 is the least significant bit of the second byte, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) This avoids any complications with differing word sizes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) The "num_dirty" field is a performance hint for KVM to determine whether it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) should skip processing the bitmap and just invalidate everything. It must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) be set to the number of set bits in the bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) 4.62 KVM_CREATE_SPAPR_TCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) :Capability: KVM_CAP_SPAPR_TCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) :Parameters: struct kvm_create_spapr_tce (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) :Returns: file descriptor for manipulating the created TCE table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) This creates a virtual TCE (translation control entry) table, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) is an IOMMU for PAPR-style virtual I/O. It is used to translate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) logical addresses used in virtual I/O into guest physical addresses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) and provides a scatter/gather capability for PAPR virtual I/O.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) /* for KVM_CAP_SPAPR_TCE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) struct kvm_create_spapr_tce {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) __u64 liobn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) __u32 window_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) The liobn field gives the logical IO bus number for which to create a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) TCE table. The window_size field specifies the size of the DMA window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) which this TCE table will translate - the table will contain one 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) bit TCE entry for every 4kiB of the DMA window.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) table has been created using this ioctl(), the kernel will handle it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) in real mode, updating the TCE table. H_PUT_TCE calls for other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) liobns will cause a vm exit and must be handled by userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) The return value is a file descriptor which can be passed to mmap(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) to map the created TCE table into userspace. This lets userspace read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) the entries written by kernel-handled H_PUT_TCE calls, and also lets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) userspace update the TCE table directly which is useful in some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) circumstances.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) 4.63 KVM_ALLOCATE_RMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) :Capability: KVM_CAP_PPC_RMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) :Parameters: struct kvm_allocate_rma (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) :Returns: file descriptor for mapping the allocated RMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) This allocates a Real Mode Area (RMA) from the pool allocated at boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) time by the kernel. An RMA is a physically-contiguous, aligned region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) of memory used on older POWER processors to provide the memory which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) will be accessed by real-mode (MMU off) accesses in a KVM guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) POWER processors support a set of sizes for the RMA that usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) includes 64MB, 128MB, 256MB and some larger powers of two.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) /* for KVM_ALLOCATE_RMA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) struct kvm_allocate_rma {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) __u64 rma_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) The return value is a file descriptor which can be passed to mmap(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) to map the allocated RMA into userspace. The mapped area can then be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) RMA for a virtual machine. The size of the RMA in bytes (which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) fixed at host kernel boot time) is returned in the rma_size field of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) the argument structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) is supported; 2 if the processor requires all virtual machines to have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) an RMA, or 1 if the processor can use an RMA but doesn't require it,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) because it supports the Virtual RMA (VRMA) facility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) 4.64 KVM_NMI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) ------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) :Capability: KVM_CAP_USER_NMI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) Queues an NMI on the thread's vcpu. Note this is well defined only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) when KVM_CREATE_IRQCHIP has not been called, since this is an interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) has been called, this interface is completely emulated within the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) following algorithm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) - pause the vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) - read the local APIC's state (KVM_GET_LAPIC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) - if so, issue KVM_NMI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) - resume the vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) Some guests configure the LINT1 NMI input to cause a panic, aiding in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) debugging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) 4.65 KVM_S390_UCAS_MAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) :Capability: KVM_CAP_S390_UCONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) :Parameters: struct kvm_s390_ucas_mapping (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) :Returns: 0 in case of success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) The parameter is defined like this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) struct kvm_s390_ucas_mapping {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) __u64 user_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) __u64 vcpu_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) __u64 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) This ioctl maps the memory at "user_addr" with the length "length" to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) the vcpu's address space starting at "vcpu_addr". All parameters need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) be aligned by 1 megabyte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) 4.66 KVM_S390_UCAS_UNMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) :Capability: KVM_CAP_S390_UCONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) :Parameters: struct kvm_s390_ucas_mapping (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) :Returns: 0 in case of success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) The parameter is defined like this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) struct kvm_s390_ucas_mapping {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) __u64 user_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) __u64 vcpu_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) __u64 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) This ioctl unmaps the memory in the vcpu's address space starting at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) "vcpu_addr" with the length "length". The field "user_addr" is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) All parameters need to be aligned by 1 megabyte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) 4.67 KVM_S390_VCPU_FAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) :Capability: KVM_CAP_S390_UCONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) :Parameters: vcpu absolute address (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) :Returns: 0 in case of success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) This call creates a page table entry on the virtual cpu's address space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) (for user controlled virtual machines) or the virtual machine's address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) space (for regular virtual machines). This only works for minor faults,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) thus it's recommended to access subject memory page via the user page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) table upfront. This is useful to handle validity intercepts for user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) controlled virtual machines to fault in the virtual cpu's lowcore pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) prior to calling the KVM_RUN ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) 4.68 KVM_SET_ONE_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) :Capability: KVM_CAP_ONE_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) :Parameters: struct kvm_one_reg (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) :Returns: 0 on success, negative value on failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) ====== ============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) ENOENT no such register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) EINVAL invalid register ID, or no such register or used with VMs in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) protected virtualization mode on s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) EPERM (arm64) register access not allowed before vcpu finalization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) ====== ============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) (These error codes are indicative only: do not rely on a specific error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) code being returned in a specific situation.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) struct kvm_one_reg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) __u64 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) __u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) Using this ioctl, a single vcpu register can be set to a specific value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) defined by user space with the passed in struct kvm_one_reg, where id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) refers to the register identifier as described below and addr is a pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) to a variable with the respective size. There can be architecture agnostic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) and architecture specific registers. Each have their own range of operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) and their own constants and width. To keep track of the implemented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) registers, find a list below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) ======= =============================== ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) Arch Register Width (bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) ======= =============================== ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) PPC KVM_REG_PPC_HIOR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) PPC KVM_REG_PPC_IAC1 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) PPC KVM_REG_PPC_IAC2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) PPC KVM_REG_PPC_IAC3 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) PPC KVM_REG_PPC_IAC4 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) PPC KVM_REG_PPC_DAC1 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) PPC KVM_REG_PPC_DAC2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) PPC KVM_REG_PPC_DABR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) PPC KVM_REG_PPC_DSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) PPC KVM_REG_PPC_PURR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) PPC KVM_REG_PPC_SPURR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) PPC KVM_REG_PPC_DAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) PPC KVM_REG_PPC_DSISR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) PPC KVM_REG_PPC_AMR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) PPC KVM_REG_PPC_UAMOR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) PPC KVM_REG_PPC_MMCR0 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) PPC KVM_REG_PPC_MMCR1 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) PPC KVM_REG_PPC_MMCRA 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) PPC KVM_REG_PPC_MMCR2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) PPC KVM_REG_PPC_MMCRS 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) PPC KVM_REG_PPC_MMCR3 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) PPC KVM_REG_PPC_SIAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) PPC KVM_REG_PPC_SDAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) PPC KVM_REG_PPC_SIER 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) PPC KVM_REG_PPC_SIER2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) PPC KVM_REG_PPC_SIER3 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) PPC KVM_REG_PPC_PMC1 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) PPC KVM_REG_PPC_PMC2 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) PPC KVM_REG_PPC_PMC3 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) PPC KVM_REG_PPC_PMC4 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) PPC KVM_REG_PPC_PMC5 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) PPC KVM_REG_PPC_PMC6 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) PPC KVM_REG_PPC_PMC7 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) PPC KVM_REG_PPC_PMC8 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) PPC KVM_REG_PPC_FPR0 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) PPC KVM_REG_PPC_FPR31 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) PPC KVM_REG_PPC_VR0 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) PPC KVM_REG_PPC_VR31 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) PPC KVM_REG_PPC_VSR0 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) PPC KVM_REG_PPC_VSR31 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) PPC KVM_REG_PPC_FPSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) PPC KVM_REG_PPC_VSCR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) PPC KVM_REG_PPC_VPA_ADDR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) PPC KVM_REG_PPC_VPA_SLB 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) PPC KVM_REG_PPC_VPA_DTL 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) PPC KVM_REG_PPC_EPCR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) PPC KVM_REG_PPC_EPR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) PPC KVM_REG_PPC_TCR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) PPC KVM_REG_PPC_TSR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) PPC KVM_REG_PPC_OR_TSR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) PPC KVM_REG_PPC_CLEAR_TSR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) PPC KVM_REG_PPC_MAS0 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) PPC KVM_REG_PPC_MAS1 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) PPC KVM_REG_PPC_MAS2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) PPC KVM_REG_PPC_MAS7_3 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) PPC KVM_REG_PPC_MAS4 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) PPC KVM_REG_PPC_MAS6 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) PPC KVM_REG_PPC_MMUCFG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) PPC KVM_REG_PPC_TLB0CFG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) PPC KVM_REG_PPC_TLB1CFG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) PPC KVM_REG_PPC_TLB2CFG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) PPC KVM_REG_PPC_TLB3CFG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) PPC KVM_REG_PPC_TLB0PS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) PPC KVM_REG_PPC_TLB1PS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) PPC KVM_REG_PPC_TLB2PS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) PPC KVM_REG_PPC_TLB3PS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) PPC KVM_REG_PPC_EPTCFG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) PPC KVM_REG_PPC_ICP_STATE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) PPC KVM_REG_PPC_VP_STATE 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) PPC KVM_REG_PPC_TB_OFFSET 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) PPC KVM_REG_PPC_SPMC1 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) PPC KVM_REG_PPC_SPMC2 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) PPC KVM_REG_PPC_IAMR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) PPC KVM_REG_PPC_TFHAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) PPC KVM_REG_PPC_TFIAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) PPC KVM_REG_PPC_TEXASR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) PPC KVM_REG_PPC_FSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) PPC KVM_REG_PPC_PSPB 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) PPC KVM_REG_PPC_EBBHR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) PPC KVM_REG_PPC_EBBRR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) PPC KVM_REG_PPC_BESCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) PPC KVM_REG_PPC_TAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) PPC KVM_REG_PPC_DPDES 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) PPC KVM_REG_PPC_DAWR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) PPC KVM_REG_PPC_DAWRX 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) PPC KVM_REG_PPC_CIABR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) PPC KVM_REG_PPC_IC 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) PPC KVM_REG_PPC_VTB 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) PPC KVM_REG_PPC_CSIGR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) PPC KVM_REG_PPC_TACR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) PPC KVM_REG_PPC_TCSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) PPC KVM_REG_PPC_PID 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) PPC KVM_REG_PPC_ACOP 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) PPC KVM_REG_PPC_VRSAVE 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) PPC KVM_REG_PPC_LPCR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) PPC KVM_REG_PPC_LPCR_64 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) PPC KVM_REG_PPC_PPR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) PPC KVM_REG_PPC_ARCH_COMPAT 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) PPC KVM_REG_PPC_DABRX 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) PPC KVM_REG_PPC_WORT 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) PPC KVM_REG_PPC_SPRG9 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) PPC KVM_REG_PPC_DBSR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) PPC KVM_REG_PPC_TIDR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) PPC KVM_REG_PPC_PSSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) PPC KVM_REG_PPC_DEC_EXPIRY 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) PPC KVM_REG_PPC_PTCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) PPC KVM_REG_PPC_TM_GPR0 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) PPC KVM_REG_PPC_TM_GPR31 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) PPC KVM_REG_PPC_TM_VSR0 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) PPC KVM_REG_PPC_TM_VSR63 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) PPC KVM_REG_PPC_TM_CR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) PPC KVM_REG_PPC_TM_LR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) PPC KVM_REG_PPC_TM_CTR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) PPC KVM_REG_PPC_TM_FPSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) PPC KVM_REG_PPC_TM_AMR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) PPC KVM_REG_PPC_TM_PPR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) PPC KVM_REG_PPC_TM_VRSAVE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) PPC KVM_REG_PPC_TM_VSCR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) PPC KVM_REG_PPC_TM_DSCR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) PPC KVM_REG_PPC_TM_TAR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) PPC KVM_REG_PPC_TM_XER 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) MIPS KVM_REG_MIPS_R0 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) MIPS KVM_REG_MIPS_R31 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) MIPS KVM_REG_MIPS_HI 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) MIPS KVM_REG_MIPS_LO 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) MIPS KVM_REG_MIPS_PC 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) MIPS KVM_REG_MIPS_CP0_INDEX 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) MIPS KVM_REG_MIPS_CP0_ENTRYLO0 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) MIPS KVM_REG_MIPS_CP0_ENTRYLO1 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) MIPS KVM_REG_MIPS_CP0_CONTEXT 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) MIPS KVM_REG_MIPS_CP0_CONTEXTCONFIG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) MIPS KVM_REG_MIPS_CP0_USERLOCAL 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) MIPS KVM_REG_MIPS_CP0_XCONTEXTCONFIG 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) MIPS KVM_REG_MIPS_CP0_PAGEMASK 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) MIPS KVM_REG_MIPS_CP0_PAGEGRAIN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) MIPS KVM_REG_MIPS_CP0_SEGCTL0 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) MIPS KVM_REG_MIPS_CP0_SEGCTL1 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) MIPS KVM_REG_MIPS_CP0_SEGCTL2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) MIPS KVM_REG_MIPS_CP0_PWBASE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) MIPS KVM_REG_MIPS_CP0_PWFIELD 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) MIPS KVM_REG_MIPS_CP0_PWSIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) MIPS KVM_REG_MIPS_CP0_WIRED 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) MIPS KVM_REG_MIPS_CP0_PWCTL 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) MIPS KVM_REG_MIPS_CP0_HWRENA 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) MIPS KVM_REG_MIPS_CP0_BADVADDR 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) MIPS KVM_REG_MIPS_CP0_BADINSTR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) MIPS KVM_REG_MIPS_CP0_BADINSTRP 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) MIPS KVM_REG_MIPS_CP0_COUNT 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) MIPS KVM_REG_MIPS_CP0_ENTRYHI 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) MIPS KVM_REG_MIPS_CP0_COMPARE 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) MIPS KVM_REG_MIPS_CP0_STATUS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) MIPS KVM_REG_MIPS_CP0_INTCTL 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) MIPS KVM_REG_MIPS_CP0_CAUSE 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) MIPS KVM_REG_MIPS_CP0_EPC 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) MIPS KVM_REG_MIPS_CP0_PRID 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) MIPS KVM_REG_MIPS_CP0_EBASE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) MIPS KVM_REG_MIPS_CP0_CONFIG 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) MIPS KVM_REG_MIPS_CP0_CONFIG1 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) MIPS KVM_REG_MIPS_CP0_CONFIG2 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) MIPS KVM_REG_MIPS_CP0_CONFIG3 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) MIPS KVM_REG_MIPS_CP0_CONFIG4 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) MIPS KVM_REG_MIPS_CP0_CONFIG5 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) MIPS KVM_REG_MIPS_CP0_CONFIG7 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) MIPS KVM_REG_MIPS_CP0_XCONTEXT 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) MIPS KVM_REG_MIPS_CP0_ERROREPC 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) MIPS KVM_REG_MIPS_CP0_KSCRATCH1 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) MIPS KVM_REG_MIPS_CP0_KSCRATCH2 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) MIPS KVM_REG_MIPS_CP0_KSCRATCH3 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) MIPS KVM_REG_MIPS_CP0_KSCRATCH4 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) MIPS KVM_REG_MIPS_CP0_KSCRATCH5 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) MIPS KVM_REG_MIPS_CP0_KSCRATCH6 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) MIPS KVM_REG_MIPS_CP0_MAAR(0..63) 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) MIPS KVM_REG_MIPS_COUNT_CTL 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) MIPS KVM_REG_MIPS_COUNT_RESUME 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) MIPS KVM_REG_MIPS_COUNT_HZ 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) MIPS KVM_REG_MIPS_FPR_32(0..31) 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) MIPS KVM_REG_MIPS_FPR_64(0..31) 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) MIPS KVM_REG_MIPS_VEC_128(0..31) 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) MIPS KVM_REG_MIPS_FCR_IR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) MIPS KVM_REG_MIPS_FCR_CSR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) MIPS KVM_REG_MIPS_MSA_IR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) MIPS KVM_REG_MIPS_MSA_CSR 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) ======= =============================== ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) ARM registers are mapped using the lower 32 bits. The upper 16 of that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) is the register group type, or coprocessor number:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) ARM core registers have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) 0x4020 0000 0010 <index into the kvm_regs struct:16>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) ARM 32-bit CP15 registers have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) ARM 64-bit CP15 registers have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) ARM CCSIDR registers are demultiplexed by CSSELR value::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) 0x4020 0000 0011 00 <csselr:8>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) ARM 32-bit VFP control registers have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) 0x4020 0000 0012 1 <regno:12>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) ARM 64-bit FP registers have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) 0x4030 0000 0012 0 <regno:12>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) ARM firmware pseudo-registers have the following bit pattern::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) 0x4030 0000 0014 <regno:16>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) arm64 registers are mapped using the lower 32 bits. The upper 16 of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) that is the register group type, or coprocessor number:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) arm64 core/FP-SIMD registers have the following id bit patterns. Note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) that the size of the access is variable, as the kvm_regs structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) contains elements ranging from 32 to 128 bits. The index is a 32bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) value in the kvm_regs structure seen as a 32bit array::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) 0x60x0 0000 0010 <index into the kvm_regs struct:16>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) Specifically:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) ======================= ========= ===== =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) Encoding Register Bits kvm_regs member
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) ======================= ========= ===== =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) 0x6030 0000 0010 0000 X0 64 regs.regs[0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) 0x6030 0000 0010 0002 X1 64 regs.regs[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) 0x6030 0000 0010 003c X30 64 regs.regs[30]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) 0x6030 0000 0010 003e SP 64 regs.sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) 0x6030 0000 0010 0040 PC 64 regs.pc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) 0x6030 0000 0010 0042 PSTATE 64 regs.pstate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) 0x6030 0000 0010 0044 SP_EL1 64 sp_el1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) 0x6030 0000 0010 0046 ELR_EL1 64 elr_el1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) 0x6030 0000 0010 0048 SPSR_EL1 64 spsr[KVM_SPSR_EL1] (alias SPSR_SVC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) 0x6030 0000 0010 004a SPSR_ABT 64 spsr[KVM_SPSR_ABT]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) 0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) 0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) 0x6060 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] [1]_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] [1]_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31] [1]_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) 0x6020 0000 0010 00d4 FPSR 32 fp_regs.fpsr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) 0x6020 0000 0010 00d5 FPCR 32 fp_regs.fpcr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) ======================= ========= ===== =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) .. [1] These encodings are not accepted for SVE-enabled vcpus. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) KVM_ARM_VCPU_INIT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) The equivalent register content can be accessed via bits [127:0] of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) the corresponding SVE Zn registers instead for vcpus that have SVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) enabled (see below).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) arm64 CCSIDR registers are demultiplexed by CSSELR value::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) 0x6020 0000 0011 00 <csselr:8>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) arm64 system registers have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) .. warning::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) Two system register IDs do not follow the specified pattern. These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) are KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT, which map to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) system registers CNTV_CVAL_EL0 and CNTVCT_EL0 respectively. These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) two had their values accidentally swapped, which means TIMER_CVAL is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) derived from the register encoding for CNTVCT_EL0 and TIMER_CNT is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) derived from the register encoding for CNTV_CVAL_EL0. As this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) API, it must remain this way.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) arm64 firmware pseudo-registers have the following bit pattern::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) 0x6030 0000 0014 <regno:16>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) arm64 SVE registers have the following bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) 0x6080 0000 0015 00 <n:5> <slice:5> Zn bits[2048*slice + 2047 : 2048*slice]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) 0x6050 0000 0015 04 <n:4> <slice:5> Pn bits[256*slice + 255 : 256*slice]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) 0x6050 0000 0015 060 <slice:5> FFR bits[256*slice + 255 : 256*slice]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) 0x6060 0000 0015 ffff KVM_REG_ARM64_SVE_VLS pseudo-register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) Access to register IDs where 2048 * slice >= 128 * max_vq will fail with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) ENOENT. max_vq is the vcpu's maximum supported vector length in 128-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) quadwords: see [2]_ below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) These registers are only accessible on vcpus for which SVE is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) See KVM_ARM_VCPU_INIT for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) In addition, except for KVM_REG_ARM64_SVE_VLS, these registers are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) accessible until the vcpu's SVE configuration has been finalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). See KVM_ARM_VCPU_INIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) and KVM_ARM_VCPU_FINALIZE for more information about this procedure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) KVM_REG_ARM64_SVE_VLS is a pseudo-register that allows the set of vector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) lengths supported by the vcpu to be discovered and configured by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) userspace. When transferred to or from user memory via KVM_GET_ONE_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) or KVM_SET_ONE_REG, the value of this register is of type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) __u64[KVM_ARM64_SVE_VLS_WORDS], and encodes the set of vector lengths as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) follows::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) __u64 vector_lengths[KVM_ARM64_SVE_VLS_WORDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) if (vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) ((vector_lengths[(vq - KVM_ARM64_SVE_VQ_MIN) / 64] >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) ((vq - KVM_ARM64_SVE_VQ_MIN) % 64)) & 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) /* Vector length vq * 16 bytes supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) /* Vector length vq * 16 bytes not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) .. [2] The maximum value vq for which the above condition is true is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) max_vq. This is the maximum vector length available to the guest on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) this vcpu, and determines which register slices are visible through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) this ioctl interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) (See Documentation/arm64/sve.rst for an explanation of the "vq"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) nomenclature.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) KVM_REG_ARM64_SVE_VLS is only accessible after KVM_ARM_VCPU_INIT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) KVM_ARM_VCPU_INIT initialises it to the best set of vector lengths that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) the host supports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) Userspace may subsequently modify it if desired until the vcpu's SVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) configuration is finalized using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) Apart from simply removing all vector lengths from the host set that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) exceed some value, support for arbitrarily chosen sets of vector lengths
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) is hardware-dependent and may not be available. Attempting to configure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) an invalid set of vector lengths via KVM_SET_ONE_REG will fail with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) After the vcpu's SVE configuration is finalized, further attempts to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) write this register will fail with EPERM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) the register group type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) MIPS core registers (see above) have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) 0x7030 0000 0000 <reg:16>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) MIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) patterns depending on whether they're 32-bit or 64-bit registers::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) Note: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) versions of the EntryLo registers regardless of the word size of the host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) hardware, host kernel, guest, and whether XPA is present in the guest, i.e.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) with the RI and XI bits (if they exist) in bits 63 and 62 respectively, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) the PFNX field starting at bit 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) MIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) 0x7030 0000 0001 01 <reg:8>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) MIPS KVM control registers (see above) have the following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) 0x7030 0000 0002 <reg:16>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) MIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) id bit patterns depending on the size of the register being accessed. They are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) always accessed according to the current guest FPU mode (Status.FR and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) Config5.FRE), i.e. as the guest would see them, and they become unpredictable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) if the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) registers (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) overlap the FPU registers::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) MIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) 0x7020 0000 0003 01 <0:3> <reg:5>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) MIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) following id bit patterns::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) 0x7020 0000 0003 02 <0:3> <reg:5>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) 4.69 KVM_GET_ONE_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) :Capability: KVM_CAP_ONE_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) :Parameters: struct kvm_one_reg (in and out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) :Returns: 0 on success, negative value on failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) Errors include:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) ======== ============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) ENOENT no such register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) EINVAL invalid register ID, or no such register or used with VMs in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) protected virtualization mode on s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) EPERM (arm64) register access not allowed before vcpu finalization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) ======== ============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) (These error codes are indicative only: do not rely on a specific error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) code being returned in a specific situation.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) This ioctl allows to receive the value of a single register implemented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) in a vcpu. The register to read is indicated by the "id" field of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) kvm_one_reg struct passed in. On success, the register value can be found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) at the memory location pointed to by "addr".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) The list of registers accessible using this interface is identical to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) list in 4.68.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) 4.70 KVM_KVMCLOCK_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) :Capability: KVM_CAP_KVMCLOCK_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) :Architectures: Any that implement pvclocks (currently x86 only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) :Parameters: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) This ioctl sets a flag accessible to the guest indicating that the specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) vCPU has been paused by the host userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) The host will set a flag in the pvclock structure that is checked from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) soft lockup watchdog. The flag is part of the pvclock structure that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) shared between guest and host, specifically the second bit of the flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) field of the pvclock_vcpu_time_info structure. It will be set exclusively by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) the host and read/cleared exclusively by the guest. The guest operation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) checking and clearing the flag must be an atomic operation so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) load-link/store-conditional, or equivalent must be used. There are two cases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) where the guest will clear the flag: when the soft lockup watchdog timer resets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) itself or when a soft lockup is detected. This ioctl can be called any time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) after pausing the vcpu, but before it is resumed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) 4.71 KVM_SIGNAL_MSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) :Capability: KVM_CAP_SIGNAL_MSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) :Architectures: x86 arm arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) :Parameters: struct kvm_msi (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) :Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) Directly inject a MSI message. Only valid with in-kernel irqchip that handles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) MSI messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) struct kvm_msi {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) __u32 address_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) __u32 address_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) __u32 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) __u32 devid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) __u8 pad[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) KVM_CAP_MSI_DEVID capability advertises the requirement to provide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) the device ID. If this capability is not available, userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) for the device that wrote the MSI message. For PCI, this is usually a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) BFD identifier in the lower 16 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) address_hi must be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) 4.71 KVM_CREATE_PIT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) :Capability: KVM_CAP_PIT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) :Parameters: struct kvm_pit_config (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) Creates an in-kernel device model for the i8254 PIT. This call is only valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) parameters have to be passed::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) struct kvm_pit_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) __u32 pad[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) Valid flags are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) PIT timer interrupts may use a per-VM kernel thread for injection. If it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) exists, this thread will have a name of the following pattern::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) kvm-pit/<owner-process-pid>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) When running a guest with elevated priorities, the scheduling parameters of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) this thread may have to be adjusted accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) This IOCTL replaces the obsolete KVM_CREATE_PIT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) 4.72 KVM_GET_PIT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) :Capability: KVM_CAP_PIT_STATE2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) :Parameters: struct kvm_pit_state2 (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) Retrieves the state of the in-kernel PIT model. Only valid after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) KVM_CREATE_PIT2. The state is returned in the following structure::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) struct kvm_pit_state2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) struct kvm_pit_channel_state channels[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) __u32 reserved[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) Valid flags are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) /* disable PIT in HPET legacy mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) This IOCTL replaces the obsolete KVM_GET_PIT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) 4.73 KVM_SET_PIT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) :Capability: KVM_CAP_PIT_STATE2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) :Parameters: struct kvm_pit_state2 (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) See KVM_GET_PIT2 for details on struct kvm_pit_state2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) This IOCTL replaces the obsolete KVM_SET_PIT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) 4.74 KVM_PPC_GET_SMMU_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) :Capability: KVM_CAP_PPC_GET_SMMU_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) :Parameters: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) This populates and returns a structure describing the features of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) the "Server" class MMU emulation supported by KVM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) This can in turn be used by userspace to generate the appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) device-tree properties for the guest operating system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) The structure contains some global information, followed by an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) array of supported segment page sizes::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) struct kvm_ppc_smmu_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) __u32 slb_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) The supported flags are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) - KVM_PPC_PAGE_SIZES_REAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) When that flag is set, guest page sizes must "fit" the backing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) store page sizes. When not set, any page size in the list can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) be used regardless of how they are backed by userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) - KVM_PPC_1T_SEGMENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) The emulated MMU supports 1T segments in addition to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) standard 256M ones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) - KVM_PPC_NO_HASH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) This flag indicates that HPT guests are not supported by KVM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) thus all guests must use radix MMU mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) The "slb_size" field indicates how many SLB entries are supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) The "sps" array contains 8 entries indicating the supported base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) page sizes for a segment in increasing order. Each entry is defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) as follow::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) struct kvm_ppc_one_seg_page_size {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) __u32 page_shift; /* Base page shift of segment (or 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) __u32 slb_enc; /* SLB encoding for BookS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) An entry with a "page_shift" of 0 is unused. Because the array is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) organized in increasing order, a lookup can stop when encoutering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) such an entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) The "slb_enc" field provides the encoding to use in the SLB for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) page size. The bits are in positions such as the value can directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) be OR'ed into the "vsid" argument of the slbmte instruction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) The "enc" array is a list which for each of those segment base page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) size provides the list of supported actual page sizes (which can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) only larger or equal to the base page size), along with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) corresponding encoding in the hash PTE. Similarly, the array is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) 8 entries sorted by increasing sizes and an entry with a "0" shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) is an empty entry and a terminator::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) struct kvm_ppc_one_page_size {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) __u32 page_shift; /* Page shift (or 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) __u32 pte_enc; /* Encoding in the HPTE (>>12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) The "pte_enc" field provides a value that can OR'ed into the hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) PTE's RPN field (ie, it needs to be shifted left by 12 to OR it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) into the hash PTE second double word).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) 4.75 KVM_IRQFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) :Capability: KVM_CAP_IRQFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) :Architectures: x86 s390 arm arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) :Parameters: struct kvm_irqfd (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) Allows setting an eventfd to directly trigger a guest interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) kvm_irqfd.fd specifies the file descriptor to use as the eventfd and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) an event is triggered on the eventfd, an interrupt is injected into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) the guest using the specified gsi pin. The irqfd is removed using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) and kvm_irqfd.gsi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) mechanism allowing emulation of level-triggered, irqfd-based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) additional eventfd in the kvm_irqfd.resamplefd field. When operating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) in resample mode, posting of an interrupt through kvm_irq.fd asserts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) the specified gsi in the irqchip. When the irqchip is resampled, such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) as from an EOI, the gsi is de-asserted and the user is notified via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) kvm_irqfd.resamplefd. It is the user's responsibility to re-queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) the interrupt if the device making use of it still requires service.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) Note that closing the resamplefd is not sufficient to disable the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) On arm/arm64, gsi routing being supported, the following can happen:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) - in case no routing entry is associated to this gsi, injection fails
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) - in case the gsi is associated to an irqchip routing entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) irqchip.pin + 32 corresponds to the injected SPI ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) - in case the gsi is associated to an MSI routing entry, the MSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) message and device ID are translated into an LPI (support restricted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) to GICv3 ITS in-kernel emulation).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) 4.76 KVM_PPC_ALLOCATE_HTAB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) :Capability: KVM_CAP_PPC_ALLOC_HTAB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) :Parameters: Pointer to u32 containing hash table order (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) This requests the host kernel to allocate an MMU hash table for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) guest using the PAPR paravirtualization interface. This only does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) anything if the kernel is configured to use the Book 3S HV style of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) virtualization. Otherwise the capability doesn't exist and the ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) returns an ENOTTY error. The rest of this description assumes Book 3S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) HV.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) There must be no vcpus running when this ioctl is called; if there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) are, it will do nothing and return an EBUSY error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) The parameter is a pointer to a 32-bit unsigned integer variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) containing the order (log base 2) of the desired size of the hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) table, which must be between 18 and 46. On successful return from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) ioctl, the value will not be changed by the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) If no hash table has been allocated when any vcpu is asked to run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) (with the KVM_RUN ioctl), the host kernel will allocate a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) default-sized hash table (16 MB).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) If this ioctl is called when a hash table has already been allocated,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) with a different order from the existing hash table, the existing hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) table will be freed and a new one allocated. If this is ioctl is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) called when a hash table has already been allocated of the same order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) as specified, the kernel will clear out the existing hash table (zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) all HPTEs). In either case, if the guest is using the virtualized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) real-mode area (VRMA) facility, the kernel will re-create the VMRA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) HPTEs on the next KVM_RUN of any vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 4.77 KVM_S390_INTERRUPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) :Type: vm ioctl, vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) :Parameters: struct kvm_s390_interrupt (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) Allows to inject an interrupt to the guest. Interrupts can be floating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) Interrupt parameters are passed via kvm_s390_interrupt::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) struct kvm_s390_interrupt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) __u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) __u32 parm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) __u64 parm64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) type can be one of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) KVM_S390_SIGP_STOP (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) - sigp stop; optional flags in parm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) KVM_S390_PROGRAM_INT (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) - program check; code in parm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) KVM_S390_SIGP_SET_PREFIX (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) - sigp set prefix; prefix address in parm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) KVM_S390_RESTART (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) - restart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) KVM_S390_INT_CLOCK_COMP (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) - clock comparator interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) KVM_S390_INT_CPU_TIMER (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) - CPU timer interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) KVM_S390_INT_VIRTIO (vm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) - virtio external interrupt; external interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) parameters in parm and parm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) KVM_S390_INT_SERVICE (vm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) - sclp external interrupt; sclp parameter in parm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) KVM_S390_INT_EMERGENCY (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) - sigp emergency; source cpu in parm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) KVM_S390_INT_EXTERNAL_CALL (vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) - sigp external call; source cpu in parm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) - compound value to indicate an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) I/O interruption parameters in parm (subchannel) and parm64 (intparm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) interruption subclass)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) KVM_S390_MCHK (vm, vcpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) - machine check interrupt; cr 14 bits in parm, machine check interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) code in parm64 (note that machine checks needing further payload are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) supported by this ioctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) This is an asynchronous vcpu ioctl and can be invoked from any thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) 4.78 KVM_PPC_GET_HTAB_FD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) :Capability: KVM_CAP_PPC_HTAB_FD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) :Parameters: Pointer to struct kvm_get_htab_fd (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) :Returns: file descriptor number (>= 0) on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) This returns a file descriptor that can be used either to read out the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) entries in the guest's hashed page table (HPT), or to write entries to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) initialize the HPT. The returned fd can only be written to if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) can only be read if that bit is clear. The argument struct looks like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) /* For KVM_PPC_GET_HTAB_FD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) struct kvm_get_htab_fd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) __u64 start_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) __u64 reserved[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) /* Values for kvm_get_htab_fd.flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) #define KVM_GET_HTAB_WRITE ((__u64)0x2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) The 'start_index' field gives the index in the HPT of the entry at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) which to start reading. It is ignored when writing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) Reads on the fd will initially supply information about all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) "interesting" HPT entries. Interesting entries are those with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) all entries. When the end of the HPT is reached, the read() will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) return. If read() is called again on the fd, it will start again from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) the beginning of the HPT, but will only return HPT entries that have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) changed since they were last read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) Data read or written is structured as a header (8 bytes) followed by a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) series of valid HPT entries (16 bytes) each. The header indicates how
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) many valid HPT entries there are and how many invalid entries follow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) the valid entries. The invalid entries are not represented explicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) in the stream. The header format is::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) struct kvm_get_htab_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) __u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) __u16 n_valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) __u16 n_invalid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) Writes to the fd create HPT entries starting at the index given in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) header; first 'n_valid' valid entries with contents from the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) written, then 'n_invalid' invalid entries, invalidating any previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) valid entries found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) 4.79 KVM_CREATE_DEVICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) :Capability: KVM_CAP_DEVICE_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) :Parameters: struct kvm_create_device (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) ====== =======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) ENODEV The device type is unknown or unsupported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) EEXIST Device already created, and this type of device may not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) be instantiated multiple times
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) ====== =======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) Other error conditions may be defined by individual device types or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) have their standard meanings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) Creates an emulated device in the kernel. The file descriptor returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) device type is supported (not necessarily whether it can be created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) in the current vm).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) Individual devices should not define flags. Attributes should be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) for specifying any behavior that is not implied by the device type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) struct kvm_create_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) __u32 type; /* in: KVM_DEV_TYPE_xxx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) __u32 fd; /* out: device handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) --------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) KVM_CAP_VCPU_ATTRIBUTES for vcpu device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) :Type: device ioctl, vm ioctl, vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) :Parameters: struct kvm_device_attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) ===== =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) ENXIO The group or attribute is unknown/unsupported for this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) or hardware support is missing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) EPERM The attribute cannot (currently) be accessed this way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) (e.g. read-only attribute, or attribute that only makes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) sense when the device is in a different state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) ===== =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) Other error conditions may be defined by individual device types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) Gets/sets a specified piece of device configuration and/or state. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) semantics are device-specific. See individual device documentation in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) the "devices" directory. As with ONE_REG, the size of the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) transferred is defined by the particular attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) struct kvm_device_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) __u32 flags; /* no flags currently defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) __u32 group; /* device-defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) __u64 attr; /* group-defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) __u64 addr; /* userspace address of attr data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) 4.81 KVM_HAS_DEVICE_ATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) KVM_CAP_VCPU_ATTRIBUTES for vcpu device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) :Type: device ioctl, vm ioctl, vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) :Parameters: struct kvm_device_attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) ===== =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) ENXIO The group or attribute is unknown/unsupported for this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) or hardware support is missing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) ===== =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) Tests whether a device supports a particular attribute. A successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) return indicates the attribute is implemented. It does not necessarily
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) indicate that the attribute can be read or written in the device's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) current state. "addr" is ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) 4.82 KVM_ARM_VCPU_INIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) :Architectures: arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) :Parameters: struct kvm_vcpu_init (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) ====== =================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) EINVAL the target is unknown, or the combination of features is invalid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) ENOENT a features bit specified is unknown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) ====== =================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) This tells KVM what type of CPU to present to the guest, and what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) optional features it should have. This will cause a reset of the cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) registers to their initial values. If this is not called, KVM_RUN will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) return ENOEXEC for that vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) Note that because some registers reflect machine topology, all vcpus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) should be created before this ioctl is invoked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) Userspace can call this function multiple times for a given vcpu, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) after the vcpu has been run. This will reset the vcpu to its initial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) state. All calls to this function after the initial call must use the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) target and same set of feature flags, otherwise EINVAL will be returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) Possible features:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) and execute guest code when KVM_RUN is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) backward compatible with v0.2) for the CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) Depends on KVM_CAP_ARM_PSCI_0_2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) Depends on KVM_CAP_ARM_PMU_V3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) for arm64 only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) for arm64 only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) Depends on KVM_CAP_ARM_PTRAUTH_GENERIC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) - KVM_ARM_VCPU_SVE: Enables SVE for the CPU (arm64 only).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) Depends on KVM_CAP_ARM_SVE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) Requires KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) * After KVM_ARM_VCPU_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) - KVM_REG_ARM64_SVE_VLS may be read using KVM_GET_ONE_REG: the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) initial value of this pseudo-register indicates the best set of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) vector lengths possible for a vcpu on this host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) * Before KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) - KVM_RUN and KVM_GET_REG_LIST are not available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) - KVM_GET_ONE_REG and KVM_SET_ONE_REG cannot be used to access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) the scalable archietctural SVE registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) KVM_REG_ARM64_SVE_FFR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) - KVM_REG_ARM64_SVE_VLS may optionally be written using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) KVM_SET_ONE_REG, to modify the set of vector lengths available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) for the vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) * After KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) - the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) no longer be written using KVM_SET_ONE_REG.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) 4.83 KVM_ARM_PREFERRED_TARGET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) -----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) :Architectures: arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) :Parameters: struct kvm_vcpu_init (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) ====== ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) ENODEV no preferred target available for the host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) ====== ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) This queries KVM for preferred CPU target type which can be emulated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) by KVM on underlying host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) The ioctl returns struct kvm_vcpu_init instance containing information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) about preferred CPU target type and recommended features for it. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) kvm_vcpu_init->features bitmap returned will have feature bits set if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) the preferred target recommends setting these features, but this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) not mandatory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) The information returned by this ioctl can be used to prepare an instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) VCPU matching underlying host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) 4.84 KVM_GET_REG_LIST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) :Architectures: arm, arm64, mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) :Parameters: struct kvm_reg_list (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) ===== ==============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) E2BIG the reg index list is too big to fit in the array specified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) the user (the number required will be written into n).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) ===== ==============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) struct kvm_reg_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) __u64 n; /* number of registers in reg[] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) __u64 reg[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) This ioctl returns the guest registers that are supported for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) -----------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) :Capability: KVM_CAP_ARM_SET_DEVICE_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) :Architectures: arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) :Parameters: struct kvm_arm_device_address (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) ====== ============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) ENODEV The device id is unknown
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) ENXIO Device not supported on current system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) EEXIST Address already set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) E2BIG Address outside guest physical address space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) EBUSY Address overlaps with other device range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) ====== ============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) struct kvm_arm_device_addr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) __u64 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) __u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) Specify a device address in the guest's physical address space where guests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) can access emulated or directly exposed devices, which the host kernel needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) to know about. The id field is an architecture specific identifier for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) specific device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) ARM/arm64 divides the id field into two parts, a device id and an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) address type id specific to the individual device::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) field: | 0x00000000 | device id | addr type id |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) ARM/arm64 currently only require this when using the in-kernel GIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) as the device id. When setting the base address for the guest's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) mapping of the VGIC virtual CPU and distributor interface, the ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) must be called after calling KVM_CREATE_IRQCHIP, but before calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) base addresses will return -EEXIST.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) should be used instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) 4.86 KVM_PPC_RTAS_DEFINE_TOKEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) :Capability: KVM_CAP_PPC_RTAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) :Parameters: struct kvm_rtas_token_args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) Defines a token value for a RTAS (Run Time Abstraction Services)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) service in order to allow it to be handled in the kernel. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) argument struct gives the name of the service, which must be the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) of a service that has a kernel-side implementation. If the token
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) value is non-zero, it will be associated with that service, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) subsequent RTAS calls by the guest specifying that token will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) handled by the kernel. If the token value is 0, then any token
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) associated with the service will be forgotten, and subsequent RTAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) calls by the guest for that service will be passed to userspace to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) handled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) 4.87 KVM_SET_GUEST_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) :Capability: KVM_CAP_SET_GUEST_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) :Architectures: x86, s390, ppc, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) :Parameters: struct kvm_guest_debug (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) struct kvm_guest_debug {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) __u32 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) struct kvm_guest_debug_arch arch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) Set up the processor specific debug registers and configure vcpu for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) handling guest debug events. There are two parts to the structure, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) first a control bitfield indicates the type of debug events to handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) when running. Common control bits are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) - KVM_GUESTDBG_ENABLE: guest debugging is enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) - KVM_GUESTDBG_SINGLESTEP: the next run should single-step
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) The top 16 bits of the control field are architecture specific control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) flags which can include the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390, arm64]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) For example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) are enabled in memory so we need to ensure breakpoint exceptions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) correctly trapped and the KVM run loop exits at the breakpoint and not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) running off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) we need to ensure the guest vCPUs architecture specific registers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) updated to the correct (supplied) values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) The second part of the structure is architecture specific and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) typically contains a set of debug registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) For arm64 the number of debug registers is implementation defined and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) indicating the number of supported registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) For ppc, the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability indicates whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) the single-step debug event (KVM_GUESTDBG_SINGLESTEP) is supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) When debug events exit the main run loop with the reason
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) structure containing architecture specific debug information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) 4.88 KVM_GET_EMULATED_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) :Capability: KVM_CAP_EXT_EMUL_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) :Parameters: struct kvm_cpuid2 (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) struct kvm_cpuid2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) __u32 nent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) struct kvm_cpuid_entry2 entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) The member 'flags' is used for passing flags from userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) struct kvm_cpuid_entry2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) __u32 function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) __u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) __u32 eax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) __u32 ebx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) __u32 ecx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) __u32 edx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) __u32 padding[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) This ioctl returns x86 cpuid features which are emulated by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) kvm.Userspace can use the information returned by this ioctl to query
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) which features are emulated by kvm instead of being present natively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) structure with the 'nent' field indicating the number of entries in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) the variable-size array 'entries'. If the number of entries is too low
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) to describe the cpu capabilities, an error (E2BIG) is returned. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) number is too high, the 'nent' field is adjusted and an error (ENOMEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) is returned. If the number is just right, the 'nent' field is adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) to the number of valid entries in the 'entries' array, which is then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) filled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) The entries returned are the set CPUID bits of the respective features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) which kvm emulates, as returned by the CPUID instruction, with unknown
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) or unsupported feature bits cleared.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) Features like x2apic, for example, may not be present in the host cpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) emulated efficiently and thus not included here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) The fields in each entry are defined as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) function:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) the eax value used to obtain the entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) index:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) the ecx value used to obtain the entry (for entries that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) affected by ecx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) an OR of zero or more of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) if the index field is valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) eax, ebx, ecx, edx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) the values returned by the cpuid instruction for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) this function/index combination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) 4.89 KVM_S390_MEM_OP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) :Capability: KVM_CAP_S390_MEM_OP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) :Parameters: struct kvm_s390_mem_op (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) :Returns: = 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) < 0 on generic error (e.g. -EFAULT or -ENOMEM),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) > 0 if an exception occurred while walking the page tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) Read or write data from/to the logical (virtual) memory of a VCPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) Parameters are specified via the following structure::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) struct kvm_s390_mem_op {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) __u64 gaddr; /* the guest address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) __u64 flags; /* flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) __u32 size; /* amount of bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) __u32 op; /* type of operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) __u64 buf; /* buffer in userspace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) __u8 ar; /* the access register number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) __u8 reserved[31]; /* should be set to 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) The type of operation is specified in the "op" field. It is either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) KVM_S390_MEMOP_LOGICAL_READ for reading from logical memory space or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) KVM_S390_MEMOP_LOGICAL_WRITE for writing to logical memory space. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) KVM_S390_MEMOP_F_CHECK_ONLY flag can be set in the "flags" field to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) whether the corresponding memory access would create an access exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) (without touching the data in the memory at the destination). In case an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) access exception occurred while walking the MMU tables of the guest, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) ioctl returns a positive error number to indicate the type of exception.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) This exception is also raised directly at the corresponding VCPU if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) flag KVM_S390_MEMOP_F_INJECT_EXCEPTION is set in the "flags" field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) The start address of the memory region has to be specified in the "gaddr"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) field, and the length of the region in the "size" field (which must not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) be 0). The maximum value for "size" can be obtained by checking the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) KVM_CAP_S390_MEM_OP capability. "buf" is the buffer supplied by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) userspace application where the read data should be written to for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) KVM_S390_MEMOP_LOGICAL_READ, or where the data that should be written is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) stored for a KVM_S390_MEMOP_LOGICAL_WRITE. When KVM_S390_MEMOP_F_CHECK_ONLY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) is specified, "buf" is unused and can be NULL. "ar" designates the access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) register number to be used; the valid range is 0..15.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) The "reserved" field is meant for future extensions. It is not used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) KVM with the currently defined set of flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) 4.90 KVM_S390_GET_SKEYS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) :Capability: KVM_CAP_S390_SKEYS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) :Parameters: struct kvm_s390_skeys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) :Returns: 0 on success, KVM_S390_GET_KEYS_NONE if guest is not using storage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) keys, negative value on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) This ioctl is used to get guest storage key values on the s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) architecture. The ioctl takes parameters via the kvm_s390_skeys struct::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) struct kvm_s390_skeys {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) __u64 start_gfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) __u64 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) __u64 skeydata_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) __u32 reserved[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) The start_gfn field is the number of the first guest frame whose storage keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) you want to get.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) The count field is the number of consecutive frames (starting from start_gfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) whose storage keys to get. The count field must be at least 1 and the maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) will cause the ioctl to return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) The skeydata_addr field is the address to a buffer large enough to hold count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) bytes. This buffer will be filled with storage key data by the ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) 4.91 KVM_S390_SET_SKEYS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) :Capability: KVM_CAP_S390_SKEYS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) :Parameters: struct kvm_s390_skeys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) :Returns: 0 on success, negative value on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) This ioctl is used to set guest storage key values on the s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) See section on KVM_S390_GET_SKEYS for struct definition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) The start_gfn field is the number of the first guest frame whose storage keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) you want to set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) The count field is the number of consecutive frames (starting from start_gfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) whose storage keys to get. The count field must be at least 1 and the maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) allowed value is defined as KVM_S390_SKEYS_ALLOC_MAX. Values outside this range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) will cause the ioctl to return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) The skeydata_addr field is the address to a buffer containing count bytes of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) storage keys. Each byte in the buffer will be set as the storage key for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) single frame starting at start_gfn for count frames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) Note: If any architecturally invalid key value is found in the given data then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) the ioctl will return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) 4.92 KVM_S390_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) :Capability: KVM_CAP_S390_INJECT_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) :Parameters: struct kvm_s390_irq (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) ====== =================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) EINVAL interrupt type is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) type is KVM_S390_SIGP_STOP and flag parameter is invalid value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) type is KVM_S390_INT_EXTERNAL_CALL and code is bigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) than the maximum of VCPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) EBUSY type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) type is KVM_S390_SIGP_STOP and a stop irq is already pending,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) is already pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) ====== =================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) Allows to inject an interrupt to the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) Using struct kvm_s390_irq as a parameter allows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) to inject additional payload which is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) possible via KVM_S390_INTERRUPT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) Interrupt parameters are passed via kvm_s390_irq::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) struct kvm_s390_irq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) __u64 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) struct kvm_s390_io_info io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) struct kvm_s390_ext_info ext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) struct kvm_s390_pgm_info pgm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) struct kvm_s390_emerg_info emerg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) struct kvm_s390_extcall_info extcall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) struct kvm_s390_prefix_info prefix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) struct kvm_s390_stop_info stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) struct kvm_s390_mchk_info mchk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) char reserved[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) type can be one of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) - KVM_S390_SIGP_STOP - sigp stop; parameter in .stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) - KVM_S390_PROGRAM_INT - program check; parameters in .pgm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) - KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) - KVM_S390_RESTART - restart; no parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) - KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) - KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) - KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) - KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) - KVM_S390_MCHK - machine check interrupt; parameters in .mchk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) This is an asynchronous vcpu ioctl and can be invoked from any thread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) 4.94 KVM_S390_GET_IRQ_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) :Capability: KVM_CAP_S390_IRQ_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) :Parameters: struct kvm_s390_irq_state (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) :Returns: >= number of bytes copied into buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) -EINVAL if buffer size is 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) -ENOBUFS if buffer size is too small to fit all pending interrupts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) -EFAULT if the buffer address was invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) This ioctl allows userspace to retrieve the complete state of all currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) pending interrupts in a single buffer. Use cases include migration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) and introspection. The parameter structure contains the address of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) userspace buffer and its length::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) struct kvm_s390_irq_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) __u64 buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) __u32 flags; /* will stay unused for compatibility reasons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) __u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) __u32 reserved[4]; /* will stay unused for compatibility reasons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) Userspace passes in the above struct and for each pending interrupt a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) struct kvm_s390_irq is copied to the provided buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) The structure contains a flags and a reserved field for future extensions. As
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) the kernel never checked for flags == 0 and QEMU never pre-zeroed flags and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) reserved, these fields can not be used in the future without breaking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) If -ENOBUFS is returned the buffer provided was too small and userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) may retry with a bigger buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) 4.95 KVM_S390_SET_IRQ_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) :Capability: KVM_CAP_S390_IRQ_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) :Parameters: struct kvm_s390_irq_state (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) -EFAULT if the buffer address was invalid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) -EINVAL for an invalid buffer length (see below),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) -EBUSY if there were already interrupts pending,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) errors occurring when actually injecting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) interrupt. See KVM_S390_IRQ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) This ioctl allows userspace to set the complete state of all cpu-local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) interrupts currently pending for the vcpu. It is intended for restoring
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) interrupt state after a migration. The input parameter is a userspace buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) containing a struct kvm_s390_irq_state::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) struct kvm_s390_irq_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) __u64 buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) __u32 flags; /* will stay unused for compatibility reasons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) __u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) __u32 reserved[4]; /* will stay unused for compatibility reasons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) The restrictions for flags and reserved apply as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) (see KVM_S390_GET_IRQ_STATE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) The userspace memory referenced by buf contains a struct kvm_s390_irq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) for each interrupt to be injected into the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) If one of the interrupts could not be injected for some reason the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) ioctl aborts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) which is the maximum number of possibly pending cpu-local interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) 4.96 KVM_SMI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) ------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) :Capability: KVM_CAP_X86_SMM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) Queues an SMI on the thread's vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) 4.97 KVM_CAP_PPC_MULTITCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) :Capability: KVM_CAP_PPC_MULTITCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) :Type: vm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) This capability means the kernel is capable of handling hypercalls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) space. This significantly accelerates DMA operations for PPC KVM guests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) User space should expect that its handlers for these hypercalls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) are not going to be called if user space previously registered LIOBN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) in KVM (via KVM_CREATE_SPAPR_TCE or similar calls).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) user space might have to advertise it for the guest. For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) present in the "ibm,hypertas-functions" device-tree property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) The hypercalls mentioned above may or may not be processed successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) in the kernel based fast path. If they can not be handled by the kernel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) they will get passed on to user space. So user space still has to have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) an implementation for these despite the in kernel acceleration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) This capability is always enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) 4.98 KVM_CREATE_SPAPR_TCE_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) :Capability: KVM_CAP_SPAPR_TCE_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) :Parameters: struct kvm_create_spapr_tce_64 (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) :Returns: file descriptor for manipulating the created TCE table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) This is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) windows, described in 4.62 KVM_CREATE_SPAPR_TCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) This capability uses extended struct in ioctl interface::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) /* for KVM_CAP_SPAPR_TCE_64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) struct kvm_create_spapr_tce_64 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) __u64 liobn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) __u32 page_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) __u64 offset; /* in pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) __u64 size; /* in pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) The aim of extension is to support an additional bigger DMA window with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) a variable page size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) KVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) a bus offset of the corresponding DMA window, @size and @offset are numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) of IOMMU pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) @flags are not used at the moment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) The rest of functionality is identical to KVM_CREATE_SPAPR_TCE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) 4.99 KVM_REINJECT_CONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) :Capability: KVM_CAP_REINJECT_CONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) :Parameters: struct kvm_reinject_control (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) -EFAULT if struct kvm_reinject_control cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) i8254 (PIT) has two modes, reinject and !reinject. The default is reinject,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) where KVM queues elapsed i8254 ticks and monitors completion of interrupt from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) vector(s) that i8254 injects. Reinject mode dequeues a tick and injects its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) interrupt whenever there isn't a pending interrupt from i8254.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) !reinject mode injects an interrupt as soon as a tick arrives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) struct kvm_reinject_control {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) __u8 pit_reinject;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) __u8 reserved[31];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) pit_reinject = 0 (!reinject mode) is recommended, unless running an old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) operating system that uses the PIT for timing (e.g. Linux 2.4.x).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) 4.100 KVM_PPC_CONFIGURE_V3_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) :Capability: KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) :Parameters: struct kvm_ppc_mmuv3_cfg (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) -EINVAL if the configuration is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) This ioctl controls whether the guest will use radix or HPT (hashed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) page table) translation, and sets the pointer to the process table for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) struct kvm_ppc_mmuv3_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) __u64 process_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) There are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) KVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) to use radix tree translation, and if clear, to use HPT translation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) KVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) to be able to use the global TLB and SLB invalidation instructions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) if clear, the guest may not use these instructions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) The process_table field specifies the address and size of the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) process table, which is in the guest's space. This field is formatted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) as the second doubleword of the partition table entry, as defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) the Power ISA V3.00, Book III section 5.7.6.1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) 4.101 KVM_PPC_GET_RMMU_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) :Capability: KVM_CAP_PPC_RADIX_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) :Parameters: struct kvm_ppc_rmmu_info (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) -EFAULT if struct kvm_ppc_rmmu_info cannot be written,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) -EINVAL if no useful information can be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) This ioctl returns a structure containing two things: (a) a list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) containing supported radix tree geometries, and (b) a list that maps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) page sizes to put in the "AP" (actual page size) field for the tlbie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) (TLB invalidate entry) instruction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) struct kvm_ppc_rmmu_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) struct kvm_ppc_radix_geom {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) __u8 page_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) __u8 level_bits[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) __u8 pad[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) } geometries[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) __u32 ap_encodings[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) The geometries[] field gives up to 8 supported geometries for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) radix page table, in terms of the log base 2 of the smallest page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) size, and the number of bits indexed at each level of the tree, from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) the PTE level up to the PGD level in that order. Any unused entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) will have 0 in the page_shift field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) The ap_encodings gives the supported page sizes and their AP field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) encodings, encoded with the AP value in the top 3 bits and the log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) base 2 of the page size in the bottom 6 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) 4.102 KVM_PPC_RESIZE_HPT_PREPARE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) --------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) :Capability: KVM_CAP_SPAPR_RESIZE_HPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) :Parameters: struct kvm_ppc_resize_hpt (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) :Returns: 0 on successful completion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) >0 if a new HPT is being prepared, the value is an estimated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) number of milliseconds until preparation is complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) -EFAULT if struct kvm_reinject_control cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) -EINVAL if the supplied shift or flags are invalid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) -ENOMEM if unable to allocate the new HPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) -ENOSPC if there was a hash collision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) struct kvm_ppc_rmmu_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) struct kvm_ppc_radix_geom {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) __u8 page_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) __u8 level_bits[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) __u8 pad[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) } geometries[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) __u32 ap_encodings[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) The geometries[] field gives up to 8 supported geometries for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) radix page table, in terms of the log base 2 of the smallest page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) size, and the number of bits indexed at each level of the tree, from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) the PTE level up to the PGD level in that order. Any unused entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) will have 0 in the page_shift field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) The ap_encodings gives the supported page sizes and their AP field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) encodings, encoded with the AP value in the top 3 bits and the log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) base 2 of the page size in the bottom 6 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) 4.102 KVM_PPC_RESIZE_HPT_PREPARE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) --------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) :Capability: KVM_CAP_SPAPR_RESIZE_HPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) :Parameters: struct kvm_ppc_resize_hpt (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) :Returns: 0 on successful completion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) >0 if a new HPT is being prepared, the value is an estimated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) number of milliseconds until preparation is complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) -EFAULT if struct kvm_reinject_control cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) -EINVAL if the supplied shift or flags are invalid,when moving existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) HPT entries to the new HPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) -EIO on other error conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) Used to implement the PAPR extension for runtime resizing of a guest's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) Hashed Page Table (HPT). Specifically this starts, stops or monitors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) the preparation of a new potential HPT for the guest, essentially
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) implementing the H_RESIZE_HPT_PREPARE hypercall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) If called with shift > 0 when there is no pending HPT for the guest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) this begins preparation of a new pending HPT of size 2^(shift) bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) It then returns a positive integer with the estimated number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) milliseconds until preparation is complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) If called when there is a pending HPT whose size does not match that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) requested in the parameters, discards the existing pending HPT and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) creates a new one as above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) If called when there is a pending HPT of the size requested, will:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) * If preparation of the pending HPT is already complete, return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) * If preparation of the pending HPT has failed, return an error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) code, then discard the pending HPT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) * If preparation of the pending HPT is still in progress, return an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) estimated number of milliseconds until preparation is complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) If called with shift == 0, discards any currently pending HPT and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) returns 0 (i.e. cancels any in-progress preparation).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) flags is reserved for future expansion, currently setting any bits in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) flags will result in an -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) Normally this will be called repeatedly with the same parameters until
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) it returns <= 0. The first call will initiate preparation, subsequent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) ones will monitor preparation until it completes or fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) struct kvm_ppc_resize_hpt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) __u32 shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) 4.103 KVM_PPC_RESIZE_HPT_COMMIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) -------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) :Capability: KVM_CAP_SPAPR_RESIZE_HPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) :Parameters: struct kvm_ppc_resize_hpt (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) :Returns: 0 on successful completion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) -EFAULT if struct kvm_reinject_control cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) -EINVAL if the supplied shift or flags are invalid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) -ENXIO is there is no pending HPT, or the pending HPT doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) have the requested size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) -EBUSY if the pending HPT is not fully prepared,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) -ENOSPC if there was a hash collision when moving existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) HPT entries to the new HPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) -EIO on other error conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) Used to implement the PAPR extension for runtime resizing of a guest's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) Hashed Page Table (HPT). Specifically this requests that the guest be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) transferred to working with the new HPT, essentially implementing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) H_RESIZE_HPT_COMMIT hypercall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) This should only be called after KVM_PPC_RESIZE_HPT_PREPARE has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) returned 0 with the same parameters. In other cases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) KVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) -EBUSY, though others may be possible if the preparation was started,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) but failed).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) This will have undefined effects on the guest if it has not already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) placed itself in a quiescent state where no vcpu will make MMU enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) memory accesses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) On succsful completion, the pending HPT will become the guest's active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) HPT and the previous HPT will be discarded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) On failure, the guest will still be operating on its previous HPT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) struct kvm_ppc_resize_hpt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) __u32 shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) 4.104 KVM_X86_GET_MCE_CAP_SUPPORTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) -----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) :Capability: KVM_CAP_MCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) :Type: system ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) :Parameters: u64 mce_cap (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) Returns supported MCE capabilities. The u64 mce_cap parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) has the same format as the MSR_IA32_MCG_CAP register. Supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) capabilities will have the corresponding bits set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) 4.105 KVM_X86_SETUP_MCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) :Capability: KVM_CAP_MCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) :Parameters: u64 mcg_cap (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) -EFAULT if u64 mcg_cap cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) -EINVAL if the requested number of banks is invalid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) -EINVAL if requested MCE capability is not supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) Initializes MCE support for use. The u64 mcg_cap parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) has the same format as the MSR_IA32_MCG_CAP register and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) specifies which capabilities should be enabled. The maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) supported number of error-reporting banks can be retrieved when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) checking for KVM_CAP_MCE. The supported capabilities can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) retrieved with KVM_X86_GET_MCE_CAP_SUPPORTED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) 4.106 KVM_X86_SET_MCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) :Capability: KVM_CAP_MCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) :Parameters: struct kvm_x86_mce (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) -EFAULT if struct kvm_x86_mce cannot be read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) -EINVAL if the bank number is invalid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) -EINVAL if VAL bit is not set in status field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) Inject a machine check error (MCE) into the guest. The input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) parameter is::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) struct kvm_x86_mce {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) __u64 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) __u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) __u64 misc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) __u64 mcg_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) __u8 bank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) __u8 pad1[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) __u64 pad2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) If the MCE being reported is an uncorrected error, KVM will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) inject it as an MCE exception into the guest. If the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) MCG_STATUS register reports that an MCE is in progress, KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) causes an KVM_EXIT_SHUTDOWN vmexit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) Otherwise, if the MCE is a corrected error, KVM will just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) store it in the corresponding bank (provided this bank is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) not holding a previously reported uncorrected error).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) 4.107 KVM_S390_GET_CMMA_BITS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) :Capability: KVM_CAP_S390_CMMA_MIGRATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) :Parameters: struct kvm_s390_cmma_log (in, out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) :Returns: 0 on success, a negative value on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) This ioctl is used to get the values of the CMMA bits on the s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) architecture. It is meant to be used in two scenarios:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) - During live migration to save the CMMA values. Live migration needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) to be enabled via the KVM_REQ_START_MIGRATION VM property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) - To non-destructively peek at the CMMA values, with the flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) KVM_S390_CMMA_PEEK set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) The ioctl takes parameters via the kvm_s390_cmma_log struct. The desired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) values are written to a buffer whose location is indicated via the "values"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) member in the kvm_s390_cmma_log struct. The values in the input struct are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) also updated as needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) Each CMMA value takes up one byte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) struct kvm_s390_cmma_log {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) __u64 start_gfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) __u64 remaining;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) __u64 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) __u64 values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) start_gfn is the number of the first guest frame whose CMMA values are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) to be retrieved,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) count is the length of the buffer in bytes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) values points to the buffer where the result will be written to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) If count is greater than KVM_S390_SKEYS_MAX, then it is considered to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) KVM_S390_SKEYS_MAX. KVM_S390_SKEYS_MAX is re-used for consistency with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) other ioctls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) The result is written in the buffer pointed to by the field values, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) the values of the input parameter are updated as follows.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) Depending on the flags, different actions are performed. The only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) supported flag so far is KVM_S390_CMMA_PEEK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) The default behaviour if KVM_S390_CMMA_PEEK is not set is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) start_gfn will indicate the first page frame whose CMMA bits were dirty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) It is not necessarily the same as the one passed as input, as clean pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) are skipped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) count will indicate the number of bytes actually written in the buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) It can (and very often will) be smaller than the input value, since the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) buffer is only filled until 16 bytes of clean values are found (which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) are then not copied in the buffer). Since a CMMA migration block needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) the base address and the length, for a total of 16 bytes, we will send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) back some clean data if there is some dirty data afterwards, as long as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) the size of the clean data does not exceed the size of the header. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) allows to minimize the amount of data to be saved or transferred over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) the network at the expense of more roundtrips to userspace. The next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) invocation of the ioctl will skip over all the clean values, saving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) potentially more than just the 16 bytes we found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) If KVM_S390_CMMA_PEEK is set:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) the existing storage attributes are read even when not in migration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) mode, and no other action is performed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) the output start_gfn will be equal to the input start_gfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) the output count will be equal to the input count, except if the end of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) memory has been reached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) In both cases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) the field "remaining" will indicate the total number of dirty CMMA values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) still remaining, or 0 if KVM_S390_CMMA_PEEK is set and migration mode is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) not enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) mask is unused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) values points to the userspace buffer where the result will be stored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) This ioctl can fail with -ENOMEM if not enough memory can be allocated to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) complete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) KVM_S390_CMMA_PEEK is not set but migration mode was not enabled, with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) -EFAULT if the userspace address is invalid or if no page table is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) present for the addresses (e.g. when using hugepages).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) 4.108 KVM_S390_SET_CMMA_BITS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) :Capability: KVM_CAP_S390_CMMA_MIGRATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) :Parameters: struct kvm_s390_cmma_log (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) :Returns: 0 on success, a negative value on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) This ioctl is used to set the values of the CMMA bits on the s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) architecture. It is meant to be used during live migration to restore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) the CMMA values, but there are no restrictions on its use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) The ioctl takes parameters via the kvm_s390_cmma_values struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) Each CMMA value takes up one byte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) struct kvm_s390_cmma_log {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) __u64 start_gfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) __u64 remaining;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) __u64 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) __u64 values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) start_gfn indicates the starting guest frame number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) count indicates how many values are to be considered in the buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) flags is not used and must be 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) mask indicates which PGSTE bits are to be considered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) remaining is not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) values points to the buffer in userspace where to store the values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) This ioctl can fail with -ENOMEM if not enough memory can be allocated to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) complete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) the count field is too large (e.g. more than KVM_S390_CMMA_SIZE_MAX) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) if the flags field was not 0, with -EFAULT if the userspace address is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) invalid, if invalid pages are written to (e.g. after the end of memory)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) or if no page table is present for the addresses (e.g. when using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) hugepages).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) 4.109 KVM_PPC_GET_CPU_CHAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) :Capability: KVM_CAP_PPC_GET_CPU_CHAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) :Parameters: struct kvm_ppc_cpu_char (out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) :Returns: 0 on successful completion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) -EFAULT if struct kvm_ppc_cpu_char cannot be written
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) This ioctl gives userspace information about certain characteristics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) of the CPU relating to speculative execution of instructions and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) possible information leakage resulting from speculative execution (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) CVE-2017-5715, CVE-2017-5753 and CVE-2017-5754). The information is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) returned in struct kvm_ppc_cpu_char, which looks like this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) struct kvm_ppc_cpu_char {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) __u64 character; /* characteristics of the CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) __u64 behaviour; /* recommended software behaviour */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) __u64 character_mask; /* valid bits in character */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193) __u64 behaviour_mask; /* valid bits in behaviour */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) For extensibility, the character_mask and behaviour_mask fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) indicate which bits of character and behaviour have been filled in by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) the kernel. If the set of defined bits is extended in future then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) userspace will be able to tell whether it is running on a kernel that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) knows about the new bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) The character field describes attributes of the CPU which can help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) with preventing inadvertent information disclosure - specifically,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) whether there is an instruction to flash-invalidate the L1 data cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) (ori 30,30,0 or mtspr SPRN_TRIG2,rN), whether the L1 data cache is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) to a mode where entries can only be used by the thread that created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) them, whether the bcctr[l] instruction prevents speculation, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) whether a speculation barrier instruction (ori 31,31,0) is provided.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) The behaviour field describes actions that software should take to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) prevent inadvertent information disclosure, and thus describes which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) vulnerabilities the hardware is subject to; specifically whether the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) L1 data cache should be flushed when returning to user mode from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) kernel, and whether a speculation barrier should be placed between an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) array bounds check and the array access.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) These fields use the same bit definitions as the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) H_GET_CPU_CHARACTERISTICS hypercall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) 4.110 KVM_MEMORY_ENCRYPT_OP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) :Type: vm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) :Parameters: an opaque platform specific structure (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) If the platform supports creating encrypted VMs then this ioctl can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) for issuing platform-specific memory encryption commands to manage those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) encrypted VMs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) Currently, this ioctl is used for issuing Secure Encrypted Virtualization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) (SEV) commands on AMD Processors. The SEV commands are defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) Documentation/virt/kvm/amd-memory-encryption.rst.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) 4.111 KVM_MEMORY_ENCRYPT_REG_REGION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) -----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) :Type: system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) :Parameters: struct kvm_enc_region (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246) This ioctl can be used to register a guest memory region which may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) contain encrypted data (e.g. guest RAM, SMRAM etc).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) It is used in the SEV-enabled guest. When encryption is enabled, a guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) memory region may contain encrypted data. The SEV memory encryption
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) engine uses a tweak such that two identical plaintext pages, each at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) different locations will have differing ciphertexts. So swapping or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) moving ciphertext of those pages will not result in plaintext being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) swapped. So relocating (or migrating) physical backing pages for the SEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) guest will require some additional steps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) Note: The current SEV key management spec does not provide commands to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) swap or migrate (move) ciphertext pages. Hence, for now we pin the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) memory region registered with the ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) 4.112 KVM_MEMORY_ENCRYPT_UNREG_REGION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) -------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) :Type: system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) :Parameters: struct kvm_enc_region (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) This ioctl can be used to unregister the guest memory region registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) with KVM_MEMORY_ENCRYPT_REG_REGION ioctl above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) 4.113 KVM_HYPERV_EVENTFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) :Capability: KVM_CAP_HYPERV_EVENTFD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) :Parameters: struct kvm_hyperv_eventfd (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) This ioctl (un)registers an eventfd to receive notifications from the guest on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) the specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) causing a user exit. SIGNAL_EVENT hypercall with non-zero event flag number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) (bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL user exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) struct kvm_hyperv_eventfd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) __u32 conn_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) __s32 fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) __u32 padding[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) The conn_id field should fit within 24 bits::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) The acceptable values for the flags field are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) :Returns: 0 on success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) -EINVAL if conn_id or flags is outside the allowed range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) -ENOENT on deassign if the conn_id isn't registered,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) -EEXIST on assign if the conn_id is already registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) 4.114 KVM_GET_NESTED_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) :Capability: KVM_CAP_NESTED_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) :Parameters: struct kvm_nested_state (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) ===== =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) E2BIG the total state size exceeds the value of 'size' specified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) the user; the size required will be written into size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) ===== =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) struct kvm_nested_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) __u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) __u16 format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) __u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) struct kvm_vmx_nested_state_hdr vmx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) struct kvm_svm_nested_state_hdr svm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) /* Pad the header to 128 bytes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) __u8 pad[120];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) } hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) struct kvm_vmx_nested_state_data vmx[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) struct kvm_svm_nested_state_data svm[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) } data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) #define KVM_STATE_NESTED_GUEST_MODE 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) #define KVM_STATE_NESTED_RUN_PENDING 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) #define KVM_STATE_NESTED_EVMCS 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) #define KVM_STATE_NESTED_FORMAT_VMX 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) #define KVM_STATE_NESTED_FORMAT_SVM 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) #define KVM_STATE_NESTED_VMX_SMM_GUEST_MODE 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) #define KVM_STATE_NESTED_VMX_SMM_VMXON 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) struct kvm_vmx_nested_state_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) __u64 vmxon_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) __u64 vmcs12_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) __u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) } smm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) __u64 preemption_timer_deadline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) struct kvm_vmx_nested_state_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) This ioctl copies the vcpu's nested virtualization state from the kernel to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) The maximum size of the state can be retrieved by passing KVM_CAP_NESTED_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) to the KVM_CHECK_EXTENSION ioctl().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) 4.115 KVM_SET_NESTED_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) :Capability: KVM_CAP_NESTED_STATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) :Parameters: struct kvm_nested_state (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) This copies the vcpu's kvm_nested_state struct from userspace to the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) For the definition of struct kvm_nested_state, see KVM_GET_NESTED_STATE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) 4.116 KVM_(UN)REGISTER_COALESCED_MMIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) -------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) :Capability: KVM_CAP_COALESCED_MMIO (for coalesced mmio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) KVM_CAP_COALESCED_PIO (for coalesced pio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) :Parameters: struct kvm_coalesced_mmio_zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) :Returns: 0 on success, < 0 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) Coalesced I/O is a performance optimization that defers hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) register write emulation so that userspace exits are avoided. It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) typically used to reduce the overhead of emulating frequently accessed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) hardware registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) When a hardware register is configured for coalesced I/O, write accesses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) do not exit to userspace and their value is recorded in a ring buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) that is shared between kernel and userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) Coalesced I/O is used if one or more write accesses to a hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) register can be deferred until a read or a write to another hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) register on the same device. This last access will cause a vmexit and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) userspace will process accesses from the ring buffer before emulating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) it. That will avoid exiting to userspace on repeated writes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) Coalesced pio is based on coalesced mmio. There is little difference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) between coalesced mmio and pio except that coalesced pio records accesses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) to I/O ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) 4.117 KVM_CLEAR_DIRTY_LOG (vm ioctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) ------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) :Capability: KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) :Architectures: x86, arm, arm64, mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) :Parameters: struct kvm_dirty_log (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) /* for KVM_CLEAR_DIRTY_LOG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) struct kvm_clear_dirty_log {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) __u32 slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) __u32 num_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) __u64 first_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) void __user *dirty_bitmap; /* one bit per page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) __u64 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) The ioctl clears the dirty status of pages in a memory slot, according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) the bitmap that is passed in struct kvm_clear_dirty_log's dirty_bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) field. Bit 0 of the bitmap corresponds to page "first_page" in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) memory slot, and num_pages is the size in bits of the input bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) first_page must be a multiple of 64; num_pages must also be a multiple of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) 64 unless first_page + num_pages is the size of the memory slot. For each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) bit that is set in the input bitmap, the corresponding page is marked "clean"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) in KVM's dirty bitmap, and dirty tracking is re-enabled for that page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) (for example via write-protection, or by clearing the dirty bit in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) a page table entry).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 specifies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) the address space for which you want to return the dirty bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) They must be less than the value that KVM_CHECK_EXTENSION returns for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) the KVM_CAP_MULTI_ADDRESS_SPACE capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) This ioctl is mostly useful when KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) is enabled; for more information, see the description of the capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) However, it can always be used as long as KVM_CHECK_EXTENSION confirms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) that KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) 4.118 KVM_GET_SUPPORTED_HV_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) --------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) :Capability: KVM_CAP_HYPERV_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) :Parameters: struct kvm_cpuid2 (in/out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) struct kvm_cpuid2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) __u32 nent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) __u32 padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) struct kvm_cpuid_entry2 entries[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) struct kvm_cpuid_entry2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) __u32 function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) __u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) __u32 eax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) __u32 ebx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) __u32 ecx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) __u32 edx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) __u32 padding[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) This ioctl returns x86 cpuid features leaves related to Hyper-V emulation in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) KVM. Userspace can use the information returned by this ioctl to construct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) cpuid information presented to guests consuming Hyper-V enlightenments (e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) Windows or Hyper-V guests).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) CPUID feature leaves returned by this ioctl are defined by Hyper-V Top Level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) Functional Specification (TLFS). These leaves can't be obtained with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) KVM_GET_SUPPORTED_CPUID ioctl because some of them intersect with KVM feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) leaves (0x40000000, 0x40000001).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) Currently, the following list of CPUID leaves are returned:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) - HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) - HYPERV_CPUID_INTERFACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) - HYPERV_CPUID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) - HYPERV_CPUID_FEATURES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) - HYPERV_CPUID_ENLIGHTMENT_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) - HYPERV_CPUID_IMPLEMENT_LIMITS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) - HYPERV_CPUID_NESTED_FEATURES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) - HYPERV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) - HYPERV_CPUID_SYNDBG_INTERFACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) - HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) HYPERV_CPUID_NESTED_FEATURES leaf is only exposed when Enlightened VMCS was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) enabled on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) Userspace invokes KVM_GET_SUPPORTED_HV_CPUID by passing a kvm_cpuid2 structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) with the 'nent' field indicating the number of entries in the variable-size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) array 'entries'. If the number of entries is too low to describe all Hyper-V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) feature leaves, an error (E2BIG) is returned. If the number is more or equal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) to the number of Hyper-V feature leaves, the 'nent' field is adjusted to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) number of valid entries in the 'entries' array, which is then filled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) 'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) userspace should not expect to get any particular value there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) 4.119 KVM_ARM_VCPU_FINALIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) :Architectures: arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) :Parameters: int feature (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) ====== ==============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) EPERM feature not enabled, needs configuration, or already finalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) EINVAL feature unknown or not present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) ====== ==============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) Recognised values for feature:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) ===== ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) arm64 KVM_ARM_VCPU_SVE (requires KVM_CAP_ARM_SVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) ===== ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) Finalizes the configuration of the specified vcpu feature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) The vcpu must already have been initialised, enabling the affected feature, by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) means of a successful KVM_ARM_VCPU_INIT call with the appropriate flag set in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) features[].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) For affected vcpu features, this is a mandatory step that must be performed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) before the vcpu is fully usable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) Between KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE, the feature may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) configured by use of ioctls such as KVM_SET_ONE_REG. The exact configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) that should be performaned and how to do it are feature-dependent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) Other calls that depend on a particular feature being finalized, such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) KVM_RUN, KVM_GET_REG_LIST, KVM_GET_ONE_REG and KVM_SET_ONE_REG, will fail with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) -EPERM unless the feature has already been finalized by means of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) KVM_ARM_VCPU_FINALIZE call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) See KVM_ARM_VCPU_INIT for details of vcpu features that require finalization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) using this ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) 4.120 KVM_SET_PMU_EVENT_FILTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) :Capability: KVM_CAP_PMU_EVENT_FILTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) :Parameters: struct kvm_pmu_event_filter (in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) struct kvm_pmu_event_filter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) __u32 action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) __u32 nevents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) __u32 fixed_counter_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) __u32 pad[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) __u64 events[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) This ioctl restricts the set of PMU events that the guest can program.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) The argument holds a list of events which will be allowed or denied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) The eventsel+umask of each event the guest attempts to program is compared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) against the events field to determine whether the guest should have access.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) The events field only controls general purpose counters; fixed purpose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) counters are controlled by the fixed_counter_bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) No flags are defined yet, the field must be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) Valid values for 'action'::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) #define KVM_PMU_EVENT_ALLOW 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) #define KVM_PMU_EVENT_DENY 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) 4.121 KVM_PPC_SVM_OFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) :Capability: basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) :Architectures: powerpc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) :Returns: 0 on successful completion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) ====== ================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) EINVAL if ultravisor failed to terminate the secure guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) ENOMEM if hypervisor failed to allocate new radix page tables for guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) ====== ================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) This ioctl is used to turn off the secure mode of the guest or transition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) the guest from secure mode to normal mode. This is invoked when the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) is reset. This has no effect if called for a normal guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) This ioctl issues an ultravisor call to terminate the secure guest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) unpins the VPA pages and releases all the device pages that are used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) track the secure pages by hypervisor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) 4.122 KVM_S390_NORMAL_RESET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) :Capability: KVM_CAP_S390_VCPU_RESETS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) :Returns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) This ioctl resets VCPU registers and control structures according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) the cpu reset definition in the POP (Principles Of Operation).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) 4.123 KVM_S390_INITIAL_RESET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) :Capability: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) :Returns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) This ioctl resets VCPU registers and control structures according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) the initial cpu reset definition in the POP. However, the cpu is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) put into ESA mode. This reset is a superset of the normal reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) 4.124 KVM_S390_CLEAR_RESET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) :Capability: KVM_CAP_S390_VCPU_RESETS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) :Type: vcpu ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) :Returns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) This ioctl resets VCPU registers and control structures according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) the clear cpu reset definition in the POP. However, the cpu is not put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) into ESA mode. This reset is a superset of the initial reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) 4.125 KVM_S390_PV_COMMAND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) :Capability: KVM_CAP_S390_PROTECTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) :Parameters: struct kvm_pv_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) :Returns: 0 on success, < 0 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) struct kvm_pv_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) __u32 cmd; /* Command to be executed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) __u16 rc; /* Ultravisor return code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) __u16 rrc; /* Ultravisor return reason code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) __u64 data; /* Data or address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) __u32 flags; /* flags for future extensions. Must be 0 for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) __u32 reserved[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) cmd values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) KVM_PV_ENABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) Allocate memory and register the VM with the Ultravisor, thereby
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) donating memory to the Ultravisor that will become inaccessible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) KVM. All existing CPUs are converted to protected ones. After this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) command has succeeded, any CPU added via hotplug will become
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) protected during its creation as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) ===== =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) EINTR an unmasked signal is pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) ===== =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) KVM_PV_DISABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) Deregister the VM from the Ultravisor and reclaim the memory that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) had been donated to the Ultravisor, making it usable by the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) again. All registered VCPUs are converted back to non-protected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) ones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) KVM_PV_VM_SET_SEC_PARMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) Pass the image header from VM memory to the Ultravisor in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) preparation of image unpacking and verification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) KVM_PV_VM_UNPACK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) Unpack (protect and decrypt) a page of the encrypted boot image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) KVM_PV_VM_VERIFY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) Verify the integrity of the unpacked image. Only if this succeeds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) KVM is allowed to start protected VCPUs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) 4.126 KVM_X86_SET_MSR_FILTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) :Capability: KVM_X86_SET_MSR_FILTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) :Type: vm ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) :Parameters: struct kvm_msr_filter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) :Returns: 0 on success, < 0 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) struct kvm_msr_filter_range {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) #define KVM_MSR_FILTER_READ (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) #define KVM_MSR_FILTER_WRITE (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) __u32 nmsrs; /* number of msrs in bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) __u32 base; /* MSR index the bitmap starts at */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) #define KVM_MSR_FILTER_MAX_RANGES 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) struct kvm_msr_filter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) flags values for ``struct kvm_msr_filter_range``:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) ``KVM_MSR_FILTER_READ``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) Filter read accesses to MSRs using the given bitmap. A 0 in the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) indicates that a read should immediately fail, while a 1 indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) a read for a particular MSR should be handled regardless of the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) filter action.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) ``KVM_MSR_FILTER_WRITE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) Filter write accesses to MSRs using the given bitmap. A 0 in the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) indicates that a write should immediately fail, while a 1 indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) a write for a particular MSR should be handled regardless of the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) filter action.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) ``KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767) Filter both read and write accesses to MSRs using the given bitmap. A 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) in the bitmap indicates that both reads and writes should immediately fail,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) while a 1 indicates that reads and writes for a particular MSR are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) filtered by this range.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) flags values for ``struct kvm_msr_filter``:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) ``KVM_MSR_FILTER_DEFAULT_ALLOW``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776) If no filter range matches an MSR index that is getting accessed, KVM will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) fall back to allowing access to the MSR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) ``KVM_MSR_FILTER_DEFAULT_DENY``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) If no filter range matches an MSR index that is getting accessed, KVM will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) fall back to rejecting access to the MSR. In this mode, all MSRs that should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) be processed by KVM need to explicitly be marked as allowed in the bitmaps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) This ioctl allows user space to define up to 16 bitmaps of MSR ranges to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) specify whether a certain MSR access should be explicitly filtered for or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) If this ioctl has never been invoked, MSR accesses are not guarded and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) default KVM in-kernel emulation behavior is fully preserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) Calling this ioctl with an empty set of ranges (all nmsrs == 0) disables MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) filtering. In that mode, ``KVM_MSR_FILTER_DEFAULT_DENY`` is invalid and causes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) an error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) As soon as the filtering is in place, every MSR access is processed through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) the filtering except for accesses to the x2APIC MSRs (from 0x800 to 0x8ff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) x2APIC MSRs are always allowed, independent of the ``default_allow`` setting,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) and their behavior depends on the ``X2APIC_ENABLE`` bit of the APIC base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799) register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) If a bit is within one of the defined ranges, read and write accesses are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) guarded by the bitmap's value for the MSR index if the kind of access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) is included in the ``struct kvm_msr_filter_range`` flags. If no range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) cover this particular access, the behavior is determined by the flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) field in the kvm_msr_filter struct: ``KVM_MSR_FILTER_DEFAULT_ALLOW``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) and ``KVM_MSR_FILTER_DEFAULT_DENY``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) Each bitmap range specifies a range of MSRs to potentially allow access on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) The range goes from MSR index [base .. base+nmsrs]. The flags field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) indicates whether reads, writes or both reads and writes are filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) by setting a 1 bit in the bitmap for the corresponding MSR index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) If an MSR access is not permitted through the filtering, it generates a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) #GP inside the guest. When combined with KVM_CAP_X86_USER_SPACE_MSR, that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) allows user space to deflect and potentially handle various MSR accesses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) into user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) Note, invoking this ioctl with a vCPU is running is inherently racy. However,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) KVM does guarantee that vCPUs will see either the previous filter or the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) filter, e.g. MSRs with identical settings in both the old and new filter will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) have deterministic behavior.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) 5. The kvm_run structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827) Application code obtains a pointer to the kvm_run structure by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) mmap()ing a vcpu fd. From that point, application code can control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) execution by changing fields in kvm_run prior to calling the KVM_RUN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) ioctl, and obtain information about the reason KVM_RUN returned by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) looking up structure members.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) struct kvm_run {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) /* in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) __u8 request_interrupt_window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) Request that KVM_RUN return when it becomes possible to inject external
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) interrupts into the guest. Useful in conjunction with KVM_INTERRUPT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) __u8 immediate_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) This field is polled once when KVM_RUN starts; if non-zero, KVM_RUN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) exits immediately, returning -EINTR. In the common scenario where a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) signal is used to "kick" a VCPU out of KVM_RUN, this field can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) to avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) Rather than blocking the signal outside KVM_RUN, userspace can set up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) a signal handler that sets run->immediate_exit to a non-zero value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) This field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) __u8 padding1[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) /* out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) __u32 exit_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) When KVM_RUN has returned successfully (return value 0), this informs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) application code why KVM_RUN has returned. Allowable values for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) field are detailed below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) __u8 ready_for_interrupt_injection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) If request_interrupt_window has been specified, this field indicates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) an interrupt can be injected now with KVM_INTERRUPT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) __u8 if_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) The value of the current interrupt flag. Only valid if in-kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) local APIC is not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) __u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) More architecture-specific flags detailing state of the VCPU that may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) affect the device's behavior. The only currently defined flag is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) KVM_RUN_X86_SMM, which is valid on x86 machines and is set if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) VCPU is in system management mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) /* in (pre_kvm_run), out (post_kvm_run) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) __u64 cr8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) The value of the cr8 register. Only valid if in-kernel local APIC is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) not used. Both input and output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) __u64 apic_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) The value of the APIC BASE msr. Only valid if in-kernel local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) APIC is not used. Both input and output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) /* KVM_EXIT_UNKNOWN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) __u64 hardware_exit_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) } hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) reasons. Further architecture-specific information is available in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) hardware_exit_reason.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) /* KVM_EXIT_FAIL_ENTRY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) __u64 hardware_entry_failure_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) __u32 cpu; /* if KVM_LAST_CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) } fail_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) to unknown reasons. Further architecture-specific information is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) available in hardware_entry_failure_reason.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) /* KVM_EXIT_EXCEPTION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) __u32 exception;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) __u32 error_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) } ex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) Unused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) /* KVM_EXIT_IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) #define KVM_EXIT_IO_IN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) #define KVM_EXIT_IO_OUT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) __u8 direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) __u8 size; /* bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) __u16 port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) __u64 data_offset; /* relative to kvm_run start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) } io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) If exit_reason is KVM_EXIT_IO, then the vcpu has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) executed a port I/O instruction which could not be satisfied by kvm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) data_offset describes where the data is located (KVM_EXIT_IO_OUT) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) where kvm expects application code to place the data for the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) KVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) /* KVM_EXIT_DEBUG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) struct kvm_debug_exit_arch arch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) } debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) If the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) for which architecture specific information is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) /* KVM_EXIT_MMIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) __u64 phys_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) __u8 data[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) __u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974) __u8 is_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) } mmio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) If exit_reason is KVM_EXIT_MMIO, then the vcpu has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) executed a memory-mapped I/O instruction which could not be satisfied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) by kvm. The 'data' member contains the written data if 'is_write' is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) true, and should be filled by application code otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) The 'data' member contains, in its first 'len' bytes, the value as it would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) appear if the VCPU performed a load or store of the appropriate width directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) to the byte array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) KVM_EXIT_EPR, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR the corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) operations are complete (and guest state is consistent) only after userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) has re-entered the kernel with KVM_RUN. The kernel side will first finish
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) incomplete operations and then check for pending signals. Userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) can re-enter the guest with an unmasked signal pending to complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) pending operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) /* KVM_EXIT_HYPERCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) __u64 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) __u64 args[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) __u64 ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) __u32 longmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) } hypercall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) Unused. This was once used for 'hypercall to userspace'. To implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) such functionality, use KVM_EXIT_IO (x86) or KVM_EXIT_MMIO (all except s390).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) .. note:: KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) /* KVM_EXIT_TPR_ACCESS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) __u64 rip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) __u32 is_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) __u32 pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) } tpr_access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) To be documented (KVM_TPR_ACCESS_REPORTING).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) /* KVM_EXIT_S390_SIEIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) __u8 icptcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) __u64 mask; /* psw upper half */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) __u64 addr; /* psw lower half */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) __u16 ipa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) __u32 ipb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) } s390_sieic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) s390 specific.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) /* KVM_EXIT_S390_RESET */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) #define KVM_S390_RESET_POR 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) #define KVM_S390_RESET_CLEAR 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) #define KVM_S390_RESET_SUBSYSTEM 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) #define KVM_S390_RESET_CPU_INIT 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) #define KVM_S390_RESET_IPL 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) __u64 s390_reset_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) s390 specific.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) /* KVM_EXIT_S390_UCONTROL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) __u64 trans_exc_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) __u32 pgm_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) } s390_ucontrol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) s390 specific. A page fault has occurred for a user controlled virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) machine (KVM_VM_S390_UNCONTROL) on it's host page table that cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) resolved by the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) The program code and the translation exception code that were placed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) in the cpu's lowcore are presented here as defined by the z Architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) Principles of Operation Book in the Chapter for Dynamic Address Translation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) (DAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) /* KVM_EXIT_DCR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) __u32 dcrn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069) __u32 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) __u8 is_write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) } dcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) Deprecated - was used for 440 KVM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) /* KVM_EXIT_OSI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) __u64 gprs[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) } osi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) hypercalls and exit with this exit struct that contains all the guest gprs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) Userspace can now handle the hypercall and when it's done modify the gprs as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) necessary. Upon guest entry all guest GPRs will then be replaced by the values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) in this struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) /* KVM_EXIT_PAPR_HCALL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) __u64 nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) __u64 ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) __u64 args[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) } papr_hcall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) This is used on 64-bit PowerPC when emulating a pSeries partition,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) e.g. with the 'pseries' machine type in qemu. It occurs when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) guest does a hypercall using the 'sc 1' instruction. The 'nr' field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) contains the hypercall number (from the guest R3), and 'args' contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) the arguments (from the guest R4 - R12). Userspace should put the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) return code in 'ret' and any extra returned values in args[].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) The possible hypercalls are defined in the Power Architecture Platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) Requirements (PAPR) document available from www.power.org (free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) developer registration required to access it).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111) /* KVM_EXIT_S390_TSCH */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) __u16 subchannel_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) __u16 subchannel_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) __u32 io_int_parm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) __u32 io_int_word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) __u32 ipb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) __u8 dequeued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) } s390_tsch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) interrupt for the target subchannel has been dequeued and subchannel_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) subchannel_nr, io_int_parm and io_int_word contain the parameters for that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) interrupt. ipb is needed for instruction parameter decoding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) /* KVM_EXIT_EPR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) __u32 epr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) } epr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) On FSL BookE PowerPC chips, the interrupt controller has a fast patch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) interrupt acknowledge path to the core. When the core successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) delivers an interrupt, it automatically populates the EPR register with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) the interrupt vector number and acknowledges the interrupt inside
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) the interrupt controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) In case the interrupt controller lives in user space, we need to do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) the interrupt acknowledge cycle through it to fetch the next to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) delivered interrupt vector using this exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) external interrupt has just been delivered into the guest. User space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) should put the acknowledged interrupt vector into the 'epr' field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) /* KVM_EXIT_SYSTEM_EVENT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) #define KVM_SYSTEM_EVENT_SHUTDOWN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) #define KVM_SYSTEM_EVENT_RESET 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) #define KVM_SYSTEM_EVENT_CRASH 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) __u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) __u64 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) } system_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) a system-level event using some architecture specific mechanism (hypercall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) or some special instruction). In case of ARM/ARM64, this is triggered using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) HVC instruction based PSCI call from the vcpu. The 'type' field describes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) the system-level event type. The 'flags' field describes architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) specific flags for the system-level event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) Valid values for 'type' are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) - KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) VM. Userspace is not obliged to honour this, and if it does honour
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) this does not need to destroy the VM synchronously (ie it may call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) KVM_RUN again before shutdown finally occurs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) - KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) As with SHUTDOWN, userspace can choose to ignore the request, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) to schedule the reset to occur in the future and may call KVM_RUN again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) - KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) has requested a crash condition maintenance. Userspace can choose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177) to ignore the request, or to gather VM memory core dump and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) reset/shutdown of the VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) /* KVM_EXIT_IOAPIC_EOI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) __u8 vector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) } eoi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) Indicates that the VCPU's in-kernel local APIC received an EOI for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) level-triggered IOAPIC interrupt. This exit only triggers when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) the userspace IOAPIC should process the EOI and retrigger the interrupt if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) it is still asserted. Vector is the LAPIC interrupt vector for which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) EOI was received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) struct kvm_hyperv_exit {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) #define KVM_EXIT_HYPERV_SYNIC 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) #define KVM_EXIT_HYPERV_HCALL 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) #define KVM_EXIT_HYPERV_SYNDBG 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) __u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) __u32 pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) __u32 msr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) __u32 pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) __u64 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) __u64 evt_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) __u64 msg_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209) } synic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) __u64 input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) __u64 result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) __u64 params[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) } hcall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) __u32 msr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) __u32 pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) __u64 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) __u64 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) __u64 send_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) __u64 recv_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) __u64 pending_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) } syndbg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) /* KVM_EXIT_HYPERV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) struct kvm_hyperv_exit hyperv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) Indicates that the VCPU exits into userspace to process some tasks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) related to Hyper-V emulation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) Valid values for 'type' are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) - KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) Hyper-V SynIC state change. Notification is used to remap SynIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) event/message pages and to enable/disable SynIC messages/events processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) in userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) - KVM_EXIT_HYPERV_SYNDBG -- synchronously notify user-space about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) Hyper-V Synthetic debugger state change. Notification is used to either update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) the pending_page location or to send a control command (send the buffer located
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) in send_page or recv a buffer to recv_page).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) /* KVM_EXIT_ARM_NISV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) __u64 esr_iss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) __u64 fault_ipa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) } arm_nisv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) Used on arm and arm64 systems. If a guest accesses memory not in a memslot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) KVM will typically return to userspace and ask it to do MMIO emulation on its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) behalf. However, for certain classes of instructions, no instruction decode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) (direction, length of memory access) is provided, and fetching and decoding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) the instruction from the VM is overly complicated to live in the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) Historically, when this situation occurred, KVM would print a warning and kill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) the VM. KVM assumed that if the guest accessed non-memslot memory, it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) trying to do I/O, which just couldn't be emulated, and the warning message was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) phrased accordingly. However, what happened more often was that a guest bug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) caused access outside the guest memory areas which should lead to a more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) meaningful warning message and an external abort in the guest, if the access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) did not fall within an I/O window.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) Userspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) this capability at VM creation. Once this is done, these types of errors will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) instead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) the HSR (arm) and ESR_EL2 (arm64) in the esr_iss field, and the faulting IPA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) in the fault_ipa field. Userspace can either fix up the access if it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) actually an I/O access by decoding the instruction from guest memory (if it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) very brave) and continue executing the guest, or it can decide to suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) dump, or restart the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) Note that KVM does not skip the faulting instruction as it does for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) if it decides to decode and emulate the instruction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) __u8 error; /* user -> kernel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) __u8 pad[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) __u32 reason; /* kernel -> user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) __u32 index; /* kernel -> user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) __u64 data; /* kernel <-> user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) } msr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) Used on x86 systems. When the VM capability KVM_CAP_X86_USER_SPACE_MSR is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) enabled, MSR accesses to registers that would invoke a #GP by KVM kernel code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) will instead trigger a KVM_EXIT_X86_RDMSR exit for reads and KVM_EXIT_X86_WRMSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) exit for writes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) The "reason" field specifies why the MSR trap occurred. User space will only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) receive MSR exit traps when a particular reason was requested during through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) ENABLE_CAP. Currently valid exit reasons are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) KVM_MSR_EXIT_REASON_UNKNOWN - access to MSR that is unknown to KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) KVM_MSR_EXIT_REASON_INVAL - access to invalid MSRs or reserved bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) KVM_MSR_EXIT_REASON_FILTER - access blocked by KVM_X86_SET_MSR_FILTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) For KVM_EXIT_X86_RDMSR, the "index" field tells user space which MSR the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) wants to read. To respond to this request with a successful read, user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) writes the respective data into the "data" field and must continue guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) execution to ensure the read data is transferred into guest register state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) If the RDMSR request was unsuccessful, user space indicates that with a "1" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) the "error" field. This will inject a #GP into the guest when the VCPU is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) executed again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) For KVM_EXIT_X86_WRMSR, the "index" field tells user space which MSR the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) wants to write. Once finished processing the event, user space must continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) vCPU execution. If the MSR write was unsuccessful, user space also sets the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) "error" field to "1".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) /* Fix the size of the union. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) char padding[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) * shared registers between kvm and userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) * kvm_valid_regs specifies the register classes set by the host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) * kvm_dirty_regs specified the register classes dirtied by userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) * struct kvm_sync_regs is architecture specific, as well as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) * bits for kvm_valid_regs and kvm_dirty_regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) __u64 kvm_valid_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) __u64 kvm_dirty_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) struct kvm_sync_regs regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) char padding[SYNC_REGS_SIZE_BYTES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) } s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340) certain guest registers without having to call SET/GET_*REGS. Thus we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) avoid some system call overhead if userspace has to handle the exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) Userspace can query the validity of the structure by checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) kvm_valid_regs for specific bits. These bits are architecture specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) and usually define the validity of a groups of registers. (e.g. one bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) for general purpose registers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) Please note that the kernel is allowed to use the kvm_run structure as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) primary storage for certain register types. Therefore, the kernel may use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) 6. Capabilities that can be enabled on vCPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) ============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) There are certain capabilities that change the behavior of the virtual CPU or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) the virtual machine when enabled. To enable them, please see section 4.37.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) Below you can find a list of capabilities and what their effect on the vCPU or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) the virtual machine is when enabling them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) The following information is provided along with the description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) Architectures:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) which instruction set architectures provide this ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) x86 includes both i386 and x86_64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) Target:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) whether this is a per-vcpu or per-vm capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) Parameters:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) what parameters are accepted by the capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) the return value. General error numbers (EBADF, ENOMEM, EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) are not detailed, but errors with specific meanings are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) 6.1 KVM_CAP_PPC_OSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) This capability enables interception of OSI hypercalls that otherwise would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) be treated as normal system calls to be injected into the guest. OSI hypercalls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) were invented by Mac-on-Linux to have a standardized communication mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) between the guest and the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) When this capability is enabled, KVM_EXIT_OSI can occur.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) 6.2 KVM_CAP_PPC_PAPR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) This capability enables interception of PAPR hypercalls. PAPR hypercalls are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) done using the hypercall instruction "sc 1".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) It also sets the guest privilege level to "supervisor" mode. Usually the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) runs in "hypervisor" privilege mode with a few missing features.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) In addition to the above, it changes the semantics of SDR1. In this mode, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) HTAB invisible to the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) 6.3 KVM_CAP_SW_TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) ------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) :Parameters: args[0] is the address of a struct kvm_config_tlb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) struct kvm_config_tlb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) __u64 params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) __u64 array;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) __u32 mmu_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) __u32 array_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) Configures the virtual CPU's TLB array, establishing a shared memory area
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) between userspace and KVM. The "params" and "array" fields are userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) addresses of mmu-type-specific data structures. The "array_len" field is an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) safety mechanism, and should be set to the size in bytes of the memory that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) userspace has reserved for the array. It must be at least the size dictated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) by "mmu_type" and "params".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) While KVM_RUN is active, the shared region is under control of KVM. Its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) contents are undefined, and any modification by userspace results in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) boundedly undefined behavior.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447) On return from KVM_RUN, the shared region will reflect the current state of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) to tell KVM which entries have been changed, prior to calling KVM_RUN again
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) on this vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) - The "params" field is of type "struct kvm_book3e_206_tlb_params".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) - The "array" field points to an array of type "struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) kvm_book3e_206_tlb_entry".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) - The array consists of all entries in the first TLB, followed by all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) entries in the second TLB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) - Within a TLB, entries are ordered first by increasing set number. Within a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) set, entries are ordered by way (increasing ESEL).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) - The tsize field of mas1 shall be set to 4K on TLB0, even though the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) hardware ignores this value for TLB0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) 6.4 KVM_CAP_S390_CSS_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) This capability enables support for handling of channel I/O instructions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) handled in-kernel, while the other I/O instructions are passed to userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480) SUBCHANNEL intercepts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) Note that even though this capability is enabled per-vcpu, the complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) virtual machine is affected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) 6.5 KVM_CAP_PPC_EPR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) :Parameters: args[0] defines whether the proxy facility is active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) This capability enables or disables the delivery of interrupts through the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) external proxy facility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) When enabled (args[0] != 0), every time the guest gets an external interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) delivered, it automatically exits into user space with a KVM_EXIT_EPR exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) to receive the topmost interrupt vector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) When disabled (args[0] == 0), behavior is as if this facility is unsupported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) When this capability is enabled, KVM_EXIT_EPR can occur.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) 6.6 KVM_CAP_IRQ_MPIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) :Parameters: args[0] is the MPIC device fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) args[1] is the MPIC CPU number for this vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) This capability connects the vcpu to an in-kernel MPIC device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) 6.7 KVM_CAP_IRQ_XICS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) :Parameters: args[0] is the XICS device fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) args[1] is the XICS CPU number (server ID) for this vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) This capability connects the vcpu to an in-kernel XICS device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) 6.8 KVM_CAP_S390_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) :Target: vm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) This capability enables the in-kernel irqchip for s390. Please refer to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) "4.24 KVM_CREATE_IRQCHIP" for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) 6.9 KVM_CAP_MIPS_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) :Architectures: mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) :Parameters: args[0] is reserved for future use (should be 0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) This capability allows the use of the host Floating Point Unit by the guest. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) done the ``KVM_REG_MIPS_FPR_*`` and ``KVM_REG_MIPS_FCR_*`` registers can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) accessed (depending on the current guest FPU register mode), and the Status.FR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544) Config5.FRE bits are accessible via the KVM API and also from the guest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) depending on them being supported by the FPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) 6.10 KVM_CAP_MIPS_MSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) :Architectures: mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) :Parameters: args[0] is reserved for future use (should be 0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) Once this is done the ``KVM_REG_MIPS_VEC_*`` and ``KVM_REG_MIPS_MSA_*``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) registers can be accessed, and the Config5.MSAEn bit is accessible via the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) KVM API and also from the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) 6.74 KVM_CAP_SYNC_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) :Architectures: s390, x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) :Target: s390: always enabled, x86: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566) :Returns: x86: KVM_CHECK_EXTENSION returns a bit-array indicating which register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) sets are supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) (bitfields defined in arch/x86/include/uapi/asm/kvm.h).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) As described above in the kvm_sync_regs struct info in section 5 (kvm_run):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) KVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) without having to call SET/GET_*REGS". This reduces overhead by eliminating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) repeated ioctl calls for setting and/or getting register values. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) particularly important when userspace is making synchronous guest state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) modifications, e.g. when emulating and/or intercepting instructions in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) For s390 specifics, please refer to the source code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) For x86:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) - the register sets to be copied out to kvm_run are selectable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) by userspace (rather that all sets being copied out for every exit).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) - vcpu_events are available in addition to regs and sregs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) For x86, the 'kvm_valid_regs' field of struct kvm_run is overloaded to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587) function as an input bit-array field set by userspace to indicate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) specific register sets to be copied out on the next exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) To indicate when userspace has modified values that should be copied into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) the vCPU, the all architecture bitarray field, 'kvm_dirty_regs' must be set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) This is done using the same bitflags as for the 'kvm_valid_regs' field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) If the dirty bit is not set, then the register set values will not be copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) into the vCPU even if they've been modified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) Unused bitfields in the bitarrays must be set to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) struct kvm_sync_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) struct kvm_regs regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) struct kvm_sregs sregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) struct kvm_vcpu_events events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) 6.75 KVM_CAP_PPC_IRQ_XIVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610) :Target: vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) :Parameters: args[0] is the XIVE device fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) args[1] is the XIVE CPU number (server ID) for this vcpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) This capability connects the vcpu to an in-kernel XIVE device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) 7. Capabilities that can be enabled on VMs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) There are certain capabilities that change the behavior of the virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) machine when enabled. To enable them, please see section 4.37. Below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) you can find a list of capabilities and what their effect on the VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) is when enabling them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) The following information is provided along with the description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) Architectures:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) which instruction set architectures provide this ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) x86 includes both i386 and x86_64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) Parameters:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) what parameters are accepted by the capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) the return value. General error numbers (EBADF, ENOMEM, EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) are not detailed, but errors with specific meanings are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) 7.1 KVM_CAP_PPC_ENABLE_HCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) :Parameters: args[0] is the sPAPR hcall number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) args[1] is 0 to disable, 1 to enable in-kernel handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) This capability controls whether individual sPAPR hypercalls (hcalls)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) get handled by the kernel or not. Enabling or disabling in-kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) handling of an hcall is effective across the VM. On creation, an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) initial set of hcalls are enabled for in-kernel handling, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) consists of those hcalls for which in-kernel handlers were implemented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) before this capability was implemented. If disabled, the kernel will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) not to attempt to handle the hcall, but will always exit to userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) to handle it. Note that it may not make sense to enable some and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) disable others of a group of related hcalls, but KVM does not prevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) userspace from doing that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) If the hcall number specified is not one that has an in-kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) 7.2 KVM_CAP_S390_USER_SIGP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) This capability controls which SIGP orders will be handled completely in user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) space. With this capability enabled, all fast orders will be handled completely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) in the kernel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) - SENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) - SENSE RUNNING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) - EXTERNAL CALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) - EMERGENCY SIGNAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) - CONDITIONAL EMERGENCY SIGNAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) All other orders will be handled completely in user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) Only privileged operation exceptions will be checked for in the kernel (or even
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) in the hardware prior to interception). If this capability is not enabled, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) old way of handling SIGP orders is used (partially in kernel and user space).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) 7.3 KVM_CAP_S390_VECTOR_REGISTERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) ---------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) :Returns: 0 on success, negative value on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689) Allows use of the vector registers introduced with z13 processor, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) provides for the synchronization between host and user space. Will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691) return -EINVAL if the machine does not support vectors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) 7.4 KVM_CAP_S390_USER_STSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) This capability allows post-handlers for the STSI instruction. After
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) initial handling in the kernel, KVM exits to user space with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701) KVM_EXIT_S390_STSI to allow user space to insert further data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) Before exiting to userspace, kvm handlers should fill in s390_stsi field of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) vcpu->run::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) __u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) __u8 ar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) __u8 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) __u8 fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) __u8 sel1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712) __u16 sel2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) } s390_stsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) @addr - guest address of STSI SYSIB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) @fc - function code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) @sel1 - selector 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718) @sel2 - selector 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) @ar - access register number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) KVM handlers should exit to userspace with rc = -EREMOTE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) 7.5 KVM_CAP_SPLIT_IRQCHIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) :Parameters: args[0] - number of routes reserved for userspace IOAPICs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) :Returns: 0 on success, -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) Create a local apic for each processor in the kernel. This can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) instead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) IOAPIC and PIC (and also the PIT, even though this has to be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) separately).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) This capability also enables in kernel routing of interrupt requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) when KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) used in the IRQ routing table. The first args[0] MSI routes are reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) for the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741) Fails if VCPU has already been created, or if the irqchip is already in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) kernel (i.e. KVM_CREATE_IRQCHIP has already been called).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) 7.6 KVM_CAP_S390_RI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) Allows use of runtime-instrumentation introduced with zEC12 processor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) Will return -EINVAL if the machine does not support runtime-instrumentation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) Will return -EBUSY if a VCPU has already been created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) 7.7 KVM_CAP_X2APIC_API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) :Parameters: args[0] - features that should be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) :Returns: 0 on success, -EINVAL when args[0] contains invalid features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) Valid feature flags in args[0] are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) Enabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) KVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) allowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) respective sections.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771) KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772) in logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) as a broadcast even in x2APIC mode in order to support physical x2APIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) without interrupt remapping. This is undesirable in logical mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) where 0xff represents CPUs 0-7 in cluster 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) 7.8 KVM_CAP_S390_USER_INSTR0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783) With this capability enabled, all illegal instructions 0x0000 (2 bytes) will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) be intercepted and forwarded to user space. User space can use this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) mechanism e.g. to realize 2-byte software breakpoints. The kernel will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) not inject an operating exception for these instructions, user space has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) to take care of that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) This capability can be enabled dynamically even if VCPUs were already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) created and are running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) 7.9 KVM_CAP_S390_GS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) :Returns: 0 on success; -EINVAL if the machine does not support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) guarded storage; -EBUSY if a VCPU has already been created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) Allows use of guarded storage for the KVM guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) 7.10 KVM_CAP_S390_AIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) Allow use of adapter-interruption suppression.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) :Returns: 0 on success; -EBUSY if a VCPU has already been created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) 7.11 KVM_CAP_PPC_SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) :Parameters: vsmt_mode, flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) Enabling this capability on a VM provides userspace with a way to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) the desired virtual SMT mode (i.e. the number of virtual CPUs per
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) virtual core). The virtual SMT mode, vsmt_mode, must be a power of 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) between 1 and 8. On POWER8, vsmt_mode must also be no greater than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) the number of threads per subcore for the host. Currently flags must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) be 0. A successful call to enable this capability will result in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) subsequently queried for the VM. This capability is only supported by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) HV KVM, and can only be set before any VCPUs have been created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) The KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) modes are available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) 7.12 KVM_CAP_PPC_FWNMI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) With this capability a machine check exception in the guest address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) space will cause KVM to exit the guest with NMI exit reason. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) enables QEMU to build error log and branch to guest kernel registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) machine check handling routine. Without this capability KVM will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) branch to guests' 0x200 interrupt vector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) 7.13 KVM_CAP_X86_DISABLE_EXITS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) :Parameters: args[0] defines which exits are disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) :Returns: 0 on success, -EINVAL when args[0] contains invalid exits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) Valid bits in args[0] are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) #define KVM_X86_DISABLE_EXITS_HLT (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853) #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) Enabling this capability on a VM provides userspace with a way to no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) longer intercept some instructions for improved latency in some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) workloads, and is suggested when vCPUs are associated to dedicated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) physical CPUs. More bits can be added in the future; userspace can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) just pass the KVM_CHECK_EXTENSION result to KVM_ENABLE_CAP to disable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) all such vmexits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) Do not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) 7.14 KVM_CAP_S390_HPAGE_1M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) :Returns: 0 on success, -EINVAL if hpage module parameter was not set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) flag set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) With this capability the KVM support for memory backing with 1m pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) through hugetlbfs can be enabled for a VM. After the capability is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) enabled, cmma can't be enabled anymore and pfmfi and the storage key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) interpretation are disabled. If cmma has already been enabled or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) hpage module parameter is not set to 1, -EINVAL is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) While it is generally possible to create a huge page backed VM without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) this capability, the VM will not be able to run.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) 7.15 KVM_CAP_MSR_PLATFORM_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) :Parameters: args[0] whether feature should be enabled or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) With this capability, a guest may read the MSR_PLATFORM_INFO MSR. Otherwise,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) a #GP would be raised when the guest tries to access. Currently, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) capability does not enable write permissions of this MSR for the guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) 7.16 KVM_CAP_PPC_NESTED_HV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) :Returns: 0 on success, -EINVAL when the implementation doesn't support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) nested-HV virtualization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) HV-KVM on POWER9 and later systems allows for "nested-HV"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) virtualization, which provides a way for a guest VM to run guests that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) can run using the CPU's supervisor mode (privileged non-hypervisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) state). Enabling this capability on a VM depends on the CPU having
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) the necessary functionality and on the facility being enabled with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) kvm-hv module parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) 7.17 KVM_CAP_EXCEPTION_PAYLOAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) :Parameters: args[0] whether feature should be enabled or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) With this capability enabled, CR2 will not be modified prior to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914) emulated VM-exit when L1 intercepts a #PF exception that occurs in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) L2. Similarly, for kvm-intel only, DR6 will not be modified prior to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) the emulated VM-exit when L1 intercepts a #DB exception that occurs in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) L2. As a result, when KVM_GET_VCPU_EVENTS reports a pending #PF (or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) #DB) exception for L2, exception.has_payload will be set and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) faulting address (or the new DR6 bits*) will be reported in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) exception_payload field. Similarly, when userspace injects a #PF (or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) #DB) into L2 using KVM_SET_VCPU_EVENTS, it is expected to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) exception.has_payload and to put the faulting address - or the new DR6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) bits\ [#]_ - in the exception_payload field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) This capability also enables exception.pending in struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) kvm_vcpu_events, which allows userspace to distinguish between pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) and injected exceptions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) .. [#] For the new DR6 bits, note that bit 16 is set iff the #DB exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) will clear DR6.RTM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) 7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) :Architectures: x86, arm, arm64, mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) :Parameters: args[0] whether feature should be enabled or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) Valid flags are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) With KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE is set, KVM_GET_DIRTY_LOG will not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) automatically clear and write-protect all pages that are returned as dirty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) Rather, userspace will have to do this operation separately using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) KVM_CLEAR_DIRTY_LOG.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) At the cost of a slightly more complicated operation, this provides better
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) scalability and responsiveness for two reasons. First,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) KVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) than requiring to sync a full memslot; this ensures that KVM does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) take spinlocks for an extended period of time. Second, in some cases a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) large amount of time can pass between a call to KVM_GET_DIRTY_LOG and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) userspace actually using the data in the page. Pages can be modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) during this time, which is inefficient for both the guest and userspace:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) the guest will incur a higher penalty due to write protection faults,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) while userspace can see false reports of dirty pages. Manual reprotection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) helps reducing this time, improving guest performance and reducing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) number of dirty log false positives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) With KVM_DIRTY_LOG_INITIALLY_SET set, all the bits of the dirty bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) will be initialized to 1 when created. This also improves performance because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) dirty logging can be enabled gradually in small chunks on the first call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964) to KVM_CLEAR_DIRTY_LOG. KVM_DIRTY_LOG_INITIALLY_SET depends on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (it is also only available on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) x86 and arm64 for now).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 was previously available under the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) KVM_CAP_MANUAL_DIRTY_LOG_PROTECT, but the implementation had bugs that make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970) it hard or impossible to use it correctly. The availability of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 signals that those bugs are fixed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) Userspace should not try to use KVM_CAP_MANUAL_DIRTY_LOG_PROTECT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) 7.19 KVM_CAP_PPC_SECURE_GUEST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) This capability indicates that KVM is running on a host that has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) ultravisor firmware and thus can support a secure guest. On such a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) system, a guest can ask the ultravisor to make it a secure guest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) one whose memory is inaccessible to the host except for pages which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) are explicitly requested to be shared with the host. The ultravisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) notifies KVM when a guest requests to become a secure guest, and KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985) has the opportunity to veto the transition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) If present, this capability can be enabled for a VM, meaning that KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) will allow the transition to secure guest mode. Otherwise KVM will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) veto the transition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) 7.20 KVM_CAP_HALT_POLL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) :Architectures: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) :Target: VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) :Parameters: args[0] is the maximum poll time in nanoseconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) This capability overrides the kvm module parameter halt_poll_ns for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) target VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) VCPU polling allows a VCPU to poll for wakeup events instead of immediately
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) scheduling during guest halts. The maximum time a VCPU can spend polling is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) controlled by the kvm module parameter halt_poll_ns. This capability allows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005) the maximum halt time to specified on a per-VM basis, effectively overriding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) the module parameter for the target VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) 7.21 KVM_CAP_X86_USER_SPACE_MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) -------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) :Target: VM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013) :Parameters: args[0] contains the mask of KVM_MSR_EXIT_REASON_* events to report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) :Returns: 0 on success; -1 on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) This capability enables trapping of #GP invoking RDMSR and WRMSR instructions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) into user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) When a guest requests to read or write an MSR, KVM may not implement all MSRs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) that are relevant to a respective system. It also does not differentiate by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) CPU type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) To allow more fine grained control over MSR handling, user space may enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) this capability. With it enabled, MSR accesses that match the mask specified in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) args[0] and trigger a #GP event inside the guest by KVM will instead trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR exit notifications which user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027) can then handle to implement model specific MSR handling and/or user notifications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) to inform a user that an MSR was not handled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) 8. Other capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) ======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) This section lists capabilities that give information about other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) features of the KVM implementation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036) 8.1 KVM_CAP_PPC_HWRNG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) This capability, if KVM_CHECK_EXTENSION indicates that it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) available, means that the kernel has an implementation of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) H_RANDOM hypercall backed by a hardware random-number generator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044) If present, the kernel H_RANDOM handler can be enabled for guest use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) with the KVM_CAP_PPC_ENABLE_HCALL capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) 8.2 KVM_CAP_HYPERV_SYNIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) This capability, if KVM_CHECK_EXTENSION indicates that it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053) available, means that the kernel has an implementation of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) Hyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) used to support Windows Hyper-V based guest paravirt drivers(VMBus).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) In order to use SynIC, it has to be activated by setting this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059) will disable the use of APIC hardware virtualization even if supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) by the CPU, as it's incompatible with SynIC auto-EOI behavior.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) 8.3 KVM_CAP_PPC_RADIX_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067) This capability, if KVM_CHECK_EXTENSION indicates that it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) available, means that the kernel can support guests using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) radix MMU defined in Power ISA V3.00 (as implemented in the POWER9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070) processor).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072) 8.4 KVM_CAP_PPC_HASH_MMU_V3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077) This capability, if KVM_CHECK_EXTENSION indicates that it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) available, means that the kernel can support guests using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079) hashed page table MMU defined in Power ISA V3.00 (as implemented in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) the POWER9 processor), including in-memory segment tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082) 8.5 KVM_CAP_MIPS_VZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085) :Architectures: mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088) it is available, means that full hardware assisted virtualization capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) of the hardware are available for use through KVM. An appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090) KVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091) utilises it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093) If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) available, it means that the VM is using full hardware assisted virtualization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) capabilities of the hardware. This is useful to check after creating a VM with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096) KVM_VM_MIPS_DEFAULT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) The value returned by KVM_CHECK_EXTENSION should be compared against known
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099) values (see below). All other values are reserved. This is to allow for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) possibility of other hardware assisted virtualization implementations which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) may be incompatible with the MIPS VZ ASE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103) == ==========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104) 0 The trap & emulate implementation is in use to run guest code in user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) mode. Guest virtual memory segments are rearranged to fit the guest in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) user mode address space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108) 1 The MIPS VZ ASE is in use, providing full hardware assisted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) virtualization, including standard guest virtual memory segments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) == ==========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112) 8.6 KVM_CAP_MIPS_TE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) :Architectures: mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117) This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) it is available, means that the trap & emulate implementation is available to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119) run guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120) assisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) to KVM_CREATE_VM to create a VM which utilises it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) available, it means that the VM is using trap & emulate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) 8.7 KVM_CAP_MIPS_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129) :Architectures: mips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) This capability indicates the supported architecture type of the guest, i.e. the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) supported register and address width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) The values returned when this capability is checked by KVM_CHECK_EXTENSION on a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) kvm VM handle correspond roughly to the CP0_Config.AT register field, and should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) be checked specifically against known values (see below). All other values are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137) reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) == ========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) 0 MIPS32 or microMIPS32.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141) Both registers and addresses are 32-bits wide.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142) It will only be possible to run 32-bit guest code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144) 1 MIPS64 or microMIPS64 with access only to 32-bit compatibility segments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) Registers are 64-bits wide, but addresses are 32-bits wide.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146) 64-bit guest code may run but cannot access MIPS64 memory segments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147) It will also be possible to run 32-bit guest code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) 2 MIPS64 or microMIPS64 with access to all address segments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) Both registers and addresses are 64-bits wide.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151) It will be possible to run 64-bit or 32-bit guest code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152) == ========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154) 8.9 KVM_CAP_ARM_USER_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157) :Architectures: arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159) This capability, if KVM_CHECK_EXTENSION indicates that it is available, means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160) that if userspace creates a VM without an in-kernel interrupt controller, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161) will be notified of changes to the output level of in-kernel emulated devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) which can generate virtual interrupts, presented to the VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163) For such VMs, on every return to userspace, the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) updates the vcpu's run->s.regs.device_irq_level field to represent the actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165) output level of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) Whenever kvm detects a change in the device output level, kvm guarantees at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) least one return to userspace before running the VM. This exit could either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169) be a KVM_EXIT_INTR or any other exit event, like KVM_EXIT_MMIO. This way,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) userspace can always sample the device output level and re-compute the state of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171) the userspace interrupt controller. Userspace should always check the state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172) of run->s.regs.device_irq_level on every kvm exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173) The value in run->s.regs.device_irq_level can represent both level and edge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) triggered interrupt signals, depending on the device. Edge triggered interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175) signals will exit to userspace with the bit in run->s.regs.device_irq_level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176) set exactly once per edge signal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) The field run->s.regs.device_irq_level is available independent of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6179) run->kvm_valid_regs or run->kvm_dirty_regs bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6181) If KVM_CAP_ARM_USER_IRQ is supported, the KVM_CHECK_EXTENSION ioctl returns a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182) number larger than 0 indicating the version of this capability is implemented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) and thereby which bits in run->s.regs.device_irq_level can signal values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) Currently the following bits are defined for the device_irq_level bitmap::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187) KVM_CAP_ARM_USER_IRQ >= 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189) KVM_ARM_DEV_EL1_VTIMER - EL1 virtual timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) KVM_ARM_DEV_EL1_PTIMER - EL1 physical timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191) KVM_ARM_DEV_PMU - ARM PMU overflow interrupt signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) Future versions of kvm may implement additional events. These will get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) indicated by returning a higher number from KVM_CHECK_EXTENSION and will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) listed above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) 8.10 KVM_CAP_PPC_SMT_POSSIBLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198) -----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200) :Architectures: ppc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) Querying this capability returns a bitmap indicating the possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203) virtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204) (counting from the right) is set, then a virtual SMT mode of 2^N is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) 8.11 KVM_CAP_HYPERV_SYNIC2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212) This capability enables a newer version of Hyper-V Synthetic interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) controller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214) doesn't clear SynIC message and event flags pages when they are enabled by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) writing to the respective MSRs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217) 8.12 KVM_CAP_HYPERV_VP_INDEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222) This capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223) value is used to denote the target vcpu for a SynIC interrupt. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224) compatibilty, KVM initializes this msr to KVM's internal vcpu index. When this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) capability is absent, userspace can still query this msr's value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227) 8.13 KVM_CAP_S390_AIS_MIGRATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228) -------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) :Parameters: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233) This capability indicates if the flic device will be able to get/set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) AIS states for migration via the KVM_DEV_FLIC_AISM_ALL attribute and allows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) to discover this without having to create a flic device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237) 8.14 KVM_CAP_S390_PSW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242) This capability indicates that the PSW is exposed via the kvm_run structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) 8.15 KVM_CAP_S390_GMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249) This capability indicates that the user space memory used as guest mapping can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250) be anywhere in the user memory address space, as long as the memory slots are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) aligned and sized to a segment (1MB) boundary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253) 8.16 KVM_CAP_S390_COW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258) This capability indicates that the user space memory used as guest mapping can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259) use copy-on-write semantics as well as dirty pages tracking via read-only page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262) 8.17 KVM_CAP_S390_BPB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) This capability indicates that kvm will implement the interfaces to handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268) reset, migration and nested KVM for branch prediction blocking. The stfle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269) facility 82 should not be provided to the guest without this capability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) 8.18 KVM_CAP_HYPERV_TLBFLUSH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) This capability indicates that KVM supports paravirtualized Hyper-V TLB Flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277) hypercalls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278) HvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) HvFlushVirtualAddressList, HvFlushVirtualAddressListEx.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281) 8.19 KVM_CAP_ARM_INJECT_SERROR_ESR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282) ----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284) :Architectures: arm, arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286) This capability indicates that userspace can specify (via the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) KVM_SET_VCPU_EVENTS ioctl) the syndrome value reported to the guest when it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) takes a virtual SError interrupt exception.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) If KVM advertises this capability, userspace can only specify the ISS field for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290) the ESR syndrome. Other parts of the ESR, such as the EC are generated by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) CPU when the exception is taken. If this virtual SError is taken to EL1 using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292) AArch64, this value will be reported in the ISS field of ESR_ELx.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294) See KVM_CAP_VCPU_EVENTS for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296) 8.20 KVM_CAP_HYPERV_SEND_IPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301) This capability indicates that KVM supports paravirtualized Hyper-V IPI send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302) hypercalls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) HvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) 8.21 KVM_CAP_HYPERV_DIRECT_TLBFLUSH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306) -----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6308) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6310) This capability indicates that KVM running on top of Hyper-V hypervisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) enables Direct TLB flush for its guests meaning that TLB flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) hypercalls are handled by Level 0 hypervisor (Hyper-V) bypassing KVM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) Due to the different ABI for hypercall parameters between Hyper-V and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314) KVM, enabling this capability effectively disables all hypercall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315) handling by KVM (as some KVM hypercall may be mistakenly treated as TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) flush hypercalls by Hyper-V) so userspace should disable KVM identification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317) in CPUID and only exposes Hyper-V identification. In this case, guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318) thinks it's running on Hyper-V and only use Hyper-V hypercalls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) 8.22 KVM_CAP_S390_VCPU_RESETS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321) -----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325) This capability indicates that the KVM_S390_NORMAL_RESET and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326) KVM_S390_CLEAR_RESET ioctls are available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) 8.23 KVM_CAP_S390_PROTECTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333) This capability indicates that the Ultravisor has been initialized and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334) KVM can therefore start protected VMs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335) This capability governs the KVM_S390_PV_COMMAND ioctl and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336) KVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) guests when the state change is invalid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) 8.24 KVM_CAP_STEAL_TIME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) :Architectures: arm64, x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) This capability indicates that KVM supports steal time accounting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) When steal time accounting is supported it may be enabled with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) architecture-specific interfaces. This capability and the architecture-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347) specific interfaces must be consistent, i.e. if one says the feature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) is supported, than the other should as well and vice versa. For arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) see Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350) For x86 see Documentation/virt/kvm/msr.rst "MSR_KVM_STEAL_TIME".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352) 8.25 KVM_CAP_S390_DIAG318
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355) :Architectures: s390
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357) This capability enables a guest to set information about its control program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358) (i.e. guest kernel type and version). The information is helpful during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) system/firmware service events, providing additional data about the guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360) environments running on the machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) The information is associated with the DIAGNOSE 0x318 instruction, which sets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) an 8-byte value consisting of a one-byte Control Program Name Code (CPNC) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364) a 7-byte Control Program Version Code (CPVC). The CPNC determines what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365) environment the control program is running in (e.g. Linux, z/VM...), and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) CPVC is used for information specific to OS (e.g. Linux version, Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367) distribution...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) If this capability is available, then the CPNC and CPVC can be synchronized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) between KVM and userspace via the sync regs mechanism (KVM_SYNC_DIAG318).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) 8.26 KVM_CAP_X86_USER_SPACE_MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373) -------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377) This capability indicates that KVM supports deflection of MSR reads and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) writes to user space. It can be enabled on a VM level. If enabled, MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379) accesses that would usually trigger a #GP by KVM into the guest will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380) instead get bounced to user space through the KVM_EXIT_X86_RDMSR and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) KVM_EXIT_X86_WRMSR exit notifications.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383) 8.27 KVM_X86_SET_MSR_FILTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) :Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388) This capability indicates that KVM supports that accesses to user defined MSRs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6389) may be rejected. With this capability exposed, KVM exports new VM ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6390) KVM_X86_SET_MSR_FILTER which user space can call to specify bitmaps of MSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6391) ranges that KVM should reject access to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6393) In combination with KVM_CAP_X86_USER_SPACE_MSR, this allows user space to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6394) trap and emulate MSRs that are outside of the scope of KVM as well as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6395) limit the attack surface on KVM's MSR emulation code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6397) 8.28 KVM_CAP_ENFORCE_PV_CPUID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6398) -----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6400) Architectures: x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6402) When enabled, KVM will disable paravirtual features provided to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6403) guest according to the bits in the KVM_CPUID_FEATURES CPUID leaf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6404) (0x40000001). Otherwise, a guest may use the paravirtual features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6405) regardless of what has actually been exposed through the CPUID leaf.