Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-16 Thread Jimi Xenidis


On Jan 16, 2007, at 10:05 AM, Ryan Harper wrote:


* Hollis Blanchard [EMAIL PROTECTED] [2007-01-15 20:44]:

On Mon, 2007-01-15 at 21:29 -0500, Jimi Xenidis wrote:

On Jan 15, 2007, at 8:20 PM, Hollis Blanchard wrote:


On Mon, 2007-01-15 at 17:25 -0500, Jimi Xenidis wrote:

+int make_devtree(

[snip]
Any ideas what this reservation is for? is it for the flat- 
devtree

itself?


Nope.


+/* root.reserve(0x100, 0x1000) */
+val[0] = cpu_to_be64((u64) 0x100);
+val[1] = cpu_to_be64((u64) 0x1000);
+ft_add_rsvmap(root, val[0], val[1]);


Yes, it is: see DEVTREE_ADDR in xc_linux_build.c .

so we can lose it, right?


You should know: http://patchwork.ozlabs.org/linuxppc/patch? 
id=5043 :)


Yes, we can remove it.


Even though we aren't making the tree in python we are still  
loading it

at DEVTREE_ADDR no?  Why don't we need it?


First off, the length is bogus.
The reservation list is to let the OS know immediately what memory  
the devtree and all it references are occupying.  However the  
devtree's header contains the real devtree size and the domain is  
given its location.  So the reservation entry is really redundant and  
makes relocating the devtree to an arbitrary location in memory more  
difficult.



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


Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-16 Thread Jimi Xenidis
Scratch this! I do not think this entry is for the devtree, I think  
it is the bogus entry that we create to optionally reserve the memory  
for the initrd, this was a side effect of creating the devtree in the  
python tree.
So now that its in libxc we can clean it up.  We must have made it  
redundant because we did not want to leave it as zero, since that  
terminates the reservation list.


Here is the patch so far.

+/* XXX:NB: you MUST set reservations BEFORE  
_starting_the_tree_ */

+
This is the redundant entry that allows us to fill in the optional  
initrd memory.
We make it first to make it easy to find later, but this should no  
longer be necessary.



+/* root.reserve(0x100, 0x1000) */
+val[0] = cpu_to_be64((u64) 0x100);
+val[1] = cpu_to_be64((u64) 0x1000);
+ft_add_rsvmap(root, val[0], val[1]);
+


This is the entry that reserves the last 4 pages of the RMA, so  
obviously this need to be hang off of rma_bytes as well.

+/* root.reserve(0x3ffc000, 0x4000 */
+val[0] = cpu_to_be64((u64) 0x3ffc000);
+val[1] = cpu_to_be64((u64) 0x4000);
+ft_add_rsvmap(root, val[0], val[1]);
+


And then there is the implicit terminating entry that is all zeros.

I also notice that:

+/* xc_linux_load.c will overwrite these 64-bit properties later
+*
+* chosen.addprop('linux,initrd-start', long(0))
+* chosen.addprop('linux,initrd-end', long(0)))
+*/
+val[0] = cpu_to_be64((u64) 0);
+ft_prop(root, linux,initrd-start, val, sizeof(val[0]));
+ft_prop(root, linux,initrd-end, val, sizeof(val[0]));


Now that we do this in libcx, we _can_ know the answer and define  
them once and even drop the prop and reservation if there _is_ no  
initrd.

-JX


On Jan 16, 2007, at 10:13 AM, Jimi Xenidis wrote:



On Jan 16, 2007, at 10:05 AM, Ryan Harper wrote:


* Hollis Blanchard [EMAIL PROTECTED] [2007-01-15 20:44]:

On Mon, 2007-01-15 at 21:29 -0500, Jimi Xenidis wrote:

On Jan 15, 2007, at 8:20 PM, Hollis Blanchard wrote:


On Mon, 2007-01-15 at 17:25 -0500, Jimi Xenidis wrote:

+int make_devtree(

[snip]
Any ideas what this reservation is for? is it for the flat- 
devtree

itself?


Nope.


+/* root.reserve(0x100, 0x1000) */
+val[0] = cpu_to_be64((u64) 0x100);
+val[1] = cpu_to_be64((u64) 0x1000);
+ft_add_rsvmap(root, val[0], val[1]);


Yes, it is: see DEVTREE_ADDR in xc_linux_build.c .

so we can lose it, right?


You should know: http://patchwork.ozlabs.org/linuxppc/patch? 
id=5043 :)


Yes, we can remove it.


Even though we aren't making the tree in python we are still  
loading it

at DEVTREE_ADDR no?  Why don't we need it?


First off, the length is bogus.
The reservation list is to let the OS know immediately what memory  
the devtree and all it references are occupying.  However the  
devtree's header contains the real devtree size and the domain is  
given its location.  So the reservation entry is really redundant  
and makes relocating the devtree to an arbitrary location in memory  
more difficult.








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


Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-15 Thread Ryan Harper
* Jimi Xenidis [EMAIL PROTECTED] [2007-01-11 16:53]:
 
 Ok there are a few things here.

Respun with fixes:

- preserve and return errno where approriate
- using open/close and read/write instead of f* 
- dropped vcpu argument, only fill out one cpu in devtree
- dropped regexp requirment, use a null-terminated list of filters
- made sure to call closedir()
- fixed double-free of bph on error path
- fixed static function names
- renamed find_first_cpu to find_cpu, we don't care which cpu we find


-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
[EMAIL PROTECTED]

diffstat output:
 b/tools/libxc/powerpc64/mk_flatdevtree.c |  567 +++
 b/tools/libxc/powerpc64/mk_flatdevtree.h |   44 ++
 tools/libxc/powerpc64/Makefile   |1 
 tools/libxc/powerpc64/xc_linux_build.c   |   30 +
 tools/libxc/xenguest.h   |4 
 tools/python/xen/lowlevel/xc/xc.c|   12 
 tools/python/xen/xend/image.py   |5 
 7 files changed, 646 insertions(+), 17 deletions(-)

Signed-off-by: Ryan Harper [EMAIL PROTECTED]
---
[PATCH] Move flat device tree construction from python to libxc for 
xc_linux_build().

Signed-off-by: Ryan Harper [EMAIL PROTECTED]

diff -r 3edbfb956864 tools/libxc/powerpc64/Makefile
--- a/tools/libxc/powerpc64/MakefileFri Jan 12 15:16:42 2007 -0600
+++ b/tools/libxc/powerpc64/MakefileFri Jan 12 15:16:42 2007 -0600
@@ -1,4 +1,5 @@ GUEST_SRCS-y += powerpc64/flatdevtree.c
 GUEST_SRCS-y += powerpc64/flatdevtree.c
+GUEST_SRCS-y += powerpc64/mk_flatdevtree.c
 GUEST_SRCS-y += powerpc64/xc_linux_build.c
 GUEST_SRCS-y += powerpc64/xc_prose_build.c
 GUEST_SRCS-y += powerpc64/utils.c
diff -r 3edbfb956864 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.cFri Jan 12 15:16:42 2007 -0600
+++ b/tools/libxc/powerpc64/xc_linux_build.cFri Jan 12 16:00:33 2007 -0600
@@ -13,9 +13,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- * Copyright (C) IBM Corporation 2006
+ * Copyright IBM Corporation 2006, 2007
  *
  * Authors: Hollis Blanchard [EMAIL PROTECTED]
+ *  Ryan Harper [EMAIL PROTECTED]
  */
 
 #include stdio.h
@@ -36,6 +37,7 @@
 #include flatdevtree_env.h
 #include flatdevtree.h
 #include utils.h
+#include mk_flatdevtree.h
 
 #define INITRD_ADDR (24UL  20)
 #define DEVTREE_ADDR (16UL  20)
@@ -238,8 +240,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int console_evtchn,
-   unsigned long *console_mfn,
-   void *devtree)
+   unsigned long *console_mfn)
 {
 start_info_t start_info;
 struct domain_setup_info dsi;
@@ -251,12 +252,34 @@ int xc_linux_build(int xc_handle,
 unsigned long initrd_len = 0;
 unsigned long start_info_addr;
 unsigned long rma_pages;
+unsigned long shadow_mb;
 int rc = 0;
+int op;
+struct ft_cxt root;
+void *devtree;
 
 DPRINTF(%s\n, __func__);
 
 nr_pages = mem_mb  (20 - PAGE_SHIFT);
 DPRINTF(nr_pages 0x%lx\n, nr_pages);
+
+/* fetch the current shadow_memory value for this domain */
+op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
+if (xc_shadow_control(xc_handle, domid, op, NULL, 0, shadow_mb, 0, NULL) 
 0 ) {
+rc = -1;
+goto out;
+}
+
+/* build the devtree here */
+DPRINTF(constructing devtree\n);
+if (make_devtree(root, domid, mem_mb, shadow_mb, cmdline)  0) {
+DPRINTF(failed to create flattened device tree\n);
+rc = -1;
+goto out;
+}
+
+/* point devtree at bph blob */
+devtree = root.bph;
 
 rma_pages = get_rma_pages(devtree);
 if (rma_pages == 0) {
@@ -314,6 +337,7 @@ int xc_linux_build(int xc_handle,
 }
 
 out:
+free_devtree(root);
 free_page_array(page_array);
 return rc;
 }
diff -r 3edbfb956864 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.hFri Jan 12 15:16:42 2007 -0600
+++ b/tools/libxc/xenguest.hFri Jan 12 17:08:40 2007 -0600
@@ -57,7 +57,6 @@ int xc_linux_restore(int xc_handle, int 
  * @parm store_mfn returned with the mfn of the store page
  * @parm console_evtchn the console event channel for this domain to use
  * @parm console_mfn returned with the mfn of the console page
- * @parm arch_args architecture-specific data
  * @return 0 on success, -1 on failure
  */
 int xc_linux_build(int xc_handle,
@@ -71,8 +70,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int console_evtchn,
-   unsigned long *console_mfn,
-   void *arch_args);
+   unsigned long *console_mfn);
 
 /**
  * This function will create a domain for a paravirtualized 

Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-15 Thread Jimi Xenidis


On Jan 15, 2007, at 1:51 PM, Ryan Harper wrote:


* Jimi Xenidis [EMAIL PROTECTED] [2007-01-11 16:53]:


Ok there are a few things here.


BTW: some of these issues existed in the original python, but they  
are yours now :)



Respun with fixes:

- preserve and return errno where approriate
- using open/close and read/write instead of f*
- dropped vcpu argument, only fill out one cpu in devtree
- dropped regexp requirment, use a null-terminated list of filters
- made sure to call closedir()
- fixed double-free of bph on error path
- fixed static function names
- renamed find_first_cpu to find_cpu, we don't care which cpu we find


I believe you _must_ use the the entry that has a reg property of 0.




--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
[EMAIL PROTECTED]

diffstat output:
 b/tools/libxc/powerpc64/mk_flatdevtree.c |  567 +++ 


 b/tools/libxc/powerpc64/mk_flatdevtree.h |   44 ++
 tools/libxc/powerpc64/Makefile   |1
 tools/libxc/powerpc64/xc_linux_build.c   |   30 +
 tools/libxc/xenguest.h   |4
 tools/python/xen/lowlevel/xc/xc.c|   12
 tools/python/xen/xend/image.py   |5
 7 files changed, 646 insertions(+), 17 deletions(-)

Signed-off-by: Ryan Harper [EMAIL PROTECTED]
---
[PATCH] Move flat device tree construction from python to libxc for  
xc_linux_build().


Signed-off-by: Ryan Harper [EMAIL PROTECTED]

diff -r 3edbfb956864 tools/libxc/powerpc64/Makefile
--- a/tools/libxc/powerpc64/MakefileFri Jan 12 15:16:42 2007 -0600
+++ b/tools/libxc/powerpc64/MakefileFri Jan 12 15:16:42 2007 -0600
@@ -1,4 +1,5 @@ GUEST_SRCS-y += powerpc64/flatdevtree.c
 GUEST_SRCS-y += powerpc64/flatdevtree.c
+GUEST_SRCS-y += powerpc64/mk_flatdevtree.c
 GUEST_SRCS-y += powerpc64/xc_linux_build.c
 GUEST_SRCS-y += powerpc64/xc_prose_build.c
 GUEST_SRCS-y += powerpc64/utils.c
diff -r 3edbfb956864 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c	Fri Jan 12 15:16:42  
2007 -0600
+++ b/tools/libxc/powerpc64/xc_linux_build.c	Fri Jan 12 16:00:33  
2007 -0600

@@ -13,9 +13,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
02111-1307, USA.

  *
- * Copyright (C) IBM Corporation 2006
+ * Copyright IBM Corporation 2006, 2007
  *
  * Authors: Hollis Blanchard [EMAIL PROTECTED]
+ *  Ryan Harper [EMAIL PROTECTED]
  */

 #include stdio.h
@@ -36,6 +37,7 @@
 #include flatdevtree_env.h
 #include flatdevtree.h
 #include utils.h
+#include mk_flatdevtree.h

 #define INITRD_ADDR (24UL  20)
 #define DEVTREE_ADDR (16UL  20)
@@ -238,8 +240,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int console_evtchn,
-   unsigned long *console_mfn,
-   void *devtree)
+   unsigned long *console_mfn)
 {
 start_info_t start_info;
 struct domain_setup_info dsi;
@@ -251,12 +252,34 @@ int xc_linux_build(int xc_handle,
 unsigned long initrd_len = 0;
 unsigned long start_info_addr;
 unsigned long rma_pages;
+unsigned long shadow_mb;
 int rc = 0;
+int op;
+struct ft_cxt root;
+void *devtree;

 DPRINTF(%s\n, __func__);

 nr_pages = mem_mb  (20 - PAGE_SHIFT);
 DPRINTF(nr_pages 0x%lx\n, nr_pages);
+
+/* fetch the current shadow_memory value for this domain */
+op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
+if (xc_shadow_control(xc_handle, domid, op, NULL, 0,  
shadow_mb, 0, NULL)  0 ) {

+rc = -1;
+goto out;
+}
+
+/* build the devtree here */
+DPRINTF(constructing devtree\n);
+if (make_devtree(root, domid, mem_mb, shadow_mb, cmdline)  0) {
+DPRINTF(failed to create flattened device tree\n);
+rc = -1;
+goto out;
+}
+
+/* point devtree at bph blob */
+devtree = root.bph;

 rma_pages = get_rma_pages(devtree);
 if (rma_pages == 0) {
@@ -314,6 +337,7 @@ int xc_linux_build(int xc_handle,
 }

 out:
+free_devtree(root);
 free_page_array(page_array);
 return rc;
 }
diff -r 3edbfb956864 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.hFri Jan 12 15:16:42 2007 -0600
+++ b/tools/libxc/xenguest.hFri Jan 12 17:08:40 2007 -0600
@@ -57,7 +57,6 @@ int xc_linux_restore(int xc_handle, int
  * @parm store_mfn returned with the mfn of the store page
  * @parm console_evtchn the console event channel for this domain  
to use

  * @parm console_mfn returned with the mfn of the console page
- * @parm arch_args architecture-specific data
  * @return 0 on success, -1 on failure
  */
 int xc_linux_build(int xc_handle,
@@ -71,8 +70,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int 

Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-15 Thread Jimi Xenidis


On Jan 15, 2007, at 4:13 PM, Ryan Harper wrote:


* Jimi Xenidis [EMAIL PROTECTED] [2007-01-15 14:53]:


On Jan 15, 2007, at 1:51 PM, Ryan Harper wrote:


* Jimi Xenidis [EMAIL PROTECTED] [2007-01-11 16:53]:

[snip]
- renamed find_first_cpu to find_cpu, we don't care which cpu we  
find


I believe you _must_ use the the entry that has a reg property of 0.


Is that because the properties we are interested aren't guaranteed  
to be

present in all cpu nodes?

Well I would like it to have a reg=0 and cpu#=0
Some OF devtrees contain nodes that described shares resources (like  
L3, L4 caches), usually the full definition is in the lowest number  
of the sharers and the secondaries can simply us a property that  
contains the phandle of the original node.

[snip]



SEGVs are good! :)


WFM. =)

No.. seriously!
[snip]




+static int copynode(struct ft_cxt *cxt, const char *dirpath, const
char **propfilter)
+{


This is totally informational, but I think the blob/fnmatch routines
may make this code way simpler.


sure and I liked my regexp, but the concern was what sort of libc
functions would be available in Xen when we implement copynode down
there for dom0 devtree construction.


this is a good point, however dom0 will copy everything.
[snip]


+int make_devtree(

[snip]

Any ideas what this reservation is for? is it for the flat-devtree
itself?


Nope.


+/* root.reserve(0x100, 0x1000) */
+val[0] = cpu_to_be64((u64) 0x100);
+val[1] = cpu_to_be64((u64) 0x1000);
+ft_add_rsvmap(root, val[0], val[1]);


Hollis?!



+


this value is keyed off of rma_bytes


No idea, just duping reservations that the python code made.  Is there
some place I should be getting these values from?
Sure.. you calculate rma_bytes below when you fill in the /[EMAIL PROTECTED]  
stuff in.

that is what you are missing below.
[snip]



+/* xen = root.addnode('xen') */
+ft_begin_node(root, xen);


the 0x3ffc00 value is offset from rma_bytes

+
+/* xen.addprop('start-info', long(0x3ffc000), long(0x1000)) */
+val[0] = cpu_to_be64((u64) 0x3ffc000);
+val[1] = cpu_to_be64((u64) 0x1000);
+ft_prop(root, start-info, val, sizeof(val));


What am I missing here?


+
+/* [EMAIL PROTECTED] is all the rest */
+if (remaining  0)
+{


this really should be memory@rma_bytes


+/* mem = root.addnode('[EMAIL PROTECTED]') */
+ft_begin_node(root, [EMAIL PROTECTED]);
+


OK.

--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
[EMAIL PROTECTED]



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


Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-15 Thread Hollis Blanchard
On Mon, 2007-01-15 at 17:25 -0500, Jimi Xenidis wrote:
  +int make_devtree(
 [snip]
  Any ideas what this reservation is for? is it for the flat-devtree
  itself?
 
  Nope.
 
  +/* root.reserve(0x100, 0x1000) */
  +val[0] = cpu_to_be64((u64) 0x100);
  +val[1] = cpu_to_be64((u64) 0x1000);
  +ft_add_rsvmap(root, val[0], val[1]);

Yes, it is: see DEVTREE_ADDR in xc_linux_build.c .

-- 
Hollis Blanchard
IBM Linux Technology Center


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


Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-15 Thread Jimi Xenidis


On Jan 15, 2007, at 8:20 PM, Hollis Blanchard wrote:


On Mon, 2007-01-15 at 17:25 -0500, Jimi Xenidis wrote:

+int make_devtree(

[snip]

Any ideas what this reservation is for? is it for the flat-devtree
itself?


Nope.


+/* root.reserve(0x100, 0x1000) */
+val[0] = cpu_to_be64((u64) 0x100);
+val[1] = cpu_to_be64((u64) 0x1000);
+ft_add_rsvmap(root, val[0], val[1]);


Yes, it is: see DEVTREE_ADDR in xc_linux_build.c .

so we can lose it, right?
-JX


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


Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-15 Thread Hollis Blanchard
On Mon, 2007-01-15 at 21:29 -0500, Jimi Xenidis wrote:
 On Jan 15, 2007, at 8:20 PM, Hollis Blanchard wrote:
 
  On Mon, 2007-01-15 at 17:25 -0500, Jimi Xenidis wrote:
  +int make_devtree(
  [snip]
  Any ideas what this reservation is for? is it for the flat-devtree
  itself?
 
  Nope.
 
  +/* root.reserve(0x100, 0x1000) */
  +val[0] = cpu_to_be64((u64) 0x100);
  +val[1] = cpu_to_be64((u64) 0x1000);
  +ft_add_rsvmap(root, val[0], val[1]);
 
  Yes, it is: see DEVTREE_ADDR in xc_linux_build.c .
 so we can lose it, right?

You should know: http://patchwork.ozlabs.org/linuxppc/patch?id=5043 :)

Yes, we can remove it.

-- 
Hollis Blanchard
IBM Linux Technology Center


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


[XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-11 Thread Ryan Harper
7 files changed, 617 insertions(+), 17 deletions(-)
tools/libxc/powerpc64/Makefile |1 
tools/libxc/powerpc64/mk_flatdevtree.c |  520 
tools/libxc/powerpc64/mk_flatdevtree.h |   48 ++
tools/libxc/powerpc64/xc_linux_build.c |   44 ++
tools/libxc/xenguest.h |4 
tools/python/xen/lowlevel/xc/xc.c  |   12 
tools/python/xen/xend/image.py |5 


# HG changeset patch
# User Ryan Harper [EMAIL PROTECTED]
# Date 1168544367 21600
# Node ID e4fda6c5e7a907b5e4726c4f4d5f117c0f4d6f50
# Parent  0279229b68453a4a1b3613ac02c8b8ca9a965875
[PATCH] Move flat device tree construction from python to libxc for 
xc_linux_build().

Signed-off-by: Ryan Harper [EMAIL PROTECTED]

diff -r 0279229b6845 -r e4fda6c5e7a9 tools/libxc/powerpc64/Makefile
--- a/tools/libxc/powerpc64/MakefileThu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/powerpc64/MakefileThu Jan 11 13:39:27 2007 -0600
@@ -1,4 +1,5 @@ GUEST_SRCS-y += powerpc64/flatdevtree.c
 GUEST_SRCS-y += powerpc64/flatdevtree.c
+GUEST_SRCS-y += powerpc64/mk_flatdevtree.c
 GUEST_SRCS-y += powerpc64/xc_linux_build.c
 GUEST_SRCS-y += powerpc64/xc_prose_build.c
 GUEST_SRCS-y += powerpc64/utils.c
diff -r 0279229b6845 -r e4fda6c5e7a9 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.cThu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/powerpc64/xc_linux_build.cThu Jan 11 13:39:27 2007 -0600
@@ -13,9 +13,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- * Copyright (C) IBM Corporation 2006
+ * Copyright IBM Corporation 2006
  *
  * Authors: Hollis Blanchard [EMAIL PROTECTED]
+ *  Ryan Harper [EMAIL PROTECTED]
  */
 
 #include stdio.h
@@ -36,6 +37,7 @@
 #include flatdevtree_env.h
 #include flatdevtree.h
 #include utils.h
+#include mk_flatdevtree.h
 
 #define INITRD_ADDR (24UL  20)
 #define DEVTREE_ADDR (16UL  20)
@@ -238,8 +240,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int console_evtchn,
-   unsigned long *console_mfn,
-   void *devtree)
+   unsigned long *console_mfn)
 {
 start_info_t start_info;
 struct domain_setup_info dsi;
@@ -251,12 +252,48 @@ int xc_linux_build(int xc_handle,
 unsigned long initrd_len = 0;
 unsigned long start_info_addr;
 unsigned long rma_pages;
+unsigned long shadow_mb;
 int rc = 0;
+int op;
+uint32_t nr_vcpus;
+xc_dominfo_t info;
+struct ft_cxt root;
+void *devtree;
 
 DPRINTF(%s\n, __func__);
 
 nr_pages = mem_mb  (20 - PAGE_SHIFT);
 DPRINTF(nr_pages 0x%lx\n, nr_pages);
+
+/* XXX: fetch the number of vcpus configured for this domain
+   checking that xc_domain_getinfo returns info for exactly 1 
+   dom */
+if (xc_domain_getinfo(xc_handle, domid, 1, info) != 1) {
+DPRINTF(xc_domain_getinfo() failed, can't determine max_vcpu_id\n);
+rc = -1;
+goto out;
+}
+
+/* NB: max_vcpu_id is zero-based */
+nr_vcpus = info.max_vcpu_id + 1;
+
+/* XXX: fetch the current shadow_memory value for this domain */
+op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
+if (xc_shadow_control(xc_handle, domid, op, NULL, 0, shadow_mb, 0, NULL) 
 0 ) {
+rc = -1;
+goto out;
+}
+
+/* build the devtree here */
+DPRINTF(constructing devtree\n);
+if (make_devtree(root, domid, mem_mb, nr_vcpus, shadow_mb, cmdline)  0) {
+DPRINTF(failed to create flattened device tree\n);
+rc = -1;
+goto out;
+}
+
+/* point devtree at bph blob */
+devtree = root.bph;
 
 rma_pages = get_rma_pages(devtree);
 if (rma_pages == 0) {
@@ -314,6 +351,7 @@ int xc_linux_build(int xc_handle,
 }
 
 out:
+free_devtree(root.bph);
 free_page_array(page_array);
 return rc;
 }
diff -r 0279229b6845 -r e4fda6c5e7a9 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.hThu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/xenguest.hThu Jan 11 13:39:27 2007 -0600
@@ -57,7 +57,6 @@ int xc_linux_restore(int xc_handle, int 
  * @parm store_mfn returned with the mfn of the store page
  * @parm console_evtchn the console event channel for this domain to use
  * @parm console_mfn returned with the mfn of the console page
- * @parm arch_args architecture-specific data
  * @return 0 on success, -1 on failure
  */
 int xc_linux_build(int xc_handle,
@@ -71,8 +70,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int console_evtchn,
-   unsigned long *console_mfn,
-   void *arch_args);
+   unsigned long *console_mfn);
 
 /**
  * This function will create a domain for a paravirtualized Linux
diff 

Re: [XenPPC] [PATCH 3 of 4] [PATCH] Move flat device tree construction from python to libxc for xc_linux_build()

2007-01-11 Thread Jimi Xenidis


Ok there are a few things here.

On Jan 11, 2007, at 1:42 PM, Ryan Harper wrote:


7 files changed, 617 insertions(+), 17 deletions(-)
tools/libxc/powerpc64/Makefile |1
tools/libxc/powerpc64/mk_flatdevtree.c |  520 ++ 
++

tools/libxc/powerpc64/mk_flatdevtree.h |   48 ++
tools/libxc/powerpc64/xc_linux_build.c |   44 ++
tools/libxc/xenguest.h |4
tools/python/xen/lowlevel/xc/xc.c  |   12
tools/python/xen/xend/image.py |5


# HG changeset patch
# User Ryan Harper [EMAIL PROTECTED]
# Date 1168544367 21600
# Node ID e4fda6c5e7a907b5e4726c4f4d5f117c0f4d6f50
# Parent  0279229b68453a4a1b3613ac02c8b8ca9a965875
[PATCH] Move flat device tree construction from python to libxc for  
xc_linux_build().


Signed-off-by: Ryan Harper [EMAIL PROTECTED]

diff -r 0279229b6845 -r e4fda6c5e7a9 tools/libxc/powerpc64/Makefile
--- a/tools/libxc/powerpc64/MakefileThu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/powerpc64/MakefileThu Jan 11 13:39:27 2007 -0600
@@ -1,4 +1,5 @@ GUEST_SRCS-y += powerpc64/flatdevtree.c
 GUEST_SRCS-y += powerpc64/flatdevtree.c
+GUEST_SRCS-y += powerpc64/mk_flatdevtree.c
 GUEST_SRCS-y += powerpc64/xc_linux_build.c
 GUEST_SRCS-y += powerpc64/xc_prose_build.c
 GUEST_SRCS-y += powerpc64/utils.c
diff -r 0279229b6845 -r e4fda6c5e7a9 tools/libxc/powerpc64/ 
xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c	Thu Jan 11 13:39:27  
2007 -0600
+++ b/tools/libxc/powerpc64/xc_linux_build.c	Thu Jan 11 13:39:27  
2007 -0600

@@ -13,9 +13,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
02111-1307, USA.

  *
- * Copyright (C) IBM Corporation 2006
+ * Copyright IBM Corporation 2006
  *
  * Authors: Hollis Blanchard [EMAIL PROTECTED]
+ *  Ryan Harper [EMAIL PROTECTED]
  */

 #include stdio.h
@@ -36,6 +37,7 @@
 #include flatdevtree_env.h
 #include flatdevtree.h
 #include utils.h
+#include mk_flatdevtree.h

 #define INITRD_ADDR (24UL  20)
 #define DEVTREE_ADDR (16UL  20)
@@ -238,8 +240,7 @@ int xc_linux_build(int xc_handle,
unsigned int store_evtchn,
unsigned long *store_mfn,
unsigned int console_evtchn,
-   unsigned long *console_mfn,
-   void *devtree)
+   unsigned long *console_mfn)
 {
 start_info_t start_info;
 struct domain_setup_info dsi;
@@ -251,12 +252,48 @@ int xc_linux_build(int xc_handle,
 unsigned long initrd_len = 0;
 unsigned long start_info_addr;
 unsigned long rma_pages;
+unsigned long shadow_mb;
 int rc = 0;
+int op;
+uint32_t nr_vcpus;
+xc_dominfo_t info;
+struct ft_cxt root;
+void *devtree;

 DPRINTF(%s\n, __func__);

 nr_pages = mem_mb  (20 - PAGE_SHIFT);
 DPRINTF(nr_pages 0x%lx\n, nr_pages);
+
+/* XXX: fetch the number of vcpus configured for this domain
+   checking that xc_domain_getinfo returns info for exactly 1
+   dom */


Hmm, you are doing this, what is the XXX for?


+if (xc_domain_getinfo(xc_handle, domid, 1, info) != 1) {
+DPRINTF(xc_domain_getinfo() failed, can't determine  
max_vcpu_id\n);

+rc = -1;
+goto out;
+}
+
+/* NB: max_vcpu_id is zero-based */
+nr_vcpus = info.max_vcpu_id + 1;


Not sure what you are actually doing here, we boot all domains UP and  
hotplug the rest, so the devtree will never have more than one CPU node.




+
+/* XXX: fetch the current shadow_memory value for this domain */

Again, why the XXX? are you Vin Diesel or Ice Cube?!


+op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
+if (xc_shadow_control(xc_handle, domid, op, NULL, 0,  
shadow_mb, 0, NULL)  0 ) {

+rc = -1;
+goto out;
+}
+
+/* build the devtree here */
+DPRINTF(constructing devtree\n);
+if (make_devtree(root, domid, mem_mb, nr_vcpus, shadow_mb,  
cmdline)  0) {


I'd expect make_devtree() to only take one argument and use separate  
ft_* calls to fill in the rest of these params.



+DPRINTF(failed to create flattened device tree\n);
+rc = -1;
+goto out;
+}
+
+/* point devtree at bph blob */
+devtree = root.bph;

 rma_pages = get_rma_pages(devtree);
 if (rma_pages == 0) {
@@ -314,6 +351,7 @@ int xc_linux_build(int xc_handle,
 }

 out:
+free_devtree(root.bph);
 free_page_array(page_array);
 return rc;
 }
diff -r 0279229b6845 -r e4fda6c5e7a9 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.hThu Jan 11 13:39:27 2007 -0600
+++ b/tools/libxc/xenguest.hThu Jan 11 13:39:27 2007 -0600
@@ -57,7 +57,6 @@ int xc_linux_restore(int xc_handle, int
  * @parm store_mfn returned with the mfn of the store page
  * @parm console_evtchn the console event channel for this domain  
to use

  * @parm console_mfn returned with the mfn of the console page
- * @parm arch_args architecture-specific data
  * @return 0 on