lkml.org 
[lkml]   [2019]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.19 38/45] selftests: kvm: fix state save/load on processors without XSAVE
    Date
    From: Paolo Bonzini <pbonzini@redhat.com>

    [ Upstream commit 54577e5018a8c0cb79c9a0fa118a55c68715d398 ]

    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: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    tools/testing/selftests/kvm/lib/x86.c | 16 ++++++++++------
    1 file changed, 10 insertions(+), 6 deletions(-)

    diff --git a/tools/testing/selftests/kvm/lib/x86.c b/tools/testing/selftests/kvm/lib/x86.c
    index a3122f1949a8e..4d35eba73dc97 100644
    --- a/tools/testing/selftests/kvm/lib/x86.c
    +++ b/tools/testing/selftests/kvm/lib/x86.c
    @@ -809,9 +809,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",
    r);

    - r = ioctl(vcpu->fd, KVM_GET_XCRS, &state->xcrs);
    - TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XCRS, r: %i",
    - r);
    + if (kvm_check_cap(KVM_CAP_XCRS)) {
    + r = ioctl(vcpu->fd, KVM_GET_XCRS, &state->xcrs);
    + TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_XCRS, r: %i",
    + r);
    + }

    r = ioctl(vcpu->fd, KVM_GET_SREGS, &state->sregs);
    TEST_ASSERT(r == 0, "Unexpected result from KVM_GET_SREGS, r: %i",
    @@ -858,9 +860,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",
    r);

    - r = ioctl(vcpu->fd, KVM_SET_XCRS, &state->xcrs);
    - TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XCRS, r: %i",
    - r);
    + if (kvm_check_cap(KVM_CAP_XCRS)) {
    + r = ioctl(vcpu->fd, KVM_SET_XCRS, &state->xcrs);
    + TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XCRS, r: %i",
    + r);
    + }

    r = ioctl(vcpu->fd, KVM_SET_SREGS, &state->sregs);
    TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_SREGS, r: %i",
    --
    2.20.1
    \
     
     \ /
      Last update: 2019-08-29 20:24    [W:4.619 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site