^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) XICS interrupt controller
^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) Device type supported: KVM_DEV_TYPE_XICS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) Groups:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 1. KVM_DEV_XICS_GRP_SOURCES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) One per interrupt source, indexed by the source number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 2. KVM_DEV_XICS_GRP_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 2.1 KVM_DEV_XICS_NR_SERVERS (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) The kvm_device_attr.addr points to a __u32 value which is the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) interrupt server numbers (ie, highest possible vcpu id plus one).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ======= ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) -EINVAL Value greater than KVM_MAX_VCPU_ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) -EFAULT Invalid user pointer for attr->addr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) -EBUSY A vcpu is already connected to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ======= ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) This device emulates the XICS (eXternal Interrupt Controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Specification) defined in PAPR. The XICS has a set of interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) sources, each identified by a 20-bit source number, and a set of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Interrupt Control Presentation (ICP) entities, also called "servers",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) each associated with a virtual CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) The ICP entities are created by enabling the KVM_CAP_IRQ_ARCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) capability for each vcpu, specifying KVM_CAP_IRQ_XICS in args[0] and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) the interrupt server number (i.e. the vcpu number from the XICS's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) point of view) in args[1] of the kvm_enable_cap struct. Each ICP has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 64 bits of state which can be read and written using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) KVM_GET_ONE_REG and KVM_SET_ONE_REG ioctls on the vcpu. The 64 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) state word has the following bitfields, starting at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) least-significant end of the word:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * Unused, 16 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * Pending interrupt priority, 8 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) Zero is the highest priority, 255 means no interrupt is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * Pending IPI (inter-processor interrupt) priority, 8 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) Zero is the highest priority, 255 means no IPI is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * Pending interrupt source number, 24 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Zero means no interrupt pending, 2 means an IPI is pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * Current processor priority, 8 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) Zero is the highest priority, meaning no interrupts can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) delivered, and 255 is the lowest priority.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) Each source has 64 bits of state that can be read and written using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) the KVM_GET_DEVICE_ATTR and KVM_SET_DEVICE_ATTR ioctls, specifying the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) KVM_DEV_XICS_GRP_SOURCES attribute group, with the attribute number being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) the interrupt source number. The 64 bit state word has the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) bitfields, starting from the least-significant end of the word:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * Destination (server number), 32 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) This specifies where the interrupt should be sent, and is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) interrupt server number specified for the destination vcpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * Priority, 8 bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) This is the priority specified for this interrupt source, where 0 is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) the highest priority and 255 is the lowest. An interrupt with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) priority of 255 will never be delivered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * Level sensitive flag, 1 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) This bit is 1 for a level-sensitive interrupt source, or 0 for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) edge-sensitive (or MSI).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * Masked flag, 1 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) This bit is set to 1 if the interrupt is masked (cannot be delivered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) regardless of its priority), for example by the ibm,int-off RTAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) call, or 0 if it is not masked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * Pending flag, 1 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) This bit is 1 if the source has a pending interrupt, otherwise 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) Only one XICS instance may be created per VM.