Skip to content

Userspace timer IRQ number control and PMU with userspace-gic

Christoffer Dall kvm kvmarm linux-arm-kernel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest9 patches 9 repliesIn review
  2. v29 patches 10 repliesSuperseded
  3. v15 patches 15 repliesSuperseded

Changes in v3 from the cover letter

- Grammer change
- Move PMU irq consistency check to when we are about to run a VCPU, ensuring that we do not allow an unconfigure irq line with an in-kernel gic.
- Rebased on kvmarm/queue.
- Acked reviewed-by and acked-by from Marc on some patches

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9KVM: arm64: Allow creating the PMU without the in-kernel GICDocumentation/virtual/kvm/devices/vcpu.txt include/kvm/arm_pmu.h virt/kvm/arm/arm.c +1 more+58 -191 reply
2/9KVM: arm: Handle VCPU device attributes in guest.carch/arm/include/asm/kvm_host.h arch/arm/kvm/guest.c+49 -150 replies
3/9KVM: arm/arm64: Move irq_is_ppi() to header fileinclude/kvm/arm_vgic.h virt/kvm/arm/pmu.c+2 -20 replies
4/9KVM: arm/arm64: Move timer IRQ default init to arch_timer.carch/arm/kvm/reset.c arch/arm64/kvm/reset.c include/kvm/arm_arch_timer.h +1 more+19 -450 replies
5/9KVM: arm/arm64: Allow setting the timer IRQ numbers from userspaceDocumentation/virtual/kvm/devices/vcpu.txt arch/arm/include/uapi/asm/kvm.h arch/arm/kvm/guest.c +4 more+162 -00 replies
6/9KVM: arm/arm64: Introduce an allocator for in-kernel irq linesinclude/kvm/arm_vgic.h virt/kvm/arm/vgic/vgic.c+38 -03 replies
7/9KVM: arm/arm64: Check if irq lines to the GIC are already usedvirt/kvm/arm/arch_timer.c virt/kvm/arm/pmu.c+17 -81 reply
8/9KVM: arm/arm64: Disallow userspace control of in-kernel IRQ linesinclude/kvm/arm_vgic.h virt/kvm/arm/arch_timer.c virt/kvm/arm/arm.c +3 more+19 -121 reply
9/9KVM: arm/arm64: Don't assume initialized vgic when setting PMU IRQinclude/kvm/arm_vgic.h virt/kvm/arm/pmu.c+3 -13 replies

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by.

PatchMarc Zyngier
1/9R-b
2/9A-b
3/9A-b
4/9R-b
5/9R-b
6/9A-b
7/9R-b
8/9A-b
9/9R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/9] Userspace timer IRQ number control and PMU with userspace-gic

So far we have been getting away with letting the kernel choosing interrupt numbers for the timers in the kernel and we have crossed our fingers in hoping that the DT/ACPI provided by userspace matches with the interrupt number we use in the kernel for a given VCPU type.

But as we are generally moving towards letting userspace be in more fine grained control of what is being emulated, let userspace decide the irq numbers for the timers.

Slightly related, and therefore included in this series, we have recently added support for a userspace GIC while still supporting the generic timers and the PMU from inside the VM. Unfortunately we forgot to rework the code to actually let userspace create the PMU device without creating an in-kernel GIC.

Patches 6-9 could be omitted and still support the basic functionality targeted by this series if preferred.

Tested on APM X-Gene, Thunder-X, and TC2.

QEMU patches used for testing can be found here:

https://git.linaro.org/people/christoffer.dall/qemu-arm.git timer-pmu-irqs

Changes since v2:
- Grammer change
- Move PMU irq consistency check to when we are about to run a VCPU, ensuring that we do not allow an unconfigure irq line with an in-kernel gic.
- Rebased on kvmarm/queue.
- Acked reviewed-by and acked-by from Marc on some patches

Changes since v1:
- Rebased on v4.12-rc1
- Check for irqchip_in_kernel() in kvm_arm_pmu_v3_get_attr
- Slightly change the wording around default timer IRQs
- Add fix for the PMU IRQ setting that assumes an initialized vgic
- Introduce an allocator for IRQ lines so that in-kernel owned IRQ lines cannot be signalled from userspace and such that an IRQ line can only be assigned to a single device.

Christoffer Dall (9):
KVM: arm64: Allow creating the PMU without the in-kernel GIC
KVM: arm: Handle VCPU device attributes in guest.c
KVM: arm/arm64: Move irq_is_ppi() to header file
KVM: arm/arm64: Move timer IRQ default init to arch_timer.c
KVM: arm/arm64: Allow setting the timer IRQ numbers from userspace
KVM: arm/arm64: Introduce an allocator for in-kernel irq lines
KVM: arm/arm64: Check if irq lines to the GIC are already used
KVM: arm/arm64: Disallow userspace control of in-kernel IRQ lines
KVM: arm/arm64: Don't assume initialized vgic when setting PMU IRQ

 Documentation/virtual/kvm/devices/vcpu.txt |  41 +++++++--
 arch/arm/include/asm/kvm_host.h            |  22 ++---
 arch/arm/include/uapi/asm/kvm.h            |   8 ++
 arch/arm/kvm/guest.c                       |  51 +++++++++++
 arch/arm/kvm/reset.c                       |  16 +---
 arch/arm64/include/uapi/asm/kvm.h          |   3 +
 arch/arm64/kvm/guest.c                     |   9 ++
 arch/arm64/kvm/reset.c                     |  16 +---
 include/kvm/arm_arch_timer.h               |   8 +-
 include/kvm/arm_pmu.h                      |   6 ++
 include/kvm/arm_vgic.h                     |  13 ++-
 virt/kvm/arm/arch_timer.c                  | 137 ++++++++++++++++++++++++++---
 virt/kvm/arm/arm.c                         |   8 +-
 virt/kvm/arm/pmu.c                         |  65 ++++++++++----
 virt/kvm/arm/vgic/vgic-irqfd.c             |   2 +-
 virt/kvm/arm/vgic/vgic.c                   |  48 +++++++++-
 16 files changed, 359 insertions(+), 94 deletions(-)
Signature · 1 line
2.9.0