KVM: track whether guest state is encrypted
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 18 Mar 2024 18:41:10 +0000 (14:41 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Apr 2024 15:35:25 +0000 (17:35 +0200)
commit5c3131c392f84c660033d511ec39872d8beb4b1e
tree90bee47c8da028b46a87c8f4d975b06397499a32
parent08b2d15cdd0d3fbbe37ce23bf192b770db3a7539
KVM: track whether guest state is encrypted

So far, KVM has allowed KVM_GET/SET_* ioctls to execute even if the
guest state is encrypted, in which case they do nothing.  For the new
API using VM types, instead, the ioctls will fail which is a safer and
more robust approach.

The new API will be the only one available for SEV-SNP and TDX, but it
is also usable for SEV and SEV-ES.  In preparation for that, require
architecture-specific KVM code to communicate the point at which guest
state is protected (which must be after kvm_cpu_synchronize_post_init(),
though that might change in the future in order to suppor migration).
From that point, skip reading registers so that cpu->vcpu_dirty is
never true: if it ever becomes true, kvm_arch_put_registers() will
fail miserably.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
accel/kvm/kvm-all.c
include/sysemu/kvm.h
include/sysemu/kvm_int.h
target/i386/sev.c