Commit b0435a12 authored by Christian Borntraeger's avatar Christian Borntraeger Committed by Paolo Bonzini

selftests: KVM: s390: test more register variants for the reset ioctl

We should not only test the oneregs or the get_(x)regs interfaces but
also the sync_regs. Those are usually the canonical place for register
content.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 41cbed5b
...@@ -20,8 +20,8 @@ struct kvm_s390_irq buf[VCPU_ID + LOCAL_IRQS]; ...@@ -20,8 +20,8 @@ struct kvm_s390_irq buf[VCPU_ID + LOCAL_IRQS];
struct kvm_vm *vm; struct kvm_vm *vm;
struct kvm_run *run; struct kvm_run *run;
struct kvm_sync_regs *regs; struct kvm_sync_regs *sync_regs;
static uint64_t regs_null[16]; static uint8_t regs_null[512];
static void guest_code_initial(void) static void guest_code_initial(void)
{ {
...@@ -86,6 +86,16 @@ static void assert_clear(void) ...@@ -86,6 +86,16 @@ static void assert_clear(void)
vcpu_fpu_get(vm, VCPU_ID, &fpu); vcpu_fpu_get(vm, VCPU_ID, &fpu);
TEST_ASSERT(!memcmp(&fpu.fprs, regs_null, sizeof(fpu.fprs)), "fprs == 0"); TEST_ASSERT(!memcmp(&fpu.fprs, regs_null, sizeof(fpu.fprs)), "fprs == 0");
/* sync regs */
TEST_ASSERT(!memcmp(sync_regs->gprs, regs_null, sizeof(sync_regs->gprs)),
"gprs0-15 == 0 (sync_regs)");
TEST_ASSERT(!memcmp(sync_regs->acrs, regs_null, sizeof(sync_regs->acrs)),
"acrs0-15 == 0 (sync_regs)");
TEST_ASSERT(!memcmp(sync_regs->vrs, regs_null, sizeof(sync_regs->vrs)),
"vrs0-15 == 0 (sync_regs)");
} }
static void assert_initial(void) static void assert_initial(void)
...@@ -93,12 +103,32 @@ static void assert_initial(void) ...@@ -93,12 +103,32 @@ static void assert_initial(void)
struct kvm_sregs sregs; struct kvm_sregs sregs;
struct kvm_fpu fpu; struct kvm_fpu fpu;
/* KVM_GET_SREGS */
vcpu_sregs_get(vm, VCPU_ID, &sregs); vcpu_sregs_get(vm, VCPU_ID, &sregs);
TEST_ASSERT(sregs.crs[0] == 0xE0UL, "cr0 == 0xE0"); TEST_ASSERT(sregs.crs[0] == 0xE0UL, "cr0 == 0xE0 (KVM_GET_SREGS)");
TEST_ASSERT(sregs.crs[14] == 0xC2000000UL, "cr14 == 0xC2000000"); TEST_ASSERT(sregs.crs[14] == 0xC2000000UL,
"cr14 == 0xC2000000 (KVM_GET_SREGS)");
TEST_ASSERT(!memcmp(&sregs.crs[1], regs_null, sizeof(sregs.crs[1]) * 12), TEST_ASSERT(!memcmp(&sregs.crs[1], regs_null, sizeof(sregs.crs[1]) * 12),
"cr1-13 == 0"); "cr1-13 == 0 (KVM_GET_SREGS)");
TEST_ASSERT(sregs.crs[15] == 0, "cr15 == 0"); TEST_ASSERT(sregs.crs[15] == 0, "cr15 == 0 (KVM_GET_SREGS)");
/* sync regs */
TEST_ASSERT(sync_regs->crs[0] == 0xE0UL, "cr0 == 0xE0 (sync_regs)");
TEST_ASSERT(sync_regs->crs[14] == 0xC2000000UL,
"cr14 == 0xC2000000 (sync_regs)");
TEST_ASSERT(!memcmp(&sync_regs->crs[1], regs_null, 8 * 12),
"cr1-13 == 0 (sync_regs)");
TEST_ASSERT(sync_regs->crs[15] == 0, "cr15 == 0 (sync_regs)");
TEST_ASSERT(sync_regs->fpc == 0, "fpc == 0 (sync_regs)");
TEST_ASSERT(sync_regs->todpr == 0, "todpr == 0 (sync_regs)");
TEST_ASSERT(sync_regs->cputm == 0, "cputm == 0 (sync_regs)");
TEST_ASSERT(sync_regs->ckc == 0, "ckc == 0 (sync_regs)");
TEST_ASSERT(sync_regs->pp == 0, "pp == 0 (sync_regs)");
TEST_ASSERT(sync_regs->gbea == 1, "gbea == 1 (sync_regs)");
/* kvm_run */
TEST_ASSERT(run->psw_addr == 0, "psw_addr == 0 (kvm_run)");
TEST_ASSERT(run->psw_mask == 0, "psw_mask == 0 (kvm_run)");
vcpu_fpu_get(vm, VCPU_ID, &fpu); vcpu_fpu_get(vm, VCPU_ID, &fpu);
TEST_ASSERT(!fpu.fpc, "fpc == 0"); TEST_ASSERT(!fpu.fpc, "fpc == 0");
...@@ -113,6 +143,8 @@ static void assert_initial(void) ...@@ -113,6 +143,8 @@ static void assert_initial(void)
static void assert_normal(void) static void assert_normal(void)
{ {
test_one_reg(KVM_REG_S390_PFTOKEN, KVM_S390_PFAULT_TOKEN_INVALID); test_one_reg(KVM_REG_S390_PFTOKEN, KVM_S390_PFAULT_TOKEN_INVALID);
TEST_ASSERT(sync_regs->pft == KVM_S390_PFAULT_TOKEN_INVALID,
"pft == 0xff..... (sync_regs)");
assert_noirq(); assert_noirq();
} }
...@@ -137,7 +169,7 @@ static void test_normal(void) ...@@ -137,7 +169,7 @@ static void test_normal(void)
/* Create VM */ /* Create VM */
vm = vm_create_default(VCPU_ID, 0, guest_code_initial); vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
run = vcpu_state(vm, VCPU_ID); run = vcpu_state(vm, VCPU_ID);
regs = &run->s.regs; sync_regs = &run->s.regs;
vcpu_run(vm, VCPU_ID); vcpu_run(vm, VCPU_ID);
...@@ -153,7 +185,7 @@ static void test_initial(void) ...@@ -153,7 +185,7 @@ static void test_initial(void)
pr_info("Testing initial reset\n"); pr_info("Testing initial reset\n");
vm = vm_create_default(VCPU_ID, 0, guest_code_initial); vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
run = vcpu_state(vm, VCPU_ID); run = vcpu_state(vm, VCPU_ID);
regs = &run->s.regs; sync_regs = &run->s.regs;
vcpu_run(vm, VCPU_ID); vcpu_run(vm, VCPU_ID);
...@@ -170,7 +202,7 @@ static void test_clear(void) ...@@ -170,7 +202,7 @@ static void test_clear(void)
pr_info("Testing clear reset\n"); pr_info("Testing clear reset\n");
vm = vm_create_default(VCPU_ID, 0, guest_code_initial); vm = vm_create_default(VCPU_ID, 0, guest_code_initial);
run = vcpu_state(vm, VCPU_ID); run = vcpu_state(vm, VCPU_ID);
regs = &run->s.regs; sync_regs = &run->s.regs;
vcpu_run(vm, VCPU_ID); vcpu_run(vm, VCPU_ID);
......
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