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-ppc-devel

[XenPPC] [xenppc-unstable] [XEN][POWERPC] support non-RMA memory in domU

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [XEN][POWERPC] support non-RMA memory in domU
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Sep 2006 20:00:53 +0000
Delivery-date: Thu, 14 Sep 2006 13:09:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Node ID 14e7c2948115b2f7ba82e37df571447c0428b8e5
# Parent  3d60bf30dff21fec2fdc8a931c725c23508cb94c
[XEN][POWERPC] support non-RMA memory in domU
- domU device tree now gets two /memory nodes; the first is the RMA
- the tools now call increase_reservation() in 16MB increments (hardcoded)
- memory is stored in a linked list of 16MB extents, which will definitely need
  replacing in the future
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
 tools/libxc/powerpc64/xc_linux_build.c  |   30 ++++++++++++++++++++++++------
 tools/python/xen/xend/FlatDeviceTree.py |   24 ++++++++++++++++++------
 tools/python/xen/xend/XendDomainInfo.py |   19 ++++++++++++-------
 xen/arch/powerpc/mm.c                   |   27 +++++++++++++++++++--------
 xen/arch/powerpc/ofd_fixup_memory.c     |    4 +++-
 xen/arch/powerpc/shadow.c               |    3 ---
 xen/common/memory.c                     |    3 +++
 xen/include/asm-ia64/mm.h               |    6 ++++++
 xen/include/asm-powerpc/mm.h            |    4 +++-
 xen/include/asm-x86/mm.h                |    6 ++++++
 10 files changed, 94 insertions(+), 32 deletions(-)

diff -r 3d60bf30dff2 -r 14e7c2948115 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c    Thu Sep 14 14:20:48 2006 -0400
+++ b/tools/libxc/powerpc64/xc_linux_build.c    Thu Sep 14 14:53:32 2006 -0500
@@ -334,22 +334,39 @@ out:
     return rc;
 }
 
-static unsigned long create_start_info(start_info_t *si,
+static unsigned long create_start_info(void *devtree, start_info_t *si,
         unsigned int console_evtchn, unsigned int store_evtchn,
         unsigned long nr_pages)
 {
+    void *rma;
     unsigned long si_addr;
+    uint64_t rma_reg[2];
+    uint64_t rma_top;
+    int rc;
 
     memset(si, 0, sizeof(*si));
     snprintf(si->magic, sizeof(si->magic), "xen-%d.%d-powerpc64HV", 3, 0);
 
+    rma = ft_find_node(devtree, "/memory@0");
+    if (rma == NULL) {
+        DPRINTF("couldn't find /memory@0\n");
+        return ~0UL;
+    }
+    rc = ft_get_prop(devtree, rma, "reg", rma_reg, sizeof(rma_reg));
+    if (rc < 0) {
+        DPRINTF("couldn't get /memory@0/reg\n");
+        return ~0UL;
+    }
+    rma_top = rma_reg[0] + rma_reg[1];
+    DPRINTF("RMA top = 0x%"PRIX64"\n", rma_top);
+
     si->nr_pages = nr_pages;
-    si->shared_info = (nr_pages - 1) << PAGE_SHIFT;
-    si->store_mfn = si->nr_pages - 2;
+    si->shared_info = rma_top - PAGE_SIZE;
+    si->store_mfn = (rma_top >> PAGE_SHIFT) - 2;
     si->store_evtchn = store_evtchn;
-    si->console.domU.mfn = si->nr_pages - 3;
+    si->console.domU.mfn = (rma_top >> PAGE_SHIFT) - 3;
     si->console.domU.evtchn = console_evtchn;
-    si_addr = (si->nr_pages - 4) << PAGE_SHIFT;
+    si_addr = rma_top - 4*PAGE_SIZE;
 
     return si_addr;
 }
@@ -434,7 +451,8 @@ int xc_linux_build(int xc_handle,
     }
 
     /* start_info stuff: about to be removed  */
-    si_addr = create_start_info(&si, console_evtchn, store_evtchn, nr_pages);
+    si_addr = create_start_info(devtree, &si, console_evtchn, store_evtchn,
+            nr_pages);
     *console_mfn = page_array[si.console.domU.mfn];
     *store_mfn = page_array[si.store_mfn];
     if (install_image(xc_handle, domid, page_array, &si, si_addr,
diff -r 3d60bf30dff2 -r 14e7c2948115 tools/python/xen/xend/FlatDeviceTree.py
--- a/tools/python/xen/xend/FlatDeviceTree.py   Thu Sep 14 14:20:48 2006 -0400
+++ b/tools/python/xen/xend/FlatDeviceTree.py   Thu Sep 14 14:53:32 2006 -0500
@@ -288,12 +288,24 @@ def build(imghandler):
     xencons = xen.addnode('console')
     xencons.addprop('interrupts', 1, 0)
 
-    # XXX split out RMA node
-    mem = root.addnode('memory@0')
+    # add memory nodes
     totalmem = imghandler.vm.getMemoryTarget() * 1024
-    mem.addprop('reg', 0, 0, 0, totalmem)
-    mem.addprop('device_type', 'memory\0')
-
+    rma_log = imghandler.vm.info.get('rma_log')
+    rma_bytes = 1 << rma_log
+
+    # RMA node
+    rma = root.addnode('memory@0')
+    rma.addprop('reg', 0, 0, 0, rma_bytes)
+    rma.addprop('device_type', 'memory\0')
+
+    # all the rest in a single node
+       remaining = totalmem - rma_bytes
+       if remaining > 0:
+               mem = root.addnode('memory@1')
+               mem.addprop('reg', 0, rma_bytes, 0, remaining)
+               mem.addprop('device_type', 'memory\0')
+
+    # add CPU nodes
     cpus = root.addnode('cpus')
     cpus.addprop('smp-enabled')
     cpus.addprop('#size-cells', 0)
@@ -323,7 +335,7 @@ def build(imghandler):
 
     chosen = root.addnode('chosen')
     chosen.addprop('cpu', cpu0.get_phandle())
-    chosen.addprop('memory', mem.get_phandle())
+    chosen.addprop('memory', rma.get_phandle())
     chosen.addprop('linux,stdout-path', '/xen/console\0')
     chosen.addprop('interrupt-controller', xen.get_phandle())
     chosen.addprop('bootargs', imghandler.cmdline + '\0')
diff -r 3d60bf30dff2 -r 14e7c2948115 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Sep 14 14:20:48 2006 -0400
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Sep 14 14:53:32 2006 -0500
@@ -1757,21 +1757,26 @@ class XendDomainInfoPPC(XendDomainInfo):
 
         # use smallest RMA size available
         rma_log = self.getRealModeLogs()[0]
+        self.info['rma_log'] = rma_log # store info for FlatDeviceTree
 
         rma_kb = (1 << rma_log) / 1024
         if mem_kb < rma_kb:
-            raise ValueError("Domain memory must be at least %d KB" % \
-                    rma_kb)
+            raise ValueError("Domain memory must be at least %d KB" % rma_kb)
 
         # allocate the RMA
         xc.alloc_real_mode_area(self.domid, rma_log)
 
-        # now allocate the remaining memory as order-0 allocations
+        # now allocate the remaining memory as large-order allocations
         mem_kb -= rma_kb
-        if mem_kb > 0:
-            log.debug("increase_reservation(%d, %d, %d)", self.domid,
-                    mem_kb, 0)
-            xc.domain_memory_increase_reservation(self.domid, mem_kb, 0, 0)
+        extent_log = 24 # 16 MB
+        extent_size = 1 << extent_log
+        page_log = 12 # 4 KB
+        extent_order = extent_log - page_log
+        for i in range(0, mem_kb * 1024, extent_size):
+            log.debug("increase_reservation(%d, 0x%x, %d)", self.domid,
+                    extent_size >> 10, extent_order)
+            xc.domain_memory_increase_reservation(self.domid, extent_size >> 
10,
+                    extent_order)
 
 
 domainTypes = {
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c     Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/arch/powerpc/mm.c     Thu Sep 14 14:53:32 2006 -0500
@@ -221,21 +221,21 @@ extern void copy_page(void *dp, void *sp
     }
 }
 
+/* XXX should probably replace with faster data structure */
 static uint add_extent(struct domain *d, struct page_info *pg, uint order)
 {
     struct page_extents *pe;
 
     pe = xmalloc(struct page_extents);
     if (pe == NULL)
-        return 0;
+        return -ENOMEM;
 
     pe->pg = pg;
     pe->order = order;
-    pe->pfn = page_to_mfn(pg);
 
     list_add_tail(&pe->pe_list, &d->arch.extent_list);
 
-    return pe->pfn;
+    return 0;
 }
 
 void free_extents(struct domain *d)
@@ -274,7 +274,7 @@ uint allocate_extents(struct domain *d, 
         if (pg == NULL)
             return total_nrpages;
 
-        if (add_extent(d, pg, ext_order) == 0) {
+        if (add_extent(d, pg, ext_order) < 0) {
             free_domheap_pages(pg, ext_order);
             return total_nrpages;
         }
@@ -353,14 +353,18 @@ ulong pfn2mfn(struct domain *d, ulong pf
             t = PFN_TYPE_RMA;
             mfn = pfn + rma_base_mfn;
         } else {
+            ulong cur_pfn = rma_size_mfn;
+
             list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
-                uint end_pfn = pe->pfn + (1 << pe->order);
-
-                if (pfn >= pe->pfn && pfn < end_pfn) {
+                uint pe_pages = 1UL << pe->order;
+                uint end_pfn = cur_pfn + pe_pages;
+
+                if (pfn >= cur_pfn && pfn < end_pfn) {
                     t = PFN_TYPE_LOGICAL;
-                    mfn = page_to_mfn(pe->pg) + (pfn - pe->pfn);
+                    mfn = page_to_mfn(pe->pg) + (pfn - cur_pfn);
                     break;
                 }
+                cur_pfn += pe_pages;
             }
         }
         BUG_ON(t != PFN_TYPE_NONE && page_get_owner(mfn_to_page(mfn)) != d);
@@ -412,3 +416,10 @@ void shadow_drop_references(
     struct domain *d, struct page_info *page)
 {
 }
+
+int arch_domain_add_extent(struct domain *d, struct page_info *page, int order)
+{
+    if (add_extent(d, page, order) < 0)
+        return -ENOMEM;
+    return 0;
+}
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/arch/powerpc/ofd_fixup_memory.c
--- a/xen/arch/powerpc/ofd_fixup_memory.c       Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/arch/powerpc/ofd_fixup_memory.c       Thu Sep 14 14:53:32 2006 -0500
@@ -86,16 +86,18 @@ static void ofd_memory_extent_nodes(void
     ulong size;
     ofdn_t n;
     struct page_extents *pe;
+    ulong cur_pfn = 1UL << d->arch.rma_order;
 
     list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
 
-        start = pe->pfn << PAGE_SHIFT;
+        start = cur_pfn << PAGE_SHIFT;
         size = 1UL << (pe->order + PAGE_SHIFT);
 
         n = ofd_memory_node_create(m, OFD_ROOT, "", memory, memory,
                                     start, size);
 
         BUG_ON(n <= 0);
+        cur_pfn += 1UL << pe->order;
     }
 }
 
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/arch/powerpc/shadow.c
--- a/xen/arch/powerpc/shadow.c Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/arch/powerpc/shadow.c Thu Sep 14 14:53:32 2006 -0500
@@ -101,9 +101,6 @@ unsigned int shadow_set_allocation(struc
 
     addr = htab_alloc(d, order);
 
-    printk("%s: ibm,fpt-size should be: 0x%x\n", __func__,
-           d->arch.htab.log_num_ptes + LOG_PTE_SIZE);
-
     if (addr == 0)
         return -ENOMEM;
 
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/common/memory.c
--- a/xen/common/memory.c       Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/common/memory.c       Thu Sep 14 14:53:32 2006 -0500
@@ -66,6 +66,9 @@ increase_reservation(
                     extent_order, d->domain_id, memflags, i, nr_extents);
             return i;
         }
+
+               /* XXX PPC-specific hack */
+        BUG_ON(0 > arch_domain_add_extent(d, page, extent_order));
 
         /* Inform the domain of the new page's machine address. */ 
         if ( !guest_handle_is_null(extent_list) )
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/include/asm-ia64/mm.h Thu Sep 14 14:53:32 2006 -0500
@@ -500,4 +500,10 @@ int steal_page(
 int steal_page(
     struct domain *d, struct page_info *page, unsigned int memflags);
 
+static inline int arch_domain_add_extent(struct domain *d,
+               struct page_info *page, int order)
+{
+       return 0;
+}
+
 #endif /* __ASM_IA64_MM_H__ */
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/include/asm-powerpc/mm.h
--- a/xen/include/asm-powerpc/mm.h      Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/include/asm-powerpc/mm.h      Thu Sep 14 14:53:32 2006 -0500
@@ -86,7 +86,6 @@ struct page_extents {
     /* page extent */
     struct page_info *pg;
     uint order;
-    ulong pfn;
 };
 
  /* The following page types are MUTUALLY EXCLUSIVE. */
@@ -244,6 +243,9 @@ extern uint allocate_extents(struct doma
 extern uint allocate_extents(struct domain *d, uint nrpages, uint rma_nrpages);
 extern void free_extents(struct domain *d);
 
+extern int arch_domain_add_extent(struct domain *d, struct page_info *page,
+        int order);
+
 extern int steal_page(struct domain *d, struct page_info *page,
                         unsigned int memflags);
 
diff -r 3d60bf30dff2 -r 14e7c2948115 xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h  Thu Sep 14 14:20:48 2006 -0400
+++ b/xen/include/asm-x86/mm.h  Thu Sep 14 14:53:32 2006 -0500
@@ -432,4 +432,10 @@ int steal_page(
 int steal_page(
     struct domain *d, struct page_info *page, unsigned int memflags);
 
+static inline int arch_domain_add_extent(struct domain *d,
+               struct page_info *page, int order)
+{
+       return 0;
+}
+
 #endif /* __ASM_X86_MM_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [XenPPC] [xenppc-unstable] [XEN][POWERPC] support non-RMA memory in domU, Xen patchbot-xenppc-unstable <=