ia64/xen-unstable

changeset 9952:0c586a81d941

Fix injection of guest faults resulting from failed injection of a
previous event. We enter an infinite loop if the original failed
injection cannot be fixed up by Xen (e.g., because it's not a shadow
pagetable issue).

The RHEL4 HVM guest hang issue was actually a side effect of
change-set 9699. In the rhel4 guest hang rc.sysinit init-script was
calls kmodule program to probe the hardware. The kmodule uses the kudzu
library call probeDevices(). For probing the graphics hardware in the
vbe_get_mode_info() function, sets up the environment and goes into the
vm86 mode to do the int x10 call. For returning back to protected mode
it sets up a int 0xff call. At the time of calling the int 0xff the
guest process pages were not filled up. And it was causing an infinite
loop of vmexits with the IDT_VECTORING_INFO on the int 0xff instruction.

The reason for the infinite loop is changeset 9699. With that
the guest page fault was always getting overridden by the int 0xff gp
fault coming from the IDT_VECTORING_INFO. With the attached patch if VMM
is injecting exceptions like page faults or gp faults then
IDT_VECTORING_INFO field does not override it, and that breaks the
vmexit infinite loop for the rhel4.

Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri May 05 14:05:31 2006 +0100 (2006-05-05)
parents 7801e09f518c
children 98f00a4ee0b4
files xen/arch/x86/hvm/vmx/io.c xen/include/asm-x86/hvm/vmx/vmcs.h xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/io.c	Fri May 05 14:01:43 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/io.c	Fri May 05 14:05:31 2006 +0100
     1.3 @@ -166,20 +166,26 @@ asmlinkage void vmx_intr_assist(void)
     1.4      }
     1.5  
     1.6      has_ext_irq = cpu_has_pending_irq(v);
     1.7 +
     1.8 +    if (unlikely(v->arch.hvm_vmx.vector_injected)) {
     1.9 +        v->arch.hvm_vmx.vector_injected=0;
    1.10 +        if (unlikely(has_ext_irq)) enable_irq_window(v);
    1.11 +        return;
    1.12 +    }
    1.13 +
    1.14      __vmread(IDT_VECTORING_INFO_FIELD, &idtv_info_field);
    1.15 -    if (idtv_info_field & INTR_INFO_VALID_MASK) {
    1.16 +    if (unlikely(idtv_info_field & INTR_INFO_VALID_MASK)) {
    1.17          __vmwrite(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field);
    1.18  
    1.19          __vmread(VM_EXIT_INSTRUCTION_LEN, &inst_len);
    1.20 -        if (inst_len >= 1 && inst_len <= 15)
    1.21 -            __vmwrite(VM_ENTRY_INSTRUCTION_LEN, inst_len);
    1.22 +        __vmwrite(VM_ENTRY_INSTRUCTION_LEN, inst_len);
    1.23  
    1.24 -        if (idtv_info_field & 0x800) { /* valid error code */
    1.25 +        if (unlikely(idtv_info_field & 0x800)) { /* valid error code */
    1.26              unsigned long error_code;
    1.27              __vmread(IDT_VECTORING_ERROR_CODE, &error_code);
    1.28              __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
    1.29          }
    1.30 -        if ( has_ext_irq )
    1.31 +        if (unlikely(has_ext_irq))
    1.32              enable_irq_window(v);
    1.33  
    1.34          HVM_DBG_LOG(DBG_LEVEL_1, "idtv_info_field=%x", idtv_info_field);
    1.35 @@ -187,8 +193,9 @@ asmlinkage void vmx_intr_assist(void)
    1.36          return;
    1.37      }
    1.38  
    1.39 -    if ( !has_ext_irq ) return;
    1.40 -    if ( is_interruptibility_state() ) {    /* pre-cleared for emulated instruction */
    1.41 +    if (likely(!has_ext_irq)) return;
    1.42 +
    1.43 +    if (unlikely(is_interruptibility_state())) {    /* pre-cleared for emulated instruction */
    1.44          enable_irq_window(v);
    1.45          HVM_DBG_LOG(DBG_LEVEL_1, "interruptibility");
    1.46          return;
     2.1 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h	Fri May 05 14:01:43 2006 +0100
     2.2 +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h	Fri May 05 14:05:31 2006 +0100
     2.3 @@ -68,6 +68,7 @@ struct arch_vmx_struct {
     2.4      struct vmcs_struct      *vmcs;  /* VMCS pointer in virtual. */
     2.5      unsigned int            launch_cpu; /* VMCS is valid on this CPU. */
     2.6      u32                     exec_control; /* cache of cpu execution control */
     2.7 +    u32                     vector_injected; /* if there is vector installed in the INTR_INFO_FIELD */
     2.8      unsigned long           flags;  /* VMCS flags */
     2.9      unsigned long           cpu_cr0; /* copy of guest CR0 */
    2.10      unsigned long           cpu_shadow_cr0; /* copy of guest read shadow CR0 */
     3.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Fri May 05 14:01:43 2006 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Fri May 05 14:05:31 2006 +0100
     3.3 @@ -444,6 +444,7 @@ static inline int __vmx_inject_exception
     3.4  
     3.5  static inline int vmx_inject_exception(struct vcpu *v, int trap, int error_code)
     3.6  {
     3.7 +    v->arch.hvm_vmx.vector_injected = 1;
     3.8      return __vmx_inject_exception(v, trap, INTR_TYPE_EXCEPTION, error_code);
     3.9  }
    3.10