1. 20 2月, 2019 1 次提交
    • C
      KVM: arm/arm64: Factor out VMID into struct kvm_vmid · e329fb75
      Christoffer Dall 提交于
      In preparation for nested virtualization where we are going to have more
      than a single VMID per VM, let's factor out the VMID data into a
      separate VMID data structure and change the VMID allocator to operate on
      this new structure instead of using a struct kvm.
      
      This also means that udate_vttbr now becomes update_vmid, and that the
      vttbr itself is generated on the fly based on the stage 2 page table
      base address and the vmid.
      
      We cache the physical address of the pgd when allocating the pgd to
      avoid doing the calculation on every entry to the guest and to avoid
      calling into potentially non-hyp-mapped code from hyp/EL2.
      
      If we wanted to merge the VMID allocator with the arm64 ASID allocator
      at some point in the future, it should actually become easier to do that
      after this patch.
      
      Note that to avoid mapping the kvm_vmid_bits variable into hyp, we
      simply forego the masking of the vmid value in kvm_get_vttbr and rely on
      update_vmid to always assign a valid vmid value (within the supported
      range).
      Reviewed-by: NMarc Zyngier <marc.zyngier@arm.com>
      [maz: minor cleanups]
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Signed-off-by: NChristoffer Dall <christoffer.dall@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      e329fb75
  2. 18 12月, 2018 6 次提交
  3. 03 10月, 2018 1 次提交
    • S
      kvm: arm64: Set a limit on the IPA size · 0f62f0e9
      Suzuki K Poulose 提交于
      So far we have restricted the IPA size of the VM to the default
      value (40bits). Now that we can manage the IPA size per VM and
      support dynamic stage2 page tables, we can allow VMs to have
      larger IPA. This patch introduces a the maximum IPA size
      supported on the host. This is decided by the following factors :
      
       1) Maximum PARange supported by the CPUs - This can be inferred
          from the system wide safe value.
       2) Maximum PA size supported by the host kernel (48 vs 52)
       3) Number of levels in the host page table (as we base our
          stage2 tables on the host table helpers).
      
      Since the stage2 page table code is dependent on the stage1
      page table, we always ensure that :
      
        Number of Levels at Stage1 >= Number of Levels at Stage2
      
      So we limit the IPA to make sure that the above condition
      is satisfied. This will affect the following combinations
      of VA_BITS and IPA for different page sizes.
      
        Host configuration | Unsupported IPA ranges
        39bit VA, 4K       | [44, 48]
        36bit VA, 16K      | [41, 48]
        42bit VA, 64K      | [47, 52]
      
      Supporting the above combinations need independent stage2
      page table manipulation code, which would need substantial
      changes. We could purse the solution independently and
      switch the page table code once we have it ready.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Christoffer Dall <cdall@kernel.org>
      Reviewed-by: NEric Auger <eric.auger@redhat.com>
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      0f62f0e9
  4. 01 10月, 2018 1 次提交
  5. 18 9月, 2018 1 次提交
  6. 09 7月, 2018 2 次提交
  7. 01 6月, 2018 1 次提交
  8. 31 5月, 2018 3 次提交
  9. 15 5月, 2018 1 次提交
  10. 19 3月, 2018 5 次提交
  11. 09 1月, 2018 1 次提交
  12. 08 1月, 2018 5 次提交
  13. 23 12月, 2017 2 次提交
  14. 09 4月, 2017 1 次提交
  15. 30 1月, 2017 2 次提交
  16. 08 9月, 2016 1 次提交
    • M
      arm/kvm: excise redundant cache maintenance · dcadda14
      Mark Rutland 提交于
      When modifying Stage-2 page tables, we perform cache maintenance to
      account for non-coherent page table walks. However, this is unnecessary,
      as page table walks are guaranteed to be coherent in the presence of the
      virtualization extensions.
      
      Per ARM DDI 0406C.c, section B1.7 ("The Virtualization Extensions"), the
      virtualization extensions mandate the multiprocessing extensions.
      
      Per ARM DDI 0406C.c, section B3.10.1 ("General TLB maintenance
      requirements"), as described in the sub-section titled "TLB maintenance
      operations and the memory order model", this maintenance is not required
      in the presence of the multiprocessing extensions.
      
      Hence, we need not perform this cache maintenance when modifying Stage-2
      entries.
      
      This patch removes the logic for performing the redundant maintenance.
      To ensure visibility and ordering of updates, a dsb(ishst) that was
      otherwise implicit in the maintenance is folded into kvm_set_pmd() and
      kvm_set_pte().
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Christoffer Dall <christoffer.dall@linaro.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: kvmarm@lists.cs.columbia.edu
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      dcadda14
  17. 04 7月, 2016 4 次提交
  18. 29 6月, 2016 1 次提交
  19. 10 5月, 2016 1 次提交
    • C
      kvm: arm64: Enable hardware updates of the Access Flag for Stage 2 page tables · 06485053
      Catalin Marinas 提交于
      The ARMv8.1 architecture extensions introduce support for hardware
      updates of the access and dirty information in page table entries. With
      VTCR_EL2.HA enabled (bit 21), when the CPU accesses an IPA with the
      PTE_AF bit cleared in the stage 2 page table, instead of raising an
      Access Flag fault to EL2 the CPU sets the actual page table entry bit
      (10). To ensure that kernel modifications to the page table do not
      inadvertently revert a bit set by hardware updates, certain Stage 2
      software pte/pmd operations must be performed atomically.
      
      The main user of the AF bit is the kvm_age_hva() mechanism. The
      kvm_age_hva_handler() function performs a "test and clear young" action
      on the pte/pmd. This needs to be atomic in respect of automatic hardware
      updates of the AF bit. Since the AF bit is in the same position for both
      Stage 1 and Stage 2, the patch reuses the existing
      ptep_test_and_clear_young() functionality if
      __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG is defined. Otherwise, the
      existing pte_young/pte_mkold mechanism is preserved.
      
      The kvm_set_s2pte_readonly() (and the corresponding pmd equivalent) have
      to perform atomic modifications in order to avoid a race with updates of
      the AF bit. The arm64 implementation has been re-written using
      exclusives.
      
      Currently, kvm_set_s2pte_writable() (and pmd equivalent) take a pointer
      argument and modify the pte/pmd in place. However, these functions are
      only used on local variables rather than actual page table entries, so
      it makes more sense to follow the pte_mkwrite() approach for stage 1
      attributes. The change to kvm_s2pte_mkwrite() makes it clear that these
      functions do not modify the actual page table entries.
      
      The (pte|pmd)_mkyoung() uses on Stage 2 entries (setting the AF bit
      explicitly) do not need to be modified since hardware updates of the
      dirty status are not supported by KVM, so there is no possibility of
      losing such information.
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: NChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: NChristoffer Dall <christoffer.dall@linaro.org>
      06485053