ia64/xen-unstable

changeset 12257:2368e779f89f

[XEN] Replace hvm_setup_platform() with hvm_domain_initialise()
and extra code in hvm_vcpu_initialise(). Remove 'apic' config
option -- HVM CPUs will always have an APIC (which should be
set up in virtual wire mode for backward compatibility, just as
in a real system).
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Sun Nov 05 20:17:40 2006 +0000 (2006-11-05)
parents e3abede54214
children d150a2178bd4
files tools/examples/xmexample.hvm tools/firmware/hvmloader/hvmloader.c tools/libxc/ia64/xc_ia64_hvm_build.c tools/libxc/xc_hvm_build.c tools/libxc/xenguest.h tools/libxc/xg_private.c tools/python/README.XendConfig tools/python/README.sxpcfg tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py tools/python/xen/xm/create.py tools/xm-test/lib/XmTestLib/arch.py xen/arch/x86/domain.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/i8254.c xen/arch/x86/hvm/i8259.c xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/pmtimer.c xen/arch/x86/hvm/rtc.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vioapic.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/mm.c xen/include/asm-ia64/vmx_platform.h xen/include/asm-x86/hvm/hvm.h xen/include/asm-x86/hvm/io.h xen/include/asm-x86/hvm/support.h xen/include/asm-x86/hvm/vlapic.h xen/include/asm-x86/hvm/vpic.h xen/include/public/hvm/params.h
line diff
     1.1 --- a/tools/examples/xmexample.hvm	Sat Nov 04 20:13:22 2006 +0000
     1.2 +++ b/tools/examples/xmexample.hvm	Sun Nov 05 20:17:40 2006 +0000
     1.3 @@ -48,9 +48,6 @@ name = "ExampleHVMDomain"
     1.4  # enable/disable HVM guest ACPI, default=0 (disabled)
     1.5  #acpi=0
     1.6  
     1.7 -# enable/disable HVM guest APIC, default=0 (disabled)
     1.8 -#apic=0
     1.9 -
    1.10  # List of which CPUS this domain is allowed to use, default Xen picks
    1.11  #cpus = ""         # leave to Xen to pick
    1.12  #cpus = "0"        # all vcpus run on CPU0
     2.1 --- a/tools/firmware/hvmloader/hvmloader.c	Sat Nov 04 20:13:22 2006 +0000
     2.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Sun Nov 05 20:17:40 2006 +0000
     2.3 @@ -165,8 +165,6 @@ init_hypercalls(void)
     2.4  int
     2.5  main(void)
     2.6  {
     2.7 -	struct xen_hvm_param hvm_param;
     2.8 -
     2.9  	puts("HVM Loader\n");
    2.10  
    2.11  	init_hypercalls();
    2.12 @@ -177,10 +175,7 @@ main(void)
    2.13  	puts("Loading ROMBIOS ...\n");
    2.14  	memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
    2.15  
    2.16 -	hvm_param.domid = DOMID_SELF;
    2.17 -	hvm_param.index = HVM_PARAM_APIC_ENABLED;
    2.18 -	if (!hypercall_hvm_op(HVMOP_get_param, &hvm_param) && hvm_param.value)
    2.19 -		create_mp_tables();
    2.20 +        create_mp_tables();
    2.21  	
    2.22  	if (cirrus_check()) {
    2.23  		puts("Loading Cirrus VGABIOS ...\n");
     3.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c	Sat Nov 04 20:13:22 2006 +0000
     3.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Sun Nov 05 20:17:40 2006 +0000
     3.3 @@ -618,7 +618,7 @@ error_out:
     3.4  int
     3.5  xc_hvm_build(int xc_handle, uint32_t domid, int memsize,
     3.6               const char *image_name, unsigned int vcpus, unsigned int pae,
     3.7 -             unsigned int acpi, unsigned int apic, unsigned int store_evtchn,
     3.8 +             unsigned int acpi, unsigned int store_evtchn,
     3.9               unsigned long *store_mfn)
    3.10  {
    3.11      struct xen_domctl launch_domctl, domctl;
     4.1 --- a/tools/libxc/xc_hvm_build.c	Sat Nov 04 20:13:22 2006 +0000
     4.2 +++ b/tools/libxc/xc_hvm_build.c	Sun Nov 05 20:17:40 2006 +0000
     4.3 @@ -157,7 +157,6 @@ static int setup_guest(int xc_handle,
     4.4                         unsigned int vcpus,
     4.5                         unsigned int pae,
     4.6                         unsigned int acpi,
     4.7 -                       unsigned int apic,
     4.8                         unsigned int store_evtchn,
     4.9                         unsigned long *store_mfn)
    4.10  {
    4.11 @@ -248,7 +247,6 @@ static int setup_guest(int xc_handle,
    4.12      }
    4.13  
    4.14      xc_set_hvm_param(xc_handle, dom, HVM_PARAM_PAE_ENABLED, pae);
    4.15 -    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_APIC_ENABLED, apic);
    4.16  
    4.17      if ( (e820_page = xc_map_foreign_range(
    4.18                xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
    4.19 @@ -307,7 +305,6 @@ static int xc_hvm_build_internal(int xc_
    4.20                                   unsigned int vcpus,
    4.21                                   unsigned int pae,
    4.22                                   unsigned int acpi,
    4.23 -                                 unsigned int apic,
    4.24                                   unsigned int store_evtchn,
    4.25                                   unsigned long *store_mfn)
    4.26  {
    4.27 @@ -340,7 +337,7 @@ static int xc_hvm_build_internal(int xc_
    4.28  
    4.29      if ( setup_guest(xc_handle, domid, memsize, image, image_size,
    4.30                       ctxt, domctl.u.getdomaininfo.shared_info_frame,
    4.31 -                     vcpus, pae, acpi, apic, store_evtchn, store_mfn) < 0)
    4.32 +                     vcpus, pae, acpi, store_evtchn, store_mfn) < 0)
    4.33      {
    4.34          ERROR("Error constructing guest OS");
    4.35          goto error_out;
    4.36 @@ -531,7 +528,6 @@ int xc_hvm_build(int xc_handle,
    4.37                   unsigned int vcpus,
    4.38                   unsigned int pae,
    4.39                   unsigned int acpi,
    4.40 -                 unsigned int apic,
    4.41                   unsigned int store_evtchn,
    4.42                   unsigned long *store_mfn)
    4.43  {
    4.44 @@ -545,7 +541,7 @@ int xc_hvm_build(int xc_handle,
    4.45  
    4.46      sts = xc_hvm_build_internal(xc_handle, domid, memsize,
    4.47                                  image, image_size,
    4.48 -                                vcpus, pae, acpi, apic,
    4.49 +                                vcpus, pae, acpi,
    4.50                                  store_evtchn, store_mfn);
    4.51  
    4.52      free(image);
    4.53 @@ -567,7 +563,6 @@ int xc_hvm_build_mem(int xc_handle,
    4.54                       unsigned int vcpus,
    4.55                       unsigned int pae,
    4.56                       unsigned int acpi,
    4.57 -                     unsigned int apic,
    4.58                       unsigned int store_evtchn,
    4.59                       unsigned long *store_mfn)
    4.60  {
    4.61 @@ -592,7 +587,7 @@ int xc_hvm_build_mem(int xc_handle,
    4.62  
    4.63      sts = xc_hvm_build_internal(xc_handle, domid, memsize,
    4.64                                  img, img_len,
    4.65 -                                vcpus, pae, acpi, apic,
    4.66 +                                vcpus, pae, acpi,
    4.67                                  store_evtchn, store_mfn);
    4.68  
    4.69      /* xc_inflate_buffer may return the original buffer pointer (for
     5.1 --- a/tools/libxc/xenguest.h	Sat Nov 04 20:13:22 2006 +0000
     5.2 +++ b/tools/libxc/xenguest.h	Sun Nov 05 20:17:40 2006 +0000
     5.3 @@ -113,7 +113,6 @@ int xc_hvm_build(int xc_handle,
     5.4                   unsigned int vcpus,
     5.5                   unsigned int pae,
     5.6                   unsigned int acpi,
     5.7 -                 unsigned int apic,
     5.8                   unsigned int store_evtchn,
     5.9                   unsigned long *store_mfn);
    5.10  
    5.11 @@ -125,7 +124,6 @@ int xc_hvm_build_mem(int xc_handle,
    5.12                       unsigned int vcpus,
    5.13                       unsigned int pae,
    5.14                       unsigned int acpi,
    5.15 -                     unsigned int apic,
    5.16                       unsigned int store_evtchn,
    5.17                       unsigned long *store_mfn);
    5.18  
     6.1 --- a/tools/libxc/xg_private.c	Sat Nov 04 20:13:22 2006 +0000
     6.2 +++ b/tools/libxc/xg_private.c	Sun Nov 05 20:17:40 2006 +0000
     6.3 @@ -196,7 +196,6 @@ unsigned long csum_page(void *page)
     6.4      unsigned int vcpus,
     6.5      unsigned int pae,
     6.6      unsigned int acpi,
     6.7 -    unsigned int apic,
     6.8      unsigned int store_evtchn,
     6.9      unsigned long *store_mfn)
    6.10  {
     7.1 --- a/tools/python/README.XendConfig	Sat Nov 04 20:13:22 2006 +0000
     7.2 +++ b/tools/python/README.XendConfig	Sun Nov 05 20:17:40 2006 +0000
     7.3 @@ -123,7 +123,6 @@ otherConfig
     7.4                                  image.hvm.vncconsole
     7.5                                  image.hvm.pae
     7.6                                  image.hvm.acpi (also in image.devices)
     7.7 -                                image.hvm.apic
     7.8                                  image.hvm.devices.boot
     7.9                                  image.hvm.devices.fda
    7.10                                  image.hvm.devices.fdb
     8.1 --- a/tools/python/README.sxpcfg	Sat Nov 04 20:13:22 2006 +0000
     8.2 +++ b/tools/python/README.sxpcfg	Sun Nov 05 20:17:40 2006 +0000
     8.3 @@ -56,7 +56,6 @@ image
     8.4    - vncconsole
     8.5    - pae
     8.6    - acpi
     8.7 -  - apic
     8.8    (parseDeviceModel)
     8.9    - boot
    8.10    - fda
     9.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Sat Nov 04 20:13:22 2006 +0000
     9.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Sun Nov 05 20:17:40 2006 +0000
     9.3 @@ -377,19 +377,18 @@ static PyObject *pyxc_hvm_build(XcObject
     9.4      int vcpus = 1;
     9.5      int pae  = 0;
     9.6      int acpi = 0;
     9.7 -    int apic = 0;
     9.8      unsigned long store_mfn = 0;
     9.9  
    9.10      static char *kwd_list[] = { "domid", "store_evtchn",
    9.11 -				"memsize", "image", "vcpus", "pae", "acpi", "apic",
    9.12 +				"memsize", "image", "vcpus", "pae", "acpi",
    9.13  				NULL };
    9.14 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiiii", kwd_list,
    9.15 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiii", kwd_list,
    9.16                                        &dom, &store_evtchn, &memsize,
    9.17 -                                      &image, &vcpus, &pae, &acpi, &apic) )
    9.18 +                                      &image, &vcpus, &pae, &acpi) )
    9.19          return NULL;
    9.20  
    9.21      if ( xc_hvm_build(self->xc_handle, dom, memsize, image,
    9.22 -                      vcpus, pae, acpi, apic, store_evtchn, &store_mfn) != 0 )
    9.23 +                      vcpus, pae, acpi, store_evtchn, &store_mfn) != 0 )
    9.24          return PyErr_SetFromErrno(xc_error);
    9.25  
    9.26      return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
    10.1 --- a/tools/python/xen/xend/image.py	Sat Nov 04 20:13:22 2006 +0000
    10.2 +++ b/tools/python/xen/xend/image.py	Sun Nov 05 20:17:40 2006 +0000
    10.3 @@ -275,7 +275,6 @@ class HVMImageHandler(ImageHandler):
    10.4          self.pae  = int(sxp.child_value(imageConfig, 'pae', 0))
    10.5  
    10.6          self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
    10.7 -        self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
    10.8  
    10.9      def buildDomain(self):
   10.10          store_evtchn = self.vm.getStorePort()
   10.11 @@ -289,7 +288,6 @@ class HVMImageHandler(ImageHandler):
   10.12          log.debug("vcpus          = %d", self.vm.getVCpuCount())
   10.13          log.debug("pae            = %d", self.pae)
   10.14          log.debug("acpi           = %d", self.acpi)
   10.15 -        log.debug("apic           = %d", self.apic)
   10.16  
   10.17          self.register_shutdown_watch()
   10.18  
   10.19 @@ -299,8 +297,7 @@ class HVMImageHandler(ImageHandler):
   10.20                              memsize        = mem_mb,
   10.21                              vcpus          = self.vm.getVCpuCount(),
   10.22                              pae            = self.pae,
   10.23 -                            acpi           = self.acpi,
   10.24 -                            apic           = self.apic)
   10.25 +                            acpi           = self.acpi)
   10.26  
   10.27      # Return a list of cmd line args to the device models based on the
   10.28      # xm config file
    11.1 --- a/tools/python/xen/xm/create.py	Sat Nov 04 20:13:22 2006 +0000
    11.2 +++ b/tools/python/xen/xm/create.py	Sun Nov 05 20:17:40 2006 +0000
    11.3 @@ -181,10 +181,6 @@ gopts.var('acpi', val='ACPI',
    11.4            fn=set_int, default=0,
    11.5            use="Disable or enable ACPI of HVM domain.")
    11.6  
    11.7 -gopts.var('apic', val='APIC',
    11.8 -          fn=set_int, default=0,
    11.9 -          use="Disable or enable APIC of HVM domain.")
   11.10 -
   11.11  gopts.var('vcpus', val='VCPUS',
   11.12            fn=set_int, default=1,
   11.13            use="# of Virtual CPUS in domain.")
   11.14 @@ -664,7 +660,7 @@ def configure_hvm(config_image, vals):
   11.15               'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
   11.16               'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
   11.17               'sdl', 'display', 'xauthority',
   11.18 -             'acpi', 'apic', 'usb', 'usbdevice' ]
   11.19 +             'acpi', 'usb', 'usbdevice' ]
   11.20      for a in args:
   11.21          if (vals.__dict__[a]):
   11.22              config_image.append([a, vals.__dict__[a]])
    12.1 --- a/tools/xm-test/lib/XmTestLib/arch.py	Sat Nov 04 20:13:22 2006 +0000
    12.2 +++ b/tools/xm-test/lib/XmTestLib/arch.py	Sun Nov 05 20:17:40 2006 +0000
    12.3 @@ -71,7 +71,6 @@ ia_ParavirtDefaults = {"memory"       : 
    12.4  ia_HVMDefaults =      {"memory"       : 64,
    12.5                         "vcpus"        : 1,
    12.6                         "acpi"         : 0,
    12.7 -                       "apic"         : 0,
    12.8                         "disk"         : ["file:%s/disk.img,ioemu:%s,w!" %
    12.9                                           (getRdPath(), BLOCK_ROOT_DEV)],
   12.10                         "kernel"       : "/usr/lib/xen/boot/hvmloader",
    13.1 --- a/xen/arch/x86/domain.c	Sat Nov 04 20:13:22 2006 +0000
    13.2 +++ b/xen/arch/x86/domain.c	Sun Nov 05 20:17:40 2006 +0000
    13.3 @@ -233,24 +233,7 @@ int arch_domain_create(struct domain *d)
    13.4              virt_to_page(d->shared_info), d, XENSHARE_writable);
    13.5      }
    13.6  
    13.7 -    if ( is_hvm_domain(d) )
    13.8 -    {
    13.9 -        if ( !hvm_enabled )
   13.10 -        {
   13.11 -            gdprintk(XENLOG_WARNING, "Attempt to create a HVM guest "
   13.12 -                     "on a non-VT/AMDV platform.\n");
   13.13 -            rc = -EINVAL;
   13.14 -            goto fail;
   13.15 -        }
   13.16 -
   13.17 -        spin_lock_init(&d->arch.hvm_domain.pbuf_lock);
   13.18 -
   13.19 -        rc = shadow_enable(d, SHM2_refcounts|SHM2_translate|SHM2_external);
   13.20 -        if ( rc != 0 )
   13.21 -            goto fail;
   13.22 -    }
   13.23 -
   13.24 -    return 0;
   13.25 +    return hvm_domain_initialise(d);
   13.26  
   13.27   fail:
   13.28      free_xenheap_page(d->shared_info);
    14.1 --- a/xen/arch/x86/hvm/hvm.c	Sat Nov 04 20:13:22 2006 +0000
    14.2 +++ b/xen/arch/x86/hvm/hvm.c	Sun Nov 05 20:17:40 2006 +0000
    14.3 @@ -57,14 +57,6 @@ integer_param("hvm_debug", opt_hvm_debug
    14.4  
    14.5  struct hvm_function_table hvm_funcs;
    14.6  
    14.7 -void hvm_create_event_channel(struct vcpu *v)
    14.8 -{
    14.9 -    v->arch.hvm_vcpu.xen_port = alloc_unbound_xen_event_channel(v, 0);
   14.10 -    if ( get_sp(v->domain) && get_vio(v->domain, v->vcpu_id) )
   14.11 -        get_vio(v->domain, v->vcpu_id)->vp_eport =
   14.12 -            v->arch.hvm_vcpu.xen_port;
   14.13 -}
   14.14 -
   14.15  void hvm_stts(struct vcpu *v)
   14.16  {
   14.17      /* FPU state already dirty? Then no need to setup_fpu() lazily. */
   14.18 @@ -123,26 +115,56 @@ void hvm_release_assist_channel(struct v
   14.19      free_xen_event_channel(v, v->arch.hvm_vcpu.xen_port);
   14.20  }
   14.21  
   14.22 +int hvm_domain_initialise(struct domain *d)
   14.23 +{
   14.24 +    struct hvm_domain *platform = &d->arch.hvm_domain;
   14.25 +    int rc;
   14.26  
   14.27 -void hvm_setup_platform(struct domain *d)
   14.28 +    if ( !is_hvm_domain(d) )
   14.29 +        return 0;
   14.30 +
   14.31 +    if ( !hvm_enabled )
   14.32 +    {
   14.33 +        gdprintk(XENLOG_WARNING, "Attempt to create a HVM guest "
   14.34 +                 "on a non-VT/AMDV platform.\n");
   14.35 +        return -EINVAL;
   14.36 +    }
   14.37 +
   14.38 +    spin_lock_init(&d->arch.hvm_domain.pbuf_lock);
   14.39 +    spin_lock_init(&d->arch.hvm_domain.round_robin_lock);
   14.40 +    spin_lock_init(&d->arch.hvm_domain.buffered_io_lock);
   14.41 +
   14.42 +    rc = shadow_enable(d, SHM2_refcounts|SHM2_translate|SHM2_external);
   14.43 +    if ( rc != 0 )
   14.44 +        return rc;
   14.45 +
   14.46 +    pic_init(&platform->vpic, pic_irq_request, &platform->interrupt_request);
   14.47 +    register_pic_io_hook(d);
   14.48 +
   14.49 +    hvm_vioapic_init(d);
   14.50 +
   14.51 +    return 0;
   14.52 +}
   14.53 +
   14.54 +int hvm_vcpu_initialise(struct vcpu *v)
   14.55  {
   14.56      struct hvm_domain *platform;
   14.57 -    struct vcpu *v = current;
   14.58 +    int rc;
   14.59  
   14.60 -    if ( !is_hvm_domain(d) || (v->vcpu_id != 0) )
   14.61 -        return;
   14.62 +    if ( (rc = hvm_funcs.vcpu_initialise(v)) != 0 )
   14.63 +        return rc;
   14.64  
   14.65 -    platform = &d->arch.hvm_domain;
   14.66 -    pic_init(&platform->vpic, pic_irq_request, &platform->interrupt_request);
   14.67 -    register_pic_io_hook();
   14.68 +    /* Create ioreq event channel. */
   14.69 +    v->arch.hvm_vcpu.xen_port = alloc_unbound_xen_event_channel(v, 0);
   14.70 +    if ( get_sp(v->domain) && get_vio(v->domain, v->vcpu_id) )
   14.71 +        get_vio(v->domain, v->vcpu_id)->vp_eport =
   14.72 +            v->arch.hvm_vcpu.xen_port;
   14.73  
   14.74 -    if ( hvm_apic_support(d) )
   14.75 -    {
   14.76 -        spin_lock_init(&d->arch.hvm_domain.round_robin_lock);
   14.77 -        hvm_vioapic_init(d);
   14.78 -    }
   14.79 +    if ( v->vcpu_id != 0 )
   14.80 +        return 0;
   14.81  
   14.82 -    spin_lock_init(&d->arch.hvm_domain.buffered_io_lock);
   14.83 +    /* XXX Below should happen in hvm_domain_initialise(). */
   14.84 +    platform = &v->domain->arch.hvm_domain;
   14.85  
   14.86      init_timer(&platform->pl_time.periodic_tm.timer,
   14.87                 pt_timer_fn, v, v->processor);
   14.88 @@ -150,8 +172,10 @@ void hvm_setup_platform(struct domain *d
   14.89      rtc_init(v, RTC_PORT(0), RTC_IRQ);
   14.90      pmtimer_init(v, ACPI_PM_TMR_BLK_ADDRESS); 
   14.91  
   14.92 -    /* init guest tsc to start from 0 */
   14.93 +    /* Init guest TSC to start from zero. */
   14.94      hvm_set_guest_time(v, 0);
   14.95 +
   14.96 +    return 0;
   14.97  }
   14.98  
   14.99  void pic_irq_request(void *data, int level)
    15.1 --- a/xen/arch/x86/hvm/i8254.c	Sat Nov 04 20:13:22 2006 +0000
    15.2 +++ b/xen/arch/x86/hvm/i8254.c	Sun Nov 05 20:17:40 2006 +0000
    15.3 @@ -374,9 +374,9 @@ void pit_init(struct vcpu *v, unsigned l
    15.4      s++; s->vcpu = v;
    15.5      s++; s->vcpu = v;
    15.6  
    15.7 -    register_portio_handler(PIT_BASE, 4, handle_pit_io);
    15.8 +    register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io);
    15.9      /* register the speaker port */
   15.10 -    register_portio_handler(0x61, 1, handle_speaker_io);
   15.11 +    register_portio_handler(v->domain, 0x61, 1, handle_speaker_io);
   15.12      ticks_per_sec(v) = cpu_khz * (int64_t)1000;
   15.13  #ifdef DEBUG_PIT
   15.14      printk("HVM_PIT: guest frequency =%lld\n", (long long)ticks_per_sec(v));
    16.1 --- a/xen/arch/x86/hvm/i8259.c	Sat Nov 04 20:13:22 2006 +0000
    16.2 +++ b/xen/arch/x86/hvm/i8259.c	Sun Nov 05 20:17:40 2006 +0000
    16.3 @@ -548,12 +548,12 @@ static int intercept_elcr_io(ioreq_t *p)
    16.4      return 1;
    16.5  }
    16.6  
    16.7 -void register_pic_io_hook (void)
    16.8 +void register_pic_io_hook(struct domain *d)
    16.9  {
   16.10 -    register_portio_handler(0x20, 2, intercept_pic_io);
   16.11 -    register_portio_handler(0x4d0, 1, intercept_elcr_io);
   16.12 -    register_portio_handler(0xa0, 2, intercept_pic_io);
   16.13 -    register_portio_handler(0x4d1, 1, intercept_elcr_io);
   16.14 +    register_portio_handler(d, 0x20, 2, intercept_pic_io);
   16.15 +    register_portio_handler(d, 0x4d0, 1, intercept_elcr_io);
   16.16 +    register_portio_handler(d, 0xa0, 2, intercept_pic_io);
   16.17 +    register_portio_handler(d, 0x4d1, 1, intercept_elcr_io);
   16.18  }
   16.19  
   16.20  
    17.1 --- a/xen/arch/x86/hvm/intercept.c	Sat Nov 04 20:13:22 2006 +0000
    17.2 +++ b/xen/arch/x86/hvm/intercept.c	Sun Nov 05 20:17:40 2006 +0000
    17.3 @@ -208,18 +208,17 @@ int hvm_mmio_intercept(ioreq_t *p)
    17.4      struct vcpu *v = current;
    17.5      int i;
    17.6  
    17.7 -    /* XXX currently only APIC use intercept */
    17.8 -    if ( !hvm_apic_support(v->domain) )
    17.9 -        return 0;
   17.10 -
   17.11 -    for ( i = 0; i < HVM_MMIO_HANDLER_NR; i++ ) {
   17.12 -        if ( hvm_mmio_handlers[i]->check_handler(v, p->addr) ) {
   17.13 +    for ( i = 0; i < HVM_MMIO_HANDLER_NR; i++ )
   17.14 +    {
   17.15 +        if ( hvm_mmio_handlers[i]->check_handler(v, p->addr) )
   17.16 +        {
   17.17              hvm_mmio_access(v, p,
   17.18                              hvm_mmio_handlers[i]->read_handler,
   17.19                              hvm_mmio_handlers[i]->write_handler);
   17.20              return 1;
   17.21          }
   17.22      }
   17.23 +
   17.24      return 0;
   17.25  }
   17.26  
   17.27 @@ -247,15 +246,15 @@ int hvm_io_intercept(ioreq_t *p, int typ
   17.28      return 0;
   17.29  }
   17.30  
   17.31 -int register_io_handler(unsigned long addr, unsigned long size,
   17.32 -                        intercept_action_t action, int type)
   17.33 +int register_io_handler(
   17.34 +    struct domain *d, unsigned long addr, unsigned long size,
   17.35 +    intercept_action_t action, int type)
   17.36  {
   17.37 -    struct vcpu *v = current;
   17.38 -    struct hvm_io_handler *handler =
   17.39 -                             &(v->domain->arch.hvm_domain.io_handler);
   17.40 +    struct hvm_io_handler *handler = &d->arch.hvm_domain.io_handler;
   17.41      int num = handler->num_slot;
   17.42  
   17.43 -    if (num >= MAX_IO_HANDLER) {
   17.44 +    if ( num >= MAX_IO_HANDLER )
   17.45 +    {
   17.46          printk("no extra space, register io interceptor failed!\n");
   17.47          domain_crash_synchronous();
   17.48      }
    18.1 --- a/xen/arch/x86/hvm/pmtimer.c	Sat Nov 04 20:13:22 2006 +0000
    18.2 +++ b/xen/arch/x86/hvm/pmtimer.c	Sun Nov 05 20:17:40 2006 +0000
    18.3 @@ -52,7 +52,7 @@ void pmtimer_init(struct vcpu *v, int ba
    18.4      /* ACPI supports a 32-bit power management timer */
    18.5      set_timer(&s->timer, NOW() + (1000000000ULL << 31) / FREQUENCE_PMTIMER);
    18.6      
    18.7 -    register_portio_handler(base, 4, handle_pmt_io);
    18.8 +    register_portio_handler(v->domain, base, 4, handle_pmt_io);
    18.9  }
   18.10  
   18.11  void pmtimer_deinit(struct domain *d)
    19.1 --- a/xen/arch/x86/hvm/rtc.c	Sat Nov 04 20:13:22 2006 +0000
    19.2 +++ b/xen/arch/x86/hvm/rtc.c	Sun Nov 05 20:17:40 2006 +0000
    19.3 @@ -381,7 +381,7 @@ void rtc_init(struct vcpu *v, int base, 
    19.4      s->next_second_time = NOW() + 1000000000ULL;
    19.5      set_timer(&s->second_timer2, s->next_second_time);
    19.6  
    19.7 -    register_portio_handler(base, 2, handle_rtc_io);
    19.8 +    register_portio_handler(v->domain, base, 2, handle_rtc_io);
    19.9  }
   19.10  
   19.11  void rtc_deinit(struct domain *d)
    20.1 --- a/xen/arch/x86/hvm/svm/svm.c	Sat Nov 04 20:13:22 2006 +0000
    20.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Sun Nov 05 20:17:40 2006 +0000
    20.3 @@ -1046,8 +1046,7 @@ static void svm_vmexit_do_cpuid(struct v
    20.4          cpuid(input, &eax, &ebx, &ecx, &edx);       
    20.5          if (input == 0x00000001 || input == 0x80000001 )
    20.6          {
    20.7 -            if ( !hvm_apic_support(v->domain) ||
    20.8 -                 !vlapic_global_enabled((VLAPIC(v))) )
    20.9 +            if ( !vlapic_global_enabled((VLAPIC(v))) )
   20.10              {
   20.11                  /* Since the apic is disabled, avoid any confusion 
   20.12                     about SMP cpus being available */
    21.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Sat Nov 04 20:13:22 2006 +0000
    21.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Sun Nov 05 20:17:40 2006 +0000
    21.3 @@ -355,11 +355,7 @@ void svm_do_launch(struct vcpu *v)
    21.4      if ( !asidpool_assign_next( vmcb, 0, core, core ))
    21.5          BUG();
    21.6  
    21.7 -    if (v->vcpu_id == 0)
    21.8 -        hvm_setup_platform(v->domain);
    21.9 -
   21.10 -    if (hvm_apic_support(v->domain))
   21.11 -        vlapic_init(v);
   21.12 +    vlapic_init(v);
   21.13      init_timer(&v->arch.hvm_vcpu.hlt_timer, hlt_timer_fn, v, v->processor);
   21.14  
   21.15      vmcb->ldtr.sel = 0;
    22.1 --- a/xen/arch/x86/hvm/vioapic.c	Sat Nov 04 20:13:22 2006 +0000
    22.2 +++ b/xen/arch/x86/hvm/vioapic.c	Sun Nov 05 20:17:40 2006 +0000
    22.3 @@ -530,9 +530,6 @@ void hvm_vioapic_do_irqs(struct domain *
    22.4  {
    22.5      hvm_vioapic_t *s = &(d->arch.hvm_domain.vioapic);
    22.6  
    22.7 -    if (!hvm_apic_support(d))
    22.8 -        return;
    22.9 -
   22.10      s->irr |= irqs & ~s->imr;
   22.11      service_ioapic(s);
   22.12  }
   22.13 @@ -541,9 +538,6 @@ void hvm_vioapic_do_irqs_clear(struct do
   22.14  {
   22.15      hvm_vioapic_t *s = &(d->arch.hvm_domain.vioapic);
   22.16  
   22.17 -    if (!hvm_apic_support(d))
   22.18 -        return;
   22.19 -
   22.20      s->irr &= ~irqs;
   22.21      service_ioapic(s);
   22.22  }
   22.23 @@ -552,8 +546,7 @@ void hvm_vioapic_set_xen_irq(struct doma
   22.24  {
   22.25      hvm_vioapic_t *s = &d->arch.hvm_domain.vioapic;
   22.26  
   22.27 -    if (!hvm_apic_support(d) || !IOAPICEnabled(s) ||
   22.28 -	s->redirtbl[irq].RedirForm.mask)
   22.29 +    if (!IOAPICEnabled(s) || s->redirtbl[irq].RedirForm.mask)
   22.30          return;
   22.31  
   22.32      if (s->redirtbl[irq].RedirForm.trigmod != IOAPIC_LEVEL_TRIGGER)
   22.33 @@ -569,9 +562,6 @@ void hvm_vioapic_set_irq(struct domain *
   22.34  {
   22.35      hvm_vioapic_t *s = &(d->arch.hvm_domain.vioapic);
   22.36  
   22.37 -    if (!hvm_apic_support(d))
   22.38 -        return ;
   22.39 -
   22.40      HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "ioapic_set_irq "
   22.41        "irq %x level %x\n", irq, level);
   22.42  
    23.1 --- a/xen/arch/x86/hvm/vlapic.c	Sat Nov 04 20:13:22 2006 +0000
    23.2 +++ b/xen/arch/x86/hvm/vlapic.c	Sun Nov 05 20:17:40 2006 +0000
    23.3 @@ -155,17 +155,11 @@ int vlapic_set_irq(struct vlapic *vlapic
    23.4      return ret;
    23.5  }
    23.6  
    23.7 -int hvm_apic_support(struct domain *d)
    23.8 -{
    23.9 -    return d->arch.hvm_domain.params[HVM_PARAM_APIC_ENABLED];
   23.10 -}
   23.11 -
   23.12  s_time_t get_apictime_scheduled(struct vcpu *v)
   23.13  {
   23.14      struct vlapic *vlapic = VLAPIC(v);
   23.15  
   23.16 -    if ( !hvm_apic_support(v->domain) ||
   23.17 -         !vlapic_lvt_enabled(vlapic, APIC_LVTT) )
   23.18 +    if ( !vlapic_lvt_enabled(vlapic, APIC_LVTT) )
   23.19          return -1;
   23.20  
   23.21      return vlapic->vlapic_timer.expires;
    24.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Sat Nov 04 20:13:22 2006 +0000
    24.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Sun Nov 05 20:17:40 2006 +0000
    24.3 @@ -307,9 +307,8 @@ static void vmx_do_launch(struct vcpu *v
    24.4      unsigned int  error = 0;
    24.5      unsigned long cr0, cr4;
    24.6  
    24.7 -    if ( v->vcpu_id == 0 )
    24.8 -        hvm_setup_platform(v->domain);
    24.9 -    else {
   24.10 +    if ( v->vcpu_id != 0 )
   24.11 +    {
   24.12          /* Sync AP's TSC with BSP's */
   24.13          v->arch.hvm_vcpu.cache_tsc_offset = 
   24.14              v->domain->vcpu[0]->arch.hvm_vcpu.cache_tsc_offset;
   24.15 @@ -333,7 +332,7 @@ static void vmx_do_launch(struct vcpu *v
   24.16  
   24.17      hvm_stts(v);
   24.18  
   24.19 -    if( hvm_apic_support(v->domain) && (vlapic_init(v) == 0) )
   24.20 +    if ( vlapic_init(v) == 0 )
   24.21      {
   24.22  #ifdef __x86_64__ 
   24.23          u32 *cpu_exec_control = &v->arch.hvm_vcpu.u.vmx.exec_control;
    25.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Sat Nov 04 20:13:22 2006 +0000
    25.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Sun Nov 05 20:17:40 2006 +0000
    25.3 @@ -905,17 +905,11 @@ static void vmx_do_cpuid(struct cpu_user
    25.4  
    25.5          if ( input == CPUID_LEAF_0x1 )
    25.6          {
    25.7 -            /* mask off reserved bits */
    25.8 +            /* Mask off reserved bits. */
    25.9              ecx &= ~VMX_VCPU_CPUID_L1_ECX_RESERVED;
   25.10  
   25.11 -            if ( !hvm_apic_support(v->domain) ||
   25.12 -                 !vlapic_global_enabled((VLAPIC(v))) )
   25.13 -            {
   25.14 -                /* Since the apic is disabled, avoid any 
   25.15 -                confusion about SMP cpus being available */
   25.16 -
   25.17 +            if ( !vlapic_global_enabled((VLAPIC(v))) )
   25.18                  clear_bit(X86_FEATURE_APIC, &edx);
   25.19 -            }
   25.20      
   25.21  #if CONFIG_PAGING_LEVELS >= 3
   25.22              if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_PAE_ENABLED] )
    26.1 --- a/xen/arch/x86/mm.c	Sat Nov 04 20:13:22 2006 +0000
    26.2 +++ b/xen/arch/x86/mm.c	Sun Nov 05 20:17:40 2006 +0000
    26.3 @@ -572,7 +572,7 @@ get_page_from_l1e(
    26.4  
    26.5          if ( !iomem_access_permitted(d, mfn, mfn) )
    26.6          {
    26.7 -            if ( mfn != INVALID_MFN )
    26.8 +            if ( mfn != (PADDR_MASK >> PAGE_SHIFT) ) /* INVALID_MFN? */
    26.9                  MEM_LOG("Non-privileged (%u) attempt to map I/O space %08lx", 
   26.10                          d->domain_id, mfn);
   26.11              return 0;
    27.1 --- a/xen/include/asm-ia64/vmx_platform.h	Sat Nov 04 20:13:22 2006 +0000
    27.2 +++ b/xen/include/asm-ia64/vmx_platform.h	Sun Nov 05 20:17:40 2006 +0000
    27.3 @@ -73,9 +73,7 @@ enum ioapic_irq_destination_types {
    27.4  	dest_ExtINT = 7
    27.5  };
    27.6  
    27.7 -/* As long as we register vlsapic to ioapic controller, it's said enabled */
    27.8  #define vlapic_enabled(l) 1
    27.9 -#define hvm_apic_support(d) 1
   27.10  
   27.11  #define VLAPIC_DELIV_MODE_FIXED		0x0
   27.12  #define VLAPIC_DELIV_MODE_REDIR		0x1
    28.1 --- a/xen/include/asm-x86/hvm/hvm.h	Sat Nov 04 20:13:22 2006 +0000
    28.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Sun Nov 05 20:17:40 2006 +0000
    28.3 @@ -91,16 +91,8 @@ hvm_disable(void)
    28.4          hvm_funcs.disable();
    28.5  }
    28.6  
    28.7 -void hvm_create_event_channel(struct vcpu *v);
    28.8 -
    28.9 -static inline int
   28.10 -hvm_vcpu_initialise(struct vcpu *v)
   28.11 -{
   28.12 -    int rc;
   28.13 -    if ( (rc = hvm_funcs.vcpu_initialise(v)) == 0 )
   28.14 -        hvm_create_event_channel(v);
   28.15 -    return rc;
   28.16 -}
   28.17 +int hvm_domain_initialise(struct domain *d);
   28.18 +int hvm_vcpu_initialise(struct vcpu *v);
   28.19  
   28.20  static inline void
   28.21  hvm_relinquish_guest_resources(struct domain *d)
    29.1 --- a/xen/include/asm-x86/hvm/io.h	Sat Nov 04 20:13:22 2006 +0000
    29.2 +++ b/xen/include/asm-x86/hvm/io.h	Sun Nov 05 20:17:40 2006 +0000
    29.3 @@ -116,8 +116,9 @@ struct hvm_mmio_handler {
    29.4  
    29.5  /* global io interception point in HV */
    29.6  extern int hvm_io_intercept(ioreq_t *p, int type);
    29.7 -extern int register_io_handler(unsigned long addr, unsigned long size,
    29.8 -                               intercept_action_t action, int type);
    29.9 +extern int register_io_handler(
   29.10 +    struct domain *d, unsigned long addr, unsigned long size,
   29.11 +    intercept_action_t action, int type);
   29.12  
   29.13  static inline int hvm_portio_intercept(ioreq_t *p)
   29.14  {
   29.15 @@ -127,11 +128,11 @@ static inline int hvm_portio_intercept(i
   29.16  extern int hvm_mmio_intercept(ioreq_t *p);
   29.17  extern int hvm_buffered_io_intercept(ioreq_t *p);
   29.18  
   29.19 -static inline int register_portio_handler(unsigned long addr,
   29.20 -                                          unsigned long size,
   29.21 -                                          intercept_action_t action)
   29.22 +static inline int register_portio_handler(
   29.23 +    struct domain *d, unsigned long addr,
   29.24 +    unsigned long size, intercept_action_t action)
   29.25  {
   29.26 -    return register_io_handler(addr, size, action, HVM_PORTIO);
   29.27 +    return register_io_handler(d, addr, size, action, HVM_PORTIO);
   29.28  }
   29.29  
   29.30  #if defined(__i386__) || defined(__x86_64__)
    30.1 --- a/xen/include/asm-x86/hvm/support.h	Sat Nov 04 20:13:22 2006 +0000
    30.2 +++ b/xen/include/asm-x86/hvm/support.h	Sun Nov 05 20:17:40 2006 +0000
    30.3 @@ -139,7 +139,6 @@ int hvm_copy_from_guest_phys(void *buf, 
    30.4  int hvm_copy_to_guest_virt(unsigned long vaddr, void *buf, int size);
    30.5  int hvm_copy_from_guest_virt(void *buf, unsigned long vaddr, int size);
    30.6  
    30.7 -void hvm_setup_platform(struct domain* d);
    30.8  void hvm_print_line(struct vcpu *v, const char c);
    30.9  void hlt_timer_fn(void *data);
   30.10  
    31.1 --- a/xen/include/asm-x86/hvm/vlapic.h	Sat Nov 04 20:13:22 2006 +0000
    31.2 +++ b/xen/include/asm-x86/hvm/vlapic.h	Sun Nov 05 20:17:40 2006 +0000
    31.3 @@ -90,6 +90,4 @@ struct vlapic *apic_round_robin(struct d
    31.4  
    31.5  s_time_t get_apictime_scheduled(struct vcpu *v);
    31.6  
    31.7 -int hvm_apic_support(struct domain *d);
    31.8 -
    31.9  #endif /* __ASM_X86_HVM_VLAPIC_H__ */
    32.1 --- a/xen/include/asm-x86/hvm/vpic.h	Sat Nov 04 20:13:22 2006 +0000
    32.2 +++ b/xen/include/asm-x86/hvm/vpic.h	Sun Nov 05 20:17:40 2006 +0000
    32.3 @@ -71,7 +71,7 @@ void pic_init(struct hvm_virpic *s,
    32.4                void (*irq_request)(void *, int),
    32.5                void *irq_request_opaque);
    32.6  void pic_update_irq(struct hvm_virpic *s); /* Caller must hold s->lock */
    32.7 -void register_pic_io_hook (void);
    32.8 +void register_pic_io_hook(struct domain *d);
    32.9  int cpu_get_pic_interrupt(struct vcpu *v, int *type);
   32.10  int is_periodic_irq(struct vcpu *v, int irq, int type);
   32.11  int is_irq_enabled(struct vcpu *v, int irq);
    33.1 --- a/xen/include/public/hvm/params.h	Sat Nov 04 20:13:22 2006 +0000
    33.2 +++ b/xen/include/public/hvm/params.h	Sun Nov 05 20:17:40 2006 +0000
    33.3 @@ -5,7 +5,6 @@
    33.4  #define HVM_PARAM_CALLBACK_IRQ 0
    33.5  #define HVM_PARAM_STORE_PFN    1
    33.6  #define HVM_PARAM_STORE_EVTCHN 2
    33.7 -#define HVM_PARAM_APIC_ENABLED 3
    33.8  #define HVM_PARAM_PAE_ENABLED  4
    33.9  #define HVM_PARAM_IOREQ_PFN    5
   33.10  #define HVM_PARAM_BUFIOREQ_PFN 6