xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] multiboot2: Fix information request tag size calculation
       [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
@ 2015-01-30 17:59 ` Daniel Kiper
  2015-01-30 17:59 ` [PATCH 2/5] i386/relocator: Remove unused extern grub_relocator64_rip_addr Daniel Kiper
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-01-30 17:59 UTC (permalink / raw)
  To: xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, phcoder,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/loader/multiboot_mbi2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index 6f74aee..d7c19bc 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -150,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char *filename)
 	    = (struct multiboot_header_tag_information_request *) tag;
 	  if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)
 	    break;
-	  for (i = 0; i < (request_tag->size - sizeof (request_tag))
+	  for (i = 0; i < (request_tag->size - sizeof (*request_tag))
 		 / sizeof (request_tag->requests[0]); i++)
 	    switch (request_tag->requests[i])
 	      {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/5] i386/relocator: Remove unused extern grub_relocator64_rip_addr
       [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
  2015-01-30 17:59 ` [PATCH 1/5] multiboot2: Fix information request tag size calculation Daniel Kiper
@ 2015-01-30 17:59 ` Daniel Kiper
  2015-01-30 17:59 ` [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument Daniel Kiper
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-01-30 17:59 UTC (permalink / raw)
  To: xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, phcoder,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/lib/i386/relocator.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
index ffaf25f..71dd4f0 100644
--- a/grub-core/lib/i386/relocator.c
+++ b/grub-core/lib/i386/relocator.c
@@ -64,7 +64,6 @@ extern grub_uint64_t grub_relocator64_rbx;
 extern grub_uint64_t grub_relocator64_rcx;
 extern grub_uint64_t grub_relocator64_rdx;
 extern grub_uint64_t grub_relocator64_rip;
-extern grub_uint64_t grub_relocator64_rip_addr;
 extern grub_uint64_t grub_relocator64_rsp;
 extern grub_uint64_t grub_relocator64_rsi;
 extern grub_addr_t grub_relocator64_cr3;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument
       [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
  2015-01-30 17:59 ` [PATCH 1/5] multiboot2: Fix information request tag size calculation Daniel Kiper
  2015-01-30 17:59 ` [PATCH 2/5] i386/relocator: Remove unused extern grub_relocator64_rip_addr Daniel Kiper
@ 2015-01-30 17:59 ` Daniel Kiper
  2015-01-30 17:59 ` [PATCH 4/5] i386/relocator: Add grub_relocator64_efi relocator Daniel Kiper
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-01-30 17:59 UTC (permalink / raw)
  To: xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, phcoder,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/lib/i386/relocator.c               |    5 ++---
 grub-core/loader/i386/bsd.c                  |    6 +++---
 grub-core/loader/i386/coreboot/chainloader.c |    2 +-
 grub-core/loader/i386/linux.c                |    2 +-
 grub-core/loader/i386/pc/plan9.c             |    2 +-
 grub-core/loader/i386/xnu.c                  |    4 ++--
 grub-core/loader/multiboot.c                 |    4 ----
 include/grub/i386/relocator.h                |    3 +--
 8 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
index 71dd4f0..b879e5b 100644
--- a/grub-core/lib/i386/relocator.c
+++ b/grub-core/lib/i386/relocator.c
@@ -73,8 +73,7 @@ extern struct grub_i386_idt grub_relocator16_idt;
 
 grub_err_t
 grub_relocator32_boot (struct grub_relocator *rel,
-		       struct grub_relocator32_state state,
-		       int avoid_efi_bootservices)
+		       struct grub_relocator32_state state)
 {
   grub_err_t err;
   void *relst;
@@ -87,7 +86,7 @@ grub_relocator32_boot (struct grub_relocator *rel,
 					  0x9a000 - RELOCATOR_SIZEOF (32),
 					  RELOCATOR_SIZEOF (32), 16,
 					  GRUB_RELOCATOR_PREFERENCE_LOW,
-					  avoid_efi_bootservices);
+					  0);
   if (err)
     return err;
 
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
index bc377b3..c2bf09f 100644
--- a/grub-core/loader/i386/bsd.c
+++ b/grub-core/loader/i386/bsd.c
@@ -797,7 +797,7 @@ grub_freebsd_boot (void)
       stack[6] = stack_target + 9 * sizeof (grub_uint32_t);
       stack[7] = bi.tags;
       stack[8] = kern_end;
-      return grub_relocator32_boot (relocator, state, 0);
+      return grub_relocator32_boot (relocator, state);
     }
 
   /* Not reached.  */
@@ -913,7 +913,7 @@ grub_openbsd_boot (void)
   stack[7] = (grub_uint8_t *) curarg - (grub_uint8_t *) arg0;
   stack[8] = ((grub_uint8_t *) arg0 - (grub_uint8_t *) buf0) + buf_target;
 
-  return grub_relocator32_boot (relocator, state, 0);
+  return grub_relocator32_boot (relocator, state);
 }
 
 static grub_err_t
@@ -1228,7 +1228,7 @@ grub_netbsd_boot (void)
   stack[5] = grub_mmap_get_upper () >> 10;
   stack[6] = grub_mmap_get_lower () >> 10;
 
-  return grub_relocator32_boot (relocator, state, 0);
+  return grub_relocator32_boot (relocator, state);
 }
 
 static grub_err_t
diff --git a/grub-core/loader/i386/coreboot/chainloader.c b/grub-core/loader/i386/coreboot/chainloader.c
index d4cc40b..4bf6dff 100644
--- a/grub-core/loader/i386/coreboot/chainloader.c
+++ b/grub-core/loader/i386/coreboot/chainloader.c
@@ -47,7 +47,7 @@ grub_chain_boot (void)
   grub_video_set_mode ("text", 0, 0);
 
   state.eip = entry;
-  return grub_relocator32_boot (relocator, state, 0);
+  return grub_relocator32_boot (relocator, state);
 }
 
 static grub_err_t
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 291f728..a554da8 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -661,7 +661,7 @@ grub_linux_boot (void)
   state.esi = ctx.real_mode_target;
   state.esp = ctx.real_mode_target;
   state.eip = ctx.params->code32_start;
-  return grub_relocator32_boot (relocator, state, 0);
+  return grub_relocator32_boot (relocator, state);
 }
 
 static grub_err_t
diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c
index 814a49d..bfff497 100644
--- a/grub-core/loader/i386/pc/plan9.c
+++ b/grub-core/loader/i386/pc/plan9.c
@@ -90,7 +90,7 @@ grub_plan9_boot (void)
   };
   grub_video_set_mode ("text", 0, 0);
 
-  return grub_relocator32_boot (rel, state, 0);
+  return grub_relocator32_boot (rel, state);
 }
 
 static grub_err_t
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
index e0506a6..a2bc876 100644
--- a/grub-core/loader/i386/xnu.c
+++ b/grub-core/loader/i386/xnu.c
@@ -791,7 +791,7 @@ grub_xnu_boot_resume (void)
   state.eip = grub_xnu_entry_point;
   state.eax = grub_xnu_arg1;
 
-  return grub_relocator32_boot (grub_xnu_relocator, state, 0); 
+  return grub_relocator32_boot (grub_xnu_relocator, state); 
 }
 
 /* Setup video for xnu. */
@@ -1099,7 +1099,7 @@ grub_xnu_boot (void)
   grub_outb (0xff, 0x21);
   grub_outb (0xff, 0xa1);
 
-  return grub_relocator32_boot (grub_xnu_relocator, state, 0);
+  return grub_relocator32_boot (grub_xnu_relocator, state);
 }
 
 static grub_command_t cmd_devprop_load;
diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c
index 4b71f33..307da32 100644
--- a/grub-core/loader/multiboot.c
+++ b/grub-core/loader/multiboot.c
@@ -131,11 +131,7 @@ grub_multiboot_boot (void)
   if (err)
     return err;
 
-#if defined (__i386__) || defined (__x86_64__)
-  grub_relocator32_boot (grub_multiboot_relocator, state, 0);
-#else
   grub_relocator32_boot (grub_multiboot_relocator, state);
-#endif
 
   /* Not reached.  */
   return GRUB_ERR_NONE;
diff --git a/include/grub/i386/relocator.h b/include/grub/i386/relocator.h
index 5f89a7e..08c5fda 100644
--- a/include/grub/i386/relocator.h
+++ b/include/grub/i386/relocator.h
@@ -69,8 +69,7 @@ grub_err_t grub_relocator16_boot (struct grub_relocator *rel,
 				  struct grub_relocator16_state state);
 
 grub_err_t grub_relocator32_boot (struct grub_relocator *rel,
-				  struct grub_relocator32_state state,
-				  int avoid_efi_bootservices);
+				  struct grub_relocator32_state state);
 
 grub_err_t grub_relocator64_boot (struct grub_relocator *rel,
 				  struct grub_relocator64_state state,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/5] i386/relocator: Add grub_relocator64_efi relocator
       [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
                   ` (2 preceding siblings ...)
  2015-01-30 17:59 ` [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument Daniel Kiper
@ 2015-01-30 17:59 ` Daniel Kiper
  2015-01-30 17:59 ` [PATCH 5/5] multiboot2: Add tags used to pass ImageHandle to loaded image Daniel Kiper
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-01-30 17:59 UTC (permalink / raw)
  To: xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, phcoder,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

Add grub_relocator64_efi relocator. It will be used on EFI 64-bit platforms
when multiboot2 compatible image requests MULTIBOOT_TAG_TYPE_EFI_BS. Relocator
will set lower parts of %rax and %rbx accordingly to multiboot2 specification.
On the other hand processor mode, just before jumping into loaded image, will
be set accordingly to Unified Extensible Firmware Interface Specification,
Version 2.4 Errata B, section 2.3.4, x64 Platforms, boot services. This way
loaded image will be able to use EFI boot services without any issues.

If idea is accepted I will prepare grub_relocator32_efi relocator too.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/Makefile.core.def          |    1 +
 grub-core/lib/i386/relocator.c       |   53 +++++++++++++++++++++++
 grub-core/lib/i386/relocator64_efi.S |   77 ++++++++++++++++++++++++++++++++++
 grub-core/loader/multiboot.c         |   29 +++++++++++--
 grub-core/loader/multiboot_mbi2.c    |   19 +++++++--
 include/grub/i386/multiboot.h        |   11 +++++
 include/grub/i386/relocator.h        |   21 ++++++++++
 include/multiboot2.h                 |    9 ++++
 8 files changed, 213 insertions(+), 7 deletions(-)
 create mode 100644 grub-core/lib/i386/relocator64_efi.S

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 42443bc..3a01189 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1533,6 +1533,7 @@ module = {
   x86 = lib/i386/relocator_common_c.c;
   ieee1275 = lib/ieee1275/relocator.c;
   efi = lib/efi/relocator.c;
+  x86_64_efi = lib/i386/relocator64_efi.S;
   mips = lib/mips/relocator_asm.S;
   mips = lib/mips/relocator.c;
   powerpc = lib/powerpc/relocator_asm.S;
diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
index b879e5b..f4d688e 100644
--- a/grub-core/lib/i386/relocator.c
+++ b/grub-core/lib/i386/relocator.c
@@ -69,6 +69,19 @@ extern grub_uint64_t grub_relocator64_rsi;
 extern grub_addr_t grub_relocator64_cr3;
 extern struct grub_i386_idt grub_relocator16_idt;
 
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+extern grub_uint8_t grub_relocator64_efi_start;
+extern grub_uint8_t grub_relocator64_efi_end;
+extern grub_uint64_t grub_relocator64_efi_rax;
+extern grub_uint64_t grub_relocator64_efi_rbx;
+extern grub_uint64_t grub_relocator64_efi_rcx;
+extern grub_uint64_t grub_relocator64_efi_rdx;
+extern grub_uint64_t grub_relocator64_efi_rip;
+extern grub_uint64_t grub_relocator64_efi_rsi;
+#endif
+#endif
+
 #define RELOCATOR_SIZEOF(x)	(&grub_relocator##x##_end - &grub_relocator##x##_start)
 
 grub_err_t
@@ -213,3 +226,43 @@ grub_relocator64_boot (struct grub_relocator *rel,
   /* Not reached.  */
   return GRUB_ERR_NONE;
 }
+
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+grub_err_t
+grub_relocator64_efi_boot (struct grub_relocator *rel,
+			   struct grub_relocator64_efi_state state)
+{
+  grub_err_t err;
+  void *relst;
+  grub_relocator_chunk_t ch;
+
+  err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
+					  0x40000000 - RELOCATOR_SIZEOF (64_efi),
+					  RELOCATOR_SIZEOF (64_efi), 16,
+					  GRUB_RELOCATOR_PREFERENCE_NONE, 1);
+  if (err)
+    return err;
+
+  grub_relocator64_efi_rax = state.rax;
+  grub_relocator64_efi_rbx = state.rbx;
+  grub_relocator64_efi_rcx = state.rcx;
+  grub_relocator64_efi_rdx = state.rdx;
+  grub_relocator64_efi_rip = state.rip;
+  grub_relocator64_efi_rsi = state.rsi;
+
+  grub_memmove (get_virtual_current_address (ch), &grub_relocator64_efi_start,
+		RELOCATOR_SIZEOF (64_efi));
+
+  err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
+				       &relst, NULL);
+  if (err)
+    return err;
+
+  ((void (*) (void)) relst) ();
+
+  /* Not reached.  */
+  return GRUB_ERR_NONE;
+}
+#endif
+#endif
diff --git a/grub-core/lib/i386/relocator64_efi.S b/grub-core/lib/i386/relocator64_efi.S
new file mode 100644
index 0000000..6baaec6
--- /dev/null
+++ b/grub-core/lib/i386/relocator64_efi.S
@@ -0,0 +1,77 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009,2010  Free Software Foundation, Inc.
+ *  Copyright (C) 2014,2015  Oracle Corp.
+ *      Author: Daniel Kiper
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "relocator_common.S"
+
+	.p2align	4	/* force 16-byte alignment */
+
+VARIABLE(grub_relocator64_efi_start)
+	PREAMBLE
+
+	.code64
+
+	/* mov imm64, %rax */
+	.byte 	0x48
+	.byte	0xb8
+VARIABLE(grub_relocator64_efi_rsi)
+	.quad	0
+
+	movq	%rax, %rsi
+
+	/* mov imm64, %rax */
+	.byte 	0x48
+	.byte	0xb8
+VARIABLE(grub_relocator64_efi_rax)
+	.quad	0
+
+	/* mov imm64, %rbx */
+	.byte 	0x48
+	.byte	0xbb
+VARIABLE(grub_relocator64_efi_rbx)
+	.quad	0
+
+	/* mov imm64, %rcx */
+	.byte 	0x48
+	.byte	0xb9
+VARIABLE(grub_relocator64_efi_rcx)
+	.quad	0
+
+	/* mov imm64, %rdx */
+	.byte 	0x48
+	.byte	0xba
+VARIABLE(grub_relocator64_efi_rdx)
+	.quad	0
+
+	/* Cleared direction flag is of no problem with any current
+	   payload and makes this implementation easier.  */
+	cld
+
+#ifdef __APPLE__
+	.byte 0xff, 0x25
+	.quad 0
+#else
+	jmp *LOCAL(jump_addr) (%rip)
+#endif
+
+LOCAL(jump_addr):
+VARIABLE(grub_relocator64_efi_rip)
+	.quad	0
+
+VARIABLE(grub_relocator64_efi_end)
diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c
index 307da32..cd0d98c 100644
--- a/grub-core/loader/multiboot.c
+++ b/grub-core/loader/multiboot.c
@@ -118,20 +118,43 @@ grub_multiboot_set_video_mode (void)
   return err;
 }
 
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+#define grub_relocator_efi_boot	grub_relocator64_efi_boot
+#endif
+#endif
+
 static grub_err_t
 grub_multiboot_boot (void)
 {
   grub_err_t err;
+  grub_uint32_t target;
   struct grub_relocator32_state state = MULTIBOOT_INITIAL_STATE;
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+  struct grub_relocator64_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE;
+#endif
+#endif
 
-  state.MULTIBOOT_ENTRY_REGISTER = grub_multiboot_payload_eip;
-
-  err = grub_multiboot_make_mbi (&state.MULTIBOOT_MBI_REGISTER);
+  err = grub_multiboot_make_mbi (&target);
 
   if (err)
     return err;
 
+  state.MULTIBOOT_ENTRY_REGISTER = grub_multiboot_payload_eip;
+  state.MULTIBOOT_MBI_REGISTER = target;
+
+#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__)
+  state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = grub_multiboot_payload_eip;
+  state_efi.MULTIBOOT_EFI_MBI_REGISTER = target;
+
+  if (grub_efi_is_finished)
+    grub_relocator32_boot (grub_multiboot_relocator, state);
+  else
+    grub_relocator_efi_boot (grub_multiboot_relocator, state_efi);
+#else
   grub_relocator32_boot (grub_multiboot_relocator, state);
+#endif
 
   /* Not reached.  */
   return GRUB_ERR_NONE;
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index d7c19bc..8d66e3f 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -107,8 +107,8 @@ grub_multiboot_load (grub_file_t file, const char *filename)
   grub_err_t err;
   struct multiboot_header_tag *tag;
   struct multiboot_header_tag_address *addr_tag = NULL;
-  int entry_specified = 0;
-  grub_addr_t entry = 0;
+  int entry_specified = 0, efi_entry_specified = 0;
+  grub_addr_t entry = 0, efi_entry = 0;
   grub_uint32_t console_required = 0;
   struct multiboot_header_tag_framebuffer *fbtag = NULL;
   int accepted_consoles = GRUB_MULTIBOOT_CONSOLE_EGA_TEXT;
@@ -192,6 +192,13 @@ grub_multiboot_load (grub_file_t file, const char *filename)
 	entry = ((struct multiboot_header_tag_entry_address *) tag)->entry_addr;
 	break;
 
+      case MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64:
+#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__)
+	efi_entry_specified = 1;
+	efi_entry = ((struct multiboot_header_tag_entry_address_efi64 *) tag)->entry_addr;
+#endif
+	break;
+
       case MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS:
 	if (!(((struct multiboot_header_tag_console_flags *) tag)->console_flags
 	    & MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED))
@@ -211,7 +218,9 @@ grub_multiboot_load (grub_file_t file, const char *filename)
 	break;
 
       case MULTIBOOT_HEADER_TAG_EFI_BS:
+#ifdef GRUB_MACHINE_EFI
 	keep_bs = 1;
+#endif
 	break;
 
       default:
@@ -224,7 +233,7 @@ grub_multiboot_load (grub_file_t file, const char *filename)
 	break;
       }
 
-  if (addr_tag && !entry_specified)
+  if (addr_tag && !entry_specified && !(keep_bs && efi_entry_specified))
     {
       grub_free (buffer);
       return grub_error (GRUB_ERR_UNKNOWN_OS,
@@ -287,7 +296,9 @@ grub_multiboot_load (grub_file_t file, const char *filename)
 	}
     }
 
-  if (entry_specified)
+  if (keep_bs && efi_entry_specified)
+    grub_multiboot_payload_eip = efi_entry;
+  else if (entry_specified)
     grub_multiboot_payload_eip = entry;
 
   if (fbtag)
diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h
index a1b9488..807a1de 100644
--- a/include/grub/i386/multiboot.h
+++ b/include/grub/i386/multiboot.h
@@ -30,6 +30,17 @@
 #define MULTIBOOT_MBI_REGISTER ebx
 #define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386
 
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+#define MULTIBOOT_EFI_INITIAL_STATE  { .rax = MULTIBOOT_BOOTLOADER_MAGIC,	\
+    .rcx = 0,									\
+    .rdx = 0,									\
+      }
+#define MULTIBOOT_EFI_ENTRY_REGISTER rip
+#define MULTIBOOT_EFI_MBI_REGISTER rbx
+#endif
+#endif
+
 #define MULTIBOOT_ELF32_MACHINE EM_386
 #define MULTIBOOT_ELF64_MACHINE EM_X86_64
 
diff --git a/include/grub/i386/relocator.h b/include/grub/i386/relocator.h
index 08c5fda..7ff56ed 100644
--- a/include/grub/i386/relocator.h
+++ b/include/grub/i386/relocator.h
@@ -65,6 +65,20 @@ struct grub_relocator64_state
   grub_addr_t cr3;
 };
 
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+struct grub_relocator64_efi_state
+{
+  grub_uint64_t rax;
+  grub_uint64_t rbx;
+  grub_uint64_t rcx;
+  grub_uint64_t rdx;
+  grub_uint64_t rip;
+  grub_uint64_t rsi;
+};
+#endif
+#endif
+
 grub_err_t grub_relocator16_boot (struct grub_relocator *rel,
 				  struct grub_relocator16_state state);
 
@@ -75,4 +89,11 @@ grub_err_t grub_relocator64_boot (struct grub_relocator *rel,
 				  struct grub_relocator64_state state,
 				  grub_addr_t min_addr, grub_addr_t max_addr);
 
+#ifdef GRUB_MACHINE_EFI
+#ifdef __x86_64__
+grub_err_t grub_relocator64_efi_boot (struct grub_relocator *rel,
+				      struct grub_relocator64_efi_state state);
+#endif
+#endif
+
 #endif /* ! GRUB_RELOCATOR_CPU_HEADER */
diff --git a/include/multiboot2.h b/include/multiboot2.h
index 3ccff15..75cc99b 100644
--- a/include/multiboot2.h
+++ b/include/multiboot2.h
@@ -69,6 +69,7 @@
 #define MULTIBOOT_HEADER_TAG_FRAMEBUFFER  5
 #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN  6
 #define MULTIBOOT_HEADER_TAG_EFI_BS  7
+#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64  9
 
 #define MULTIBOOT_ARCHITECTURE_I386  0
 #define MULTIBOOT_ARCHITECTURE_MIPS32  4
@@ -133,6 +134,14 @@ struct multiboot_header_tag_entry_address
   multiboot_uint32_t entry_addr;
 };
 
+struct multiboot_header_tag_entry_address_efi64
+{
+  multiboot_uint16_t type;
+  multiboot_uint16_t flags;
+  multiboot_uint32_t size;
+  multiboot_uint32_t entry_addr;
+};
+
 struct multiboot_header_tag_console_flags
 {
   multiboot_uint16_t type;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/5] multiboot2: Add tags used to pass ImageHandle to loaded image
       [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
                   ` (3 preceding siblings ...)
  2015-01-30 17:59 ` [PATCH 4/5] i386/relocator: Add grub_relocator64_efi relocator Daniel Kiper
@ 2015-01-30 17:59 ` Daniel Kiper
  2015-02-09 17:55 ` [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images Daniel Kiper
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-01-30 17:59 UTC (permalink / raw)
  To: xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, phcoder,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

Add tags used to pass ImageHandle to loaded image. It is used
by at least ExitBootServices() function.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/loader/multiboot_mbi2.c |   36 +++++++++++++++++++++++++++++++-----
 include/multiboot2.h              |   16 ++++++++++++++++
 2 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index 8d66e3f..865267c 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -172,6 +172,8 @@ grub_multiboot_load (grub_file_t file, const char *filename)
 	      case MULTIBOOT_TAG_TYPE_NETWORK:
 	      case MULTIBOOT_TAG_TYPE_EFI_MMAP:
 	      case MULTIBOOT_TAG_TYPE_EFI_BS:
+	      case MULTIBOOT_TAG_TYPE_EFI32_IH:
+	      case MULTIBOOT_TAG_TYPE_EFI64_IH:
 		break;
 
 	      default:
@@ -906,11 +908,35 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
 
   if (keep_bs)
     {
-      struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig;
-      tag->type = MULTIBOOT_TAG_TYPE_EFI_BS;
-      tag->size = sizeof (struct multiboot_tag);
-      ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
-	/ sizeof (grub_properly_aligned_t);
+      {
+	struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig;
+	tag->type = MULTIBOOT_TAG_TYPE_EFI_BS;
+	tag->size = sizeof (struct multiboot_tag);
+	ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+	  / sizeof (grub_properly_aligned_t);
+      }
+
+#ifdef __x86_64__
+      {
+	struct multiboot_tag_efi64_ih *tag = (struct multiboot_tag_efi64_ih *) ptrorig;
+	tag->type = MULTIBOOT_TAG_TYPE_EFI64_IH;
+	tag->size = sizeof (*tag);
+	tag->pointer = (grub_addr_t) grub_efi_image_handle;
+	ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+	  / sizeof (grub_properly_aligned_t);
+      }
+#endif
+
+#ifdef __i386__
+      {
+	struct multiboot_tag_efi32_ih *tag = (struct multiboot_tag_efi32_ih *) ptrorig;
+	tag->type = MULTIBOOT_TAG_TYPE_EFI32_IH;
+	tag->size = sizeof (*tag);
+	tag->pointer = (grub_addr_t) grub_efi_image_handle;
+	ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN)
+	  / sizeof (grub_properly_aligned_t);
+      }
+#endif
     }
 #endif
 
diff --git a/include/multiboot2.h b/include/multiboot2.h
index 75cc99b..36372f4 100644
--- a/include/multiboot2.h
+++ b/include/multiboot2.h
@@ -60,6 +60,8 @@
 #define MULTIBOOT_TAG_TYPE_NETWORK           16
 #define MULTIBOOT_TAG_TYPE_EFI_MMAP          17
 #define MULTIBOOT_TAG_TYPE_EFI_BS            18
+#define MULTIBOOT_TAG_TYPE_EFI32_IH          19
+#define MULTIBOOT_TAG_TYPE_EFI64_IH          20
 
 #define MULTIBOOT_HEADER_TAG_END  0
 #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST  1
@@ -382,6 +384,20 @@ struct multiboot_tag_efi_mmap
   multiboot_uint8_t efi_mmap[0];
 }; 
 
+struct multiboot_tag_efi32_ih
+{
+  multiboot_uint32_t type;
+  multiboot_uint32_t size;
+  multiboot_uint32_t pointer;
+};
+
+struct multiboot_tag_efi64_ih
+{
+  multiboot_uint32_t type;
+  multiboot_uint32_t size;
+  multiboot_uint64_t pointer;
+};
+
 #endif /* ! ASM_FILE */
 
 #endif /* ! MULTIBOOT_HEADER */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/5] multiboot2: Fix information request tag size calculation
       [not found] ` <1422640768-28181-2-git-send-email-daniel.kiper@oracle.com>
@ 2015-01-30 20:52   ` Ben Hildred
       [not found]   ` <CAKcyEGrgr=HxZfk4nCPHtfQVWtGKXGsbGboRy0qskFUeiNwH5A@mail.gmail.com>
  2015-02-14 16:27   ` Andrei Borzenkov
  2 siblings, 0 replies; 19+ messages in thread
From: Ben Hildred @ 2015-01-30 20:52 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: jgross, keir, ian.campbell, stefano.stabellini, andrew.cooper3,
	roy.franz, ning.sun, david.vrabel, jbeulich, Vladimir Serbinenko,
	xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei


[-- Attachment #1.1: Type: text/plain, Size: 1272 bytes --]

Why do you want the size of a pointer instead of the size of the structure?

On Fri, Jan 30, 2015 at 10:59 AM, Daniel Kiper <daniel.kiper@oracle.com>
wrote:

> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  grub-core/loader/multiboot_mbi2.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/grub-core/loader/multiboot_mbi2.c
> b/grub-core/loader/multiboot_mbi2.c
> index 6f74aee..d7c19bc 100644
> --- a/grub-core/loader/multiboot_mbi2.c
> +++ b/grub-core/loader/multiboot_mbi2.c
> @@ -150,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char
> *filename)
>             = (struct multiboot_header_tag_information_request *) tag;
>           if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)
>             break;
> -         for (i = 0; i < (request_tag->size - sizeof (request_tag))
> +         for (i = 0; i < (request_tag->size - sizeof (*request_tag))
>                  / sizeof (request_tag->requests[0]); i++)
>             switch (request_tag->requests[i])
>               {
> --
> 1.7.10.4
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
--
Ben Hildred
Automation Support Services
303 815 6721

[-- Attachment #1.2: Type: text/html, Size: 2070 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/5] multiboot2: Fix information request tag size calculation
       [not found]   ` <CAKcyEGrgr=HxZfk4nCPHtfQVWtGKXGsbGboRy0qskFUeiNwH5A@mail.gmail.com>
@ 2015-01-30 21:21     ` Lennart Sorensen
  0 siblings, 0 replies; 19+ messages in thread
From: Lennart Sorensen @ 2015-01-30 21:21 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: jgross, keir, ian.campbell, stefano.stabellini, andrew.cooper3,
	roy.franz, ning.sun, david.vrabel, jbeulich, Vladimir Serbinenko,
	xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Fri, Jan 30, 2015 at 01:52:09PM -0700, Ben Hildred wrote:
> Why do you want the size of a pointer instead of the size of the structure?

Isn't *request_tag the dereferenced pointer, and hence is the size of
the structure, where as before it was the size of a pointer?

-- 
Len Sorensen

> On Fri, Jan 30, 2015 at 10:59 AM, Daniel Kiper <daniel.kiper@oracle.com>
> wrote:
> 
> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> > ---
> >  grub-core/loader/multiboot_mbi2.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/grub-core/loader/multiboot_mbi2.c
> > b/grub-core/loader/multiboot_mbi2.c
> > index 6f74aee..d7c19bc 100644
> > --- a/grub-core/loader/multiboot_mbi2.c
> > +++ b/grub-core/loader/multiboot_mbi2.c
> > @@ -150,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char
> > *filename)
> >             = (struct multiboot_header_tag_information_request *) tag;
> >           if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)
> >             break;
> > -         for (i = 0; i < (request_tag->size - sizeof (request_tag))
> > +         for (i = 0; i < (request_tag->size - sizeof (*request_tag))
> >                  / sizeof (request_tag->requests[0]); i++)
> >             switch (request_tag->requests[i])
> >               {
> > --
> > 1.7.10.4
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >
> 
> 
> 
> -- 
> --
> Ben Hildred
> Automation Support Services
> 303 815 6721

> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images
       [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
                   ` (4 preceding siblings ...)
  2015-01-30 17:59 ` [PATCH 5/5] multiboot2: Add tags used to pass ImageHandle to loaded image Daniel Kiper
@ 2015-02-09 17:55 ` Daniel Kiper
       [not found] ` <1422640768-28181-2-git-send-email-daniel.kiper@oracle.com>
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-02-09 17:55 UTC (permalink / raw)
  To: xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, phcoder,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

Hi all,

On Fri, Jan 30, 2015 at 06:59:23PM +0100, Daniel Kiper wrote:
> Hi,
>
> This patch series enable EFI boot services usage
> in loaded images by multiboot2 protocol.

Guys, do you have any comments on this patch series?
Should I fix something? Could you apply them to GRUB2 tree?

Daniel

PS Please CC all interested parties. I suppose that there are
   some people here who are not subscribed to grub-devel list.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/5] multiboot2: Fix information request tag size calculation
       [not found] ` <1422640768-28181-2-git-send-email-daniel.kiper@oracle.com>
  2015-01-30 20:52   ` [PATCH 1/5] multiboot2: Fix information request tag size calculation Ben Hildred
       [not found]   ` <CAKcyEGrgr=HxZfk4nCPHtfQVWtGKXGsbGboRy0qskFUeiNwH5A@mail.gmail.com>
@ 2015-02-14 16:27   ` Andrei Borzenkov
  2 siblings, 0 replies; 19+ messages in thread
From: Andrei Borzenkov @ 2015-02-14 16:27 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, david.vrabel, jbeulich,
	phcoder, xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei,
	fu.wei

В Fri, 30 Jan 2015 18:59:24 +0100
Daniel Kiper <daniel.kiper@oracle.com> пишет:

> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  grub-core/loader/multiboot_mbi2.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
> index 6f74aee..d7c19bc 100644
> --- a/grub-core/loader/multiboot_mbi2.c
> +++ b/grub-core/loader/multiboot_mbi2.c
> @@ -150,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char *filename)
>  	    = (struct multiboot_header_tag_information_request *) tag;
>  	  if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)
>  	    break;
> -	  for (i = 0; i < (request_tag->size - sizeof (request_tag))
> +	  for (i = 0; i < (request_tag->size - sizeof (*request_tag))
>  		 / sizeof (request_tag->requests[0]); i++)
>  	    switch (request_tag->requests[i])
>  	      {

Applied. Thanks!

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/5] i386/relocator: Remove unused extern grub_relocator64_rip_addr
       [not found] ` <1422640768-28181-3-git-send-email-daniel.kiper@oracle.com>
@ 2015-05-07 16:01   ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 19+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2015-05-07 16:01 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel, grub-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	roy.franz, ning.sun, david.vrabel, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei


[-- Attachment #1.1: Type: text/plain, Size: 22 bytes --]

Committed, thanks.


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was:Re: [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images
       [not found] ` <20150209175505.GC2227@olila.local.net-space.pl>
@ 2015-05-11 16:26   ` Konrad Rzeszutek Wilk
       [not found]   ` <20150511162637.GA2794@l.oracle.com>
  1 sibling, 0 replies; 19+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-05-11 16:26 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, david.vrabel, jbeulich,
	phcoder, xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei,
	fu.wei

On Mon, Feb 09, 2015 at 06:55:05PM +0100, Daniel Kiper wrote:
> Hi all,
> 
> On Fri, Jan 30, 2015 at 06:59:23PM +0100, Daniel Kiper wrote:
> > Hi,
> >
> > This patch series enable EFI boot services usage
> > in loaded images by multiboot2 protocol.
> 
> Guys, do you have any comments on this patch series?
> Should I fix something? Could you apply them to GRUB2 tree?

Hey,

Follow up part of this is to make 20_linux_xen.in be able to detect
whether Xen.gz can be loaded using multiboot2.

I was thinking to piggy-back on the patches which dropped
the check on CONFIG_XEN_DOM0 in the Linux kernel config file
as (I think so) it was inspecting the ELF of the Linux kernel
and determining if it has ".note.Xen" (see
http://xenbits.xen.org/docs/4.3-testing/misc/dump-core-format.txt or
http://wiki.xen.org/wiki/X86_Paravirtualised_Memory_Management#Start_Of_Day)
and using some of that logic to inspect the Xen to find
the MB2 header?

But I am having a hard time finding them? Vladimir do you remember
where they might be?

Thank you!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was:Re: [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images
       [not found]   ` <20150511162637.GA2794@l.oracle.com>
@ 2015-05-11 16:38     ` Vladimir 'phcoder' Serbinenko
       [not found]     ` <CAEaD8JMSk+y21e+dZd6h-Pju8iaMn4F5cACRd7FnonU_W4Sw9A@mail.gmail.com>
  1 sibling, 0 replies; 19+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2015-05-11 16:38 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, Daniel Kiper, roy.franz, ning.sun, david.vrabel,
	jbeulich, xen-devel, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei


[-- Attachment #1.1: Type: text/plain, Size: 1231 bytes --]

On May 11, 2015 6:26 PM, "Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>
wrote:
>
> On Mon, Feb 09, 2015 at 06:55:05PM +0100, Daniel Kiper wrote:
> > Hi all,
> >
> > On Fri, Jan 30, 2015 at 06:59:23PM +0100, Daniel Kiper wrote:
> > > Hi,
> > >
> > > This patch series enable EFI boot services usage
> > > in loaded images by multiboot2 protocol.
> >
> > Guys, do you have any comments on this patch series?
> > Should I fix something? Could you apply them to GRUB2 tree?
>
> Hey,
>
> Follow up part of this is to make 20_linux_xen.in be able to detect
> whether Xen.gz can be loaded using multiboot2.
>
> I was thinking to piggy-back on the patches which dropped
> the check on CONFIG_XEN_DOM0 in the Linux kernel config file
> as (I think so) it was inspecting the ELF of the Linux kernel
> and determining if it has ".note.Xen" (see
> http://xenbits.xen.org/docs/4.3-testing/misc/dump-core-format.txt or
>
http://wiki.xen.org/wiki/X86_Paravirtualised_Memory_Management#Start_Of_Day)
> and using some of that logic to inspect the Xen to find
> the MB2 header?
>
See grub-file tool. Possibly it's still only in next branch
> But I am having a hard time finding them? Vladimir do you remember
> where they might be?
>
> Thank you!

[-- Attachment #1.2: Type: text/html, Size: 1802 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was:Re: [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images
       [not found]     ` <CAEaD8JMSk+y21e+dZd6h-Pju8iaMn4F5cACRd7FnonU_W4Sw9A@mail.gmail.com>
@ 2015-05-11 18:56       ` Konrad Rzeszutek Wilk
  2015-05-12 14:54       ` [PATCH] Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was: Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 19+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-05-11 18:56 UTC (permalink / raw)
  To: Vladimir 'phcoder' Serbinenko
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, Daniel Kiper, roy.franz, ning.sun, david.vrabel,
	jbeulich, xen-devel, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

> > and using some of that logic to inspect the Xen to find
> > the MB2 header?
> >
> See grub-file tool. Possibly it's still only in next branch

I see it. Thank you.

I also see 'faf4a65e1e1ce1d822d251c1e4b53d96ec7faec5'
    	Revert grub-file usage in grub-mkconfig.

but not much of an explanation? What didn't work?

Thanks!
> > But I am having a hard time finding them? Vladimir do you remember
> > where they might be?
> >
> > Thank you!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was:..
       [not found]     ` <CAEaD8JMSk+y21e+dZd6h-Pju8iaMn4F5cACRd7FnonU_W4Sw9A@mail.gmail.com>
  2015-05-11 18:56       ` Konrad Rzeszutek Wilk
@ 2015-05-12 14:54       ` Konrad Rzeszutek Wilk
  2015-05-12 14:54         ` [PATCH] grub-mkconfig: Detect if Xen is multiboot2 and use appropiate module Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 19+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-05-12 14:54 UTC (permalink / raw)
  To: phcoder, grub-devel, xen-devel

> > and using some of that logic to inspect the Xen to find
> > the MB2 header?
> >
> See grub-file tool. Possibly it's still only in next branch

Sending a patch to utilize the 'grub-file' to figure this out. It is
right now only for Linux as platforms as I don't have yet the other
platforms installed to test the patch properly.

Vladimir, thank you for having the 'grub-file' already in the tree!
(it shows up in the master branch).

 util/grub.d/20_linux_xen.in | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Konrad Rzeszutek Wilk (1):
      grub-mkconfig: Detect if Xen is multiboot2 and use appropiate module.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] grub-mkconfig: Detect if Xen is multiboot2 and use appropiate module.
  2015-05-12 14:54       ` [PATCH] Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was: Konrad Rzeszutek Wilk
@ 2015-05-12 14:54         ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 19+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-05-12 14:54 UTC (permalink / raw)
  To: phcoder, grub-devel, xen-devel; +Cc: Konrad Rzeszutek Wilk

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 util/grub.d/20_linux_xen.in | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index de34c8d..ce91c1e 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -83,6 +83,10 @@ linux_entry ()
   type="$4"
   args="$5"
   xen_args="$6"
+  ver=""
+  if $($grub_file --is-x86-multiboot2 ${xen_dirname}/${xen_basename}); then
+     ver="2"
+  fi
   if [ -z "$boot_device_id" ]; then
       boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
   fi
@@ -120,16 +124,16 @@ linux_entry ()
         else
             xen_rm_opts="no-real-mode edd=off"
         fi
-	multiboot	${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
+	multiboot${ver}	${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
 	echo	'$(echo "$lmessage" | grub_quote)'
-	module	${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
+	module${ver}	${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
     # TRANSLATORS: ramdisk isn't identifier. Should be translated.
     message="$(gettext_printf "Loading initial ramdisk ...")"
     sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
-	module	--nounzip   ${rel_dirname}/${initrd}
+	module${ver}	--nounzip   ${rel_dirname}/${initrd}
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument
       [not found]   ` <554B8D05.4000004@gmail.com>
@ 2015-05-29 20:58     ` Daniel Kiper
       [not found]     ` <20150529205843.GL3787@olila.local.net-space.pl>
  1 sibling, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-05-29 20:58 UTC (permalink / raw)
  Cc: jgross, grub-devel, keir, ian.campbell, andrew.cooper3,
	stefano.stabellini, roy.franz, ning.sun, david.vrabel, jbeulich,
	phcoder, xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei,
	fu.wei

Hey,

Sorry for late reply but I was busy with our internal EFI stuff. We did
more tests and some fixes and it seems that everything is going in right
direction. Well, I hope... :-))) Right now I am going to continue my work
on upstream EFI + GRUB2 + Xen stuff. I think that I will be able to release
new patch series for GRUB2 and Xen in second or third week of June (next
week we have 2 days holiday in Poland). Stay tuned...

On Thu, May 07, 2015 at 06:04:21PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Not unused:
>     grub_efi_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx,
> 			   avoid_efi_boot_services);

In general I have a problem with avoid_efi_boot_services stuff in GRUB2.
By default it is disabled and GRUB2 assumes that boot services (BS) memory
regions (code and data) are free. This means that it may put there loaded image
and/or fills memory maps (MULTIBOOT_TAG_TYPE_BASIC_MEMINFO, MULTIBOOT_TAG_TYPE_MMAP)
with above mentioned regions marked as free. This is OK when BS are disabled
before loaded image exaction. However, we introduced new feature like
MULTIBOOT_TAG_TYPE_EFI_BS (I am going to improve/extend it) and this makes
this behavior more problematic. It means that now GRUB2 with MULTIBOOT_TAG_TYPE_EFI_BS
enabled may overwrite BS regions and/or memory maps are bogus. In turn, this means
that BS are potentially unusable by loaded image which asked for BS with above
mentioned tag. So, I think that we should find a solution for that issues.

The simplest fix for that problem seems total removal of avoid_efi_boot_services
and assumption that BS memory regions are not free. I did some tests with that
but not so many and not so deep. I discovered that at least linux loader (IIRC)
has some issues with this solution. Maybe it could be fixed easily but I did
not investigated this issue so long. Additionally, I realized that boot services
regions are quite big (dozens or even about 100 MiB) and maybe this is not very
nice idea to assume them used in all cases.

So, maybe we should just focus on multiboot2 loader only. In that case GRUB2 should
at first assume that BS regions are used. Then it should check image header. If it
does not contain MULTIBOOT_TAG_TYPE_EFI_BS tag then starting from that point it should
assume that BS regions are free and behave as it behaves right now. However, if multiboot2
loader encounters MULTIBOOT_TAG_TYPE_EFI_BS tag then it should still assume that BS
regions are not free. Additionally, GRUB2 should not pass any memory map info (i.e,
MULTIBOOT_TAG_TYPE_BASIC_MEMINFO, MULTIBOOT_TAG_TYPE_MMAP, MULTIBOOT_TAG_TYPE_EFI_MMAP,
etc.) because they are bogus. In that case loaded image should take memory map itself
using relevant BS calls. Does it make sense?

Another questions is why grub_relocator_alloc_chunk_addr() does not consult EFI
memory map if grub_relocator_alloc_chunk_align() does. Should not we fix it?

Daniel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument
       [not found]     ` <20150529205843.GL3787@olila.local.net-space.pl>
@ 2015-05-30  5:25       ` Andrei Borzenkov
       [not found]       ` <20150530082542.1fc95f55@opensuse.site>
  1 sibling, 0 replies; 19+ messages in thread
From: Andrei Borzenkov @ 2015-05-30  5:25 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	Vladimir 'φ-coder/phcoder' Serbinenko, roy.franz,
	ning.sun, david.vrabel, jbeulich, andrew.cooper3, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

В Fri, 29 May 2015 22:58:43 +0200
Daniel Kiper <daniel.kiper@oracle.com> пишет:

> Another questions is why grub_relocator_alloc_chunk_addr() does not consult EFI
> memory map if grub_relocator_alloc_chunk_align() does. Should not we fix it?

My best guess is that grub_relocator_alloc_chunk_addr() gets target
from elsewhere so there is nothing to consult (it is caller
responsibility); while grub_relocator_alloc_chunk_align() needs to
actually search for suitable memory region.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument
       [not found]       ` <20150530082542.1fc95f55@opensuse.site>
@ 2015-07-15 17:50         ` Vladimir 'φ-coder/phcoder' Serbinenko
       [not found]         ` <55A69D7B.50702@gmail.com>
  1 sibling, 0 replies; 19+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2015-07-15 17:50 UTC (permalink / raw)
  To: Andrei Borzenkov, Daniel Kiper
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, david.vrabel, jbeulich,
	xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei


[-- Attachment #1.1: Type: text/plain, Size: 709 bytes --]

On 30.05.2015 07:25, Andrei Borzenkov wrote:
> В Fri, 29 May 2015 22:58:43 +0200
> Daniel Kiper <daniel.kiper@oracle.com> пишет:
> 
>> Another questions is why grub_relocator_alloc_chunk_addr() does not consult EFI
>> memory map if grub_relocator_alloc_chunk_align() does. Should not we fix it?
> 
> My best guess is that grub_relocator_alloc_chunk_addr() gets target
> from elsewhere so there is nothing to consult (it is caller
> responsibility); while grub_relocator_alloc_chunk_align() needs to
> actually search for suitable memory region.
> 
My suggestion would be to pass avoid_boot_services = 1 in multiboot2 iff
we don't terminate the services. Any problems with this approach?


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument
       [not found]         ` <55A69D7B.50702@gmail.com>
@ 2015-07-16 12:02           ` Daniel Kiper
  0 siblings, 0 replies; 19+ messages in thread
From: Daniel Kiper @ 2015-07-16 12:02 UTC (permalink / raw)
  To: Vladimir 'φ-coder/phcoder' Serbinenko
  Cc: jgross, grub-devel, keir, ian.campbell, stefano.stabellini,
	Andrei Borzenkov, andrew.cooper3, roy.franz, ning.sun,
	david.vrabel, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Wed, Jul 15, 2015 at 07:50:51PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 30.05.2015 07:25, Andrei Borzenkov wrote:
> > В Fri, 29 May 2015 22:58:43 +0200
> > Daniel Kiper <daniel.kiper@oracle.com> пишет:
> >
> >> Another questions is why grub_relocator_alloc_chunk_addr() does not consult EFI
> >> memory map if grub_relocator_alloc_chunk_align() does. Should not we fix it?
> >
> > My best guess is that grub_relocator_alloc_chunk_addr() gets target
> > from elsewhere so there is nothing to consult (it is caller
> > responsibility); while grub_relocator_alloc_chunk_align() needs to
> > actually search for suitable memory region.
> >
> My suggestion would be to pass avoid_boot_services = 1 in multiboot2 iff
> we don't terminate the services. Any problems with this approach?

I am just working on new GRUB2 patches. I thought to go that way. I hope
this is good idea. Probably I will post new version of patches next week.

Daniel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-07-16 12:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1422640768-28181-1-git-send-email-daniel.kiper@oracle.com>
2015-01-30 17:59 ` [PATCH 1/5] multiboot2: Fix information request tag size calculation Daniel Kiper
2015-01-30 17:59 ` [PATCH 2/5] i386/relocator: Remove unused extern grub_relocator64_rip_addr Daniel Kiper
2015-01-30 17:59 ` [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument Daniel Kiper
2015-01-30 17:59 ` [PATCH 4/5] i386/relocator: Add grub_relocator64_efi relocator Daniel Kiper
2015-01-30 17:59 ` [PATCH 5/5] multiboot2: Add tags used to pass ImageHandle to loaded image Daniel Kiper
2015-02-09 17:55 ` [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images Daniel Kiper
     [not found] ` <1422640768-28181-2-git-send-email-daniel.kiper@oracle.com>
2015-01-30 20:52   ` [PATCH 1/5] multiboot2: Fix information request tag size calculation Ben Hildred
     [not found]   ` <CAKcyEGrgr=HxZfk4nCPHtfQVWtGKXGsbGboRy0qskFUeiNwH5A@mail.gmail.com>
2015-01-30 21:21     ` Lennart Sorensen
2015-02-14 16:27   ` Andrei Borzenkov
     [not found] ` <1422640768-28181-3-git-send-email-daniel.kiper@oracle.com>
2015-05-07 16:01   ` [PATCH 2/5] i386/relocator: Remove unused extern grub_relocator64_rip_addr Vladimir 'φ-coder/phcoder' Serbinenko
     [not found] ` <20150209175505.GC2227@olila.local.net-space.pl>
2015-05-11 16:26   ` Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was:Re: [PATCH 0/5] multiboot2: Enable EFI boot services usage in loaded images Konrad Rzeszutek Wilk
     [not found]   ` <20150511162637.GA2794@l.oracle.com>
2015-05-11 16:38     ` Vladimir 'phcoder' Serbinenko
     [not found]     ` <CAEaD8JMSk+y21e+dZd6h-Pju8iaMn4F5cACRd7FnonU_W4Sw9A@mail.gmail.com>
2015-05-11 18:56       ` Konrad Rzeszutek Wilk
2015-05-12 14:54       ` [PATCH] Is: grub2-mkconfig detecting ELF files the multiboot2 header and using proper module. Was: Konrad Rzeszutek Wilk
2015-05-12 14:54         ` [PATCH] grub-mkconfig: Detect if Xen is multiboot2 and use appropiate module Konrad Rzeszutek Wilk
     [not found] ` <1422640768-28181-4-git-send-email-daniel.kiper@oracle.com>
     [not found]   ` <554B8D05.4000004@gmail.com>
2015-05-29 20:58     ` [PATCH 3/5] i386/relocator: Remove unused avoid_efi_bootservices argument Daniel Kiper
     [not found]     ` <20150529205843.GL3787@olila.local.net-space.pl>
2015-05-30  5:25       ` Andrei Borzenkov
     [not found]       ` <20150530082542.1fc95f55@opensuse.site>
2015-07-15 17:50         ` Vladimir 'φ-coder/phcoder' Serbinenko
     [not found]         ` <55A69D7B.50702@gmail.com>
2015-07-16 12:02           ` Daniel Kiper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).