1. 09 2月, 2022 1 次提交
  2. 02 2月, 2022 1 次提交
    • M
      kvm/arm64: rework guest entry logic · 8cfe148a
      Mark Rutland 提交于
      In kvm_arch_vcpu_ioctl_run() we enter an RCU extended quiescent state
      (EQS) by calling guest_enter_irqoff(), and unmasked IRQs prior to
      exiting the EQS by calling guest_exit(). As the IRQ entry code will not
      wake RCU in this case, we may run the core IRQ code and IRQ handler
      without RCU watching, leading to various potential problems.
      
      Additionally, we do not inform lockdep or tracing that interrupts will
      be enabled during guest execution, which caan lead to misleading traces
      and warnings that interrupts have been enabled for overly-long periods.
      
      This patch fixes these issues by using the new timing and context
      entry/exit helpers to ensure that interrupts are handled during guest
      vtime but with RCU watching, with a sequence:
      
      	guest_timing_enter_irqoff();
      
      	guest_state_enter_irqoff();
      	< run the vcpu >
      	guest_state_exit_irqoff();
      
      	< take any pending IRQs >
      
      	guest_timing_exit_irqoff();
      
      Since instrumentation may make use of RCU, we must also ensure that no
      instrumented code is run during the EQS. I've split out the critical
      section into a new kvm_arm_enter_exit_vcpu() helper which is marked
      noinstr.
      
      Fixes: 1b3d546d ("arm/arm64: KVM: Properly account for guest CPU time")
      Reported-by: NNicolas Saenz Julienne <nsaenzju@redhat.com>
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NMarc Zyngier <maz@kernel.org>
      Reviewed-by: NNicolas Saenz Julienne <nsaenzju@redhat.com>
      Cc: Alexandru Elisei <alexandru.elisei@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Frederic Weisbecker <frederic@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Message-Id: <20220201132926.3301912-3-mark.rutland@arm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8cfe148a
  3. 16 12月, 2021 2 次提交
  4. 08 12月, 2021 5 次提交
    • S
      KVM: Add helpers to wake/query blocking vCPU · d92a5d1c
      Sean Christopherson 提交于
      Add helpers to wake and query a blocking vCPU.  In addition to providing
      nice names, the helpers reduce the probability of KVM neglecting to use
      kvm_arch_vcpu_get_wait().
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211009021236.4122790-20-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d92a5d1c
    • S
      KVM: Rename kvm_vcpu_block() => kvm_vcpu_halt() · 91b99ea7
      Sean Christopherson 提交于
      Rename kvm_vcpu_block() to kvm_vcpu_halt() in preparation for splitting
      the actual "block" sequences into a separate helper (to be named
      kvm_vcpu_block()).  x86 will use the standalone block-only path to handle
      non-halt cases where the vCPU is not runnable.
      
      Rename block_ns to halt_ns to match the new function name.
      
      No functional change intended.
      Reviewed-by: NDavid Matlack <dmatlack@google.com>
      Reviewed-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211009021236.4122790-14-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      91b99ea7
    • S
      KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook · 6109c5a6
      Sean Christopherson 提交于
      Move the put and reload of the vGIC out of the block/unblock callbacks
      and into a dedicated WFI helper.  Functionally, this is nearly a nop as
      the block hook is called at the very beginning of kvm_vcpu_block(), and
      the only code in kvm_vcpu_block() after the unblock hook is to update the
      halt-polling controls, i.e. can only affect the next WFI.
      
      Back when the arch (un)blocking hooks were added by commits 3217f7c2
      ("KVM: Add kvm_arch_vcpu_{un}blocking callbacks) and d35268da
      ("arm/arm64: KVM: arch_timer: Only schedule soft timer on vcpu_block"),
      the hooks were invoked only when KVM was about to "block", i.e. schedule
      out the vCPU.  The use case at the time was to schedule a timer in the
      host based on the earliest timer in the guest in order to wake the
      blocking vCPU when the emulated guest timer fired.  Commit accb99bc
      ("KVM: arm/arm64: Simplify bg_timer programming") reworked the timer
      logic to be even more precise, by waiting until the vCPU was actually
      scheduled out, and so move the timer logic from the (un)blocking hooks to
      vcpu_load/put.
      
      In the meantime, the hooks gained usage for enabling vGIC v4 doorbells in
      commit df9ba959 ("KVM: arm/arm64: GICv4: Use the doorbell interrupt
      as an unblocking source"), and added related logic for the VMCR in commit
      5eeaf10e ("KVM: arm/arm64: Sync ICH_VMCR_EL2 back when about to block").
      
      Finally, commit 07ab0f8d ("KVM: Call kvm_arch_vcpu_blocking early
      into the blocking sequence") hoisted the (un)blocking hooks so that they
      wrapped KVM's halt-polling logic in addition to the core "block" logic.
      
      In other words, the original need for arch hooks to take action _only_
      in the block path is long since gone.
      
      Cc: Oliver Upton <oupton@google.com>
      Cc: Marc Zyngier <maz@kernel.org>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211009021236.4122790-11-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6109c5a6
    • M
      KVM: Use 'unsigned long' as kvm_for_each_vcpu()'s index · 46808a4c
      Marc Zyngier 提交于
      Everywhere we use kvm_for_each_vpcu(), we use an int as the vcpu
      index. Unfortunately, we're about to move rework the iterator,
      which requires this to be upgrade to an unsigned long.
      
      Let's bite the bullet and repaint all of it in one go.
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Message-Id: <20211116160403.4074052-7-maz@kernel.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      46808a4c
    • M
      KVM: Move wiping of the kvm->vcpus array to common code · 27592ae8
      Marc Zyngier 提交于
      All architectures have similar loops iterating over the vcpus,
      freeing one vcpu at a time, and eventually wiping the reference
      off the vcpus array. They are also inconsistently taking
      the kvm->lock mutex when wiping the references from the array.
      
      Make this code common, which will simplify further changes.
      The locking is dropped altogether, as this should only be called
      when there is no further references on the kvm structure.
      Reviewed-by: NClaudio Imbrenda <imbrenda@linux.ibm.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Message-Id: <20211116160403.4074052-2-maz@kernel.org>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      27592ae8
  5. 01 12月, 2021 4 次提交
  6. 23 11月, 2021 1 次提交
  7. 18 11月, 2021 1 次提交
  8. 17 11月, 2021 2 次提交
  9. 08 11月, 2021 1 次提交
  10. 17 10月, 2021 1 次提交
  11. 11 10月, 2021 5 次提交
  12. 01 10月, 2021 1 次提交
  13. 20 8月, 2021 2 次提交
  14. 19 8月, 2021 3 次提交
  15. 18 8月, 2021 3 次提交
  16. 11 8月, 2021 1 次提交
  17. 04 8月, 2021 1 次提交
  18. 30 7月, 2021 1 次提交
  19. 22 6月, 2021 2 次提交
  20. 18 6月, 2021 1 次提交
  21. 11 6月, 2021 1 次提交