Re: [PATCH v2 2/2] HV: Reset physical core of lapic_pt vm when shutdown


Eddie Dong
 

-----Original Message-----
From: acrn-dev@... [mailto:acrn-dev@...]
On Behalf Of Kaige Fu
Sent: Wednesday, April 10, 2019 12:45 AM
To: acrn-dev@...
Subject: [acrn-dev] [PATCH v2 2/2] HV: Reset physical core of lapic_pt vm
when shutdown

The physical core of lapic_pt vm should be reset for security and correctness
when shutdown the vm.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/cpu.c | 2 +-
hypervisor/arch/x86/guest/vm.c | 8 ++++++++
hypervisor/include/arch/x86/cpu.h | 1 +
3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index
1a4966e8..b46cae4d 100644
--- a/hypervisor/arch/x86/cpu.c
+++ b/hypervisor/arch/x86/cpu.c
@@ -259,7 +259,7 @@ static uint16_t get_cpu_id_from_lapic_id(uint32_t
lapic_id)
return pcpu_id;
}

-static void start_cpu(uint16_t pcpu_id)
+void start_cpu(uint16_t pcpu_id)
{
uint32_t timeout;

diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c
index cbc70785..4c24f573 100644
--- a/hypervisor/arch/x86/guest/vm.c
+++ b/hypervisor/arch/x86/guest/vm.c
@@ -496,6 +496,14 @@ int32_t shutdown_vm(struct acrn_vm *vm)
foreach_vcpu(i, vm, vcpu) {
reset_vcpu(vcpu);
offline_vcpu(vcpu);
+
+ /* All pcpu of lapic_pt vm should be reset for security and
correctness */
+ if (is_lapic_pt(vm)) {
+ make_pcpu_offline(vcpu->pcpu_id);
Not sure how you address the following issues:
make_pcpu_offline relies on send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU), which further relies on the scheduler to tick to execute cpu_dead()... In this case, the caller PCPU needs to wait till the target PCPU is VMX off. I didn't see this waiting mechanism... Did I miss something?


+ start_cpu(vcpu->pcpu_id);
+ } else {
+ /* No other state currently, do nothing */
+ }
}

ptdev_release_all_entries(vm);
diff --git a/hypervisor/include/arch/x86/cpu.h
b/hypervisor/include/arch/x86/cpu.h
index 13c2fd9e..5eca144f 100644
--- a/hypervisor/include/arch/x86/cpu.h
+++ b/hypervisor/include/arch/x86/cpu.h
@@ -259,6 +259,7 @@ void trampoline_start16(void); void
load_cpu_state_data(void); void init_cpu_pre(uint16_t pcpu_id_args); void
init_cpu_post(uint16_t pcpu_id);
+void start_cpu(uint16_t pcpu_id);
void start_cpus(void);
void stop_cpus(void);
void wait_sync_change(uint64_t *sync, uint64_t wake_sync);
--
2.20.0


Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.