1. 07 Mar, 2024 4 commits
    • Oliver Upton's avatar
      Merge branch kvm-arm64/lpi-xarray into kvmarm/next · 8dbc4110
      Oliver Upton authored
      * kvm-arm64/lpi-xarray:
        : xarray-based representation of vgic LPIs
        :
        : KVM's linked-list of LPI state has proven to be a bottleneck in LPI
        : injection paths, due to lock serialization when acquiring / releasing a
        : reference on an IRQ.
        :
        : Start the tedious process of reworking KVM's LPI injection by replacing
        : the LPI linked-list with an xarray, leveraging this to allow RCU readers
        : to walk it outside of the spinlock.
        KVM: arm64: vgic: Don't acquire the lpi_list_lock in vgic_put_irq()
        KVM: arm64: vgic: Ensure the irq refcount is nonzero when taking a ref
        KVM: arm64: vgic: Rely on RCU protection in vgic_get_lpi()
        KVM: arm64: vgic: Free LPI vgic_irq structs in an RCU-safe manner
        KVM: arm64: vgic: Use atomics to count LPIs
        KVM: arm64: vgic: Get rid of the LPI linked-list
        KVM: arm64: vgic-its: Walk the LPI xarray in vgic_copy_lpi_list()
        KVM: arm64: vgic-v3: Iterate the xarray to find pending LPIs
        KVM: arm64: vgic: Use xarray to find LPI in vgic_get_lpi()
        KVM: arm64: vgic: Store LPIs in an xarray
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      8dbc4110
    • Oliver Upton's avatar
      Merge branch kvm-arm64/vm-configuration into kvmarm/next · 0d874858
      Oliver Upton authored
      * kvm-arm64/vm-configuration: (29 commits)
        : VM configuration enforcement, courtesy of Marc Zyngier
        :
        : Userspace has gained the ability to control the features visible
        : through the ID registers, yet KVM didn't take this into account as the
        : effective feature set when determing trap / emulation behavior. This
        : series adds:
        :
        :  - Mechanism for testing the presence of a particular CPU feature in the
        :    guest's ID registers
        :
        :  - Infrastructure for computing the effective value of VNCR-backed
        :    registers, taking into account the RES0 / RES1 bits for a particular
        :    VM configuration
        :
        :  - Implementation of 'fine-grained UNDEF' controls that shadow the FGT
        :    register definitions.
        KVM: arm64: Don't initialize idreg debugfs w/ preemption disabled
        KVM: arm64: Fail the idreg iterator if idregs aren't initialized
        KVM: arm64: Make build-time check of RES0/RES1 bits optional
        KVM: arm64: Add debugfs file for guest's ID registers
        KVM: arm64: Snapshot all non-zero RES0/RES1 sysreg fields for later checking
        KVM: arm64: Make FEAT_MOPS UNDEF if not advertised to the guest
        KVM: arm64: Make AMU sysreg UNDEF if FEAT_AMU is not advertised to the guest
        KVM: arm64: Make PIR{,E0}_EL1 UNDEF if S1PIE is not advertised to the guest
        KVM: arm64: Make TLBI OS/Range UNDEF if not advertised to the guest
        KVM: arm64: Streamline save/restore of HFG[RW]TR_EL2
        KVM: arm64: Move existing feature disabling over to FGU infrastructure
        KVM: arm64: Propagate and handle Fine-Grained UNDEF bits
        KVM: arm64: Add Fine-Grained UNDEF tracking information
        KVM: arm64: Rename __check_nv_sr_forward() to triage_sysreg_trap()
        KVM: arm64: Use the xarray as the primary sysreg/sysinsn walker
        KVM: arm64: Register AArch64 system register entries with the sysreg xarray
        KVM: arm64: Always populate the trap configuration xarray
        KVM: arm64: nv: Move system instructions to their own sys_reg_desc array
        KVM: arm64: Drop the requirement for XARRAY_MULTI
        KVM: arm64: nv: Turn encoding ranges into discrete XArray stores
        ...
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      0d874858
    • Oliver Upton's avatar
      Merge branch kvm-arm64/misc into kvmarm/next · a040adfb
      Oliver Upton authored
      * kvm-arm64/misc:
        : Miscellaneous updates
        :
        :  - Fix handling of features w/ nonzero safe values in set_id_regs
        :    selftest
        :
        :  - Cleanup the unused kern_hyp_va() asm macro
        :
        :  - Differentiate nVHE and hVHE in boot-time message
        :
        :  - Several selftests cleanups
        :
        :  - Drop bogus return value from kvm_arch_create_vm_debugfs()
        :
        :  - Make save/restore of SPE and TRBE control registers affect EL1 state
        :    in hVHE mode
        :
        :  - Typos
        KVM: arm64: Fix TRFCR_EL1/PMSCR_EL1 access in hVHE mode
        KVM: selftests: aarch64: Remove unused functions from vpmu test
        KVM: arm64: Fix typos
        KVM: Get rid of return value from kvm_arch_create_vm_debugfs()
        KVM: selftests: Print timer ctl register in ISTATUS assertion
        KVM: selftests: Fix GUEST_PRINTF() format warnings in ARM code
        KVM: arm64: removed unused kern_hyp_va asm macro
        KVM: arm64: add comments to __kern_hyp_va
        KVM: arm64: print Hyp mode
        KVM: arm64: selftests: Handle feature fields with nonzero minimum value correctly
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      a040adfb
    • Oliver Upton's avatar
      Merge branch kvm-arm64/feat_e2h0 into kvmarm/next · 262cd16e
      Oliver Upton authored
      * kvm-arm64/feat_e2h0:
        : Support for FEAT_E2H0, courtesy of Marc Zyngier
        :
        : As described in the cover letter:
        :
        :   Since ARMv8.1, the architecture has grown the VHE feature, which makes
        :   EL2 a superset of EL1. With ARMv9.5 (and retroactively allowed from
        :   ARMv8.1), the architecture allows implementations to have VHE as the
        :   *only* implemented behaviour, meaning that HCR_EL2.E2H can be
        :   implemented as RES1. As a follow-up, HCR_EL2.NV1 can also be
        :   implemented as RES0, making the VHE-ness of the architecture
        :   recursive.
        :
        : This series adds support for detecting the architectural feature of E2H
        : being RES1, leveraging the existing infrastructure for handling
        : out-of-spec CPUs that are VHE-only. Additionally, the (incomplete) NV
        : infrastructure in KVM is updated to enforce E2H=1 for guest hypervisors
        : on implementations that do not support NV1.
        arm64: cpufeatures: Fix FEAT_NV check when checking for FEAT_NV1
        arm64: cpufeatures: Only check for NV1 if NV is present
        arm64: cpufeatures: Add missing ID_AA64MMFR4_EL1 to __read_sysreg_by_encoding()
        KVM: arm64: Handle Apple M2 as not having HCR_EL2.NV1 implemented
        KVM: arm64: Force guest's HCR_EL2.E2H RES1 when NV1 is not implemented
        KVM: arm64: Expose ID_AA64MMFR4_EL1 to guests
        arm64: Treat HCR_EL2.E2H as RES1 when ID_AA64MMFR4_EL1.E2H0 is negative
        arm64: cpufeature: Detect HCR_EL2.NV1 being RES0
        arm64: cpufeature: Add ID_AA64MMFR4_EL1 handling
        arm64: sysreg: Add layout for ID_AA64MMFR4_EL1
        arm64: cpufeature: Correctly display signed override values
        arm64: cpufeatures: Correctly handle signed values
        arm64: Add macro to compose a sysreg field value
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      262cd16e
  2. 01 Mar, 2024 1 commit
  3. 29 Feb, 2024 1 commit
  4. 27 Feb, 2024 2 commits
    • Oliver Upton's avatar
      KVM: arm64: Don't initialize idreg debugfs w/ preemption disabled · 5c1ebe9a
      Oliver Upton authored
      Testing KVM with DEBUG_ATOMIC_SLEEP enabled doesn't get far before hitting the
      first splat:
      
        BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1578
        in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 13062, name: vgic_lpi_stress
        preempt_count: 1, expected: 0
        2 locks held by vgic_lpi_stress/13062:
         #0: ffff080084553240 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0xc0/0x13f0
         #1: ffff800080485f08 (&kvm->arch.config_lock){+.+.}-{3:3}, at: kvm_arch_vcpu_ioctl+0xd60/0x1788
        CPU: 19 PID: 13062 Comm: vgic_lpi_stress Tainted: G        W  O       6.8.0-dbg-DEV #1
        Call trace:
         dump_backtrace+0xf8/0x148
         show_stack+0x20/0x38
         dump_stack_lvl+0xb4/0xf8
         dump_stack+0x18/0x40
         __might_resched+0x248/0x2a0
         __might_sleep+0x50/0x88
         down_write+0x30/0x150
         start_creating+0x90/0x1a0
         __debugfs_create_file+0x5c/0x1b0
         debugfs_create_file+0x34/0x48
         kvm_reset_sys_regs+0x120/0x1e8
         kvm_reset_vcpu+0x148/0x270
         kvm_arch_vcpu_ioctl+0xddc/0x1788
         kvm_vcpu_ioctl+0xb6c/0x13f0
         __arm64_sys_ioctl+0x98/0xd8
         invoke_syscall+0x48/0x108
         el0_svc_common+0xb4/0xf0
         do_el0_svc+0x24/0x38
         el0_svc+0x54/0x128
         el0t_64_sync_handler+0x68/0xc0
         el0t_64_sync+0x1a8/0x1b0
      
      kvm_reset_vcpu() disables preemption as it needs to unload vCPU state
      from the CPU to twiddle with it, which subsequently explodes when
      taking the parent inode's rwsem while creating the idreg debugfs file.
      
      Fix it by moving the initialization to kvm_arch_create_vm_debugfs().
      
      Fixes: 89176658 ("KVM: arm64: Add debugfs file for guest's ID registers")
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20240227094115.1723330-3-oliver.upton@linux.devSigned-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      5c1ebe9a
    • Oliver Upton's avatar
      KVM: arm64: Fail the idreg iterator if idregs aren't initialized · 29ef55ce
      Oliver Upton authored
      Return an error to userspace if the VM's ID register values haven't been
      initialized in preparation for changing the debugfs file initialization
      order.
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20240227094115.1723330-2-oliver.upton@linux.devSigned-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      29ef55ce
  5. 24 Feb, 2024 1 commit
  6. 23 Feb, 2024 11 commits
  7. 22 Feb, 2024 1 commit
  8. 19 Feb, 2024 19 commits