KVM: arm64: Recursive NV support
Status from this message: Applied to next, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest17 patches 2 repliesApplied
- v317 patches 2 repliesSuperseded
- v217 patches 2 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 14 patches | 0 replies | Superseded |
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/17 | arm64: sysreg: Add layout for VNCR_EL2arch/ arch/ | +6 | 0 replies | |
| 2/17 | KVM: arm64: nv: Allocate VNCR page when requiredarch/ arch/ | +11 | 0 replies | |
| 3/17 | KVM: arm64: nv: Extract translation helper from the AT codearch/ arch/ | +91 | 0 replies | |
| 4/17 | KVM: arm64: nv: Snapshot S1 ASID tagging information during walkarch/ arch/ | +29 | 0 replies | |
| 5/17 | KVM: arm64: nv: Move TLBI range decoding to a helperarch/ arch/ | +34 | 0 replies | |
| 6/17 | KVM: arm64: nv: Don't adjust PSTATE.M when L2 is nestingarch/ arch/ | +20 | 0 replies | |
| 7/17 | KVM: arm64: nv: Add pseudo-TLB backing VNCR_EL2arch/ arch/ arch/ +2 more | +85 | 0 replies | |
| 8/17 | KVM: arm64: nv: Add userspace and guest handling of VNCR_EL2arch/ arch/ arch/ | +20 | 0 replies | |
| 9/17 | KVM: arm64: nv: Handle VNCR_EL2-triggered faultsarch/ arch/ arch/ +2 more | +164 | 0 replies | |
| 10/17 | KVM: arm64: nv: Handle mapping of VNCR_EL2 at EL2arch/ arch/ arch/ +1 more | +103 | 0 replies | |
| 11/17 | KVM: arm64: nv: Handle VNCR_EL2 invalidation from MMU notifiersarch/ | +75 | 0 replies | |
| 12/17 | KVM: arm64: nv: Program host's VNCR_EL2 to the fixmap addressarch/ | +16 | 0 replies | |
| 13/17 | KVM: arm64: nv: Add S1 TLB invalidation primitive for VNCR_EL2arch/ arch/ arch/ +1 more | +205 | 0 replies | |
| 14/17 | KVM: arm64: nv: Plumb TLBI S1E2 into system instruction dispatcharch/ | +61 | 0 replies | |
| 15/17 | KVM: arm64: nv: Remove dead code from ERET handlingarch/ | +0 | 0 replies | |
| 16/17 | KVM: arm64: Allow userspace to request KVM_ARM_VCPU_EL2*arch/ arch/ include/ | +9 | 0 replies | |
| 17/17 | KVM: arm64: Document NV caps and vcpu flagsDocumentation/ | +13 | 0 replies |
Reviews trailers per patch
3 of 17 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Ganapatrao Kulkarni | Oliver Upton | Joey Gouly |
|---|---|---|---|
| Series | R-b | ||
| 1/17 | |||
| 2/17 | R-b | ||
| 3/17 | |||
| 4/17 | |||
| 5/17 | |||
| 6/17 | |||
| 7/17 | |||
| 8/17 | |||
| 9/17 | |||
| 10/17 | |||
| 11/17 | |||
| 12/17 | |||
| 13/17 | |||
| 14/17 | |||
| 15/17 | |||
| 16/17 | R-b | R-b | R-b |
| 17/17 | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v4 00/17] KVM: arm64: Recursive NV support
This is probably the most interesting bit of the whole NV adventure. So far, everything else has been a walk in the park, but this one is where the real fun takes place.
With FEAT_NV2, most of the NV support revolves around tricking a guest into accessing memory while it tries to access system registers. The hypervisor's job is to handle the context switch of the actual registers with the state in memory as needed.
This memory (which we shall call the VNCR page henceforth) lives at an EL2 VA, and is therefore accessed out of context by the EL1 guest hypervisor.
So far, so good. But what does it mean to virtualise VNCR itself?
It means that when L1 has a prepared a VNCR page for L2, we must map it in the L0 EL2, and allow L2 to magically access it. Isn't that fun? To some extent. But there's more!
Having that L0 mapping on behalf of L1 comes with strings attached. It means that we must be prepared for this page to become inaccessible, which can happen for a variety of reasons:
- paged out from the host (MMU notifiers)
- unmapped from L1 EL2 stage-1
- permission changes in L1 EL2 stage-1
And in case you're wondering, yes, all of these have TLB invalidation in common. That's because performing this mapping is akin to allocating a "SW managed" TLB for L1's VNCR page.
This is what the bulk of this series is about: TLB management for VNCR pages, and making sure we have the correct page at the right time.
From an implementation perspective, it isn't that complicated, as it plugs into the existing NV artillery (TLBI, AT, MMU notifiers). Of course, nothing is optimised, because we're not at this stage yet. I have plans to make this better (i.e. fewer TLBIs, which implies fewer traps when nesting), but that's all future work.
But this is functional enough that I can run an L4 guest on my QC box. Slowly.
As an added bonus, this series now includes the last two patches that switch the damned thing on. Does it mean this is bug-free? Of course not. But we're at a point where NV is no longer a third-rate citizen. Only a second-rate one.
Patches on top of my kvm-arm64/at-fixes-6.16 branch posted at [4], itself based on 6.15-rc3. The full integration is, as always, in my kvm-arm64/nv-next branch.
* From v3 [3]:
- Added GFP_KERNEL_ACCOUNT on VNCR page allocation
* From v2 [2]:
- Handle access fault on translating the guest S1 to populate the VNCR TLB
- Added RBs by Ganapatrao on a couple of patches
* From v1 [1]:
- Rebased on 6.15-rc1
- Picked up the last two patches to enable the full NV shebang
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/[email protected]
[4] https://lore.kernel.org/r/[email protected]
Marc Zyngier (17):
arm64: sysreg: Add layout for VNCR_EL2
KVM: arm64: nv: Allocate VNCR page when required
KVM: arm64: nv: Extract translation helper from the AT code
KVM: arm64: nv: Snapshot S1 ASID tagging information during walk
KVM: arm64: nv: Move TLBI range decoding to a helper
KVM: arm64: nv: Don't adjust PSTATE.M when L2 is nesting
KVM: arm64: nv: Add pseudo-TLB backing VNCR_EL2
KVM: arm64: nv: Add userspace and guest handling of VNCR_EL2
KVM: arm64: nv: Handle VNCR_EL2-triggered faults
KVM: arm64: nv: Handle mapping of VNCR_EL2 at EL2
KVM: arm64: nv: Handle VNCR_EL2 invalidation from MMU notifiers
KVM: arm64: nv: Program host's VNCR_EL2 to the fixmap address
KVM: arm64: nv: Add S1 TLB invalidation primitive for VNCR_EL2
KVM: arm64: nv: Plumb TLBI S1E2 into system instruction dispatch
KVM: arm64: nv: Remove dead code from ERET handling
KVM: arm64: Allow userspace to request KVM_ARM_VCPU_EL2*
KVM: arm64: Document NV caps and vcpu flags
Documentation/virt/kvm/api.rst | 14 +- arch/arm64/include/asm/esr.h | 2 + arch/arm64/include/asm/fixmap.h | 6 + arch/arm64/include/asm/kvm_host.h | 15 +- arch/arm64/include/asm/kvm_nested.h | 100 +++++ arch/arm64/include/asm/sysreg.h | 1 - arch/arm64/kvm/arm.c | 10 + arch/arm64/kvm/at.c | 123 +++--- arch/arm64/kvm/emulate-nested.c | 7 - arch/arm64/kvm/handle_exit.c | 1 + arch/arm64/kvm/hyp/vhe/switch.c | 46 ++- arch/arm64/kvm/nested.c | 610 +++++++++++++++++++++++++++- arch/arm64/kvm/reset.c | 2 + arch/arm64/kvm/sys_regs.c | 135 +++--- arch/arm64/tools/sysreg | 6 + include/uapi/linux/kvm.h | 2 + 16 files changed, 942 insertions(+), 138 deletions(-)
Signature · 1 line
2.39.2