Skip to content

KVM: arm64: ARMv8.3/8.4 Nested Virtualization support

Marc Zyngier kvm kvmarm linux-arm-kernel 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v10 Latest59 patches 35 repliesIn review
  2. v950 patches 1 replySuperseded
  3. v869 patches 15 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v768 patches0 repliesSuperseded
v664 patches61 repliesSuperseded
v569 patches69 repliesApplied
v466 patches10 repliesSuperseded
v366 patches17 repliesSuperseded
v294 patches9 repliesSuperseded

Patches in v10 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/59KVM: arm64: Move VTCR_EL2 into struct s2_mmuarch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_mmu.h arch/arm64/include/asm/stage2_pgtable.h +6 more+33 -240 replies
2/59arm64: Add missing Set/Way CMO encodingsarch/arm64/include/asm/sysreg.h+6 -00 replies
3/59arm64: Add missing VA CMO encodingsarch/arm64/include/asm/sysreg.h+26 -01 reply
4/59arm64: Add missing ERXMISCx_EL1 encodingsarch/arm64/include/asm/sysreg.h+2 -01 reply
5/59arm64: Add missing DC ZVA/GVA/GZVA encodingsarch/arm64/include/asm/sysreg.h+5 -01 reply
6/59arm64: Add TLBI operation encodingsarch/arm64/include/asm/sysreg.h+128 -01 reply
7/59arm64: Add AT operation encodingsarch/arm64/include/asm/sysreg.h+17 -01 reply
8/59KVM: arm64: Add missing HCR_EL2 trap bitsarch/arm64/include/asm/kvm_arm.h+10 -01 reply
9/59KVM: arm64: nv: Add trap forwarding infrastructurearch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/emulate-nested.c +2 more+203 -02 replies
10/59KVM: arm64: nv: Add trap forwarding for HCR_EL2arch/arm64/kvm/emulate-nested.c+472 -00 replies
11/59KVM: arm64: nv: Expose FEAT_EVT to nested guestsarch/arm64/kvm/nested.c+1 -20 replies
12/59KVM: arm64: nv: Add trap forwarding for MDCR_EL2arch/arm64/kvm/emulate-nested.c+204 -00 replies
13/59KVM: arm64: nv: Add trap forwarding for CNTHCTL_EL2arch/arm64/kvm/emulate-nested.c+36 -10 replies
14/59KVM: arm64: nv: Add non-VHE-EL2->EL1 translation helpersarch/arm64/include/asm/kvm_nested.h+48 -00 replies
15/59KVM: arm64: nv: Handle virtual EL2 registers in vcpu_read/write_sys_reg()arch/arm64/kvm/sys_regs.c+138 -50 replies
16/59KVM: arm64: nv: Handle SPSR_EL2 speciallyarch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/sys_regs.c+58 -20 replies
17/59KVM: arm64: nv: Handle HCR_EL2.E2H speciallyarch/arm64/kvm/sys_regs.c+20 -00 replies
18/59KVM: arm64: nv: Save/Restore vEL2 sysregsarch/arm64/kvm/hyp/include/hyp/sysreg-sr.h arch/arm64/kvm/hyp/nvhe/sysreg-sr.c arch/arm64/kvm/hyp/vhe/sysreg-sr.c+126 -50 replies
19/59KVM: arm64: nv: Trap EL1 VM register accesses in virtual EL2arch/arm64/kvm/hyp/include/hyp/switch.h arch/arm64/kvm/hyp/nvhe/switch.c arch/arm64/kvm/hyp/vhe/switch.c +1 more+24 -80 replies
20/59KVM: arm64: nv: Trap CPACR_EL1 access in virtual EL2arch/arm64/kvm/hyp/vhe/switch.c arch/arm64/kvm/sys_regs.c+4 -10 replies
21/59KVM: arm64: nv: Respect virtual HCR_EL2.TWX settingarch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/handle_exit.c+19 -10 replies
22/59KVM: arm64: nv: Respect virtual CPTR_EL2.{TFP,FPEN} settingsarch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/handle_exit.c arch/arm64/kvm/hyp/include/hyp/switch.h+41 -40 replies
23/59KVM: arm64: nv: Respect virtual HCR_EL2.{NV,TSC) settingsarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/emulate-nested.c arch/arm64/kvm/handle_exit.c+35 -00 replies
24/59KVM: arm64: nv: Configure HCR_EL2 for nested virtualizationarch/arm64/include/asm/kvm_arm.h arch/arm64/kvm/hyp/vhe/switch.c+36 -30 replies
25/59KVM: arm64: nv: Support multiple nested Stage-2 mmu structuresarch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_mmu.h arch/arm64/include/asm/kvm_nested.h +4 more+345 -240 replies
26/59KVM: arm64: nv: Implement nested Stage-2 page table walk logicarch/arm64/include/asm/esr.h arch/arm64/include/asm/kvm_arm.h arch/arm64/include/asm/kvm_nested.h +1 more+283 -00 replies
27/59KVM: arm64: nv: Handle shadow stage 2 page faultsarch/arm64/include/asm/kvm_emulate.h arch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c +1 more+152 -100 replies
28/59KVM: arm64: nv: Restrict S2 RD/WR permissions to match the guest'sarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c arch/arm64/kvm/nested.c+29 -20 replies
29/59KVM: arm64: nv: Unmap/flush shadow stage 2 page tablesarch/arm64/include/asm/kvm_mmu.h arch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c +1 more+70 -52 replies
30/59KVM: arm64: nv: Set a handler for the system instruction trapsarch/arm64/kvm/sys_regs.c+38 -90 replies
31/59KVM: arm64: nv: Trap and emulate AT instructions from virtual EL2arch/arm64/include/asm/kvm_arm.h arch/arm64/include/asm/kvm_asm.h arch/arm64/kvm/Makefile +3 more+451 -30 replies
32/59KVM: arm64: nv: Trap and emulate TLBI instructions from virtual EL2arch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_nested.h arch/arm64/include/asm/sysreg.h +5 more+387 -50 replies
33/59KVM: arm64: nv: Fold guest's HCR_EL2 configuration into the host'sarch/arm64/kvm/hyp/vhe/switch.c+5 -00 replies
34/59KVM: arm64: nv: Hide RAS from nested guestsarch/arm64/kvm/sys_regs.c+1 -00 replies
35/59KVM: arm64: nv: Add handling of EL2-specific timer registersarch/arm64/include/asm/sysreg.h arch/arm64/kvm/sys_regs.c+108 -10 replies
36/59KVM: arm64: nv: Load timer before the GICarch/arm64/kvm/arm.c+1 -10 replies
37/59KVM: arm64: nv: Nested GICv3 Supportarch/arm64/include/asm/kvm_emulate.h arch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_nested.h +8 more+455 -110 replies
38/59KVM: arm64: nv: Don't load the GICv4 context on entering a nested guestarch/arm64/kvm/vgic/vgic-v3.c+8 -20 replies
39/59KVM: arm64: nv: vgic: Emulate the HW bit in softwarearch/arm64/include/asm/kvm_hyp.h arch/arm64/kvm/hyp/vgic-v3-sr.c arch/arm64/kvm/vgic/vgic-v3-nested.c +2 more+40 -30 replies
40/59KVM: arm64: nv: vgic: Allow userland to set VGIC maintenance IRQDocumentation/virt/kvm/devices/arm-vgic-v3.rst arch/arm64/include/uapi/asm/kvm.h arch/arm64/kvm/vgic/vgic-kvm-device.c +2 more+43 -30 replies
41/59KVM: arm64: nv: Implement maintenance interrupt forwardingarch/arm64/kvm/vgic/vgic-init.c arch/arm64/kvm/vgic/vgic-v3-nested.c+55 -60 replies
42/59KVM: arm64: nv: Deal with broken VGIC on maintenance interrupt deliveryarch/arm64/kvm/vgic/vgic-v3-nested.c+3 -00 replies
43/59KVM: arm64: nv: Allow userspace to request KVM_ARM_VCPU_NESTED_VIRTarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c include/uapi/linux/kvm.h+5 -10 replies
44/59KVM: arm64: nv: Add handling of FEAT_TTL TLB invalidationarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/nested.c arch/arm64/kvm/sys_regs.c+93 -250 replies
45/59KVM: arm64: nv: Invalidate TLBs based on shadow S2 TTL-like informationarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/nested.c+83 -00 replies
46/59KVM: arm64: nv: Tag shadow S2 entries with nested levelarch/arm64/include/asm/kvm_nested.h arch/arm64/kvm/mmu.c+21 -20 replies
47/59KVM: arm64: nv: Add include containing the VNCR_EL2 offsetsarch/arm64/include/asm/vncr_mapping.h+74 -00 replies
48/59KVM: arm64: nv: Map VNCR-capable registers to a separate pagearch/arm64/include/asm/kvm_host.h arch/arm64/tools/cpucaps+70 -350 replies
49/59KVM: arm64: nv: Move nested vgic state into the sysreg filearch/arm64/include/asm/kvm_host.h arch/arm64/kvm/sys_regs.c arch/arm64/kvm/vgic/vgic-v3-nested.c +3 more+104 -690 replies
50/59KVM: arm64: Add FEAT_NV2 cpu featurearch/arm64/include/asm/kvm_nested.h arch/arm64/kernel/cpufeature.c+17 -00 replies
51/59KVM: arm64: nv: Sync nested timer state with FEAT_NV2arch/arm64/kvm/arch_timer.c arch/arm64/kvm/arm.c include/kvm/arm_arch_timer.h+48 -00 replies
52/59KVM: arm64: nv: Fold GICv3 host trapping requirements into guest setuparch/arm64/kvm/hyp/vgic-v3-sr.c arch/arm64/kvm/vgic/vgic-v3-nested.c+20 -50 replies
53/59KVM: arm64: nv: Publish emulated timer interrupt state in the in-memory statearch/arm64/kvm/arch_timer.c+19 -00 replies
54/59KVM: arm64: nv: Allocate VNCR page when requiredarch/arm64/kvm/nested.c arch/arm64/kvm/reset.c+11 -00 replies
55/59KVM: arm64: nv: Enable ARMv8.4-NV supportarch/arm64/include/asm/kvm_emulate.h arch/arm64/include/asm/sysreg.h arch/arm64/kvm/hyp/vhe/switch.c+27 -110 replies
56/59KVM: arm64: nv: Fast-track 'InHost' exception returnsarch/arm64/kvm/emulate-nested.c arch/arm64/kvm/hyp/vhe/switch.c+49 -260 replies
57/59KVM: arm64: nv: Fast-track EL1 TLBIs for VHE guestsarch/arm64/kvm/hyp/vhe/switch.c arch/arm64/kvm/hyp/vhe/tlb.c arch/arm64/kvm/sys_regs.c+46 -150 replies
58/59KVM: arm64: nv: Use FEAT_ECV to trap access to EL0 timersarch/arm64/kvm/arch_timer.c include/clocksource/arm_arch_timer.h+38 -30 replies
59/59KVM: arm64: nv: Accelerate EL0 timer read accesses when FEAT_ECV is onarch/arm64/kvm/hyp/vhe/switch.c+49 -00 replies

Reviews trailers per patch

13 of 59 patches have a Reviewed-by or Acked-by.

PatchGanapatrao KulkarniAlexandru EliseiRussell King (Oracle)Eric Auger
1/59
2/59
3/59R-b
4/59R-b
5/59R-b
6/59R-b
7/59R-b
8/59R-b
9/59
10/59
11/59
12/59
13/59
14/59
15/59R-b R-b R-b
16/59R-b R-b
17/59R-b
18/59R-b
19/59R-b R-b
20/59R-b
21/59
22/59
23/59
24/59
25/59
26/59
27/59
28/59R-b
29/59
30/59
31/59
32/59
33/59
34/59
35/59
36/59
37/59
38/59
39/59
40/59
41/59
42/59
43/59
44/59
45/59
46/59
47/59
48/59
49/59
50/59
51/59
52/59
53/59
54/59
55/59
56/59
57/59
58/59
59/59

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v10 thread

Cover letter [PATCH v10 00/59] KVM: arm64: ARMv8.3/8.4 Nested Virtualization support

This is the 4th drop of NV support on arm64 for this year.

For the previous episodes, see [1].

What's changed:

- New framework to track system register traps that are reinjected in guest EL2. It is expected to replace the discrete handling we have enjoyed so far, which didn't scale at all. This has already fixed a number of bugs that were hidden (a bunch of traps were never forwarded...). Still a work in progress, but this is going in the right direction.

- Allow the L1 hypervisor to have a S2 that has an input larger than the L0 IPA space. This fixes a number of subtle issues, depending on how the initial guest was created.

- Consequently, the patch series has gone longer again. Boo. But hopefully some of it is easier to review...

[1] https://lore.kernel.org/r/[email protected]

Andre Przywara (1):
KVM: arm64: nv: vgic: Allow userland to set VGIC maintenance IRQ

Christoffer Dall (5):
KVM: arm64: nv: Trap EL1 VM register accesses in virtual EL2
KVM: arm64: nv: Implement nested Stage-2 page table walk logic
KVM: arm64: nv: Unmap/flush shadow stage 2 page tables
KVM: arm64: nv: vgic: Emulate the HW bit in software
KVM: arm64: nv: Sync nested timer state with FEAT_NV2

Jintack Lim (7):
KVM: arm64: nv: Trap CPACR_EL1 access in virtual EL2
KVM: arm64: nv: Respect virtual HCR_EL2.TWX setting
KVM: arm64: nv: Respect virtual CPTR_EL2.{TFP,FPEN} settings
KVM: arm64: nv: Respect virtual HCR_EL2.{NV,TSC) settings
KVM: arm64: nv: Configure HCR_EL2 for nested virtualization
KVM: arm64: nv: Trap and emulate TLBI instructions from virtual EL2
KVM: arm64: nv: Nested GICv3 Support

Marc Zyngier (46):
KVM: arm64: Move VTCR_EL2 into struct s2_mmu
arm64: Add missing Set/Way CMO encodings
arm64: Add missing VA CMO encodings
arm64: Add missing ERXMISCx_EL1 encodings
arm64: Add missing DC ZVA/GVA/GZVA encodings
arm64: Add TLBI operation encodings
arm64: Add AT operation encodings
KVM: arm64: Add missing HCR_EL2 trap bits
KVM: arm64: nv: Add trap forwarding infrastructure
KVM: arm64: nv: Add trap forwarding for HCR_EL2
KVM: arm64: nv: Expose FEAT_EVT to nested guests
KVM: arm64: nv: Add trap forwarding for MDCR_EL2
KVM: arm64: nv: Add trap forwarding for CNTHCTL_EL2
KVM: arm64: nv: Add non-VHE-EL2->EL1 translation helpers
KVM: arm64: nv: Handle virtual EL2 registers in
vcpu_read/write_sys_reg()
KVM: arm64: nv: Handle SPSR_EL2 specially
KVM: arm64: nv: Handle HCR_EL2.E2H specially
KVM: arm64: nv: Save/Restore vEL2 sysregs
KVM: arm64: nv: Support multiple nested Stage-2 mmu structures
KVM: arm64: nv: Handle shadow stage 2 page faults
KVM: arm64: nv: Restrict S2 RD/WR permissions to match the guest's
KVM: arm64: nv: Set a handler for the system instruction traps
KVM: arm64: nv: Trap and emulate AT instructions from virtual EL2
KVM: arm64: nv: Fold guest's HCR_EL2 configuration into the host's
KVM: arm64: nv: Hide RAS from nested guests
KVM: arm64: nv: Add handling of EL2-specific timer registers
KVM: arm64: nv: Load timer before the GIC
KVM: arm64: nv: Don't load the GICv4 context on entering a nested
guest
KVM: arm64: nv: Implement maintenance interrupt forwarding
KVM: arm64: nv: Deal with broken VGIC on maintenance interrupt
delivery
KVM: arm64: nv: Allow userspace to request KVM_ARM_VCPU_NESTED_VIRT
KVM: arm64: nv: Add handling of FEAT_TTL TLB invalidation
KVM: arm64: nv: Invalidate TLBs based on shadow S2 TTL-like
information
KVM: arm64: nv: Tag shadow S2 entries with nested level
KVM: arm64: nv: Add include containing the VNCR_EL2 offsets
KVM: arm64: nv: Map VNCR-capable registers to a separate page
KVM: arm64: nv: Move nested vgic state into the sysreg file
KVM: arm64: Add FEAT_NV2 cpu feature
KVM: arm64: nv: Fold GICv3 host trapping requirements into guest setup
KVM: arm64: nv: Publish emulated timer interrupt state in the
in-memory state
KVM: arm64: nv: Allocate VNCR page when required
KVM: arm64: nv: Enable ARMv8.4-NV support
KVM: arm64: nv: Fast-track 'InHost' exception returns
KVM: arm64: nv: Fast-track EL1 TLBIs for VHE guests
KVM: arm64: nv: Use FEAT_ECV to trap access to EL0 timers
KVM: arm64: nv: Accelerate EL0 timer read accesses when FEAT_ECV is on

 .../virt/kvm/devices/arm-vgic-v3.rst          |  12 +-
 arch/arm64/include/asm/esr.h                  |   1 +
 arch/arm64/include/asm/kvm_arm.h              |  14 +
 arch/arm64/include/asm/kvm_asm.h              |   4 +
 arch/arm64/include/asm/kvm_emulate.h          |  93 +-
 arch/arm64/include/asm/kvm_host.h             | 181 +++-
 arch/arm64/include/asm/kvm_hyp.h              |   2 +
 arch/arm64/include/asm/kvm_mmu.h              |  20 +-
 arch/arm64/include/asm/kvm_nested.h           | 133 +++
 arch/arm64/include/asm/stage2_pgtable.h       |   4 +-
 arch/arm64/include/asm/sysreg.h               | 196 ++++
 arch/arm64/include/asm/vncr_mapping.h         |  74 ++
 arch/arm64/include/uapi/asm/kvm.h             |   1 +
 arch/arm64/kernel/cpufeature.c                |  11 +
 arch/arm64/kvm/Makefile                       |   4 +-
 arch/arm64/kvm/arch_timer.c                   |  98 +-
 arch/arm64/kvm/arm.c                          |  33 +-
 arch/arm64/kvm/at.c                           | 219 ++++
 arch/arm64/kvm/emulate-nested.c               | 934 ++++++++++++++++-
 arch/arm64/kvm/handle_exit.c                  |  29 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h       |   8 +-
 arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h    |   5 +-
 arch/arm64/kvm/hyp/nvhe/mem_protect.c         |   8 +-
 arch/arm64/kvm/hyp/nvhe/pkvm.c                |   4 +-
 arch/arm64/kvm/hyp/nvhe/switch.c              |   2 +-
 arch/arm64/kvm/hyp/nvhe/sysreg-sr.c           |   2 +-
 arch/arm64/kvm/hyp/pgtable.c                  |   2 +-
 arch/arm64/kvm/hyp/vgic-v3-sr.c               |   6 +-
 arch/arm64/kvm/hyp/vhe/switch.c               | 206 +++-
 arch/arm64/kvm/hyp/vhe/sysreg-sr.c            | 124 ++-
 arch/arm64/kvm/hyp/vhe/tlb.c                  |  83 ++
 arch/arm64/kvm/mmu.c                          | 255 ++++-
 arch/arm64/kvm/nested.c                       | 799 ++++++++++++++-
 arch/arm64/kvm/pkvm.c                         |   2 +-
 arch/arm64/kvm/reset.c                        |   7 +
 arch/arm64/kvm/sys_regs.c                     | 958 +++++++++++++++++-
 arch/arm64/kvm/trace_arm.h                    |  19 +
 arch/arm64/kvm/vgic/vgic-init.c               |  33 +
 arch/arm64/kvm/vgic/vgic-kvm-device.c         |  32 +-
 arch/arm64/kvm/vgic/vgic-v3-nested.c          | 248 +++++
 arch/arm64/kvm/vgic/vgic-v3.c                 |  43 +-
 arch/arm64/kvm/vgic/vgic.c                    |  29 +
 arch/arm64/kvm/vgic/vgic.h                    |  10 +
 arch/arm64/tools/cpucaps                      |   1 +
 include/clocksource/arm_arch_timer.h          |   4 +
 include/kvm/arm_arch_timer.h                  |   1 +
 include/kvm/arm_vgic.h                        |  17 +
 include/uapi/linux/kvm.h                      |   1 +
 tools/arch/arm/include/uapi/asm/kvm.h         |   1 +
 49 files changed, 4790 insertions(+), 183 deletions(-)
 create mode 100644 arch/arm64/include/asm/vncr_mapping.h
 create mode 100644 arch/arm64/kvm/at.c
 create mode 100644 arch/arm64/kvm/vgic/vgic-v3-nested.c
Signature · 1 line
2.34.1