From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZwrcF-0004S8-F4 for mharc-grub-devel@gnu.org; Thu, 12 Nov 2015 08:08:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwrcB-0004Rk-Ql for grub-devel@gnu.org; Thu, 12 Nov 2015 08:08:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwrcA-0003NY-52 for grub-devel@gnu.org; Thu, 12 Nov 2015 08:08:35 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:38477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zwrc9-0003ND-So for grub-devel@gnu.org; Thu, 12 Nov 2015 08:08:34 -0500 Received: by wmec201 with SMTP id c201so90562226wme.1 for ; Thu, 12 Nov 2015 05:08:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-type; bh=bChCgQ47jwGklb4xSz2yHILrXFuncMPe05sXKQaw3eg=; b=nHUC+oXR6TKovG88AWlX7TuLl9Jk0+cAkYGhtZWdSd3Jp4zkR9CCLPMugJ8jkIKMpq 2gKgGUs+o+WxaJWp2nUS1oymtTnDNBoAy4lhuBDzHZldY+sNSdRgdu1S1xW2snv8jkCH dFSBOD3v2h7b7a7vDJNuzv/830sHe+8hPV8HZ7l0Ryl9ZKyqfR85mQFp+biMndRMuijY aK2tGoWRYvTYg9iSHuo/IaNy6L9eFtaR4s1jsKyssTpXHbIAs3v/Eas63r6G925RrVxT OqCGKkmRChHEmEuwaFojJgXCOe3r9pawH7dBo/n5R5p7gALYsv1qC5yYTjLU0jxDdZ7u Bvyw== X-Received: by 10.28.213.212 with SMTP id m203mr44420627wmg.33.1447333713116; Thu, 12 Nov 2015 05:08:33 -0800 (PST) Received: from ?IPv6:2620:0:105f:fd00:863a:4bff:fe50:abc4? ([2620:0:105f:fd00:863a:4bff:fe50:abc4]) by smtp.gmail.com with ESMTPSA id s9sm11200023wmf.2.2015.11.12.05.08.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2015 05:08:31 -0800 (PST) To: The development of GRUB 2 , Fu Wei , "xen-devel@lists.xen.org" From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= Subject: [PATCH GRUB] Allow initrd concatenation on ARM64 Message-ID: <56448F4A.2090609@gmail.com> Date: Thu, 12 Nov 2015 14:08:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.3.0 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="d0LeBgtLbFfC2dTjjrUeNv6LFhVebX7lm" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::234 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2015 13:08:37 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --d0LeBgtLbFfC2dTjjrUeNv6LFhVebX7lm Content-Type: multipart/mixed; boundary="------------010700000302070905030909" This is a multi-part message in MIME format. --------------010700000302070905030909 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable While on it also change "xen_linux" to "xen_kernel" to be vendor-neutral Could someone test please? I only compile-tested it --------------010700000302070905030909 Content-Type: text/x-diff; name="initrd.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="initrd.diff" diff --git a/docs/grub.texi b/docs/grub.texi index 1df3db2..112b42b 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3859,7 +3859,7 @@ you forget a command, you can run the command @comm= and{help} * videoinfo:: List available video modes @comment * xen_*:: Xen boot commands * xen_hypervisor:: Load xen hypervisor binary -* xen_linux:: Load dom0 kernel for xen hypervisor +* xen_kernel:: Load dom0 kernel for xen hypervisor * xen_initrd:: Load dom0 initrd for dom0 kernel * xen_xsm:: Load xen security module for xen hypervi= sor @end menu @@ -5134,10 +5134,10 @@ verbatim as the @dfn{kernel command-line}. Any ot= her binaries must be reloaded after using this command. @end deffn =20 -@node xen_linux -@subsection xen_linux +@node xen_kernel +@subsection xen_kernel =20 -@deffn Command xen_linux file [arguments] +@deffn Command xen_kernel file [arguments] Load a dom0 kernel image for xen hypervisor at the booting process of xe= n. The rest of the line is passed verbatim as the module command line. @end deffn diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index d9fa0e3..34f7b61 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1641,6 +1642,7 @@ module =3D { module =3D { name =3D xen_boot; common =3D lib/cmdline.c; + common =3D loader/linux.c; arm64 =3D loader/arm64/xen_boot.c; enable =3D arm64; }; diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/x= en_boot.c index d1a2189..e4a12bc 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -33,6 +33,7 @@ #include /* required by struct xen_hypervisor_header *= / #include #include +#include =20 GRUB_MOD_LICENSE ("GPLv3+"); =20 @@ -137,17 +138,53 @@ xen_boot_address_align (grub_addr_t start, grub_siz= e_t align) } =20 /* set module type according to command name. */ -static grub_err_t -set_module_type (grub_command_t cmd, struct xen_boot_binary *module) +static struct xen_boot_binary * +allocate_module (module_type_t type) { - if (!grub_strcmp (cmd->name, "xen_linux")) - module->node_info.type =3D MODULE_IMAGE; - else if (!grub_strcmp (cmd->name, "xen_initrd")) - module->node_info.type =3D MODULE_INITRD; - else if (!grub_strcmp (cmd->name, "xen_xsm")) - module->node_info.type =3D MODULE_XSM; + struct xen_boot_binary *module; =20 - return GRUB_ERR_NONE; + if (!loaded) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the Xen Hypervisor first")); + return NULL; + } + + module =3D + (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_bina= ry)); + if (!module) + return NULL; + + module->node_info.type =3D type; + + switch (module->node_info.type) + { + case MODULE_IMAGE: + case MODULE_INITRD: + case MODULE_XSM: + module->node_info.compat_string =3D + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size =3D + default_compat_string[module->node_info.type].size; + break; + + case MODULE_CUSTOM: + /* we have set the node_info in set_module_type */ + break; + + default: + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); + return NULL; + } + module->name =3D module->node_info.compat_string; + module->align =3D module_default_align[module->node_info.type]; + + grub_dprintf ("xen_loader", "Init %s module and node info:\n" + "compatible %s\ncompat_string_size 0x%lx\n", + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + return module; } =20 static grub_err_t @@ -372,11 +409,11 @@ xen_unload (void) return GRUB_ERR_NONE; } =20 -static void -xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, - int argc, char *argv[]) +static grub_err_t +xen_boot_binary_allocate (struct xen_boot_binary *binary, + grub_size_t size) { - binary->size =3D grub_file_size (file); + binary->size =3D size; grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n", binary->name, binary->size); =20 @@ -386,13 +423,21 @@ xen_boot_binary_load (struct xen_boot_binary *binar= y, grub_file_t file, (binary->size + binary->align)); if (!binary->start) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); - return; - } + return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); =20 grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n", binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align));= + return GRUB_ERR_NONE; +} + +static void +xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, + int argc, char *argv[]) +{ + if (xen_boot_binary_allocate(binary, grub_file_size(file))) + { + return; + } =20 if (grub_file_read (file, (void *) xen_boot_address_align (binary->sta= rt, binary->align), @@ -432,9 +477,9 @@ xen_boot_binary_load (struct xen_boot_binary *binary,= grub_file_t file, static grub_err_t grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) { - struct xen_boot_binary *module =3D NULL; grub_file_t file =3D 0; + module_type_t type =3D MODULE_IMAGE; =20 if (!argc) { @@ -442,46 +487,15 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, = char *argv[]) goto fail; } =20 - if (!loaded) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, - N_("you need to load the Xen Hypervisor first")); - goto fail; - } - - module =3D - (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_bina= ry)); - if (!module) - return grub_errno; + if (grub_strcmp (cmd->name, "xen_kernel") =3D=3D 0) + type =3D MODULE_IMAGE; + else if (grub_strcmp (cmd->name, "xen_xsm") =3D=3D 0) + type =3D MODULE_XSM; =20 + module =3D allocate_module (type); /* process all the options and get module type */ - if (set_module_type (cmd, module) !=3D GRUB_ERR_NONE) + if (!module) goto fail; - switch (module->node_info.type) - { - case MODULE_IMAGE: - case MODULE_INITRD: - case MODULE_XSM: - module->node_info.compat_string =3D - default_compat_string[module->node_info.type].compat_string; - module->node_info.compat_string_size =3D - default_compat_string[module->node_info.type].size; - break; - - case MODULE_CUSTOM: - /* we have set the node_info in set_module_type */ - break; - - default: - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));= - } - module->name =3D module->node_info.compat_string; - module->align =3D module_default_align[module->node_info.type]; - - grub_dprintf ("xen_loader", "Init %s module and node info:\n" - "compatible %s\ncompat_string_size 0x%lx\n", - module->name, module->node_info.compat_string, - module->node_info.compat_string_size); =20 file =3D grub_file_open (argv[0]); if (!file) @@ -501,6 +515,44 @@ fail: } =20 static grub_err_t +grub_cmd_xen_initrd (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + struct xen_boot_binary *module =3D NULL; + struct grub_linux_initrd_context initrd_ctx =3D { 0, 0, 0 }; + void *initrd_mem; + + if (!argc) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + goto fail; + } + + module =3D allocate_module (MODULE_INITRD); + /* process all the options and get module type */ + if (!module) + goto fail; + + if (xen_boot_binary_allocate (module, grub_get_initrd_size (&initrd_ct= x))) + goto fail; + + initrd_mem =3D (void *) xen_boot_address_align (module->start, + module->align); + + if (grub_initrd_load (&initrd_ctx, argv, initrd_mem)) + goto fail; + + grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module));= + +fail: + grub_initrd_close (&initrd_ctx); + if (grub_errno !=3D GRUB_ERR_NONE) + single_binary_unload (module); + + return grub_errno; +} + +static grub_err_t grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { @@ -559,18 +611,18 @@ fail: } =20 static grub_command_t cmd_xen_hypervisor; -static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; +static grub_command_t cmd_xen_kernel, cmd_xen_initrd, cmd_xen_xsm; =20 GRUB_MOD_INIT (xen_boot) { cmd_xen_hypervisor =3D grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0,= N_("Load a xen hypervisor.")); - cmd_xen_linux =3D - grub_register_command ("xen_linux", grub_cmd_xen_module, 0, + cmd_xen_kernel =3D + grub_register_command ("xen_kernel", grub_cmd_xen_module, 0, N_("Load a xen linux kernel for dom0.")); cmd_xen_initrd =3D - grub_register_command ("xen_initrd", grub_cmd_xen_module, 0, + grub_register_command ("xen_initrd", grub_cmd_xen_initrd, 0, N_("Load a xen initrd for dom0.")); cmd_xen_xsm =3D grub_register_command ("xen_xsm", grub_cmd_xen_module, 0, @@ -581,7 +633,7 @@ GRUB_MOD_INIT (xen_boot) GRUB_MOD_FINI (xen_boot) { grub_unregister_command (cmd_xen_hypervisor); - grub_unregister_command (cmd_xen_linux); + grub_unregister_command (cmd_xen_kernel); grub_unregister_command (cmd_xen_initrd); grub_unregister_command (cmd_xen_xsm); } --------------010700000302070905030909-- --d0LeBgtLbFfC2dTjjrUeNv6LFhVebX7lm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREKAAYFAlZEj08ACgkQmBXlbbo5nOtasAEAplBJx+njHvRcIpZQInBfD1tb uORqWSgITDUeOM9dK2sA+gLwSqpkA3Uij9jRKnJcDdymaEAq+1ulBnRJvkKrFYra =L7CK -----END PGP SIGNATURE----- --d0LeBgtLbFfC2dTjjrUeNv6LFhVebX7lm--