rpms/grub/F-12 grub-0.97-relocatable-kernel-on-x86_64-uefi.patch, 1.1, 1.2

Peter Jones pjones at fedoraproject.org
Mon Oct 19 14:28:45 UTC 2009


Author: pjones

Update of /cvs/extras/rpms/grub/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13803

Modified Files:
	grub-0.97-relocatable-kernel-on-x86_64-uefi.patch 
Log Message:
Update relocatable kernel support to Fujitsu's newest patch.

This patch fixes the problem that UEFI boot fains on systems that
have the memory region starting at 1MB in use. 
The strategy is as follows:

- Loading temporarily vmlinuz image to the address which AllocatePages()
  function returned.
- After calling ExitBootServices() function, copy its reagion to the
  address which params->hdr.code32_start points to.

Signed-off-by: Taku Izumi <izumi.taku at jp.fujitsu.com>


grub-0.97-relocatable-kernel-on-x86_64-uefi.patch:
 efimm.c               |   39 +++++++++++++++++++++++++++++++++++++++
 grub/efi/efi.h        |    1 +
 x86_64/loader/linux.c |   18 +++++++++++++++++-
 3 files changed, 57 insertions(+), 1 deletion(-)

Index: grub-0.97-relocatable-kernel-on-x86_64-uefi.patch
===================================================================
RCS file: /cvs/extras/rpms/grub/F-12/grub-0.97-relocatable-kernel-on-x86_64-uefi.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- grub-0.97-relocatable-kernel-on-x86_64-uefi.patch	11 Aug 2009 15:29:50 -0000	1.1
+++ grub-0.97-relocatable-kernel-on-x86_64-uefi.patch	19 Oct 2009 14:28:44 -0000	1.2
@@ -1,22 +1,19 @@
-From 1ccd96dbe74f7dad8d57080c83b68de85f1fe466 Mon Sep 17 00:00:00 2001
-From: Peter Jones <pjones at redhat.com>
-Date: Tue, 11 Aug 2009 11:26:17 -0400
-Subject: [PATCH] Dynamically choose load address for bzimage on 64-bit UEFI.
 
-Instead of loading the kernel at one meg, dynamically load it at an
-address that UEFI tells us is actually available.  Based on a patch from
-Masahiro Matsuya <mmatsuya at redhat.com>.
----
- efi/efimm.c               |   39 +++++++++++++++++++++++++++++++++++++++
- efi/grub/efi/efi.h        |    1 +
- efi/grub/x86_64/linux.h   |    1 -
- efi/x86_64/loader/linux.c |   13 ++++++++++++-
- 4 files changed, 52 insertions(+), 2 deletions(-)
+This patch fixes the problem that UEFI boot fains on systems that
+have the memory region starting at 1MB in use. 
+The strategy is as follows:
+
+ - Loading temporarily vmlinuz image to the address which AllocatePages()
+   function returned.
+ - After calling ExitBootServices() function, copy its reagion to the
+   address which params->hdr.code32_start points to.
 
-diff --git a/efi/efimm.c b/efi/efimm.c
-index d14b630..3b790d5 100644
---- a/efi/efimm.c
-+++ b/efi/efimm.c
+Signed-off-by: Taku Izumi <izumi.taku at jp.fujitsu.com>
+---
+Index: grub-0.97/efi/efimm.c
+===================================================================
+--- grub-0.97.orig/efi/efimm.c
++++ grub-0.97/efi/efimm.c
 @@ -78,6 +78,45 @@ grub_efi_free_pool (void *buffer)
    Call_Service_1(b->free_pool, buffer);
  }
@@ -63,11 +60,11 @@ index d14b630..3b790d5 100644
  /* Allocate pages. Return the pointer to the first of allocated pages.  */
  void *
  grub_efi_allocate_pages (grub_efi_physical_address_t address,
-diff --git a/efi/grub/efi/efi.h b/efi/grub/efi/efi.h
-index 5409911..59314bd 100644
---- a/efi/grub/efi/efi.h
-+++ b/efi/grub/efi/efi.h
-@@ -46,6 +46,7 @@ int grub_efi_get_text_mode(void);
+Index: grub-0.97/efi/grub/efi/efi.h
+===================================================================
+--- grub-0.97.orig/efi/grub/efi/efi.h
++++ grub-0.97/efi/grub/efi/efi.h
+@@ -45,6 +45,7 @@ int grub_efi_set_text_mode (int on);
  void grub_efi_stall (grub_efi_uintn_t microseconds);
  void *grub_efi_allocate_pool (grub_efi_uintn_t size);
  void grub_efi_free_pool (void *buffer);
@@ -75,31 +72,20 @@ index 5409911..59314bd 100644
  void *grub_efi_allocate_pages (grub_efi_physical_address_t address,
  			       grub_efi_uintn_t pages);
  void
-diff --git a/efi/grub/x86_64/linux.h b/efi/grub/x86_64/linux.h
-index 65af9ee..06e83d0 100644
---- a/efi/grub/x86_64/linux.h
-+++ b/efi/grub/x86_64/linux.h
-@@ -28,7 +28,6 @@
- #define GRUB_LINUX_BOOT_LOADER_TYPE	0x72
- #define GRUB_LINUX_HEAP_END_OFFSET	(0x9000 - 0x200)
- 
--#define GRUB_LINUX_BZIMAGE_ADDR		0x100000
- #define GRUB_LINUX_ZIMAGE_ADDR		0x10000
- #define GRUB_LINUX_OLD_REAL_MODE_ADDR	0x90000
- #define GRUB_LINUX_SETUP_STACK		0x9000
-diff --git a/efi/x86_64/loader/linux.c b/efi/x86_64/loader/linux.c
-index 542b0b0..cfa66b2 100644
---- a/efi/x86_64/loader/linux.c
-+++ b/efi/x86_64/loader/linux.c
-@@ -40,6 +40,7 @@
+Index: grub-0.97/efi/x86_64/loader/linux.c
+===================================================================
+--- grub-0.97.orig/efi/x86_64/loader/linux.c
++++ grub-0.97/efi/x86_64/loader/linux.c
+@@ -40,6 +40,8 @@
  static unsigned long linux_mem_size;
  static int loaded;
  static void *real_mode_mem;
 +static void *prot_mode_mem;
++static grub_size_t prot_kernel_size;
  static void *initrd_mem;
  static void *mmap_buf;
  static grub_efi_uintn_t real_mode_pages;
-@@ -143,6 +144,7 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
+@@ -143,6 +145,7 @@ allocate_pages (grub_size_t real_size, g
  
    /* Initialize the memory pointers with NULL for convenience.  */
    real_mode_mem = 0;
@@ -107,21 +93,41 @@ index 542b0b0..cfa66b2 100644
    mmap_buf = 0;
  
    /* Read the memory map temporarily, to find free space.  */
-@@ -205,6 +207,13 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
+@@ -205,6 +208,13 @@ allocate_pages (grub_size_t real_size, g
        goto fail;
      }
  
 +  grub_printf("Trying to allocate %u pages for VMLINUZ\n",
 +		(unsigned) prot_mode_pages);
 +  prot_mode_mem = grub_efi_allocate_anypages(prot_mode_pages);
++
 +  if (!prot_mode_mem)
 +	grub_fatal("Cannot allocate pages for VMLINUZ");
-+  
-+  
++    
    mmap_buf = grub_efi_allocate_pages (0, mmap_pages);
    if (! mmap_buf)
      {
-@@ -501,9 +510,11 @@ grub_load_linux (char *kernel, char *arg)
+@@ -259,6 +269,11 @@ big_linux_boot (void)
+     grub_fatal ("cannot exit boot services");
+ 
+   /* Note that no boot services are available from here.  */
++
++  /* copy vmlinuz image to hdr.code32_start */
++  memcpy ((char *)(params->hdr.code32_start), (char *)prot_mode_mem,
++	  prot_kernel_size);
++  /* copy switch image */
+   memcpy ((void *) 0x700, switch_image, switch_size);
+ 
+   lh = &params->hdr;
+@@ -370,6 +385,7 @@ grub_load_linux (char *kernel, char *arg
+ 
+   real_size = 0x1000 + grub_strlen(arg);
+   prot_size = grub_file_size () - (setup_sects << SECTOR_BITS) - SECTOR_SIZE;
++  prot_kernel_size = prot_size;
+ 
+   if (! allocate_pages (real_size, prot_size))
+     goto fail;
+@@ -501,7 +517,7 @@ grub_load_linux (char *kernel, char *arg
  
    grub_seek ((setup_sects << SECTOR_BITS) + SECTOR_SIZE);
    len = prot_size;
@@ -129,11 +135,4 @@ index 542b0b0..cfa66b2 100644
 +  if (grub_read ((char *)prot_mode_mem, len) != len)
      grub_printf ("Couldn't read file");
  
-+  params->hdr.code32_start = (long)prot_mode_mem;
-+
    if (errnum == ERR_NONE)
-     {
-       loaded = 1;
--- 
-1.6.4
-




More information about the scm-commits mailing list