check validity of 'VM-exit Int-Info' before extracting vector

1. exception vector and other information
   can be extracted from 'VM-Exit Interrupt-Information'
   field of VMCS only if bit31 (Valid) is set.
   -Intel SDM 24.9.2, Vol3

2.  Rename 'exit-interrupt_info' to 'idt_vectoring_info'
    in 'struct vcpu_arch', which is consistent with
    SDM 24.9.3, Vol3

3. 'IDT-vectoring information' in VMCS is 32bit
    -Intel SDM 24.9.3, Vol3

    Update the type of 'idt_vectoring_info' in
    'struct vcpu_arch'from 'uint32_t' to 'uint64_t'.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang 2018-04-17 21:11:54 +08:00 committed by Jack Ren
parent fdfb71e075
commit 3c119e124a
4 changed files with 23 additions and 22 deletions

View File

@ -309,9 +309,9 @@ int acrn_do_intr_process(struct vcpu *vcpu)
/* handling pending vector injection:
* there are many reason inject failed, we need re-inject again
*/
if (vcpu->arch_vcpu.exit_interrupt_info & VMX_INT_INFO_VALID) {
if (vcpu->arch_vcpu.idt_vectoring_info & VMX_INT_INFO_VALID) {
exec_vmwrite(VMX_ENTRY_INT_INFO_FIELD,
vcpu->arch_vcpu.exit_interrupt_info);
vcpu->arch_vcpu.idt_vectoring_info);
goto INTR_WIN;
}
@ -419,8 +419,8 @@ void cancel_event_injection(struct vcpu *vcpu)
int exception_vmexit_handler(struct vcpu *vcpu)
{
uint32_t intinfo, int_err_code;
uint32_t exception_vector;
uint32_t intinfo, int_err_code = 0;
int32_t exception_vector = -1;
uint32_t cpl;
int status = 0;
@ -436,24 +436,24 @@ int exception_vmexit_handler(struct vcpu *vcpu)
/* Obtain VM-Exit information field pg 2912 */
intinfo = exec_vmread(VMX_EXIT_INT_INFO);
exception_vector = intinfo & 0xFF;
/* Check if exception caused by the guest is a HW exception. If the
* exit occurred due to a HW exception obtain the error code to be
* conveyed to get via the stack
*/
if (intinfo & VMX_INT_INFO_ERR_CODE_VALID) {
int_err_code = exec_vmread(VMX_EXIT_INT_EC);
if (intinfo & VMX_INT_INFO_VALID) {
exception_vector = intinfo & 0xFF;
/* Check if exception caused by the guest is a HW exception.
* If the exit occurred due to a HW exception obtain the
* error code to be conveyed to get via the stack
*/
if (intinfo & VMX_INT_INFO_ERR_CODE_VALID) {
int_err_code = exec_vmread(VMX_EXIT_INT_EC);
/* get current privilege level and fault address */
cpl = exec_vmread(VMX_GUEST_CS_ATTR);
cpl = (cpl >> 5) & 3;
/* get current privilege level and fault address */
cpl = exec_vmread(VMX_GUEST_CS_ATTR);
cpl = (cpl >> 5) & 3;
if (cpl < 3)
int_err_code &= ~4;
else
int_err_code |= 4;
} else {
int_err_code = 0;
if (cpl < 3)
int_err_code &= ~4;
else
int_err_code |= 4;
}
}
/* Handle all other exceptions */

View File

@ -162,7 +162,7 @@ struct vm_exit_dispatch *vmexit_handler(struct vcpu *vcpu)
uint16_t basic_exit_reason;
/* Obtain interrupt info */
vcpu->arch_vcpu.exit_interrupt_info =
vcpu->arch_vcpu.idt_vectoring_info =
exec_vmread(VMX_IDT_VEC_INFO_FIELD);
/* Calculate basic exit reason (low 16-bits) */

View File

@ -215,7 +215,7 @@ struct vcpu_arch {
/* VCPU context state information */
uint32_t exit_reason;
uint64_t exit_interrupt_info;
uint32_t idt_vectoring_info;
uint64_t exit_qualification;
uint32_t inst_len;

View File

@ -376,6 +376,7 @@
/* VMX entry/exit Interrupt info */
#define VMX_INT_INFO_ERR_CODE_VALID (1<<11)
#define VMX_INT_INFO_VALID (1<<31)
#define VMX_INT_TYPE_MASK (0x700)
#define VMX_INT_TYPE_EXT_INT 0
#define VMX_INT_TYPE_NMI 2
#define VMX_INT_TYPE_HW_EXP 3