Commit 54577e50 authored by Paolo Bonzini's avatar Paolo Bonzini

selftests: kvm: fix state save/load on processors without XSAVE

state_test and smm_test are failing on older processors that do not
have xcr0.  This is because on those processor KVM does provide
support for KVM_GET/SET_XSAVE (to avoid having to rely on the older
KVM_GET/SET_FPU) but not for KVM_GET/SET_XCRS.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent c930e197
...@@ -1060,9 +1060,11 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid) ...@@ -1060,9 +1060,11 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid)
TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XSAVE, r: %i", TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XSAVE, r: %i",
r); r);
if (kvm_check_cap(KVM_CAP_XCRS)) {
r = ioctl(vcpu->fd, KVM_GET_XCRS, &state->xcrs); r = ioctl(vcpu->fd, KVM_GET_XCRS, &state->xcrs);
TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XCRS, r: %i", TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XCRS, r: %i",
r); r);
}
r = ioctl(vcpu->fd, KVM_GET_SREGS, &state->sregs); r = ioctl(vcpu->fd, KVM_GET_SREGS, &state->sregs);
TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_SREGS, r: %i", TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_SREGS, r: %i",
...@@ -1103,9 +1105,11 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s ...@@ -1103,9 +1105,11 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s
TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XSAVE, r: %i", TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XSAVE, r: %i",
r); r);
if (kvm_check_cap(KVM_CAP_XCRS)) {
r = ioctl(vcpu->fd, KVM_SET_XCRS, &state->xcrs); r = ioctl(vcpu->fd, KVM_SET_XCRS, &state->xcrs);
TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XCRS, r: %i", TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XCRS, r: %i",
r); r);
}
r = ioctl(vcpu->fd, KVM_SET_SREGS, &state->sregs); r = ioctl(vcpu->fd, KVM_SET_SREGS, &state->sregs);
TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_SREGS, r: %i", TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_SREGS, r: %i",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment