Skip to content

Commit

Permalink
KVM: selftests: enlightened VMPTRLD with an incorrect GPA
Browse files Browse the repository at this point in the history
Check that guest doesn't hang when an invalid eVMCS GPA is specified.
Testing that #UD is injected would probably be better but selftests lack
the infrastructure currently.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Vitaly Kuznetsov authored and Paolo Bonzini committed Mar 16, 2020
1 parent 41b0552 commit 6d05a96
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tools/testing/selftests/kvm/x86_64/evmcs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ void guest_code(struct vmx_pages *vmx_pages)
l1_guest_code(vmx_pages);

GUEST_DONE();

/* Try enlightened vmptrld with an incorrect GPA */
evmcs_vmptrld(0xdeadbeef, vmx_pages->enlightened_vmcs);
GUEST_ASSERT(vmlaunch());
}

int main(int argc, char *argv[])
Expand Down Expand Up @@ -120,7 +124,7 @@ int main(int argc, char *argv[])
case UCALL_SYNC:
break;
case UCALL_DONE:
goto done;
goto part1_done;
default:
TEST_FAIL("Unknown ucall %lu", uc.cmd);
}
Expand Down Expand Up @@ -152,6 +156,10 @@ int main(int argc, char *argv[])
(ulong) regs2.rdi, (ulong) regs2.rsi);
}

done:
part1_done:
_vcpu_run(vm, VCPU_ID);
TEST_ASSERT(run->exit_reason == KVM_EXIT_SHUTDOWN,
"Unexpected successful VMEnter with invalid eVMCS pointer!");

kvm_vm_free(vm);
}

0 comments on commit 6d05a96

Please sign in to comment.