From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZvshY-0002mA-I5 for mharc-grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvshW-0002iG-3a for grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvshU-0002MK-V5 for grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:02 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:37134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvshU-0002M3-Mx for grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:00 -0500 Received: by wmww144 with SMTP id w144so47734708wmw.0 for ; Mon, 09 Nov 2015 12:06:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:to:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=zFDo4F6vKSMiBerp/0RvK7Tg//cXwL9gwrtqhSQhIHk=; b=Smq3bQyPoEyhhyWZVBIUt1ErqgIs3lb1zetmpoKdqfyw3gfvppePdO5N+2H04jr1Dx JvVa602kdgFEY+PcPrvB7yn3CyRyk2tMFVZE8zzRsBCaA5tWlKF3EP3naLHh2+ICb0HA wxEh8oNoVDuRLr3kqkCQMBr1M4y7qD/ux7ssPwwycPwHF5wfY8MAtC/fyd6Or37+53fU ckBnRaLhGhFRLQmLHb+rhcYBZ0IB7fIDoKZU44t+HcIRKXRn83Ef2tUrjA2MUXcAgBvA rLpBB38vAmPmk/SZ/zjTAxBnX82BuyIlLw2WbCY7LjvXhthkLUdeoYy3eITlcvXI1CMd o0xQ== X-Received: by 10.194.78.15 with SMTP id x15mr35632548wjw.144.1447099560108; Mon, 09 Nov 2015 12:06:00 -0800 (PST) Received: from ?IPv6:2a02:1205:34c8:dc00:863a:4bff:fe50:abc4? ([2a02:1205:34c8:dc00:863a:4bff:fe50:abc4]) by smtp.gmail.com with ESMTPSA id l1sm18604304wmb.1.2015.11.09.12.05.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 12:05:59 -0800 (PST) Subject: Fwd: Re: [PATCH v2 6/6] multiboot2: Do not pass memory maps to image if EFI boot services are enabled References: To: The development of GRUB 2 From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= X-Forwarded-Message-Id: Message-ID: <5640FCA6.5070105@gmail.com> Date: Mon, 9 Nov 2015 21:05:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5NRO1RH10iUUnl8iGoV1EUI3EMURIcU6I" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::232 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: Mon, 09 Nov 2015 20:06:03 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5NRO1RH10iUUnl8iGoV1EUI3EMURIcU6I Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable -------- Forwarded Message -------- Subject: Re: [PATCH v2 6/6] multiboot2: Do not pass memory maps to image if EFI boot services are enabled Date: Mon, 9 Nov 2015 20:07:23 +0100 From: Vladimir 'phcoder' Serbinenko To: Daniel Kiper This one is good to go. But the main reason for not providing the map is because it will likely be invalid. We do few allocations after filling the map I.a. git relocator. Usually we don't care as we would already finish boot services but if we keep them, it's easier not to provide them, at least until somebody needs then. Please adjust the description and add or to the comment Le 20 juil. 2015 4:37 PM, "Daniel Kiper" > a =C3=A9crit : Do not pass memory maps to image if it asked for EFI boot services. Maps are usually invalid in that case and they can confuse potential user. Image should get memory map itself just before ExitBootServices() call. Signed-off-by: Daniel Kiper > --- grub-core/loader/multiboot_mbi2.c | 71 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 7ac64ec..26e955c 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -431,7 +431,7 @@ static grub_size_t grub_multiboot_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI - if (!efi_mmap_size) + if (!keep_bs && !efi_mmap_size) find_efi_mmap_size (); #endif return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) @@ -805,12 +805,13 @@ grub_multiboot_make_mbi (grub_uint32_t *target)= } } - { - struct multiboot_tag_mmap *tag =3D (struct multiboot_tag_mmap *)= ptrorig; - grub_fill_multiboot_mmap (tag); - ptrorig +=3D ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); - } + if (!keep_bs) + { + struct multiboot_tag_mmap *tag =3D (struct multiboot_tag_mmap *) ptrorig; + grub_fill_multiboot_mmap (tag); + ptrorig +=3D ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } { struct multiboot_tag_elf_sections *tag @@ -826,18 +827,19 @@ grub_multiboot_make_mbi (grub_uint32_t *target)= / sizeof (grub_properly_aligned_t); } - { - struct multiboot_tag_basic_meminfo *tag - =3D (struct multiboot_tag_basic_meminfo *) ptrorig; - tag->type =3D MULTIBOOT_TAG_TYPE_BASIC_MEMINFO; - tag->size =3D sizeof (struct multiboot_tag_basic_meminfo); + if (!keep_bs) + { + struct multiboot_tag_basic_meminfo *tag + =3D (struct multiboot_tag_basic_meminfo *) ptrorig; + tag->type =3D MULTIBOOT_TAG_TYPE_BASIC_MEMINFO; + tag->size =3D sizeof (struct multiboot_tag_basic_meminfo); - /* Convert from bytes to kilobytes. */ - tag->mem_lower =3D grub_mmap_get_lower () / 1024; - tag->mem_upper =3D grub_mmap_get_upper () / 1024; - ptrorig +=3D ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); - } + /* Convert from bytes to kilobytes. */ + tag->mem_lower =3D grub_mmap_get_lower () / 1024; + tag->mem_upper =3D grub_mmap_get_upper () / 1024; + ptrorig +=3D ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } { struct grub_net_network_level_interface *net; @@ -936,27 +938,24 @@ grub_multiboot_make_mbi (grub_uint32_t *target)= grub_efi_uintn_t efi_desc_size; grub_efi_uint32_t efi_desc_version; - tag->type =3D MULTIBOOT_TAG_TYPE_EFI_MMAP; - tag->size =3D sizeof (*tag) + efi_mmap_size; - if (!keep_bs) - err =3D grub_efi_finish_boot_services (&efi_mmap_size, tag->efi_mmap, NULL, - &efi_desc_size, &efi_desc_version); - else { - if (grub_efi_get_memory_map (&efi_mmap_size, (void *) tag->efi_mmap, - NULL, - &efi_desc_size, &efi_desc_version) <=3D 0) - err =3D grub_error (GRUB_ERR_IO, "couldn't retrieve memory map"); + tag->type =3D MULTIBOOT_TAG_TYPE_EFI_MMAP; + tag->size =3D sizeof (*tag) + efi_mmap_size; + + err =3D grub_efi_finish_boot_services (&efi_mmap_size, tag->efi_mmap, NULL, + &efi_desc_size, &efi_desc_version); + + if (err) + return err; + + tag->descr_size =3D efi_desc_size; + tag->descr_vers =3D efi_desc_version; + tag->size =3D sizeof (*tag) + efi_mmap_size; + + ptrorig +=3D ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); } - if (err) - return err; - tag->descr_size =3D efi_desc_size; - tag->descr_vers =3D efi_desc_version; - tag->size =3D sizeof (*tag) + efi_mmap_size; - - ptrorig +=3D ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); } if (keep_bs) -- 1.7.10.4 --5NRO1RH10iUUnl8iGoV1EUI3EMURIcU6I 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 iF4EAREKAAYFAlZA/KYACgkQmBXlbbo5nOtvvQD/ZGqUG1UR0xZJByyPYLqJ1+jb x7AVMF6l1kUwfyyK5CMA/0DOycfWmsNX01oU35O3Uc8mPc9Ir0XY7UPY1MU2XOKd =gpVZ -----END PGP SIGNATURE----- --5NRO1RH10iUUnl8iGoV1EUI3EMURIcU6I--