mbox series

[GIT,PULL] KVM/arm64 updates for v6.4

Message ID 20230421104005.3017731-1-maz@kernel.org
State New
Headers show
Series [GIT,PULL] KVM/arm64 updates for v6.4 | expand

Pull-request

git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvmarm-6.4

Message

Marc Zyngier April 21, 2023, 10:40 a.m. UTC
Hi Paolo,

Here's the initial set of changes for KVM/arm64. A bunch of
infrastructure changes this time around, with two new user
visible changes (hypercall forwarding to userspace, global counter
offset) and a large set of locking inversion fixes.

The remaining of the patches contain the NV timer emulation code, and
a small set of less important fixes/improvements.

Please pull,

       M.

The following changes since commit 197b6b60ae7bc51dd0814953c562833143b292aa:

  Linux 6.3-rc4 (2023-03-26 14:40:20 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvmarm-6.4

for you to fetch changes up to 36fe1b29b3cae48f781011abd5a0b9e938f5b35f:

  Merge branch kvm-arm64/spec-ptw into kvmarm-master/next (2023-04-21 09:44:58 +0100)

----------------------------------------------------------------
KVM/arm64 updates for 6.4

- Numerous fixes for the pathological lock inversion issue that
  plagued KVM/arm64 since... forever.

- New framework allowing SMCCC-compliant hypercalls to be forwarded
  to userspace, hopefully paving the way for some more features
  being moved to VMMs rather than be implemented in the kernel.

- Large rework of the timer code to allow a VM-wide offset to be
  applied to both virtual and physical counters as well as a
  per-timer, per-vcpu offset that complements the global one.
  This last part allows the NV timer code to be implemented on
  top.

- A small set of fixes to make sure that we don't change anything
  affecting the EL1&0 translation regime just after having having
  taken an exception to EL2 until we have executed a DSB. This
  ensures that speculative walks started in EL1&0 have completed.

- The usual selftest fixes and improvements.

----------------------------------------------------------------
Colin Ian King (1):
      KVM: selftests: Fix spelling mistake "KVM_HYPERCAL_EXIT_SMC" -> "KVM_HYPERCALL_EXIT_SMC"

Marc Zyngier (33):
      KVM: arm64: timers: Use a per-vcpu, per-timer accumulator for fractional ns
      arm64: Add CNTPOFF_EL2 register definition
      arm64: Add HAS_ECV_CNTPOFF capability
      KVM: arm64: timers: Use CNTPOFF_EL2 to offset the physical timer
      KVM: arm64: timers: Allow physical offset without CNTPOFF_EL2
      KVM: arm64: Expose {un,}lock_all_vcpus() to the rest of KVM
      KVM: arm64: timers: Allow userspace to set the global counter offset
      KVM: arm64: timers: Allow save/restoring of the physical timer
      KVM: arm64: timers: Rationalise per-vcpu timer init
      KVM: arm64: timers: Abstract per-timer IRQ access
      KVM: arm64: timers: Move the timer IRQs into arch_timer_vm_data
      KVM: arm64: Elide kern_hyp_va() in VHE-specific parts of the hypervisor
      KVM: arm64: timers: Fast-track CNTPCT_EL0 trap handling
      KVM: arm64: timers: Abstract the number of valid timers per vcpu
      KVM: arm64: Document KVM_ARM_SET_CNT_OFFSETS and co
      KVM: arm64: nv: timers: Add a per-timer, per-vcpu offset
      KVM: arm64: nv: timers: Support hyp timer emulation
      KVM: arm64: selftests: Add physical timer registers to the sysreg list
      KVM: arm64: selftests: Deal with spurious timer interrupts
      KVM: arm64: selftests: Augment existing timer test to handle variable offset
      KVM: arm64: Expose SMC/HVC width to userspace
      KVM: arm64: nvhe: Synchronise with page table walker on vcpu run
      KVM: arm64: Handle 32bit CNTPCTSS traps
      KVM: arm64: nvhe: Synchronise with page table walker on TLBI
      KVM: arm64: pkvm: Document the side effects of kvm_flush_dcache_to_poc()
      KVM: arm64: vhe: Synchronise with page table walker on MMU update
      KVM: arm64: vhe: Drop extra isb() on guest exit
      Merge branch kvm-arm64/lock-inversion into kvmarm-master/next
      Merge branch kvm-arm64/timer-vm-offsets into kvmarm-master/next
      Merge branch kvm-arm64/selftest/lpa into kvmarm-master/next
      Merge branch kvm-arm64/selftest/misc-6.4 into kvmarm-master/next
      Merge branch kvm-arm64/smccc-filtering into kvmarm-master/next
      Merge branch kvm-arm64/spec-ptw into kvmarm-master/next

Mark Brown (1):
      KVM: selftests: Comment newly defined aarch64 ID registers

Oliver Upton (20):
      KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON
      KVM: arm64: Avoid lock inversion when setting the VM register width
      KVM: arm64: Use config_lock to protect data ordered against KVM_RUN
      KVM: arm64: Use config_lock to protect vgic state
      KVM: x86: Redefine 'longmode' as a flag for KVM_EXIT_HYPERCALL
      KVM: arm64: Add a helper to check if a VM has ran once
      KVM: arm64: Add vm fd device attribute accessors
      KVM: arm64: Rename SMC/HVC call handler to reflect reality
      KVM: arm64: Start handling SMCs from EL1
      KVM: arm64: Refactor hvc filtering to support different actions
      KVM: arm64: Use a maple tree to represent the SMCCC filter
      KVM: arm64: Add support for KVM_EXIT_HYPERCALL
      KVM: arm64: Introduce support for userspace SMCCC filtering
      KVM: arm64: Return NOT_SUPPORTED to guest for unknown PSCI version
      KVM: arm64: Let errors from SMCCC emulation to reach userspace
      KVM: selftests: Add a helper for SMCCC calls with SMC instruction
      KVM: selftests: Add test for SMCCC filter
      KVM: arm64: Prevent userspace from handling SMC64 arch range
      KVM: arm64: Test that SMC64 arch calls are reserved
      KVM: arm64: vgic: Don't acquire its_lock before config_lock

Reiji Watanabe (2):
      KVM: arm64: Acquire mp_state_lock in kvm_arch_vcpu_ioctl_vcpu_init()
      KVM: arm64: Have kvm_psci_vcpu_on() use WRITE_ONCE() to update mp_state

Ryan Roberts (3):
      KVM: selftests: Fixup config fragment for access_tracking_perf_test
      KVM: selftests: arm64: Fix pte encode/decode for PA bits > 48
      KVM: selftests: arm64: Fix ttbr0_el1 encoding for PA bits > 48

 Documentation/virt/kvm/api.rst                     |  71 ++-
 Documentation/virt/kvm/devices/vm.rst              |  79 +++
 arch/arm64/include/asm/kvm_host.h                  |  25 +-
 arch/arm64/include/asm/kvm_mmu.h                   |   4 +
 arch/arm64/include/asm/sysreg.h                    |   3 +
 arch/arm64/include/uapi/asm/kvm.h                  |  36 ++
 arch/arm64/kernel/cpufeature.c                     |  11 +
 arch/arm64/kvm/arch_timer.c                        | 550 ++++++++++++++++-----
 arch/arm64/kvm/arm.c                               | 147 +++++-
 arch/arm64/kvm/guest.c                             |  31 +-
 arch/arm64/kvm/handle_exit.c                       |  36 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h            |  53 ++
 arch/arm64/kvm/hyp/nvhe/debug-sr.c                 |   2 -
 arch/arm64/kvm/hyp/nvhe/mem_protect.c              |   7 +
 arch/arm64/kvm/hyp/nvhe/switch.c                   |  18 +
 arch/arm64/kvm/hyp/nvhe/timer-sr.c                 |  18 +-
 arch/arm64/kvm/hyp/nvhe/tlb.c                      |  38 +-
 arch/arm64/kvm/hyp/vhe/switch.c                    |   7 +-
 arch/arm64/kvm/hyp/vhe/sysreg-sr.c                 |  12 +
 arch/arm64/kvm/hypercalls.c                        | 189 ++++++-
 arch/arm64/kvm/pmu-emul.c                          |  25 +-
 arch/arm64/kvm/psci.c                              |  37 +-
 arch/arm64/kvm/reset.c                             |  15 +-
 arch/arm64/kvm/sys_regs.c                          |  10 +
 arch/arm64/kvm/trace_arm.h                         |   6 +-
 arch/arm64/kvm/vgic/vgic-debug.c                   |   8 +-
 arch/arm64/kvm/vgic/vgic-init.c                    |  36 +-
 arch/arm64/kvm/vgic/vgic-its.c                     |  33 +-
 arch/arm64/kvm/vgic/vgic-kvm-device.c              |  85 ++--
 arch/arm64/kvm/vgic/vgic-mmio-v3.c                 |   4 +-
 arch/arm64/kvm/vgic/vgic-mmio.c                    |  12 +-
 arch/arm64/kvm/vgic/vgic-v4.c                      |  11 +-
 arch/arm64/kvm/vgic/vgic.c                         |  27 +-
 arch/arm64/kvm/vgic/vgic.h                         |   3 -
 arch/arm64/tools/cpucaps                           |   1 +
 arch/arm64/tools/sysreg                            |   4 +
 arch/x86/include/asm/kvm_host.h                    |   7 +
 arch/x86/include/uapi/asm/kvm.h                    |   3 +
 arch/x86/kvm/x86.c                                 |   6 +-
 include/clocksource/arm_arch_timer.h               |   1 +
 include/kvm/arm_arch_timer.h                       |  34 +-
 include/kvm/arm_hypercalls.h                       |   6 +-
 include/kvm/arm_vgic.h                             |   1 +
 include/uapi/linux/kvm.h                           |  12 +-
 tools/testing/selftests/kvm/Makefile               |   1 +
 tools/testing/selftests/kvm/aarch64/arch_timer.c   |  56 ++-
 tools/testing/selftests/kvm/aarch64/get-reg-list.c |  15 +-
 tools/testing/selftests/kvm/aarch64/smccc_filter.c | 268 ++++++++++
 tools/testing/selftests/kvm/config                 |   1 +
 .../selftests/kvm/include/aarch64/processor.h      |  13 +
 .../testing/selftests/kvm/lib/aarch64/processor.c  |  91 ++--
 51 files changed, 1759 insertions(+), 410 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/smccc_filter.c

Comments

Paolo Bonzini April 26, 2023, 7:46 p.m. UTC | #1
On Fri, Apr 21, 2023 at 12:40 PM Marc Zyngier <maz@kernel.org> wrote:
>
> Hi Paolo,
>
> Here's the initial set of changes for KVM/arm64. A bunch of
> infrastructure changes this time around, with two new user
> visible changes (hypercall forwarding to userspace, global counter
> offset) and a large set of locking inversion fixes.
>
> The remaining of the patches contain the NV timer emulation code, and
> a small set of less important fixes/improvements.
>
> Please pull,

Queued, thanks!  I assume I'll get -rc pull requests from you as well
over the next two months?

Paolo

>        M.
>
> The following changes since commit 197b6b60ae7bc51dd0814953c562833143b292aa:
>
>   Linux 6.3-rc4 (2023-03-26 14:40:20 -0700)
>
> are available in the Git repository at:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvmarm-6.4
>
> for you to fetch changes up to 36fe1b29b3cae48f781011abd5a0b9e938f5b35f:
>
>   Merge branch kvm-arm64/spec-ptw into kvmarm-master/next (2023-04-21 09:44:58 +0100)
>
> ----------------------------------------------------------------
> KVM/arm64 updates for 6.4
>
> - Numerous fixes for the pathological lock inversion issue that
>   plagued KVM/arm64 since... forever.
>
> - New framework allowing SMCCC-compliant hypercalls to be forwarded
>   to userspace, hopefully paving the way for some more features
>   being moved to VMMs rather than be implemented in the kernel.
>
> - Large rework of the timer code to allow a VM-wide offset to be
>   applied to both virtual and physical counters as well as a
>   per-timer, per-vcpu offset that complements the global one.
>   This last part allows the NV timer code to be implemented on
>   top.
>
> - A small set of fixes to make sure that we don't change anything
>   affecting the EL1&0 translation regime just after having having
>   taken an exception to EL2 until we have executed a DSB. This
>   ensures that speculative walks started in EL1&0 have completed.
>
> - The usual selftest fixes and improvements.
>
> ----------------------------------------------------------------
> Colin Ian King (1):
>       KVM: selftests: Fix spelling mistake "KVM_HYPERCAL_EXIT_SMC" -> "KVM_HYPERCALL_EXIT_SMC"
>
> Marc Zyngier (33):
>       KVM: arm64: timers: Use a per-vcpu, per-timer accumulator for fractional ns
>       arm64: Add CNTPOFF_EL2 register definition
>       arm64: Add HAS_ECV_CNTPOFF capability
>       KVM: arm64: timers: Use CNTPOFF_EL2 to offset the physical timer
>       KVM: arm64: timers: Allow physical offset without CNTPOFF_EL2
>       KVM: arm64: Expose {un,}lock_all_vcpus() to the rest of KVM
>       KVM: arm64: timers: Allow userspace to set the global counter offset
>       KVM: arm64: timers: Allow save/restoring of the physical timer
>       KVM: arm64: timers: Rationalise per-vcpu timer init
>       KVM: arm64: timers: Abstract per-timer IRQ access
>       KVM: arm64: timers: Move the timer IRQs into arch_timer_vm_data
>       KVM: arm64: Elide kern_hyp_va() in VHE-specific parts of the hypervisor
>       KVM: arm64: timers: Fast-track CNTPCT_EL0 trap handling
>       KVM: arm64: timers: Abstract the number of valid timers per vcpu
>       KVM: arm64: Document KVM_ARM_SET_CNT_OFFSETS and co
>       KVM: arm64: nv: timers: Add a per-timer, per-vcpu offset
>       KVM: arm64: nv: timers: Support hyp timer emulation
>       KVM: arm64: selftests: Add physical timer registers to the sysreg list
>       KVM: arm64: selftests: Deal with spurious timer interrupts
>       KVM: arm64: selftests: Augment existing timer test to handle variable offset
>       KVM: arm64: Expose SMC/HVC width to userspace
>       KVM: arm64: nvhe: Synchronise with page table walker on vcpu run
>       KVM: arm64: Handle 32bit CNTPCTSS traps
>       KVM: arm64: nvhe: Synchronise with page table walker on TLBI
>       KVM: arm64: pkvm: Document the side effects of kvm_flush_dcache_to_poc()
>       KVM: arm64: vhe: Synchronise with page table walker on MMU update
>       KVM: arm64: vhe: Drop extra isb() on guest exit
>       Merge branch kvm-arm64/lock-inversion into kvmarm-master/next
>       Merge branch kvm-arm64/timer-vm-offsets into kvmarm-master/next
>       Merge branch kvm-arm64/selftest/lpa into kvmarm-master/next
>       Merge branch kvm-arm64/selftest/misc-6.4 into kvmarm-master/next
>       Merge branch kvm-arm64/smccc-filtering into kvmarm-master/next
>       Merge branch kvm-arm64/spec-ptw into kvmarm-master/next
>
> Mark Brown (1):
>       KVM: selftests: Comment newly defined aarch64 ID registers
>
> Oliver Upton (20):
>       KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON
>       KVM: arm64: Avoid lock inversion when setting the VM register width
>       KVM: arm64: Use config_lock to protect data ordered against KVM_RUN
>       KVM: arm64: Use config_lock to protect vgic state
>       KVM: x86: Redefine 'longmode' as a flag for KVM_EXIT_HYPERCALL
>       KVM: arm64: Add a helper to check if a VM has ran once
>       KVM: arm64: Add vm fd device attribute accessors
>       KVM: arm64: Rename SMC/HVC call handler to reflect reality
>       KVM: arm64: Start handling SMCs from EL1
>       KVM: arm64: Refactor hvc filtering to support different actions
>       KVM: arm64: Use a maple tree to represent the SMCCC filter
>       KVM: arm64: Add support for KVM_EXIT_HYPERCALL
>       KVM: arm64: Introduce support for userspace SMCCC filtering
>       KVM: arm64: Return NOT_SUPPORTED to guest for unknown PSCI version
>       KVM: arm64: Let errors from SMCCC emulation to reach userspace
>       KVM: selftests: Add a helper for SMCCC calls with SMC instruction
>       KVM: selftests: Add test for SMCCC filter
>       KVM: arm64: Prevent userspace from handling SMC64 arch range
>       KVM: arm64: Test that SMC64 arch calls are reserved
>       KVM: arm64: vgic: Don't acquire its_lock before config_lock
>
> Reiji Watanabe (2):
>       KVM: arm64: Acquire mp_state_lock in kvm_arch_vcpu_ioctl_vcpu_init()
>       KVM: arm64: Have kvm_psci_vcpu_on() use WRITE_ONCE() to update mp_state
>
> Ryan Roberts (3):
>       KVM: selftests: Fixup config fragment for access_tracking_perf_test
>       KVM: selftests: arm64: Fix pte encode/decode for PA bits > 48
>       KVM: selftests: arm64: Fix ttbr0_el1 encoding for PA bits > 48
>
>  Documentation/virt/kvm/api.rst                     |  71 ++-
>  Documentation/virt/kvm/devices/vm.rst              |  79 +++
>  arch/arm64/include/asm/kvm_host.h                  |  25 +-
>  arch/arm64/include/asm/kvm_mmu.h                   |   4 +
>  arch/arm64/include/asm/sysreg.h                    |   3 +
>  arch/arm64/include/uapi/asm/kvm.h                  |  36 ++
>  arch/arm64/kernel/cpufeature.c                     |  11 +
>  arch/arm64/kvm/arch_timer.c                        | 550 ++++++++++++++++-----
>  arch/arm64/kvm/arm.c                               | 147 +++++-
>  arch/arm64/kvm/guest.c                             |  31 +-
>  arch/arm64/kvm/handle_exit.c                       |  36 +-
>  arch/arm64/kvm/hyp/include/hyp/switch.h            |  53 ++
>  arch/arm64/kvm/hyp/nvhe/debug-sr.c                 |   2 -
>  arch/arm64/kvm/hyp/nvhe/mem_protect.c              |   7 +
>  arch/arm64/kvm/hyp/nvhe/switch.c                   |  18 +
>  arch/arm64/kvm/hyp/nvhe/timer-sr.c                 |  18 +-
>  arch/arm64/kvm/hyp/nvhe/tlb.c                      |  38 +-
>  arch/arm64/kvm/hyp/vhe/switch.c                    |   7 +-
>  arch/arm64/kvm/hyp/vhe/sysreg-sr.c                 |  12 +
>  arch/arm64/kvm/hypercalls.c                        | 189 ++++++-
>  arch/arm64/kvm/pmu-emul.c                          |  25 +-
>  arch/arm64/kvm/psci.c                              |  37 +-
>  arch/arm64/kvm/reset.c                             |  15 +-
>  arch/arm64/kvm/sys_regs.c                          |  10 +
>  arch/arm64/kvm/trace_arm.h                         |   6 +-
>  arch/arm64/kvm/vgic/vgic-debug.c                   |   8 +-
>  arch/arm64/kvm/vgic/vgic-init.c                    |  36 +-
>  arch/arm64/kvm/vgic/vgic-its.c                     |  33 +-
>  arch/arm64/kvm/vgic/vgic-kvm-device.c              |  85 ++--
>  arch/arm64/kvm/vgic/vgic-mmio-v3.c                 |   4 +-
>  arch/arm64/kvm/vgic/vgic-mmio.c                    |  12 +-
>  arch/arm64/kvm/vgic/vgic-v4.c                      |  11 +-
>  arch/arm64/kvm/vgic/vgic.c                         |  27 +-
>  arch/arm64/kvm/vgic/vgic.h                         |   3 -
>  arch/arm64/tools/cpucaps                           |   1 +
>  arch/arm64/tools/sysreg                            |   4 +
>  arch/x86/include/asm/kvm_host.h                    |   7 +
>  arch/x86/include/uapi/asm/kvm.h                    |   3 +
>  arch/x86/kvm/x86.c                                 |   6 +-
>  include/clocksource/arm_arch_timer.h               |   1 +
>  include/kvm/arm_arch_timer.h                       |  34 +-
>  include/kvm/arm_hypercalls.h                       |   6 +-
>  include/kvm/arm_vgic.h                             |   1 +
>  include/uapi/linux/kvm.h                           |  12 +-
>  tools/testing/selftests/kvm/Makefile               |   1 +
>  tools/testing/selftests/kvm/aarch64/arch_timer.c   |  56 ++-
>  tools/testing/selftests/kvm/aarch64/get-reg-list.c |  15 +-
>  tools/testing/selftests/kvm/aarch64/smccc_filter.c | 268 ++++++++++
>  tools/testing/selftests/kvm/config                 |   1 +
>  .../selftests/kvm/include/aarch64/processor.h      |  13 +
>  .../testing/selftests/kvm/lib/aarch64/processor.c  |  91 ++--
>  51 files changed, 1759 insertions(+), 410 deletions(-)
>  create mode 100644 tools/testing/selftests/kvm/aarch64/smccc_filter.c
>
Marc Zyngier April 26, 2023, 9:24 p.m. UTC | #2
On Wed, 26 Apr 2023 20:46:26 +0100,
Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On Fri, Apr 21, 2023 at 12:40 PM Marc Zyngier <maz@kernel.org> wrote:
> >
> > Hi Paolo,
> >
> > Here's the initial set of changes for KVM/arm64. A bunch of
> > infrastructure changes this time around, with two new user
> > visible changes (hypercall forwarding to userspace, global counter
> > offset) and a large set of locking inversion fixes.
> >
> > The remaining of the patches contain the NV timer emulation code, and
> > a small set of less important fixes/improvements.
> >
> > Please pull,
> 
> Queued, thanks!  I assume I'll get -rc pull requests from you as well
> over the next two months?

That's the plan, yes.

We aim to mimic what arm64 does by taking turn in maintaining the tree
for a given kernel version (initial drop + fixes), unless something
crops up. This means that while I'm dealing with fixes for 6.4, Oliver
can queue 6.5 material in parallel.

Which is why you have seen a late 6.3 PR for fixes and a 6.4 PR for
new feature basically at the same time.

	M.