^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) POWER9 eXternal Interrupt Virtualization Engine (XIVE Gen1)
^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 types supported:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) - KVM_DEV_TYPE_XIVE POWER9 XIVE Interrupt Controller generation 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) This device acts as a VM interrupt controller. It provides the KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) interface to configure the interrupt sources of a VM in the underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) POWER9 XIVE interrupt controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) Only one XIVE instance may be instantiated. A guest XIVE device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) requires a POWER9 host and the guest OS should have support for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) XIVE native exploitation interrupt mode. If not, it should run using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) the legacy interrupt mode, referred as XICS (POWER7/8).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Device Mappings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) The KVM device exposes different MMIO ranges of the XIVE HW which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) are required for interrupt management. These are exposed to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) guest in VMAs populated with a custom VM fault handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 1. Thread Interrupt Management Area (TIMA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) Each thread has an associated Thread Interrupt Management context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) composed of a set of registers. These registers let the thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) handle priority management and interrupt acknowledgment. The most
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) important are :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) - Interrupt Pending Buffer (IPB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) - Current Processor Priority (CPPR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) - Notification Source Register (NSR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) They are exposed to software in four different pages each proposing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) a view with a different privilege. The first page is for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) physical thread context and the second for the hypervisor. Only the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) third (operating system) and the fourth (user level) are exposed the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) guest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 2. Event State Buffer (ESB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Each source is associated with an Event State Buffer (ESB) with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) either a pair of even/odd pair of pages which provides commands to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) manage the source: to trigger, to EOI, to turn off the source for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 3. Device pass-through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) When a device is passed-through into the guest, the source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) interrupts are from a different HW controller (PHB4) and the ESB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) pages exposed to the guest should accommadate this change.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) The passthru_irq helpers, kvmppc_xive_set_mapped() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) kvmppc_xive_clr_mapped() are called when the device HW irqs are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) mapped into or unmapped from the guest IRQ number space. The KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) device extends these helpers to clear the ESB pages of the guest IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) number being mapped and then lets the VM fault handler repopulate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) The handler will insert the ESB page corresponding to the HW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) interrupt of the device being passed-through or the initial IPI ESB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) page if the device has being removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) The ESB remapping is fully transparent to the guest and the OS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) device driver. All handling is done within VFIO and the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) helpers in KVM-PPC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Groups:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 1. KVM_DEV_XIVE_GRP_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) Provides global controls on the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 1.1 KVM_DEV_XIVE_RESET (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) Resets the interrupt controller configuration for sources and event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) queues. To be used by kexec and kdump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) Errors: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 1.2 KVM_DEV_XIVE_EQ_SYNC (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) Sync all the sources and queues and mark the EQ pages dirty. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) to make sure that a consistent memory state is captured when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) migrating the VM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) Errors: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 1.3 KVM_DEV_XIVE_NR_SERVERS (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) The kvm_device_attr.addr points to a __u32 value which is the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) interrupt server numbers (ie, highest possible vcpu id plus one).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ======= ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) -EINVAL Value greater than KVM_MAX_VCPU_ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) -EFAULT Invalid user pointer for attr->addr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) -EBUSY A vCPU is already connected to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ======= ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) 2. KVM_DEV_XIVE_GRP_SOURCE (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) Initializes a new source in the XIVE device and mask it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) Interrupt source number (64-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) The kvm_device_attr.addr points to a __u64 value::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) bits: | 63 .... 2 | 1 | 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) values: | unused | level | type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) - type: 0:MSI 1:LSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) - level: assertion level in case of an LSI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) ======= ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) -E2BIG Interrupt source number is out of range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) -ENOMEM Could not create a new source block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) -EFAULT Invalid user pointer for attr->addr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) -ENXIO Could not allocate underlying HW interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ======= ==========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 3. KVM_DEV_XIVE_GRP_SOURCE_CONFIG (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) Configures source targeting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) Interrupt source number (64-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) The kvm_device_attr.addr points to a __u64 value::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) bits: | 63 .... 33 | 32 | 31 .. 3 | 2 .. 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) values: | eisn | mask | server | priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) - priority: 0-7 interrupt priority level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) - server: CPU number chosen to handle the interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) - mask: mask flag (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) - eisn: Effective Interrupt Source Number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) Errors:
^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) -ENOENT Unknown source number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) -EINVAL Not initialized source number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) -EINVAL Invalid priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) -EINVAL Invalid CPU number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) -EFAULT Invalid user pointer for attr->addr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) -ENXIO CPU event queues not configured or configuration of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) underlying HW interrupt failed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) -EBUSY No CPU available to serve interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ======= =======================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 4. KVM_DEV_XIVE_GRP_EQ_CONFIG (read-write)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) Configures an event queue of a CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) EQ descriptor identifier (64-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) The EQ descriptor identifier is a tuple (server, priority)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) bits: | 63 .... 32 | 31 .. 3 | 2 .. 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) values: | unused | server | priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) The kvm_device_attr.addr points to::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct kvm_ppc_xive_eq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) __u32 qshift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) __u64 qaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) __u32 qtoggle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) __u32 qindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) __u8 pad[40];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) - flags: queue flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) KVM_XIVE_EQ_ALWAYS_NOTIFY (required)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) forces notification without using the coalescing mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) provided by the XIVE END ESBs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) - qshift: queue size (power of 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) - qaddr: real address of queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) - qtoggle: current queue toggle bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) - qindex: current queue index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) - pad: reserved for future use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) ======= =========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) -ENOENT Invalid CPU number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) -EINVAL Invalid priority
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) -EINVAL Invalid flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) -EINVAL Invalid queue size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) -EINVAL Invalid queue address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) -EFAULT Invalid user pointer for attr->addr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) -EIO Configuration of the underlying HW failed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ======= =========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 5. KVM_DEV_XIVE_GRP_SOURCE_SYNC (write only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) Synchronize the source to flush event notifications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) Attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) Interrupt source number (64-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) Errors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) ======= =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) -ENOENT Unknown source number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) -EINVAL Not initialized source number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ======= =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * VCPU state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) The XIVE IC maintains VP interrupt state in an internal structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) called the NVT. When a VP is not dispatched on a HW processor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) thread, this structure can be updated by HW if the VP is the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) of an event notification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) It is important for migration to capture the cached IPB from the NVT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) as it synthesizes the priorities of the pending interrupts. We
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) capture a bit more to report debug information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) KVM_REG_PPC_VP_STATE (2 * 64bits)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) bits: | 63 .... 32 | 31 .... 0 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) values: | TIMA word0 | TIMA word1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) bits: | 127 .......... 64 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) values: | unused |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Migration:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) Saving the state of a VM using the XIVE native exploitation mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) should follow a specific sequence. When the VM is stopped :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 1. Mask all sources (PQ=01) to stop the flow of events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 2. Sync the XIVE device with the KVM control KVM_DEV_XIVE_EQ_SYNC to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) flush any in-flight event notification and to stabilize the EQs. At
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) this stage, the EQ pages are marked dirty to make sure they are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) transferred in the migration sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 3. Capture the state of the source targeting, the EQs configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) and the state of thread interrupt context registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) Restore is similar:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 1. Restore the EQ configuration. As targeting depends on it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 2. Restore targeting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 3. Restore the thread interrupt contexts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 4. Restore the source states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 5. Let the vCPU run