Skip to content

Fix diagnostics and capability probes for protected VMs

Fuad Tabba kvm kvmarm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5arm64: Do not abort on register-dump failuresarm64/kvm-cpu.c+24 -124 replies
2/5kvm: Bound-check the exit-reason string lookupbuiltin-run.c include/kvm/kvm.h kvm.c+11 -31 reply
3/5kvm: Name every exit reason the UAPI header defineskvm.c+25 -21 reply
4/5arm64: Query steal-time support on the VM fdarm64/pvtime.c+2 -21 reply
5/5arm64: Query counter-offset support on the VM fdarm64/kvm.c+1 -11 reply

Reviews trailers per patch

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

PatchSuzuki K Poulose
1/5R-b
2/5R-b
3/5R-b
4/5R-b
5/5R-b

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 kvmtool 0/5] Fix diagnostics and capability probes for protected VMs

Hi folks,

These are the kvmtool changes that go with the pKVM series confining a protected VM's vCPU state to EL2 [1].

That series stops the host reading a protected vCPU's registers once it has run, and stops it setting the PVTIME attribute. kvmtool dies on both. Its arm64 register-dump helpers call die() when KVM_GET_ONE_REG fails, which turns a diagnostic into a VMM abort. kvm_cpu__setup_pvtime() runs into the new -EPERM and fails vCPU init.

The PVTIME failure is a probe on the wrong fd. kvmtool asks the global /dev/kvm fd whether steal-time is available, and that fd advertises it for a protected VM, which cannot use it.
The last patch fixes the same wrong-fd probe for the counter offset, where "lkvm run --protected --counter-offset" already fails on Linux 7.3-rc1, without the kernel series.
The same conversion went in for the vCPU feature probes in July [2].

Patches 2 and 3 are not specific to protected VMs. They fix the exit-reason table on the same panic path as patch 1. The lookup ran off the end of it, and the table had stopped naming anything KVM added after KVM_EXIT_INTERNAL_ERROR, which on arm64 includes KVM_EXIT_SYSTEM_EVENT and KVM_EXIT_ARM_NISV.

Patch 1's path needs a protected VM that is already running: "lkvm debug -d" against one kills the VMM without this series, and prints the errno with it.

Based on kvmtool master (f67bc0b).

Cheers,
/fuad

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

Fuad Tabba (5):
arm64: Do not abort on register-dump failures
kvm: Bound-check the exit-reason string lookup
kvm: Name every exit reason the UAPI header defines
arm64: Query steal-time support on the VM fd
arm64: Query counter-offset support on the VM fd

 arm64/kvm-cpu.c   | 36 ++++++++++++++++++++++++------------
 arm64/kvm.c       |  2 +-
 arm64/pvtime.c    |  4 ++--
 builtin-run.c     |  2 +-
 include/kvm/kvm.h |  2 +-
 kvm.c             | 37 ++++++++++++++++++++++++++++++++++---
 6 files changed, 63 insertions(+), 20 deletions(-)

base-commit: f67bc0bdae9433a9cfd05e65ea2c1bb6102566d9

Signature · 1 line
2.39.5