hv: Add split-lock emulation for LOCK prefix instruction

This patch adds the split-lock emulation.
If a #AC is caused by instruction with LOCK prefix then
emulate it, otherwise, inject it back as it used to be.

 1. Kick other vcpus of the guest to stop execution
    and set the TF flag to have #DB if the guest has more
    than one vcpu.

 2. Skip over the LOCK prefix and resume the current
    vcpu back to guest for execution.

 3. Notify other vcpus to restart exception at the end
    of handling the #DB since we have completed
    the LOCK prefix instruction emulation.

Tracked-On: #5605
Signed-off-by: Jie Deng <jie.deng@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Jie Deng
2020-10-26 15:13:08 +08:00
committed by wenlingz
parent 69b207ac6a
commit 47e193a7bb
7 changed files with 175 additions and 6 deletions

View File

@@ -53,6 +53,7 @@ bool pcpu_has_vmx_ept_cap(uint32_t bit_mask);
bool pcpu_has_vmx_vpid_cap(uint32_t bit_mask);
bool is_apl_platform(void);
bool has_core_cap(uint32_t bit_mask);
bool is_ac_enabled(void);
void init_pcpu_capabilities(void);
void init_pcpu_model_name(void);
int32_t detect_hardware_support(void);

View File

@@ -98,6 +98,11 @@
*/
#define ACRN_REQUEST_WAIT_WBINVD 9U
/**
* @brief Request for split lock operation
*/
#define ACRN_REQUEST_SPLIT_LOCK 10U
/**
* @}
*/
@@ -154,7 +159,9 @@ enum vm_cpu_mode {
#define VCPU_EVENT_IOREQ 0
#define VCPU_EVENT_VIRTUAL_INTERRUPT 1
#define VCPU_EVENT_SYNC_WBINVD 2
#define VCPU_EVENT_NUM 3
#define VCPU_EVENT_SPLIT_LOCK 3
#define VCPU_EVENT_NUM 4
enum reset_mode;
@@ -230,6 +237,7 @@ struct acrn_vcpu_arch {
uint8_t lapic_mask;
bool irq_window_enabled;
bool emulating_lock;
uint32_t nrexits;
/* VCPU context state information */

View File

@@ -130,6 +130,7 @@ uint32_t alloc_irq_num(uint32_t req_irq);
uint32_t alloc_irq_vector(uint32_t irq);
/* RFLAGS */
#define HV_ARCH_VCPU_RFLAGS_TF (1UL<<8U)
#define HV_ARCH_VCPU_RFLAGS_IF (1UL<<9U)
#define HV_ARCH_VCPU_RFLAGS_RF (1UL<<16U)