Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Wa217-0000Jz-U5 for mharc-grub-devel@gnu.org; Tue, 15 Apr 2014 07:59:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wa20w-0000IA-Um for grub-devel@gnu.org; Tue, 15 Apr 2014 07:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wa20n-0007Z7-QH for grub-devel@gnu.org; Tue, 15 Apr 2014 07:58:58 -0400 Received: from mail-we0-x22f.google.com ([2a00:1450:400c:c03::22f]:46216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wa20n-0007Ys-JE for grub-devel@gnu.org; Tue, 15 Apr 2014 07:58:49 -0400 Received: by mail-we0-f175.google.com with SMTP id q58so9193003wes.6 for ; Tue, 15 Apr 2014 04:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=adOQJ2omCAluAoL91DGcl5qwkg7hRPGFq25BRWqMf6o=; b=ch9rAqYav/Y+CGC+lqvRqwbmw9g7N4RhAYUTKHk16RZ0HOkXgasziK00gSRWHJpzbi 8HIsXWnYsvacOQSOTQWNZ1cdDEjgtn6Yl7Y94gF+pnejRs8ijmAODNuhConQ3xynyGz5 dWzM1U6IxGzmxlhv066s7wOn9lRDkozCzwdECEkjLHX+xFwY7qTFf79bKmsQB0WOLPP9 kHuxWzLRH5J3SWybt8Nd9D7JjLldamVEfhvkJNyrrniiERTi+iy064AUwagqy+EdpkV1 k0EG9FRamiXVz3fmPwF/T3TdONO/rbyfq7zLllUB4b/qFC5YJfCZT4ReNiIHNg7AuXZs RzOA== X-Received: by 10.180.188.134 with SMTP id ga6mr2167934wic.58.1397563128295; Tue, 15 Apr 2014 04:58:48 -0700 (PDT) Received: from localhost.localdomain ([89.101.39.53]) by mx.google.com with ESMTPSA id b1sm29421450wjb.37.2014.04.15.04.58.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Apr 2014 04:58:47 -0700 (PDT) From: Piotr Krysiuk To: grub-devel@gnu.org Subject: [PATCHv2] Unable to boot very old Linux kernels Date: Tue, 15 Apr 2014 12:58:40 +0100 Message-Id: <1397563120-3509-1-git-send-email-piotras@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22f Cc: Piotr Krysiuk 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: Tue, 15 Apr 2014 11:59:08 -0000 GRUB cannot determine end of BSS section of compressed image when loading very old Linux kernels. Booting these kernels, grub_relocator32_start and new Global Descriptor Table are placed in the area overlapping with the BSS section of loaded image. When Linux executes, it initializes BSS also wiping Global Descriptor Table that is still active. This leads to failure on segment reload that follows. Current HEAD of GRUB repository is affected, with "Clear BSS" code from https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/arch/x86_64/boot/compressed/head.S?h=linux-2.6.17.y#n57 wiping GDT. Old versions of GRUB, from before relocator was introduced, placed GDT close to end of physical memory avoiding this issue. This patch fixes regression by moving GDT into conventional memory. * grub-core/lib/i386/relocator.c: Move GDT into conventional memory to avoid collision with BSS section of compressed Linux image for very old kernels. --- grub-core/lib/i386/relocator.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c index d2a1b27..ffaf25f 100644 --- a/grub-core/lib/i386/relocator.c +++ b/grub-core/lib/i386/relocator.c @@ -81,10 +81,13 @@ grub_relocator32_boot (struct grub_relocator *rel, void *relst; grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_align (rel, &ch, 0, - (0xffffffff - RELOCATOR_SIZEOF (32)) - + 1, RELOCATOR_SIZEOF (32), 16, - GRUB_RELOCATOR_PREFERENCE_NONE, + /* Specific memory range due to Global Descriptor Table for use by payload + that we will store in returned chunk. The address range and preference + are based on "THE LINUX/x86 BOOT PROTOCOL" specification. */ + err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000, + 0x9a000 - RELOCATOR_SIZEOF (32), + RELOCATOR_SIZEOF (32), 16, + GRUB_RELOCATOR_PREFERENCE_LOW, avoid_efi_bootservices); if (err) return err; -- 1.7.9.5