ia64/xen-unstable

changeset 14473:cabf9e221cd5

svm: Remove special 'launch' scheduler tail function.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Mar 20 11:28:45 2007 +0000 (2007-03-20)
parents 4e380c769774
children 61a4a4795be5 522a1cd17b6d
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/svm/x86_32/exits.S xen/arch/x86/hvm/svm/x86_64/exits.S xen/include/asm-x86/hvm/svm/svm.h xen/include/asm-x86/hvm/svm/vmcb.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Mon Mar 19 16:55:21 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Mar 20 11:28:45 2007 +0000
     1.3 @@ -485,7 +485,6 @@ int svm_vmcb_restore(struct vcpu *v, str
     1.4           * first.
     1.5           */
     1.6          HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 c->cr3 = %"PRIx64"", c->cr3);
     1.7 -        /* current!=vcpu as not called by arch_vmx_do_launch */
     1.8          mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
     1.9          if( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) ) 
    1.10              goto bad_cr3;
    1.11 @@ -921,17 +920,6 @@ static void svm_load_cpu_guest_regs(
    1.12      svm_load_cpu_user_regs(v, regs);
    1.13  }
    1.14  
    1.15 -static void arch_svm_do_launch(struct vcpu *v) 
    1.16 -{
    1.17 -    svm_do_launch(v);
    1.18 -
    1.19 -    if ( paging_mode_hap(v->domain) ) {
    1.20 -        v->arch.hvm_svm.vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
    1.21 -    }
    1.22 -
    1.23 -    reset_stack_and_jump(svm_asm_do_launch);
    1.24 -}
    1.25 -
    1.26  static void svm_ctxt_switch_from(struct vcpu *v)
    1.27  {
    1.28      svm_save_dr(v);
    1.29 @@ -953,16 +941,30 @@ static void svm_ctxt_switch_to(struct vc
    1.30      svm_restore_dr(v);
    1.31  }
    1.32  
    1.33 +static void arch_svm_do_resume(struct vcpu *v) 
    1.34 +{
    1.35 +    if ( v->arch.hvm_svm.launch_core != smp_processor_id() )
    1.36 +    {
    1.37 +        v->arch.hvm_svm.launch_core = smp_processor_id();
    1.38 +        hvm_migrate_timers(v);
    1.39 +    }
    1.40 +
    1.41 +    hvm_do_resume(v);
    1.42 +    reset_stack_and_jump(svm_asm_do_resume);
    1.43 +}
    1.44 +
    1.45  static int svm_vcpu_initialise(struct vcpu *v)
    1.46  {
    1.47      int rc;
    1.48  
    1.49 -    v->arch.schedule_tail    = arch_svm_do_launch;
    1.50 +    v->arch.schedule_tail    = arch_svm_do_resume;
    1.51      v->arch.ctxt_switch_from = svm_ctxt_switch_from;
    1.52      v->arch.ctxt_switch_to   = svm_ctxt_switch_to;
    1.53  
    1.54      v->arch.hvm_svm.saved_irq_vector = -1;
    1.55  
    1.56 +    v->arch.hvm_svm.launch_core = -1;
    1.57 +
    1.58      if ( (rc = svm_create_vmcb(v)) != 0 )
    1.59      {
    1.60          dprintk(XENLOG_WARNING,
    1.61 @@ -1026,10 +1028,12 @@ void svm_npt_detect(void)
    1.62  
    1.63      /* check CPUID for nested paging support */
    1.64      cpuid(0x8000000A, &eax, &ebx, &ecx, &edx);
    1.65 -    if ( edx & 0x01 ) { /* nested paging */
    1.66 +    if ( edx & 0x01 ) /* nested paging */
    1.67 +    {
    1.68          hap_capable_system = 1;
    1.69      }
    1.70 -    else if ( opt_hap_enabled ) {
    1.71 +    else if ( opt_hap_enabled )
    1.72 +    {
    1.73          printk(" nested paging is not supported by this CPU.\n");
    1.74          hap_capable_system = 0; /* no nested paging, we disable flag. */
    1.75      }
    1.76 @@ -1087,24 +1091,6 @@ int start_svm(void)
    1.77      return 1;
    1.78  }
    1.79  
    1.80 -void arch_svm_do_resume(struct vcpu *v) 
    1.81 -{
    1.82 -    /* pinning VCPU to a different core? */
    1.83 -    if ( v->arch.hvm_svm.launch_core == smp_processor_id()) {
    1.84 -        hvm_do_resume( v );
    1.85 -        reset_stack_and_jump( svm_asm_do_resume );
    1.86 -    }
    1.87 -    else {
    1.88 -        if (svm_dbg_on)
    1.89 -            printk("VCPU core pinned: %d to %d\n", 
    1.90 -                   v->arch.hvm_svm.launch_core, smp_processor_id() );
    1.91 -        v->arch.hvm_svm.launch_core = smp_processor_id();
    1.92 -        hvm_migrate_timers( v );
    1.93 -        hvm_do_resume( v );
    1.94 -        reset_stack_and_jump( svm_asm_do_resume );
    1.95 -    }
    1.96 -}
    1.97 -
    1.98  static int svm_do_nested_pgfault(paddr_t gpa, struct cpu_user_regs *regs)
    1.99  {
   1.100      if (mmio_space(gpa)) {
     2.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Mon Mar 19 16:55:21 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Tue Mar 20 11:28:45 2007 +0000
     2.3 @@ -196,11 +196,13 @@ static int construct_vmcb(struct vcpu *v
     2.4  
     2.5      arch_svm->vmcb->exception_intercepts = MONITOR_DEFAULT_EXCEPTION_BITMAP;
     2.6  
     2.7 -    if ( paging_mode_hap(v->domain) ) {
     2.8 +    if ( paging_mode_hap(v->domain) )
     2.9 +    {
    2.10          vmcb->cr0 = arch_svm->cpu_shadow_cr0;
    2.11          vmcb->np_enable = 1; /* enable nested paging */
    2.12          vmcb->g_pat = 0x0007040600070406ULL; /* guest PAT */
    2.13          vmcb->exception_intercepts &= ~EXCEPTION_BITMAP_PG;
    2.14 +        vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
    2.15      }
    2.16  
    2.17      return 0;
    2.18 @@ -247,16 +249,6 @@ void svm_destroy_vmcb(struct vcpu *v)
    2.19      arch_svm->vmcb = NULL;
    2.20  }
    2.21  
    2.22 -void svm_do_launch(struct vcpu *v)
    2.23 -{
    2.24 -    hvm_stts(v);
    2.25 -
    2.26 -    /* current core is the one we intend to perform the VMRUN on */
    2.27 -    v->arch.hvm_svm.launch_core = smp_processor_id();
    2.28 -
    2.29 -    v->arch.schedule_tail = arch_svm_do_resume;
    2.30 -}
    2.31 -
    2.32  static void svm_dump_sel(char *name, svm_segment_register_t *s)
    2.33  {
    2.34      printk("%s: sel=0x%04x, attr=0x%04x, limit=0x%08x, base=0x%016llx\n", 
     3.1 --- a/xen/arch/x86/hvm/svm/x86_32/exits.S	Mon Mar 19 16:55:21 2007 +0000
     3.2 +++ b/xen/arch/x86/hvm/svm/x86_32/exits.S	Tue Mar 20 11:28:45 2007 +0000
     3.3 @@ -80,15 +80,24 @@
     3.4          popl %eax;  \
     3.5          addl $(NR_SKIPPED_REGS*4), %esp
     3.6  
     3.7 -        ALIGN
     3.8 -
     3.9  #define VMRUN  .byte 0x0F,0x01,0xD8
    3.10  #define VMLOAD .byte 0x0F,0x01,0xDA
    3.11  #define VMSAVE .byte 0x0F,0x01,0xDB
    3.12  #define STGI   .byte 0x0F,0x01,0xDC
    3.13  #define CLGI   .byte 0x0F,0x01,0xDD
    3.14  
    3.15 -ENTRY(svm_asm_do_launch)
    3.16 +ENTRY(svm_asm_do_resume)
    3.17 +        GET_CURRENT(%ebx)
    3.18 +        xorl %ecx,%ecx
    3.19 +        notl %ecx
    3.20 +        cli                             # tests must not race interrupts
    3.21 +        movl VCPU_processor(%ebx),%eax
    3.22 +        shl  $IRQSTAT_shift,%eax
    3.23 +        test %ecx,irq_stat(%eax,1)
    3.24 +        jnz  svm_process_softirqs
    3.25 +        call svm_intr_assist
    3.26 +        call svm_load_cr2
    3.27 +
    3.28          CLGI                
    3.29          sti
    3.30          GET_CURRENT(%ebx)
    3.31 @@ -135,30 +144,7 @@ svm_stgi_label:
    3.32          jmp  svm_asm_do_resume
    3.33  
    3.34          ALIGN
    3.35 -
    3.36 -ENTRY(svm_asm_do_resume)
    3.37 -svm_test_all_events:
    3.38 -        GET_CURRENT(%ebx)
    3.39 -/*test_all_events:*/
    3.40 -        xorl %ecx,%ecx
    3.41 -        notl %ecx
    3.42 -        cli                             # tests must not race interrupts
    3.43 -/*test_softirqs:*/  
    3.44 -        movl VCPU_processor(%ebx),%eax
    3.45 -        shl  $IRQSTAT_shift,%eax
    3.46 -        test %ecx,irq_stat(%eax,1)
    3.47 -        jnz  svm_process_softirqs
    3.48 -svm_restore_all_guest:
    3.49 -        call svm_intr_assist
    3.50 -        call svm_load_cr2
    3.51 -        /* 
    3.52 -         * Check if we are going back to AMD-V based VM
    3.53 -         * By this time, all the setups in the VMCB must be complete.
    3.54 -         */
    3.55 -        jmp svm_asm_do_launch
    3.56 -
    3.57 -        ALIGN
    3.58  svm_process_softirqs:
    3.59          sti       
    3.60          call do_softirq
    3.61 -        jmp  svm_test_all_events
    3.62 +        jmp  svm_asm_do_resume
     4.1 --- a/xen/arch/x86/hvm/svm/x86_64/exits.S	Mon Mar 19 16:55:21 2007 +0000
     4.2 +++ b/xen/arch/x86/hvm/svm/x86_64/exits.S	Tue Mar 20 11:28:45 2007 +0000
     4.3 @@ -98,7 +98,17 @@
     4.4  #define STGI   .byte 0x0F,0x01,0xDC
     4.5  #define CLGI   .byte 0x0F,0x01,0xDD
     4.6  
     4.7 -ENTRY(svm_asm_do_launch)
     4.8 +ENTRY(svm_asm_do_resume)
     4.9 +        GET_CURRENT(%rbx)
    4.10 +        cli                             # tests must not race interrupts
    4.11 +        movl VCPU_processor(%rbx),%eax
    4.12 +        shl  $IRQSTAT_shift, %rax
    4.13 +        leaq irq_stat(%rip), %rdx
    4.14 +        testl $~0, (%rdx, %rax, 1)
    4.15 +        jnz  svm_process_softirqs
    4.16 +        call svm_intr_assist
    4.17 +        call svm_load_cr2
    4.18 +
    4.19          CLGI                
    4.20          sti
    4.21          GET_CURRENT(%rbx)
    4.22 @@ -150,28 +160,8 @@ svm_stgi_label:
    4.23          call svm_vmexit_handler
    4.24          jmp  svm_asm_do_resume
    4.25  
    4.26 -ENTRY(svm_asm_do_resume)
    4.27 -svm_test_all_events:
    4.28 -        GET_CURRENT(%rbx)
    4.29 -/*test_all_events:*/
    4.30 -        cli                             # tests must not race interrupts
    4.31 -/*test_softirqs:*/
    4.32 -        movl  VCPU_processor(%rbx),%eax
    4.33 -        shl   $IRQSTAT_shift, %rax
    4.34 -        leaq  irq_stat(%rip), %rdx
    4.35 -        testl $~0, (%rdx, %rax, 1)
    4.36 -        jnz   svm_process_softirqs
    4.37 -svm_restore_all_guest:
    4.38 -        call svm_intr_assist
    4.39 -        call svm_load_cr2
    4.40 -        /*
    4.41 -         * Check if we are going back to AMD-V based VM
    4.42 -         * By this time, all the setups in the VMCB must be complete.
    4.43 -         */
    4.44 -        jmp svm_asm_do_launch
    4.45 -
    4.46          ALIGN
    4.47  svm_process_softirqs:
    4.48          sti
    4.49          call do_softirq
    4.50 -        jmp  svm_test_all_events
    4.51 +        jmp  svm_asm_do_resume
     5.1 --- a/xen/include/asm-x86/hvm/svm/svm.h	Mon Mar 19 16:55:21 2007 +0000
     5.2 +++ b/xen/include/asm-x86/hvm/svm/svm.h	Tue Mar 20 11:28:45 2007 +0000
     5.3 @@ -29,8 +29,6 @@
     5.4  #include <asm/i387.h>
     5.5  
     5.6  extern void svm_dump_vmcb(const char *from, struct vmcb_struct *vmcb);
     5.7 -extern void svm_do_launch(struct vcpu *v);
     5.8 -extern void arch_svm_do_resume(struct vcpu *v);
     5.9  
    5.10  extern u64 root_vmcb_pa[NR_CPUS];
    5.11  
     6.1 --- a/xen/include/asm-x86/hvm/svm/vmcb.h	Mon Mar 19 16:55:21 2007 +0000
     6.2 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Mar 20 11:28:45 2007 +0000
     6.3 @@ -447,7 +447,7 @@ struct arch_svm_struct {
     6.4      u32                 *msrpm;
     6.5      u64                 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */
     6.6      int                 saved_irq_vector;
     6.7 -    u32                 launch_core;
     6.8 +    int                 launch_core;
     6.9      
    6.10      unsigned long       flags;            /* VMCB flags */
    6.11      unsigned long       cpu_shadow_cr0;   /* Guest value for CR0 */