Commit e5d86c7a authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Convert debug-exceptions away from VCPU_ID

Convert debug-exceptions to use vm_create_with_one_vcpu() and pass around
a 'struct kvm_vcpu' object instead of using a global VCPU_ID.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 20a7eb99
......@@ -3,8 +3,6 @@
#include <kvm_util.h>
#include <processor.h>
#define VCPU_ID 0
#define MDSCR_KDE (1 << 13)
#define MDSCR_MDE (1 << 15)
#define MDSCR_SS (1 << 0)
......@@ -240,27 +238,28 @@ static void guest_svc_handler(struct ex_regs *regs)
svc_addr = regs->pc;
}
static int debug_version(struct kvm_vm *vm)
static int debug_version(struct kvm_vcpu *vcpu)
{
uint64_t id_aa64dfr0;
get_reg(vm, VCPU_ID, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1), &id_aa64dfr0);
get_reg(vcpu->vm, vcpu->id, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1), &id_aa64dfr0);
return id_aa64dfr0 & 0xf;
}
int main(int argc, char *argv[])
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
struct ucall uc;
int stage;
vm = vm_create_default(VCPU_ID, 0, guest_code);
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
ucall_init(vm, NULL);
vm_init_descriptor_tables(vm);
vcpu_init_descriptor_tables(vm, VCPU_ID);
vcpu_init_descriptor_tables(vm, vcpu->id);
if (debug_version(vm) < 6) {
if (debug_version(vcpu) < 6) {
print_skip("Armv8 debug architecture not supported.");
kvm_vm_free(vm);
exit(KSFT_SKIP);
......@@ -278,9 +277,9 @@ int main(int argc, char *argv[])
ESR_EC_SVC64, guest_svc_handler);
for (stage = 0; stage < 11; stage++) {
vcpu_run(vm, VCPU_ID);
vcpu_run(vm, vcpu->id);
switch (get_ucall(vm, VCPU_ID, &uc)) {
switch (get_ucall(vm, vcpu->id, &uc)) {
case UCALL_SYNC:
TEST_ASSERT(uc.args[1] == stage,
"Stage %d: Unexpected sync ucall, got %lx",
......
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