1. 29 Jan, 2023 1 commit
    • Gavin Shan's avatar
      KVM: arm64: Add helper vgic_write_guest_lock() · a23eaf93
      Gavin Shan authored
      Currently, the unknown no-running-vcpu sites are reported when a
      dirty page is tracked by mark_page_dirty_in_slot(). Until now, the
      only known no-running-vcpu site is saving vgic/its tables through
      KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} command on KVM device
      "kvm-arm-vgic-its". Unfortunately, there are more unknown sites to
      be handled and no-running-vcpu context will be allowed in these
      sites: (1) KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} command
      on KVM device "kvm-arm-vgic-its" to restore vgic/its tables. The
      vgic3 LPI pending status could be restored. (2) Save vgic3 pending
      table through KVM_DEV_ARM_{VGIC_GRP_CTRL, VGIC_SAVE_PENDING_TABLES}
      command on KVM device "kvm-arm-vgic-v3".
      
      In order to handle those unknown cases, we need a unified helper
      vgic_write_guest_lock(). struct vgic_dist::save_its_tables_in_progress
      is also renamed to struct vgic_dist::save_tables_in_progress.
      
      No functional change intended.
      Suggested-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarGavin Shan <gshan@redhat.com>
      Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20230126235451.469087-3-gshan@redhat.com
      a23eaf93
  2. 21 Jan, 2023 2 commits
  3. 05 Jan, 2023 6 commits
  4. 03 Jan, 2023 3 commits
    • Marc Zyngier's avatar
      KVM: arm64: Convert FSC_* over to ESR_ELx_FSC_* · b0803ba7
      Marc Zyngier authored
      The former is an AArch32 legacy, so let's move over to the
      verbose (and strictly identical) version.
      
      This involves moving some of the #defines that were private
      to KVM into the more generic esr.h.
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      b0803ba7
    • Marc Zyngier's avatar
      KVM: arm64: Document the behaviour of S1PTW faults on RO memslots · b8f8d190
      Marc Zyngier authored
      Although the KVM API says that a write to a RO memslot must result
      in a KVM_EXIT_MMIO describing the write, the arm64 architecture
      doesn't provide the *data* written by a Stage-1 page table walk
      (we only get the address).
      
      Since there isn't much userspace can do with so little information
      anyway, document the fact that such an access results in a guest
      exception, not an exit. This is consistent with the guest being
      terminally broken anyway.
      Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      b8f8d190
    • Marc Zyngier's avatar
      KVM: arm64: Fix S1PTW handling on RO memslots · 406504c7
      Marc Zyngier authored
      A recent development on the EFI front has resulted in guests having
      their page tables baked in the firmware binary, and mapped into the
      IPA space as part of a read-only memslot. Not only is this legitimate,
      but it also results in added security, so thumbs up.
      
      It is possible to take an S1PTW translation fault if the S1 PTs are
      unmapped at stage-2. However, KVM unconditionally treats S1PTW as a
      write to correctly handle hardware AF/DB updates to the S1 PTs.
      Furthermore, KVM injects an exception into the guest for S1PTW writes.
      In the aforementioned case this results in the guest taking an abort
      it won't recover from, as the S1 PTs mapping the vectors suffer from
      the same problem.
      
      So clearly our handling is... wrong.
      
      Instead, switch to a two-pronged approach:
      
      - On S1PTW translation fault, handle the fault as a read
      
      - On S1PTW permission fault, handle the fault as a write
      
      This is of no consequence to SW that *writes* to its PTs (the write
      will trigger a non-S1PTW fault), and SW that uses RO PTs will not
      use HW-assisted AF/DB anyway, as that'd be wrong.
      
      Only in the case described in c4ad98e4 ("KVM: arm64: Assume write
      fault on S1PTW permission fault on instruction fetch") do we end-up
      with two back-to-back faults (page being evicted and faulted back).
      I don't think this is a case worth optimising for.
      
      Fixes: c4ad98e4 ("KVM: arm64: Assume write fault on S1PTW permission fault on instruction fetch")
      Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Regression-tested-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      406504c7
  5. 01 Jan, 2023 6 commits
  6. 31 Dec, 2022 2 commits
  7. 30 Dec, 2022 19 commits
  8. 29 Dec, 2022 1 commit
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 2258c2dc
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "Changes that were posted too late for 6.1, or after the release.
      
        x86:
      
         - several fixes to nested VMX execution controls
      
         - fixes and clarification to the documentation for Xen emulation
      
         - do not unnecessarily release a pmu event with zero period
      
         - MMU fixes
      
         - fix Coverity warning in kvm_hv_flush_tlb()
      
        selftests:
      
         - fixes for the ucall mechanism in selftests
      
         - other fixes mostly related to compilation with clang"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (41 commits)
        KVM: selftests: restore special vmmcall code layout needed by the harness
        Documentation: kvm: clarify SRCU locking order
        KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET
        KVM: x86/xen: Documentation updates and clarifications
        KVM: x86/xen: Add KVM_XEN_INVALID_GPA and KVM_XEN_INVALID_GFN to uapi
        KVM: x86/xen: Simplify eventfd IOCTLs
        KVM: x86/xen: Fix SRCU/RCU usage in readers of evtchn_ports
        KVM: x86/xen: Use kvm_read_guest_virt() instead of open-coding it badly
        KVM: x86/xen: Fix memory leak in kvm_xen_write_hypercall_page()
        KVM: Delete extra block of "};" in the KVM API documentation
        kvm: x86/mmu: Remove duplicated "be split" in spte.h
        kvm: Remove the unused macro KVM_MMU_READ_{,UN}LOCK()
        MAINTAINERS: adjust entry after renaming the vmx hyperv files
        KVM: selftests: Mark correct page as mapped in virt_map()
        KVM: arm64: selftests: Don't identity map the ucall MMIO hole
        KVM: selftests: document the default implementation of vm_vaddr_populate_bitmap
        KVM: selftests: Use magic value to signal ucall_alloc() failure
        KVM: selftests: Disable "gnu-variable-sized-type-not-at-end" warning
        KVM: selftests: Include lib.mk before consuming $(CC)
        KVM: selftests: Explicitly disable builtins for mem*() overrides
        ...
      2258c2dc