hv: implement NEED_SHUTDOWN_VM request to idle thread

For pre-launched VMs and SOS, VM shutdown should not be executed in the
current VM context.

- implement NEED_SHUTDOWN_VM request so that the BSP of the target VM can shut
  down the guest in idle thread.
- implement shutdown_vm_from_idle() to shut down target VM.

Tracked-On: #2700
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Zide Chen
2019-02-27 09:54:58 -08:00
committed by wenlingz
parent db952315c5
commit 8ad0fd98a3
7 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef VM_RESET_H_
#define VM_RESET_H_
void shutdown_vm_from_idle(uint16_t pcpu_id);
#endif /* VM_RESET_H_ */

View File

@@ -18,6 +18,7 @@
#include <gdt.h>
#include <schedule.h>
#include <security.h>
#include <vm_config.h>
struct per_cpu_region {
/* vmxon_region MUST be 4KB-aligned */
@@ -52,6 +53,7 @@ struct per_cpu_region {
#ifdef PROFILING_ON
struct profiling_info_wrapper profiling_info;
#endif
uint16_t shutdown_vm_id;
} __aligned(PAGE_SIZE); /* per_cpu_region size aligned with PAGE_SIZE */
extern struct per_cpu_region per_cpu_data[CONFIG_MAX_PCPU_NUM];

View File

@@ -10,6 +10,7 @@
#define NEED_RESCHEDULE (1U)
#define NEED_OFFLINE (2U)
#define NEED_SHUTDOWN_VM (3U)
#define DEL_MODE_INIT (1U)
#define DEL_MODE_IPI (2U)
@@ -50,6 +51,8 @@ void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode);
bool need_reschedule(uint16_t pcpu_id);
void make_pcpu_offline(uint16_t pcpu_id);
int32_t need_offline(uint16_t pcpu_id);
void make_shutdown_vm_request(uint16_t pcpu_id);
bool need_shutdown_vm(uint16_t pcpu_id);
void schedule(void);
void run_sched_thread(struct sched_object *obj);