1. 02 7月, 2019 1 次提交
    • C
      spapr/xive: rework the mapping the KVM memory regions · 981b1c62
      Cédric Le Goater 提交于
      Today, the interrupt device is fully initialized at reset when the CAS
      negotiation process has completed. Depending on the KVM capabilities,
      the SpaprXive memory regions (ESB, TIMA) are initialized with a host
      MMIO backend or a QEMU emulated backend. This results in a complex
      initialization sequence partially done at realize and later at reset,
      and some memory region leaks.
      
      To simplify this sequence and to remove of the late initialization of
      the emulated device which is required to be done only once, we
      introduce new memory regions specific for KVM. These regions are
      mapped as overlaps on top of the emulated device to make use of the
      host MMIOs. Also provide proper cleanups of these regions when the
      XIVE KVM device is destroyed to fix the leaks.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Message-Id: <20190614165920.12670-2-clg@kaod.org>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      981b1c62
  2. 12 6月, 2019 1 次提交
  3. 29 5月, 2019 4 次提交
    • C
      spapr/irq: add KVM support to the 'dual' machine · 3f777abc
      Cédric Le Goater 提交于
      The interrupt mode is chosen by the CAS negotiation process and
      activated after a reset to take into account the required changes in
      the machine. This brings new constraints on how the associated KVM IRQ
      device is initialized.
      
      Currently, each model takes care of the initialization of the KVM
      device in their realize method but this is not possible anymore as the
      initialization needs to be done globaly when the interrupt mode is
      known, i.e. when machine is reseted. It also means that we need a way
      to delete a KVM device when another mode is chosen.
      
      Also, to support migration, the QEMU objects holding the state to
      transfer should always be available but not necessarily activated.
      
      The overall approach of this proposal is to initialize both interrupt
      mode at the QEMU level to keep the IRQ number space in sync and to
      allow switching from one mode to another. For the KVM side of things,
      the whole initialization of the KVM device, sources and presenters, is
      grouped in a single routine. The XICS and XIVE sPAPR IRQ reset
      handlers are modified accordingly to handle the init and the delete
      sequences of the KVM device.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20190513084245.25755-15-clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      3f777abc
    • C
      spapr/xive: add migration support for KVM · 277dd3d7
      Cédric Le Goater 提交于
      When the VM is stopped, the VM state handler stabilizes the XIVE IC
      and marks the EQ pages dirty. These are then transferred to destination
      before the transfer of the device vmstates starts.
      
      The SpaprXive interrupt controller model captures the XIVE internal
      tables, EAT and ENDT and the XiveTCTX model does the same for the
      thread interrupt context registers.
      
      At restart, the SpaprXive 'post_load' method restores all the XIVE
      states. It is called by the sPAPR machine 'post_load' method, when all
      XIVE states have been transferred and loaded.
      
      Finally, the source states are restored in the VM change state handler
      when the machine reaches the running state.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20190513084245.25755-7-clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      277dd3d7
    • C
      spapr/xive: add state synchronization with KVM · 7bfc759c
      Cédric Le Goater 提交于
      This extends the KVM XIVE device backend with 'synchronize_state'
      methods used to retrieve the state from KVM. The HW state of the
      sources, the KVM device and the thread interrupt contexts are
      collected for the monitor usage and also migration.
      
      These get operations rely on their KVM counterpart in the host kernel
      which acts as a proxy for OPAL, the host firmware. The set operations
      will be added for migration support later.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Message-Id: <20190513084245.25755-5-clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      7bfc759c
    • C
      spapr/xive: add KVM support · 38afd772
      Cédric Le Goater 提交于
      This introduces a set of helpers when KVM is in use, which create the
      KVM XIVE device, initialize the interrupt sources at a KVM level and
      connect the interrupt presenters to the vCPU.
      
      They also handle the initialization of the TIMA and the source ESB
      memory regions of the controller. These have a different type under
      KVM. They are 'ram device' memory mappings, similarly to VFIO, exposed
      to the guest and the associated VMAs on the host are populated
      dynamically with the appropriate pages using a fault handler.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20190513084245.25755-3-clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      38afd772
  4. 12 3月, 2019 2 次提交
  5. 17 2月, 2019 1 次提交
  6. 04 2月, 2019 2 次提交
  7. 09 1月, 2019 3 次提交
  8. 21 12月, 2018 9 次提交
    • C
      spapr: allocate the interrupt thread context under the CPU core · 1a937ad7
      Cédric Le Goater 提交于
      Each interrupt mode has its own specific interrupt presenter object,
      that we store under the CPU object, one for XICS and one for XIVE.
      
      Extend the sPAPR IRQ backend with a new handler to support them both.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      1a937ad7
    • C
      ppc/xive: introduce a simplified XIVE presenter · af53dbf6
      Cédric Le Goater 提交于
      The last sub-engine of the XIVE architecture is the Interrupt
      Virtualization Presentation Engine (IVPE). On HW, the IVRE and the
      IVPE share elements, the Power Bus interface (CQ), the routing table
      descriptors, and they can be combined in the same HW logic. We do the
      same in QEMU and combine both engines in the XiveRouter for
      simplicity.
      
      When the IVRE has completed its job of matching an event source with a
      Notification Virtual Target (NVT) to notify, it forwards the event
      notification to the IVPE sub-engine. The IVPE scans the thread
      interrupt contexts of the Notification Virtual Targets (NVT)
      dispatched on the HW processor threads and if a match is found, it
      signals the thread. If not, the IVPE escalates the notification to
      some other targets and records the notification in a backlog queue.
      
      The IVPE maintains the thread interrupt context state for each of its
      NVTs not dispatched on HW processor threads in the Notification
      Virtual Target table (NVTT).
      
      The model currently only supports single NVT notifications.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      [dwg: Folded in fix for field accessors]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      af53dbf6
    • C
      ppc/xive: introduce the XIVE interrupt thread context · 207d9fe9
      Cédric Le Goater 提交于
      Each POWER9 processor chip has a XIVE presenter that can generate four
      different exceptions to its threads:
      
        - hypervisor exception,
        - O/S exception
        - Event-Based Branch (EBB)
        - msgsnd (doorbell).
      
      Each exception has a state independent from the others called a Thread
      Interrupt Management context. This context is a set of registers which
      lets the thread handle priority management and interrupt acknowledgment
      among other things. The most important ones being :
      
        - Interrupt Priority Register  (PIPR)
        - Interrupt Pending Buffer     (IPB)
        - Current Processor Priority   (CPPR)
        - Notification Source Register (NSR)
      
      These registers are accessible through a specific MMIO region, called
      the Thread Interrupt Management Area (TIMA), four aligned pages, each
      exposing a different view of the registers. First page (page address
      ending in 0b00) gives access to the entire context and is reserved for
      the ring 0 view for the physical thread context. The second (page
      address ending in 0b01) is for the hypervisor, ring 1 view. The third
      (page address ending in 0b10) is for the operating system, ring 2
      view. The fourth (page address ending in 0b11) is for user level, ring
      3 view.
      
      The thread interrupt context is modeled with a XiveTCTX object
      containing the values of the different exception registers. The TIMA
      region is mapped at the same address for each CPU.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      207d9fe9
    • C
      ppc/xive: add support for the END Event State Buffers · 002686be
      Cédric Le Goater 提交于
      The Event Notification Descriptor (END) XIVE structure also contains
      two Event State Buffers providing further coalescing of interrupts,
      one for the notification event (ESn) and one for the escalation events
      (ESe). A MMIO page is assigned for each to control the EOI through
      loads only. Stores are not allowed.
      
      The END ESBs are modeled through an object resembling the 'XiveSource'
      It is stateless as the END state bits are backed into the XiveEND
      structure under the XiveRouter and the MMIO accesses follow the same
      rules as for the XiveSource ESBs.
      
      END ESBs are not supported by the Linux drivers neither on OPAL nor on
      sPAPR. Nevetherless, it provides a mean to study the question in the
      future and validates a bit more the XIVE model.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      [dwg: Fold in a later fix for field access]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      002686be
    • C
      ppc/xive: introduce the XIVE Event Notification Descriptors · e4ddaac6
      Cédric Le Goater 提交于
      To complete the event routing, the IVRE sub-engine uses a second table
      containing Event Notification Descriptor (END) structures.
      
      An END specifies on which Event Queue (EQ) the event notification
      data, defined in the associated EAS, should be posted when an
      exception occurs. It also defines which Notification Virtual Target
      (NVT) should be notified.
      
      The Event Queue is a memory page provided by the O/S defining a
      circular buffer, one per server and priority couple, containing Event
      Queue entries. These are 4 bytes long, the first bit being a
      'generation' bit and the 31 following bits the END Data field. They
      are pulled by the O/S when the exception occurs.
      
      The END Data field is a way to set an invariant logical event source
      number for an IRQ. On sPAPR machines, it is set with the
      H_INT_SET_SOURCE_CONFIG hcall when the EISN flag is used.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      [dwg: Fold in a later fix from Cédric fixing field accessors]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      e4ddaac6
    • C
      ppc/xive: introduce the XiveRouter model · 7ff7ea92
      Cédric Le Goater 提交于
      The XiveRouter models the second sub-engine of the XIVE architecture :
      the Interrupt Virtualization Routing Engine (IVRE).
      
      The IVRE handles event notifications of the IVSE and performs the
      interrupt routing process. For this purpose, it uses a set of tables
      stored in system memory, the first of which being the Event Assignment
      Structure (EAS) table.
      
      The EAT associates an interrupt source number with an Event Notification
      Descriptor (END) which will be used in a second phase of the routing
      process to identify a Notification Virtual Target.
      
      The XiveRouter is an abstract class which needs to be inherited from
      to define a storage for the EAT, and other upcoming tables.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      [dwg: Folded in parts of a later fix by Cédric fixing field access]
      [dwg: Fix style nits]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      7ff7ea92
    • C
      ppc/xive: introduce the XiveNotifier interface · 5e79b155
      Cédric Le Goater 提交于
      The XiveNotifier offers a simple interface, between the XiveSource
      object and the main interrupt controller of the machine. It will
      forward event notifications to the XIVE Interrupt Virtualization
      Routing Engine (IVRE).
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      [dwg: Adjust type name string for XiveNotifier]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      5e79b155
    • C
      ppc/xive: add support for the LSI interrupt sources · 5fd9ef18
      Cédric Le Goater 提交于
      The 'sent' status of the LSI interrupt source is modeled with the 'P'
      bit of the ESB and the assertion status of the source is maintained
      with an extra bit under the main XiveSource object. The type of the
      source is stored in the same array for practical reasons.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      [dwg: Fix style nit]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      5fd9ef18
    • C
      ppc/xive: introduce a XIVE interrupt source model · 02e3ff54
      Cédric Le Goater 提交于
      The first sub-engine of the overall XIVE architecture is the Interrupt
      Virtualization Source Engine (IVSE). An IVSE can be integrated into
      another logic, like in a PCI PHB or in the main interrupt controller
      to manage IPIs.
      
      Each IVSE instance is associated with an Event State Buffer (ESB) that
      contains a two bit state entry for each possible event source. When an
      event is signaled to the IVSE, by MMIO or some other means, the
      associated interrupt state bits are fetched from the ESB and
      modified. Depending on the resulting ESB state, the event is forwarded
      to the IVRE sub-engine of the controller doing the routing.
      
      Each supported ESB entry is associated with either a single or a
      even/odd pair of pages which provides commands to manage the source:
      to EOI, to turn off the source for instance.
      
      On a sPAPR machine, the O/S will obtain the page address of the ESB
      entry associated with a source and its characteristic using the
      H_INT_GET_SOURCE_INFO hcall. On PowerNV, a similar OPAL call is used.
      
      The xive_source_notify() routine is in charge forwarding the source
      event notification to the routing engine. It will be filled later on.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      02e3ff54