1. 29 11月, 2017 1 次提交
  2. 10 11月, 2017 4 次提交
  3. 07 11月, 2017 1 次提交
  4. 06 11月, 2017 6 次提交
    • C
      KVM: arm/arm64: Rework kvm_timer_should_fire · 1c88ab7e
      Christoffer Dall 提交于
      kvm_timer_should_fire() can be called in two different situations from
      the kvm_vcpu_block().
      
      The first case is before calling kvm_timer_schedule(), used for wait
      polling, and in this case the VCPU thread is running and the timer state
      is loaded onto the hardware so all we have to do is check if the virtual
      interrupt lines are asserted, becasue the timer interrupt handler
      functions will raise those lines as appropriate.
      
      The second case is inside the wait loop of kvm_vcpu_block(), where we
      have already called kvm_timer_schedule() and therefore the hardware will
      be disabled and the software view of the timer state is up to date
      (timer->loaded is false), and so we can simply check if the timer should
      fire by looking at the software state.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      1c88ab7e
    • C
      KVM: arm/arm64: Get rid of kvm_timer_flush_hwstate · 7e90c8e5
      Christoffer Dall 提交于
      Now when both the vtimer and the ptimer when using both the in-kernel
      vgic emulation and a userspace IRQ chip are driven by the timer signals
      and at the vcpu load/put boundaries, instead of recomputing the timer
      state at every entry/exit to/from the guest, we can get entirely rid of
      the flush hwstate function.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      7e90c8e5
    • C
      KVM: arm/arm64: Avoid timer save/restore in vcpu entry/exit · b103cc3f
      Christoffer Dall 提交于
      We don't need to save and restore the hardware timer state and examine
      if it generates interrupts on on every entry/exit to the guest.  The
      timer hardware is perfectly capable of telling us when it has expired
      by signaling interrupts.
      
      When taking a vtimer interrupt in the host, we don't want to mess with
      the timer configuration, we just want to forward the physical interrupt
      to the guest as a virtual interrupt.  We can use the split priority drop
      and deactivate feature of the GIC to do this, which leaves an EOI'ed
      interrupt active on the physical distributor, making sure we don't keep
      taking timer interrupts which would prevent the guest from running.  We
      can then forward the physical interrupt to the VM using the HW bit in
      the LR of the GIC, like we do already, which lets the guest directly
      deactivate both the physical and virtual timer simultaneously, allowing
      the timer hardware to exit the VM and generate a new physical interrupt
      when the timer output is again asserted later on.
      
      We do need to capture this state when migrating VCPUs between physical
      CPUs, however, which we use the vcpu put/load functions for, which are
      called through preempt notifiers whenever the thread is scheduled away
      from the CPU or called directly if we return from the ioctl to
      userspace.
      
      One caveat is that we have to save and restore the timer state in both
      kvm_timer_vcpu_[put/load] and kvm_timer_[schedule/unschedule], because
      we can have the following flows:
      
        1. kvm_vcpu_block
        2. kvm_timer_schedule
        3. schedule
        4. kvm_timer_vcpu_put (preempt notifier)
        5. schedule (vcpu thread gets scheduled back)
        6. kvm_timer_vcpu_load (preempt notifier)
        7. kvm_timer_unschedule
      
      And a version where we don't actually call schedule:
      
        1. kvm_vcpu_block
        2. kvm_timer_schedule
        7. kvm_timer_unschedule
      
      Since kvm_timer_[schedule/unschedule] may not be followed by put/load,
      but put/load also may be called independently, we call the timer
      save/restore functions from both paths.  Since they rely on the loaded
      flag to never save/restore when unnecessary, this doesn't cause any
      harm, and we ensure that all invokations of either set of functions work
      as intended.
      
      An added benefit beyond not having to read and write the timer sysregs
      on every entry and exit is that we no longer have to actively write the
      active state to the physical distributor, because we configured the
      irq for the vtimer to only get a priority drop when handling the
      interrupt in the GIC driver (we called irq_set_vcpu_affinity()), and
      the interrupt stays active after firing on the host.
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      b103cc3f
    • C
      KVM: arm/arm64: Use separate timer for phys timer emulation · f2a2129e
      Christoffer Dall 提交于
      We were using the same hrtimer for emulating the physical timer and for
      making sure a blocking VCPU thread would be eventually woken up.  That
      worked fine in the previous arch timer design, but as we are about to
      actually use the soft timer expire function for the physical timer
      emulation, change the logic to use a dedicated hrtimer.
      
      This has the added benefit of not having to cancel any work in the sync
      path, which in turn allows us to run the flush and sync with IRQs
      disabled.
      
      Note that the hrtimer used to program the host kernel's timer to
      generate an exit from the guest when the emulated physical timer fires
      never has to inject any work, and to share the soft_timer_cancel()
      function with the bg_timer, we change the function to only cancel any
      pending work if the pointer to the work struct is not null.
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      f2a2129e
    • C
      KVM: arm/arm64: Rename soft timer to bg_timer · 14d61fa9
      Christoffer Dall 提交于
      As we are about to introduce a separate hrtimer for the physical timer,
      call this timer bg_timer, because we refer to this timer as the
      background timer in the code and comments elsewhere.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      14d61fa9
    • C
      KVM: arm/arm64: Make timer_arm and timer_disarm helpers more generic · 8409a06f
      Christoffer Dall 提交于
      We are about to add an additional soft timer to the arch timer state for
      a VCPU and would like to be able to reuse the functions to program and
      cancel a timer, so we make them slightly more generic and rename to make
      it more clear that these functions work on soft timers and not the
      hardware resource that this code is managing.
      
      The armed flag on the timer state is only used to assert a condition,
      and we don't rely on this assertion in any meaningful way, so we can
      simply get rid of this flack and slightly reduce complexity.
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      8409a06f
  5. 25 7月, 2017 1 次提交
    • A
      KVM: arm/arm64: PMU: Fix overflow interrupt injection · d9f89b4e
      Andrew Jones 提交于
      kvm_pmu_overflow_set() is called from perf's interrupt handler,
      making the call of kvm_vgic_inject_irq() from it introduced with
      "KVM: arm/arm64: PMU: remove request-less vcpu kick" a really bad
      idea, as it's quite easy to try and retake a lock that the
      interrupted context is already holding. The fix is to use a vcpu
      kick, leaving the interrupt injection to kvm_pmu_sync_hwstate(),
      like it was doing before the refactoring. We don't just revert,
      though, because before the kick was request-less, leaving the vcpu
      exposed to the request-less vcpu kick race, and also because the
      kick was used unnecessarily from register access handlers.
      Reviewed-by: NChristoffer Dall <cdall@linaro.org>
      Signed-off-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d9f89b4e
  6. 15 6月, 2017 1 次提交
  7. 08 6月, 2017 7 次提交
  8. 18 5月, 2017 1 次提交
    • C
      KVM: arm/arm64: Fix bug when registering redist iodevs · 552c9f47
      Christoffer Dall 提交于
      If userspace creates the VCPUs after initializing the VGIC, then we end
      up in a situation where we trigger a bug in kvm_vcpu_get_idx(), because
      it is called prior to adding the VCPU into the vcpus array on the VM.
      
      There is no tight coupling between the VCPU index and the area of the
      redistributor region used for the VCPU, so we can simply ensure that all
      creations of redistributors are serialized per VM, and increment an
      offset when we successfully add a redistributor.
      
      The vgic_register_redist_iodev() function can be called from two paths:
      vgic_redister_all_redist_iodev() which is called via the kvm_vgic_addr()
      device attribute handler.  This patch already holds the kvm->lock mutex.
      
      The other path is via kvm_vgic_vcpu_init, which is called through a
      longer chain from kvm_vm_ioctl_create_vcpu(), which releases the
      kvm->lock mutex just before calling kvm_arch_vcpu_create(), so we can
      simply take this mutex again later for our purposes.
      
      Fixes: ab6f468c10 ("KVM: arm/arm64: Register iodevs when setting redist base and creating VCPUs")
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Tested-by: NJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      552c9f47
  9. 09 5月, 2017 2 次提交
  10. 08 5月, 2017 1 次提交
    • E
      KVM: arm64: vgic-its: Introduce migration ABI infrastructure · 71afe470
      Eric Auger 提交于
      We plan to support different migration ABIs, ie. characterizing
      the ITS table layout format in guest RAM. For example, a new ABI
      will be needed if vLPIs get supported for nested use case.
      
      So let's introduce an array of supported ABIs (at the moment a single
      ABI is supported though). The following characteristics are foreseen
      to vary with the ABI: size of table entries, save/restore operation,
      the way abi settings are applied.
      
      By default the MAX_ABI_REV is applied on its creation. In subsequent
      patches we will introduce a way for the userspace to change the ABI
      in use.
      
      The entry sizes now are set according to the ABI version and not
      hardcoded anymore.
      Signed-off-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NChristoffer Dall <cdall@linaro.org>
      71afe470
  11. 09 4月, 2017 5 次提交
  12. 04 4月, 2017 1 次提交
  13. 08 2月, 2017 6 次提交
  14. 30 1月, 2017 1 次提交
    • V
      KVM: arm/arm64: vgic: Implement VGICv3 CPU interface access · d017d7b0
      Vijaya Kumar K 提交于
      VGICv3 CPU interface registers are accessed using
      KVM_DEV_ARM_VGIC_CPU_SYSREGS ioctl. These registers are accessed
      as 64-bit. The cpu MPIDR value is passed along with register id.
      It is used to identify the cpu for registers access.
      
      The VM that supports SEIs expect it on destination machine to handle
      guest aborts and hence checked for ICC_CTLR_EL1.SEIS compatibility.
      Similarly, VM that supports Affinity Level 3 that is required for AArch64
      mode, is required to be supported on destination machine. Hence checked
      for ICC_CTLR_EL1.A3V compatibility.
      
      The arch/arm64/kvm/vgic-sys-reg-v3.c handles read and write of VGIC
      CPU registers for AArch64.
      
      For AArch32 mode, arch/arm/kvm/vgic-v3-coproc.c file is created but
      APIs are not implemented.
      
      Updated arch/arm/include/uapi/asm/kvm.h with new definitions
      required to compile for AArch32.
      
      The version of VGIC v3 specification is defined here
      Documentation/virtual/kvm/devices/arm-vgic-v3.txt
      Acked-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Signed-off-by: NPavel Fedin <p.fedin@samsung.com>
      Signed-off-by: NVijaya Kumar K <Vijaya.Kumar@cavium.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d017d7b0
  15. 25 1月, 2017 2 次提交