target/i386: SEV: use KVM_SEV_INIT2 if possible
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 19 Mar 2024 14:30:25 +0000 (15:30 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Apr 2024 15:35:25 +0000 (17:35 +0200)
commit663e2f443e5722370708ce2f4c27d94a2087d2d3
tree6e96d1e1ba7291f2cc48383d367c3b60d7720212
parentee88612df1e8d6c2bfec75bff3f9482ea44acec1
target/i386: SEV: use KVM_SEV_INIT2 if possible

Implement support for the KVM_X86_SEV_VM and KVM_X86_SEV_ES_VM virtual
machine types, and the KVM_SEV_INIT2 function of KVM_MEMORY_ENCRYPT_OP.

These replace the KVM_SEV_INIT and KVM_SEV_ES_INIT functions, and have
several advantages:

- sharing the initialization sequence with SEV-SNP and TDX

- allowing arguments including the set of desired VMSA features

- protection against invalid use of KVM_GET/SET_* ioctls for guests
  with encrypted state

If the KVM_X86_SEV_VM and KVM_X86_SEV_ES_VM types are not supported,
fall back to KVM_SEV_INIT and KVM_SEV_ES_INIT (which use the
default x86 VM type).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/kvm/kvm.c
target/i386/sev.c