hv: add hypercall to set vcpu init state

DM will use this hypercall to initialize the UOS BSP state.

Tracked-On: #1231
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yin Fengwei
2018-10-03 19:29:01 +08:00
committed by wenlingz
parent 66b53f8248
commit 3cfbc004f5
5 changed files with 72 additions and 0 deletions

View File

@@ -297,6 +297,40 @@ int32_t hcall_pulse_irqline(struct vm *vm, uint16_t vmid, uint64_t param)
return ret;
}
/**
*@pre Pointer vm shall point to VM0
*/
int32_t hcall_set_vcpu_regs(struct vm *vm, uint16_t vmid, uint64_t param)
{
struct vm *target_vm = get_vm_from_vmid(vmid);
struct acrn_set_vcpu_regs vcpu_regs;
struct vcpu *vcpu;
if ((target_vm == NULL) || (param == 0U) || is_vm0(target_vm)) {
return -1;
}
/* Only allow setup init ctx while target_vm is inactive */
if (target_vm->state == VM_STARTED) {
return -1;
}
if (copy_from_gpa(vm, &vcpu_regs, param, sizeof(vcpu_regs)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);
return -1;
}
vcpu = vcpu_from_vid(target_vm, vcpu_regs.vcpu_id);
if (vcpu == NULL) {
pr_err("%s: invalid vcpu_id for set_vcpu_regs\n", __func__);
return -1;
}
set_vcpu_regs(vcpu, &(vcpu_regs.vcpu_regs));
return 0;
}
/**
*@pre Pointer vm shall point to VM0
*/