Skip to content

KVM: arm64: Add support for protected guest memory with pKVM

Will Deacon kvmarm linux-arm-kernel 5 versions – Applied

Status from this message: Applied to next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest38 patches 4 repliesApplied
  2. v438 patches 1 replySuperseded
  3. v336 patches 26 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v235 patches18 repliesSuperseded
v130 patches37 repliesApplied

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/38KVM: arm64: Remove unused PKVM_ID_FFA definitionarch/arm64/kvm/hyp/include/nvhe/mem_protect.h+0 -10 replies
2/38KVM: arm64: Don't leak stage-2 page-table if VM fails to init under pKVMarch/arm64/kvm/arm.c+3 -10 replies
3/38KVM: arm64: Move handle check into pkvm_pgtable_stage2_destroy_range()arch/arm64/kvm/pkvm.c+6 -30 replies
4/38KVM: arm64: Rename __pkvm_pgtable_stage2_unmap()arch/arm64/kvm/pkvm.c+4 -40 replies
5/38KVM: arm64: Don't advertise unsupported features for protected guestsarch/arm64/include/asm/kvm_pkvm.h+0 -20 replies
6/38KVM: arm64: Expose self-hosted debug regs as RAZ/WI for protected guestsarch/arm64/kvm/hyp/nvhe/sys_regs.c+8 -00 replies
7/38KVM: arm64: Remove is_protected_kvm_enabled() checks from hypercallsarch/arm64/include/asm/kvm_asm.h arch/arm64/kvm/hyp/nvhe/hyp-main.c+34 -530 replies
8/38KVM: arm64: Ignore MMU notifier callbacks for protected VMsarch/arm64/kvm/mmu.c arch/arm64/kvm/pkvm.c+24 -40 replies
9/38KVM: arm64: Prevent unsupported memslot operations on protected VMsarch/arm64/kvm/mmu.c arch/arm64/kvm/pkvm.c+19 -00 replies
10/38KVM: arm64: Ignore -EAGAIN when mapping in pages for the pKVM hostarch/arm64/kvm/hyp/nvhe/mem_protect.c+16 -50 replies
11/38KVM: arm64: Split teardown hypercall into two phasesarch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/hyp/include/nvhe/pkvm.h +3 more+67 -123 replies
12/38KVM: arm64: Introduce __pkvm_host_donate_guest()arch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_pgtable.h arch/arm64/kvm/hyp/include/nvhe/mem_protect.h +2 more+55 -10 replies
13/38KVM: arm64: Hook up donation hypercall to pkvm_pgtable_stage2_map()arch/arm64/kvm/pkvm.c+41 -170 replies
14/38KVM: arm64: Handle aborts from protected VMsarch/arm64/kvm/mmu.c+81 -80 replies
15/38KVM: arm64: Introduce __pkvm_reclaim_dying_guest_page()arch/arm64/include/asm/kvm_asm.h arch/arm64/kvm/hyp/include/nvhe/mem_protect.h arch/arm64/kvm/hyp/include/nvhe/pkvm.h +3 more+105 -00 replies
16/38KVM: arm64: Hook up reclaim hypercall to pkvm_pgtable_stage2_destroy()arch/arm64/kvm/pkvm.c+30 -10 replies
17/38KVM: arm64: Factor out pKVM host exception injection logicarch/arm64/kvm/hyp/nvhe/hyp-main.c+23 -260 replies
18/38KVM: arm64: Support translation faults in inject_host_exception()arch/arm64/kvm/hyp/include/nvhe/trap_handler.h arch/arm64/kvm/hyp/nvhe/hyp-main.c+17 -30 replies
19/38KVM: arm64: Inject SIGSEGV on illegal accessesarch/arm64/kvm/hyp/nvhe/mem_protect.c arch/arm64/mm/fault.c+59 -00 replies
20/38KVM: arm64: Avoid pointless annotation when mapping host-owned pagesarch/arm64/kvm/hyp/nvhe/mem_protect.c+16 -120 replies
21/38KVM: arm64: Generalise kvm_pgtable_stage2_set_owner()arch/arm64/include/asm/kvm_pgtable.h arch/arm64/kvm/hyp/nvhe/mem_protect.c arch/arm64/kvm/hyp/pgtable.c+62 -260 replies
22/38KVM: arm64: Introduce host_stage2_set_owner_metadata_locked()arch/arm64/include/asm/kvm_pgtable.h arch/arm64/kvm/hyp/nvhe/mem_protect.c+32 -170 replies
23/38KVM: arm64: Change 'pkvm_handle_t' to u16arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/hyp/nvhe/pkvm.c+2 -10 replies
24/38KVM: arm64: Annotate guest donations with handle and gfn in host stage-2arch/arm64/kvm/hyp/nvhe/mem_protect.c+18 -20 replies
25/38KVM: arm64: Introduce hypercall to force reclaim of a protected pagearch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/kvm_pgtable.h arch/arm64/kvm/hyp/include/nvhe/mem_protect.h +5 more+154 -20 replies
26/38KVM: arm64: Reclaim faulting page from pKVM in spurious fault handlerarch/arm64/include/asm/virt.h arch/arm64/kvm/pkvm.c arch/arm64/mm/fault.c+32 -60 replies
27/38KVM: arm64: Return -EFAULT from VCPU_RUN on access to a poisoned ptearch/arm64/include/asm/kvm_asm.h arch/arm64/kvm/hyp/include/nvhe/mem_protect.h arch/arm64/kvm/hyp/nvhe/hyp-main.c +2 more+61 -30 replies
28/38KVM: arm64: Add hvc handler at EL2 for hypercalls from protected VMsarch/arm64/kvm/hyp/include/nvhe/pkvm.h arch/arm64/kvm/hyp/nvhe/pkvm.c arch/arm64/kvm/hyp/nvhe/switch.c+39 -00 replies
29/38KVM: arm64: Implement the MEM_SHARE hypercall for protected VMsarch/arm64/kvm/hyp/include/nvhe/mem_protect.h arch/arm64/kvm/hyp/nvhe/mem_protect.c arch/arm64/kvm/hyp/nvhe/pkvm.c+94 -00 replies
30/38KVM: arm64: Implement the MEM_UNSHARE hypercall for protected VMsarch/arm64/kvm/hyp/include/nvhe/mem_protect.h arch/arm64/kvm/hyp/nvhe/mem_protect.c arch/arm64/kvm/hyp/nvhe/pkvm.c+57 -00 replies
31/38KVM: arm64: Allow userspace to create protected VMs when pKVM is enabledarch/arm64/include/asm/kvm_pkvm.h arch/arm64/kvm/arm.c arch/arm64/kvm/mmu.c +2 more+20 -60 replies
32/38KVM: arm64: Add some initial documentation for pKVMDocumentation/admin-guide/kernel-parameters.txt Documentation/virt/kvm/arm/index.rst Documentation/virt/kvm/arm/pkvm.rst+109 -20 replies
33/38KVM: arm64: Extend pKVM page ownership selftests to cover guest donationarch/arm64/kvm/hyp/nvhe/mem_protect.c+22 -00 replies
34/38KVM: arm64: Register 'selftest_vm' in the VM tablearch/arm64/kvm/hyp/include/nvhe/mem_protect.h arch/arm64/kvm/hyp/nvhe/mem_protect.c arch/arm64/kvm/hyp/nvhe/pkvm.c+61 -430 replies
35/38KVM: arm64: Extend pKVM page ownership selftests to cover forced reclaimarch/arm64/kvm/hyp/nvhe/mem_protect.c+14 -20 replies
36/38KVM: arm64: Extend pKVM page ownership selftests to cover guest hvcsarch/arm64/kvm/hyp/nvhe/mem_protect.c+30 -00 replies
37/38KVM: arm64: Rename PKVM_PAGE_STATE_MASKarch/arm64/kvm/hyp/include/nvhe/memory.h+3 -30 replies
38/38drivers/virt: pkvm: Add Kconfig dependency on DMA_RESTRICTED_POOLdrivers/virt/coco/pkvm-guest/Kconfig+1 -10 replies

Reviews trailers per patch

21 of 38 patches have a Reviewed-by or Acked-by.

PatchFuad TabbaMostafa SalehQuentin PerretVincent Donnefort
1/38
2/38R-b T-b T-b
3/38R-b T-b T-b
4/38R-b T-b T-b
5/38R-b T-b T-b
6/38T-b
7/38R-b T-b T-b R-b
8/38R-b T-b T-b
9/38R-b T-b T-b
10/38R-b T-b T-b
11/38R-b T-b T-b
12/38T-b T-b
13/38T-b T-b
14/38R-b T-b T-b
15/38T-b T-b R-b
16/38T-b T-b
17/38R-b T-b T-b
18/38R-b T-b T-b
19/38R-b T-b T-b
20/38T-b T-b
21/38T-b T-b
22/38T-b T-b
23/38R-b T-b T-b
24/38R-b T-b T-b
25/38T-b T-b
26/38T-b T-b
27/38T-b T-b
28/38T-b T-b R-b
29/38T-b T-b R-b
30/38T-b T-b R-b
31/38T-b T-b
32/38R-b T-b T-b
33/38T-b T-b
34/38T-b T-b
35/38T-b T-b
36/38T-b T-b
37/38R-b T-b T-b
38/38

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 v5 thread

Cover letter [PATCH v5 00/38] KVM: arm64: Add support for protected guest memory with pKVM

Hi everyone,

As promised on Friday, here's v5 of the pKVM protected memory patches previously posted here:

v1: https://lore.kernel.org/kvmarm/[email protected]/
v2: https://lore.kernel.org/kvmarm/[email protected]/
v3: https://lore.kernel.org/r/[email protected]
v4: https://lore.kernel.org/r/[email protected]

This version primarily addresses the comments from Sashiko that I think are valid:

* Mask out page offset from physical address passed to "force reclaim" hypercall.
* Check for 'is_dying' in get_pkvm_hyp_vm() to prevent taking a reference on a VM in the process of being destroyed.
* Take the 'slots_lock' while creating the hyp vm to avoid racing with check in kvm_arch_prepare_memory_region().
* Keep trying to reclaim pages from a dying guest if we fail part-way through.
* Fix return value from pkvm_pgtable_stage2_test_clear_young() if it's unexpectedly called for a pVM.

As before, I've pushed an updated branch with this series:

https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=kvm/protected-memory

and the kvmtool patches are available at:

https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/log/?h=pkvm

Cheers,

Will

Cc Marc Zyngier <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Joey Gouly <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Zenghui Yu <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Quentin Perret <[email protected]>
Cc Fuad Tabba <[email protected]>
Cc Vincent Donnefort <[email protected]>
Cc Mostafa Saleh <[email protected]>
Cc Alexandru Elisei <[email protected]>

--->8

Fuad Tabba (1):
KVM: arm64: Expose self-hosted debug regs as RAZ/WI for protected
guests

Quentin Perret (1):
KVM: arm64: Inject SIGSEGV on illegal accesses

Will Deacon (36):
KVM: arm64: Remove unused PKVM_ID_FFA definition
KVM: arm64: Don't leak stage-2 page-table if VM fails to init under
pKVM
KVM: arm64: Move handle check into pkvm_pgtable_stage2_destroy_range()
KVM: arm64: Rename __pkvm_pgtable_stage2_unmap()
KVM: arm64: Don't advertise unsupported features for protected guests
KVM: arm64: Remove is_protected_kvm_enabled() checks from hypercalls
KVM: arm64: Ignore MMU notifier callbacks for protected VMs
KVM: arm64: Prevent unsupported memslot operations on protected VMs
KVM: arm64: Ignore -EAGAIN when mapping in pages for the pKVM host
KVM: arm64: Split teardown hypercall into two phases
KVM: arm64: Introduce __pkvm_host_donate_guest()
KVM: arm64: Hook up donation hypercall to pkvm_pgtable_stage2_map()
KVM: arm64: Handle aborts from protected VMs
KVM: arm64: Introduce __pkvm_reclaim_dying_guest_page()
KVM: arm64: Hook up reclaim hypercall to pkvm_pgtable_stage2_destroy()
KVM: arm64: Factor out pKVM host exception injection logic
KVM: arm64: Support translation faults in inject_host_exception()
KVM: arm64: Avoid pointless annotation when mapping host-owned pages
KVM: arm64: Generalise kvm_pgtable_stage2_set_owner()
KVM: arm64: Introduce host_stage2_set_owner_metadata_locked()
KVM: arm64: Change 'pkvm_handle_t' to u16
KVM: arm64: Annotate guest donations with handle and gfn in host

    stage-2

KVM: arm64: Introduce hypercall to force reclaim of a protected page
KVM: arm64: Reclaim faulting page from pKVM in spurious fault handler
KVM: arm64: Return -EFAULT from VCPU_RUN on access to a poisoned pte
KVM: arm64: Add hvc handler at EL2 for hypercalls from protected VMs
KVM: arm64: Implement the MEM_SHARE hypercall for protected VMs
KVM: arm64: Implement the MEM_UNSHARE hypercall for protected VMs
KVM: arm64: Allow userspace to create protected VMs when pKVM is
enabled
KVM: arm64: Add some initial documentation for pKVM
KVM: arm64: Extend pKVM page ownership selftests to cover guest
donation
KVM: arm64: Register 'selftest_vm' in the VM table
KVM: arm64: Extend pKVM page ownership selftests to cover forced
reclaim
KVM: arm64: Extend pKVM page ownership selftests to cover guest hvcs
KVM: arm64: Rename PKVM_PAGE_STATE_MASK
drivers/virt: pkvm: Add Kconfig dependency on DMA_RESTRICTED_POOL

 .../admin-guide/kernel-parameters.txt         |   4 +-
 Documentation/virt/kvm/arm/index.rst          |   1 +
 Documentation/virt/kvm/arm/pkvm.rst           | 106 ++++
 arch/arm64/include/asm/kvm_asm.h              |  31 +-
 arch/arm64/include/asm/kvm_host.h             |   9 +-
 arch/arm64/include/asm/kvm_pgtable.h          |  45 +-
 arch/arm64/include/asm/kvm_pkvm.h             |   4 +-
 arch/arm64/include/asm/virt.h                 |   9 +
 arch/arm64/kvm/arm.c                          |  12 +-
 arch/arm64/kvm/hyp/include/nvhe/mem_protect.h |  10 +-
 arch/arm64/kvm/hyp/include/nvhe/memory.h      |  12 +-
 arch/arm64/kvm/hyp/include/nvhe/pkvm.h        |   7 +-
 .../arm64/kvm/hyp/include/nvhe/trap_handler.h |   2 +
 arch/arm64/kvm/hyp/nvhe/hyp-main.c            | 184 +++---
 arch/arm64/kvm/hyp/nvhe/mem_protect.c         | 587 ++++++++++++++++--
 arch/arm64/kvm/hyp/nvhe/pkvm.c                | 232 ++++++-
 arch/arm64/kvm/hyp/nvhe/switch.c              |   1 +
 arch/arm64/kvm/hyp/nvhe/sys_regs.c            |   8 +
 arch/arm64/kvm/hyp/pgtable.c                  |  33 +-
 arch/arm64/kvm/mmu.c                          | 114 +++-
 arch/arm64/kvm/pkvm.c                         | 157 ++++-
 arch/arm64/mm/fault.c                         |  33 +-
 drivers/virt/coco/pkvm-guest/Kconfig          |   2 +-
 include/uapi/linux/kvm.h                      |   5 +
 24 files changed, 1380 insertions(+), 228 deletions(-)
 create mode 100644 Documentation/virt/kvm/arm/pkvm.rst
Signature · 1 line
2.53.0.1018.g2bb0e51243-goog