1. 11 May, 2016 1 commit
    • Paolo Bonzini's avatar
      Merge tag 'kvm-arm-for-4.7' of... · bdb4094e
      Paolo Bonzini authored
      Merge tag 'kvm-arm-for-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
      
      KVM/ARM Changes for Linux v4.7
      
      Reworks our stage 2 page table handling to have page table manipulation
      macros separate from those of the host systems as the underlying
      hardware page tables can be configured to be noticably different in
      layout from the stage 1 page tables used by the host.
      
      Adds 16K page size support based on the above.
      
      Adds a generic firmware probing layer for the timer and GIC so that KVM
      initializes using the same logic based on both ACPI and FDT.
      
      Finally adds support for hardware updating of the access flag.
      bdb4094e
  2. 10 May, 2016 6 commits
    • Paolo Bonzini's avatar
      Merge tag 'kvm-s390-next-4.7-2' of... · 6ac0f61f
      Paolo Bonzini authored
      Merge tag 'kvm-s390-next-4.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
      
      KVM: s390: features and fixes for 4.7 part2
      
      - Use hardware provided information about facility bits that do not
        need any hypervisor activitiy
      - Add missing documentation for KVM_CAP_S390_RI
      - Some updates/fixes for handling cpu models and facilities
      6ac0f61f
    • James Hogan's avatar
      MIPS: KVM: Add missing disable FPU hazard barriers · 4ac33429
      James Hogan authored
      Add the necessary hazard barriers after disabling the FPU in
      kvm_lose_fpu(), just to be safe.
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim KrčmáÅ" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4ac33429
    • James Hogan's avatar
      MIPS: KVM: Fix preemption warning reading FPU capability · 556f2a52
      James Hogan authored
      Reading the KVM_CAP_MIPS_FPU capability returns cpu_has_fpu, however
      this uses smp_processor_id() to read the current CPU capabilities (since
      some old MIPS systems could have FPUs present on only a subset of CPUs).
      
      We don't support any such systems, so work around the warning by using
      raw_cpu_has_fpu instead.
      
      We should probably instead claim not to support FPU at all if any one
      CPU is lacking an FPU, but this should do for now.
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim KrčmáÅ" <rkrcmar@redhat.com>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      556f2a52
    • James Hogan's avatar
      MIPS: KVM: Fix preemptable kvm_mips_get_*_asid() calls · f049729c
      James Hogan authored
      There are a couple of places in KVM fault handling code which implicitly
      use smp_processor_id() via kvm_mips_get_kernel_asid() and
      kvm_mips_get_user_asid() from preemptable context. This is unsafe as a
      preemption could cause the guest kernel ASID to be changed, resulting in
      a host TLB entry being written with the wrong ASID.
      
      Fix by disabling preemption around the kvm_mips_get_*_asid() call and
      the corresponding kvm_mips_host_tlb_write().
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim KrčmáÅ" <rkrcmar@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f049729c
    • James Hogan's avatar
      MIPS: KVM: Fix timer IRQ race when writing CP0_Compare · b45bacd2
      James Hogan authored
      Writing CP0_Compare clears the timer interrupt pending bit
      (CP0_Cause.TI), but this wasn't being done atomically. If a timer
      interrupt raced with the write of the guest CP0_Compare, the timer
      interrupt could end up being pending even though the new CP0_Compare is
      nowhere near CP0_Count.
      
      We were already updating the hrtimer expiry with
      kvm_mips_update_hrtimer(), which used both kvm_mips_freeze_hrtimer() and
      kvm_mips_resume_hrtimer(). Close the race window by expanding out
      kvm_mips_update_hrtimer(), and clearing CP0_Cause.TI and setting
      CP0_Compare between the freeze and resume. Since the pending timer
      interrupt should not be cleared when CP0_Compare is written via the KVM
      user API, an ack argument is added to distinguish the source of the
      write.
      
      Fixes: e30492bb ("MIPS: KVM: Rewrite count/compare timer emulation")
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim KrčmáÅ" <rkrcmar@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      Cc: <stable@vger.kernel.org> # 3.16.x-
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b45bacd2
    • James Hogan's avatar
      MIPS: KVM: Fix timer IRQ race when freezing timer · 4355c44f
      James Hogan authored
      There's a particularly narrow and subtle race condition when the
      software emulated guest timer is frozen which can allow a guest timer
      interrupt to be missed.
      
      This happens due to the hrtimer expiry being inexact, so very
      occasionally the freeze time will be after the moment when the emulated
      CP0_Count transitions to the same value as CP0_Compare (so an IRQ should
      be generated), but before the moment when the hrtimer is due to expire
      (so no IRQ is generated). The IRQ won't be generated when the timer is
      resumed either, since the resume CP0_Count will already match CP0_Compare.
      
      With VZ guests in particular this is far more likely to happen, since
      the soft timer may be frozen frequently in order to restore the timer
      state to the hardware guest timer. This happens after 5-10 hours of
      guest soak testing, resulting in an overflow in guest kernel timekeeping
      calculations, hanging the guest. A more focussed test case to
      intentionally hit the race (with the help of a new hypcall to cause the
      timer state to migrated between hardware & software) hits the condition
      fairly reliably within around 30 seconds.
      
      Instead of relying purely on the inexact hrtimer expiry to determine
      whether an IRQ should be generated, read the guest CP0_Compare and
      directly check whether the freeze time is before or after it. Only if
      CP0_Count is on or after CP0_Compare do we check the hrtimer expiry to
      determine whether the last IRQ has already been generated (which will
      have pushed back the expiry by one timer period).
      
      Fixes: e30492bb ("MIPS: KVM: Rewrite count/compare timer emulation")
      Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Radim KrčmáÅ" <rkrcmar@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: kvm@vger.kernel.org
      Cc: <stable@vger.kernel.org> # 3.16.x-
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4355c44f
  3. 09 May, 2016 10 commits
  4. 04 May, 2016 2 commits
  5. 03 May, 2016 11 commits
  6. 29 Apr, 2016 2 commits
  7. 25 Apr, 2016 1 commit
  8. 21 Apr, 2016 7 commits
    • Suzuki K Poulose's avatar
      arm64: kvm: Add support for 16K pages · 02e0b760
      Suzuki K Poulose authored
      Now that we can handle stage-2 page tables independent
      of the host page table levels, wire up the 16K page
      support.
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      02e0b760
    • Suzuki K Poulose's avatar
      kvm-arm: Cleanup stage2 pgd handling · 9163ee23
      Suzuki K Poulose authored
      Now that we don't have any fake page table levels for arm64,
      cleanup the common code to get rid of the dead code.
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      9163ee23
    • Suzuki K Poulose's avatar
      kvm: arm64: Get rid of fake page table levels · da04fa04
      Suzuki K Poulose authored
      On arm64, the hardware supports concatenation of upto 16 tables,
      at entry level for stage2 translations and we make use that whenever
      possible. This could lead to reduced number of translation levels than
      the normal (stage1 table) table. Also, since the IPA(40bit) is smaller
      than the some of the supported VA_BITS (e.g, 48bit), there could be
      different number of levels in stage-1 vs stage-2 tables. To reuse the
      kernel host page table walker for stage2 we have been using a fake
      software page table level, not known to the hardware. But with 16K
      translations, there could be upto 2 fake software levels (with 48bit VA
      and 40bit IPA), which complicates the code. Hence, we want to get rid of
      the hack.
      
      Now that we have explicit accessors for hyp vs stage2 page tables,
      define the stage2 walker helpers accordingly based on the actual
      table used by the hardware.
      
      Once we know the number of translation levels used by the hardware,
      it is merely a job of defining the helpers based on whether a
      particular level is folded or not, looking at the number of levels.
      
      Some facts before we calculate the translation levels:
      
      1) Smallest page size supported by arm64 is 4K.
      2) The minimum number of bits resolved at any page table level
         is (PAGE_SHIFT - 3) at intermediate levels.
      Both of them implies, minimum number of bits required for a level
      change is 9.
      
      Since we can concatenate upto 16 tables at stage2 entry, the total
      number of page table levels used by the hardware for resolving N bits
      is same as that for (N - 4) bits (with concatenation), as there cannot
      be a level in between (N, N-4) as per the above rules.
      
      Hence, we have
      
       STAGE2_PGTABLE_LEVELS = PGTABLE_LEVELS(KVM_PHYS_SHIFT - 4)
      
      With the current IPA limit (40bit), for all supported translations
      and VA_BITS, we have the following condition (even for 36bit VA with
      16K page size):
      
       CONFIG_PGTABLE_LEVELS >= STAGE2_PGTABLE_LEVELS.
      
      So, for e.g,  if PUD is present in stage2, it is present in the hyp(host).
      Hence, we fall back to the host definition if we find that a level is not
      folded. Otherwise we redefine it accordingly. A build time check is added
      to make sure the above condition holds. If this condition breaks in future,
      we can rearrange the host level helpers and fix our code easily.
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Christoffer Dall <christoffer.dall@linaro.org>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      da04fa04
    • Suzuki K Poulose's avatar
      kvm-arm: Cleanup kvm_* wrappers · 8684e701
      Suzuki K Poulose authored
      Now that we have switched to explicit page table routines,
      get rid of the obsolete kvm_* wrappers.
      
      Also, kvm_tlb_flush_vmid_by_ipa is now called only on stage2
      page tables, hence get rid of the redundant check.
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      8684e701
    • Suzuki K Poulose's avatar
      kvm-arm: Add stage2 page table modifiers · 7a1c831e
      Suzuki K Poulose authored
      Now that the hyp page table is handled by different set of
      routines, rename the original shared routines to stage2 handlers.
      Also make explicit use of the stage2 page table helpers.
      
      unmap_range has been merged to existing unmap_stage2_range.
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      7a1c831e
    • Suzuki K Poulose's avatar
      kvm-arm: Add explicit hyp page table modifiers · 64f32497
      Suzuki K Poulose authored
      We have common routines to modify hyp and stage2 page tables
      based on the 'kvm' parameter. For a smoother transition to
      using separate routines for each, duplicate the routines
      and modify the copy to work on hyp.
      
      Marks the forked routines with _hyp_ and gets rid of the
      kvm parameter which is no longer needed and is NULL for hyp.
      Also, gets rid of calls to kvm_tlb_flush_by_vmid_ipa() calls
      from the hyp versions. Uses explicit host page table accessors
      instead of the kvm_* page table helpers.
      Suggested-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      64f32497
    • Suzuki K Poulose's avatar
      kvm-arm: Use explicit stage2 helper routines · 70fd1906
      Suzuki K Poulose authored
      We have stage2 page table helpers for both arm and arm64. Switch to
      the stage2 helpers for routines that only deal with stage2 page table.
      
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      70fd1906