1. 03 11月, 2017 1 次提交
    • D
      arm64: KVM: Hide unsupported AArch64 CPU features from guests · 93390c0a
      Dave Martin 提交于
      Currently, a guest kernel sees the true CPU feature registers
      (ID_*_EL1) when it reads them using MRS instructions.  This means
      that the guest may observe features that are present in the
      hardware but the host doesn't understand or doesn't provide support
      for.  A guest may legimitately try to use such a feature as per the
      architecture, but use of the feature may trap instead of working
      normally, triggering undef injection into the guest.
      
      This is not a problem for the host, but the guest may go wrong when
      running on newer hardware than the host knows about.
      
      This patch hides from guest VMs any AArch64-specific CPU features
      that the host doesn't support, by exposing to the guest the
      sanitised versions of the registers computed by the cpufeatures
      framework, instead of the true hardware registers.  To achieve
      this, HCR_EL2.TID3 is now set for AArch64 guests, and emulation
      code is added to KVM to report the sanitised versions of the
      affected registers in response to MRS and register reads from
      userspace.
      
      The affected registers are removed from invariant_sys_regs[] (since
      the invariant_sys_regs handling is no longer quite correct for
      them) and added to sys_reg_desgs[], with appropriate access(),
      get_user() and set_user() methods.  No runtime vcpu storage is
      allocated for the registers: instead, they are read on demand from
      the cpufeatures framework.  This may need modification in the
      future if there is a need for userspace to customise the features
      visible to the guest.
      
      Attempts by userspace to write the registers are handled similarly
      to the current invariant_sys_regs handling: writes are permitted,
      but only if they don't attempt to change the value.  This is
      sufficient to support VM snapshot/restore from userspace.
      
      Because of the additional registers, restoring a VM on an older
      kernel may not work unless userspace knows how to handle the extra
      VM registers exposed to the KVM user ABI by this patch.
      
      Under the principle of least damage, this patch makes no attempt to
      handle any of the other registers currently in
      invariant_sys_regs[], or to emulate registers for AArch32: however,
      these could be handled in a similar way in future, as necessary.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      93390c0a
  2. 18 10月, 2017 1 次提交
  3. 05 9月, 2017 1 次提交
  4. 21 8月, 2017 1 次提交
  5. 08 8月, 2017 2 次提交
  6. 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
  7. 15 6月, 2017 5 次提交
  8. 14 6月, 2017 1 次提交
  9. 08 6月, 2017 2 次提交
    • C
      KVM: arm/arm64: Allow setting the timer IRQ numbers from userspace · 99a1db7a
      Christoffer Dall 提交于
      First we define an ABI using the vcpu devices that lets userspace set
      the interrupt numbers for the various timers on both the 32-bit and
      64-bit KVM/ARM implementations.
      
      Second, we add the definitions for the groups and attributes introduced
      by the above ABI.  (We add the PMU define on the 32-bit side as well for
      symmetry and it may get used some day.)
      
      Third, we set up the arch-specific vcpu device operation handlers to
      call into the timer code for anything related to the
      KVM_ARM_VCPU_TIMER_CTRL group.
      
      Fourth, we implement support for getting and setting the timer interrupt
      numbers using the above defined ABI in the arch timer code.
      
      Fifth, we introduce error checking upon enabling the arch timer (which
      is called when first running a VCPU) to check that all VCPUs are
      configured to use the same PPI for the timer (as mandated by the
      architecture) and that the virtual and physical timers are not
      configured to use the same IRQ number.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      99a1db7a
    • C
      KVM: arm/arm64: Move timer IRQ default init to arch_timer.c · 85e69ad7
      Christoffer Dall 提交于
      We currently initialize the arch timer IRQ numbers from the reset code,
      presumably because we once intended to model multiple CPU or SoC types
      from within the kernel and have hard-coded reset values in the reset
      code.
      
      As we are moving towards userspace being in charge of more fine-grained
      CPU emulation and stitching together the pieces needed to emulate a
      particular type of CPU, we should no longer have a tight coupling
      between resetting a VCPU and setting IRQ numbers.
      
      Therefore, move the logic to define and use the default IRQ numbers to
      the timer code and set the IRQ number immediately when creating the
      VCPU.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      85e69ad7
  10. 07 6月, 2017 2 次提交
  11. 04 6月, 2017 1 次提交
    • A
      KVM: arm/arm64: properly use vcpu requests · 6a6d73be
      Andrew Jones 提交于
      arm/arm64 already has one VCPU request used when setting pause,
      but it doesn't properly check requests in VCPU RUN. Check it
      and also make sure we set vcpu->mode at the appropriate time
      (before the check) and with the appropriate barriers. See
      Documentation/virtual/kvm/vcpu-requests.rst. Also make sure we
      don't leave any vcpu requests we don't intend to handle later
      set in the request bitmap. If we don't clear them, then
      kvm_request_pending() may return true when it shouldn't.
      
      Using VCPU requests properly fixes a small race where pause
      could get set just as a VCPU was entering guest mode.
      Signed-off-by: NAndrew Jones <drjones@redhat.com>
      Reviewed-by: NChristoffer Dall <cdall@linaro.org>
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      6a6d73be
  12. 24 5月, 2017 1 次提交
  13. 16 5月, 2017 1 次提交
  14. 15 5月, 2017 1 次提交
  15. 04 5月, 2017 1 次提交
    • C
      KVM: arm/arm64: Move shared files to virt/kvm/arm · 35d2d5d4
      Christoffer Dall 提交于
      For some time now we have been having a lot of shared functionality
      between the arm and arm64 KVM support in arch/arm, which not only
      required a horrible inter-arch reference from the Makefile in
      arch/arm64/kvm, but also created confusion for newcomers to the code
      base, as was recently seen on the mailing list.
      
      Further, it causes confusion for things like cscope, which needs special
      attention to index specific shared files for arm64 from the arm tree.
      
      Move the shared files into virt/kvm/arm and move the trace points along
      with it.  When moving the tracepoints we have to modify the way the vgic
      creates definitions of the trace points, so we take the chance to
      include the VGIC tracepoints in its very own special vgic trace.h file.
      Signed-off-by: NChristoffer Dall <cdall@linaro.org>
      35d2d5d4
  16. 02 5月, 2017 1 次提交
  17. 09 4月, 2017 15 次提交
  18. 04 4月, 2017 1 次提交
  19. 23 3月, 2017 1 次提交