1. Apr 21, 2023
    • Marc Zyngier's avatar
      Merge branch kvm-arm64/smccc-filtering into kvmarm-master/next · 6dcf7316
      Marc Zyngier authored
      
      
      * kvm-arm64/smccc-filtering:
        : .
        : SMCCC call filtering and forwarding to userspace, courtesy of
        : Oliver Upton. From the cover letter:
        :
        : "The Arm SMCCC is rather prescriptive in regards to the allocation of
        : SMCCC function ID ranges. Many of the hypercall ranges have an
        : associated specification from Arm (FF-A, PSCI, SDEI, etc.) with some
        : room for vendor-specific implementations.
        :
        : The ever-expanding SMCCC surface leaves a lot of work within KVM for
        : providing new features. Furthermore, KVM implements its own
        : vendor-specific ABI, with little room for other implementations (like
        : Hyper-V, for example). Rather than cramming it all into the kernel we
        : should provide a way for userspace to handle hypercalls."
        : .
        KVM: selftests: Fix spelling mistake "KVM_HYPERCAL_EXIT_SMC" -> "KVM_HYPERCALL_EXIT_SMC"
        KVM: arm64: Test that SMC64 arch calls are reserved
        KVM: arm64: Prevent userspace from handling SMC64 arch range
        KVM: arm64: Expose SMC/HVC width to userspace
        KVM: selftests: Add test for SMCCC filter
        KVM: selftests: Add a helper for SMCCC calls with SMC instruction
        KVM: arm64: Let errors from SMCCC emulation to reach userspace
        KVM: arm64: Return NOT_SUPPORTED to guest for unknown PSCI version
        KVM: arm64: Introduce support for userspace SMCCC filtering
        KVM: arm64: Add support for KVM_EXIT_HYPERCALL
        KVM: arm64: Use a maple tree to represent the SMCCC filter
        KVM: arm64: Refactor hvc filtering to support different actions
        KVM: arm64: Start handling SMCs from EL1
        KVM: arm64: Rename SMC/HVC call handler to reflect reality
        KVM: arm64: Add vm fd device attribute accessors
        KVM: arm64: Add a helper to check if a VM has ran once
        KVM: x86: Redefine 'longmode' as a flag for KVM_EXIT_HYPERCALL
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      6dcf7316
    • Marc Zyngier's avatar
      Merge branch kvm-arm64/selftest/misc-6.4 into kvmarm-master/next · 367eb095
      Marc Zyngier authored
      
      
      * kvm-arm64/selftest/misc-6.4:
        : .
        : Misc selftest updates for 6.4
        :
        : - Add comments for recently added ID registers
        : .
        KVM: selftests: Comment newly defined aarch64 ID registers
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      367eb095
    • Marc Zyngier's avatar
      Merge branch kvm-arm64/selftest/lpa into kvmarm-master/next · e2e321a7
      Marc Zyngier authored
      
      
      * kvm-arm64/selftest/lpa:
        : .
        : Selftest fixes addressing PTE and TTBR0_EL1 encodings for
        : 52bit PAs
        : .
        KVM: selftests: arm64: Fix ttbr0_el1 encoding for PA bits > 48
        KVM: selftests: arm64: Fix pte encode/decode for PA bits > 48
        KVM: selftests: Fixup config fragment for access_tracking_perf_test
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      e2e321a7
    • Marc Zyngier's avatar
      Merge branch kvm-arm64/timer-vm-offsets into kvmarm-master/next · b22498c4
      Marc Zyngier authored
      
      
      * kvm-arm64/timer-vm-offsets: (21 commits)
        : .
        : This series aims at satisfying multiple goals:
        :
        : - allow a VMM to atomically restore a timer offset for a whole VM
        :   instead of updating the offset each time a vcpu get its counter
        :   written
        :
        : - allow a VMM to save/restore the physical timer context, something
        :   that we cannot do at the moment due to the lack of offsetting
        :
        : - provide a framework that is suitable for NV support, where we get
        :   both global and per timer, per vcpu offsetting, and manage
        :   interrupts in a less braindead way.
        :
        : Conflict resolution involves using the new per-vcpu config lock instead
        : of the home-grown timer lock.
        : .
        KVM: arm64: Handle 32bit CNTPCTSS traps
        KVM: arm64: selftests: Augment existing timer test to handle variable offset
        KVM: arm64: selftests: Deal with spurious timer interrupts
        KVM: arm64: selftests: Add physical timer registers to the sysreg list
        KVM: arm64: nv: timers: Support hyp timer emulation
        KVM: arm64: nv: timers: Add a per-timer, per-vcpu offset
        KVM: arm64: Document KVM_ARM_SET_CNT_OFFSETS and co
        KVM: arm64: timers: Abstract the number of valid timers per vcpu
        KVM: arm64: timers: Fast-track CNTPCT_EL0 trap handling
        KVM: arm64: Elide kern_hyp_va() in VHE-specific parts of the hypervisor
        KVM: arm64: timers: Move the timer IRQs into arch_timer_vm_data
        KVM: arm64: timers: Abstract per-timer IRQ access
        KVM: arm64: timers: Rationalise per-vcpu timer init
        KVM: arm64: timers: Allow save/restoring of the physical timer
        KVM: arm64: timers: Allow userspace to set the global counter offset
        KVM: arm64: Expose {un,}lock_all_vcpus() to the rest of KVM
        KVM: arm64: timers: Allow physical offset without CNTPOFF_EL2
        KVM: arm64: timers: Use CNTPOFF_EL2 to offset the physical timer
        arm64: Add HAS_ECV_CNTPOFF capability
        arm64: Add CNTPOFF_EL2 register definition
        ...
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      b22498c4
    • Marc Zyngier's avatar
      Merge branch kvm-arm64/lock-inversion into kvmarm-master/next · ef5f97e9
      Marc Zyngier authored
      
      
      * kvm-arm64/lock-inversion:
        : .
        : vm/vcpu lock inversion fixes, courtesy of Oliver Upton, plus a few
        : extra fixes from both Oliver and Reiji Watanabe.
        :
        : From the initial cover letter:
        :
        : As it so happens, lock ordering in KVM/arm64 is completely backwards.
        : There's a significant amount of VM-wide state that needs to be accessed
        : from the context of a vCPU. Until now, this was accomplished by
        : acquiring the kvm->lock, but that cannot be nested within vcpu->mutex.
        :
        : This series fixes the issue with some fine-grained locking for MP state
        : and a new, dedicated mutex that can nest with both kvm->lock and
        : vcpu->mutex.
        : .
        KVM: arm64: Have kvm_psci_vcpu_on() use WRITE_ONCE() to update mp_state
        KVM: arm64: Acquire mp_state_lock in kvm_arch_vcpu_ioctl_vcpu_init()
        KVM: arm64: vgic: Don't acquire its_lock before config_lock
        KVM: arm64: Use config_lock to protect vgic state
        KVM: arm64: Use config_lock to protect data ordered against KVM_RUN
        KVM: arm64: Avoid lock inversion when setting the VM register width
        KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      ef5f97e9
  2. Apr 20, 2023
  3. Apr 13, 2023
  4. Apr 12, 2023
  5. Apr 08, 2023
  6. Apr 06, 2023
    • Marc Zyngier's avatar
      KVM: arm64: Expose SMC/HVC width to userspace · 0e5c9a9d
      Marc Zyngier authored
      
      
      When returning to userspace to handle a SMCCC call, we consistently
      set PC to point to the instruction immediately after the HVC/SMC.
      
      However, should userspace need to know the exact address of the
      trapping instruction, it needs to know about the *size* of that
      instruction. For AArch64, this is pretty easy. For AArch32, this
      is a bit more funky, as Thumb has 16bit encodings for both HVC
      and SMC.
      
      Expose this to userspace with a new flag that directly derives
      from ESR_EL2.IL. Also update the documentation to reflect the PC
      state at the point of exit.
      
      Finally, this fixes a small buglet where the hypercall.{args,ret}
      fields would not be cleared on exit, and could contain some
      random junk.
      
      Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/86pm8iv8tj.wl-maz@kernel.org
      0e5c9a9d
  7. Apr 05, 2023
  8. Mar 31, 2023