1. 04 5月, 2022 2 次提交
    • R
      KVM: arm64: Add standard hypervisor firmware register · 428fd678
      Raghavendra Rao Ananta 提交于
      Introduce the firmware register to hold the standard hypervisor
      service calls (owner value 5) as a bitmap. The bitmap represents
      the features that'll be enabled for the guest, as configured by
      the user-space. Currently, this includes support only for
      Paravirtualized time, represented by bit-0.
      Signed-off-by: NRaghavendra Rao Ananta <rananta@google.com>
      Reviewed-by: NGavin Shan <gshan@redhat.com>
      [maz: tidy-up bitmap values]
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220502233853.1233742-4-rananta@google.com
      428fd678
    • R
      KVM: arm64: Setup a framework for hypercall bitmap firmware registers · 05714cab
      Raghavendra Rao Ananta 提交于
      KVM regularly introduces new hypercall services to the guests without
      any consent from the userspace. This means, the guests can observe
      hypercall services in and out as they migrate across various host
      kernel versions. This could be a major problem if the guest
      discovered a hypercall, started using it, and after getting migrated
      to an older kernel realizes that it's no longer available. Depending
      on how the guest handles the change, there's a potential chance that
      the guest would just panic.
      
      As a result, there's a need for the userspace to elect the services
      that it wishes the guest to discover. It can elect these services
      based on the kernels spread across its (migration) fleet. To remedy
      this, extend the existing firmware pseudo-registers, such as
      KVM_REG_ARM_PSCI_VERSION, but by creating a new COPROC register space
      for all the hypercall services available.
      
      These firmware registers are categorized based on the service call
      owners, but unlike the existing firmware pseudo-registers, they hold
      the features supported in the form of a bitmap.
      
      During the VM initialization, the registers are set to upper-limit of
      the features supported by the corresponding registers. It's expected
      that the VMMs discover the features provided by each register via
      GET_ONE_REG, and write back the desired values using SET_ONE_REG.
      KVM allows this modification only until the VM has started.
      
      Some of the standard features are not mapped to any bits of the
      registers. But since they can recreate the original problem of
      making it available without userspace's consent, they need to
      be explicitly added to the case-list in
      kvm_hvc_call_default_allowed(). Any function-id that's not enabled
      via the bitmap, or not listed in kvm_hvc_call_default_allowed, will
      be returned as SMCCC_RET_NOT_SUPPORTED to the guest.
      
      Older userspace code can simply ignore the feature and the
      hypercall services will be exposed unconditionally to the guests,
      thus ensuring backward compatibility.
      
      In this patch, the framework adds the register only for ARM's standard
      secure services (owner value 4). Currently, this includes support only
      for ARM True Random Number Generator (TRNG) service, with bit-0 of the
      register representing mandatory features of v1.0. Other services are
      momentarily added in the upcoming patches.
      Signed-off-by: NRaghavendra Rao Ananta <rananta@google.com>
      Reviewed-by: NGavin Shan <gshan@redhat.com>
      [maz: reduced the scope of some helpers, tidy-up bitmap max values,
       dropped error-only fast path]
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220502233853.1233742-3-rananta@google.com
      05714cab
  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 次提交