Skip to content

KVM: arm64: Userspace SMCCC call filtering

Oliver Upton kvm kvmarm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11KVM: x86: Redefine 'longmode' as a flag for KVM_EXIT_HYPERCALLarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/x86.c include/uapi/linux/kvm.h+20 -32 replies
2/11KVM: arm64: Add a helper to check if a VM has ran oncearch/arm64/include/asm/kvm_host.h arch/arm64/kvm/pmu-emul.c+5 -22 replies
3/11KVM: arm64: Add vm fd device attribute accessorsarch/arm64/kvm/arm.c+29 -04 replies
4/11KVM: arm64: Rename SMC/HVC call handler to reflect realityarch/arm64/kvm/handle_exit.c arch/arm64/kvm/hypercalls.c include/kvm/arm_hypercalls.h+4 -42 replies
5/11KVM: arm64: Start handling SMCs from EL1arch/arm64/kvm/handle_exit.c+7 -72 replies
6/11KVM: arm64: Refactor hvc filtering to support different actionsarch/arm64/include/uapi/asm/kvm.h arch/arm64/kvm/hypercalls.c+24 -41 reply
7/11KVM: arm64: Use a maple tree to represent the SMCCC filterarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/hypercalls.c +1 more+64 -10 replies
8/11KVM: arm64: Add support for KVM_EXIT_HYPERCALLDocumentation/virt/kvm/api.rst arch/arm64/include/uapi/asm/kvm.h arch/arm64/kvm/handle_exit.c +1 more+47 -40 replies
9/11KVM: arm64: Indroduce support for userspace SMCCC filteringDocumentation/virt/kvm/devices/vm.rst arch/arm64/include/uapi/asm/kvm.h arch/arm64/kvm/arm.c +2 more+150 -00 replies
10/11KVM: selftests: Add a helper for SMCCC calls with SMC instructiontools/testing/selftests/kvm/include/aarch64/processor.h tools/testing/selftests/kvm/lib/aarch64/processor.c+46 -190 replies
11/11KVM: selftests: Add test for SMCCC filtertools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/aarch64/smccc_filter.c+197 -00 replies

Reviews trailers per patch

4 of 11 patches have a Reviewed-by or Acked-by.

PatchSuzuki K Poulose
1/11
2/11
3/11R-b
4/11R-b R-b
5/11R-b
6/11R-b
7/11
8/11
9/11
10/11
11/11

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

Read the v1 thread

Cover letter [PATCH 00/11] KVM: arm64: Userspace SMCCC call filtering

The Arm SMCCC is rather prescriptive in regards to the allocation of SMCCC function ID ranges. Many of the hypercall ranges have an associated specification from Arm (FF-A, PSCI, SDEI, etc.) with some room for vendor-specific implementations.

The ever-expanding SMCCC surface leaves a lot of work within KVM for providing new features. Furthermore, KVM implements its own vendor-specific ABI, with little room for other implementations (like Hyper-V, for example). Rather than cramming it all into the kernel we should provide a way for userspace to handle hypercalls.

It would appear that vCPU hotplug [*] has a legitimate use case for something like this, sending PSCI calls to userspace (where they should have gone in the first place).

[*] https://lore.kernel.org/kvmarm/[email protected]/

=> We have these new hypercall bitmap registers, why not use that?

The hypercall bitmap registers aren't necessarily aimed at the same problem. The bitmap registers allow a VMM to preserve the ABI the guest gets from KVM by default when migrating between hosts. By default KVM exposes the entire feature set to the guest, whereas user SMCCC calls need explicit opt-in from userspace.

Applies to 6.3-rc3.

RFCv2: https://lore.kernel.org/kvmarm/[email protected]/

RFCv2 -> v1:
- Redefine kvm_run::hypercall::longmode as a flags field (Sean)
- Handle SMCs from EL1
- Pre-increment PC before exiting to userspace for an SMC
- A test!

Oliver Upton (11):
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: Indroduce support for userspace SMCCC filtering
KVM: selftests: Add a helper for SMCCC calls with SMC instruction
KVM: selftests: Add test for SMCCC filter

 Documentation/virt/kvm/api.rst                |  24 ++-
 Documentation/virt/kvm/devices/vm.rst         |  74 +++++++
 arch/arm64/include/asm/kvm_host.h             |   8 +-
 arch/arm64/include/uapi/asm/kvm.h             |  24 +++
 arch/arm64/kvm/arm.c                          |  35 ++++
 arch/arm64/kvm/handle_exit.c                  |  22 +-
 arch/arm64/kvm/hypercalls.c                   | 155 +++++++++++++-
 arch/arm64/kvm/pmu-emul.c                     |   4 +-
 arch/x86/include/uapi/asm/kvm.h               |   9 +
 arch/x86/kvm/x86.c                            |   5 +-
 include/kvm/arm_hypercalls.h                  |   6 +-
 include/uapi/linux/kvm.h                      |   9 +-
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/aarch64/smccc_filter.c      | 196 ++++++++++++++++++
 .../selftests/kvm/include/aarch64/processor.h |  13 ++
 .../selftests/kvm/lib/aarch64/processor.c     |  52 +++--
 16 files changed, 593 insertions(+), 44 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/smccc_filter.c

base-commit: e8d018dd0257f744ca50a729e3d042cf2ec9da65

Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog