direct-io.hg

changeset 11637:88418d7f22f2

[HVM] Avoid mis-optimisation of the SVM/VMX exit handlers
by passing a *pointer* to the register state, instead of
'passing by value'.

This should fix the bugs resulting in display of
"trying to set reserved bit in EFER"
on the Xen console.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Sep 28 11:25:15 2006 +0100 (2006-09-28)
parents e759cc598822
children c40ea583941c
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/x86_32/exits.S xen/arch/x86/hvm/svm/x86_64/exits.S xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/hvm/vmx/x86_32/exits.S xen/arch/x86/hvm/vmx/x86_64/exits.S xen/include/asm-x86/hvm/support.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Thu Sep 28 10:10:59 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Thu Sep 28 11:25:15 2006 +0100
     1.3 @@ -2564,9 +2564,7 @@ void walk_shadow_and_guest_pt(unsigned l
     1.4  #endif /* SVM_WALK_GUEST_PAGES */
     1.5  
     1.6  
     1.7 -
     1.8 -
     1.9 -asmlinkage void svm_vmexit_handler(struct cpu_user_regs regs)
    1.10 +asmlinkage void svm_vmexit_handler(struct cpu_user_regs *regs)
    1.11  {
    1.12      unsigned int exit_reason;
    1.13      unsigned long eip;
    1.14 @@ -2578,7 +2576,7 @@ asmlinkage void svm_vmexit_handler(struc
    1.15      ASSERT(vmcb);
    1.16  
    1.17      exit_reason = vmcb->exitcode;
    1.18 -    save_svm_cpu_user_regs(v, &regs);
    1.19 +    save_svm_cpu_user_regs(v, regs);
    1.20  
    1.21      vmcb->tlb_control = 1;
    1.22  
    1.23 @@ -2602,26 +2600,26 @@ asmlinkage void svm_vmexit_handler(struc
    1.24              if (svm_paging_enabled(v) && 
    1.25                  !mmio_space(shadow_gva_to_gpa(current, vmcb->exitinfo2)))
    1.26              {
    1.27 -                printk("I%08ld,ExC=%s(%d),IP=%x:%llx,"
    1.28 -                       "I1=%llx,I2=%llx,INT=%llx, "
    1.29 -                       "gpa=%llx\n", intercepts_counter,
    1.30 -                       exit_reasons[exit_reason], exit_reason, regs.cs,
    1.31 -                       (unsigned long long) regs.rip,
    1.32 -                       (unsigned long long) vmcb->exitinfo1,
    1.33 -                       (unsigned long long) vmcb->exitinfo2,
    1.34 -                       (unsigned long long) vmcb->exitintinfo.bytes,
    1.35 -                       (unsigned long long) shadow_gva_to_gpa(current, vmcb->exitinfo2));
    1.36 +                printk("I%08ld,ExC=%s(%d),IP=%x:%"PRIx64","
    1.37 +                       "I1=%"PRIx64",I2=%"PRIx64",INT=%"PRIx64", "
    1.38 +                       "gpa=%"PRIx64"\n", intercepts_counter,
    1.39 +                       exit_reasons[exit_reason], exit_reason, regs->cs,
    1.40 +                       (u64)regs->rip,
    1.41 +                       (u64)vmcb->exitinfo1,
    1.42 +                       (u64)vmcb->exitinfo2,
    1.43 +                       (u64)vmcb->exitintinfo.bytes,
    1.44 +                       (u64)shadow_gva_to_gpa(current, vmcb->exitinfo2));
    1.45              }
    1.46              else 
    1.47              {
    1.48 -                printk("I%08ld,ExC=%s(%d),IP=%x:%llx,"
    1.49 -                       "I1=%llx,I2=%llx,INT=%llx\n", 
    1.50 +                printk("I%08ld,ExC=%s(%d),IP=%x:%"PRIx64","
    1.51 +                       "I1=%"PRIx64",I2=%"PRIx64",INT=%"PRIx64"\n", 
    1.52                         intercepts_counter,
    1.53 -                       exit_reasons[exit_reason], exit_reason, regs.cs,
    1.54 -                       (unsigned long long) regs.rip,
    1.55 -                       (unsigned long long) vmcb->exitinfo1,
    1.56 -                       (unsigned long long) vmcb->exitinfo2,
    1.57 -                       (unsigned long long) vmcb->exitintinfo.bytes );
    1.58 +                       exit_reasons[exit_reason], exit_reason, regs->cs,
    1.59 +                       (u64)regs->rip,
    1.60 +                       (u64)vmcb->exitinfo1,
    1.61 +                       (u64)vmcb->exitinfo2,
    1.62 +                       (u64)vmcb->exitintinfo.bytes );
    1.63              }
    1.64          } 
    1.65          else if ( svm_dbg_on 
    1.66 @@ -2631,24 +2629,24 @@ asmlinkage void svm_vmexit_handler(struc
    1.67  
    1.68              if (exit_reasons[exit_reason])
    1.69              {
    1.70 -                printk("I%08ld,ExC=%s(%d),IP=%x:%llx,"
    1.71 -                       "I1=%llx,I2=%llx,INT=%llx\n", 
    1.72 +                printk("I%08ld,ExC=%s(%d),IP=%x:%"PRIx64","
    1.73 +                       "I1=%"PRIx64",I2=%"PRIx64",INT=%"PRIx64"\n", 
    1.74                         intercepts_counter,
    1.75 -                       exit_reasons[exit_reason], exit_reason, regs.cs,
    1.76 -                       (unsigned long long) regs.rip,
    1.77 -                       (unsigned long long) vmcb->exitinfo1,
    1.78 -                       (unsigned long long) vmcb->exitinfo2,
    1.79 -                       (unsigned long long) vmcb->exitintinfo.bytes);
    1.80 +                       exit_reasons[exit_reason], exit_reason, regs->cs,
    1.81 +                       (u64)regs->rip,
    1.82 +                       (u64)vmcb->exitinfo1,
    1.83 +                       (u64)vmcb->exitinfo2,
    1.84 +                       (u64)vmcb->exitintinfo.bytes);
    1.85              } 
    1.86              else 
    1.87              {
    1.88 -                printk("I%08ld,ExC=%d(0x%x),IP=%x:%llx,"
    1.89 -                       "I1=%llx,I2=%llx,INT=%llx\n", 
    1.90 -                       intercepts_counter, exit_reason, exit_reason, regs.cs, 
    1.91 -                       (unsigned long long) regs.rip,
    1.92 -                       (unsigned long long) vmcb->exitinfo1,
    1.93 -                       (unsigned long long) vmcb->exitinfo2,
    1.94 -                       (unsigned long long) vmcb->exitintinfo.bytes);
    1.95 +                printk("I%08ld,ExC=%d(0x%x),IP=%x:%"PRIx64","
    1.96 +                       "I1=%"PRIx64",I2=%"PRIx64",INT=%"PRIx64"\n", 
    1.97 +                       intercepts_counter, exit_reason, exit_reason, regs->cs, 
    1.98 +                       (u64)regs->rip,
    1.99 +                       (u64)vmcb->exitinfo1,
   1.100 +                       (u64)vmcb->exitinfo2,
   1.101 +                       (u64)vmcb->exitintinfo.bytes);
   1.102              }
   1.103          }
   1.104  
   1.105 @@ -2680,7 +2678,7 @@ asmlinkage void svm_vmexit_handler(struc
   1.106                     (int) v->arch.shadow_table.pfn);
   1.107  
   1.108              svm_dump_vmcb(__func__, vmcb);
   1.109 -            svm_dump_regs(__func__, &regs);
   1.110 +            svm_dump_regs(__func__, regs);
   1.111              svm_dump_inst(svm_rip2pointer(vmcb));
   1.112          }
   1.113  
   1.114 @@ -2710,18 +2708,18 @@ asmlinkage void svm_vmexit_handler(struc
   1.115      case VMEXIT_EXCEPTION_DB:
   1.116      {
   1.117  #ifdef XEN_DEBUGGER
   1.118 -        svm_debug_save_cpu_user_regs(&regs);
   1.119 -        pdb_handle_exception(1, &regs, 1);
   1.120 -        svm_debug_restore_cpu_user_regs(&regs);
   1.121 +        svm_debug_save_cpu_user_regs(regs);
   1.122 +        pdb_handle_exception(1, regs, 1);
   1.123 +        svm_debug_restore_cpu_user_regs(regs);
   1.124  #else
   1.125 -        svm_store_cpu_user_regs(&regs, v);
   1.126 +        svm_store_cpu_user_regs(regs, v);
   1.127          domain_pause_for_debugger();  
   1.128  #endif
   1.129      }
   1.130      break;
   1.131  
   1.132      case VMEXIT_NMI:
   1.133 -        do_nmi(&regs, 0);
   1.134 +        do_nmi(regs, 0);
   1.135          break;
   1.136  
   1.137      case VMEXIT_SMI:
   1.138 @@ -2741,9 +2739,9 @@ asmlinkage void svm_vmexit_handler(struc
   1.139  
   1.140      case VMEXIT_EXCEPTION_BP:
   1.141  #ifdef XEN_DEBUGGER
   1.142 -        svm_debug_save_cpu_user_regs(&regs);
   1.143 -        pdb_handle_exception(3, &regs, 1);
   1.144 -        svm_debug_restore_cpu_user_regs(&regs);
   1.145 +        svm_debug_save_cpu_user_regs(regs);
   1.146 +        pdb_handle_exception(3, regs, 1);
   1.147 +        svm_debug_restore_cpu_user_regs(regs);
   1.148  #else
   1.149          if ( test_bit(_DOMF_debugging, &v->domain->domain_flags) )
   1.150              domain_pause_for_debugger();
   1.151 @@ -2758,25 +2756,25 @@ asmlinkage void svm_vmexit_handler(struc
   1.152  
   1.153      case VMEXIT_EXCEPTION_GP:
   1.154          /* This should probably not be trapped in the future */
   1.155 -        regs.error_code = vmcb->exitinfo1;
   1.156 -        svm_do_general_protection_fault(v, &regs);
   1.157 +        regs->error_code = vmcb->exitinfo1;
   1.158 +        svm_do_general_protection_fault(v, regs);
   1.159          break;  
   1.160  
   1.161      case VMEXIT_EXCEPTION_PF:
   1.162      {
   1.163          unsigned long va;
   1.164          va = vmcb->exitinfo2;
   1.165 -        regs.error_code = vmcb->exitinfo1;
   1.166 +        regs->error_code = vmcb->exitinfo1;
   1.167          HVM_DBG_LOG(DBG_LEVEL_VMMU, 
   1.168                      "eax=%lx, ebx=%lx, ecx=%lx, edx=%lx, esi=%lx, edi=%lx",
   1.169 -                    (unsigned long)regs.eax, (unsigned long)regs.ebx,
   1.170 -                    (unsigned long)regs.ecx, (unsigned long)regs.edx,
   1.171 -                    (unsigned long)regs.esi, (unsigned long)regs.edi);
   1.172 -
   1.173 -        if (!(error = svm_do_page_fault(va, &regs))) 
   1.174 +                    (unsigned long)regs->eax, (unsigned long)regs->ebx,
   1.175 +                    (unsigned long)regs->ecx, (unsigned long)regs->edx,
   1.176 +                    (unsigned long)regs->esi, (unsigned long)regs->edi);
   1.177 +
   1.178 +        if (!(error = svm_do_page_fault(va, regs))) 
   1.179          {
   1.180              /* Inject #PG using Interruption-Information Fields */
   1.181 -            svm_inject_exception(v, TRAP_page_fault, 1, regs.error_code);
   1.182 +            svm_inject_exception(v, TRAP_page_fault, 1, regs->error_code);
   1.183  
   1.184              v->arch.hvm_svm.cpu_cr2 = va;
   1.185              vmcb->cr2 = va;
   1.186 @@ -2789,7 +2787,7 @@ asmlinkage void svm_vmexit_handler(struc
   1.187      case VMEXIT_EXCEPTION_DF:
   1.188          /* Debug info to hopefully help debug WHY the guest double-faulted. */
   1.189          svm_dump_vmcb(__func__, vmcb);
   1.190 -        svm_dump_regs(__func__, &regs);
   1.191 +        svm_dump_regs(__func__, regs);
   1.192          svm_dump_inst(svm_rip2pointer(vmcb));
   1.193          svm_inject_exception(v, TRAP_double_fault, 1, 0);
   1.194          break;
   1.195 @@ -2806,11 +2804,11 @@ asmlinkage void svm_vmexit_handler(struc
   1.196          break;
   1.197  
   1.198      case VMEXIT_TASK_SWITCH:
   1.199 -        __hvm_bug(&regs);
   1.200 +        __hvm_bug(regs);
   1.201          break;
   1.202  
   1.203      case VMEXIT_CPUID:
   1.204 -        svm_vmexit_do_cpuid(vmcb, regs.eax, &regs);
   1.205 +        svm_vmexit_do_cpuid(vmcb, regs->eax, regs);
   1.206          break;
   1.207  
   1.208      case VMEXIT_HLT:
   1.209 @@ -2818,60 +2816,60 @@ asmlinkage void svm_vmexit_handler(struc
   1.210          break;
   1.211  
   1.212      case VMEXIT_INVLPG:
   1.213 -        svm_handle_invlpg(0, &regs);
   1.214 +        svm_handle_invlpg(0, regs);
   1.215          break;
   1.216  
   1.217      case VMEXIT_INVLPGA:
   1.218 -        svm_handle_invlpg(1, &regs);
   1.219 +        svm_handle_invlpg(1, regs);
   1.220          break;
   1.221  
   1.222      case VMEXIT_VMMCALL:
   1.223 -        svm_do_vmmcall(v, &regs);
   1.224 +        svm_do_vmmcall(v, regs);
   1.225          break;
   1.226  
   1.227      case VMEXIT_CR0_READ:
   1.228 -        svm_cr_access(v, 0, TYPE_MOV_FROM_CR, &regs);
   1.229 +        svm_cr_access(v, 0, TYPE_MOV_FROM_CR, regs);
   1.230          break;
   1.231  
   1.232      case VMEXIT_CR2_READ:
   1.233 -        svm_cr_access(v, 2, TYPE_MOV_FROM_CR, &regs);
   1.234 +        svm_cr_access(v, 2, TYPE_MOV_FROM_CR, regs);
   1.235          break;
   1.236  
   1.237      case VMEXIT_CR3_READ:
   1.238 -        svm_cr_access(v, 3, TYPE_MOV_FROM_CR, &regs);
   1.239 +        svm_cr_access(v, 3, TYPE_MOV_FROM_CR, regs);
   1.240          break;
   1.241  
   1.242      case VMEXIT_CR4_READ:
   1.243 -        svm_cr_access(v, 4, TYPE_MOV_FROM_CR, &regs);
   1.244 +        svm_cr_access(v, 4, TYPE_MOV_FROM_CR, regs);
   1.245          break;
   1.246  
   1.247      case VMEXIT_CR8_READ:
   1.248 -        svm_cr_access(v, 8, TYPE_MOV_FROM_CR, &regs);
   1.249 +        svm_cr_access(v, 8, TYPE_MOV_FROM_CR, regs);
   1.250          break;
   1.251  
   1.252      case VMEXIT_CR0_WRITE:
   1.253 -        svm_cr_access(v, 0, TYPE_MOV_TO_CR, &regs);
   1.254 +        svm_cr_access(v, 0, TYPE_MOV_TO_CR, regs);
   1.255          break;
   1.256  
   1.257      case VMEXIT_CR2_WRITE:
   1.258 -        svm_cr_access(v, 2, TYPE_MOV_TO_CR, &regs);
   1.259 +        svm_cr_access(v, 2, TYPE_MOV_TO_CR, regs);
   1.260          break;
   1.261  
   1.262      case VMEXIT_CR3_WRITE:
   1.263 -        svm_cr_access(v, 3, TYPE_MOV_TO_CR, &regs);
   1.264 +        svm_cr_access(v, 3, TYPE_MOV_TO_CR, regs);
   1.265          local_flush_tlb();
   1.266          break;
   1.267  
   1.268      case VMEXIT_CR4_WRITE:
   1.269 -        svm_cr_access(v, 4, TYPE_MOV_TO_CR, &regs);
   1.270 +        svm_cr_access(v, 4, TYPE_MOV_TO_CR, regs);
   1.271          break;
   1.272  
   1.273      case VMEXIT_CR8_WRITE:
   1.274 -        svm_cr_access(v, 8, TYPE_MOV_TO_CR, &regs);
   1.275 +        svm_cr_access(v, 8, TYPE_MOV_TO_CR, regs);
   1.276          break;
   1.277  	
   1.278      case VMEXIT_DR0_WRITE ... VMEXIT_DR7_WRITE:
   1.279 -        svm_dr_access(v, &regs);
   1.280 +        svm_dr_access(v, regs);
   1.281          break;
   1.282  
   1.283      case VMEXIT_IOIO:
   1.284 @@ -2879,7 +2877,7 @@ asmlinkage void svm_vmexit_handler(struc
   1.285          break;
   1.286  
   1.287      case VMEXIT_MSR:
   1.288 -        svm_do_msr_access(v, &regs);
   1.289 +        svm_do_msr_access(v, regs);
   1.290          break;
   1.291  
   1.292      case VMEXIT_SHUTDOWN:
   1.293 @@ -2888,11 +2886,10 @@ asmlinkage void svm_vmexit_handler(struc
   1.294          break;
   1.295  
   1.296      default:
   1.297 -        printk("unexpected VMEXIT: exit reason = 0x%x, exitinfo1 = %llx, "
   1.298 -               "exitinfo2 = %llx\n", exit_reason, 
   1.299 -               (unsigned long long)vmcb->exitinfo1, 
   1.300 -               (unsigned long long)vmcb->exitinfo2);
   1.301 -        __hvm_bug(&regs);       /* should not happen */
   1.302 +        printk("unexpected VMEXIT: exit reason = 0x%x, exitinfo1 = %"PRIx64", "
   1.303 +               "exitinfo2 = %"PRIx64"\n", exit_reason, 
   1.304 +               (u64)vmcb->exitinfo1, (u64)vmcb->exitinfo2);
   1.305 +        __hvm_bug(regs);       /* should not happen */
   1.306          break;
   1.307      }
   1.308  
   1.309 @@ -2900,7 +2897,7 @@ asmlinkage void svm_vmexit_handler(struc
   1.310      if (do_debug) 
   1.311      {
   1.312          printk("%s: Done switch on vmexit_code\n", __func__);
   1.313 -        svm_dump_regs(__func__, &regs);
   1.314 +        svm_dump_regs(__func__, regs);
   1.315      }
   1.316  
   1.317      if (do_debug) 
     2.1 --- a/xen/arch/x86/hvm/svm/x86_32/exits.S	Thu Sep 28 10:10:59 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/x86_32/exits.S	Thu Sep 28 11:25:15 2006 +0100
     2.3 @@ -126,7 +126,10 @@ ENTRY(svm_asm_do_launch)
     2.4  
     2.5          HVM_SAVE_ALL_NOSEGREGS
     2.6          STGI
     2.7 +        movl %esp,%eax
     2.8 +        push %eax
     2.9          call svm_vmexit_handler
    2.10 +        addl $4,%esp
    2.11          jmp  svm_asm_do_resume
    2.12  
    2.13          ALIGN
     3.1 --- a/xen/arch/x86/hvm/svm/x86_64/exits.S	Thu Sep 28 10:10:59 2006 +0100
     3.2 +++ b/xen/arch/x86/hvm/svm/x86_64/exits.S	Thu Sep 28 11:25:15 2006 +0100
     3.3 @@ -144,6 +144,7 @@ ENTRY(svm_asm_do_launch)
     3.4          VMLOAD
     3.5  
     3.6          STGI
     3.7 +        movq %rsp,%rdi
     3.8          call svm_vmexit_handler
     3.9          jmp  svm_asm_do_resume
    3.10  
     4.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Sep 28 10:10:59 2006 +0100
     4.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Thu Sep 28 11:25:15 2006 +0100
     4.3 @@ -2111,7 +2111,7 @@ static void vmx_reflect_exception(struct
     4.4      }
     4.5  }
     4.6  
     4.7 -asmlinkage void vmx_vmexit_handler(struct cpu_user_regs regs)
     4.8 +asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
     4.9  {
    4.10      unsigned int exit_reason;
    4.11      unsigned long exit_qualification, rip, inst_len = 0;
    4.12 @@ -2182,16 +2182,16 @@ asmlinkage void vmx_vmexit_handler(struc
    4.13  #ifdef XEN_DEBUGGER
    4.14          case TRAP_debug:
    4.15          {
    4.16 -            save_cpu_user_regs(&regs);
    4.17 -            pdb_handle_exception(1, &regs, 1);
    4.18 -            restore_cpu_user_regs(&regs);
    4.19 +            save_cpu_user_regs(regs);
    4.20 +            pdb_handle_exception(1, regs, 1);
    4.21 +            restore_cpu_user_regs(regs);
    4.22              break;
    4.23          }
    4.24          case TRAP_int3:
    4.25          {
    4.26 -            save_cpu_user_regs(&regs);
    4.27 -            pdb_handle_exception(3, &regs, 1);
    4.28 -            restore_cpu_user_regs(&regs);
    4.29 +            save_cpu_user_regs(regs);
    4.30 +            pdb_handle_exception(3, regs, 1);
    4.31 +            restore_cpu_user_regs(regs);
    4.32              break;
    4.33          }
    4.34  #else
    4.35 @@ -2201,7 +2201,7 @@ asmlinkage void vmx_vmexit_handler(struc
    4.36  
    4.37              if ( test_bit(_DOMF_debugging, &v->domain->domain_flags) )
    4.38              {
    4.39 -                store_cpu_user_regs(&regs);
    4.40 +                store_cpu_user_regs(regs);
    4.41                  domain_pause_for_debugger();
    4.42                  __vm_clear_bit(GUEST_PENDING_DBG_EXCEPTIONS,
    4.43                                 PENDING_DEBUG_EXC_BS);
    4.44 @@ -2232,29 +2232,29 @@ asmlinkage void vmx_vmexit_handler(struc
    4.45          case TRAP_page_fault:
    4.46          {
    4.47              __vmread(EXIT_QUALIFICATION, &va);
    4.48 -            __vmread(VM_EXIT_INTR_ERROR_CODE, &regs.error_code);
    4.49 +            __vmread(VM_EXIT_INTR_ERROR_CODE, &regs->error_code);
    4.50  
    4.51 -            TRACE_VMEXIT(3,regs.error_code);
    4.52 -            TRACE_VMEXIT(4,va);
    4.53 +            TRACE_VMEXIT(3, regs->error_code);
    4.54 +            TRACE_VMEXIT(4, va);
    4.55  
    4.56              HVM_DBG_LOG(DBG_LEVEL_VMMU,
    4.57                          "eax=%lx, ebx=%lx, ecx=%lx, edx=%lx, esi=%lx, edi=%lx",
    4.58 -                        (unsigned long)regs.eax, (unsigned long)regs.ebx,
    4.59 -                        (unsigned long)regs.ecx, (unsigned long)regs.edx,
    4.60 -                        (unsigned long)regs.esi, (unsigned long)regs.edi);
    4.61 +                        (unsigned long)regs->eax, (unsigned long)regs->ebx,
    4.62 +                        (unsigned long)regs->ecx, (unsigned long)regs->edx,
    4.63 +                        (unsigned long)regs->esi, (unsigned long)regs->edi);
    4.64  
    4.65 -            if ( !vmx_do_page_fault(va, &regs) ) {
    4.66 -                /*
    4.67 -                 * Inject #PG using Interruption-Information Fields
    4.68 -                 */
    4.69 -                vmx_inject_hw_exception(v, TRAP_page_fault, regs.error_code);
    4.70 +            if ( !vmx_do_page_fault(va, regs) )
    4.71 +            {
    4.72 +                /* Inject #PG using Interruption-Information Fields. */
    4.73 +                vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code);
    4.74                  v->arch.hvm_vmx.cpu_cr2 = va;
    4.75 -                TRACE_3D(TRC_VMX_INT, v->domain->domain_id, TRAP_page_fault, va);
    4.76 +                TRACE_3D(TRC_VMX_INT, v->domain->domain_id,
    4.77 +                         TRAP_page_fault, va);
    4.78              }
    4.79              break;
    4.80          }
    4.81          case TRAP_nmi:
    4.82 -            do_nmi(&regs);
    4.83 +            do_nmi(regs);
    4.84              break;
    4.85          default:
    4.86              vmx_reflect_exception(v);
    4.87 @@ -2263,7 +2263,7 @@ asmlinkage void vmx_vmexit_handler(struc
    4.88          break;
    4.89      }
    4.90      case EXIT_REASON_EXTERNAL_INTERRUPT:
    4.91 -        vmx_vmexit_do_extint(&regs);
    4.92 +        vmx_vmexit_do_extint(regs);
    4.93          break;
    4.94      case EXIT_REASON_TRIPLE_FAULT:
    4.95          domain_crash_synchronous();
    4.96 @@ -2280,7 +2280,7 @@ asmlinkage void vmx_vmexit_handler(struc
    4.97      case EXIT_REASON_CPUID:
    4.98          inst_len = __get_instruction_length(); /* Safe: CPUID */
    4.99          __update_guest_eip(inst_len);
   4.100 -        vmx_vmexit_do_cpuid(&regs);
   4.101 +        vmx_vmexit_do_cpuid(regs);
   4.102          break;
   4.103      case EXIT_REASON_HLT:
   4.104          inst_len = __get_instruction_length(); /* Safe: HLT */
   4.105 @@ -2302,7 +2302,7 @@ asmlinkage void vmx_vmexit_handler(struc
   4.106          __update_guest_eip(inst_len);
   4.107          __vmread(GUEST_RIP, &rip);
   4.108          __vmread(EXIT_QUALIFICATION, &exit_qualification);
   4.109 -        hvm_do_hypercall(&regs);
   4.110 +        hvm_do_hypercall(regs);
   4.111          break;
   4.112      }
   4.113      case EXIT_REASON_CR_ACCESS:
   4.114 @@ -2310,15 +2310,15 @@ asmlinkage void vmx_vmexit_handler(struc
   4.115          __vmread(GUEST_RIP, &rip);
   4.116          __vmread(EXIT_QUALIFICATION, &exit_qualification);
   4.117          inst_len = __get_instruction_length(); /* Safe: MOV Cn, LMSW, CLTS */
   4.118 -        if ( vmx_cr_access(exit_qualification, &regs) )
   4.119 +        if ( vmx_cr_access(exit_qualification, regs) )
   4.120              __update_guest_eip(inst_len);
   4.121 -        TRACE_VMEXIT(3,regs.error_code);
   4.122 -        TRACE_VMEXIT(4,exit_qualification);
   4.123 +        TRACE_VMEXIT(3, regs->error_code);
   4.124 +        TRACE_VMEXIT(4, exit_qualification);
   4.125          break;
   4.126      }
   4.127      case EXIT_REASON_DR_ACCESS:
   4.128          __vmread(EXIT_QUALIFICATION, &exit_qualification);
   4.129 -        vmx_dr_access(exit_qualification, &regs);
   4.130 +        vmx_dr_access(exit_qualification, regs);
   4.131          break;
   4.132      case EXIT_REASON_IO_INSTRUCTION:
   4.133          __vmread(EXIT_QUALIFICATION, &exit_qualification);
   4.134 @@ -2329,12 +2329,12 @@ asmlinkage void vmx_vmexit_handler(struc
   4.135      case EXIT_REASON_MSR_READ:
   4.136          inst_len = __get_instruction_length(); /* Safe: RDMSR */
   4.137          __update_guest_eip(inst_len);
   4.138 -        vmx_do_msr_read(&regs);
   4.139 +        vmx_do_msr_read(regs);
   4.140          break;
   4.141      case EXIT_REASON_MSR_WRITE:
   4.142          inst_len = __get_instruction_length(); /* Safe: WRMSR */
   4.143          __update_guest_eip(inst_len);
   4.144 -        vmx_do_msr_write(&regs);
   4.145 +        vmx_do_msr_write(regs);
   4.146          break;
   4.147      case EXIT_REASON_MWAIT_INSTRUCTION:
   4.148      case EXIT_REASON_MONITOR_INSTRUCTION:
     5.1 --- a/xen/arch/x86/hvm/vmx/x86_32/exits.S	Thu Sep 28 10:10:59 2006 +0100
     5.2 +++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S	Thu Sep 28 11:25:15 2006 +0100
     5.3 @@ -82,7 +82,10 @@ ENTRY(vmx_asm_vmexit_handler)
     5.4          /* selectors are restored/saved by VMX */
     5.5          HVM_SAVE_ALL_NOSEGREGS
     5.6          call vmx_trace_vmexit
     5.7 +        movl %esp,%eax
     5.8 +        push %eax
     5.9          call vmx_vmexit_handler
    5.10 +        addl $4,%esp
    5.11          jmp vmx_asm_do_vmentry
    5.12  
    5.13          ALIGN
     6.1 --- a/xen/arch/x86/hvm/vmx/x86_64/exits.S	Thu Sep 28 10:10:59 2006 +0100
     6.2 +++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S	Thu Sep 28 11:25:15 2006 +0100
     6.3 @@ -93,6 +93,7 @@ ENTRY(vmx_asm_vmexit_handler)
     6.4          /* selectors are restored/saved by VMX */
     6.5          HVM_SAVE_ALL_NOSEGREGS
     6.6          call vmx_trace_vmexit
     6.7 +        movq %rsp,%rdi
     6.8          call vmx_vmexit_handler
     6.9          jmp vmx_asm_do_vmentry
    6.10  
     7.1 --- a/xen/include/asm-x86/hvm/support.h	Thu Sep 28 10:10:59 2006 +0100
     7.2 +++ b/xen/include/asm-x86/hvm/support.h	Thu Sep 28 11:25:15 2006 +0100
     7.3 @@ -118,7 +118,7 @@ enum hval_bitmaps {
     7.4  extern unsigned int opt_hvm_debug_level;
     7.5  #define HVM_DBG_LOG(level, _f, _a...)                                         \
     7.6      do {                                                                      \
     7.7 -        if ( (level) & opt_hvm_debug_level )                                  \
     7.8 +        if ( unlikely((level) & opt_hvm_debug_level) )                        \
     7.9              printk("[HVM:%d.%d] <%s> " _f "\n",                               \
    7.10                     current->domain->domain_id, current->vcpu_id, __func__,    \
    7.11                     ## _a);                                                    \