From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aUGa0-00048X-7J for mharc-grub-devel@gnu.org; Fri, 12 Feb 2016 11:28:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUGZx-00046r-14 for grub-devel@gnu.org; Fri, 12 Feb 2016 11:28:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUGZv-0001Va-Fk for grub-devel@gnu.org; Fri, 12 Feb 2016 11:28:20 -0500 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:37540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUGZv-0001VI-2b for grub-devel@gnu.org; Fri, 12 Feb 2016 11:28:19 -0500 Received: by mail-wm0-x235.google.com with SMTP id g62so26461899wme.0 for ; Fri, 12 Feb 2016 08:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=y2Tgap1+Gsy7poxOQMeZcY/0jexsSQol0UmHzdw46KM=; b=0AjDFSmDFeODpYovlyzjByD/1dIC2qRjWmjHMsOyI25d0XHF87998OfEE/AmKvYIVh jlnKRG+F6SYjAghY0NDqQUL6r4rrN2+WKJyEnH8/rVL4zJYqCWZKWa4sBqfOxiqFxuJc FeEOXEhpjKU6lxJjOYylpy+aLGMyaoMizCXKytIPtAVro1OSxhOjt8AQALmidIRDx7EM +/GJP3bcng8TWJ47YmvCRV/2pVmBCUqfiOE/qt1nB5FJkrFLWX6HwKdi+tW9TUk5gZNg yZXbBUKyKlDDBToNUYOkWbPjUzpRlWzWN+veRB3mGRJBW6GiZrVzSGxj34dcE2c5+tGv MT9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type; bh=y2Tgap1+Gsy7poxOQMeZcY/0jexsSQol0UmHzdw46KM=; b=W430qkEq+3YskTGfqe2hw2ZrHTpnNf5KNT3YxoCgjIzALv547GGO1Rdoh0Ghf8WNwV erkBCfT01QBmGC15qK2IX/+y4oPlL8H1xCfKvk97/9hfJdFJhzgFUbKjoqozmN5d714U qoNoWihGXrDhKDUgogQpJQrbfzj9Qcrv6jL9vDWz0WfR22OGinud0yNk3oK2O/QvhEJ2 zhjI2Ob6wrJieRfn4SpefJTP3Ea4G8+ulL7saG4MMcE/8J6+CSnlSzb+tRvXHn1KdT3g ILVTetpPYp36PzlDBVvWh0Vp0oup5x6bA85PzPPOuWCCgByxiRaECxVyAPiTm0V8XT77 cCpw== X-Gm-Message-State: AG10YOQcyD3Ip9MrozCdrg5sk/sGSvcCP3izxJxZAW1MPGD1zjtXfK69T1VFe6rSYkzSwA== X-Received: by 10.28.215.16 with SMTP id o16mr442252wmg.57.1455294498370; Fri, 12 Feb 2016 08:28:18 -0800 (PST) Received: from ?IPv6:2620:0:105f:fd00:a2a8:cdff:fe64:b3b5? ([2620:0:105f:fd00:a2a8:cdff:fe64:b3b5]) by smtp.gmail.com with ESMTPSA id cb2sm12790118wjc.16.2016.02.12.08.28.16 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Feb 2016 08:28:16 -0800 (PST) Subject: Re: [PATCH] grub-install: Include all decompressor modules in pvxen core image. To: The development of GNU GRUB References: <1417163614-22703-1-git-send-email-ijc@hellion.org.uk> <20141128200952.31d2c6be@opensuse.site> <1417195555.23604.69.camel@hellion.org.uk> <20141130143101.0bb4298e@opensuse.site> <1417348279.2372.20.camel@hellion.org.uk> <1417354463.2372.27.camel@hellion.org.uk> <54848BF7.5030907@gmail.com> <20141207202608.0add92f0@opensuse.site> From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= Message-ID: <56BE0814.7060403@gmail.com> Date: Fri, 12 Feb 2016 17:28:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 MIME-Version: 1.0 In-Reply-To: <20141207202608.0add92f0@opensuse.site> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="QQ2sLRrx6dL0gkO5eXHuicOM3ibAbHVu9" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::235 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: Fri, 12 Feb 2016 16:28:22 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QQ2sLRrx6dL0gkO5eXHuicOM3ibAbHVu9 Content-Type: multipart/mixed; boundary="------------020808010505070506080506" This is a multi-part message in MIME format. --------------020808010505070506080506 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07.12.2014 18:26, Andrei Borzenkov wrote: > =D0=92 Sun, 07 Dec 2014 18:18:47 +0100 > Vladimir '=CF=86-coder/phcoder' Serbinenko =D0=BF=D0= =B8=D1=88=D0=B5=D1=82: >=20 >> On 30.11.2014 14:34, Ian Campbell wrote: >>> On Sun, 2014-11-30 at 11:51 +0000, Ian Campbell wrote: >>>> On Sun, 2014-11-30 at 14:31 +0300, Andrei Borzenkov wrote: >>>>> if [ x$grub_platform =3D xxen ]; then >>>>> insmod xzio >>>>> fi >>>> >>>> I think that could work. >>> >>> Indeed it does, so how about this instead of the patch at the start o= f >>> the thread? >>> >> This should probably have been autoloaded. >=20 > File filters are not autoloaded and I do not see how it can really be > done. OTOH unconditionally loading them may have unwanted side effect > where we assumed files were not decompressed. >=20 > In this specific case extending grub-file to detect compression type > used by kernel is probably OK. Please test attached file. >=20 >> Can you send me privately a= >> kernel you use, so I can reproduce your tests? >>> >From f4199776eca80dfad4e9378a01ddb5866face3d7 Mon Sep 17 00:00:00 20= 01 >>> From: Ian Campbell >>> Date: Sun, 30 Nov 2014 12:12:52 +0000 >>> Subject: [PATCH] Arrange to insmod xzio when booting a kernel as a Xe= n guest >>> >>> This is needed in case the Linux kernel is compiled with CONFIG_KERNE= L_XZ >>> rather than CONFIG_KERNEL_GZ (gzio is already loaded by grub.cfg). >>> >>> Signed-off-by: Ian Campbell >>> >>> Patch-Name: insmod-xzio-on-xen.patch >>> --- >>> util/grub.d/10_linux.in | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in >>> index 79fa03a..86e35f2 100644 >>> --- a/util/grub.d/10_linux.in >>> +++ b/util/grub.d/10_linux.in >>> @@ -150,6 +150,7 @@ linux_entry () >>> fi >>> =20 >>> echo " insmod gzio" | sed "s/^/$submenu_indentation/" >>> + echo " if [ x\$grub_platform =3D xxen ]; then insmod xzio; insmod = lzopio; fi" | sed "s/^/$submenu_indentation/" >>> =20 >>> if [ x$dirname =3D x/ ]; then >>> if [ -z "${prepare_root_cache}" ]; then >>> >> >> >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 --------------020808010505070506080506 Content-Type: text/x-diff; name="autoload.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="autoload.diff" diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen= _file.c index 5836218..90e0a6e 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -20,12 +20,99 @@ #include #include =20 +#define LZOP_MAGIC "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a" +#define LZOP_MAGIC_SIZE 9 +#define XZ_MAGIC "\3757zXZ\0" +#define XZ_MAGIC_SIZE 6 +#define ELF_MAGIC "\177ELF" +#define ELF_MAGIC_SIZE 4 +#define GZ_MAGIC "\x1F\x8B" +#define GZ_MAGIC_SIZE 2 +#define GZ_OLD_MAGIC "\x1F\x9E" +#define GZ_OLD_MAGIC_SIZE 2 + +#ifndef GRUB_UTIL + +#include + +static grub_uint8_t +mod_31 (grub_uint16_t v) +{ + /* At most 2 iterations for any number that + we can get here. + In any case faster than real division. */ + while (v > 0x1f) + v =3D (v & 0x1f) + (v >> 5); + if (v =3D=3D 0x1f) + return 0; + return v; +} + +static int +is_zlib (grub_uint8_t *head) +{ + grub_uint8_t cmf, flg; +=20 + cmf =3D head[0]; + flg =3D head[1]; + + if ((cmf & 0xf) !=3D 8) + return 0; + + if (mod_31 (cmf + flg * 4) !=3D 0) + return 0; + + if (flg & 0x20) + return 0; + =20 + return 1; +} + +static void +autoload_filters (grub_file_t file, grub_uint32_t payload_offset) +{ + grub_uint8_t payload_header[LZOP_MAGIC_SIZE]; + + grub_file_seek (file, payload_offset); + + if (grub_file_read (file, &payload_header, sizeof (payload_header)) !=3D= sizeof (payload_header)) + { + grub_print_error (); + return; + } + + if (grub_memcmp (payload_header, ELF_MAGIC, ELF_MAGIC_SIZE) =3D=3D 0) + { + /* Uncompressed. */ + } + else if (grub_memcmp (payload_header, XZ_MAGIC, XZ_MAGIC_SIZE) =3D=3D = 0) + { + grub_dl_load("xzio"); + grub_print_error (); + } + else if (grub_memcmp (payload_header, LZOP_MAGIC, LZOP_MAGIC_SIZE) =3D= =3D 0) + { + grub_dl_load("lzopio"); + grub_print_error (); + } + else if (grub_memcmp (payload_header, GZ_MAGIC, GZ_MAGIC_SIZE) =3D=3D = 0 + || grub_memcmp (payload_header, GZ_OLD_MAGIC, GZ_OLD_MAGIC_SIZE) =3D= =3D 0 + || is_zlib (payload_header)) + { + grub_dl_load("gzio"); + grub_print_error (); + } +} + +#endif + grub_elf_t grub_xen_file (grub_file_t file) { grub_elf_t elf; struct linux_kernel_header lh; grub_file_t off_file; + grub_uint32_t payload_offset; =20 elf =3D grub_elf_file (file, file->name); if (elf) @@ -46,19 +133,24 @@ grub_xen_file (grub_file_t file) return NULL; } =20 - if (lh.payload_length < 4) + if (lh.payload_length < LZOP_MAGIC_SIZE) { grub_error (GRUB_ERR_BAD_OS, "payload too short"); return NULL; } =20 + payload_offset =3D (lh.setup_sects + 1) * 512 + lh.payload_offset; + +#ifndef GRUB_UTIL + autoload_filters (file, payload_offset); +#endif + grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n", (unsigned long long) (lh.setup_sects + 1) * 512 + lh.payload_offset, (unsigned long long) lh.payload_length - 4); =20 - off_file =3D grub_file_offset_open (file, (lh.setup_sects + 1) * 512 - + lh.payload_offset, + off_file =3D grub_file_offset_open (file, payload_offset, lh.payload_length - 4); if (!off_file) goto fail; --------------020808010505070506080506-- --QQ2sLRrx6dL0gkO5eXHuicOM3ibAbHVu9 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 iF4EAREKAAYFAla+CBUACgkQmBXlbbo5nOuC7gD+LTmQY1XH8N/H0ddNTyVZ372y TbF7q1YMNaadoTppTvgA/iIv3+VcIp8AqPJzxvKghCR/RBSEAW93JnRBU9ZO+xsZ =UeO5 -----END PGP SIGNATURE----- --QQ2sLRrx6dL0gkO5eXHuicOM3ibAbHVu9--