direct-io.hg

changeset 14350:f3f5f2756d75

x86: Add VGCF_onlien flag to vcpu_guest_context.
Change common Xen code to start all VCPUs (except idle ones)
offline. Change arch code to deal with this.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Mar 12 13:53:43 2007 +0000 (2007-03-12)
parents 1721f90e1422
children 7ec182baf9fd
files tools/libxc/xc_dom_x86.c tools/libxc/xc_hvm_build.c tools/libxc/xc_linux_restore.c xen/arch/ia64/xen/domain.c xen/arch/powerpc/domain.c xen/arch/powerpc/domain_build.c xen/arch/x86/domain.c xen/arch/x86/domain_build.c xen/common/domain.c xen/common/domctl.c xen/include/public/arch-x86/xen.h xen/include/public/foreign/structs.py
line diff
     1.1 --- a/tools/libxc/xc_dom_x86.c	Mon Mar 12 11:15:56 2007 +0000
     1.2 +++ b/tools/libxc/xc_dom_x86.c	Mon Mar 12 13:53:43 2007 +0000
     1.3 @@ -455,7 +455,7 @@ static int vcpu_x86_32(struct xc_dom_ima
     1.4      ctxt->kernel_ss = ctxt->user_regs.ss;
     1.5      ctxt->kernel_sp = ctxt->user_regs.esp;
     1.6  
     1.7 -    ctxt->flags = VGCF_in_kernel_X86_32;
     1.8 +    ctxt->flags = VGCF_in_kernel_X86_32 | VGCF_online_X86_32;
     1.9      if ( dom->parms.pae == 2 /* extended_cr3 */ ||
    1.10           dom->parms.pae == 3 /* bimodal */ )
    1.11          ctxt->vm_assist |= (1UL << VMASST_TYPE_pae_extended_cr3);
    1.12 @@ -494,7 +494,7 @@ static int vcpu_x86_64(struct xc_dom_ima
    1.13      ctxt->kernel_ss = ctxt->user_regs.ss;
    1.14      ctxt->kernel_sp = ctxt->user_regs.esp;
    1.15  
    1.16 -    ctxt->flags = VGCF_in_kernel_X86_64;
    1.17 +    ctxt->flags = VGCF_in_kernel_X86_64 | VGCF_online_X86_64;
    1.18      cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn);
    1.19      ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_64(cr3_pfn);
    1.20      xc_dom_printf("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "\n",
     2.1 --- a/tools/libxc/xc_hvm_build.c	Mon Mar 12 11:15:56 2007 +0000
     2.2 +++ b/tools/libxc/xc_hvm_build.c	Mon Mar 12 13:53:43 2007 +0000
     2.3 @@ -302,9 +302,15 @@ static int setup_guest(int xc_handle,
     2.4  
     2.5      /* Set [er]ip in the way that's right for Xen */
     2.6      if ( strstr(caps, "x86_64") )
     2.7 +    {
     2.8          ctxt->c64.user_regs.rip = elf_uval(&elf, elf.ehdr, e_entry); 
     2.9 +        ctxt->c64.flags = VGCF_online;
    2.10 +    }
    2.11      else
    2.12 +    {
    2.13          ctxt->c32.user_regs.eip = elf_uval(&elf, elf.ehdr, e_entry);
    2.14 +        ctxt->c32.flags = VGCF_online;
    2.15 +    }
    2.16  
    2.17      return 0;
    2.18  
    2.19 @@ -344,7 +350,7 @@ static int xc_hvm_build_internal(int xc_
    2.20  
    2.21      memset(&launch_domctl, 0, sizeof(launch_domctl));
    2.22      launch_domctl.domain = (domid_t)domid;
    2.23 -    launch_domctl.u.vcpucontext.vcpu   = 0;
    2.24 +    launch_domctl.u.vcpucontext.vcpu = 0;
    2.25      set_xen_guest_handle(launch_domctl.u.vcpucontext.ctxt, &ctxt.c);
    2.26      launch_domctl.cmd = XEN_DOMCTL_setvcpucontext;
    2.27      rc = xc_domctl(xc_handle, &launch_domctl);
     3.1 --- a/tools/libxc/xc_linux_restore.c	Mon Mar 12 11:15:56 2007 +0000
     3.2 +++ b/tools/libxc/xc_linux_restore.c	Mon Mar 12 13:53:43 2007 +0000
     3.3 @@ -189,6 +189,7 @@ int xc_linux_restore(int xc_handle, int 
     3.4  
     3.5      uint64_t vcpumap = 1ULL;
     3.6      unsigned int max_vcpu_id = 0;
     3.7 +    int new_ctxt_format = 0;
     3.8  
     3.9      max_pfn = nr_pfns;
    3.10  
    3.11 @@ -372,6 +373,7 @@ int xc_linux_restore(int xc_handle, int 
    3.12          }
    3.13  
    3.14          if (j == -2) {
    3.15 +            new_ctxt_format = 1;
    3.16              if (!read_exact(io_fd, &max_vcpu_id, sizeof(int)) ||
    3.17                  (max_vcpu_id >= 64) ||
    3.18                  !read_exact(io_fd, &vcpumap, sizeof(uint64_t))) {
    3.19 @@ -797,6 +799,9 @@ int xc_linux_restore(int xc_handle, int 
    3.20              goto out;
    3.21          }
    3.22  
    3.23 +        if ( !new_ctxt_format )
    3.24 +            ctxt.flags |= VGCF_online;
    3.25 +
    3.26          if (i == 0) {
    3.27              /*
    3.28               * Uncanonicalise the suspend-record frame number and poke
     4.1 --- a/xen/arch/ia64/xen/domain.c	Mon Mar 12 11:15:56 2007 +0000
     4.2 +++ b/xen/arch/ia64/xen/domain.c	Mon Mar 12 13:53:43 2007 +0000
     4.3 @@ -672,8 +672,11 @@ int arch_set_info_guest(struct vcpu *v, 
     4.4  	/* This overrides some registers. */
     4.5  	vcpu_init_regs(v);
     4.6  
     4.7 -	/* Don't redo final setup */
     4.8 -	set_bit(_VCPUF_initialised, &v->vcpu_flags);
     4.9 +	/* Don't redo final setup. Auto-online VCPU0. */
    4.10 +	if (!test_and_set_bit(_VCPUF_initialised, &v->vcpu_flags) &&
    4.11 +	    (v->vcpu_id == 0))
    4.12 +		clear_bit(_VCPUF_down, &v->vcpu_flags);
    4.13 +
    4.14  	return 0;
    4.15  }
    4.16  
    4.17 @@ -1182,6 +1185,7 @@ int construct_dom0(struct domain *d,
    4.18  	printk("Dom0: 0x%lx\n", (u64)dom0);
    4.19  
    4.20  	set_bit(_VCPUF_initialised, &v->vcpu_flags);
    4.21 +	clear_bit(_VCPUF_down, &v->vcpu_flags);
    4.22  
    4.23  	/* Build firmware.
    4.24  	   Note: Linux kernel reserve memory used by start_info, so there is
     5.1 --- a/xen/arch/powerpc/domain.c	Mon Mar 12 11:15:56 2007 +0000
     5.2 +++ b/xen/arch/powerpc/domain.c	Mon Mar 12 13:53:43 2007 +0000
     5.3 @@ -168,7 +168,10 @@ int arch_set_info_guest(struct vcpu *v, 
     5.4      d->shared_info->wc_nsec = dom0->shared_info->wc_nsec;
     5.5      d->shared_info->arch.boot_timebase = dom0->shared_info->arch.boot_timebase;
     5.6  
     5.7 -    set_bit(_VCPUF_initialised, &v->vcpu_flags);
     5.8 +    /* Auto-online VCPU0 when it is initialised. */
     5.9 +    if ( !test_and_set_bit(_VCPUF_initialised, &v->vcpu_flags) &&
    5.10 +         (v->vcpu_id == 0) )
    5.11 +        clear_bit(_VCPUF_down, &v->vcpu_flags);
    5.12  
    5.13      cpu_init_vcpu(v);
    5.14  
     6.1 --- a/xen/arch/powerpc/domain_build.c	Mon Mar 12 11:15:56 2007 +0000
     6.2 +++ b/xen/arch/powerpc/domain_build.c	Mon Mar 12 13:53:43 2007 +0000
     6.3 @@ -274,6 +274,7 @@ int construct_dom0(struct domain *d,
     6.4      ofd_dom0_fixup(d, *ofh_tree + rma, cmdline, shared_info_addr);
     6.5  
     6.6      set_bit(_VCPUF_initialised, &v->vcpu_flags);
     6.7 +    clear_bit(_VCPUF_down, &v->vcpu_flags);
     6.8  
     6.9      rc = 0;
    6.10  
     7.1 --- a/xen/arch/x86/domain.c	Mon Mar 12 11:15:56 2007 +0000
     7.2 +++ b/xen/arch/x86/domain.c	Mon Mar 12 13:53:43 2007 +0000
     7.3 @@ -601,7 +601,7 @@ int arch_set_info_guest(
     7.4      }
     7.5  
     7.6      if ( test_bit(_VCPUF_initialised, &v->vcpu_flags) )
     7.7 -        return 0;
     7.8 +        goto out;
     7.9  
    7.10      memset(v->arch.guest_context.debugreg, 0,
    7.11             sizeof(v->arch.guest_context.debugreg));
    7.12 @@ -706,6 +706,11 @@ int arch_set_info_guest(
    7.13  
    7.14      update_cr3(v);
    7.15  
    7.16 + out:
    7.17 +    if ( flags & VGCF_online )
    7.18 +        clear_bit(_VCPUF_down, &v->vcpu_flags);
    7.19 +    else
    7.20 +        set_bit(_VCPUF_down, &v->vcpu_flags);
    7.21      return 0;
    7.22  #undef c
    7.23  }
     8.1 --- a/xen/arch/x86/domain_build.c	Mon Mar 12 11:15:56 2007 +0000
     8.2 +++ b/xen/arch/x86/domain_build.c	Mon Mar 12 13:53:43 2007 +0000
     8.3 @@ -902,6 +902,7 @@ int construct_dom0(struct domain *d,
     8.4      update_domain_wallclock_time(d);
     8.5  
     8.6      set_bit(_VCPUF_initialised, &v->vcpu_flags);
     8.7 +    clear_bit(_VCPUF_down, &v->vcpu_flags);
     8.8  
     8.9      /*
    8.10       * Initial register values:
     9.1 --- a/xen/common/domain.c	Mon Mar 12 11:15:56 2007 +0000
     9.2 +++ b/xen/common/domain.c	Mon Mar 12 13:53:43 2007 +0000
     9.3 @@ -102,7 +102,7 @@ struct vcpu *alloc_vcpu(
     9.4      v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
     9.5      v->runstate.state_entry_time = NOW();
     9.6  
     9.7 -    if ( (vcpu_id != 0) && !is_idle_domain(d) )
     9.8 +    if ( !is_idle_domain(d) )
     9.9          set_bit(_VCPUF_down, &v->vcpu_flags);
    9.10  
    9.11      if ( sched_init_vcpu(v, cpu_id) != 0 )
    10.1 --- a/xen/common/domctl.c	Mon Mar 12 11:15:56 2007 +0000
    10.2 +++ b/xen/common/domctl.c	Mon Mar 12 13:53:43 2007 +0000
    10.3 @@ -268,18 +268,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    10.4      case XEN_DOMCTL_unpausedomain:
    10.5      {
    10.6          struct domain *d = rcu_lock_domain_by_id(op->domain);
    10.7 +
    10.8          ret = -ESRCH;
    10.9 -        if ( d != NULL )
   10.10 -        {
   10.11 -            ret = -EINVAL;
   10.12 -            if ( (d != current->domain) && (d->vcpu[0] != NULL) &&
   10.13 -                 test_bit(_VCPUF_initialised, &d->vcpu[0]->vcpu_flags) )
   10.14 -            {
   10.15 -                domain_unpause_by_systemcontroller(d);
   10.16 -                ret = 0;
   10.17 -            }
   10.18 -            rcu_unlock_domain(d);
   10.19 -        }
   10.20 +        if ( d == NULL )
   10.21 +            break;
   10.22 +
   10.23 +        domain_unpause_by_systemcontroller(d);
   10.24 +        rcu_unlock_domain(d);
   10.25 +        ret = 0;
   10.26      }
   10.27      break;
   10.28  
    11.1 --- a/xen/include/public/arch-x86/xen.h	Mon Mar 12 11:15:56 2007 +0000
    11.2 +++ b/xen/include/public/arch-x86/xen.h	Mon Mar 12 13:53:43 2007 +0000
    11.3 @@ -126,6 +126,8 @@ struct vcpu_guest_context {
    11.4  #define VGCF_failsafe_disables_events  (1<<_VGCF_failsafe_disables_events)
    11.5  #define _VGCF_syscall_disables_events  4
    11.6  #define VGCF_syscall_disables_events   (1<<_VGCF_syscall_disables_events)
    11.7 +#define _VGCF_online                   5
    11.8 +#define VGCF_online                    (1<<_VGCF_online)
    11.9      unsigned long flags;                    /* VGCF_* flags                 */
   11.10      struct cpu_user_regs user_regs;         /* User-level CPU registers     */
   11.11      struct trap_info trap_ctxt[256];        /* Virtual IDT                  */
    12.1 --- a/xen/include/public/foreign/structs.py	Mon Mar 12 11:15:56 2007 +0000
    12.2 +++ b/xen/include/public/foreign/structs.py	Mon Mar 12 13:53:43 2007 +0000
    12.3 @@ -41,6 +41,8 @@ defines = [ "__i386__",
    12.4              "VGCF_failsafe_disables_events",
    12.5              "_VGCF_syscall_disables_events",
    12.6              "VGCF_syscall_disables_events",
    12.7 +            "_VGCF_online",
    12.8 +            "VGCF_online",
    12.9  
   12.10              # ia64
   12.11              "VGCF_EXTRA_REGS",