Skip to content

Commit

Permalink
vm_arm: add helper function vm_get_boot_vcpu()
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed May 4, 2023
1 parent cd0869a commit 6b6af16
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions components/VM_Arm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ int get_crossvm_irq_num(void)
return free_plat_interrupts[0];
}

static vm_vcpu_t *vm_get_boot_vcpu(vm_t *vm, const vm_config_t *vm_config)
{
assert(BOOT_VCPU < vm_config->num_vcpus);
assert(BOOT_VCPU < ARRAY_SIZE(vm->vcpus));
return vm->vcpus[BOOT_VCPU];
}

static int _dma_morecore(size_t min_size, int cached, struct dma_mem_descriptor *dma_desc)
{
static uint32_t _vaddr = DMA_VSTART;
Expand Down Expand Up @@ -666,8 +673,9 @@ static void irq_handler(void *data, ps_irq_acknowledge_fn_t acknowledge_fn, void
/* Fill in the rest of the details */
token->acknowledge_fn = acknowledge_fn;
token->ack_data = ack_data;
int err;
err = vm_inject_irq(token->vm->vcpus[BOOT_VCPU], token->virq);
vm_vcpu_t *vcpu_boot = vm_get_boot_vcpu(token->vm, &vm_config);
assert(vcpu_boot);
int err = vm_inject_irq(vcpu_boot, token->virq);
if (err) {
ZF_LOGW("IRQ %d Dropped", token->virq);
}
Expand Down Expand Up @@ -979,7 +987,8 @@ static int load_vm_images(vm_t *vm, const vm_config_t *vm_config)
}

/* Set boot arguments */
err = vcpu_set_bootargs(vm->vcpus[BOOT_VCPU], entry, MACH_TYPE, dtb);
vm_vcpu_t *vcpu_boot = vm_get_boot_vcpu(vm, vm_config);
err = vcpu_set_bootargs(vcpu_boot, entry, MACH_TYPE, dtb);
if (err) {
printf("Error: Failed to set boot arguments\n");
return -1;
Expand Down Expand Up @@ -1247,14 +1256,15 @@ static int main_continued(void)
}
}

vm_vcpu_t *vm_vcpu = vm.vcpus[BOOT_VCPU];
err = vm_assign_vcpu_target(vm_vcpu, 0);
vm_vcpu_t *vcpu_boot = vm_get_boot_vcpu(&vm, &vm_config);
assert(vcpu_boot);
err = vm_assign_vcpu_target(vcpu_boot, 0);
if (err) {
return -1;
}

/* Route IRQs */
err = route_irqs(vm_vcpu, _irq_server);
err = route_irqs(vcpu_boot, _irq_server);
if (err) {
return -1;
}
Expand All @@ -1275,7 +1285,7 @@ static int main_continued(void)
return -1;
}

err = vcpu_start(vm_vcpu);
err = vcpu_start(vcpu_boot);
if (err) {
ZF_LOGE("Failed to start Boot VCPU");
return -1;
Expand Down

0 comments on commit 6b6af16

Please sign in to comment.