1. 12 Jul, 2024 12 commits
  2. 04 Jul, 2024 2 commits
  3. 03 Jul, 2024 1 commit
  4. 26 Jun, 2024 5 commits
  5. 20 Jun, 2024 10 commits
    • Rick Edgecombe's avatar
      KVM: x86/tdp_mmu: Take a GFN in kvm_tdp_mmu_fast_pf_get_last_sptep() · c2f38f75
      Rick Edgecombe authored
      Pass fault->gfn into kvm_tdp_mmu_fast_pf_get_last_sptep(), instead of
      passing fault->addr and then converting it to a GFN.
      
      Future changes will make fault->addr and fault->gfn differ when running
      TDX guests. The GFN will be conceptually the same as it is for normal VMs,
      but fault->addr may contain a TDX specific bit that differentiates between
      "shared" and "private" memory. This bit will be used to direct faults to
      be handled on different roots, either the normal "direct" root or a new
      type of root that handles private memory. The TDP iterators will process
      the traditional GFN concept and apply the required TDX specifics depending
      on the root type. For this reason, it needs to operate on regular GFN and
      not the addr, which may contain these special TDX specific bits.
      
      Today kvm_tdp_mmu_fast_pf_get_last_sptep() takes fault->addr and then
      immediately converts it to a GFN with a bit shift. However, this would
      unfortunately retain the TDX specific bits in what is supposed to be a
      traditional GFN. Excluding TDX's needs, it is also is unnecessary to pass
      fault->addr and convert it to a GFN when the GFN is already on hand.
      
      So instead just pass the GFN into kvm_tdp_mmu_fast_pf_get_last_sptep() and
      use it directly.
      Signed-off-by: default avatarRick Edgecombe <rick.p.edgecombe@intel.com>
      Message-ID: <20240619223614.290657-9-rick.p.edgecombe@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c2f38f75
    • Rick Edgecombe's avatar
      KVM: x86/tdp_mmu: Rename REMOVED_SPTE to FROZEN_SPTE · 964cea81
      Rick Edgecombe authored
      Rename REMOVED_SPTE to FROZEN_SPTE so that it can be used for other
      multi-part operations.
      
      REMOVED_SPTE is used as a non-present intermediate value for multi-part
      operations that can happen when a thread doesn't have an MMU write lock.
      Today these operations are when removing PTEs.
      
      However, future changes will want to use the same concept for setting a
      PTE. In that case the REMOVED_SPTE name does not quite fit. So rename it
      to FROZEN_SPTE so it can be used for both types of operations.
      
      Also rename the relevant helpers and comments that refer to "removed"
      within the context of the SPTE value. Take care to not update naming
      referring the "remove" operations, which are still distinct.
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarRick Edgecombe <rick.p.edgecombe@intel.com>
      Message-ID: <20240619223614.290657-2-rick.p.edgecombe@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      964cea81
    • Paolo Bonzini's avatar
      Merge branch 'kvm-6.10-fixes' into HEAD · 02b0d3b9
      Paolo Bonzini authored
      02b0d3b9
    • Isaku Yamahata's avatar
      KVM: x86/tdp_mmu: Sprinkle __must_check · 8a4e2742
      Isaku Yamahata authored
      The TDP MMU function __tdp_mmu_set_spte_atomic uses a cmpxchg64 to replace
      the SPTE value and returns -EBUSY on failure.  The caller must check the
      return value and retry.  Add __must_check to it, as well as to two more
      functions that forward the return value of __tdp_mmu_set_spte_atomic to
      their caller.
      Signed-off-by: default avatarIsaku Yamahata <isaku.yamahata@intel.com>
      Reviewed-by: default avatarBinbin Wu <binbin.wu@linux.intel.com>
      Message-Id: <8f7d5a1b241bf5351eaab828d1a1efe5c17699ca.1705965635.git.isaku.yamahata@intel.com>
      Acked-by: default avatarKai Huang <kai.huang@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8a4e2742
    • Paolo Bonzini's avatar
      KVM: interrupt kvm_gmem_populate() on signals · d8147384
      Paolo Bonzini authored
      kvm_gmem_populate() is a potentially lengthy operation that can involve
      multiple calls to the firmware.  Interrupt it if a signal arrives.
      
      Fixes: 1f6c06b1 ("KVM: guest_memfd: Add interface for populating gmem pages with user data")
      Cc: Isaku Yamahata <isaku.yamahata@intel.com>
      Cc: Michael Roth <michael.roth@amd.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d8147384
    • Bibo Mao's avatar
      KVM: Discard zero mask with function kvm_dirty_ring_reset · 676f819c
      Bibo Mao authored
      Function kvm_reset_dirty_gfn may be called with parameters cur_slot /
      cur_offset / mask are all zero, it does not represent real dirty page.
      It is not necessary to clear dirty page in this condition. Also return
      value of macro __fls() is undefined if mask is zero which is called in
      funciton kvm_reset_dirty_gfn(). Here just return.
      Signed-off-by: default avatarBibo Mao <maobibo@loongson.cn>
      Message-ID: <20240613122803.1031511-1-maobibo@loongson.cn>
      [Move the conditional inside kvm_reset_dirty_gfn; suggested by
       Sean Christopherson. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      676f819c
    • Paolo Bonzini's avatar
      virt: guest_memfd: fix reference leak on hwpoisoned page · c31745d2
      Paolo Bonzini authored
      If kvm_gmem_get_pfn() detects an hwpoisoned page, it returns -EHWPOISON
      but it does not put back the reference that kvm_gmem_get_folio() had
      grabbed.  Add the forgotten folio_put().
      
      Fixes: a7800aa8 ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarLiam Merwick <liam.merwick@oracle.com>
      Reviewed-by: default avatarIsaku Yamahata <isaku.yamahata@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c31745d2
    • Alexey Dobriyan's avatar
      kvm: do not account temporary allocations to kmem · f474092c
      Alexey Dobriyan authored
      Some allocations done by KVM are temporary, they are created as result
      of program actions, but can't exists for arbitrary long times.
      
      They should have been GFP_TEMPORARY (rip!).
      
      OTOH, kvm-nx-lpage-recovery and kvm-pit kernel threads exist for as long
      as VM exists but their task_struct memory is not accounted.
      This is story for another day.
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Message-ID: <c0122f66-f428-417e-a360-b25fc0f154a0@p183>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f474092c
    • Sean Christopherson's avatar
      MAINTAINERS: Drop Wanpeng Li as a Reviewer for KVM Paravirt support · b0185890
      Sean Christopherson authored
      Drop Wanpeng as a KVM PARAVIRT reviewer as his @tencent.com email is
      bouncing, and according to lore[*], the last activity from his @gmail.com
      address was almost two years ago.
      
      [*] https://lore.kernel.org/all/CANRm+Cwj29M9HU3=JRUOaKDR+iDKgr0eNMWQi0iLkR5THON-bg@mail.gmail.com
      
      Cc: Wanpeng Li <kernellwp@gmail.com>
      Cc: Like Xu <like.xu.linux@gmail.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-ID: <20240610163427.3359426-1-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b0185890
    • Sean Christopherson's avatar
      KVM: x86: Always sync PIR to IRR prior to scanning I/O APIC routes · f3ced000
      Sean Christopherson authored
      Sync pending posted interrupts to the IRR prior to re-scanning I/O APIC
      routes, irrespective of whether the I/O APIC is emulated by userspace or
      by KVM.  If a level-triggered interrupt routed through the I/O APIC is
      pending or in-service for a vCPU, KVM needs to intercept EOIs on said
      vCPU even if the vCPU isn't the destination for the new routing, e.g. if
      servicing an interrupt using the old routing races with I/O APIC
      reconfiguration.
      
      Commit fceb3a36 ("KVM: x86: ioapic: Fix level-triggered EOI and
      userspace I/OAPIC reconfigure race") fixed the common cases, but
      kvm_apic_pending_eoi() only checks if an interrupt is in the local
      APIC's IRR or ISR, i.e. misses the uncommon case where an interrupt is
      pending in the PIR.
      
      Failure to intercept EOI can manifest as guest hangs with Windows 11 if
      the guest uses the RTC as its timekeeping source, e.g. if the VMM doesn't
      expose a more modern form of time to the guest.
      
      Cc: stable@vger.kernel.org
      Cc: Adamos Ttofari <attofari@amazon.de>
      Cc: Raghavendra Rao Ananta <rananta@google.com>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-ID: <20240611014845.82795-1-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f3ced000
  6. 06 Jun, 2024 1 commit
  7. 05 Jun, 2024 3 commits
    • Ravi Bangoria's avatar
      KVM: SNP: Fix LBR Virtualization for SNP guest · f99b0522
      Ravi Bangoria authored
      SEV-ES and thus SNP guest mandates LBR Virtualization to be _always_ ON.
      Although commit b7e4be0a ("KVM: SEV-ES: Delegate LBR virtualization
      to the processor") did the correct change for SEV-ES guests, it missed
      the SNP. Fix it.
      Reported-by: default avatarSrikanth Aithal <sraithal@amd.com>
      Fixes: b7e4be0a ("KVM: SEV-ES: Delegate LBR virtualization to the processor")
      Signed-off-by: default avatarRavi Bangoria <ravi.bangoria@amd.com>
      Message-ID: <20240605114810.1304-1-ravi.bangoria@amd.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f99b0522
    • Tao Su's avatar
      KVM: x86/mmu: Don't save mmu_invalidate_seq after checking private attr · db574f2f
      Tao Su authored
      Drop the second snapshot of mmu_invalidate_seq in kvm_faultin_pfn().
      Before checking the mismatch of private vs. shared, mmu_invalidate_seq is
      saved to fault->mmu_seq, which can be used to detect an invalidation
      related to the gfn occurred, i.e. KVM will not install a mapping in page
      table if fault->mmu_seq != mmu_invalidate_seq.
      
      Currently there is a second snapshot of mmu_invalidate_seq, which may not
      be same as the first snapshot in kvm_faultin_pfn(), i.e. the gfn attribute
      may be changed between the two snapshots, but the gfn may be mapped in
      page table without hindrance. Therefore, drop the second snapshot as it
      has no obvious benefits.
      
      Fixes: f6adeae8 ("KVM: x86/mmu: Handle no-slot faults at the beginning of kvm_faultin_pfn()")
      Signed-off-by: default avatarTao Su <tao1.su@linux.intel.com>
      Message-ID: <20240528102234.2162763-1-tao1.su@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      db574f2f
    • Paolo Bonzini's avatar
      Merge tag 'kvmarm-fixes-6.10-1' of... · 45ce0314
      Paolo Bonzini authored
      Merge tag 'kvmarm-fixes-6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
      
      KVM/arm64 fixes for 6.10, take #1
      
      - Large set of FP/SVE fixes for pKVM, addressing the fallout
        from the per-CPU data rework and making sure that the host
        is not involved in the FP/SVE switching any more
      
      - Allow FEAT_BTI to be enabled with NV now that FEAT_PAUTH
        is copletely supported
      
      - Fix for the respective priorities of Failed PAC, Illegal
        Execution state and Instruction Abort exceptions
      
      - Fix the handling of AArch32 instruction traps failing their
        condition code, which was broken by the introduction of
        ESR_EL2.ISS2
      
      - Allow vpcus running in AArch32 state to be restored in
        System mode
      
      - Fix AArch32 GPR restore that would lose the 64 bit state
        under some conditions
      45ce0314
  8. 04 Jun, 2024 6 commits