mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-18 19:57:31 +00:00
HV: inject exception for invalid vmcall
For non-trusty hypercalls, HV should inject #GP(0) to vCPU if they are from non-ring0 or inject #UD if they are from ring0 of non-SOS. Also we should not modify RAX of vCPU for these invalid vmcalls. Tracked-On: #3497 Signed-off-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
c4f6681045
commit
901a65cb53
@ -233,6 +233,7 @@ int32_t vmcall_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
|
||||
if (!is_hypercall_from_ring0()) {
|
||||
pr_err("hypercall is only allowed from RING-0!\n");
|
||||
vcpu_inject_gp(vcpu, 0U);
|
||||
ret = -EACCES;
|
||||
} else if (hypcall_id == HC_WORLD_SWITCH) {
|
||||
ret = hcall_world_switch(vcpu);
|
||||
@ -248,10 +249,13 @@ int32_t vmcall_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
ret = dispatch_sos_hypercall(vcpu);
|
||||
} else {
|
||||
pr_err("hypercall %d is only allowed from SOS_VM!\n", hypcall_id);
|
||||
vcpu_inject_ud(vcpu);
|
||||
ret = -ENODEV;
|
||||
}
|
||||
|
||||
vcpu_set_gpreg(vcpu, CPU_REG_RAX, (uint64_t)ret);
|
||||
if ((ret != -EACCES) && (ret != -ENODEV)) {
|
||||
vcpu_set_gpreg(vcpu, CPU_REG_RAX, (uint64_t)ret);
|
||||
}
|
||||
TRACE_2L(TRACE_VMEXIT_VMCALL, vm->vm_id, hypcall_id);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user