mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-07 02:54:09 +08:00
KVM: selftests: Test invalid bits in kvm_valid_regs and kvm_dirty_regs on s390x
Now that we disallow invalid bits in kvm_valid_regs and kvm_dirty_regs on s390x, too, we should also check this condition in the selftests. The code has been taken from the x86-version of the sync_regs_test. Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Link: https://lore.kernel.org/lkml/20190904085200.29021-3-thuth@redhat.com/ Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
This commit is contained in:
parent
200824f55e
commit
81cb736c0c
@ -85,6 +85,36 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
run = vcpu_state(vm, VCPU_ID);
|
run = vcpu_state(vm, VCPU_ID);
|
||||||
|
|
||||||
|
/* Request reading invalid register set from VCPU. */
|
||||||
|
run->kvm_valid_regs = INVALID_SYNC_FIELD;
|
||||||
|
rv = _vcpu_run(vm, VCPU_ID);
|
||||||
|
TEST_ASSERT(rv < 0 && errno == EINVAL,
|
||||||
|
"Invalid kvm_valid_regs did not cause expected KVM_RUN error: %d\n",
|
||||||
|
rv);
|
||||||
|
vcpu_state(vm, VCPU_ID)->kvm_valid_regs = 0;
|
||||||
|
|
||||||
|
run->kvm_valid_regs = INVALID_SYNC_FIELD | TEST_SYNC_FIELDS;
|
||||||
|
rv = _vcpu_run(vm, VCPU_ID);
|
||||||
|
TEST_ASSERT(rv < 0 && errno == EINVAL,
|
||||||
|
"Invalid kvm_valid_regs did not cause expected KVM_RUN error: %d\n",
|
||||||
|
rv);
|
||||||
|
vcpu_state(vm, VCPU_ID)->kvm_valid_regs = 0;
|
||||||
|
|
||||||
|
/* Request setting invalid register set into VCPU. */
|
||||||
|
run->kvm_dirty_regs = INVALID_SYNC_FIELD;
|
||||||
|
rv = _vcpu_run(vm, VCPU_ID);
|
||||||
|
TEST_ASSERT(rv < 0 && errno == EINVAL,
|
||||||
|
"Invalid kvm_dirty_regs did not cause expected KVM_RUN error: %d\n",
|
||||||
|
rv);
|
||||||
|
vcpu_state(vm, VCPU_ID)->kvm_dirty_regs = 0;
|
||||||
|
|
||||||
|
run->kvm_dirty_regs = INVALID_SYNC_FIELD | TEST_SYNC_FIELDS;
|
||||||
|
rv = _vcpu_run(vm, VCPU_ID);
|
||||||
|
TEST_ASSERT(rv < 0 && errno == EINVAL,
|
||||||
|
"Invalid kvm_dirty_regs did not cause expected KVM_RUN error: %d\n",
|
||||||
|
rv);
|
||||||
|
vcpu_state(vm, VCPU_ID)->kvm_dirty_regs = 0;
|
||||||
|
|
||||||
/* Request and verify all valid register sets. */
|
/* Request and verify all valid register sets. */
|
||||||
run->kvm_valid_regs = TEST_SYNC_FIELDS;
|
run->kvm_valid_regs = TEST_SYNC_FIELDS;
|
||||||
rv = _vcpu_run(vm, VCPU_ID);
|
rv = _vcpu_run(vm, VCPU_ID);
|
||||||
|
Loading…
Reference in New Issue
Block a user