From 76e43ac7cec62bc7fb6bb702fdbee5166eafb55b Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Mon, 13 Aug 2018 15:44:46 +0800 Subject: [PATCH] HV: handle trusty on vm reset - 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 Signed-off-by: Yin Fengwei Reviewed-by: Chi Mingqiang Acked-by: Eddie Dong --- 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 9dc0241d6..a6746d258 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 4bfda8eee..f2efbf9e7 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;