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