[XEN] Replace hvm_setup_platform() with hvm_domain_initialise()
authorkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Sun, 5 Nov 2006 20:17:40 +0000 (20:17 +0000)
committerkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Sun, 5 Nov 2006 20:17:40 +0000 (20:17 +0000)
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>
33 files changed:
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

index 20b58af44bdee83514a5d3e059bbc4f809e6f74d..5f10a76fb6bcd2a56349df872d9a8c46ae15e83c 100644 (file)
@@ -48,9 +48,6 @@ name = "ExampleHVMDomain"
 # enable/disable HVM guest ACPI, default=0 (disabled)
 #acpi=0
 
-# enable/disable HVM guest APIC, default=0 (disabled)
-#apic=0
-
 # List of which CPUS this domain is allowed to use, default Xen picks
 #cpus = ""         # leave to Xen to pick
 #cpus = "0"        # all vcpus run on CPU0
index a4adff8a890686dc3a77c7f1ea5181cee89801d4..49a870bb0de5261c7b6ad13170ef37ba64a26cbf 100644 (file)
@@ -165,8 +165,6 @@ init_hypercalls(void)
 int
 main(void)
 {
-       struct xen_hvm_param hvm_param;
-
        puts("HVM Loader\n");
 
        init_hypercalls();
@@ -177,10 +175,7 @@ main(void)
        puts("Loading ROMBIOS ...\n");
        memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
 
-       hvm_param.domid = DOMID_SELF;
-       hvm_param.index = HVM_PARAM_APIC_ENABLED;
-       if (!hypercall_hvm_op(HVMOP_get_param, &hvm_param) && hvm_param.value)
-               create_mp_tables();
+        create_mp_tables();
        
        if (cirrus_check()) {
                puts("Loading Cirrus VGABIOS ...\n");
index 0caaf343b35abd4aa536600c46a9c14e9a75a520..ad5c6fdabd10889c59c38b2b05cbd6aa09ca304c 100644 (file)
@@ -618,7 +618,7 @@ error_out:
 int
 xc_hvm_build(int xc_handle, uint32_t domid, int memsize,
              const char *image_name, unsigned int vcpus, unsigned int pae,
-             unsigned int acpi, unsigned int apic, unsigned int store_evtchn,
+             unsigned int acpi, unsigned int store_evtchn,
              unsigned long *store_mfn)
 {
     struct xen_domctl launch_domctl, domctl;
index 300d7ae428c032d7c95df2d1622645654580fec6..8995c6092517d11297d1c95203fcbb611f2cf145 100644 (file)
@@ -157,7 +157,6 @@ static int setup_guest(int xc_handle,
                        unsigned int vcpus,
                        unsigned int pae,
                        unsigned int acpi,
-                       unsigned int apic,
                        unsigned int store_evtchn,
                        unsigned long *store_mfn)
 {
@@ -248,7 +247,6 @@ static int setup_guest(int xc_handle,
     }
 
     xc_set_hvm_param(xc_handle, dom, HVM_PARAM_PAE_ENABLED, pae);
-    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_APIC_ENABLED, apic);
 
     if ( (e820_page = xc_map_foreign_range(
               xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
@@ -307,7 +305,6 @@ static int xc_hvm_build_internal(int xc_handle,
                                  unsigned int vcpus,
                                  unsigned int pae,
                                  unsigned int acpi,
-                                 unsigned int apic,
                                  unsigned int store_evtchn,
                                  unsigned long *store_mfn)
 {
@@ -340,7 +337,7 @@ static int xc_hvm_build_internal(int xc_handle,
 
     if ( setup_guest(xc_handle, domid, memsize, image, image_size,
                      ctxt, domctl.u.getdomaininfo.shared_info_frame,
-                     vcpus, pae, acpi, apic, store_evtchn, store_mfn) < 0)
+                     vcpus, pae, acpi, store_evtchn, store_mfn) < 0)
     {
         ERROR("Error constructing guest OS");
         goto error_out;
@@ -531,7 +528,6 @@ int xc_hvm_build(int xc_handle,
                  unsigned int vcpus,
                  unsigned int pae,
                  unsigned int acpi,
-                 unsigned int apic,
                  unsigned int store_evtchn,
                  unsigned long *store_mfn)
 {
@@ -545,7 +541,7 @@ int xc_hvm_build(int xc_handle,
 
     sts = xc_hvm_build_internal(xc_handle, domid, memsize,
                                 image, image_size,
-                                vcpus, pae, acpi, apic,
+                                vcpus, pae, acpi,
                                 store_evtchn, store_mfn);
 
     free(image);
@@ -567,7 +563,6 @@ int xc_hvm_build_mem(int xc_handle,
                      unsigned int vcpus,
                      unsigned int pae,
                      unsigned int acpi,
-                     unsigned int apic,
                      unsigned int store_evtchn,
                      unsigned long *store_mfn)
 {
@@ -592,7 +587,7 @@ int xc_hvm_build_mem(int xc_handle,
 
     sts = xc_hvm_build_internal(xc_handle, domid, memsize,
                                 img, img_len,
-                                vcpus, pae, acpi, apic,
+                                vcpus, pae, acpi,
                                 store_evtchn, store_mfn);
 
     /* xc_inflate_buffer may return the original buffer pointer (for
index 75e0c47be5a720ce3a802dbac73353aa0703a226..d6343fbf5c6976fa9c144babdb39368f53d6e428 100644 (file)
@@ -113,7 +113,6 @@ int xc_hvm_build(int xc_handle,
                  unsigned int vcpus,
                  unsigned int pae,
                  unsigned int acpi,
-                 unsigned int apic,
                  unsigned int store_evtchn,
                  unsigned long *store_mfn);
 
@@ -125,7 +124,6 @@ int xc_hvm_build_mem(int xc_handle,
                      unsigned int vcpus,
                      unsigned int pae,
                      unsigned int acpi,
-                     unsigned int apic,
                      unsigned int store_evtchn,
                      unsigned long *store_mfn);
 
index 3c50552290bb07188de43f589d3b085bb7163758..49fcb624e85860231db7188142307983670cfb9e 100644 (file)
@@ -196,7 +196,6 @@ __attribute__((weak)) int xc_hvm_build(
     unsigned int vcpus,
     unsigned int pae,
     unsigned int acpi,
-    unsigned int apic,
     unsigned int store_evtchn,
     unsigned long *store_mfn)
 {
index 2e677f887a4595d4e554dee3c3756e6d8232ca8c..d860aac9c741ce935a47845c626674740aa90124 100644 (file)
@@ -123,7 +123,6 @@ otherConfig
                                 image.hvm.vncconsole
                                 image.hvm.pae
                                 image.hvm.acpi (also in image.devices)
-                                image.hvm.apic
                                 image.hvm.devices.boot
                                 image.hvm.devices.fda
                                 image.hvm.devices.fdb
index 9beffd6ba0988b256a9423cde918f619a9af14b2..9f7b7877899151902574f7636a250f43b85e695e 100644 (file)
@@ -56,7 +56,6 @@ image
   - vncconsole
   - pae
   - acpi
-  - apic
   (parseDeviceModel)
   - boot
   - fda
index d267164d8b718cc0679d6fa65cd7c7d8e69caa26..51831838f761bda9d772110c521551bf250e6e02 100644 (file)
@@ -377,19 +377,18 @@ static PyObject *pyxc_hvm_build(XcObject *self,
     int vcpus = 1;
     int pae  = 0;
     int acpi = 0;
-    int apic = 0;
     unsigned long store_mfn = 0;
 
     static char *kwd_list[] = { "domid", "store_evtchn",
-                               "memsize", "image", "vcpus", "pae", "acpi", "apic",
+                               "memsize", "image", "vcpus", "pae", "acpi",
                                NULL };
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiiii", kwd_list,
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiii", kwd_list,
                                       &dom, &store_evtchn, &memsize,
-                                      &image, &vcpus, &pae, &acpi, &apic) )
+                                      &image, &vcpus, &pae, &acpi) )
         return NULL;
 
     if ( xc_hvm_build(self->xc_handle, dom, memsize, image,
-                      vcpus, pae, acpi, apic, store_evtchn, &store_mfn) != 0 )
+                      vcpus, pae, acpi, store_evtchn, &store_mfn) != 0 )
         return PyErr_SetFromErrno(xc_error);
 
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
index c70c94fc00954a6d16901d409fcfbcfabbbc19ce..f140c158c72984749fbbbfb32d7420cbece765ca 100644 (file)
@@ -275,7 +275,6 @@ class HVMImageHandler(ImageHandler):
         self.pae  = int(sxp.child_value(imageConfig, 'pae', 0))
 
         self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
-        self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
 
     def buildDomain(self):
         store_evtchn = self.vm.getStorePort()
@@ -289,7 +288,6 @@ class HVMImageHandler(ImageHandler):
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
         log.debug("pae            = %d", self.pae)
         log.debug("acpi           = %d", self.acpi)
-        log.debug("apic           = %d", self.apic)
 
         self.register_shutdown_watch()
 
@@ -299,8 +297,7 @@ class HVMImageHandler(ImageHandler):
                             memsize        = mem_mb,
                             vcpus          = self.vm.getVCpuCount(),
                             pae            = self.pae,
-                            acpi           = self.acpi,
-                            apic           = self.apic)
+                            acpi           = self.acpi)
 
     # Return a list of cmd line args to the device models based on the
     # xm config file
index eadd79891a3c62e1efd6163fb5da8591a3092771..1bb5171eef3a62a95417c818c96f4d3f77a8f547 100644 (file)
@@ -181,10 +181,6 @@ gopts.var('acpi', val='ACPI',
           fn=set_int, default=0,
           use="Disable or enable ACPI of HVM domain.")
 
-gopts.var('apic', val='APIC',
-          fn=set_int, default=0,
-          use="Disable or enable APIC of HVM domain.")
-
 gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
           use="# of Virtual CPUS in domain.")
@@ -664,7 +660,7 @@ def configure_hvm(config_image, vals):
              'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
              'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
              'sdl', 'display', 'xauthority',
-             'acpi', 'apic', 'usb', 'usbdevice' ]
+             'acpi', 'usb', 'usbdevice' ]
     for a in args:
         if (vals.__dict__[a]):
             config_image.append([a, vals.__dict__[a]])
index 5625a535460e7f27c15d9770b08560ce33c41400..331ede54144014018df69f01acefda0a2331ef86 100644 (file)
@@ -71,7 +71,6 @@ ia_ParavirtDefaults = {"memory"       : 64,
 ia_HVMDefaults =      {"memory"       : 64,
                        "vcpus"        : 1,
                        "acpi"         : 0,
-                       "apic"         : 0,
                        "disk"         : ["file:%s/disk.img,ioemu:%s,w!" %
                                          (getRdPath(), BLOCK_ROOT_DEV)],
                        "kernel"       : "/usr/lib/xen/boot/hvmloader",
index 6a2bc549b79b6a7758b27b5d902d68158fd73756..da2e29f77278c25f2bde252c0bd0b2820342e5b6 100644 (file)
@@ -233,24 +233,7 @@ int arch_domain_create(struct domain *d)
             virt_to_page(d->shared_info), d, XENSHARE_writable);
     }
 
-    if ( is_hvm_domain(d) )
-    {
-        if ( !hvm_enabled )
-        {
-            gdprintk(XENLOG_WARNING, "Attempt to create a HVM guest "
-                     "on a non-VT/AMDV platform.\n");
-            rc = -EINVAL;
-            goto fail;
-        }
-
-        spin_lock_init(&d->arch.hvm_domain.pbuf_lock);
-
-        rc = shadow_enable(d, SHM2_refcounts|SHM2_translate|SHM2_external);
-        if ( rc != 0 )
-            goto fail;
-    }
-
-    return 0;
+    return hvm_domain_initialise(d);
 
  fail:
     free_xenheap_page(d->shared_info);
index f423f41c6c4bf5a3d796c6fa448281b38243ae27..e785d31882629df2b1cd80f64a093822b6e268ea 100644 (file)
@@ -57,14 +57,6 @@ integer_param("hvm_debug", opt_hvm_debug_level);
 
 struct hvm_function_table hvm_funcs;
 
-void hvm_create_event_channel(struct vcpu *v)
-{
-    v->arch.hvm_vcpu.xen_port = alloc_unbound_xen_event_channel(v, 0);
-    if ( get_sp(v->domain) && get_vio(v->domain, v->vcpu_id) )
-        get_vio(v->domain, v->vcpu_id)->vp_eport =
-            v->arch.hvm_vcpu.xen_port;
-}
-
 void hvm_stts(struct vcpu *v)
 {
     /* FPU state already dirty? Then no need to setup_fpu() lazily. */
@@ -123,35 +115,67 @@ void hvm_release_assist_channel(struct vcpu *v)
     free_xen_event_channel(v, v->arch.hvm_vcpu.xen_port);
 }
 
-
-void hvm_setup_platform(struct domain *d)
+int hvm_domain_initialise(struct domain *d)
 {
-    struct hvm_domain *platform;
-    struct vcpu *v = current;
-
-    if ( !is_hvm_domain(d) || (v->vcpu_id != 0) )
-        return;
+    struct hvm_domain *platform = &d->arch.hvm_domain;
+    int rc;
 
-    platform = &d->arch.hvm_domain;
-    pic_init(&platform->vpic, pic_irq_request, &platform->interrupt_request);
-    register_pic_io_hook();
+    if ( !is_hvm_domain(d) )
+        return 0;
 
-    if ( hvm_apic_support(d) )
+    if ( !hvm_enabled )
     {
-        spin_lock_init(&d->arch.hvm_domain.round_robin_lock);
-        hvm_vioapic_init(d);
+        gdprintk(XENLOG_WARNING, "Attempt to create a HVM guest "
+                 "on a non-VT/AMDV platform.\n");
+        return -EINVAL;
     }
 
+    spin_lock_init(&d->arch.hvm_domain.pbuf_lock);
+    spin_lock_init(&d->arch.hvm_domain.round_robin_lock);
     spin_lock_init(&d->arch.hvm_domain.buffered_io_lock);
 
+    rc = shadow_enable(d, SHM2_refcounts|SHM2_translate|SHM2_external);
+    if ( rc != 0 )
+        return rc;
+
+    pic_init(&platform->vpic, pic_irq_request, &platform->interrupt_request);
+    register_pic_io_hook(d);
+
+    hvm_vioapic_init(d);
+
+    return 0;
+}
+
+int hvm_vcpu_initialise(struct vcpu *v)
+{
+    struct hvm_domain *platform;
+    int rc;
+
+    if ( (rc = hvm_funcs.vcpu_initialise(v)) != 0 )
+        return rc;
+
+    /* Create ioreq event channel. */
+    v->arch.hvm_vcpu.xen_port = alloc_unbound_xen_event_channel(v, 0);
+    if ( get_sp(v->domain) && get_vio(v->domain, v->vcpu_id) )
+        get_vio(v->domain, v->vcpu_id)->vp_eport =
+            v->arch.hvm_vcpu.xen_port;
+
+    if ( v->vcpu_id != 0 )
+        return 0;
+
+    /* XXX Below should happen in hvm_domain_initialise(). */
+    platform = &v->domain->arch.hvm_domain;
+
     init_timer(&platform->pl_time.periodic_tm.timer,
                pt_timer_fn, v, v->processor);
     pit_init(v, cpu_khz);
     rtc_init(v, RTC_PORT(0), RTC_IRQ);
     pmtimer_init(v, ACPI_PM_TMR_BLK_ADDRESS); 
 
-    /* init guest tsc to start from 0 */
+    /* Init guest TSC to start from zero. */
     hvm_set_guest_time(v, 0);
+
+    return 0;
 }
 
 void pic_irq_request(void *data, int level)
index 96a80cf67033013cda6622befc9517335c7d048b..516c114907ed5ea5d8c1ec30f6ac0c246e99d3ca 100644 (file)
@@ -374,9 +374,9 @@ void pit_init(struct vcpu *v, unsigned long cpu_khz)
     s++; s->vcpu = v;
     s++; s->vcpu = v;
 
-    register_portio_handler(PIT_BASE, 4, handle_pit_io);
+    register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io);
     /* register the speaker port */
-    register_portio_handler(0x61, 1, handle_speaker_io);
+    register_portio_handler(v->domain, 0x61, 1, handle_speaker_io);
     ticks_per_sec(v) = cpu_khz * (int64_t)1000;
 #ifdef DEBUG_PIT
     printk("HVM_PIT: guest frequency =%lld\n", (long long)ticks_per_sec(v));
index 5da40cf7f926a3f4575169e64d9622c6f9a81dcb..d22eaa8ca9f7566dcf7877020d16146b04f0e1d4 100644 (file)
@@ -548,12 +548,12 @@ static int intercept_elcr_io(ioreq_t *p)
     return 1;
 }
 
-void register_pic_io_hook (void)
+void register_pic_io_hook(struct domain *d)
 {
-    register_portio_handler(0x20, 2, intercept_pic_io);
-    register_portio_handler(0x4d0, 1, intercept_elcr_io);
-    register_portio_handler(0xa0, 2, intercept_pic_io);
-    register_portio_handler(0x4d1, 1, intercept_elcr_io);
+    register_portio_handler(d, 0x20, 2, intercept_pic_io);
+    register_portio_handler(d, 0x4d0, 1, intercept_elcr_io);
+    register_portio_handler(d, 0xa0, 2, intercept_pic_io);
+    register_portio_handler(d, 0x4d1, 1, intercept_elcr_io);
 }
 
 
index 8a6dc963dfdd57f02ea3a9c6f367426d8724dce2..839d29787ab57af559d6e2072e5681e2ec91dbe3 100644 (file)
@@ -208,18 +208,17 @@ int hvm_mmio_intercept(ioreq_t *p)
     struct vcpu *v = current;
     int i;
 
-    /* XXX currently only APIC use intercept */
-    if ( !hvm_apic_support(v->domain) )
-        return 0;
-
-    for ( i = 0; i < HVM_MMIO_HANDLER_NR; i++ ) {
-        if ( hvm_mmio_handlers[i]->check_handler(v, p->addr) ) {
+    for ( i = 0; i < HVM_MMIO_HANDLER_NR; i++ )
+    {
+        if ( hvm_mmio_handlers[i]->check_handler(v, p->addr) )
+        {
             hvm_mmio_access(v, p,
                             hvm_mmio_handlers[i]->read_handler,
                             hvm_mmio_handlers[i]->write_handler);
             return 1;
         }
     }
+
     return 0;
 }
 
@@ -247,15 +246,15 @@ int hvm_io_intercept(ioreq_t *p, int type)
     return 0;
 }
 
-int register_io_handler(unsigned long addr, unsigned long size,
-                        intercept_action_t action, int type)
+int register_io_handler(
+    struct domain *d, unsigned long addr, unsigned long size,
+    intercept_action_t action, int type)
 {
-    struct vcpu *v = current;
-    struct hvm_io_handler *handler =
-                             &(v->domain->arch.hvm_domain.io_handler);
+    struct hvm_io_handler *handler = &d->arch.hvm_domain.io_handler;
     int num = handler->num_slot;
 
-    if (num >= MAX_IO_HANDLER) {
+    if ( num >= MAX_IO_HANDLER )
+    {
         printk("no extra space, register io interceptor failed!\n");
         domain_crash_synchronous();
     }
index f857de8f872f1888fd3b36a010d01c9fa14d4d4a..b435fbdf9f72f8b39bba1b5e4ec705f2da01b0cc 100644 (file)
@@ -52,7 +52,7 @@ void pmtimer_init(struct vcpu *v, int base)
     /* ACPI supports a 32-bit power management timer */
     set_timer(&s->timer, NOW() + (1000000000ULL << 31) / FREQUENCE_PMTIMER);
     
-    register_portio_handler(base, 4, handle_pmt_io);
+    register_portio_handler(v->domain, base, 4, handle_pmt_io);
 }
 
 void pmtimer_deinit(struct domain *d)
index 5aff1b72d0607568ec0468265af6eef882ea4046..77b703b0406a6947f7bd0ef7dcfb9b2260311aac 100644 (file)
@@ -381,7 +381,7 @@ void rtc_init(struct vcpu *v, int base, int irq)
     s->next_second_time = NOW() + 1000000000ULL;
     set_timer(&s->second_timer2, s->next_second_time);
 
-    register_portio_handler(base, 2, handle_rtc_io);
+    register_portio_handler(v->domain, base, 2, handle_rtc_io);
 }
 
 void rtc_deinit(struct domain *d)
index fc2827bb11738c2648b03025f8e2db98c7ea85da..ef354abb7e52167b4284d396c76637da78a5bb91 100644 (file)
@@ -1046,8 +1046,7 @@ static void svm_vmexit_do_cpuid(struct vmcb_struct *vmcb, unsigned long input,
         cpuid(input, &eax, &ebx, &ecx, &edx);       
         if (input == 0x00000001 || input == 0x80000001 )
         {
-            if ( !hvm_apic_support(v->domain) ||
-                 !vlapic_global_enabled((VLAPIC(v))) )
+            if ( !vlapic_global_enabled((VLAPIC(v))) )
             {
                 /* Since the apic is disabled, avoid any confusion 
                    about SMP cpus being available */
index 356130bd11d6618001308e1a399398f5ca157543..6c3dc7c7c1beaf47d69c313ce84ba75a00606742 100644 (file)
@@ -355,11 +355,7 @@ void svm_do_launch(struct vcpu *v)
     if ( !asidpool_assign_next( vmcb, 0, core, core ))
         BUG();
 
-    if (v->vcpu_id == 0)
-        hvm_setup_platform(v->domain);
-
-    if (hvm_apic_support(v->domain))
-        vlapic_init(v);
+    vlapic_init(v);
     init_timer(&v->arch.hvm_vcpu.hlt_timer, hlt_timer_fn, v, v->processor);
 
     vmcb->ldtr.sel = 0;
index d7b2321e626bbfc141b5fb4142093ce81ba4a0e7..0ed6463045cd86a1da13450c68486920a85711a2 100644 (file)
@@ -530,9 +530,6 @@ void hvm_vioapic_do_irqs(struct domain *d, uint16_t irqs)
 {
     hvm_vioapic_t *s = &(d->arch.hvm_domain.vioapic);
 
-    if (!hvm_apic_support(d))
-        return;
-
     s->irr |= irqs & ~s->imr;
     service_ioapic(s);
 }
@@ -541,9 +538,6 @@ void hvm_vioapic_do_irqs_clear(struct domain *d, uint16_t irqs)
 {
     hvm_vioapic_t *s = &(d->arch.hvm_domain.vioapic);
 
-    if (!hvm_apic_support(d))
-        return;
-
     s->irr &= ~irqs;
     service_ioapic(s);
 }
@@ -552,8 +546,7 @@ void hvm_vioapic_set_xen_irq(struct domain *d, int irq, int level)
 {
     hvm_vioapic_t *s = &d->arch.hvm_domain.vioapic;
 
-    if (!hvm_apic_support(d) || !IOAPICEnabled(s) ||
-       s->redirtbl[irq].RedirForm.mask)
+    if (!IOAPICEnabled(s) || s->redirtbl[irq].RedirForm.mask)
         return;
 
     if (s->redirtbl[irq].RedirForm.trigmod != IOAPIC_LEVEL_TRIGGER)
@@ -569,9 +562,6 @@ void hvm_vioapic_set_irq(struct domain *d, int irq, int level)
 {
     hvm_vioapic_t *s = &(d->arch.hvm_domain.vioapic);
 
-    if (!hvm_apic_support(d))
-        return ;
-
     HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "ioapic_set_irq "
       "irq %x level %x\n", irq, level);
 
index 24c3af8c0b1c5ba7d064a949d4dc6075665ffc72..64820c767c8b9ab55c052e2d32142846316854a2 100644 (file)
@@ -155,17 +155,11 @@ int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig)
     return ret;
 }
 
-int hvm_apic_support(struct domain *d)
-{
-    return d->arch.hvm_domain.params[HVM_PARAM_APIC_ENABLED];
-}
-
 s_time_t get_apictime_scheduled(struct vcpu *v)
 {
     struct vlapic *vlapic = VLAPIC(v);
 
-    if ( !hvm_apic_support(v->domain) ||
-         !vlapic_lvt_enabled(vlapic, APIC_LVTT) )
+    if ( !vlapic_lvt_enabled(vlapic, APIC_LVTT) )
         return -1;
 
     return vlapic->vlapic_timer.expires;
index 6a49cec3fc492980df50ef9ec69525a00ce6e760..65be8a349474da04764188abec2bf447048881eb 100644 (file)
@@ -307,9 +307,8 @@ static void vmx_do_launch(struct vcpu *v)
     unsigned int  error = 0;
     unsigned long cr0, cr4;
 
-    if ( v->vcpu_id == 0 )
-        hvm_setup_platform(v->domain);
-    else {
+    if ( v->vcpu_id != 0 )
+    {
         /* Sync AP's TSC with BSP's */
         v->arch.hvm_vcpu.cache_tsc_offset = 
             v->domain->vcpu[0]->arch.hvm_vcpu.cache_tsc_offset;
@@ -333,7 +332,7 @@ static void vmx_do_launch(struct vcpu *v)
 
     hvm_stts(v);
 
-    if( hvm_apic_support(v->domain) && (vlapic_init(v) == 0) )
+    if ( vlapic_init(v) == 0 )
     {
 #ifdef __x86_64__ 
         u32 *cpu_exec_control = &v->arch.hvm_vcpu.u.vmx.exec_control;
index 343eb3d3c51f36be981d70a59757a201be0d4113..e91bb58d6a6f05a8cfb2a8d3ee07cebf914ac49b 100644 (file)
@@ -905,17 +905,11 @@ static void vmx_do_cpuid(struct cpu_user_regs *regs)
 
         if ( input == CPUID_LEAF_0x1 )
         {
-            /* mask off reserved bits */
+            /* Mask off reserved bits. */
             ecx &= ~VMX_VCPU_CPUID_L1_ECX_RESERVED;
 
-            if ( !hvm_apic_support(v->domain) ||
-                 !vlapic_global_enabled((VLAPIC(v))) )
-            {
-                /* Since the apic is disabled, avoid any 
-                confusion about SMP cpus being available */
-
+            if ( !vlapic_global_enabled((VLAPIC(v))) )
                 clear_bit(X86_FEATURE_APIC, &edx);
-            }
     
 #if CONFIG_PAGING_LEVELS >= 3
             if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_PAE_ENABLED] )
index fd0745773e51836ab72ada83fdefb445ec89be0a..d3b4d0287eed48df1d14b0045e29bd19e56f9552 100644 (file)
@@ -572,7 +572,7 @@ get_page_from_l1e(
 
         if ( !iomem_access_permitted(d, mfn, mfn) )
         {
-            if ( mfn != INVALID_MFN )
+            if ( mfn != (PADDR_MASK >> PAGE_SHIFT) ) /* INVALID_MFN? */
                 MEM_LOG("Non-privileged (%u) attempt to map I/O space %08lx", 
                         d->domain_id, mfn);
             return 0;
index 07d05a68c660ecc51733b91fdc36a2a4ca1bec2a..17f4df7302368ae35e1028d8ed75a341256ebe95 100644 (file)
@@ -73,9 +73,7 @@ enum ioapic_irq_destination_types {
        dest_ExtINT = 7
 };
 
-/* As long as we register vlsapic to ioapic controller, it's said enabled */
 #define vlapic_enabled(l) 1
-#define hvm_apic_support(d) 1
 
 #define VLAPIC_DELIV_MODE_FIXED                0x0
 #define VLAPIC_DELIV_MODE_REDIR                0x1
index 5c7369550cd0e139daa29cee5e3d1184fb2e3a47..851b37830e81bcb8d725d5d681a13cb3c6f16ce7 100644 (file)
@@ -91,16 +91,8 @@ hvm_disable(void)
         hvm_funcs.disable();
 }
 
-void hvm_create_event_channel(struct vcpu *v);
-
-static inline int
-hvm_vcpu_initialise(struct vcpu *v)
-{
-    int rc;
-    if ( (rc = hvm_funcs.vcpu_initialise(v)) == 0 )
-        hvm_create_event_channel(v);
-    return rc;
-}
+int hvm_domain_initialise(struct domain *d);
+int hvm_vcpu_initialise(struct vcpu *v);
 
 static inline void
 hvm_relinquish_guest_resources(struct domain *d)
index a49cf34ad3d62140229c3bdb5ec2ff7bdbcc1391..b784d059fe318185342dc3fce7ff2749bc97cec7 100644 (file)
@@ -116,8 +116,9 @@ struct hvm_mmio_handler {
 
 /* global io interception point in HV */
 extern int hvm_io_intercept(ioreq_t *p, int type);
-extern int register_io_handler(unsigned long addr, unsigned long size,
-                               intercept_action_t action, int type);
+extern int register_io_handler(
+    struct domain *d, unsigned long addr, unsigned long size,
+    intercept_action_t action, int type);
 
 static inline int hvm_portio_intercept(ioreq_t *p)
 {
@@ -127,11 +128,11 @@ static inline int hvm_portio_intercept(ioreq_t *p)
 extern int hvm_mmio_intercept(ioreq_t *p);
 extern int hvm_buffered_io_intercept(ioreq_t *p);
 
-static inline int register_portio_handler(unsigned long addr,
-                                          unsigned long size,
-                                          intercept_action_t action)
+static inline int register_portio_handler(
+    struct domain *d, unsigned long addr,
+    unsigned long size, intercept_action_t action)
 {
-    return register_io_handler(addr, size, action, HVM_PORTIO);
+    return register_io_handler(d, addr, size, action, HVM_PORTIO);
 }
 
 #if defined(__i386__) || defined(__x86_64__)
index 4373949a263d03633895f8298974215082ea0734..f63b0156e96d5bd9692def55a55786c2aca872ec 100644 (file)
@@ -139,7 +139,6 @@ int hvm_copy_from_guest_phys(void *buf, paddr_t paddr, int size);
 int hvm_copy_to_guest_virt(unsigned long vaddr, void *buf, int size);
 int hvm_copy_from_guest_virt(void *buf, unsigned long vaddr, int size);
 
-void hvm_setup_platform(struct domain* d);
 void hvm_print_line(struct vcpu *v, const char c);
 void hlt_timer_fn(void *data);
 
index 883e3cac28803815cb03a4a9127c94235290279c..3827c117666213ee4f3545130329aa18a8e28a94 100644 (file)
@@ -90,6 +90,4 @@ struct vlapic *apic_round_robin(struct domain *d,
 
 s_time_t get_apictime_scheduled(struct vcpu *v);
 
-int hvm_apic_support(struct domain *d);
-
 #endif /* __ASM_X86_HVM_VLAPIC_H__ */
index 67f229f04a4afec80af3f7feb8a674ed369572f4..643eb5bd1a151ab111e96eb35532988be78896f0 100644 (file)
@@ -71,7 +71,7 @@ void pic_init(struct hvm_virpic *s,
               void (*irq_request)(void *, int),
               void *irq_request_opaque);
 void pic_update_irq(struct hvm_virpic *s); /* Caller must hold s->lock */
-void register_pic_io_hook (void);
+void register_pic_io_hook(struct domain *d);
 int cpu_get_pic_interrupt(struct vcpu *v, int *type);
 int is_periodic_irq(struct vcpu *v, int irq, int type);
 int is_irq_enabled(struct vcpu *v, int irq);
index 82aaebc4a93b739d0fa332bc4b75bacbb7b83e5f..f4f424a0e58202c93c91513c009b0776c5cf0275 100644 (file)
@@ -5,7 +5,6 @@
 #define HVM_PARAM_CALLBACK_IRQ 0
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
-#define HVM_PARAM_APIC_ENABLED 3
 #define HVM_PARAM_PAE_ENABLED  4
 #define HVM_PARAM_IOREQ_PFN    5
 #define HVM_PARAM_BUFIOREQ_PFN 6