From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zvshj-0003A8-IU for mharc-grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvshg-00033i-DB for grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvshf-0002Qb-5y for grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:12 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:34409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvshe-0002QL-UP for grub-devel@gnu.org; Mon, 09 Nov 2015 15:06:11 -0500 Received: by wmnn186 with SMTP id n186so124013324wmn.1 for ; Mon, 09 Nov 2015 12:06:10 -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=B8ZURhRj/SIcBx7CdpRiCrKtBp7M1jWW9Ap1vb/yHPQ=; b=DDEFJAijcR3gIG18QaI8iEcAWjDScy7X/kGGQwMay3ShAkhXVOovVKRwQ5LFaU9dPp NKIgBxuOUfcDDG7imt1FAUCG+1L8J58Hh8XDhpN25jeno8fQA0xF4s3NP/GQNmG+l/0Q 01ttlpHYwivihggy8VZt03Pb48N3/MQxEX1O9zCH67zhzSXoXBowNeBu4MA1Cug2K9Ew D6P9+C42snhxqXTHeVsbK8s5aRIBybgu5fKKHKSWEp0AxetoLlyV8Nzlrjr6mh+byBYZ FsF7gqmwCLY80fZ/0Zy4hHqErzLfpQjfeFzzhRnhNZjFKvYZBw7HQdCc5EWOtGOov0+i aXkQ== X-Received: by 10.28.19.65 with SMTP id 62mr28474216wmt.6.1447099570281; Mon, 09 Nov 2015 12:06:10 -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 l78sm16002061wmb.5.2015.11.09.12.06.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 12:06:09 -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: <5640FCB0.7050309@gmail.com> Date: Mon, 9 Nov 2015 21:06:08 +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="5xFcfFdxnop9WIQKcCDURkKVBRtuXejs8" 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: Mon, 09 Nov 2015 20:06:14 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5xFcfFdxnop9WIQKcCDURkKVBRtuXejs8 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:08:38 +0100 From: Vladimir 'phcoder' Serbinenko To: Daniel Kiper And you also need to adjust loader code to reject images which request memory tags and bs at the same time Le 9 nov. 2015 8:07 PM, "Vladimir 'phcoder' Serbinenko" > a =C3=A9crit : 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_t= ag) @@ -805,12 +805,13 @@ grub_multiboot_make_mbi (grub_uint32_t *target) } } - { - struct multiboot_tag_mmap *tag =3D (struct multiboot_tag_mma= p *) 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 --5xFcfFdxnop9WIQKcCDURkKVBRtuXejs8 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/LEACgkQmBXlbbo5nOsNOgEAold6hXwBAO2k+SAgVT60q6yo 0s2dmWu4bedUi+oUOw0A/0Mq3OXLPFI+lqVz9376/SRchMVwnvqlrZTOXVW6BfZd =6I8n -----END PGP SIGNATURE----- --5xFcfFdxnop9WIQKcCDURkKVBRtuXejs8--