mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 00:38:28 +00:00
HV: trusty: new hypercall to save/restore context of secure world
New field in VM's structure: sworld_snapshot: save cpu_context of secure world. New hypercall: HC_SAVE_RESTORE_SWORLD_CTX In UOS S3 suspend path: trusty kernel driver will call this hypercall to require Hypervisor save context of secure world. In UOS S3 resume path: virtual firmware will call this hypercall to require Hypervisor restore context of secure world. New bit in secure_world_control.flag: ctx_saved: indicate whether cpu_context of secure world is saved. Signed-off-by: Qi Yadong <yadong.qi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -29,7 +29,8 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
|
||||
}
|
||||
|
||||
if (!is_vm0(vm) && hypcall_id != HC_WORLD_SWITCH &&
|
||||
hypcall_id != HC_INITIALIZE_TRUSTY) {
|
||||
hypcall_id != HC_INITIALIZE_TRUSTY &&
|
||||
hypcall_id != HC_SAVE_RESTORE_SWORLD_CTX) {
|
||||
pr_err("hypercall %d is only allowed from VM0!\n", hypcall_id);
|
||||
goto out;
|
||||
}
|
||||
@@ -170,6 +171,10 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
|
||||
ret = hcall_get_cpu_pm_state(vm, param1, param2);
|
||||
break;
|
||||
|
||||
case HC_SAVE_RESTORE_SWORLD_CTX:
|
||||
ret = hcall_save_restore_sworld_ctx(vcpu);
|
||||
break;
|
||||
|
||||
default:
|
||||
pr_err("op %d: Invalid hypercall\n", hypcall_id);
|
||||
ret = -EPERM;
|
||||
|
@@ -494,6 +494,30 @@ void trusty_set_dseed(void *dseed, uint8_t dseed_num)
|
||||
dseed, sizeof(struct seed_info) * dseed_num);
|
||||
}
|
||||
|
||||
void save_sworld_context(struct vcpu *vcpu)
|
||||
{
|
||||
memcpy_s(&vcpu->vm->sworld_snapshot,
|
||||
sizeof(struct cpu_context),
|
||||
&vcpu->arch_vcpu.contexts[SECURE_WORLD],
|
||||
sizeof(struct cpu_context));
|
||||
}
|
||||
|
||||
void restore_sworld_context(struct vcpu *vcpu)
|
||||
{
|
||||
struct secure_world_control *sworld_ctl =
|
||||
&vcpu->vm->sworld_control;
|
||||
|
||||
create_secure_world_ept(vcpu->vm,
|
||||
sworld_ctl->sworld_memory.base_gpa_in_uos,
|
||||
sworld_ctl->sworld_memory.length,
|
||||
TRUSTY_EPT_REBASE_GPA);
|
||||
|
||||
memcpy_s(&vcpu->arch_vcpu.contexts[SECURE_WORLD],
|
||||
sizeof(struct cpu_context),
|
||||
&vcpu->vm->sworld_snapshot,
|
||||
sizeof(struct cpu_context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ // End of trusty_apis
|
||||
|
Reference in New Issue
Block a user