WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Merge

# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 20204db0891b0b7c10959822e3283656c3600500
# Parent  ec7e7e94649677bfdf33235e5438370102f11c5a
# Parent  4c2d9a2ef1b74b883cb697acbca668753011d925
Merge
---
 config/SunOS.mk                           |    2 
 linux-2.6-xen-sparse/include/xen/gnttab.h |    4 
 tools/firmware/vmxassist/setup.c          |    3 
 tools/libxc/xc_hvm_build.c                |  103 +++++-----------
 tools/pygrub/setup.py                     |    2 
 tools/python/setup.py                     |    3 
 xen/arch/x86/domain.c                     |   48 +++----
 xen/arch/x86/hvm/hvm.c                    |  189 ++++++------------------------
 xen/arch/x86/hvm/svm/svm.c                |   37 -----
 xen/arch/x86/hvm/vmx/vmcs.c               |   21 ---
 xen/arch/x86/hvm/vmx/vmx.c                |   80 ++----------
 xen/arch/x86/mm.c                         |   14 +-
 xen/arch/x86/setup.c                      |    2 
 xen/include/asm-x86/grant_table.h         |    4 
 xen/include/asm-x86/hvm/hvm.h             |   22 +--
 xen/include/asm-x86/hvm/vmx/vmcs.h        |    5 
 xen/include/public/hvm/e820.h             |    6 
 xen/include/public/hvm/params.h           |    4 
 18 files changed, 151 insertions(+), 398 deletions(-)

diff -r ec7e7e946496 -r 20204db0891b config/SunOS.mk
--- a/config/SunOS.mk   Thu Nov 02 18:51:23 2006 +0000
+++ b/config/SunOS.mk   Thu Nov 02 18:52:04 2006 +0000
@@ -21,7 +21,7 @@ SOCKET_LIBS = -lsocket
 SOCKET_LIBS = -lsocket
 CURSES_LIBS = -lcurses
 SONAME_LDFLAG = -h
-SHLIB_CFLAGS = -static-libgcc -shared
+SHLIB_CFLAGS = -R /usr/sfw/$(LIBDIR) -shared
 
 ifneq ($(debug),y)
 # Optimisation flags are overridable
diff -r ec7e7e946496 -r 20204db0891b linux-2.6-xen-sparse/include/xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/xen/gnttab.h Thu Nov 02 18:51:23 2006 +0000
+++ b/linux-2.6-xen-sparse/include/xen/gnttab.h Thu Nov 02 18:52:04 2006 +0000
@@ -118,7 +118,7 @@ int gnttab_resume(void);
 int gnttab_resume(void);
 
 static inline void
-gnttab_set_map_op(struct gnttab_map_grant_ref *map, unsigned long addr,
+gnttab_set_map_op(struct gnttab_map_grant_ref *map, uint64_t addr,
                  uint32_t flags, grant_ref_t ref, domid_t domid)
 {
        if (flags & GNTMAP_contains_pte)
@@ -134,7 +134,7 @@ gnttab_set_map_op(struct gnttab_map_gran
 }
 
 static inline void
-gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, unsigned long addr,
+gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, uint64_t addr,
                    uint32_t flags, grant_handle_t handle)
 {
        if (flags & GNTMAP_contains_pte)
diff -r ec7e7e946496 -r 20204db0891b tools/firmware/vmxassist/setup.c
--- a/tools/firmware/vmxassist/setup.c  Thu Nov 02 18:51:23 2006 +0000
+++ b/tools/firmware/vmxassist/setup.c  Thu Nov 02 18:52:04 2006 +0000
@@ -53,13 +53,10 @@ struct e820entry e820map[] = {
 struct e820entry e820map[] = {
        { 0x0000000000000000ULL, 0x000000000009F800ULL, E820_RAM },
        { 0x000000000009F800ULL, 0x0000000000000800ULL, E820_RESERVED },
-       { 0x00000000000A0000ULL, 0x0000000000020000ULL, E820_IO },
        { 0x00000000000C0000ULL, 0x0000000000040000ULL, E820_RESERVED },
        { 0x0000000000100000ULL, 0x0000000000000000ULL, E820_RAM },
-       { 0x0000000000000000ULL, 0x0000000000001000ULL, E820_SHARED_PAGE },
        { 0x0000000000000000ULL, 0x0000000000003000ULL, E820_NVS },
        { 0x0000000000003000ULL, 0x000000000000A000ULL, E820_ACPI },
-       { 0x00000000FEC00000ULL, 0x0000000001400000ULL, E820_IO },
 };
 #endif /* TEST */
 
diff -r ec7e7e946496 -r 20204db0891b tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Thu Nov 02 18:51:23 2006 +0000
+++ b/tools/libxc/xc_hvm_build.c        Thu Nov 02 18:52:04 2006 +0000
@@ -56,11 +56,12 @@ static void build_e820map(void *e820_pag
     unsigned char nr_map = 0;
 
     /*
-     * physical address space from HVM_BELOW_4G_RAM_END to 4G is reserved
+     * Physical address space from HVM_BELOW_4G_RAM_END to 4G is reserved
      * for PCI devices MMIO. So if HVM has more than HVM_BELOW_4G_RAM_END
      * RAM, memory beyond HVM_BELOW_4G_RAM_END will go to 4G above.
      */
-    if ( mem_size > HVM_BELOW_4G_RAM_END ) {
+    if ( mem_size > HVM_BELOW_4G_RAM_END )
+    {
         extra_mem_size = mem_size - HVM_BELOW_4G_RAM_END;
         mem_size = HVM_BELOW_4G_RAM_END;
     }
@@ -75,11 +76,6 @@ static void build_e820map(void *e820_pag
     e820entry[nr_map].type = E820_RESERVED;
     nr_map++;
 
-    e820entry[nr_map].addr = 0xA0000;
-    e820entry[nr_map].size = 0x20000;
-    e820entry[nr_map].type = E820_IO;
-    nr_map++;
-
     e820entry[nr_map].addr = 0xEA000;
     e820entry[nr_map].size = 0x01000;
     e820entry[nr_map].type = E820_ACPI;
@@ -90,54 +86,14 @@ static void build_e820map(void *e820_pag
     e820entry[nr_map].type = E820_RESERVED;
     nr_map++;
 
-/* buffered io page.    */
-#define BUFFERED_IO_PAGES   1
-/* xenstore page.       */
-#define XENSTORE_PAGES      1
-/* shared io page.      */
-#define SHARED_IO_PAGES     1
-/* totally 16 static pages are reserved in E820 table */
-
-    /* Most of the ram goes here */
+    /* Low RAM goes here. Remove 3 pages for ioreq, bufioreq, and xenstore. */
     e820entry[nr_map].addr = 0x100000;
-    e820entry[nr_map].size = mem_size - 0x100000 - PAGE_SIZE *
-                                                (BUFFERED_IO_PAGES +
-                                                 XENSTORE_PAGES +
-                                                 SHARED_IO_PAGES);
+    e820entry[nr_map].size = mem_size - 0x100000 - PAGE_SIZE * 3;
     e820entry[nr_map].type = E820_RAM;
     nr_map++;
 
-    /* Statically allocated special pages */
-
-    /* For buffered IO requests */
-    e820entry[nr_map].addr = mem_size - PAGE_SIZE *
-                                        (BUFFERED_IO_PAGES +
-                                         XENSTORE_PAGES +
-                                         SHARED_IO_PAGES);
-    e820entry[nr_map].size = PAGE_SIZE * BUFFERED_IO_PAGES;
-    e820entry[nr_map].type = E820_BUFFERED_IO;
-    nr_map++;
-
-    /* For xenstore */
-    e820entry[nr_map].addr = mem_size - PAGE_SIZE *
-                                        (XENSTORE_PAGES +
-                                         SHARED_IO_PAGES);
-    e820entry[nr_map].size = PAGE_SIZE * XENSTORE_PAGES;
-    e820entry[nr_map].type = E820_XENSTORE;
-    nr_map++;
-
-    /* Shared ioreq_t page */
-    e820entry[nr_map].addr = mem_size - PAGE_SIZE * SHARED_IO_PAGES;
-    e820entry[nr_map].size = PAGE_SIZE * SHARED_IO_PAGES;
-    e820entry[nr_map].type = E820_SHARED_PAGE;
-    nr_map++;
-
-    e820entry[nr_map].addr = 0xFEC00000;
-    e820entry[nr_map].size = 0x1400000;
-    e820entry[nr_map].type = E820_IO;
-    nr_map++;
-
-    if ( extra_mem_size ) {
+    if ( extra_mem_size )
+    {
         e820entry[nr_map].addr = (1ULL << 32);
         e820entry[nr_map].size = extra_mem_size;
         e820entry[nr_map].type = E820_RAM;
@@ -212,6 +168,7 @@ static int setup_guest(int xc_handle,
     void *e820_page;
     struct domain_setup_info dsi;
     uint64_t v_end;
+    int rc;
 
     memset(&dsi, 0, sizeof(struct domain_setup_info));
 
@@ -253,10 +210,25 @@ static int setup_guest(int xc_handle,
     for ( i = HVM_BELOW_4G_RAM_END >> PAGE_SHIFT; i < nr_pages; i++ )
         page_array[i] += HVM_BELOW_4G_MMIO_LENGTH >> PAGE_SHIFT;
 
-    if ( xc_domain_memory_populate_physmap(xc_handle, dom, nr_pages,
-                                           0, 0, page_array) )
+    /* Allocate memory for HVM guest, skipping VGA hole 0xA0000-0xC0000. */
+    rc = xc_domain_memory_populate_physmap(
+        xc_handle, dom, (nr_pages > 0xa0) ? 0xa0 : nr_pages,
+        0, 0, &page_array[0x00]);
+    if ( (rc == 0) && (nr_pages > 0xc0) )
+        rc = xc_domain_memory_populate_physmap(
+            xc_handle, dom, nr_pages - 0xc0, 0, 0, &page_array[0xc0]);
+    if ( rc != 0 )
     {
         PERROR("Could not allocate memory for HVM guest.\n");
+        goto error_out;
+    }
+
+    if ( (nr_pages > 0xa0) &&
+         xc_domain_memory_decrease_reservation(
+             xc_handle, dom, (nr_pages < 0xc0) ? (nr_pages - 0xa0) : 0x20,
+             0, &page_array[0xa0]) )
+    {
+        PERROR("Could not free VGA hole.\n");
         goto error_out;
     }
 
@@ -295,6 +267,8 @@ static int setup_guest(int xc_handle,
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
+    memset(&shared_info->evtchn_mask[0], 0xff,
+           sizeof(shared_info->evtchn_mask));
     munmap(shared_info, PAGE_SIZE);
 
     if ( v_end > HVM_BELOW_4G_RAM_END )
@@ -302,22 +276,17 @@ static int setup_guest(int xc_handle,
     else
         shared_page_nr = (v_end >> PAGE_SHIFT) - 1;
 
+    /* Paranoia: clean pages. */
+    if ( xc_clear_domain_page(xc_handle, dom, page_array[shared_page_nr]) ||
+         xc_clear_domain_page(xc_handle, dom, page_array[shared_page_nr-1]) ||
+         xc_clear_domain_page(xc_handle, dom, page_array[shared_page_nr-2]) )
+        goto error_out;
+
     *store_mfn = page_array[shared_page_nr - 1];
-
-    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, shared_page_nr - 1);
+    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, shared_page_nr-1);
     xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_EVTCHN, store_evtchn);
-
-    /* Paranoia */
-    /* clean the shared IO requests page */
-    if ( xc_clear_domain_page(xc_handle, dom, page_array[shared_page_nr]) )
-        goto error_out;
-
-    /* clean the buffered IO requests page */
-    if ( xc_clear_domain_page(xc_handle, dom, page_array[shared_page_nr - 2]) )
-        goto error_out;
-
-    if ( xc_clear_domain_page(xc_handle, dom, *store_mfn) )
-        goto error_out;
+    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_BUFIOREQ_PFN, shared_page_nr-2);
+    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_IOREQ_PFN, shared_page_nr);
 
     free(page_array);
 
diff -r ec7e7e946496 -r 20204db0891b tools/pygrub/setup.py
--- a/tools/pygrub/setup.py     Thu Nov 02 18:51:23 2006 +0000
+++ b/tools/pygrub/setup.py     Thu Nov 02 18:52:04 2006 +0000
@@ -3,7 +3,7 @@ import os
 import os
 import sys
 
-extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
+extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
 
 fsys_mods = []
 fsys_pkgs = []
diff -r ec7e7e946496 -r 20204db0891b tools/python/setup.py
--- a/tools/python/setup.py     Thu Nov 02 18:51:23 2006 +0000
+++ b/tools/python/setup.py     Thu Nov 02 18:52:04 2006 +0000
@@ -4,8 +4,7 @@ import os
 
 XEN_ROOT = "../.."
 
-extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
-
+extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
 
 include_dirs = [ XEN_ROOT + "/tools/libxc",
                  XEN_ROOT + "/tools/xenstore",
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/domain.c     Thu Nov 02 18:52:04 2006 +0000
@@ -123,20 +123,31 @@ struct vcpu *alloc_vcpu_struct(struct do
 
     memset(v, 0, sizeof(*v));
 
+    v->vcpu_id = vcpu_id;
+    v->domain  = d;
+
     v->arch.flags = TF_kernel_mode;
 
-    if ( is_idle_domain(d) )
-    {
-        v->arch.schedule_tail = continue_idle_domain;
-        v->arch.cr3           = __pa(idle_pg_table);
+    if ( is_hvm_domain(d) )
+    {
+        if ( hvm_vcpu_initialise(v) != 0 )
+        {
+            xfree(v);
+            return NULL;
+        }
     }
     else
     {
         v->arch.schedule_tail = continue_nonidle_domain;
-    }
-
-    v->arch.ctxt_switch_from = paravirt_ctxt_switch_from;
-    v->arch.ctxt_switch_to   = paravirt_ctxt_switch_to;
+        v->arch.ctxt_switch_from = paravirt_ctxt_switch_from;
+        v->arch.ctxt_switch_to   = paravirt_ctxt_switch_to;
+
+        if ( is_idle_domain(d) )
+        {
+            v->arch.schedule_tail = continue_idle_domain;
+            v->arch.cr3           = __pa(idle_pg_table);
+        }
+    }
 
     v->arch.perdomain_ptes =
         d->arch.mm_perdomain_pt + (vcpu_id << GDT_LDT_VCPU_SHIFT);
@@ -335,22 +346,11 @@ int arch_set_info_guest(
 
     if ( !is_hvm_vcpu(v) )
     {
+        if ( (rc = (int)set_gdt(v, c->gdt_frames, c->gdt_ents)) != 0 )
+            return rc;
+
         cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c->ctrlreg[3]));
-        v->arch.guest_table = pagetable_from_pfn(cr3_pfn);
-    }
-
-    if ( (rc = (int)set_gdt(v, c->gdt_frames, c->gdt_ents)) != 0 )
-        return rc;
-
-    if ( is_hvm_vcpu(v) )
-    {
-        v->arch.guest_table = pagetable_null();
-
-        if ( !hvm_initialize_guest_resources(v) )
-            return -EINVAL;
-    }
-    else
-    {
+
         if ( shadow_mode_refcounts(d)
              ? !get_page(mfn_to_page(cr3_pfn), d)
              : !get_page_and_type(mfn_to_page(cr3_pfn), d,
@@ -359,6 +359,8 @@ int arch_set_info_guest(
             destroy_gdt(v);
             return -EINVAL;
         }
+
+        v->arch.guest_table = pagetable_from_pfn(cr3_pfn);
     }    
 
     /* Shadow: make sure the domain has enough shadow memory to
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Thu Nov 02 18:52:04 2006 +0000
@@ -57,149 +57,13 @@ integer_param("hvm_debug", opt_hvm_debug
 
 struct hvm_function_table hvm_funcs;
 
-static void hvm_zap_mmio_range(
-    struct domain *d, unsigned long pfn, unsigned long nr_pfn)
-{
-    unsigned long i;
-
-    ASSERT(d == current->domain);
-
-    for ( i = 0; i < nr_pfn; i++ )
-    {
-        if ( pfn + i >= 0xfffff )
-            break;
-
-        if ( VALID_MFN(gmfn_to_mfn(d, pfn + i)) )
-            guest_remove_page(d, pfn + i);
-    }
-}
-
-static void e820_zap_iommu_callback(struct domain *d,
-                                    struct e820entry *e,
-                                    void *ign)
-{
-    if ( e->type == E820_IO )
-        hvm_zap_mmio_range(d, e->addr >> PAGE_SHIFT, e->size >> PAGE_SHIFT);
-}
-
-static void e820_foreach(struct domain *d,
-                         void (*cb)(struct domain *d,
-                                    struct e820entry *e,
-                                    void *data),
-                         void *data)
-{
-    int i;
-    unsigned char e820_map_nr;
-    struct e820entry *e820entry;
-    unsigned char *p;
-    unsigned long mfn;
-
-    mfn = gmfn_to_mfn(d, E820_MAP_PAGE >> PAGE_SHIFT);
-    if ( mfn == INVALID_MFN )
-    {
-        printk("Can not find E820 memory map page for HVM domain.\n");
-        domain_crash_synchronous();
-    }
-
-    p = map_domain_page(mfn);
-    if ( p == NULL )
-    {
-        printk("Can not map E820 memory map page for HVM domain.\n");
-        domain_crash_synchronous();
-    }
-
-    e820_map_nr = *(p + E820_MAP_NR_OFFSET);
-    e820entry = (struct e820entry *)(p + E820_MAP_OFFSET);
-
-    for ( i = 0; i < e820_map_nr; i++ )
-        cb(d, e820entry + i, data);
-
-    unmap_domain_page(p);
-}
-
-static void hvm_zap_iommu_pages(struct domain *d)
-{
-    e820_foreach(d, e820_zap_iommu_callback, NULL);
-}
-
-static void e820_map_io_shared_callback(struct domain *d,
-                                        struct e820entry *e,
-                                        void *data)
-{
-    unsigned long *mfn = data;
-    if ( e->type == E820_SHARED_PAGE )
-    {
-        ASSERT(*mfn == INVALID_MFN);
-        *mfn = gmfn_to_mfn(d, e->addr >> PAGE_SHIFT);
-    }
-}
-
-static void e820_map_buffered_io_callback(struct domain *d,
-                                          struct e820entry *e,
-                                          void *data)
-{
-    unsigned long *mfn = data;
-    if ( e->type == E820_BUFFERED_IO ) {
-        ASSERT(*mfn == INVALID_MFN);
-        *mfn = gmfn_to_mfn(d, e->addr >> PAGE_SHIFT);
-    }
-}
-
-void hvm_map_io_shared_pages(struct vcpu *v)
-{
-    unsigned long mfn;
-    void *p;
-    struct domain *d = v->domain;
-
-    if ( d->arch.hvm_domain.shared_page_va ||
-         d->arch.hvm_domain.buffered_io_va )
-        return;
-
-    mfn = INVALID_MFN;
-    e820_foreach(d, e820_map_io_shared_callback, &mfn);
-
-    if ( mfn == INVALID_MFN )
-    {
-        printk("Can not find io request shared page for HVM domain.\n");
-        domain_crash_synchronous();
-    }
-
-    p = map_domain_page_global(mfn);
-    if ( p == NULL )
-    {
-        printk("Can not map io request shared page for HVM domain.\n");
-        domain_crash_synchronous();
-    }
-
-    d->arch.hvm_domain.shared_page_va = (unsigned long)p;
-
-    mfn = INVALID_MFN;
-    e820_foreach(d, e820_map_buffered_io_callback, &mfn);
-    if ( mfn != INVALID_MFN ) {
-        p = map_domain_page_global(mfn);
-        if ( p )
-            d->arch.hvm_domain.buffered_io_va = (unsigned long)p;
-    }
-}
-
-void hvm_create_event_channels(struct vcpu *v)
-{
-    vcpu_iodata_t *p;
-    struct vcpu *o;
-
-    if ( v->vcpu_id == 0 ) {
-        /* Ugly: create event channels for every vcpu when vcpu 0
-           starts, so that they're available for ioemu to bind to. */
-        for_each_vcpu(v->domain, o) {
-            p = get_vio(v->domain, o->vcpu_id);
-            o->arch.hvm_vcpu.xen_port = p->vp_eport =
-                alloc_unbound_xen_event_channel(o, 0);
-            dprintk(XENLOG_INFO, "Allocated port %d for hvm.\n",
-                    o->arch.hvm_vcpu.xen_port);
-        }
-    }
-}
-
+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)
 {
@@ -267,8 +131,6 @@ void hvm_setup_platform(struct domain *d
 
     if ( !is_hvm_domain(d) || (v->vcpu_id != 0) )
         return;
-
-    hvm_zap_iommu_pages(d);
 
     platform = &d->arch.hvm_domain;
     pic_init(&platform->vpic, pic_irq_request, &platform->interrupt_request);
@@ -689,6 +551,9 @@ long do_hvm_op(unsigned long op, XEN_GUE
     {
         struct xen_hvm_param a;
         struct domain *d;
+        struct vcpu *v;
+        unsigned long mfn;
+        void *p;
 
         if ( copy_from_guest(&a, arg, 1) )
             return -EFAULT;
@@ -712,8 +577,41 @@ long do_hvm_op(unsigned long op, XEN_GUE
             return -EPERM;
         }
 
+        rc = -EINVAL;
+        if ( !is_hvm_domain(d) )
+            goto param_fail;
+
         if ( op == HVMOP_set_param )
         {
+            switch ( a.index )
+            {
+            case HVM_PARAM_IOREQ_PFN:
+                if ( d->arch.hvm_domain.shared_page_va )
+                    goto param_fail;
+                mfn = gmfn_to_mfn(d, a.value);
+                if ( mfn == INVALID_MFN )
+                    goto param_fail;
+                p = map_domain_page_global(mfn);
+                if ( p == NULL )
+                    goto param_fail;
+                d->arch.hvm_domain.shared_page_va = (unsigned long)p;
+                /* Initialise evtchn port info if VCPUs already created. */
+                for_each_vcpu ( d, v )
+                    get_vio(d, v->vcpu_id)->vp_eport =
+                    v->arch.hvm_vcpu.xen_port;
+                break;
+            case HVM_PARAM_BUFIOREQ_PFN:
+                if ( d->arch.hvm_domain.buffered_io_va )
+                    goto param_fail;
+                mfn = gmfn_to_mfn(d, a.value);
+                if ( mfn == INVALID_MFN )
+                    goto param_fail;
+                p = map_domain_page_global(mfn);
+                if ( p == NULL )
+                    goto param_fail;
+                d->arch.hvm_domain.buffered_io_va = (unsigned long)p;
+                break;
+            }
             d->arch.hvm_domain.params[a.index] = a.value;
             rc = 0;
         }
@@ -723,6 +621,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
             rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
         }
 
+    param_fail:
         put_domain(d);
         break;
     }
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/hvm/svm/svm.c        Thu Nov 02 18:52:04 2006 +0000
@@ -789,40 +789,13 @@ static void svm_ctxt_switch_to(struct vc
     svm_restore_dr(v);
 }
 
-
-static void svm_final_setup_guest(struct vcpu *v)
-{
-    struct domain *d = v->domain;
-
+static int svm_vcpu_initialise(struct vcpu *v)
+{
     v->arch.schedule_tail    = arch_svm_do_launch;
     v->arch.ctxt_switch_from = svm_ctxt_switch_from;
     v->arch.ctxt_switch_to   = svm_ctxt_switch_to;
-
-    if ( v != d->vcpu[0] )
-        return;
-
-    if ( !shadow_mode_external(d) )
-    {
-        gdprintk(XENLOG_ERR, "Can't init HVM for dom %u vcpu %u: "
-                "not in shadow external mode\n", d->domain_id, v->vcpu_id);
-        domain_crash(d);
-    }
-
-    /* 
-     * Required to do this once per domain
-     * TODO: add a seperate function to do these.
-     */
-    memset(&d->shared_info->evtchn_mask[0], 0xff, 
-           sizeof(d->shared_info->evtchn_mask));       
-}
-
-
-static int svm_initialize_guest_resources(struct vcpu *v)
-{
-    svm_final_setup_guest(v);
-    return 1;
-}
-
+    return 0;
+}
 
 int start_svm(void)
 {
@@ -871,7 +844,7 @@ int start_svm(void)
     /* Setup HVM interfaces */
     hvm_funcs.disable = stop_svm;
 
-    hvm_funcs.initialize_guest_resources = svm_initialize_guest_resources;
+    hvm_funcs.vcpu_initialise = svm_vcpu_initialise;
     hvm_funcs.relinquish_guest_resources = svm_relinquish_guest_resources;
 
     hvm_funcs.store_cpu_guest_regs = svm_store_cpu_guest_regs;
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c       Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/hvm/vmx/vmcs.c       Thu Nov 02 18:52:04 2006 +0000
@@ -56,7 +56,7 @@
       CPU_BASED_INVDPG_EXITING |                        \
       CPU_BASED_MWAIT_EXITING |                         \
       CPU_BASED_MOV_DR_EXITING |                        \
-      CPU_BASED_ACTIVATE_IO_BITMAP |                    \
+      CPU_BASED_UNCOND_IO_EXITING |                     \
       CPU_BASED_USE_TSC_OFFSETING )
 
 /* Basic flags for VM-Exit controls. */
@@ -240,21 +240,8 @@ static inline int construct_vmcs_control
     int error = 0;
 
     error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL, vmx_pin_based_exec_control);
-
     error |= __vmwrite(VM_EXIT_CONTROLS, vmx_vmexit_control);
-
     error |= __vmwrite(VM_ENTRY_CONTROLS, vmx_vmentry_control);
-
-    error |= __vmwrite(IO_BITMAP_A, virt_to_maddr(arch_vmx->io_bitmap_a));
-    error |= __vmwrite(IO_BITMAP_B, virt_to_maddr(arch_vmx->io_bitmap_b));
-
-#ifdef CONFIG_X86_PAE
-    /* On PAE bitmaps may in future be above 4GB. Write high words. */
-    error |= __vmwrite(IO_BITMAP_A_HIGH,
-                       (paddr_t)virt_to_maddr(arch_vmx->io_bitmap_a) >> 32);
-    error |= __vmwrite(IO_BITMAP_B_HIGH,
-                       (paddr_t)virt_to_maddr(arch_vmx->io_bitmap_b) >> 32);
-#endif
 
     return error;
 }
@@ -589,12 +576,6 @@ void vmx_destroy_vmcs(struct vcpu *v)
 
     vmx_clear_vmcs(v);
 
-    free_xenheap_pages(arch_vmx->io_bitmap_a, IO_BITMAP_ORDER);
-    free_xenheap_pages(arch_vmx->io_bitmap_b, IO_BITMAP_ORDER);
-
-    arch_vmx->io_bitmap_a = NULL;
-    arch_vmx->io_bitmap_b = NULL;
-
     vmx_free_vmcs(arch_vmx->vmcs);
     arch_vmx->vmcs = NULL;
 }
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Thu Nov 02 18:52:04 2006 +0000
@@ -53,77 +53,25 @@ static void vmx_ctxt_switch_from(struct 
 static void vmx_ctxt_switch_from(struct vcpu *v);
 static void vmx_ctxt_switch_to(struct vcpu *v);
 
-static int vmx_initialize_guest_resources(struct vcpu *v)
-{
-    struct domain *d = v->domain;
-    struct vcpu *vc;
-    void *io_bitmap_a, *io_bitmap_b;
+static int vmx_vcpu_initialise(struct vcpu *v)
+{
     int rc;
 
     v->arch.schedule_tail    = arch_vmx_do_launch;
     v->arch.ctxt_switch_from = vmx_ctxt_switch_from;
     v->arch.ctxt_switch_to   = vmx_ctxt_switch_to;
 
-    if ( v->vcpu_id != 0 )
-        return 1;
-
-    if ( !shadow_mode_external(d) )
-    {
-        dprintk(XENLOG_ERR, "Can't init HVM for dom %u vcpu %u: "
-                "not in shadow external mode\n", 
-                d->domain_id, v->vcpu_id);
-        domain_crash(d);
-    }
-
-    for_each_vcpu ( d, vc )
-    {
-        memset(&vc->arch.hvm_vmx, 0, sizeof(struct arch_vmx_struct));
-
-        if ( (rc = vmx_create_vmcs(vc)) != 0 )
-        {
-            dprintk(XENLOG_WARNING,
-                    "Failed to create VMCS for vcpu %d: err=%d.\n",
-                    vc->vcpu_id, rc);
-            return 0;
-        }
-
-        spin_lock_init(&vc->arch.hvm_vmx.vmcs_lock);
-
-        if ( (io_bitmap_a = alloc_xenheap_pages(IO_BITMAP_ORDER)) == NULL )
-        {
-            dprintk(XENLOG_WARNING,
-                   "Failed to allocate io bitmap b for vcpu %d.\n",
-                    vc->vcpu_id);
-            return 0;
-        }
-
-        if ( (io_bitmap_b = alloc_xenheap_pages(IO_BITMAP_ORDER)) == NULL )
-        {
-            dprintk(XENLOG_WARNING,
-                    "Failed to allocate io bitmap b for vcpu %d.\n",
-                    vc->vcpu_id);
-            return 0;
-        }
-
-        memset(io_bitmap_a, 0xff, 0x1000);
-        memset(io_bitmap_b, 0xff, 0x1000);
-
-        /* don't bother debug port access */
-        clear_bit(PC_DEBUG_PORT, io_bitmap_a);
-
-        vc->arch.hvm_vmx.io_bitmap_a = io_bitmap_a;
-        vc->arch.hvm_vmx.io_bitmap_b = io_bitmap_b;
-
-    }
-
-    /*
-     * Required to do this once per domain XXX todo: add a seperate function 
-     * to do these.
-     */
-    memset(&d->shared_info->evtchn_mask[0], 0xff,
-           sizeof(d->shared_info->evtchn_mask));
-
-    return 1;
+    if ( (rc = vmx_create_vmcs(v)) != 0 )
+    {
+        dprintk(XENLOG_WARNING,
+                "Failed to create VMCS for vcpu %d: err=%d.\n",
+                v->vcpu_id, rc);
+        return rc;
+    }
+
+    spin_lock_init(&v->arch.hvm_vmx.vmcs_lock);
+
+    return 0;
 }
 
 static void vmx_relinquish_guest_resources(struct domain *d)
@@ -747,7 +695,7 @@ static void vmx_setup_hvm_funcs(void)
 
     hvm_funcs.disable = stop_vmx;
 
-    hvm_funcs.initialize_guest_resources = vmx_initialize_guest_resources;
+    hvm_funcs.vcpu_initialise = vmx_vcpu_initialise;
     hvm_funcs.relinquish_guest_resources = vmx_relinquish_guest_resources;
 
     hvm_funcs.store_cpu_guest_regs = vmx_store_cpu_guest_regs;
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/mm.c Thu Nov 02 18:52:04 2006 +0000
@@ -2379,7 +2379,7 @@ int do_mmu_update(
 
 
 static int create_grant_pte_mapping(
-    unsigned long pte_addr, l1_pgentry_t nl1e, struct vcpu *v)
+    uint64_t pte_addr, l1_pgentry_t nl1e, struct vcpu *v)
 {
     int rc = GNTST_okay;
     void *va;
@@ -2403,7 +2403,7 @@ static int create_grant_pte_mapping(
     }
     
     va = map_domain_page(mfn);
-    va = (void *)((unsigned long)va + (pte_addr & ~PAGE_MASK));
+    va = (void *)((unsigned long)va + ((unsigned long)pte_addr & ~PAGE_MASK));
     page = mfn_to_page(mfn);
 
     type = page->u.inuse.type_info & PGT_type_mask;
@@ -2435,7 +2435,7 @@ static int create_grant_pte_mapping(
 }
 
 static int destroy_grant_pte_mapping(
-    unsigned long addr, unsigned long frame, struct domain *d)
+    uint64_t addr, unsigned long frame, struct domain *d)
 {
     int rc = GNTST_okay;
     void *va;
@@ -2454,7 +2454,7 @@ static int destroy_grant_pte_mapping(
     }
     
     va = map_domain_page(mfn);
-    va = (void *)((unsigned long)va + (addr & ~PAGE_MASK));
+    va = (void *)((unsigned long)va + ((unsigned long)addr & ~PAGE_MASK));
     page = mfn_to_page(mfn);
 
     type = page->u.inuse.type_info & PGT_type_mask;
@@ -2475,7 +2475,7 @@ static int destroy_grant_pte_mapping(
     /* Check that the virtual address supplied is actually mapped to frame. */
     if ( unlikely((l1e_get_intpte(ol1e) >> PAGE_SHIFT) != frame) )
     {
-        MEM_LOG("PTE entry %lx for address %lx doesn't match frame %lx",
+        MEM_LOG("PTE entry %lx for address %"PRIx64" doesn't match frame %lx",
                 (unsigned long)l1e_get_intpte(ol1e), addr, frame);
         put_page_type(page);
         rc = GNTST_general_error;
@@ -2575,7 +2575,7 @@ static int destroy_grant_va_mapping(
 }
 
 int create_grant_host_mapping(
-    unsigned long addr, unsigned long frame, unsigned int flags)
+    uint64_t addr, unsigned long frame, unsigned int flags)
 {
     l1_pgentry_t pte = l1e_from_pfn(frame, GRANT_PTE_FLAGS);
 
@@ -2590,7 +2590,7 @@ int create_grant_host_mapping(
 }
 
 int destroy_grant_host_mapping(
-    unsigned long addr, unsigned long frame, unsigned int flags)
+    uint64_t addr, unsigned long frame, unsigned int flags)
 {
     if ( flags & GNTMAP_contains_pte )
         return destroy_grant_pte_mapping(addr, frame, current->domain);
diff -r ec7e7e946496 -r 20204db0891b xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/arch/x86/setup.c      Thu Nov 02 18:52:04 2006 +0000
@@ -363,7 +363,7 @@ void __init __start_xen(multiboot_info_t
             e820_raw[e820_raw_nr].size = 
                 ((u64)map->length_high << 32) | (u64)map->length_low;
             e820_raw[e820_raw_nr].type = 
-                (map->type > E820_SHARED_PAGE) ? E820_RESERVED : map->type;
+                (map->type > E820_NVS) ? E820_RESERVED : map->type;
             e820_raw_nr++;
 
             bytes += map->size + 4;
diff -r ec7e7e946496 -r 20204db0891b xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/include/asm-x86/grant_table.h Thu Nov 02 18:52:04 2006 +0000
@@ -14,9 +14,9 @@
  * must hold a reference to the page.
  */
 int create_grant_host_mapping(
-    unsigned long addr, unsigned long frame, unsigned int flags);
+    uint64_t addr, unsigned long frame, unsigned int flags);
 int destroy_grant_host_mapping(
-    unsigned long addr, unsigned long frame, unsigned int flags);
+    uint64_t addr, unsigned long frame, unsigned int flags);
 
 #define gnttab_create_shared_page(d, t, i)                               \
     do {                                                                 \
diff -r ec7e7e946496 -r 20204db0891b xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h     Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/include/asm-x86/hvm/hvm.h     Thu Nov 02 18:52:04 2006 +0000
@@ -35,7 +35,7 @@ struct hvm_function_table {
     /*
      * Initialize/relinguish HVM guest resources
      */
-    int  (*initialize_guest_resources)(struct vcpu *v);
+    int  (*vcpu_initialise)(struct vcpu *v);
     void (*relinquish_guest_resources)(struct domain *d);
 
     /*
@@ -91,27 +91,21 @@ hvm_disable(void)
         hvm_funcs.disable();
 }
 
-void hvm_create_event_channels(struct vcpu *v);
-void hvm_map_io_shared_pages(struct vcpu *v);
+void hvm_create_event_channel(struct vcpu *v);
 
 static inline int
-hvm_initialize_guest_resources(struct vcpu *v)
+hvm_vcpu_initialise(struct vcpu *v)
 {
-    int ret = 1;
-    if ( hvm_funcs.initialize_guest_resources )
-        ret = hvm_funcs.initialize_guest_resources(v);
-    if ( ret == 1 ) {
-        hvm_map_io_shared_pages(v);
-        hvm_create_event_channels(v);
-    }
-    return ret;
+    int rc;
+    if ( (rc = hvm_funcs.vcpu_initialise(v)) == 0 )
+        hvm_create_event_channel(v);
+    return rc;
 }
 
 static inline void
 hvm_relinquish_guest_resources(struct domain *d)
 {
-    if (hvm_funcs.relinquish_guest_resources)
-        hvm_funcs.relinquish_guest_resources(d);
+    hvm_funcs.relinquish_guest_resources(d);
 }
 
 static inline void
diff -r ec7e7e946496 -r 20204db0891b xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h        Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h        Thu Nov 02 18:52:04 2006 +0000
@@ -49,10 +49,6 @@ struct vmx_msr_state {
     unsigned long msr_items[VMX_MSR_COUNT];
     unsigned long shadow_gs;
 };
-
-/* io bitmap is 4KBytes in size */
-#define IO_BITMAP_SIZE      0x1000
-#define IO_BITMAP_ORDER     (get_order_from_bytes(IO_BITMAP_SIZE))
 
 struct arch_vmx_struct {
     /* Virtual address of VMCS. */
@@ -82,7 +78,6 @@ struct arch_vmx_struct {
     unsigned long        cpu_cr3;
     unsigned long        cpu_based_exec_control;
     struct vmx_msr_state msr_content;
-    void                *io_bitmap_a, *io_bitmap_b;
     unsigned long        vmxassist_enabled:1; 
 };
 
diff -r ec7e7e946496 -r 20204db0891b xen/include/public/hvm/e820.h
--- a/xen/include/public/hvm/e820.h     Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/include/public/hvm/e820.h     Thu Nov 02 18:52:04 2006 +0000
@@ -6,12 +6,6 @@
 #define E820_RESERVED     2
 #define E820_ACPI         3
 #define E820_NVS          4
-
-/* Xen HVM extended E820 types. */
-#define E820_IO          16
-#define E820_SHARED_PAGE 17
-#define E820_XENSTORE    18
-#define E820_BUFFERED_IO 19
 
 /* E820 location in HVM virtual address space. */
 #define E820_MAP_PAGE        0x00090000
diff -r ec7e7e946496 -r 20204db0891b xen/include/public/hvm/params.h
--- a/xen/include/public/hvm/params.h   Thu Nov 02 18:51:23 2006 +0000
+++ b/xen/include/public/hvm/params.h   Thu Nov 02 18:52:04 2006 +0000
@@ -7,7 +7,9 @@
 #define HVM_PARAM_STORE_EVTCHN 2
 #define HVM_PARAM_APIC_ENABLED 3
 #define HVM_PARAM_PAE_ENABLED  4
-#define HVM_NR_PARAMS          5
+#define HVM_PARAM_IOREQ_PFN    5
+#define HVM_PARAM_BUFIOREQ_PFN 6
+#define HVM_NR_PARAMS          7
 
 /* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
 #define HVMOP_set_param 0

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>