Index: conf/x86_64-efi.rmk
===================================================================
--- conf/x86_64-efi.rmk	(revision 2194)
+++ conf/x86_64-efi.rmk	(working copy)
@@ -137,7 +137,7 @@
 appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For linux.mod.
-linux_mod_SOURCES = loader/i386/efi/linux.c
+linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/efi/linux_trampoline.S
 linux_mod_CFLAGS = $(COMMON_CFLAGS)
 linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
@@ -189,7 +189,7 @@
 pkglib_MODULES += xnu.mod
 xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c\
 	 loader/macho.c loader/xnu.c loader/i386/xnu_helper.S
-xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Werror -Wall
+xnu_mod_CFLAGS = $(COMMON_CFLAGS) -Wall
 xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
 xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
Index: kern/x86_64/efi/startup.S
===================================================================
--- kern/x86_64/efi/startup.S	(revision 2194)
+++ kern/x86_64/efi/startup.S	(working copy)
@@ -61,26 +61,3 @@
 	call	EXT_C(grub_main)
 	ret
 
-	.code32
-
-FUNCTION(grub_linux_real_boot)
-        /* Turn off PG bit in CR0 and set CR3 to zero.  */
-        movl    %cr0, %eax
-        andl    $0x7FFFFFFF, %eax
-        movl    %eax, %cr0
-
-        /* Setup EFER (Extended Feature Enable Register).  */
-        movl    $0xc0000080, %ecx
-        rdmsr
-
-        /* Disable Long Mode.  */
-        andl    $0xFFFFFEFF, %eax
-
-        /* Make changes effective.  */
-        wrmsr
-
-        /* Disable PAE.  */
-        xorl    %eax, %eax
-        movl    %eax, %cr4
-
-        jmp     *%ebx
Index: kern/efi/mm.c
===================================================================
--- kern/efi/mm.c	(revision 2194)
+++ kern/efi/mm.c	(working copy)
@@ -47,7 +47,7 @@
 
 /* The minimum and maximum heap size for GRUB itself.  */
 #define MIN_HEAP_SIZE	0x100000
-#define MAX_HEAP_SIZE	(1600 * 0x100000)
+#define MAX_HEAP_SIZE	(16 * 0x100000)
 
 
 /* Allocate pages. Return the pointer to the first of allocated pages.  */
Index: include/grub/x86_64/efi/loader.h
===================================================================
--- include/grub/x86_64/efi/loader.h	(revision 2194)
+++ include/grub/x86_64/efi/loader.h	(working copy)
@@ -22,6 +22,5 @@
 #include <grub/types.h>
 #include <grub/symbol.h>
 
-void EXPORT_FUNC(grub_linux_real_boot) (void);
 
 #endif /* ! GRUB_LOADER_MACHINE_HEADER */
Index: loader/i386/efi/linux.c
===================================================================
--- loader/i386/efi/linux.c	(revision 2194)
+++ loader/i386/efi/linux.c	(working copy)
@@ -241,7 +241,7 @@
 	      
   /* Next, find free pages for the protected mode code.  */
   /* XXX what happens if anything is using this address?  */
-  prot_mode_mem = grub_efi_allocate_pages (0x100000, prot_mode_pages);
+  prot_mode_mem = grub_efi_allocate_pages (0x100000, prot_mode_pages + 1);
   if (! prot_mode_mem)
     {
       grub_error (GRUB_ERR_OUT_OF_MEMORY,
@@ -286,11 +286,8 @@
 }
 
 #ifdef __x86_64__
-struct
-{
-  grub_uint32_t kernel_entry;
-  grub_uint32_t kernel_cs;
-} jumpvector;
+extern grub_uint8_t grub_linux_trampoline_start[];
+extern grub_uint8_t grub_linux_trampoline_end[];
 #endif
 
 static grub_err_t
@@ -384,6 +381,18 @@
       params->v0204.efi_mmap_size = mmap_size;
     }
 
+#ifdef __x86_64__
+
+  grub_memcpy ((char *) prot_mode_mem + (prot_mode_pages << 12), 
+	       grub_linux_trampoline_start, 
+	       grub_linux_trampoline_end - grub_linux_trampoline_start);
+  
+  ((void (*) (void *, unsigned long)) ((char *) prot_mode_mem 
+				       + (prot_mode_pages << 12)))
+    (params->code32_start, real_mode_mem);
+
+#else
+
   /* Hardware interrupts are not safe any longer.  */
   asm volatile ("cli" : : );
   
@@ -391,18 +400,6 @@
   asm volatile ("lidt %0" : : "m" (idt_desc));
   asm volatile ("lgdt %0" : : "m" (gdt_desc));
 
-#ifdef __x86_64__
-
-  jumpvector.kernel_entry = (grub_uint64_t) grub_linux_real_boot;
-  jumpvector.kernel_cs = 0x10;
-
-  asm volatile ( "mov %0, %%rbx" : : "m" (params->code32_start));
-  asm volatile ( "mov %0, %%rsi" : : "m" (real_mode_mem));
-
-  asm volatile ( "ljmp *%0" : : "m" (jumpvector));
-
-#else
-
   /* Pass parameters.  */
   asm volatile ("movl %0, %%ecx" : : "m" (params->code32_start));
   asm volatile ("movl %0, %%esi" : : "m" (real_mode_mem));
