Skip to content

Fixes and lock cleanup+hardening

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Applied to kvm-x86 svm, even though it's very late in the cycle and this is

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 12 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/21KVM: selftests: Remove duplicate LAUNCH_UPDATE_VMSA call in SEV-ES migrate testtools/testing/selftests/kvm/x86/sev_migrate_tests.c+0 -20 replies
2/21KVM: SEV: Reject attempts to sync VMSA of an already-launched/encrypted vCPUarch/x86/kvm/svm/sev.c+3 -00 replies
3/21KVM: SEV: Protect *all* of sev_mem_enc_register_region() with kvm->lockarch/x86/kvm/svm/sev.c+2 -40 replies
4/21KVM: SEV: Disallow LAUNCH_FINISH if vCPUs are actively being createdarch/x86/kvm/svm/sev.c include/linux/kvm_host.h+15 -20 replies
5/21KVM: SEV: Lock all vCPUs when synchronzing VMSAs for SNP launch finisharch/x86/kvm/svm/sev.c+13 -33 replies
6/21KVM: SEV: Lock all vCPUs for the duration of SEV-ES VMSA synchronizationarch/x86/kvm/svm/sev.c+7 -80 replies
7/21KVM: SEV: Provide vCPU-scoped accessors for detecting SEV+ guestsarch/x86/kvm/svm/sev.c arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h+82 -640 replies
8/21KVM: SEV: Add quad-underscore version of VM-scoped APIs to detect SEV+ guestsarch/x86/kvm/svm/svm.h+21 -70 replies
9/21KVM: SEV: Document the SEV-ES check when querying SMM support as "safe"arch/x86/kvm/svm/svm.c+10 -20 replies
10/21KVM: SEV: Move standard VM-scoped helpers to detect SEV+ guests to sev.carch/x86/kvm/svm/sev.c arch/x86/kvm/svm/svm.h+14 -172 replies
11/21KVM: SEV: Move SEV-specific VM initialization to sev.carch/x86/kvm/svm/sev.c arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h+18 -110 replies
12/21KVM: SEV: WARN on unhandled VM type when initializing VMarch/x86/kvm/svm/sev.c+18 -114 replies
13/21KVM: SEV: Hide "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=yarch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h+7 -10 replies
14/21KVM: SEV: Document that checking for SEV+ guests when reclaiming memory is "safe"arch/x86/kvm/svm/sev.c+7 -10 replies
15/21KVM: SEV: Assert that kvm->lock is held when querying SEV+ supportarch/x86/kvm/svm/sev.c+25 -00 replies
16/21KVM: SEV: use mutex guard in snp_launch_update()arch/x86/kvm/svm/sev.c+12 -190 replies
17/21KVM: SEV: use mutex guard in sev_mem_enc_ioctl()arch/x86/kvm/svm/sev.c+8 -170 replies
18/21KVM: SEV: use mutex guard in sev_mem_enc_unregister_region()arch/x86/kvm/svm/sev.c+5 -150 replies
19/21KVM: SEV: use mutex guard in snp_handle_guest_req()arch/x86/kvm/svm/sev.c+8 -150 replies
20/21KVM: SVM: Move lock-protected allocation of SEV ASID into a separate helperarch/x86/kvm/svm/sev.c+23 -140 replies
21/21KVM: SEV: Goto an existing error label if charging misc_cg for an ASID failsarch/x86/kvm/svm/sev.c+5 -60 replies

Reviews trailers per patch

None of the 21 patches has a Reviewed-by or Acked-by.

PatchAlexander Potapenko
1/21
2/21
3/21T-b
4/21
5/21
6/21
7/21
8/21
9/21
10/21
11/21
12/21
13/21
14/21
15/21
16/21
17/21
18/21
19/21
20/21
21/21

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/21] Fixes and lock cleanup+hardening

Fix several fatal SEV bugs, then clean up the SEV+ APIs to either document that they are safe to query outside of kvm->lock, or to use lockdep-protected version. The sev_mem_enc_register_region() goof is at least the second bug we've had related to checking for an SEV guest outside of kvm->lock, and in general it's nearly impossible to just "eyeball" the safety of KVM's usage.

I included Carlos' guard() cleanups here to avoid annoying conflicts (well, to solve them now instead of when applying).

Carlos López (5):
KVM: SEV: use mutex guard in snp_launch_update()
KVM: SEV: use mutex guard in sev_mem_enc_ioctl()
KVM: SEV: use mutex guard in sev_mem_enc_unregister_region()
KVM: SEV: use mutex guard in snp_handle_guest_req()
KVM: SVM: Move lock-protected allocation of SEV ASID into a separate
helper

Sean Christopherson (16):
KVM: selftests: Remove duplicate LAUNCH_UPDATE_VMSA call in SEV-ES
migrate test
KVM: SEV: Reject attempts to sync VMSA of an
already-launched/encrypted vCPU
KVM: SEV: Protect *all* of sev_mem_enc_register_region() with

    kvm->lock
  KVM: SEV: Disallow LAUNCH_FINISH if vCPUs are actively being created
  KVM: SEV: Lock all vCPUs when synchronzing VMSAs for SNP launch finish
  KVM: SEV: Lock all vCPUs for the duration of SEV-ES VMSA
    synchronization
  KVM: SEV: Provide vCPU-scoped accessors for detecting SEV+ guests
  KVM: SEV: Add quad-underscore version of VM-scoped APIs to detect SEV+
    guests
  KVM: SEV: Document the SEV-ES check when querying SMM support as
    "safe"

KVM: SEV: Move standard VM-scoped helpers to detect SEV+ guests to
sev.c
KVM: SEV: Move SEV-specific VM initialization to sev.c
KVM: SEV: WARN on unhandled VM type when initializing VM
KVM: SEV: Hide "struct kvm_sev_info" behind CONFIG_KVM_AMD_SEV=y
KVM: SEV: Document that checking for SEV+ guests when reclaiming
memory is "safe"
KVM: SEV: Assert that kvm->lock is held when querying SEV+ support
KVM: SEV: Goto an existing error label if charging misc_cg for an ASID
fails

 arch/x86/kvm/svm/sev.c                        | 315 +++++++++++-------
 arch/x86/kvm/svm/svm.c                        | 106 +++---
 arch/x86/kvm/svm/svm.h                        |  36 +-
 include/linux/kvm_host.h                      |   7 +
 .../selftests/kvm/x86/sev_migrate_tests.c     |   2 -
 5 files changed, 275 insertions(+), 191 deletions(-)

base-commit: 11439c4635edd669ae435eec308f4ab8a0804808

Signature · 1 line
2.53.0.473.g4a7958ca14-goog