Re: [Xen-devel] [PATCH v2 1/3] arm64: Add Xen boot support file

2015-07-23 Thread Fu Wei
Hi Vladimir,

I have submitted a new patchset (v3) for xen boot.
this patchset follows all your comment here.

please help me again on this, Great thanks for your help.

On 16 July 2015 at 00:18, Vladimir 'φ-coder/phcoder' Serbinenko
 wrote:
> On 13.07.2015 10:53, fu@linaro.org wrote:
>> From: Fu Wei 
>>
>> This patch adds Xen boot support file:
>> grub-core/loader/arm64/xen_boot.c
>> include/grub/arm64/xen_boot.h
>>
>> This patch also adds commands register code and hearder file into
>> grub-core/loader/arm64/linux.c
>>
>>   - This adds support for the Xen boot on ARM specification for arm64.
>>   - The implementation for Xen is following  > Specification>:
>>   
>> http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
> Please don't refer to this protocol as multiboot anywhere in grub or
> around because it's NOT multiboot and we don't want to confuse those 2
> protocols.
>> and xen/docs/misc/arm/device-tree/booting.txt in Xen source code.
>>   - The multiboot/module commands have existed,
>> so we use xen_hypervisor/xen_module instead.
>>   - This Xen boot support is built into linux module for aarch64.
>>   - Adding this functionality to the existing "linux" module is for
>> reusing the existing code of devicetree.
>>
> Please create separate module. Modules are dynamically linked.
>> Signed-off-by: Fu Wei 
>> ---
>>  grub-core/Makefile.core.def   |   1 +
>>  grub-core/loader/arm64/linux.c|   6 +
>>  grub-core/loader/arm64/xen_boot.c | 615 
>> ++
>>  include/grub/arm64/xen_boot.h | 115 +++
>>  4 files changed, 737 insertions(+)
>>  create mode 100644 grub-core/loader/arm64/xen_boot.c
>>  create mode 100644 include/grub/arm64/xen_boot.h
>>
>> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
>> index a6101de..01f8261 100644
>> --- a/grub-core/Makefile.core.def
>> +++ b/grub-core/Makefile.core.def
>> @@ -1659,6 +1659,7 @@ module = {
>>ia64_efi = loader/ia64/efi/linux.c;
>>arm = loader/arm/linux.c;
>>arm64 = loader/arm64/linux.c;
>> +  arm64 = loader/arm64/xen_boot.c;
>>fdt = lib/fdt.c;
>>common = loader/linux.c;
>>common = lib/cmdline.c;
>> diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
>> index 987f5b9..7ae9bde 100644
>> --- a/grub-core/loader/arm64/linux.c
>> +++ b/grub-core/loader/arm64/linux.c
>> @@ -26,6 +26,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -477,6 +478,9 @@ GRUB_MOD_INIT (linux)
>>cmd_devicetree =
>>  grub_register_command ("devicetree", grub_cmd_devicetree, 0,
>>  N_("Load DTB file."));
>> +
>> +  grub_arm64_linux_register_xen_boot_command (mod, &loaded);
>> +
>>my_mod = mod;
>>  }
>>
>> @@ -485,4 +489,6 @@ GRUB_MOD_FINI (linux)
>>grub_unregister_command (cmd_linux);
>>grub_unregister_command (cmd_initrd);
>>grub_unregister_command (cmd_devicetree);
>> +
>> +  grub_arm64_linux_unregister_xen_boot_command ();
>>  }
> Not needed with separate module.
>> diff --git a/grub-core/loader/arm64/xen_boot.c 
>> b/grub-core/loader/arm64/xen_boot.c
>> new file mode 100644
>> index 000..23bd00e
>> --- /dev/null
>> +++ b/grub-core/loader/arm64/xen_boot.c
>> @@ -0,0 +1,615 @@
>> +/*
>> + *  GRUB  --  GRand Unified Bootloader
>> + *  Copyright (C) 2014  Free Software Foundation, Inc.
>> + *
>> + *  GRUB is free software: you can redistribute it and/or modify
>> + *  it under the terms of the GNU General Public License as published by
>> + *  the Free Software Foundation, either version 3 of the License, or
>> + *  (at your option) any later version.
>> + *
>> + *  GRUB is distributed in the hope that it will be useful,
>> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + *  GNU General Public License for more details.
>> + *
>> + *  You should have received a copy of the GNU General Public License
>> + *  along with GRUB.  If not, see .
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +static grub_dl_t linux_mod;
>> +static int *loaded;
>> +
>> +static struct xen_boot_binary *xen_hypervisor;
>> +static struct xen_boot_binary *module_head;
>> +static const grub_size_t module_default_align[] = {
>> +  MODULE_IMAGE_MIN_ALIGN,
>> +  MODULE_INITRD_MIN_ALIGN,
>> +  MODULE_OTHER_MIN_ALIGN,
>> +  MODULE_CUSTOM_MIN_ALIGN
>> +};
>> +
>> +static void *xen_boot_fdt;
>> +static const compat_string_struct_t default_compat_string[] = {
>> +  FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE),
>> +  FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE),
>> +  FDT_COMPATIBLE (MODULE_OTHER_COMPATIBLE)
>> +};
>> +
>> +
>> +/

Re: [Xen-devel] [PATCH v2 1/3] arm64: Add Xen boot support file

2015-07-16 Thread Ian Campbell
On Wed, 2015-07-15 at 18:18 +0200, Vladimir 'φ-coder/phcoder' Serbinenko
wrote:
> On 13.07.2015 10:53, fu@linaro.org wrote:
> > From: Fu Wei 
> > 
> > This patch adds Xen boot support file:
> > grub-core/loader/arm64/xen_boot.c
> > include/grub/arm64/xen_boot.h
> > 
> > This patch also adds commands register code and hearder file into
> > grub-core/loader/arm64/linux.c
> > 
> >   - This adds support for the Xen boot on ARM specification for arm64.
> >   - The implementation for Xen is following   > Specification>:
> >   
> > http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
> Please don't refer to this protocol as multiboot anywhere in grub or
> around because it's NOT multiboot and we don't want to confuse those 2
> protocols.

That's fair enough, my hope was that the docs and communal knowledge
about how to write a grub.cfg for Xen x86/multiboot could remain
unchanged for Xen on arm (e.g. by using the same multiboot1 command
names, which surely won't be reused on arm), but I can see why you would
object to that and updating 20_linux_xen to DTRT on both arches solves
the majority of that concern.

WRT to what to call it instead: I did try and design it[0] to not be Xen
specific, so it would be nice to avoid making it so in the command names
if possible. I suspect this may lead to a certain amount of
bikeshedding, if so we should just call it something Xen specific and
move on I think.

For a non-Xen specific name how about "fbm -- fdt boot module" protocol
and associated commands fbm_kernel + fbm_module?

Ian.

[0]
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 1/3] arm64: Add Xen boot support file

2015-07-15 Thread Vladimir 'φ-coder/phcoder' Serbinenko
On 13.07.2015 10:53, fu@linaro.org wrote:
> From: Fu Wei 
> 
> This patch adds Xen boot support file:
> grub-core/loader/arm64/xen_boot.c
> include/grub/arm64/xen_boot.h
> 
> This patch also adds commands register code and hearder file into
> grub-core/loader/arm64/linux.c
> 
>   - This adds support for the Xen boot on ARM specification for arm64.
>   - The implementation for Xen is following  :
>   
> http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
Please don't refer to this protocol as multiboot anywhere in grub or
around because it's NOT multiboot and we don't want to confuse those 2
protocols.
> and xen/docs/misc/arm/device-tree/booting.txt in Xen source code.
>   - The multiboot/module commands have existed,
> so we use xen_hypervisor/xen_module instead.
>   - This Xen boot support is built into linux module for aarch64.
>   - Adding this functionality to the existing "linux" module is for
> reusing the existing code of devicetree.
> 
Please create separate module. Modules are dynamically linked.
> Signed-off-by: Fu Wei 
> ---
>  grub-core/Makefile.core.def   |   1 +
>  grub-core/loader/arm64/linux.c|   6 +
>  grub-core/loader/arm64/xen_boot.c | 615 
> ++
>  include/grub/arm64/xen_boot.h | 115 +++
>  4 files changed, 737 insertions(+)
>  create mode 100644 grub-core/loader/arm64/xen_boot.c
>  create mode 100644 include/grub/arm64/xen_boot.h
> 
> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> index a6101de..01f8261 100644
> --- a/grub-core/Makefile.core.def
> +++ b/grub-core/Makefile.core.def
> @@ -1659,6 +1659,7 @@ module = {
>ia64_efi = loader/ia64/efi/linux.c;
>arm = loader/arm/linux.c;
>arm64 = loader/arm64/linux.c;
> +  arm64 = loader/arm64/xen_boot.c;
>fdt = lib/fdt.c;
>common = loader/linux.c;
>common = lib/cmdline.c;
> diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
> index 987f5b9..7ae9bde 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -26,6 +26,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -477,6 +478,9 @@ GRUB_MOD_INIT (linux)
>cmd_devicetree =
>  grub_register_command ("devicetree", grub_cmd_devicetree, 0,
>  N_("Load DTB file."));
> +
> +  grub_arm64_linux_register_xen_boot_command (mod, &loaded);
> +
>my_mod = mod;
>  }
>  
> @@ -485,4 +489,6 @@ GRUB_MOD_FINI (linux)
>grub_unregister_command (cmd_linux);
>grub_unregister_command (cmd_initrd);
>grub_unregister_command (cmd_devicetree);
> +
> +  grub_arm64_linux_unregister_xen_boot_command ();
>  }
Not needed with separate module.
> diff --git a/grub-core/loader/arm64/xen_boot.c 
> b/grub-core/loader/arm64/xen_boot.c
> new file mode 100644
> index 000..23bd00e
> --- /dev/null
> +++ b/grub-core/loader/arm64/xen_boot.c
> @@ -0,0 +1,615 @@
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2014  Free Software Foundation, Inc.
> + *
> + *  GRUB is free software: you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation, either version 3 of the License, or
> + *  (at your option) any later version.
> + *
> + *  GRUB is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with GRUB.  If not, see .
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static grub_dl_t linux_mod;
> +static int *loaded;
> +
> +static struct xen_boot_binary *xen_hypervisor;
> +static struct xen_boot_binary *module_head;
> +static const grub_size_t module_default_align[] = {
> +  MODULE_IMAGE_MIN_ALIGN,
> +  MODULE_INITRD_MIN_ALIGN,
> +  MODULE_OTHER_MIN_ALIGN,
> +  MODULE_CUSTOM_MIN_ALIGN
> +};
> +
> +static void *xen_boot_fdt;
> +static const compat_string_struct_t default_compat_string[] = {
> +  FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE),
> +  FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE),
> +  FDT_COMPATIBLE (MODULE_OTHER_COMPATIBLE)
> +};
> +
> +
> +/* Parse all the options of xen_module command. For now, we support
> +   (1) --type 
> +   (2) --nounzip
> +   We also set up the type of module in this function.
> +   If there are some "--type" options in the command line,
> +   we make a custom compatible stream in this function. */
> +static grub_err_t
> +set_module_type (struct xen_boot_binary *module, int argc, char *argv[],
> + 

[Xen-devel] [PATCH v2 1/3] arm64: Add Xen boot support file

2015-07-13 Thread fu . wei
From: Fu Wei 

This patch adds Xen boot support file:
grub-core/loader/arm64/xen_boot.c
include/grub/arm64/xen_boot.h

This patch also adds commands register code and hearder file into
grub-core/loader/arm64/linux.c

  - This adds support for the Xen boot on ARM specification for arm64.
  - The implementation for Xen is following  :
  http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot
and xen/docs/misc/arm/device-tree/booting.txt in Xen source code.
  - The multiboot/module commands have existed,
so we use xen_hypervisor/xen_module instead.
  - This Xen boot support is built into linux module for aarch64.
  - Adding this functionality to the existing "linux" module is for
reusing the existing code of devicetree.

Signed-off-by: Fu Wei 
---
 grub-core/Makefile.core.def   |   1 +
 grub-core/loader/arm64/linux.c|   6 +
 grub-core/loader/arm64/xen_boot.c | 615 ++
 include/grub/arm64/xen_boot.h | 115 +++
 4 files changed, 737 insertions(+)
 create mode 100644 grub-core/loader/arm64/xen_boot.c
 create mode 100644 include/grub/arm64/xen_boot.h

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index a6101de..01f8261 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1659,6 +1659,7 @@ module = {
   ia64_efi = loader/ia64/efi/linux.c;
   arm = loader/arm/linux.c;
   arm64 = loader/arm64/linux.c;
+  arm64 = loader/arm64/xen_boot.c;
   fdt = lib/fdt.c;
   common = loader/linux.c;
   common = lib/cmdline.c;
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 987f5b9..7ae9bde 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -477,6 +478,9 @@ GRUB_MOD_INIT (linux)
   cmd_devicetree =
 grub_register_command ("devicetree", grub_cmd_devicetree, 0,
   N_("Load DTB file."));
+
+  grub_arm64_linux_register_xen_boot_command (mod, &loaded);
+
   my_mod = mod;
 }
 
@@ -485,4 +489,6 @@ GRUB_MOD_FINI (linux)
   grub_unregister_command (cmd_linux);
   grub_unregister_command (cmd_initrd);
   grub_unregister_command (cmd_devicetree);
+
+  grub_arm64_linux_unregister_xen_boot_command ();
 }
diff --git a/grub-core/loader/arm64/xen_boot.c 
b/grub-core/loader/arm64/xen_boot.c
new file mode 100644
index 000..23bd00e
--- /dev/null
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -0,0 +1,615 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2014  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static grub_dl_t linux_mod;
+static int *loaded;
+
+static struct xen_boot_binary *xen_hypervisor;
+static struct xen_boot_binary *module_head;
+static const grub_size_t module_default_align[] = {
+  MODULE_IMAGE_MIN_ALIGN,
+  MODULE_INITRD_MIN_ALIGN,
+  MODULE_OTHER_MIN_ALIGN,
+  MODULE_CUSTOM_MIN_ALIGN
+};
+
+static void *xen_boot_fdt;
+static const compat_string_struct_t default_compat_string[] = {
+  FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE),
+  FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE),
+  FDT_COMPATIBLE (MODULE_OTHER_COMPATIBLE)
+};
+
+
+/* Parse all the options of xen_module command. For now, we support
+   (1) --type 
+   (2) --nounzip
+   We also set up the type of module in this function.
+   If there are some "--type" options in the command line,
+   we make a custom compatible stream in this function. */
+static grub_err_t
+set_module_type (struct xen_boot_binary *module, int argc, char *argv[],
+int *file_name_index)
+{
+  char **compat_string_temp_array =
+(char **) grub_zalloc (sizeof (char *) * argc);
+  static module_type_t default_type = MODULE_IMAGE;
+  grub_size_t total_size = 0;
+  int num_types = 0, i;
+  char *temp = NULL;
+
+  *file_name_index = 0;
+
+  /* if there are some options we need to process. */
+  while (argc > 1 && !grub_strncmp (argv[0], "--", 2))
+{
+  if (!grub_strcmp (argv[0], "--type"))
+   {
+ module->node_info.type = MODULE_CUSTOM;
+ ARG_SHIFT (argc, argv);
+ total_size += grub_strlen (argv[0]) +