target/i386: Implement mc->kvm_type() to get VM type
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 19 Mar 2024 14:29:33 +0000 (15:29 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Apr 2024 15:35:25 +0000 (17:35 +0200)
commitee88612df1e8d6c2bfec75bff3f9482ea44acec1
tree82de4c7f1beffa77cf4e4ba1f237197a8a06d5c3
parentd82e9c843d662f13821026618aba936eda31a6c0
target/i386: Implement mc->kvm_type() to get VM type

KVM is introducing a new API to create confidential guests, which
will be used by TDX and SEV-SNP but is also available for SEV and
SEV-ES.  The API uses the VM type argument to KVM_CREATE_VM to
identify which confidential computing technology to use.

Since there are no other expected uses of VM types, delegate
mc->kvm_type() for x86 boards to the confidential-guest-support
object pointed to by ms->cgs.

For example, if a sev-guest object is specified to confidential-guest-support,
like,

  qemu -machine ...,confidential-guest-support=sev0 \
       -object sev-guest,id=sev0,...

it will check if a VM type KVM_X86_SEV_VM or KVM_X86_SEV_ES_VM
is supported, and if so use them together with the KVM_SEV_INIT2
function of the KVM_MEMORY_ENCRYPT_OP ioctl. If not, it will fall back to
KVM_SEV_INIT and KVM_SEV_ES_INIT.

This is a preparatory work towards TDX and SEV-SNP support, but it
will also enable support for VMSA features such as DebugSwap, which
are only available via KVM_SEV_INIT2.

Co-developed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/i386/x86.c
target/i386/confidential-guest.h
target/i386/kvm/kvm.c
target/i386/kvm/kvm_i386.h