1. 27 12月, 2019 3 次提交
  2. 12 8月, 2018 3 次提交
  3. 09 7月, 2018 1 次提交
    • M
      arm64: KVM: Handle Set/Way CMOs as NOPs if FWB is present · 09605e94
      Marc Zyngier 提交于
      Set/Way handling is one of the ugliest corners of KVM. We shouldn't
      have to handle that, but better safe than sorry.
      
      Thankfully, FWB fixes this for us by not requiering any maintenance
      (the guest is forced to use cacheable memory, no matter what it says,
      and the whole system is garanteed to be cache coherent), which means
      we don't have to emulate S/W CMOs, and don't have to track VM ops either.
      
      We still have to trap S/W though, if only to prevent the guest from
      doing something bad.
      Reviewed-by: NChristoffer Dall <christoffer.dall@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      09605e94
  4. 25 5月, 2018 1 次提交
    • D
      KVM: arm64: Repurpose vcpu_arch.debug_flags for general-purpose flags · fa89d31c
      Dave Martin 提交于
      In struct vcpu_arch, the debug_flags field is used to store
      debug-related flags about the vcpu state.
      
      Since we are about to add some more flags related to FPSIMD and
      SVE, it makes sense to add them to the existing flags field rather
      than adding new fields.  Since there is only one debug_flags flag
      defined so far, there is plenty of free space for expansion.
      
      In preparation for adding more flags, this patch renames the
      debug_flags field to simply "flags", and updates comments
      appropriately.
      
      The flag definitions are also moved to <asm/kvm_host.h>, since
      their presence in <asm/kvm_asm.h> was for purely historical
      reasons:  these definitions are not used from asm any more, and not
      very likely to be as more Hyp asm is migrated to C.
      
      KVM_ARM64_DEBUG_DIRTY_SHIFT has not been used since commit
      1ea66d27 ("arm64: KVM: Move away from the assembly version of
      the world switch"), so this patch gets rid of that too.
      
      No functional change.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Acked-by: NChristoffer Dall <christoffer.dall@arm.com>
      [maz: fixed minor conflict]
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      fa89d31c
  5. 17 4月, 2018 1 次提交
  6. 19 3月, 2018 5 次提交
    • C
      KVM: arm64: Defer saving/restoring 32-bit sysregs to vcpu load/put · b9f8ca4d
      Christoffer Dall 提交于
      When running a 32-bit VM (EL1 in AArch32), the AArch32 system registers
      can be deferred to vcpu load/put on VHE systems because neither
      the host kernel nor host userspace uses these registers.
      
      Note that we can't save DBGVCR32_EL2 conditionally based on the state of
      the debug dirty flag on VHE after this change, because during
      vcpu_load() we haven't calculated a valid debug flag yet, and when we've
      restored the register during vcpu_load() we also have to save it during
      vcpu_put().  This means that we'll always restore/save the register for
      VHE on load/put, but luckily vcpu load/put are called rarely, so saving
      an extra register unconditionally shouldn't significantly hurt
      performance.
      
      We can also not defer saving FPEXC32_32 because this register only holds
      a guest-valid value for 32-bit guests during the exit path when the
      guest has used FPSIMD registers and restored the register in the early
      assembly handler from taking the EL2 fault, and therefore we have to
      check if fpsimd is enabled for the guest in the exit path and save the
      register then, for both VHE and non-VHE guests.
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      b9f8ca4d
    • C
      KVM: arm64: Defer saving/restoring 64-bit sysregs to vcpu load/put on VHE · fc7563b3
      Christoffer Dall 提交于
      Some system registers do not affect the host kernel's execution and can
      therefore be loaded when we are about to run a VCPU and we don't have to
      restore the host state to the hardware before the time when we are
      actually about to return to userspace or schedule out the VCPU thread.
      
      The EL1 system registers and the userspace state registers only
      affecting EL0 execution do not need to be saved and restored on every
      switch between the VM and the host, because they don't affect the host
      kernel's execution.
      
      We mark all registers which are now deffered as such in the
      vcpu_{read,write}_sys_reg accessors in sys-regs.c to ensure the most
      up-to-date copy is always accessed.
      
      Note MPIDR_EL1 (controlled via VMPIDR_EL2) is accessed from other vcpu
      threads, for example via the GIC emulation, and therefore must be
      declared as immediate, which is fine as the guest cannot modify this
      value.
      
      The 32-bit sysregs can also be deferred but we do this in a separate
      patch as it requires a bit more infrastructure.
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      fc7563b3
    • C
      KVM: arm64: Introduce framework for accessing deferred sysregs · d47533da
      Christoffer Dall 提交于
      We are about to defer saving and restoring some groups of system
      registers to vcpu_put and vcpu_load on supported systems.  This means
      that we need some infrastructure to access system registes which
      supports either accessing the memory backing of the register or directly
      accessing the system registers, depending on the state of the system
      when we access the register.
      
      We do this by defining read/write accessor functions, which can handle
      both "immediate" and "deferrable" system registers.  Immediate registers
      are always saved/restored in the world-switch path, but deferrable
      registers are only saved/restored in vcpu_put/vcpu_load when supported
      and sysregs_loaded_on_cpu will be set in that case.
      
      Note that we don't use the deferred mechanism yet in this patch, but only
      introduce infrastructure.  This is to improve convenience of review in
      the subsequent patches where it is clear which registers become
      deferred.
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d47533da
    • C
      KVM: arm64: Rewrite system register accessors to read/write functions · 8d404c4c
      Christoffer Dall 提交于
      Currently we access the system registers array via the vcpu_sys_reg()
      macro.  However, we are about to change the behavior to some times
      modify the register file directly, so let's change this to two
      primitives:
      
       * Accessor macros vcpu_write_sys_reg() and vcpu_read_sys_reg()
       * Direct array access macro __vcpu_sys_reg()
      
      The accessor macros should be used in places where the code needs to
      access the currently loaded VCPU's state as observed by the guest.  For
      example, when trapping on cache related registers, a write to a system
      register should go directly to the VCPU version of the register.
      
      The direct array access macro can be used in places where the VCPU is
      known to never be running (for example userspace access) or for
      registers which are never context switched (for example all the PMU
      system registers).
      
      This rewrites all users of vcpu_sys_regs to one of the macros described
      above.
      
      No functional change.
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NChristoffer Dall <cdall@cs.columbia.edu>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      8d404c4c
    • C
      KVM: arm64: Change 32-bit handling of VM system registers · 52f6c4f0
      Christoffer Dall 提交于
      We currently handle 32-bit accesses to trapped VM system registers using
      the 32-bit index into the coproc array on the vcpu structure, which is a
      union of the coproc array and the sysreg array.
      
      Since all the 32-bit coproc indices are created to correspond to the
      architectural mapping between 64-bit system registers and 32-bit
      coprocessor registers, and because the AArch64 system registers are the
      double in size of the AArch32 coprocessor registers, we can always find
      the system register entry that we must update by dividing the 32-bit
      coproc index by 2.
      
      This is going to make our lives much easier when we have to start
      accessing system registers that use deferred save/restore and might
      have to be read directly from the physical CPU.
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      52f6c4f0
  7. 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
  8. 16 1月, 2018 2 次提交
  9. 08 1月, 2018 1 次提交
  10. 02 1月, 2018 1 次提交
  11. 06 11月, 2017 1 次提交
  12. 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
  13. 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
  14. 15 6月, 2017 2 次提交
  15. 02 5月, 2017 1 次提交
  16. 09 4月, 2017 7 次提交
  17. 04 4月, 2017 1 次提交
  18. 23 3月, 2017 5 次提交