Skip to content

Commit ada0a50

Browse files
frankjaaborntraeger
authored andcommitted
selftests: KVM: Add fpu and one reg set/get library functions
Add library access to more registers. Signed-off-by: Janosch Frank <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Borntraeger <[email protected]>
1 parent 7de3f14 commit ada0a50

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ void vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid,
125125
struct kvm_sregs *sregs);
126126
int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid,
127127
struct kvm_sregs *sregs);
128+
void vcpu_fpu_get(struct kvm_vm *vm, uint32_t vcpuid,
129+
struct kvm_fpu *fpu);
130+
void vcpu_fpu_set(struct kvm_vm *vm, uint32_t vcpuid,
131+
struct kvm_fpu *fpu);
132+
void vcpu_get_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg);
133+
void vcpu_set_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg);
128134
#ifdef __KVM_HAVE_VCPU_EVENTS
129135
void vcpu_events_get(struct kvm_vm *vm, uint32_t vcpuid,
130136
struct kvm_vcpu_events *events);

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,42 @@ int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs)
13731373
return ioctl(vcpu->fd, KVM_SET_SREGS, sregs);
13741374
}
13751375

1376+
void vcpu_fpu_get(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_fpu *fpu)
1377+
{
1378+
int ret;
1379+
1380+
ret = _vcpu_ioctl(vm, vcpuid, KVM_GET_FPU, fpu);
1381+
TEST_ASSERT(ret == 0, "KVM_GET_FPU failed, rc: %i errno: %i (%s)",
1382+
ret, errno, strerror(errno));
1383+
}
1384+
1385+
void vcpu_fpu_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_fpu *fpu)
1386+
{
1387+
int ret;
1388+
1389+
ret = _vcpu_ioctl(vm, vcpuid, KVM_SET_FPU, fpu);
1390+
TEST_ASSERT(ret == 0, "KVM_SET_FPU failed, rc: %i errno: %i (%s)",
1391+
ret, errno, strerror(errno));
1392+
}
1393+
1394+
void vcpu_get_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg)
1395+
{
1396+
int ret;
1397+
1398+
ret = _vcpu_ioctl(vm, vcpuid, KVM_GET_ONE_REG, reg);
1399+
TEST_ASSERT(ret == 0, "KVM_GET_ONE_REG failed, rc: %i errno: %i (%s)",
1400+
ret, errno, strerror(errno));
1401+
}
1402+
1403+
void vcpu_set_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg)
1404+
{
1405+
int ret;
1406+
1407+
ret = _vcpu_ioctl(vm, vcpuid, KVM_SET_ONE_REG, reg);
1408+
TEST_ASSERT(ret == 0, "KVM_SET_ONE_REG failed, rc: %i errno: %i (%s)",
1409+
ret, errno, strerror(errno));
1410+
}
1411+
13761412
/*
13771413
* VCPU Ioctl
13781414
*

0 commit comments

Comments
 (0)