1. 08 1月, 2020 2 次提交
  2. 17 12月, 2019 8 次提交
  3. 18 11月, 2019 1 次提交
    • G
      ppc: Add intc_destroy() handlers to SpaprInterruptController/PnvChip · 0990ce6a
      Greg Kurz 提交于
      SpaprInterruptControllerClass and PnvChipClass have an intc_create() method
      that calls the appropriate routine, ie. icp_create() or xive_tctx_create(),
      to establish the link between the VCPU and the presenter component of the
      interrupt controller during realize.
      
      There aren't any symmetrical call to be called when the VCPU gets unrealized
      though. It is assumed that object_unparent() is the only thing to do.
      
      This is questionable because the parenting logic around the CPU and
      presenter objects is really an implementation detail of the interrupt
      controller. It shouldn't be open-coded in the machine code.
      
      Fix this by adding an intc_destroy() method that undoes what was done in
      intc_create(). Also NULLify the presenter pointers to avoid having
      stale pointers around. This will allow to reliably check if a vCPU has
      a valid presenter.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Message-Id: <157192724208.3146912.7254684777515287626.stgit@bahia.lan>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      0990ce6a
  4. 24 10月, 2019 1 次提交
    • C
      ppc: Reset the interrupt presenter from the CPU reset handler · d49e8a9b
      Cédric Le Goater 提交于
      On the sPAPR machine and PowerNV machine, the interrupt presenters are
      created by a machine handler at the core level and are reset
      independently. This is not consistent and it raises issues when it
      comes to handle hot-plugged CPUs. In that case, the presenters are not
      reset. This is less of an issue in XICS, although a zero MFFR could
      be a concern, but in XIVE, the OS CAM line is not set and this breaks
      the presenting algorithm. The current code has workarounds which need
      a global cleanup.
      
      Extend the sPAPR IRQ backend and the PowerNV Chip class with a new
      cpu_intc_reset() handler called by the CPU reset handler and remove
      the XiveTCTX reset handler which is now redundant.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Message-Id: <20191022163812.330-6-clg@kaod.org>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      d49e8a9b
  5. 04 10月, 2019 1 次提交
    • D
      xive: Improve irq claim/free path · e594c2ad
      David Gibson 提交于
      spapr_xive_irq_claim() returns a bool to indicate if it succeeded.
      But most of the callers and one callee use int return values and/or an
      Error * with more information instead.  In any case, ints are a more
      common idiom for success/failure states than bools (one never knows
      what sense they'll be in).
      
      So instead change to an int return value to indicate presence of error
      + an Error * to describe the details through that call chain.
      
      It also didn't actually check if the irq was already claimed, which is
      one of the primary purposes of the claim path, so do that.
      
      spapr_xive_irq_free() also returned a bool... which no callers checked
      and was always true, so just drop it.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      e594c2ad
  6. 21 8月, 2019 2 次提交
  7. 16 8月, 2019 1 次提交
    • M
      Include hw/qdev-properties.h less · a27bd6c7
      Markus Armbruster 提交于
      In my "build everything" tree, changing hw/qdev-properties.h triggers
      a recompile of some 2700 out of 6600 objects (not counting tests and
      objects that don't depend on qemu/osdep.h).
      
      Many places including hw/qdev-properties.h (directly or via hw/qdev.h)
      actually need only hw/qdev-core.h.  Include hw/qdev-core.h there
      instead.
      
      hw/qdev.h is actually pointless: all it does is include hw/qdev-core.h
      and hw/qdev-properties.h, which in turn includes hw/qdev-core.h.
      Replace the remaining uses of hw/qdev.h by hw/qdev-properties.h.
      
      While there, delete a few superfluous inclusions of hw/qdev-core.h.
      
      Touching hw/qdev-properties.h now recompiles some 1200 objects.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Daniel P. Berrangé" <berrange@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20190812052359.30071-22-armbru@redhat.com>
      a27bd6c7
  8. 13 8月, 2019 1 次提交
    • C
      spapr/xive: Fix migration of hot-plugged CPUs · 310cda5b
      Cédric Le Goater 提交于
      The migration sequence of a guest using the XIVE exploitation mode
      relies on the fact that the states of all devices are restored before
      the machine is. This is not true for hot-plug devices such as CPUs
      which state come after the machine. This breaks migration because the
      thread interrupt context registers are not correctly set.
      
      Fix migration of hotplugged CPUs by restoring their context in the
      'post_load' handler of the XiveTCTX model.
      
      Fixes: 277dd3d7 ("spapr/xive: add migration support for KVM")
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Message-Id: <20190813064853.29310-1-clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      310cda5b
  9. 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
  10. 12 6月, 2019 1 次提交
  11. 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
  12. 12 3月, 2019 2 次提交
  13. 17 2月, 2019 1 次提交
  14. 04 2月, 2019 2 次提交
  15. 09 1月, 2019 3 次提交
  16. 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