1. 26 2月, 2018 2 次提交
    • J
      KVM: arm64: Enable the EL1 physical timer for AArch32 guests · eac137b4
      Jérémy Fanguède 提交于
      Some 32bits guest OS can use the CNTP timer, however KVM does not
      handle the accesses, injecting a fault instead.
      
      Use the proper handlers to emulate the EL1 Physical Timer (CNTP)
      register accesses of AArch32 guests.
      Signed-off-by: NJérémy Fanguède <j.fanguede@virtualopensystems.com>
      Signed-off-by: NAlvise Rigo <a.rigo@virtualopensystems.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      eac137b4
    • M
      arm64/kvm: Prohibit guest LOR accesses · cc33c4e2
      Mark Rutland 提交于
      We don't currently limit guest accesses to the LOR registers, which we
      neither virtualize nor context-switch. As such, guests are provided with
      unusable information/controls, and are not isolated from each other (or
      the host).
      
      To prevent these issues, we can trap register accesses and present the
      illusion LORegions are unssupported by the CPU. To do this, we mask
      ID_AA64MMFR1.LO, and set HCR_EL2.TLOR to trap accesses to the following
      registers:
      
      * LORC_EL1
      * LOREA_EL1
      * LORID_EL1
      * LORN_EL1
      * LORSA_EL1
      
      ... when trapped, we inject an UNDEFINED exception to EL1, simulating
      their non-existence.
      
      As noted in D7.2.67, when no LORegions are implemented, LoadLOAcquire
      and StoreLORelease must behave as LoadAcquire and StoreRelease
      respectively. We can ensure this by clearing LORC_EL1.EN when a CPU's
      EL2 is first initialized, as the host kernel will not modify this.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Vladimir Murzin <vladimir.murzin@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoffer Dall <christoffer.dall@linaro.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: kvmarm@lists.cs.columbia.edu
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      cc33c4e2
  2. 16 1月, 2018 2 次提交
  3. 08 1月, 2018 1 次提交
  4. 02 1月, 2018 1 次提交
  5. 06 11月, 2017 1 次提交
  6. 03 11月, 2017 2 次提交
    • D
      arm64/sve: KVM: Hide SVE from CPU features exposed to guests · 07d79fe7
      Dave Martin 提交于
      KVM guests cannot currently use SVE, because SVE is always
      configured to trap to EL2.
      
      However, a guest that sees SVE reported as present in
      ID_AA64PFR0_EL1 may legitimately expect that SVE works and try to
      use it.  Instead of working, the guest will receive an injected
      undef exception, which may cause the guest to oops or go into a
      spin.
      
      To avoid misleading the guest into believing that SVE will work,
      this patch masks out the SVE field from ID_AA64PFR0_EL1 when a
      guest attempts to read this register.  No support is explicitly
      added for ID_AA64ZFR0_EL1 either, so that is still emulated as
      reading as zero, which is consistent with SVE not being
      implemented.
      
      This is a temporary measure, and will be removed in a later series
      when full KVM support for SVE is implemented.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Acked-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>
      07d79fe7
    • 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
  7. 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
  8. 15 6月, 2017 2 次提交
  9. 02 5月, 2017 1 次提交
  10. 09 4月, 2017 7 次提交
  11. 04 4月, 2017 1 次提交
  12. 23 3月, 2017 7 次提交
  13. 08 2月, 2017 2 次提交
  14. 30 1月, 2017 1 次提交
  15. 18 11月, 2016 1 次提交
  16. 09 9月, 2016 1 次提交
    • M
      arm64/kvm: use {read,write}_sysreg() · 1f3d8699
      Mark Rutland 提交于
      A while back we added {read,write}_sysreg accessors to handle accesses
      to system registers, without the usual boilerplate asm volatile,
      temporary variable, etc.
      
      This patch makes use of these in the arm64 KVM code to make the code
      shorter and clearer.
      
      At the same time, a comment style violation next to a system register
      access is fixed up in reset_pmcr, and comments describing whether
      operations are reads or writes are removed as this is now painfully
      obvious.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Acked-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      1f3d8699
  17. 17 8月, 2016 2 次提交
  18. 14 7月, 2016 1 次提交
  19. 31 5月, 2016 1 次提交
  20. 01 3月, 2016 3 次提交
    • M
      arm64: KVM: Switch the sys_reg search to be a binary search · 623eefa8
      Marc Zyngier 提交于
      Our 64bit sys_reg table is about 90 entries long (so far, and the
      PMU support is likely to increase this). This means that on average,
      it takes 45 comparaisons to find the right entry (and actually the
      full 90 if we have to search the invariant table).
      
      Not the most efficient thing. Specially when you think that this
      table is already sorted. Switching to a binary search effectively
      reduces the search to about 7 comparaisons. Slightly better!
      
      As an added bonus, the comparison is done by comparing all the
      fields at once, instead of one at a time.
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      623eefa8
    • S
      arm64: KVM: Add access handler for PMUSERENR register · d692b8ad
      Shannon Zhao 提交于
      This register resets as unknown in 64bit mode while it resets as zero
      in 32bit mode. Here we choose to reset it as zero for consistency.
      
      PMUSERENR_EL0 holds some bits which decide whether PMU registers can be
      accessed from EL0. Add some check helpers to handle the access from EL0.
      
      When these bits are zero, only reading PMUSERENR will trap to EL2 and
      writing PMUSERENR or reading/writing other PMU registers will trap to
      EL1 other than EL2 when HCR.TGE==0. To current KVM configuration
      (HCR.TGE==0) there is no way to get these traps. Here we write 0xf to
      physical PMUSERENR register on VM entry, so that it will trap PMU access
      from EL0 to EL2. Within the register access handler we check the real
      value of guest PMUSERENR register to decide whether this access is
      allowed. If not allowed, return false to inject UND to guest.
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d692b8ad
    • S
      arm64: KVM: Add helper to handle PMCR register bits · 76993739
      Shannon Zhao 提交于
      According to ARMv8 spec, when writing 1 to PMCR.E, all counters are
      enabled by PMCNTENSET, while writing 0 to PMCR.E, all counters are
      disabled. When writing 1 to PMCR.P, reset all event counters, not
      including PMCCNTR, to zero. When writing 1 to PMCR.C, reset PMCCNTR to
      zero.
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      76993739