- clear run context when reset vcpu;
- destroy trusty without erase trusty memory when reset vm;
changelog:
v1 -> v2: fix misra violation on calling memset();
Signed-off-by: Sun Victor <victor.sun@...>
Signed-off-by: Yin Fengwei <fengwei.yin@...>
---
hypervisor/arch/x86/guest/vcpu.c | 7 +++++++
hypervisor/arch/x86/guest/vm.c | 2 ++
2 files changed, 9 insertions(+)
diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c
index 9dc0241..a6746d2 100644
--- a/hypervisor/arch/x86/guest/vcpu.c
+++ b/hypervisor/arch/x86/guest/vcpu.c
@@ -396,6 +396,7 @@ void destroy_vcpu(struct vcpu *vcpu)
*/
void reset_vcpu(struct vcpu *vcpu)
{
+ int i;
struct acrn_vlapic *vlapic;
pr_dbg("vcpu%hu reset", vcpu->vcpu_id);
@@ -419,6 +420,12 @@ void reset_vcpu(struct vcpu *vcpu)
vcpu->arch_vcpu.inject_event_pending = false;
(void)memset(vcpu->arch_vcpu.vmcs, 0U, CPU_PAGE_SIZE);
+ for (i = 0; i < NR_WORLD; i++) {
+ (void)memset(&vcpu->arch_vcpu.contexts[i], 0U,
+ sizeof(struct run_context));
+ }
+ vcpu->arch_vcpu.cur_context = NORMAL_WORLD;
+
vlapic = vcpu->arch_vcpu.vlapic;
vlapic_reset(vlapic);
}
diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c
index 4bfda8e..f2efbf9 100644
--- a/hypervisor/arch/x86/guest/vm.c
+++ b/hypervisor/arch/x86/guest/vm.c
@@ -366,6 +366,8 @@ int reset_vm(struct vm *vm)
}
vioapic_reset(vm->arch_vm.virt_ioapic);
+ destroy_secure_world(vm, false);
+ vm->sworld_control.flag.active = 0UL;
start_vm(vm);
return 0;
--
2.7.4