1. 23 4月, 2022 2 次提交
    • M
      KVM: arm64: Handle SME host state when running guests · 861262ab
      Mark Brown 提交于
      While we don't currently support SME in guests we do currently support it
      for the host system so we need to take care of SME's impact, including
      the floating point register state, when running guests. Simiarly to SVE
      we need to manage the traps in CPACR_RL1, what is new is the handling of
      streaming mode and ZA.
      
      Normally we defer any handling of the floating point register state until
      the guest first uses it however if the system is in streaming mode FPSIMD
      and SVE operations may generate SME traps which we would need to distinguish
      from actual attempts by the guest to use SME. Rather than do this for the
      time being if we are in streaming mode when entering the guest we force
      the floating point state to be saved immediately and exit streaming mode,
      meaning that the guest won't generate SME traps for supported operations.
      
      We could handle ZA in the access trap similarly to the FPSIMD/SVE state
      without the disruption caused by streaming mode but for simplicity
      handle it the same way as streaming mode for now.
      
      This will be revisited when we support SME for guests (hopefully before SME
      hardware becomes available), for now it will only incur additional cost on
      systems with SME and even there only if streaming mode or ZA are enabled.
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220419112247.711548-27-broonie@kernel.orgSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      861262ab
    • M
      arm64/sme: Implement ZA context switching · 0033cd93
      Mark Brown 提交于
      Allocate space for storing ZA on first access to SME and use that to save
      and restore ZA state when context switching. We do this by using the vector
      form of the LDR and STR ZA instructions, these do not require streaming
      mode and have implementation recommendations that they avoid contention
      issues in shared SMCU implementations.
      
      Since ZA is architecturally guaranteed to be zeroed when enabled we do not
      need to explicitly zero ZA, either we will be restoring from a saved copy
      or trapping on first use of SME so we know that ZA must be disabled.
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Link: https://lore.kernel.org/r/20220419112247.711548-16-broonie@kernel.orgSigned-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      0033cd93
  2. 06 4月, 2022 1 次提交
    • R
      KVM: arm64: mixed-width check should be skipped for uninitialized vCPUs · 26bf74bd
      Reiji Watanabe 提交于
      KVM allows userspace to configure either all EL1 32bit or 64bit vCPUs
      for a guest.  At vCPU reset, vcpu_allowed_register_width() checks
      if the vcpu's register width is consistent with all other vCPUs'.
      Since the checking is done even against vCPUs that are not initialized
      (KVM_ARM_VCPU_INIT has not been done) yet, the uninitialized vCPUs
      are erroneously treated as 64bit vCPU, which causes the function to
      incorrectly detect a mixed-width VM.
      
      Introduce KVM_ARCH_FLAG_EL1_32BIT and KVM_ARCH_FLAG_REG_WIDTH_CONFIGURED
      bits for kvm->arch.flags.  A value of the EL1_32BIT bit indicates that
      the guest needs to be configured with all 32bit or 64bit vCPUs, and
      a value of the REG_WIDTH_CONFIGURED bit indicates if a value of the
      EL1_32BIT bit is valid (already set up). Values in those bits are set at
      the first KVM_ARM_VCPU_INIT for the guest based on KVM_ARM_VCPU_EL1_32BIT
      configuration for the vCPU.
      
      Check vcpu's register width against those new bits at the vcpu's
      KVM_ARM_VCPU_INIT (instead of against other vCPUs' register width).
      
      Fixes: 66e94d5c ("KVM: arm64: Prevent mixed-width VM creation")
      Signed-off-by: NReiji Watanabe <reijiw@google.com>
      Reviewed-by: NOliver Upton <oupton@google.com>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220329031924.619453-2-reijiw@google.com
      26bf74bd
  3. 18 3月, 2022 1 次提交
  4. 16 2月, 2022 1 次提交
    • J
      KVM: arm64: Allow indirect vectors to be used without SPECTRE_V3A · 5bdf3437
      James Morse 提交于
      CPUs vulnerable to Spectre-BHB either need to make an SMC-CC firmware
      call from the vectors, or run a sequence of branches. This gets added
      to the hyp vectors. If there is no support for arch-workaround-1 in
      firmware, the indirect vector will be used.
      
      kvm_init_vector_slots() only initialises the two indirect slots if
      the platform is vulnerable to Spectre-v3a. pKVM's hyp_map_vectors()
      only initialises __hyp_bp_vect_base if the platform is vulnerable to
      Spectre-v3a.
      
      As there are about to more users of the indirect vectors, ensure
      their entries in hyp_spectre_vector_selector[] are always initialised,
      and __hyp_bp_vect_base defaults to the regular VA mapping.
      
      The Spectre-v3a check is moved to a helper
      kvm_system_needs_idmapped_vectors(), and merged with the code
      that creates the hyp mappings.
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NJames Morse <james.morse@arm.com>
      5bdf3437
  5. 09 2月, 2022 3 次提交
  6. 08 2月, 2022 7 次提交
  7. 16 12月, 2021 1 次提交
  8. 08 12月, 2021 2 次提交
  9. 01 12月, 2021 2 次提交
  10. 23 11月, 2021 2 次提交
  11. 22 11月, 2021 2 次提交
    • M
      KVM: arm64: Get rid of host SVE tracking/saving · 8383741a
      Marc Zyngier 提交于
      The SVE host tracking in KVM is pretty involved. It relies on a
      set of flags tracking the ownership of the SVE register, as well
      as that of the EL0 access.
      
      It is also pretty scary: __hyp_sve_save_host() computes
      a thread_struct pointer and obtains a sve_state which gets directly
      accessed without further ado, even on nVHE. How can this even work?
      
      The answer to that is that it doesn't, and that this is mostly dead
      code. Closer examination shows that on executing a syscall, userspace
      loses its SVE state entirely. This is part of the ABI. Another
      thing to notice is that although the kernel provides helpers such as
      kernel_neon_begin()/end(), they only deal with the FP/NEON state,
      and not SVE.
      
      Given that you can only execute a guest as the result of a syscall,
      and that the kernel cannot use SVE by itself, it becomes pretty
      obvious that there is never any host SVE state to save, and that
      this code is only there to increase confusion.
      
      Get rid of the TIF_SVE tracking and host save infrastructure altogether.
      Reviewed-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      8383741a
    • M
      KVM: arm64: Reorder vcpu flag definitions · 892fd259
      Marc Zyngier 提交于
      The vcpu arch flags are in an interesting, semi random order.
      As I have made the mistake of reusing a flag once, let's rework
      this in an order that I find a bit less confusing.
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      892fd259
  12. 17 11月, 2021 3 次提交
  13. 08 11月, 2021 1 次提交
  14. 11 10月, 2021 2 次提交
  15. 01 10月, 2021 1 次提交
  16. 20 8月, 2021 4 次提交
  17. 19 8月, 2021 1 次提交
  18. 18 8月, 2021 1 次提交
  19. 02 8月, 2021 1 次提交
    • M
      KVM: arm64: Remove PMSWINC_EL0 shadow register · 7a3ba309
      Marc Zyngier 提交于
      We keep an entry for the PMSWINC_EL0 register in the vcpu structure,
      while *never* writing anything there outside of reset.
      
      Given that the register is defined as write-only, that we always
      trap when this register is accessed, there is little point in saving
      anything anyway.
      
      Get rid of the entry, and save a mighty 8 bytes per vcpu structure.
      
      We still need to keep it exposed to userspace in order to preserve
      backward compatibility with previously saved VMs. Since userspace
      cannot expect any effect of writing to PMSWINC_EL0, treat the
      register as RAZ/WI for the purpose of userspace access.
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20210719123902.1493805-5-maz@kernel.org
      7a3ba309
  20. 24 6月, 2021 1 次提交
  21. 22 6月, 2021 1 次提交