]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86: block KVM_CAP_SYNC_REGS if guest state is protected
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 6 Mar 2025 20:29:22 +0000 (21:29 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:39:36 +0000 (14:39 +0200)
commitd39838da59bda11b5b292f46db5a52201cef107a
tree1327d0949b447762d8cb217f52fa01b267d60b04
parenta54247efbc73131def0d5cd3ac35ef89629f2c13
KVM: x86: block KVM_CAP_SYNC_REGS if guest state is protected

commit 74c1807f6c4feddb3c3cb1056c54531d4adbaea6 upstream.

KVM_CAP_SYNC_REGS does not make sense for VMs with protected guest state,
since the register values cannot actually be written.  Return 0
when using the VM-level KVM_CHECK_EXTENSION ioctl, and accordingly
return -EINVAL from KVM_RUN if the valid/dirty fields are nonzero.

However, on exit from KVM_RUN userspace could have placed a nonzero
value into kvm_run->kvm_valid_regs, so check guest_state_protected
again and skip store_regs() in that case.

Cc: stable@vger.kernel.org
Fixes: 517987e3fb19 ("KVM: x86: add fields to struct kvm_arch for CoCo features")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20250306202923.646075-1-pbonzini@redhat.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/x86.c