Skip to content

Commit

Permalink
check validity of 'VM-exit Int-Info' before extracting vector
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
yonghuah authored and jren1 committed May 15, 2018
1 parent fdfb71e commit 3c119e1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
40 changes: 20 additions & 20 deletions hypervisor/arch/x86/interrupt.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/arch/x86/vmexit.c
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/include/arch/x86/guest/vcpu.h
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions hypervisor/include/arch/x86/vmx.h
Expand Up @@ -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
Expand Down

0 comments on commit 3c119e1

Please sign in to comment.