Hollis Blanchard
2006-Aug-08 20:28 UTC
[Xen-devel] [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
(I''m not attached to the name "arch_args" in this patch.) Keir, this patch applies on top of the xc.c whitespace patch I just sent, and also on top of the contents of xenppc-unstable-merge.hg (because we''ve moved xc_ppc_linux_build.c into its own directory). We also have a couple important fixes in there anyways, so now would be a good time to pull. :) .hgignore | 8 a/tools/libxc/xc_ppc_linux_build.c | 408 ------------------------------- b/tools/libxc/powerpc64/Makefile | 1 b/tools/libxc/powerpc64/xc_linux_build.c | 408 +++++++++++++++++++++++++++++++ tools/libxc/xc_ppc_linux_build.c | 40 +-- xen/arch/powerpc/Makefile | 3 xen/arch/powerpc/boot_of.c | 8 xen/arch/powerpc/dom0_ops.c | 43 ++- xen/arch/powerpc/domain.c | 29 +- xen/arch/powerpc/of_handler/devtree.c | 2 xen/arch/powerpc/powerpc64/ppc970.c | 7 xen/arch/powerpc/usercopy.c | 4 xen/include/asm-powerpc/processor.h | 1 13 files changed, 502 insertions(+), 460 deletions(-) # HG changeset patch # User Hollis Blanchard <hollisb@us.ibm.com> # Date 1155068244 18000 # Node ID e74340460b8cac614ac71d540ca78eb11a0e917f # Parent 375fb1f773c5ec053d63315e4d942e7d3aeb0cda [LIBXC] add architecture-specific parameter to xc_linux_build() On PowerPC, we will pass down the flattened device tree from Python this way. Other architectures currently leave this unused. Should more than one parameter be needed in the future, the address of an architecture-specific structure can be passed instead (i.e. we won''t need to add more parameters to the prototype). Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> diff -r 375fb1f773c5 -r e74340460b8c tools/libxc/powerpc64/xc_linux_build.c --- a/tools/libxc/powerpc64/xc_linux_build.c Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/libxc/powerpc64/xc_linux_build.c Tue Aug 08 15:17:24 2006 -0500 @@ -352,7 +352,8 @@ int xc_linux_build(int xc_handle, unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *devtree) { struct domain_setup_info dsi; xen_pfn_t *page_array = NULL; diff -r 375fb1f773c5 -r e74340460b8c tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/libxc/xc_linux_build.c Tue Aug 08 15:17:24 2006 -0500 @@ -1337,7 +1337,8 @@ int xc_linux_build(int xc_handle, unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *unused) { char *image = NULL; unsigned long image_size; diff -r 375fb1f773c5 -r e74340460b8c tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/libxc/xenguest.h Tue Aug 08 15:17:24 2006 -0500 @@ -55,7 +55,8 @@ int xc_linux_restore(int xc_handle, int * @parm store_evtchn the store event channel for this domain to use * @parm store_mfn returned with the mfn of the store page * @parm console_evtchn the console event channel for this domain to use - * @parm conole_mfn returned with the mfn of the console page + * @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, @@ -68,7 +69,8 @@ int xc_linux_build(int xc_handle, unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn); + unsigned long *console_mfn, + void *arch_args); /** * This function will create a domain for a paravirtualized Linux diff -r 375fb1f773c5 -r e74340460b8c tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/python/xen/lowlevel/xc/xc.c Tue Aug 08 15:17:24 2006 -0500 @@ -331,25 +331,26 @@ static PyObject *pyxc_linux_build(XcObje int store_evtchn, console_evtchn; unsigned long store_mfn = 0; unsigned long console_mfn = 0; + void *arch_args = NULL; static char *kwd_list[] = { "dom", "store_evtchn", "console_evtchn", "image", /* optional */ "ramdisk", "cmdline", "flags", - "features", "arch", NULL }; - - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssis", kwd_list, + "features", "arch_args", NULL }; + + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssiss", kwd_list, &dom, &store_evtchn, &console_evtchn, &image, /* optional */ &ramdisk, &cmdline, &flags, - &features) ) + &features, &arch_args) ) return NULL; if ( xc_linux_build(self->xc_handle, dom, image, ramdisk, cmdline, features, flags, store_evtchn, &store_mfn, - console_evtchn, &console_mfn) != 0 ) { + console_evtchn, &console_mfn, arch_args) != 0 ) { if (!errno) errno = EINVAL; return PyErr_SetFromErrno(xc_error); -- Hollis Blanchard IBM Linux Technology Center _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hollis Blanchard
2006-Aug-09 04:39 UTC
Re: [Xen-devel] [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On Tue, 2006-08-08 at 15:28 -0500, Hollis Blanchard wrote:> diff -r 375fb1f773c5 -r e74340460b8c tools/python/xen/lowlevel/xc/xc.c > --- a/tools/python/xen/lowlevel/xc/xc.c Tue Aug 08 15:11:25 2006 -0500 > +++ b/tools/python/xen/lowlevel/xc/xc.c Tue Aug 08 15:17:24 2006 -0500 > @@ -331,25 +331,26 @@ static PyObject *pyxc_linux_build(XcObje > int store_evtchn, console_evtchn; > unsigned long store_mfn = 0; > unsigned long console_mfn = 0; > + void *arch_args = NULL; > > static char *kwd_list[] = { "dom", "store_evtchn", > "console_evtchn", "image", > /* optional */ > "ramdisk", "cmdline", "flags", > - "features", "arch", NULL }; > - > - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssis", kwd_list, > + "features", "arch_args", NULL }; > + > + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssiss", kwd_list,The one complication is that PPC''s data structure has NULL characters in it, which the "s" conversion char doesn''t like. Instead you must use "s#" to get the length as well, except I think it''s ok to leave it up to the architecture to handle the length itself (after all, even an int that has a NULL byte trips this problem). So here is the updated patch. # HG changeset patch # User Hollis Blanchard <hollisb@us.ibm.com> # Date 1155068244 18000 # Node ID e74340460b8cac614ac71d540ca78eb11a0e917f # Parent 375fb1f773c5ec053d63315e4d942e7d3aeb0cda [LIBXC] add architecture-specific parameter to xc_linux_build() On PowerPC, we will pass down the flattened device tree from Python this way. Other architectures currently leave this unused. Should more than one parameter be needed in the future, the address of an architecture-specific structure can be passed instead (i.e. we won''t need to add more parameters to the prototype). Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> diff -r 375fb1f773c5 -r e74340460b8c tools/libxc/powerpc64/xc_linux_build.c --- a/tools/libxc/powerpc64/xc_linux_build.c Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/libxc/powerpc64/xc_linux_build.c Tue Aug 08 15:17:24 2006 -0500 @@ -352,7 +352,8 @@ int xc_linux_build(int xc_handle, unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *devtree) { struct domain_setup_info dsi; xen_pfn_t *page_array = NULL; diff -r 375fb1f773c5 -r e74340460b8c tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/libxc/xc_linux_build.c Tue Aug 08 15:17:24 2006 -0500 @@ -1337,7 +1337,8 @@ int xc_linux_build(int xc_handle, unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn) + unsigned long *console_mfn, + void *unused) { char *image = NULL; unsigned long image_size; diff -r 375fb1f773c5 -r e74340460b8c tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h Tue Aug 08 15:11:25 2006 -0500 +++ b/tools/libxc/xenguest.h Tue Aug 08 15:17:24 2006 -0500 @@ -55,7 +55,8 @@ int xc_linux_restore(int xc_handle, int * @parm store_evtchn the store event channel for this domain to use * @parm store_mfn returned with the mfn of the store page * @parm console_evtchn the console event channel for this domain to use - * @parm conole_mfn returned with the mfn of the console page + * @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, @@ -68,7 +69,8 @@ int xc_linux_build(int xc_handle, unsigned int store_evtchn, unsigned long *store_mfn, unsigned int console_evtchn, - unsigned long *console_mfn); + unsigned long *console_mfn, + void *arch_args); /** * This function will create a domain for a paravirtualized Linux --- tools/python/xen/lowlevel/xc/xc.c.orig 2006-08-08 23:36:31.000000000 -0500 +++ tools/python/xen/lowlevel/xc/xc.c 2006-08-08 23:36:34.000000000 -0500 @@ -331,25 +331,27 @@ int store_evtchn, console_evtchn; unsigned long store_mfn = 0; unsigned long console_mfn = 0; + void *arch_args = NULL; + int unused; static char *kwd_list[] = { "dom", "store_evtchn", "console_evtchn", "image", /* optional */ "ramdisk", "cmdline", "flags", - "features", NULL }; + "features", "arch_args", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssis", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssiss#", kwd_list, &dom, &store_evtchn, &console_evtchn, &image, /* optional */ &ramdisk, &cmdline, &flags, - &features) ) + &features, &arch_args, &unused) ) return NULL; if ( xc_linux_build(self->xc_handle, dom, image, ramdisk, cmdline, features, flags, store_evtchn, &store_mfn, - console_evtchn, &console_mfn) != 0 ) { + console_evtchn, &console_mfn, arch_args) != 0 ) { if (!errno) errno = EINVAL; return PyErr_SetFromErrno(xc_error); -- Hollis Blanchard IBM Linux Technology Center _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Aug-09 09:56 UTC
[Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On 8/8/06 9:28 pm, "Hollis Blanchard" <hollisb@us.ibm.com> wrote:> Keir, this patch applies on top of the xc.c whitespace patch I just > sent, and also on top of the contents of xenppc-unstable-merge.hg > (because we''ve moved xc_ppc_linux_build.c into its own directory). We > also have a couple important fixes in there anyways, so now would be a > good time to pull. :)The diffstat doesn''t correspond to the patch. Can I ignore the diffstat? -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Aug-09 10:16 UTC
Re: [Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On 9/8/06 10:56 am, "Keir Fraser" <Keir.Fraser@cl.cam.ac.uk> wrote:>> Keir, this patch applies on top of the xc.c whitespace patch I just >> sent, and also on top of the contents of xenppc-unstable-merge.hg >> (because we''ve moved xc_ppc_linux_build.c into its own directory). We >> also have a couple important fixes in there anyways, so now would be a >> good time to pull. :) > > The diffstat doesn''t correspond to the patch. Can I ignore the diffstat?Actually I''m not sure about this approach at all. Couldn''t specifying the open firmware tree be done separately from the build (e.g., just after)? Maybe hooked off the new proposed ''platform object'' in xend. Xc_linux_build is really ugly enough already: I think in future we would like to split xc_linux_build up into smaller API functions, even for x86, and that the patch you propose goes in the opposite direction to this. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hollis Blanchard
2006-Aug-09 15:00 UTC
[Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On Wed, 2006-08-09 at 10:56 +0100, Keir Fraser wrote:> > > On 8/8/06 9:28 pm, "Hollis Blanchard" <hollisb@us.ibm.com> wrote: > > > Keir, this patch applies on top of the xc.c whitespace patch I just > > sent, and also on top of the contents of xenppc-unstable-merge.hg > > (because we''ve moved xc_ppc_linux_build.c into its own directory). We > > also have a couple important fixes in there anyways, so now would be a > > good time to pull. :) > > The diffstat doesn''t correspond to the patch. Can I ignore the diffstat?Sorry for being unclear. The diffstat corresponds to the contents of the xenppc-unstable-merge.hg tree, which I was asking you to pull. -- Hollis Blanchard IBM Linux Technology Center _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hollis Blanchard
2006-Aug-09 15:14 UTC
Re: [Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On Wed, 2006-08-09 at 11:16 +0100, Keir Fraser wrote:> > Actually I''m not sure about this approach at all. Couldn''t specifying the > open firmware tree be done separately from the build (e.g., just after)? > Maybe hooked off the new proposed ''platform object'' in xend. Xc_linux_build > is really ugly enough already: I think in future we would like to split > xc_linux_build up into smaller API functions, even for x86, and that the > patch you propose goes in the opposite direction to this.That direction certainly seems like a good one to me. In this case, we need to load the device tree into the domain''s memory and pass its address in a register (i.e. via xc_vcpu_setcontext). Currently it doesn''t look like xc_vcpu_setcontext is exposed to python for us to use. What would you like to see here? -- Hollis Blanchard IBM Linux Technology Center _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Aug-09 16:38 UTC
[Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On 9/8/06 4:00 pm, "Hollis Blanchard" <hollisb@us.ibm.com> wrote:>> The diffstat doesn''t correspond to the patch. Can I ignore the diffstat? > > Sorry for being unclear. The diffstat corresponds to the contents of the > xenppc-unstable-merge.hg tree, which I was asking you to pull.Ah, I missed that bit. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Aug-09 16:44 UTC
Re: [Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On 9/8/06 4:14 pm, "Hollis Blanchard" <hollisb@us.ibm.com> wrote:> That direction certainly seems like a good one to me. > > In this case, we need to load the device tree into the domain''s memory > and pass its address in a register (i.e. via xc_vcpu_setcontext). > Currently it doesn''t look like xc_vcpu_setcontext is exposed to python > for us to use. What would you like to see here?Hmmm... I was expecting you''d want a ppc-specific libxenguest or libxenctrl function, but I guess maybe you could do it by more generic means. That would obviously be much preferable if it''s possible. Could a copy_to/from_guest interface exposed to Python be used? Or does the device tree need some processing in C into an appropriate format for writing into guest memory? As for set/get_vcpu_context, the context could be expressed as a Python dictionary mapping register names to (reasonably constrained) long values. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hollis Blanchard
2006-Aug-10 15:57 UTC
Re: [Xen-devel] Re: [PATCH] [LIBXC] add architecture-specific parameter to xc_linux_build()
On Wed, 2006-08-09 at 17:44 +0100, Keir Fraser wrote:> > On 9/8/06 4:14 pm, "Hollis Blanchard" <hollisb@us.ibm.com> wrote: > > > That direction certainly seems like a good one to me. > > > > In this case, we need to load the device tree into the domain''s memory > > and pass its address in a register (i.e. via xc_vcpu_setcontext). > > Currently it doesn''t look like xc_vcpu_setcontext is exposed to python > > for us to use. What would you like to see here? > > Hmmm... I was expecting you''d want a ppc-specific libxenguest or libxenctrl > function, but I guess maybe you could do it by more generic means. That > would obviously be much preferable if it''s possible. > > Could a copy_to/from_guest interface exposed to Python be used? Or does the > device tree need some processing in C into an appropriate format for writing > into guest memory? As for set/get_vcpu_context, the context could be > expressed as a Python dictionary mapping register names to (reasonably > constrained) long values.I spent some time building the proper binary format in Python (through lots of struct.pack and ''\0''.join), so the C code doesn''t need to reformat it. However, there are a few values we only determine in C code that need to be inserted into the device tree: - initrd start/end -- could be done in Python with an xc.copy_to_guest - console_mfn/store_mfn -- chosen arbitrarily in C, so could just as easily be chosen arbitrarily in Python Actually, I think that may be it... most of the data we can gather in Python or come directly from the domain config file. I can implement xc.copy_to_guest() and wc.copy_from_guest() and do the initrd loading in Python (including using the gzip module). However, initrd loading in tools/libxc/xc_linux_build.c looks a little more complicated than I''d feel comfortable modifying without testing, and I''m not really set up to test x86 changes. -- Hollis Blanchard IBM Linux Technology Center _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel