124563a58SCédric Le Goater================================ 224563a58SCédric Le GoaterPOWER9 XIVE interrupt controller 324563a58SCédric Le Goater================================ 424563a58SCédric Le Goater 524563a58SCédric Le GoaterThe POWER9 processor comes with a new interrupt controller 624563a58SCédric Le Goaterarchitecture, called XIVE as "eXternal Interrupt Virtualization 724563a58SCédric Le GoaterEngine". 824563a58SCédric Le Goater 924563a58SCédric Le GoaterCompared to the previous architecture, the main characteristics of 1024563a58SCédric Le GoaterXIVE are to support a larger number of interrupt sources and to 1124563a58SCédric Le Goaterdeliver interrupts directly to virtual processors without hypervisor 1224563a58SCédric Le Goaterassistance. This removes the context switches required for the 1324563a58SCédric Le Goaterdelivery process. 1424563a58SCédric Le Goater 1524563a58SCédric Le Goater 1624563a58SCédric Le GoaterXIVE architecture 1724563a58SCédric Le Goater================= 1824563a58SCédric Le Goater 1924563a58SCédric Le GoaterThe XIVE IC is composed of three sub-engines, each taking care of a 2024563a58SCédric Le Goaterprocessing layer of external interrupts: 2124563a58SCédric Le Goater 2224563a58SCédric Le Goater- Interrupt Virtualization Source Engine (IVSE), or Source Controller 23b87a0100SCédric Le Goater (SC). These are found in PCI PHBs, in the Processor Service 24b87a0100SCédric Le Goater Interface (PSI) host bridge Controller, but also inside the main 25b87a0100SCédric Le Goater controller for the core IPIs and other sub-chips (NX, CAP, NPU) of 26b87a0100SCédric Le Goater the chip/processor. They are configured to feed the IVRE with 27b87a0100SCédric Le Goater events. 2824563a58SCédric Le Goater- Interrupt Virtualization Routing Engine (IVRE) or Virtualization 2924563a58SCédric Le Goater Controller (VC). It handles event coalescing and perform interrupt 3024563a58SCédric Le Goater routing by matching an event source number with an Event 3124563a58SCédric Le Goater Notification Descriptor (END). 3224563a58SCédric Le Goater- Interrupt Virtualization Presentation Engine (IVPE) or Presentation 3324563a58SCédric Le Goater Controller (PC). It maintains the interrupt context state of each 3424563a58SCédric Le Goater thread and handles the delivery of the external interrupt to the 3524563a58SCédric Le Goater thread. 3624563a58SCédric Le Goater 3724563a58SCédric Le Goater:: 3824563a58SCédric Le Goater 3924563a58SCédric Le Goater XIVE Interrupt Controller 4024563a58SCédric Le Goater +------------------------------------+ IPIs 4124563a58SCédric Le Goater | +---------+ +---------+ +--------+ | +-------+ 4224563a58SCédric Le Goater | |IVRE | |Common Q | |IVPE |----> | CORES | 4324563a58SCédric Le Goater | | esb | | | | |----> | | 4424563a58SCédric Le Goater | | eas | | Bridge | | tctx |----> | | 4524563a58SCédric Le Goater | |SC end | | | | nvt | | | | 4624563a58SCédric Le Goater +------+ | +---------+ +----+----+ +--------+ | +-+-+-+-+ 4724563a58SCédric Le Goater | RAM | +------------------|-----------------+ | | | 4824563a58SCédric Le Goater | | | | | | 4924563a58SCédric Le Goater | | | | | | 5024563a58SCédric Le Goater | | +--------------------v------------------------v-v-v--+ other 5124563a58SCédric Le Goater | <--+ Power Bus +--> chips 5224563a58SCédric Le Goater | esb | +---------+-----------------------+------------------+ 5324563a58SCédric Le Goater | eas | | | 5424563a58SCédric Le Goater | end | +--|------+ | 5524563a58SCédric Le Goater | nvt | +----+----+ | +----+----+ 5624563a58SCédric Le Goater +------+ |IVSE | | |IVSE | 5724563a58SCédric Le Goater | | | | | 5824563a58SCédric Le Goater | PQ-bits | | | PQ-bits | 5924563a58SCédric Le Goater | local |-+ | in VC | 6024563a58SCédric Le Goater +---------+ +---------+ 6124563a58SCédric Le Goater PCIe NX,NPU,CAPI 6224563a58SCédric Le Goater 6324563a58SCédric Le Goater 6424563a58SCédric Le Goater PQ-bits: 2 bits source state machine (P:pending Q:queued) 6524563a58SCédric Le Goater esb: Event State Buffer (Array of PQ bits in an IVSE) 6624563a58SCédric Le Goater eas: Event Assignment Structure 6724563a58SCédric Le Goater end: Event Notification Descriptor 6824563a58SCédric Le Goater nvt: Notification Virtual Target 6924563a58SCédric Le Goater tctx: Thread interrupt Context registers 7024563a58SCédric Le Goater 7124563a58SCédric Le Goater 7224563a58SCédric Le Goater 7324563a58SCédric Le GoaterXIVE internal tables 7424563a58SCédric Le Goater-------------------- 7524563a58SCédric Le Goater 7624563a58SCédric Le GoaterEach of the sub-engines uses a set of tables to redirect interrupts 7724563a58SCédric Le Goaterfrom event sources to CPU threads. 7824563a58SCédric Le Goater 7924563a58SCédric Le Goater:: 8024563a58SCédric Le Goater 8124563a58SCédric Le Goater +-------+ 8224563a58SCédric Le Goater User or O/S | EQ | 8324563a58SCédric Le Goater or +------>|entries| 8424563a58SCédric Le Goater Hypervisor | | .. | 8524563a58SCédric Le Goater Memory | +-------+ 8624563a58SCédric Le Goater | ^ 8724563a58SCédric Le Goater | | 8824563a58SCédric Le Goater +-------------------------------------------------+ 8924563a58SCédric Le Goater | | 9024563a58SCédric Le Goater Hypervisor +------+ +---+--+ +---+--+ +------+ 9124563a58SCédric Le Goater Memory | ESB | | EAT | | ENDT | | NVTT | 9224563a58SCédric Le Goater (skiboot) +----+-+ +----+-+ +----+-+ +------+ 9324563a58SCédric Le Goater ^ | ^ | ^ | ^ 9424563a58SCédric Le Goater | | | | | | | 9524563a58SCédric Le Goater +-------------------------------------------------+ 9624563a58SCédric Le Goater | | | | | | | 9724563a58SCédric Le Goater | | | | | | | 9824563a58SCédric Le Goater +----|--|--------|--|--------|--|-+ +-|-----+ +------+ 9924563a58SCédric Le Goater | | | | | | | | | | tctx| |Thread| 10024563a58SCédric Le Goater IPI or ---+ + v + v + v |---| + .. |-----> | 10124563a58SCédric Le Goater HW events | | | | | | 10224563a58SCédric Le Goater | IVRE | | IVPE | +------+ 10324563a58SCédric Le Goater +---------------------------------+ +-------+ 10424563a58SCédric Le Goater 10524563a58SCédric Le Goater 10624563a58SCédric Le GoaterThe IVSE have a 2-bits state machine, P for pending and Q for queued, 10724563a58SCédric Le Goaterfor each source that allows events to be triggered. They are stored in 10824563a58SCédric Le Goateran Event State Buffer (ESB) array and can be controlled by MMIOs. 10924563a58SCédric Le Goater 11024563a58SCédric Le GoaterIf the event is let through, the IVRE looks up in the Event Assignment 11124563a58SCédric Le GoaterStructure (EAS) table for an Event Notification Descriptor (END) 11224563a58SCédric Le Goaterconfigured for the source. Each Event Notification Descriptor defines 11324563a58SCédric Le Goatera notification path to a CPU and an in-memory Event Queue, in which 11424563a58SCédric Le Goaterwill be enqueued an EQ data for the O/S to pull. 11524563a58SCédric Le Goater 11624563a58SCédric Le GoaterThe IVPE determines if a Notification Virtual Target (NVT) can handle 11724563a58SCédric Le Goaterthe event by scanning the thread contexts of the VCPUs dispatched on 11824563a58SCédric Le Goaterthe processor HW threads. It maintains the interrupt context state of 11924563a58SCédric Le Goatereach thread in a NVT table. 12024563a58SCédric Le Goater 12124563a58SCédric Le GoaterXIVE thread interrupt context 12224563a58SCédric Le Goater----------------------------- 12324563a58SCédric Le Goater 12424563a58SCédric Le GoaterThe XIVE presenter can generate four different exceptions to its 12524563a58SCédric Le GoaterHW threads: 12624563a58SCédric Le Goater 12724563a58SCédric Le Goater- hypervisor exception 12824563a58SCédric Le Goater- O/S exception 12924563a58SCédric Le Goater- Event-Based Branch (user level) 13024563a58SCédric Le Goater- msgsnd (doorbell) 13124563a58SCédric Le Goater 13224563a58SCédric Le GoaterEach exception has a state independent from the others called a Thread 13324563a58SCédric Le GoaterInterrupt Management context. This context is a set of registers which 13424563a58SCédric Le Goaterlets the thread handle priority management and interrupt 13524563a58SCédric Le Goateracknowledgment among other things. The most important ones being : 13624563a58SCédric Le Goater 13724563a58SCédric Le Goater- Interrupt Priority Register (PIPR) 13824563a58SCédric Le Goater- Interrupt Pending Buffer (IPB) 13924563a58SCédric Le Goater- Current Processor Priority (CPPR) 14024563a58SCédric Le Goater- Notification Source Register (NSR) 14124563a58SCédric Le Goater 14224563a58SCédric Le GoaterTIMA 14324563a58SCédric Le Goater~~~~ 14424563a58SCédric Le Goater 14524563a58SCédric Le GoaterThe Thread Interrupt Management registers are accessible through a 14624563a58SCédric Le Goaterspecific MMIO region, called the Thread Interrupt Management Area 14724563a58SCédric Le Goater(TIMA), four aligned pages, each exposing a different view of the 14824563a58SCédric Le Goaterregisters. First page (page address ending in ``0b00``) gives access 14924563a58SCédric Le Goaterto the entire context and is reserved for the ring 0 view for the 15024563a58SCédric Le Goaterphysical thread context. The second (page address ending in ``0b01``) 15124563a58SCédric Le Goateris for the hypervisor, ring 1 view. The third (page address ending in 15224563a58SCédric Le Goater``0b10``) is for the operating system, ring 2 view. The fourth (page 15324563a58SCédric Le Goateraddress ending in ``0b11``) is for user level, ring 3 view. 15424563a58SCédric Le Goater 15524563a58SCédric Le GoaterInterrupt flow from an O/S perspective 15624563a58SCédric Le Goater~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 15724563a58SCédric Le Goater 15824563a58SCédric Le GoaterAfter an event data has been enqueued in the O/S Event Queue, the IVPE 15924563a58SCédric Le Goaterraises the bit corresponding to the priority of the pending interrupt 16024563a58SCédric Le Goaterin the register IBP (Interrupt Pending Buffer) to indicate that an 16124563a58SCédric Le Goaterevent is pending in one of the 8 priority queues. The Pending 16224563a58SCédric Le GoaterInterrupt Priority Register (PIPR) is also updated using the IPB. This 16324563a58SCédric Le Goaterregister represent the priority of the most favored pending 16424563a58SCédric Le Goaternotification. 16524563a58SCédric Le Goater 166*df59feb1SDr. David Alan GilbertThe PIPR is then compared to the Current Processor Priority 16724563a58SCédric Le GoaterRegister (CPPR). If it is more favored (numerically less than), the 16824563a58SCédric Le GoaterCPU interrupt line is raised and the EO bit of the Notification Source 16924563a58SCédric Le GoaterRegister (NSR) is updated to notify the presence of an exception for 17024563a58SCédric Le Goaterthe O/S. The O/S acknowledges the interrupt with a special load in the 17124563a58SCédric Le GoaterThread Interrupt Management Area. 17224563a58SCédric Le Goater 17324563a58SCédric Le GoaterThe O/S handles the interrupt and when done, performs an EOI using a 17424563a58SCédric Le GoaterMMIO operation on the ESB management page of the associate source. 17524563a58SCédric Le Goater 17624563a58SCédric Le GoaterOverview of the QEMU models for XIVE 17724563a58SCédric Le Goater==================================== 17824563a58SCédric Le Goater 17924563a58SCédric Le GoaterThe XiveSource models the IVSE in general, internal and external. It 18024563a58SCédric Le Goaterhandles the source ESBs and the MMIO interface to control them. 18124563a58SCédric Le Goater 18224563a58SCédric Le GoaterThe XiveNotifier is a small helper interface interconnecting the 18324563a58SCédric Le GoaterXiveSource to the XiveRouter. 18424563a58SCédric Le Goater 18524563a58SCédric Le GoaterThe XiveRouter is an abstract model acting as a combined IVRE and 18624563a58SCédric Le GoaterIVPE. It routes event notifications using the EAS and END tables to 18724563a58SCédric Le Goaterthe IVPE sub-engine which does a CAM scan to find a CPU to deliver the 18824563a58SCédric Le Goaterexception. Storage should be provided by the inheriting classes. 18924563a58SCédric Le Goater 19024563a58SCédric Le GoaterXiveEnDSource is a special source object. It exposes the END ESB MMIOs 19124563a58SCédric Le Goaterof the Event Queues which are used for coalescing event notifications 19224563a58SCédric Le Goaterand for escalation. Not used on the field, only to sync the EQ cache 19324563a58SCédric Le Goaterin OPAL. 19424563a58SCédric Le Goater 19524563a58SCédric Le GoaterFinally, the XiveTCTX contains the interrupt state context of a thread, 19624563a58SCédric Le Goaterfour sets of registers, one for each exception that can be delivered 19724563a58SCédric Le Goaterto a CPU. These contexts are scanned by the IVPE to find a matching VP 19824563a58SCédric Le Goaterwhen a notification is triggered. It also models the Thread Interrupt 19924563a58SCédric Le GoaterManagement Area (TIMA), which exposes the thread context registers to 20024563a58SCédric Le Goaterthe CPU for interrupt management. 201