All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup
@ 2017-08-03 10:04 Leif Lindholm
  2017-08-03 10:04 ` [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
                   ` (13 more replies)
  0 siblings, 14 replies; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

This patch series is really three different ones, but they unite around                                                                                                                                             
the need for (and the implementation) of more flexible control of memory                                                                                                                                            
allocation on UEFI systems.                                                                                                                                                                                         
                                                                                                                                                                                                                    
1: Adding new interfaces                                                                                                                                                                                            
- A function for detecting the start address of RAM                                                                                                                                                                 
  Since ARM platforms have no standardised memory map, implement a                                                                                                                                                  
  function that picks the lowest-address region supporting the                                                                                                                                                      
  write-back cache atribute from the UEFI memory map.                                                                                                                                                               
- Implement and expose a new memory allocation function giving access to                                                                                                                                            
  the allocation type and memory type arguments to the AllocatePages                                                                                                                                                
  boot service.                                                                                                                                                                                                     
                                                                                                                                                                                                                    
2: ARM unification                                                                                                                                                                                                  
- The fdt helper library for arm64-efi is really an efi/fdt function.                                                                                                                                               
  So move it to neutral ground in loader/efi.                                                                                                                                                                       
- The arm64 efi linux loader was written for arm64 only, so clean it up a                                                                                                                                           
  bit with regards to 32/64-bit portability, and abstract out some                                                                                                                                                  
  definitions and function prototypes.                                                                                                                                                                              
- Move the arm efi port to use the arm64 linux loader instead of the one                                                                                                                                            
  shared with the u-boot port. Clean up the u-boot loder by deleting the                                                                                                                                            
  efi-specific bits and other code only used by that.                                                                                                                                                               
                                                                                                                                                                                                                    
3: Correctness improvements                                                                                                                                                                                         
- There are some restrictions on the placement of initrd images in                                                                                                                                                  
  relation to the runtime kernel images, for both arm and arm64 - but the                                                                                                                                           
  arm64 one did not use to be explicitly documented (and only triggerable                                                                                                                                           
  on systems with > 40GB of RAM), and the u-boot loader always placed the                                                                                                                                           
  images nearly adjacent. Use the new interfaces to place the initrd as                                                                                                                                             
  approrpiate for each architecture.                                                                                                                                                                                
- The allocation of memory for the grub heap is done of memory type                                                                                                                                                 
  GRUB_EFI_LOADER_DATA. Since UEFI can return memory with non-executable                                                                                                                                            
  mappings for this request, and modules are loaded onto the heap, change                                                                                                                                           
  this allocation to GRUB_EFI_LOADER_CODE instead.

Changes between v1 and v2:
- Move EFI_PAGE_SHIFT/EFI_BYTES_TO_PAGES first in the series, as
  separate patch.
- Add GRUB_EFI_PAGE_SIZE definition.
- Break out find_efi_mmap_size function from existing code to common 
  code for reuse.
  - Move current users to this version.
- Rename grub_efi_get_dram_base -> grub_efi_get_ram_base.
- Break up commits to better separate logical changes.
- Moved initrd location restrictions description, and the resulting
  macros, to the body of the function that uses them.

Changes between RFC and v1:
- Rebased (to deal with arm coreboot upstream changes).                                                                                                                                                             
- Moved EFI page size definitions to common header.                                                                                                                                                                 
- Moved a few stray 32/64-bit fixes from 3/7 to 4/7.

Leif Lindholm (14):
  arm64/efi: move EFI_PAGE definitions to efi/memory.h
  efi: add central copy of grub_efi_find_mmap_size
  loader: drop local implementations of find_efi_mmap_size
  efi: add grub_efi_get_ram_base() function for arm*
  efi: refactor grub_efi_allocate_pages
  efi: move fdt helper library
  efi: Add GRUB_PE32_MAGIC definition
  arm64 linux loader: improve type portability
  arm64 linux loader: rename functions and macros and move to common
    headers
  loader: switch arm/linux to grub_linux_kernel_header struct
  arm/efi: switch to arm64 linux loader
  arm: delete unused efi support from loader/arm
  efi: restrict arm/arm64 linux loader initrd placement
  efi: change heap allocation type to GRUB_EFI_LOADER_CODE

 grub-core/Makefile.am                 |   1 -
 grub-core/Makefile.core.def           |   6 +-
 grub-core/kern/arm/efi/misc.c         | 202 ----------------------------------
 grub-core/kern/efi/mm.c               | 130 ++++++++++++++++++----
 grub-core/loader/arm/linux.c          |  39 +------
 grub-core/loader/arm64/linux.c        |  73 ++++++++----
 grub-core/loader/arm64/xen_boot.c     |  15 +--
 grub-core/loader/{arm64 => efi}/fdt.c |  11 +-
 grub-core/loader/i386/linux.c         |  51 +--------
 grub-core/loader/multiboot_mbi2.c     |  38 +------
 include/grub/arm/efi/loader.h         |  26 -----
 include/grub/arm/linux.h              |  31 ++----
 include/grub/arm64/linux.h            |  13 +--
 include/grub/efi/efi.h                |  11 ++
 include/grub/{arm64 => efi}/fdtload.h |   3 -
 include/grub/efi/memory.h             |   4 +
 include/grub/efi/pe32.h               |   2 +
 17 files changed, 216 insertions(+), 440 deletions(-)
 delete mode 100644 grub-core/kern/arm/efi/misc.c
 rename grub-core/loader/{arm64 => efi}/fdt.c (93%)
 delete mode 100644 include/grub/arm/efi/loader.h
 rename include/grub/{arm64 => efi}/fdtload.h (89%)

-- 
2.11.0



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

* [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 15:18   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size Leif Lindholm
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

The EFI page definitions and macros are generic and should not be confined
to atm64 headers - so move to efi/memory.h.
Also add EFI_PAGE_SIZE macro.

Update loader sources to reflect new header location.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/fdt.c      | 1 +
 grub-core/loader/arm64/linux.c    | 1 +
 grub-core/loader/arm64/xen_boot.c | 1 +
 include/grub/arm64/fdtload.h      | 3 ---
 include/grub/efi/memory.h         | 4 ++++
 5 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c
index db49cf649..bdc3a0c1f 100644
--- a/grub-core/loader/arm64/fdt.c
+++ b/grub-core/loader/arm64/fdt.c
@@ -24,6 +24,7 @@
 #include <grub/command.h>
 #include <grub/file.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
 
 static void *loaded_fdt;
 static void *fdt;
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 9519d2e4d..1960d18b5 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -28,6 +28,7 @@
 #include <grub/cpu/linux.h>
 #include <grub/cpu/fdtload.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>
 #include <grub/i18n.h>
 #include <grub/lib/cmdline.h>
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index 27ede46ca..b7a5b17c9 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -30,6 +30,7 @@
 #include <grub/cpu/fdtload.h>
 #include <grub/cpu/linux.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>	/* required by struct xen_hypervisor_header */
 #include <grub/i18n.h>
 #include <grub/lib/cmdline.h>
diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h
index 7b9ddba91..713c9424d 100644
--- a/include/grub/arm64/fdtload.h
+++ b/include/grub/arm64/fdtload.h
@@ -29,7 +29,4 @@ grub_fdt_unload (void);
 grub_err_t
 grub_fdt_install (void);
 
-#define GRUB_EFI_PAGE_SHIFT	12
-#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
-
 #endif
diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
index 20526b146..a113348ca 100644
--- a/include/grub/efi/memory.h
+++ b/include/grub/efi/memory.h
@@ -22,6 +22,10 @@
 #include <grub/err.h>
 #include <grub/types.h>
 
+#define GRUB_EFI_PAGE_SHIFT             12
+#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)
+#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
+
 #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1
 
 grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
-- 
2.11.0



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

* [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
  2017-08-03 10:04 ` [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 15:19   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size Leif Lindholm
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

There are several implementations of this function in the tree.
Add a central version in grub-core/efi/mm.c.

Taken from grub-core/loader/i386/linux.c, changing some hard-coded constants
to use macros from efi/memory.h.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/kern/efi/mm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 include/grub/efi/efi.h  |  1 +
 2 files changed, 45 insertions(+)

diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 20a47aaf5..31ca703ec 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -217,6 +217,50 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf,
   return GRUB_ERR_NONE;
 }
 
+grub_efi_uintn_t
+grub_efi_find_mmap_size (void)
+{
+  static grub_efi_uintn_t mmap_size = 0;
+
+  if (mmap_size != 0)
+    return mmap_size;
+
+  mmap_size = 1 * GRUB_EFI_PAGE_SIZE;
+  while (1)
+    {
+      int ret;
+      grub_efi_memory_descriptor_t *mmap;
+      grub_efi_uintn_t desc_size;
+      grub_efi_uintn_t cur_mmap_size = mmap_size;
+
+      mmap = grub_malloc (cur_mmap_size);
+      if (! mmap)
+	return 0;
+
+      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0);
+      grub_free (mmap);
+
+      if (ret < 0)
+	{
+	  grub_error (GRUB_ERR_IO, "cannot get memory map");
+	  return 0;
+	}
+      else if (ret > 0)
+	break;
+
+      if (mmap_size < cur_mmap_size)
+	mmap_size = cur_mmap_size;
+      mmap_size += GRUB_EFI_PAGE_SIZE;
+    }
+
+  /* Increase the size a bit for safety, because GRUB allocates more on
+     later, and EFI itself may allocate more.  */
+  mmap_size += 3 * GRUB_EFI_PAGE_SIZE;
+
+  mmap_size = ALIGN_UP (mmap_size, GRUB_EFI_PAGE_SIZE);
+  return mmap_size;
+}
+
 /* Get the memory map as defined in the EFI spec. Return 1 if successful,
    return 0 if partial, or return -1 if an error occurs.  */
 int
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index e9c601f34..3984de083 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -42,6 +42,7 @@ EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address,
 				      grub_efi_uintn_t pages);
 void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address,
 				       grub_efi_uintn_t pages);
+grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void);
 int
 EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
 				      grub_efi_memory_descriptor_t *memory_map,
-- 
2.11.0



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

* [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
  2017-08-03 10:04 ` [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
  2017-08-03 10:04 ` [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 15:20   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Leif Lindholm
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Now we have a grub_efi_find_mmap_size, replace near-identical implementations
in i386/linux and mbi2 loaders with calls to that one.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/i386/linux.c     | 51 +--------------------------------------
 grub-core/loader/multiboot_mbi2.c | 38 +----------------------------
 2 files changed, 2 insertions(+), 87 deletions(-)

diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 083f9417c..dfd50472f 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -101,55 +101,6 @@ page_align (grub_size_t size)
   return (size + (1 << 12) - 1) & (~((1 << 12) - 1));
 }
 
-#ifdef GRUB_MACHINE_EFI
-/* Find the optimal number of pages for the memory map. Is it better to
-   move this code to efi/mm.c?  */
-static grub_efi_uintn_t
-find_efi_mmap_size (void)
-{
-  static grub_efi_uintn_t mmap_size = 0;
-
-  if (mmap_size != 0)
-    return mmap_size;
-
-  mmap_size = (1 << 12);
-  while (1)
-    {
-      int ret;
-      grub_efi_memory_descriptor_t *mmap;
-      grub_efi_uintn_t desc_size;
-      grub_efi_uintn_t cur_mmap_size = mmap_size;
-
-      mmap = grub_malloc (cur_mmap_size);
-      if (! mmap)
-	return 0;
-
-      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0);
-      grub_free (mmap);
-
-      if (ret < 0)
-	{
-	  grub_error (GRUB_ERR_IO, "cannot get memory map");
-	  return 0;
-	}
-      else if (ret > 0)
-	break;
-
-      if (mmap_size < cur_mmap_size)
-	mmap_size = cur_mmap_size;
-      mmap_size += (1 << 12);
-    }
-
-  /* Increase the size a bit for safety, because GRUB allocates more on
-     later, and EFI itself may allocate more.  */
-  mmap_size += (3 << 12);
-
-  mmap_size = page_align (mmap_size);
-  return mmap_size;
-}
-
-#endif
-
 /* Helper for find_mmap_size.  */
 static int
 count_hook (grub_uint64_t addr __attribute__ ((unused)),
@@ -560,7 +511,7 @@ grub_linux_boot (void)
   ctx.real_size = ALIGN_UP (cl_offset + maximal_cmdline_size, 4096);
 
 #ifdef GRUB_MACHINE_EFI
-  efi_mmap_size = find_efi_mmap_size ();
+  efi_mmap_size = grub_efi_find_mmap_size ();
   if (efi_mmap_size == 0)
     return grub_errno;
 #endif
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index b0679a9f6..b5f961494 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -407,42 +407,6 @@ acpiv2_size (void)
 
 static grub_efi_uintn_t efi_mmap_size = 0;
 
-/* Find the optimal number of pages for the memory map. Is it better to
-   move this code to efi/mm.c?  */
-static void
-find_efi_mmap_size (void)
-{
-  efi_mmap_size = (1 << 12);
-  while (1)
-    {
-      int ret;
-      grub_efi_memory_descriptor_t *mmap;
-      grub_efi_uintn_t desc_size;
-      grub_efi_uintn_t cur_mmap_size = efi_mmap_size;
-
-      mmap = grub_malloc (cur_mmap_size);
-      if (! mmap)
-	return;
-
-      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0);
-      grub_free (mmap);
-
-      if (ret < 0)
-	return;
-      else if (ret > 0)
-	break;
-
-      if (efi_mmap_size < cur_mmap_size)
-	efi_mmap_size = cur_mmap_size;
-      efi_mmap_size += (1 << 12);
-    }
-
-  /* Increase the size a bit for safety, because GRUB allocates more on
-     later, and EFI itself may allocate more.  */
-  efi_mmap_size += (3 << 12);
-
-  efi_mmap_size = ALIGN_UP (efi_mmap_size, 4096);
-}
 #endif
 
 static grub_size_t
@@ -463,7 +427,7 @@ grub_multiboot_get_mbi_size (void)
 {
 #ifdef GRUB_MACHINE_EFI
   if (!keep_bs && !efi_mmap_size)
-    find_efi_mmap_size ();    
+    efi_mmap_size = grub_efi_find_mmap_size ();
 #endif
   return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag)
     + sizeof (struct multiboot_tag)
-- 
2.11.0



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

* [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm*
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (2 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 15:30   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages Leif Lindholm
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Since ARM platforms do not have a common memory map, add a helper
function that finds the lowest address region with the EFI_MEMORY_WB
attribute set in the UEFI memory map.

Required for the arm/arm64 linux loader to restrict the initrd
location to where it will be accessible by the kernel at runtime.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++
 include/grub/efi/efi.h  |  3 +++
 2 files changed, 39 insertions(+)

diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 31ca703ec..8413c19e5 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -569,3 +569,39 @@ grub_efi_mm_init (void)
   grub_efi_free_pages ((grub_addr_t) memory_map,
 		       2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
 }
+
+#if defined (__aarch64__)
+grub_err_t
+grub_efi_get_ram_base(grub_addr_t *base_addr)
+{
+  grub_efi_memory_descriptor_t *memory_map;
+  grub_efi_memory_descriptor_t *desc;
+  grub_efi_uintn_t mmap_size;
+  grub_efi_uintn_t desc_size;
+  int ret;
+
+  mmap_size = grub_efi_find_mmap_size();
+
+  memory_map = grub_malloc (mmap_size);
+  if (! memory_map)
+    return GRUB_ERR_OUT_OF_MEMORY;
+  ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL,
+				 &desc_size, NULL);
+
+  if (ret < 1)
+    return GRUB_ERR_BUG;
+
+  for (desc = memory_map, *base_addr = GRUB_UINT_MAX;
+       (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size);
+       desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
+    {
+      if (desc->attribute & GRUB_EFI_MEMORY_WB)
+	if (desc->physical_start < *base_addr)
+	  *base_addr = desc->physical_start;
+    }
+
+  grub_free(memory_map);
+
+  return GRUB_ERR_NONE;
+}
+#endif
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 3984de083..80ab56795 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -85,6 +85,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
 #if defined(__arm__) || defined(__aarch64__)
 void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
 #endif
+#if defined(__aarch64__)
+grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
+#endif
 
 grub_addr_t grub_efi_modules_addr (void);
 
-- 
2.11.0



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

* [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (3 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 15:37   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 06/14] efi: move fdt helper library Leif Lindholm
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Expose a new function, grub_efi_allocate_pages_real(), making it possible
to specify allocation type and memory type as supported by the UEFI
AllocatePages boot service.

Make grub_efi_allocate_pages() a consumer of the new function,
maintaining its old functionality.

Also delete some left-around #if 1/#else blocks in the affected
functions.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/kern/efi/mm.c | 46 ++++++++++++++++++++++++----------------------
 include/grub/efi/efi.h  |  5 +++++
 2 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 8413c19e5..1e62eff8f 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -51,36 +51,20 @@ int grub_efi_is_finished = 0;
 
 /* Allocate pages. Return the pointer to the first of allocated pages.  */
 void *
-grub_efi_allocate_pages (grub_efi_physical_address_t address,
-			 grub_efi_uintn_t pages)
+grub_efi_allocate_pages_real (grub_efi_physical_address_t address,
+			      grub_efi_uintn_t pages,
+			      grub_efi_allocate_type_t alloctype,
+			      grub_efi_memory_type_t memtype)
 {
-  grub_efi_allocate_type_t type;
   grub_efi_status_t status;
   grub_efi_boot_services_t *b;
 
-#if 1
   /* Limit the memory access to less than 4GB for 32-bit platforms.  */
   if (address > GRUB_EFI_MAX_USABLE_ADDRESS)
     return 0;
-#endif
-
-#if 1
-  if (address == 0)
-    {
-      type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
-      address = GRUB_EFI_MAX_USABLE_ADDRESS;
-    }
-  else
-    type = GRUB_EFI_ALLOCATE_ADDRESS;
-#else
-  if (address == 0)
-    type = GRUB_EFI_ALLOCATE_ANY_PAGES;
-  else
-    type = GRUB_EFI_ALLOCATE_ADDRESS;
-#endif
 
   b = grub_efi_system_table->boot_services;
-  status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
+  status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address);
   if (status != GRUB_EFI_SUCCESS)
     return 0;
 
@@ -89,7 +73,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
       /* Uggh, the address 0 was allocated... This is too annoying,
 	 so reallocate another one.  */
       address = GRUB_EFI_MAX_USABLE_ADDRESS;
-      status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
+      status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address);
       grub_efi_free_pages (0, pages);
       if (status != GRUB_EFI_SUCCESS)
 	return 0;
@@ -98,6 +82,24 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
   return (void *) ((grub_addr_t) address);
 }
 
+void *
+grub_efi_allocate_pages (grub_efi_physical_address_t address,
+			 grub_efi_uintn_t pages)
+{
+  grub_efi_allocate_type_t alloctype;
+
+  if (address == 0)
+    {
+      alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
+      address = GRUB_EFI_MAX_USABLE_ADDRESS;
+    }
+  else
+    alloctype = GRUB_EFI_ALLOCATE_ADDRESS;
+
+  return grub_efi_allocate_pages_real (address, pages, alloctype,
+				       GRUB_EFI_LOADER_DATA);
+}
+
 /* Free pages starting from ADDRESS.  */
 void
 grub_efi_free_pages (grub_efi_physical_address_t address,
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 80ab56795..a58774efc 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -38,6 +38,11 @@ void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
 int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
 void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
 void *
+EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address,
+				           grub_efi_uintn_t pages,
+					   grub_efi_allocate_type_t alloctype,
+					   grub_efi_memory_type_t memtype);
+void *
 EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address,
 				      grub_efi_uintn_t pages);
 void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address,
-- 
2.11.0



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

* [PATCH v2 06/14] efi: move fdt helper library
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (4 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 15:38   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition Leif Lindholm
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

There is nothing ARM64 (or even ARM) specific about the efi fdt helper
library, which is used for locating or overriding a firmware-provided
devicetree in a UEFI system - so move it to loader/efi for reuse.

Move the fdtload.h include file to grub/efi and update path to
efi/fdtload.h in source code referring to it.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/Makefile.core.def           | 2 +-
 grub-core/loader/arm64/linux.c        | 2 +-
 grub-core/loader/arm64/xen_boot.c     | 2 +-
 grub-core/loader/{arm64 => efi}/fdt.c | 2 +-
 include/grub/{arm64 => efi}/fdtload.h | 0
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename grub-core/loader/{arm64 => efi}/fdt.c (99%)
 rename include/grub/{arm64 => efi}/fdtload.h (100%)

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 1d86bd22e..a65c27f7f 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1707,7 +1707,7 @@ module = {
 
 module = {
   name = fdt;
-  arm64 = loader/arm64/fdt.c;
+  arm64 = loader/efi/fdt.c;
   common = lib/fdt.c;
   enable = fdt;
 };
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 1960d18b5..cac94d53d 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -26,8 +26,8 @@
 #include <grub/mm.h>
 #include <grub/types.h>
 #include <grub/cpu/linux.h>
-#include <grub/cpu/fdtload.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
 #include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>
 #include <grub/i18n.h>
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index b7a5b17c9..d092a53ed 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -27,9 +27,9 @@
 #include <grub/misc.h>
 #include <grub/mm.h>
 #include <grub/types.h>
-#include <grub/cpu/fdtload.h>
 #include <grub/cpu/linux.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
 #include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>	/* required by struct xen_hypervisor_header */
 #include <grub/i18n.h>
diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c
similarity index 99%
rename from grub-core/loader/arm64/fdt.c
rename to grub-core/loader/efi/fdt.c
index bdc3a0c1f..9715afee0 100644
--- a/grub-core/loader/arm64/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -18,12 +18,12 @@
 
 #include <grub/fdt.h>
 #include <grub/mm.h>
-#include <grub/cpu/fdtload.h>
 #include <grub/err.h>
 #include <grub/dl.h>
 #include <grub/command.h>
 #include <grub/file.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
 #include <grub/efi/memory.h>
 
 static void *loaded_fdt;
diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h
similarity index 100%
rename from include/grub/arm64/fdtload.h
rename to include/grub/efi/fdtload.h
-- 
2.11.0



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

* [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (5 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 06/14] efi: move fdt helper library Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 16:35   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 08/14] arm64 linux loader: improve type portability Leif Lindholm
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete
the existing one in arm64/linux.h.

Update arm64 Linux loader to use this new definition.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c | 2 +-
 include/grub/arm64/linux.h     | 2 --
 include/grub/efi/pe32.h        | 2 ++
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index cac94d53d..57ee43fac 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -53,7 +53,7 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
   if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
     return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
 
-  if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC)
+  if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
     return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
 		       N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
 
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
index 1ea23696e..a981df5d1 100644
--- a/include/grub/arm64/linux.h
+++ b/include/grub/arm64/linux.h
@@ -23,8 +23,6 @@
 
 #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
 
-#define GRUB_EFI_PE_MAGIC	0x5A4D
-
 /* From linux/Documentation/arm64/booting.txt */
 struct grub_arm64_linux_kernel_header
 {
diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h
index f79c36c02..7d44732d2 100644
--- a/include/grub/efi/pe32.h
+++ b/include/grub/efi/pe32.h
@@ -45,6 +45,8 @@
 
 #define GRUB_PE32_MSDOS_STUB_SIZE	0x80
 
+#define GRUB_PE32_MAGIC			0x5a4d
+
 /* According to the spec, the minimal alignment is 512 bytes...
    But some examples (such as EFI drivers in the Intel
    Sample Implementation) use 32 bytes (0x20) instead, and it seems
-- 
2.11.0



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

* [PATCH v2 08/14] arm64 linux loader: improve type portability
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (6 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 16:41   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Leif Lindholm
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

In preparation for turning this into a common loader for 32-bit and 64-bit
platforms, ensure the code will compile cleanly for either.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c | 15 ++++++---------
 grub-core/loader/efi/fdt.c     |  8 ++++----
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 57ee43fac..c60469e53 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -58,8 +58,6 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
 		       N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
 
   grub_dprintf ("linux", "UEFI stub kernel:\n");
-  grub_dprintf ("linux", "text_offset = 0x%012llx\n",
-		(long long unsigned) lh->text_offset);
   grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
 
   return GRUB_ERR_NONE;
@@ -87,8 +85,8 @@ finalize_params_linux (void)
   /* Set initrd info */
   if (initrd_start && initrd_end > initrd_start)
     {
-      grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n",
-		    initrd_start, initrd_end);
+      grub_dprintf ("linux", "Initrd @ %p-%p\n",
+		    (void *) initrd_start, (void *) initrd_end);
 
       retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start",
 				    initrd_start);
@@ -163,7 +161,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args)
 
   /* When successful, not reached */
   b->unload_image (image_handle);
-  grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options,
+  grub_efi_free_pages ((grub_addr_t) loaded_image->load_options,
 		       GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
 
   return grub_errno;
@@ -190,7 +188,7 @@ grub_linux_unload (void)
   initrd_start = initrd_end = 0;
   grub_free (linux_args);
   if (kernel_addr)
-    grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
+    grub_efi_free_pages ((grub_addr_t) kernel_addr,
 			 GRUB_EFI_BYTES_TO_PAGES (kernel_size));
   grub_fdt_unload ();
   return GRUB_ERR_NONE;
@@ -242,8 +240,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
  fail:
   grub_initrd_close (&initrd_ctx);
   if (initrd_mem && !initrd_start)
-    grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem,
-			 initrd_pages);
+    grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages);
 
   return grub_errno;
 }
@@ -330,7 +327,7 @@ fail:
     grub_free (linux_args);
 
   if (kernel_addr && !loaded)
-    grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
+    grub_efi_free_pages ((grub_addr_t) kernel_addr,
 			 GRUB_EFI_BYTES_TO_PAGES (kernel_size));
 
   return grub_errno;
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
index 9715afee0..08bdb3d51 100644
--- a/grub-core/loader/efi/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -33,12 +33,12 @@ void *
 grub_fdt_load (grub_size_t additional_size)
 {
   void *raw_fdt;
-  grub_size_t size;
+  unsigned int size;
 
   if (fdt)
     {
       size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
-      grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size);
+      grub_efi_free_pages ((grub_addr_t) fdt, size);
     }
 
   if (loaded_fdt)
@@ -50,7 +50,7 @@ grub_fdt_load (grub_size_t additional_size)
     raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;
   size += additional_size;
 
-  grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size);
+  grub_dprintf ("linux", "allocating %d bytes for fdt\n", size);
   fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size));
   if (!fdt)
     return NULL;
@@ -89,7 +89,7 @@ grub_fdt_unload (void) {
   if (!fdt) {
     return;
   }
-  grub_efi_free_pages ((grub_efi_physical_address_t) fdt,
+  grub_efi_free_pages ((grub_addr_t) fdt,
 		       GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
   fdt = NULL;
 }
-- 
2.11.0



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

* [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (7 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 08/14] arm64 linux loader: improve type portability Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-03 16:44   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Leif Lindholm
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

In preparation for using the linux loader for 32-bit and 64-bit platforms, rename
grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*.

Move prototypes for now-common functions to efi/efi.h.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c    | 14 +++++++-------
 grub-core/loader/arm64/xen_boot.c | 12 ++++++------
 include/grub/arm64/linux.h        | 11 ++---------
 include/grub/efi/efi.h            |  4 ++++
 4 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index c60469e53..8cd44230d 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -48,9 +48,9 @@ static grub_addr_t initrd_start;
 static grub_addr_t initrd_end;
 
 grub_err_t
-grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
+grub_efi_linux_check_image (struct grub_linux_kernel_header * lh)
 {
-  if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
+  if (lh->magic != GRUB_LINUX_MAGIC_SIGNATURE)
     return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
 
   if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
@@ -109,7 +109,7 @@ failure:
 }
 
 grub_err_t
-grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args)
+grub_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
 {
   grub_efi_memory_mapped_device_path_t *mempath;
   grub_efi_handle_t image_handle;
@@ -173,8 +173,8 @@ grub_linux_boot (void)
   if (finalize_params_linux () != GRUB_ERR_NONE)
     return grub_errno;
 
-  return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr,
-                                     kernel_size, linux_args));
+  return (grub_efi_linux_boot_image((grub_addr_t)kernel_addr,
+                                    kernel_size, linux_args));
 }
 
 static grub_err_t
@@ -250,7 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 		int argc, char *argv[])
 {
   grub_file_t file = 0;
-  struct grub_arm64_linux_kernel_header lh;
+  struct grub_linux_kernel_header lh;
 
   grub_dl_ref (my_mod);
 
@@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
   if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
     return grub_errno;
 
-  if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE)
+  if (grub_efi_linux_check_image (&lh) != GRUB_ERR_NONE)
     goto fail;
 
   grub_loader_unset();
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index d092a53ed..e8720584b 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -67,7 +67,7 @@ typedef enum module_type module_type_t;
 
 struct xen_hypervisor_header
 {
-  struct grub_arm64_linux_kernel_header efi_head;
+  struct grub_linux_kernel_header efi_head;
 
   /* This is always PE\0\0.  */
   grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
@@ -254,9 +254,9 @@ xen_boot (void)
   if (err)
     return err;
 
-  return grub_arm64_uefi_boot_image (xen_hypervisor->start,
-				     xen_hypervisor->size,
-				     xen_hypervisor->cmdline);
+  return grub_efi_linux_boot_image (xen_hypervisor->start,
+				    xen_hypervisor->size,
+				    xen_hypervisor->cmdline);
 }
 
 static void
@@ -458,8 +458,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
 
   if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
     goto fail;
-  if (grub_arm64_uefi_check_image
-      ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
+  if (grub_efi_linux_check_image
+      ((struct grub_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
     goto fail;
   grub_file_seek (file, 0);
 
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
index a981df5d1..e53be83b1 100644
--- a/include/grub/arm64/linux.h
+++ b/include/grub/arm64/linux.h
@@ -19,12 +19,10 @@
 #ifndef GRUB_LINUX_CPU_HEADER
 #define GRUB_LINUX_CPU_HEADER 1
 
-#include <grub/efi/efi.h>
-
-#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
+#define GRUB_LINUX_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */
 
 /* From linux/Documentation/arm64/booting.txt */
-struct grub_arm64_linux_kernel_header
+struct grub_linux_kernel_header
 {
   grub_uint32_t code0;		/* Executable code */
   grub_uint32_t code1;		/* Executable code */
@@ -38,9 +36,4 @@ struct grub_arm64_linux_kernel_header
   grub_uint32_t hdr_offset;	/* Offset of PE/COFF header */
 };
 
-grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header
-                                        *lh);
-grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size,
-                                       char *args);
-
 #endif /* ! GRUB_LINUX_CPU_HEADER */
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index a58774efc..149969941 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -92,6 +92,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
 #endif
 #if defined(__aarch64__)
 grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
+#include <grub/cpu/linux.h>
+grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header *lh);
+grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size,
+				     char *args);
 #endif
 
 grub_addr_t grub_efi_modules_addr (void);
-- 
2.11.0



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

* [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (8 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-07 14:07   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 11/14] arm/efi: switch to arm64 linux loader Leif Lindholm
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Use kernel header struct and generic magic definition to align with
arm64/linux loader.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm/linux.c | 11 +++++------
 include/grub/arm/linux.h     | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
index e64c79a95..067f69894 100644
--- a/grub-core/loader/arm/linux.c
+++ b/grub-core/loader/arm/linux.c
@@ -46,9 +46,6 @@ static const void *current_fdt;
 
 typedef void (*kernel_entry_t) (int, unsigned long, void *);
 
-#define LINUX_ZIMAGE_OFFSET	0x24
-#define LINUX_ZIMAGE_MAGIC	0x016f2818
-
 #define LINUX_PHYS_OFFSET        (0x00008000)
 #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
 #define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
@@ -315,6 +312,7 @@ linux_boot (void)
 static grub_err_t
 linux_load (const char *filename, grub_file_t file)
 {
+  struct grub_linux_kernel_header *lh;
   int size;
 
   size = grub_file_size (file);
@@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file)
       return grub_errno;
     }
 
-  if (size > LINUX_ZIMAGE_OFFSET + 4
-      && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
-      == LINUX_ZIMAGE_MAGIC)
+  lh = (void *) linux_addr;
+
+  if ((grub_size_t) size > sizeof (*lh) &&
+      lh->magic == GRUB_LINUX_MAGIC_SIGNATURE)
     ;
   else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006
 	   && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
index f217f8281..802090239 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
@@ -20,11 +20,20 @@
 #ifndef GRUB_LINUX_CPU_HEADER
 #define GRUB_LINUX_CPU_HEADER 1
 
-#define LINUX_ZIMAGE_OFFSET 0x24
-#define LINUX_ZIMAGE_MAGIC  0x016f2818
-
 #include "system.h"
 
+#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818
+
+struct grub_linux_kernel_header {
+  grub_uint32_t code0;
+  grub_uint32_t reserved1[8];
+  grub_uint32_t magic;
+  grub_uint32_t start; /* _start */
+  grub_uint32_t end;   /* _edata */
+  grub_uint32_t reserved2[4];
+  grub_uint32_t hdr_offset;
+};
+
 #if defined GRUB_MACHINE_UBOOT
 # include <grub/uboot/uboot.h>
 # define LINUX_ADDRESS        (start_of_ram + 0x8000)
-- 
2.11.0



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

* [PATCH v2 11/14] arm/efi: switch to arm64 linux loader
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (9 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-07 14:08   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 12/14] arm: delete unused efi support from loader/arm Leif Lindholm
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

Switch over to the EFI-stub aware arm64 loader for 32-bit ARM platforms.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/Makefile.core.def | 6 +++---
 grub-core/kern/efi/mm.c     | 2 +-
 include/grub/efi/efi.h      | 2 --
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index a65c27f7f..87f80d316 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -229,7 +229,6 @@ kernel = {
   ia64_efi = kern/ia64/cache.c;
 
   arm_efi = kern/arm/efi/init.c;
-  arm_efi = kern/arm/efi/misc.c;
   arm_efi = kern/efi/fdt.c;
 
   arm64_efi = kern/arm64/efi/init.c;
@@ -1698,7 +1697,8 @@ module = {
   powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
   sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
   ia64_efi = loader/ia64/efi/linux.c;
-  arm = loader/arm/linux.c;
+  arm_uboot = loader/arm/linux.c;
+  arm_efi = loader/arm64/linux.c;
   arm64 = loader/arm64/linux.c;
   common = loader/linux.c;
   common = lib/cmdline.c;
@@ -1707,7 +1707,7 @@ module = {
 
 module = {
   name = fdt;
-  arm64 = loader/efi/fdt.c;
+  efi = loader/efi/fdt.c;
   common = lib/fdt.c;
   enable = fdt;
 };
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 1e62eff8f..c8fffe902 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -572,7 +572,7 @@ grub_efi_mm_init (void)
 		       2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
 }
 
-#if defined (__aarch64__)
+#if defined (__aarch64__) || defined (__arm__)
 grub_err_t
 grub_efi_get_ram_base(grub_addr_t *base_addr)
 {
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 149969941..ec691bd44 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -89,8 +89,6 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
 
 #if defined(__arm__) || defined(__aarch64__)
 void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
-#endif
-#if defined(__aarch64__)
 grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
 #include <grub/cpu/linux.h>
 grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header *lh);
-- 
2.11.0



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

* [PATCH v2 12/14] arm: delete unused efi support from loader/arm
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (10 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 11/14] arm/efi: switch to arm64 linux loader Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-07 14:09   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement Leif Lindholm
  2017-08-03 10:04 ` [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Leif Lindholm
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

The 32-bit arm efi port now shares the 64-bit linux loader, so delete
the now unused bits from the 32-bit linux loader.

This in turn leaves the grub-core/kern/arm/efi/misc.c unused, so
delete that too.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/Makefile.am         |   1 -
 grub-core/kern/arm/efi/misc.c | 202 ------------------------------------------
 grub-core/loader/arm/linux.c  |  28 ------
 include/grub/arm/efi/loader.h |  26 ------
 include/grub/arm/linux.h      |  16 ----
 5 files changed, 273 deletions(-)
 delete mode 100644 grub-core/kern/arm/efi/misc.c
 delete mode 100644 include/grub/arm/efi/loader.h

diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 622f946f5..cd3424c07 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -256,7 +256,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h
 endif
 
 if COND_arm_efi
-KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c
deleted file mode 100644
index 7cd41842a..000000000
--- a/grub-core/kern/arm/efi/misc.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* misc.c - various system functions for an arm-based EFI system */
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2013 Free Software Foundation, Inc.
- *
- *  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 <grub/misc.h>
-#include <grub/mm.h>
-#include <grub/cpu/linux.h>
-#include <grub/cpu/system.h>
-#include <grub/efi/efi.h>
-#include <grub/machine/loader.h>
-
-static inline grub_size_t
-page_align (grub_size_t size)
-{
-  return (size + (1 << 12) - 1) & (~((1 << 12) - 1));
-}
-
-/* Find the optimal number of pages for the memory map. Is it better to
-   move this code to efi/mm.c?  */
-static grub_efi_uintn_t
-find_mmap_size (void)
-{
-  static grub_efi_uintn_t mmap_size = 0;
-
-  if (mmap_size != 0)
-    return mmap_size;
-  
-  mmap_size = (1 << 12);
-  while (1)
-    {
-      int ret;
-      grub_efi_memory_descriptor_t *mmap;
-      grub_efi_uintn_t desc_size;
-      
-      mmap = grub_malloc (mmap_size);
-      if (! mmap)
-	return 0;
-
-      ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0);
-      grub_free (mmap);
-      
-      if (ret < 0)
-	{
-	  grub_error (GRUB_ERR_IO, "cannot get memory map");
-	  return 0;
-	}
-      else if (ret > 0)
-	break;
-
-      mmap_size += (1 << 12);
-    }
-
-  /* Increase the size a bit for safety, because GRUB allocates more on
-     later, and EFI itself may allocate more.  */
-  mmap_size += (1 << 12);
-
-  return page_align (mmap_size);
-}
-
-#define NEXT_MEMORY_DESCRIPTOR(desc, size)      \
-  ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
-#define PAGE_SHIFT 12
-
-void *
-grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size)
-{
-  grub_efi_uintn_t desc_size;
-  grub_efi_memory_descriptor_t *mmap, *mmap_end;
-  grub_efi_uintn_t mmap_size, tmp_mmap_size;
-  grub_efi_memory_descriptor_t *desc;
-  void *mem = NULL;
-  grub_addr_t min_start = 0;
-
-  mmap_size = find_mmap_size();
-  if (!mmap_size)
-    return NULL;
-
-  mmap = grub_malloc(mmap_size);
-  if (!mmap)
-    return NULL;
-
-  tmp_mmap_size = mmap_size;
-  if (grub_efi_get_memory_map (&tmp_mmap_size, mmap, 0, &desc_size, 0) <= 0)
-    {
-      grub_error (GRUB_ERR_IO, "cannot get memory map");
-      goto fail;
-    }
-
-  mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size);
-  /* Find lowest accessible RAM location */
-  {
-    int found = 0;
-    for (desc = mmap ; !found && (desc < mmap_end) ;
-	 desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size))
-      {
-	switch (desc->type)
-	  {
-	  case GRUB_EFI_CONVENTIONAL_MEMORY:
-	  case GRUB_EFI_LOADER_CODE:
-	  case GRUB_EFI_LOADER_DATA:
-	    min_start = desc->physical_start + min_offset;
-	    found = 1;
-	    break;
-	  default:
-	    break;
-	  }
-      }
-  }
-
-  /* First, find free pages for the real mode code
-     and the memory map buffer.  */
-  for (desc = mmap ; desc < mmap_end ;
-       desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size))
-    {
-      grub_uint64_t start, end;
-
-      grub_dprintf("mm", "%s: 0x%08x bytes @ 0x%08x\n",
-		   __FUNCTION__,
-		   (grub_uint32_t) (desc->num_pages << PAGE_SHIFT),
-		   (grub_uint32_t) (desc->physical_start));
-
-      if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY)
-	continue;
-
-      start = desc->physical_start;
-      end = start + (desc->num_pages << PAGE_SHIFT);
-      grub_dprintf("mm", "%s: start=0x%016llx, end=0x%016llx\n",
-		  __FUNCTION__, start, end);
-      start = start < min_start ? min_start : start;
-      if (start + size > end)
-	continue;
-      grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n",
-		  __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start);
-      mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1);
-      grub_dprintf("mm", "%s: retval=0x%08x\n",
-		   __FUNCTION__, (grub_addr_t) mem);
-      if (! mem)
-	{
-	  grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
-	  goto fail;
-	}
-      break;
-    }
-
-  if (! mem)
-    {
-      grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
-      goto fail;
-    }
-
-  grub_free (mmap);
-  return mem;
-
- fail:
-  grub_free (mmap);
-  return NULL;
-}
-
-grub_err_t
-grub_efi_prepare_platform (void)
-{
-  grub_efi_uintn_t mmap_size;
-  grub_efi_uintn_t map_key;
-  grub_efi_uintn_t desc_size;
-  grub_efi_uint32_t desc_version;
-  grub_efi_memory_descriptor_t *mmap_buf;
-  grub_err_t err;
-
-  /*
-   * Cloned from IA64
-   * Must be done after grub_machine_fini because map_key is used by
-   *exit_boot_services.
-   */
-  mmap_size = find_mmap_size ();
-  if (! mmap_size)
-    return GRUB_ERR_OUT_OF_MEMORY;
-  mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12);
-  if (! mmap_buf)
-    return GRUB_ERR_OUT_OF_MEMORY;
-
-  err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key,
-				       &desc_size, &desc_version);
-  if (err != GRUB_ERR_NONE)
-    return err;
-
-  return GRUB_ERR_NONE;
-}
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
index 067f69894..e563eca95 100644
--- a/grub-core/loader/arm/linux.c
+++ b/grub-core/loader/arm/linux.c
@@ -290,15 +290,6 @@ linux_boot (void)
    */
   linuxmain = (kernel_entry_t) linux_addr;
 
-#ifdef GRUB_MACHINE_EFI
-  {
-    grub_err_t err;
-    err = grub_efi_prepare_platform();
-    if (err != GRUB_ERR_NONE)
-      return err;
-  }
-#endif
-
   grub_arm_disable_caches_mmu ();
 
   linuxmain (0, machine_type, target_fdt);
@@ -317,13 +308,7 @@ linux_load (const char *filename, grub_file_t file)
 
   size = grub_file_size (file);
 
-#ifdef GRUB_MACHINE_EFI
-  linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_PHYS_OFFSET, size);
-  if (!linux_addr)
-    return grub_errno;
-#else
   linux_addr = LINUX_ADDRESS;
-#endif
   grub_dprintf ("loader", "Loading Linux to 0x%08x\n",
 		(grub_addr_t) linux_addr);
 
@@ -428,20 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
 
   size = grub_get_initrd_size (&initrd_ctx);
 
-#ifdef GRUB_MACHINE_EFI
-  if (initrd_start)
-    grub_efi_free_pages (initrd_start,
-			 (initrd_end - initrd_start + 0xfff) >> 12);
-  initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_INITRD_PHYS_OFFSET, size);
-
-  if (!initrd_start)
-    {
-      grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
-      goto fail;
-    }
-#else
   initrd_start = LINUX_INITRD_ADDRESS;
-#endif
 
   grub_dprintf ("loader", "Loading initrd to 0x%08x\n",
 		(grub_addr_t) initrd_start);
diff --git a/include/grub/arm/efi/loader.h b/include/grub/arm/efi/loader.h
deleted file mode 100644
index 4bab18e83..000000000
--- a/include/grub/arm/efi/loader.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2013  Free Software Foundation, Inc.
- *
- *  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/>.
- */
-
-#ifndef GRUB_LOADER_MACHINE_HEADER
-#define GRUB_LOADER_MACHINE_HEADER	1
-
-grub_err_t EXPORT_FUNC (grub_efi_prepare_platform) (void);
-void * EXPORT_FUNC (grub_efi_allocate_loader_memory) (grub_uint32_t min_offset,
-						      grub_uint32_t size);
-
-#endif /* ! GRUB_LOADER_MACHINE_HEADER */
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
index 802090239..758e97d72 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
@@ -41,20 +41,6 @@ struct grub_linux_kernel_header {
 # define LINUX_FDT_ADDRESS    (LINUX_INITRD_ADDRESS - 0x10000)
 # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data
 # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type
-#elif defined GRUB_MACHINE_EFI
-# include <grub/efi/efi.h>
-# include <grub/machine/loader.h>
-/* On UEFI platforms - load the images at the lowest available address not
-   less than *_PHYS_OFFSET from the first available memory location. */
-# define LINUX_PHYS_OFFSET        (0x00008000)
-# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
-# define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
-# define grub_arm_firmware_get_boot_data (grub_addr_t)grub_efi_get_firmware_fdt
-static inline grub_uint32_t
-grub_arm_firmware_get_machine_type (void)
-{
-  return GRUB_ARM_MACHINE_TYPE_FDT;
-}
 #elif defined (GRUB_MACHINE_COREBOOT)
 #include <grub/fdtbus.h>
 #include <grub/machine/kernel.h>
@@ -73,6 +59,4 @@ grub_arm_firmware_get_machine_type (void)
 }
 #endif
 
-#define FDT_ADDITIONAL_ENTRIES_SIZE	0x300
-
 #endif /* ! GRUB_LINUX_CPU_HEADER */
-- 
2.11.0



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

* [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (11 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 12/14] arm: delete unused efi support from loader/arm Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-07 14:10   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 10:04 ` [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Leif Lindholm
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

The 32-bit arm Linux kernel is built as a zImage, which self-decompresses
down to near start of RAM. In order for an initrd/initramfs to be
accessible, it needs to be placed within the first ~768MB of RAM.
The initrd loader built into the kernel EFI stub restricts this down to
512MB for simplicity - so enable the same restriction in grub.

For arm64, the requirement is within a 1GB aligned 32GB window also
covering the (runtime) kernel image. Since the EFI stub loader itself
will attempt to relocate to near start of RAM, force initrd to be loaded
completely within the first 32GB of RAM.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/loader/arm64/linux.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 8cd44230d..a96019a3b 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -194,6 +194,42 @@ grub_linux_unload (void)
   return GRUB_ERR_NONE;
 }
 
+/*
+ * This function returns a pointer to a legally allocated initrd buffer,
+ * or NULL if unsuccessful
+ */
+static void *
+allocate_initrd_mem (int initrd_pages)
+{
+  grub_addr_t max_addr;
+
+  if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE)
+    return NULL;
+
+  /*
+   * As per linux/Documentation/arm/Booting
+   * ARM initrd needs to be covered by kernel linear mapping,
+   * so place it in the first 512MB of DRAM.
+   *
+   * As per linux/Documentation/arm64/booting.txt
+   * ARM64 initrd needs to be contained entirely within a 1GB aligned window
+   * of up to 32GB of size that covers the kernel image as well.
+   * Since the EFI stub loader will attempt to load the kernel near start of
+   * RAM, place the buffer in the first 32GB of RAM.
+   */
+#ifdef __arm__
+#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024)
+#else /* __aarch64__ */
+#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024)
+#endif
+
+  max_addr += INITRD_MAX_ADDRESS_OFFSET - 1;
+
+  return grub_efi_allocate_pages_real (max_addr, initrd_pages,
+				       GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+				       GRUB_EFI_LOADER_DATA);
+}
+
 static grub_err_t
 grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
 		 int argc, char *argv[])
@@ -222,7 +258,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
   grub_dprintf ("linux", "Loading initrd\n");
 
   initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size));
-  initrd_mem = grub_efi_allocate_pages (0, initrd_pages);
+  initrd_mem = allocate_initrd_mem (initrd_pages);
+
   if (!initrd_mem)
     {
       grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
-- 
2.11.0



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

* [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE
  2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
                   ` (12 preceding siblings ...)
  2017-08-03 10:04 ` [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement Leif Lindholm
@ 2017-08-03 10:04 ` Leif Lindholm
  2017-08-07 14:11   ` Vladimir 'phcoder' Serbinenko
  13 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-08-03 10:04 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper

With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
not return regions with execute ability. Since modules are loaded onto
the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
order to permit execution on systems with this feature enabled.

Closes: 50420

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 grub-core/kern/efi/mm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index c8fffe902..f1424f2e4 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -448,7 +448,9 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
 	  pages = required_pages;
 	}
 
-      addr = grub_efi_allocate_pages (start, pages);
+      addr = grub_efi_allocate_pages_real (start, pages,
+					   GRUB_EFI_ALLOCATE_ADDRESS,
+					   GRUB_EFI_LOADER_CODE);
       if (! addr)
 	grub_fatal ("cannot allocate conventional memory %p with %u pages",
 		    (void *) ((grub_addr_t) start),
-- 
2.11.0



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

* Re: [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h
  2017-08-03 10:04 ` [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
@ 2017-08-03 15:18   ` Vladimir 'phcoder' Serbinenko
  2017-08-04  9:11     ` Leif Lindholm
  0 siblings, 1 reply; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 15:18 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 3305 bytes --]

This assumes that all CPUs supporting EFI have 4K pages. What if some of
CPUs have other page sizes?

Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> The EFI page definitions and macros are generic and should not be confined
> to atm64 headers - so move to efi/memory.h.
> Also add EFI_PAGE_SIZE macro.
>
> Update loader sources to reflect new header location.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/arm64/fdt.c      | 1 +
>  grub-core/loader/arm64/linux.c    | 1 +
>  grub-core/loader/arm64/xen_boot.c | 1 +
>  include/grub/arm64/fdtload.h      | 3 ---
>  include/grub/efi/memory.h         | 4 ++++
>  5 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c
> index db49cf649..bdc3a0c1f 100644
> --- a/grub-core/loader/arm64/fdt.c
> +++ b/grub-core/loader/arm64/fdt.c
> @@ -24,6 +24,7 @@
>  #include <grub/command.h>
>  #include <grub/file.h>
>  #include <grub/efi/efi.h>
> +#include <grub/efi/memory.h>
>
>  static void *loaded_fdt;
>  static void *fdt;
> diff --git a/grub-core/loader/arm64/linux.c
> b/grub-core/loader/arm64/linux.c
> index 9519d2e4d..1960d18b5 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -28,6 +28,7 @@
>  #include <grub/cpu/linux.h>
>  #include <grub/cpu/fdtload.h>
>  #include <grub/efi/efi.h>
> +#include <grub/efi/memory.h>
>  #include <grub/efi/pe32.h>
>  #include <grub/i18n.h>
>  #include <grub/lib/cmdline.h>
> diff --git a/grub-core/loader/arm64/xen_boot.c
> b/grub-core/loader/arm64/xen_boot.c
> index 27ede46ca..b7a5b17c9 100644
> --- a/grub-core/loader/arm64/xen_boot.c
> +++ b/grub-core/loader/arm64/xen_boot.c
> @@ -30,6 +30,7 @@
>  #include <grub/cpu/fdtload.h>
>  #include <grub/cpu/linux.h>
>  #include <grub/efi/efi.h>
> +#include <grub/efi/memory.h>
>  #include <grub/efi/pe32.h>     /* required by struct
> xen_hypervisor_header */
>  #include <grub/i18n.h>
>  #include <grub/lib/cmdline.h>
> diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h
> index 7b9ddba91..713c9424d 100644
> --- a/include/grub/arm64/fdtload.h
> +++ b/include/grub/arm64/fdtload.h
> @@ -29,7 +29,4 @@ grub_fdt_unload (void);
>  grub_err_t
>  grub_fdt_install (void);
>
> -#define GRUB_EFI_PAGE_SHIFT    12
> -#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >>
> GRUB_EFI_PAGE_SHIFT)
> -
>  #endif
> diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
> index 20526b146..a113348ca 100644
> --- a/include/grub/efi/memory.h
> +++ b/include/grub/efi/memory.h
> @@ -22,6 +22,10 @@
>  #include <grub/err.h>
>  #include <grub/types.h>
>
> +#define GRUB_EFI_PAGE_SHIFT             12
> +#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)
> +#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >>
> GRUB_EFI_PAGE_SHIFT)
> +
>  #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1
>
>  grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t
> size,
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 4133 bytes --]

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

* Re: [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size
  2017-08-03 10:04 ` [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size Leif Lindholm
@ 2017-08-03 15:19   ` Vladimir 'phcoder' Serbinenko
  2017-08-08 15:56     ` Leif Lindholm
  0 siblings, 1 reply; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 15:19 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 3260 bytes --]

Looks good. But out of context the name is not descriptive enough. Can we
add a comment near declaration to clarify what this functions is for?

Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> There are several implementations of this function in the tree.
> Add a central version in grub-core/efi/mm.c.
>
> Taken from grub-core/loader/i386/linux.c, changing some hard-coded
> constants
> to use macros from efi/memory.h.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/kern/efi/mm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  include/grub/efi/efi.h  |  1 +
>  2 files changed, 45 insertions(+)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index 20a47aaf5..31ca703ec 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -217,6 +217,50 @@ grub_efi_finish_boot_services (grub_efi_uintn_t
> *outbuf_size, void *outbuf,
>    return GRUB_ERR_NONE;
>  }
>
> +grub_efi_uintn_t
> +grub_efi_find_mmap_size (void)
> +{
> +  static grub_efi_uintn_t mmap_size = 0;
> +
> +  if (mmap_size != 0)
> +    return mmap_size;
> +
> +  mmap_size = 1 * GRUB_EFI_PAGE_SIZE;
> +  while (1)
> +    {
> +      int ret;
> +      grub_efi_memory_descriptor_t *mmap;
> +      grub_efi_uintn_t desc_size;
> +      grub_efi_uintn_t cur_mmap_size = mmap_size;
> +
> +      mmap = grub_malloc (cur_mmap_size);
> +      if (! mmap)
> +       return 0;
> +
> +      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size,
> 0);
> +      grub_free (mmap);
> +
> +      if (ret < 0)
> +       {
> +         grub_error (GRUB_ERR_IO, "cannot get memory map");
> +         return 0;
> +       }
> +      else if (ret > 0)
> +       break;
> +
> +      if (mmap_size < cur_mmap_size)
> +       mmap_size = cur_mmap_size;
> +      mmap_size += GRUB_EFI_PAGE_SIZE;
> +    }
> +
> +  /* Increase the size a bit for safety, because GRUB allocates more on
> +     later, and EFI itself may allocate more.  */
> +  mmap_size += 3 * GRUB_EFI_PAGE_SIZE;
> +
> +  mmap_size = ALIGN_UP (mmap_size, GRUB_EFI_PAGE_SIZE);
> +  return mmap_size;
> +}
> +
>  /* Get the memory map as defined in the EFI spec. Return 1 if successful,
>     return 0 if partial, or return -1 if an error occurs.  */
>  int
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index e9c601f34..3984de083 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -42,6 +42,7 @@ EXPORT_FUNC(grub_efi_allocate_pages)
> (grub_efi_physical_address_t address,
>                                       grub_efi_uintn_t pages);
>  void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t
> address,
>                                        grub_efi_uintn_t pages);
> +grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void);
>  int
>  EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
>                                       grub_efi_memory_descriptor_t
> *memory_map,
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 4068 bytes --]

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

* Re: [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size
  2017-08-03 10:04 ` [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size Leif Lindholm
@ 2017-08-03 15:20   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 15:20 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 4504 bytes --]

LGTM

Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> Now we have a grub_efi_find_mmap_size, replace near-identical
> implementations
> in i386/linux and mbi2 loaders with calls to that one.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/i386/linux.c     | 51
> +--------------------------------------
>  grub-core/loader/multiboot_mbi2.c | 38 +----------------------------
>  2 files changed, 2 insertions(+), 87 deletions(-)
>
> diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
> index 083f9417c..dfd50472f 100644
> --- a/grub-core/loader/i386/linux.c
> +++ b/grub-core/loader/i386/linux.c
> @@ -101,55 +101,6 @@ page_align (grub_size_t size)
>    return (size + (1 << 12) - 1) & (~((1 << 12) - 1));
>  }
>
> -#ifdef GRUB_MACHINE_EFI
> -/* Find the optimal number of pages for the memory map. Is it better to
> -   move this code to efi/mm.c?  */
> -static grub_efi_uintn_t
> -find_efi_mmap_size (void)
> -{
> -  static grub_efi_uintn_t mmap_size = 0;
> -
> -  if (mmap_size != 0)
> -    return mmap_size;
> -
> -  mmap_size = (1 << 12);
> -  while (1)
> -    {
> -      int ret;
> -      grub_efi_memory_descriptor_t *mmap;
> -      grub_efi_uintn_t desc_size;
> -      grub_efi_uintn_t cur_mmap_size = mmap_size;
> -
> -      mmap = grub_malloc (cur_mmap_size);
> -      if (! mmap)
> -       return 0;
> -
> -      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size,
> 0);
> -      grub_free (mmap);
> -
> -      if (ret < 0)
> -       {
> -         grub_error (GRUB_ERR_IO, "cannot get memory map");
> -         return 0;
> -       }
> -      else if (ret > 0)
> -       break;
> -
> -      if (mmap_size < cur_mmap_size)
> -       mmap_size = cur_mmap_size;
> -      mmap_size += (1 << 12);
> -    }
> -
> -  /* Increase the size a bit for safety, because GRUB allocates more on
> -     later, and EFI itself may allocate more.  */
> -  mmap_size += (3 << 12);
> -
> -  mmap_size = page_align (mmap_size);
> -  return mmap_size;
> -}
> -
> -#endif
> -
>  /* Helper for find_mmap_size.  */
>  static int
>  count_hook (grub_uint64_t addr __attribute__ ((unused)),
> @@ -560,7 +511,7 @@ grub_linux_boot (void)
>    ctx.real_size = ALIGN_UP (cl_offset + maximal_cmdline_size, 4096);
>
>  #ifdef GRUB_MACHINE_EFI
> -  efi_mmap_size = find_efi_mmap_size ();
> +  efi_mmap_size = grub_efi_find_mmap_size ();
>    if (efi_mmap_size == 0)
>      return grub_errno;
>  #endif
> diff --git a/grub-core/loader/multiboot_mbi2.c
> b/grub-core/loader/multiboot_mbi2.c
> index b0679a9f6..b5f961494 100644
> --- a/grub-core/loader/multiboot_mbi2.c
> +++ b/grub-core/loader/multiboot_mbi2.c
> @@ -407,42 +407,6 @@ acpiv2_size (void)
>
>  static grub_efi_uintn_t efi_mmap_size = 0;
>
> -/* Find the optimal number of pages for the memory map. Is it better to
> -   move this code to efi/mm.c?  */
> -static void
> -find_efi_mmap_size (void)
> -{
> -  efi_mmap_size = (1 << 12);
> -  while (1)
> -    {
> -      int ret;
> -      grub_efi_memory_descriptor_t *mmap;
> -      grub_efi_uintn_t desc_size;
> -      grub_efi_uintn_t cur_mmap_size = efi_mmap_size;
> -
> -      mmap = grub_malloc (cur_mmap_size);
> -      if (! mmap)
> -       return;
> -
> -      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size,
> 0);
> -      grub_free (mmap);
> -
> -      if (ret < 0)
> -       return;
> -      else if (ret > 0)
> -       break;
> -
> -      if (efi_mmap_size < cur_mmap_size)
> -       efi_mmap_size = cur_mmap_size;
> -      efi_mmap_size += (1 << 12);
> -    }
> -
> -  /* Increase the size a bit for safety, because GRUB allocates more on
> -     later, and EFI itself may allocate more.  */
> -  efi_mmap_size += (3 << 12);
> -
> -  efi_mmap_size = ALIGN_UP (efi_mmap_size, 4096);
> -}
>  #endif
>
>  static grub_size_t
> @@ -463,7 +427,7 @@ grub_multiboot_get_mbi_size (void)
>  {
>  #ifdef GRUB_MACHINE_EFI
>    if (!keep_bs && !efi_mmap_size)
> -    find_efi_mmap_size ();
> +    efi_mmap_size = grub_efi_find_mmap_size ();
>  #endif
>    return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag)
>      + sizeof (struct multiboot_tag)
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 5544 bytes --]

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

* Re: [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm*
  2017-08-03 10:04 ` [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Leif Lindholm
@ 2017-08-03 15:30   ` Vladimir 'phcoder' Serbinenko
  2017-08-08 16:04     ` Leif Lindholm
  0 siblings, 1 reply; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 15:30 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 2805 bytes --]

Any reason to use plain error numbers without grub_error?

Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> Since ARM platforms do not have a common memory map, add a helper
> function that finds the lowest address region with the EFI_MEMORY_WB
> attribute set in the UEFI memory map.
>
> Required for the arm/arm64 linux loader to restrict the initrd
> location to where it will be accessible by the kernel at runtime.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++
>  include/grub/efi/efi.h  |  3 +++
>  2 files changed, 39 insertions(+)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index 31ca703ec..8413c19e5 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -569,3 +569,39 @@ grub_efi_mm_init (void)
>    grub_efi_free_pages ((grub_addr_t) memory_map,
>                        2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
>  }
> +
> +#if defined (__aarch64__)
> +grub_err_t
> +grub_efi_get_ram_base(grub_addr_t *base_addr)
> +{
> +  grub_efi_memory_descriptor_t *memory_map;
> +  grub_efi_memory_descriptor_t *desc;
> +  grub_efi_uintn_t mmap_size;
> +  grub_efi_uintn_t desc_size;
> +  int ret;
> +
> +  mmap_size = grub_efi_find_mmap_size();
> +
> +  memory_map = grub_malloc (mmap_size);
> +  if (! memory_map)
> +    return GRUB_ERR_OUT_OF_MEMORY;
> +  ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL,
> +                                &desc_size, NULL);
> +
> +  if (ret < 1)
> +    return GRUB_ERR_BUG;
> +
> +  for (desc = memory_map, *base_addr = GRUB_UINT_MAX;
> +       (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size);
> +       desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
> +    {
> +      if (desc->attribute & GRUB_EFI_MEMORY_WB)
> +       if (desc->physical_start < *base_addr)
> +         *base_addr = desc->physical_start;
> +    }
> +
> +  grub_free(memory_map);
> +
> +  return GRUB_ERR_NONE;
> +}
> +#endif
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index 3984de083..80ab56795 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -85,6 +85,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config))
> (grub_efi_handle_t hnd,
>  #if defined(__arm__) || defined(__aarch64__)
>  void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
>  #endif
> +#if defined(__aarch64__)
> +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
> +#endif
>
>  grub_addr_t grub_efi_modules_addr (void);
>
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 3540 bytes --]

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

* Re: [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages
  2017-08-03 10:04 ` [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages Leif Lindholm
@ 2017-08-03 15:37   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 15:37 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 5009 bytes --]

Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> Expose a new function, grub_efi_allocate_pages_real(), making it possible
> to specify allocation type and memory type as supported by the UEFI
> AllocatePages boot service.
>
> Make grub_efi_allocate_pages() a consumer of the new function,
> maintaining its old functionality.
>
> Also delete some left-around #if 1/#else blocks in the affected
> functions.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/kern/efi/mm.c | 46
> ++++++++++++++++++++++++----------------------
>  include/grub/efi/efi.h  |  5 +++++
>  2 files changed, 29 insertions(+), 22 deletions(-)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index 8413c19e5..1e62eff8f 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -51,36 +51,20 @@ int grub_efi_is_finished = 0;
>
>  /* Allocate pages. Return the pointer to the first of allocated pages.  */
>  void *
> -grub_efi_allocate_pages (grub_efi_physical_address_t address,
> -                        grub_efi_uintn_t pages)
> +grub_efi_allocate_pages_real (grub_efi_physical_address_t address,
> +                             grub_efi_uintn_t pages,
> +                             grub_efi_allocate_type_t alloctype,
> +                             grub_efi_memory_type_t memtype)
>  {
> -  grub_efi_allocate_type_t type;
>    grub_efi_status_t status;
>    grub_efi_boot_services_t *b;
>
> -#if 1
>    /* Limit the memory access to less than 4GB for 32-bit platforms.  */
>    if (address > GRUB_EFI_MAX_USABLE_ADDRESS)
>      return 0;
> -#endif
> -
> -#if 1
> -  if (address == 0)
> -    {
> -      type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
> -      address = GRUB_EFI_MAX_USABLE_ADDRESS;
> -    }
> -  else
> -    type = GRUB_EFI_ALLOCATE_ADDRESS;
> -#else
> -  if (address == 0)
> -    type = GRUB_EFI_ALLOCATE_ANY_PAGES;
> -  else
> -    type = GRUB_EFI_ALLOCATE_ADDRESS;
> -#endif
>
>    b = grub_efi_system_table->boot_services;
> -  status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA,
> pages, &address);
> +  status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages,
> &address);
>    if (status != GRUB_EFI_SUCCESS)
>      return 0;
>
> @@ -89,7 +73,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t
> address,
>        /* Uggh, the address 0 was allocated... This is too annoying,
>          so reallocate another one.  */
>        address = GRUB_EFI_MAX_USABLE_ADDRESS;
> -      status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA,
> pages, &address);
> +      status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages,
> &address);
>        grub_efi_free_pages (0, pages);
>        if (status != GRUB_EFI_SUCCESS)
>         return 0;
> @@ -98,6 +82,24 @@ grub_efi_allocate_pages (grub_efi_physical_address_t
> address,
>    return (void *) ((grub_addr_t) address);
>  }
>
> +void *
> +grub_efi_allocate_pages (grub_efi_physical_address_t address,
> +                        grub_efi_uintn_t pages)
> +{
> +  grub_efi_allocate_type_t alloctype;
> +
> +  if (address == 0)
> +    {
> +      alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
> +      address = GRUB_EFI_MAX_USABLE_ADDRESS;
> +    }
> +  else
> +    alloctype = GRUB_EFI_ALLOCATE_ADDRESS;
>
I think this function needs to be split into 2:  grub_efi_allocate_fixed,
grub_efi_allocate_any_pages. Then _real suffix on the other function can be
dropped. However I'm fine if it's done at a later time

> +
> +  return grub_efi_allocate_pages_real (address, pages, alloctype,
> +                                      GRUB_EFI_LOADER_DATA);
> +}
> +
>  /* Free pages starting from ADDRESS.  */
>  void
>  grub_efi_free_pages (grub_efi_physical_address_t address,
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index 80ab56795..a58774efc 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -38,6 +38,11 @@ void *EXPORT_FUNC(grub_efi_open_protocol)
> (grub_efi_handle_t handle,
>  int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
>  void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
>  void *
> +EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t
> address,
> +                                          grub_efi_uintn_t pages,
> +                                          grub_efi_allocate_type_t
> alloctype,
> +                                          grub_efi_memory_type_t memtype);
> +void *
>  EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address,
>                                       grub_efi_uintn_t pages);
>  void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t
> address,
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 6138 bytes --]

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

* Re: [PATCH v2 06/14] efi: move fdt helper library
  2017-08-03 10:04 ` [PATCH v2 06/14] efi: move fdt helper library Leif Lindholm
@ 2017-08-03 15:38   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 15:38 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 3370 bytes --]

LGTM

Le Thu, Aug 3, 2017 à 12:10 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> There is nothing ARM64 (or even ARM) specific about the efi fdt helper
> library, which is used for locating or overriding a firmware-provided
> devicetree in a UEFI system - so move it to loader/efi for reuse.
>
> Move the fdtload.h include file to grub/efi and update path to
> efi/fdtload.h in source code referring to it.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/Makefile.core.def           | 2 +-
>  grub-core/loader/arm64/linux.c        | 2 +-
>  grub-core/loader/arm64/xen_boot.c     | 2 +-
>  grub-core/loader/{arm64 => efi}/fdt.c | 2 +-
>  include/grub/{arm64 => efi}/fdtload.h | 0
>  5 files changed, 4 insertions(+), 4 deletions(-)
>  rename grub-core/loader/{arm64 => efi}/fdt.c (99%)
>  rename include/grub/{arm64 => efi}/fdtload.h (100%)
>
> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> index 1d86bd22e..a65c27f7f 100644
> --- a/grub-core/Makefile.core.def
> +++ b/grub-core/Makefile.core.def
> @@ -1707,7 +1707,7 @@ module = {
>
>  module = {
>    name = fdt;
> -  arm64 = loader/arm64/fdt.c;
> +  arm64 = loader/efi/fdt.c;
>    common = lib/fdt.c;
>    enable = fdt;
>  };
> diff --git a/grub-core/loader/arm64/linux.c
> b/grub-core/loader/arm64/linux.c
> index 1960d18b5..cac94d53d 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -26,8 +26,8 @@
>  #include <grub/mm.h>
>  #include <grub/types.h>
>  #include <grub/cpu/linux.h>
> -#include <grub/cpu/fdtload.h>
>  #include <grub/efi/efi.h>
> +#include <grub/efi/fdtload.h>
>  #include <grub/efi/memory.h>
>  #include <grub/efi/pe32.h>
>  #include <grub/i18n.h>
> diff --git a/grub-core/loader/arm64/xen_boot.c
> b/grub-core/loader/arm64/xen_boot.c
> index b7a5b17c9..d092a53ed 100644
> --- a/grub-core/loader/arm64/xen_boot.c
> +++ b/grub-core/loader/arm64/xen_boot.c
> @@ -27,9 +27,9 @@
>  #include <grub/misc.h>
>  #include <grub/mm.h>
>  #include <grub/types.h>
> -#include <grub/cpu/fdtload.h>
>  #include <grub/cpu/linux.h>
>  #include <grub/efi/efi.h>
> +#include <grub/efi/fdtload.h>
>  #include <grub/efi/memory.h>
>  #include <grub/efi/pe32.h>     /* required by struct
> xen_hypervisor_header */
>  #include <grub/i18n.h>
> diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c
> similarity index 99%
> rename from grub-core/loader/arm64/fdt.c
> rename to grub-core/loader/efi/fdt.c
> index bdc3a0c1f..9715afee0 100644
> --- a/grub-core/loader/arm64/fdt.c
> +++ b/grub-core/loader/efi/fdt.c
> @@ -18,12 +18,12 @@
>
>  #include <grub/fdt.h>
>  #include <grub/mm.h>
> -#include <grub/cpu/fdtload.h>
>  #include <grub/err.h>
>  #include <grub/dl.h>
>  #include <grub/command.h>
>  #include <grub/file.h>
>  #include <grub/efi/efi.h>
> +#include <grub/efi/fdtload.h>
>  #include <grub/efi/memory.h>
>
>  static void *loaded_fdt;
> diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h
> similarity index 100%
> rename from include/grub/arm64/fdtload.h
> rename to include/grub/efi/fdtload.h
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 4261 bytes --]

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

* Re: [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition
  2017-08-03 10:04 ` [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition Leif Lindholm
@ 2017-08-03 16:35   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 16:35 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

LGTM

On Thu, Aug 3, 2017, 12:09 Leif Lindholm <leif.lindholm@linaro.org> wrote:

> Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete
> the existing one in arm64/linux.h.
>
> Update arm64 Linux loader to use this new definition.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/arm64/linux.c | 2 +-
>  include/grub/arm64/linux.h     | 2 --
>  include/grub/efi/pe32.h        | 2 ++
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/grub-core/loader/arm64/linux.c
> b/grub-core/loader/arm64/linux.c
> index cac94d53d..57ee43fac 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -53,7 +53,7 @@ grub_arm64_uefi_check_image (struct
> grub_arm64_linux_kernel_header * lh)
>    if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
>      return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
>
> -  if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC)
> +  if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
>      return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
>                        N_("plain image kernel not supported - rebuild with
> CONFIG_(U)EFI_STUB enabled"));
>
> diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
> index 1ea23696e..a981df5d1 100644
> --- a/include/grub/arm64/linux.h
> +++ b/include/grub/arm64/linux.h
> @@ -23,8 +23,6 @@
>
>  #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
>
> -#define GRUB_EFI_PE_MAGIC      0x5A4D
> -
>  /* From linux/Documentation/arm64/booting.txt */
>  struct grub_arm64_linux_kernel_header
>  {
> diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h
> index f79c36c02..7d44732d2 100644
> --- a/include/grub/efi/pe32.h
> +++ b/include/grub/efi/pe32.h
> @@ -45,6 +45,8 @@
>
>  #define GRUB_PE32_MSDOS_STUB_SIZE      0x80
>
> +#define GRUB_PE32_MAGIC                        0x5a4d
> +
>  /* According to the spec, the minimal alignment is 512 bytes...
>     But some examples (such as EFI drivers in the Intel
>     Sample Implementation) use 32 bytes (0x20) instead, and it seems
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 2980 bytes --]

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

* Re: [PATCH v2 08/14] arm64 linux loader: improve type portability
  2017-08-03 10:04 ` [PATCH v2 08/14] arm64 linux loader: improve type portability Leif Lindholm
@ 2017-08-03 16:41   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 16:41 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 4596 bytes --]

LGTM

On Thu, Aug 3, 2017, 12:10 Leif Lindholm <leif.lindholm@linaro.org> wrote:

> In preparation for turning this into a common loader for 32-bit and 64-bit
> platforms, ensure the code will compile cleanly for either.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/arm64/linux.c | 15 ++++++---------
>  grub-core/loader/efi/fdt.c     |  8 ++++----
>  2 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/grub-core/loader/arm64/linux.c
> b/grub-core/loader/arm64/linux.c
> index 57ee43fac..c60469e53 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -58,8 +58,6 @@ grub_arm64_uefi_check_image (struct
> grub_arm64_linux_kernel_header * lh)
>                        N_("plain image kernel not supported - rebuild with
> CONFIG_(U)EFI_STUB enabled"));
>
>    grub_dprintf ("linux", "UEFI stub kernel:\n");
> -  grub_dprintf ("linux", "text_offset = 0x%012llx\n",
> -               (long long unsigned) lh->text_offset);
>    grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
>
>    return GRUB_ERR_NONE;
> @@ -87,8 +85,8 @@ finalize_params_linux (void)
>    /* Set initrd info */
>    if (initrd_start && initrd_end > initrd_start)
>      {
> -      grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n",
> -                   initrd_start, initrd_end);
> +      grub_dprintf ("linux", "Initrd @ %p-%p\n",
> +                   (void *) initrd_start, (void *) initrd_end);
>
>        retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start",
>                                     initrd_start);
> @@ -163,7 +161,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr,
> grub_size_t size, char *args)
>
>    /* When successful, not reached */
>    b->unload_image (image_handle);
> -  grub_efi_free_pages ((grub_efi_physical_address_t)
> loaded_image->load_options,
> +  grub_efi_free_pages ((grub_addr_t) loaded_image->load_options,
>                        GRUB_EFI_BYTES_TO_PAGES
> (loaded_image->load_options_size));
>
>    return grub_errno;
> @@ -190,7 +188,7 @@ grub_linux_unload (void)
>    initrd_start = initrd_end = 0;
>    grub_free (linux_args);
>    if (kernel_addr)
> -    grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
> +    grub_efi_free_pages ((grub_addr_t) kernel_addr,
>                          GRUB_EFI_BYTES_TO_PAGES (kernel_size));
>    grub_fdt_unload ();
>    return GRUB_ERR_NONE;
> @@ -242,8 +240,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__
> ((unused)),
>   fail:
>    grub_initrd_close (&initrd_ctx);
>    if (initrd_mem && !initrd_start)
> -    grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem,
> -                        initrd_pages);
> +    grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages);
>
>    return grub_errno;
>  }
> @@ -330,7 +327,7 @@ fail:
>      grub_free (linux_args);
>
>    if (kernel_addr && !loaded)
> -    grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
> +    grub_efi_free_pages ((grub_addr_t) kernel_addr,
>                          GRUB_EFI_BYTES_TO_PAGES (kernel_size));
>
>    return grub_errno;
> diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
> index 9715afee0..08bdb3d51 100644
> --- a/grub-core/loader/efi/fdt.c
> +++ b/grub-core/loader/efi/fdt.c
> @@ -33,12 +33,12 @@ void *
>  grub_fdt_load (grub_size_t additional_size)
>  {
>    void *raw_fdt;
> -  grub_size_t size;
> +  unsigned int size;
>
>    if (fdt)
>      {
>        size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
> -      grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size);
> +      grub_efi_free_pages ((grub_addr_t) fdt, size);
>      }
>
>    if (loaded_fdt)
> @@ -50,7 +50,7 @@ grub_fdt_load (grub_size_t additional_size)
>      raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;
>    size += additional_size;
>
> -  grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size);
> +  grub_dprintf ("linux", "allocating %d bytes for fdt\n", size);
>    fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size));
>    if (!fdt)
>      return NULL;
> @@ -89,7 +89,7 @@ grub_fdt_unload (void) {
>    if (!fdt) {
>      return;
>    }
> -  grub_efi_free_pages ((grub_efi_physical_address_t) fdt,
> +  grub_efi_free_pages ((grub_addr_t) fdt,
>                        GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize
> (fdt)));
>    fdt = NULL;
>  }
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 5845 bytes --]

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

* Re: [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers
  2017-08-03 10:04 ` [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Leif Lindholm
@ 2017-08-03 16:44   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 16:46     ` Vladimir 'phcoder' Serbinenko
  2017-09-04 14:29     ` Leif Lindholm
  0 siblings, 2 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 16:44 UTC (permalink / raw)
  To: The development of GRUB 2; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 6050 bytes --]

On Thu, Aug 3, 2017, 12:14 Leif Lindholm <leif.lindholm@linaro.org> wrote:

> In preparation for using the linux loader for 32-bit and 64-bit platforms,
> rename
> grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*.
>
> Move prototypes for now-common functions to efi/efi.h.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/arm64/linux.c    | 14 +++++++-------
>  grub-core/loader/arm64/xen_boot.c | 12 ++++++------
>  include/grub/arm64/linux.h        | 11 ++---------
>  include/grub/efi/efi.h            |  4 ++++
>  4 files changed, 19 insertions(+), 22 deletions(-)
>
> diff --git a/grub-core/loader/arm64/linux.c
> b/grub-core/loader/arm64/linux.c
> index c60469e53..8cd44230d 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -48,9 +48,9 @@ static grub_addr_t initrd_start;
>  static grub_addr_t initrd_end;
>
>  grub_err_t
> -grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
> +grub_efi_linux_check_image (struct grub_linux_kernel_header * lh)
>  {
> -  if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
> +  if (lh->magic != GRUB_LINUX_MAGIC_SIGNATURE)
>      return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
>
>    if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
> @@ -109,7 +109,7 @@ failure:
>  }
>
>  grub_err_t
> -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char
> *args)
> +grub_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
>  {
>    grub_efi_memory_mapped_device_path_t *mempath;
>    grub_efi_handle_t image_handle;
> @@ -173,8 +173,8 @@ grub_linux_boot (void)
>    if (finalize_params_linux () != GRUB_ERR_NONE)
>      return grub_errno;
>
> -  return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr,
> -                                     kernel_size, linux_args));
> +  return (grub_efi_linux_boot_image((grub_addr_t)kernel_addr,
> +                                    kernel_size, linux_args));
>  }
>
>  static grub_err_t
> @@ -250,7 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__
> ((unused)),
>                 int argc, char *argv[])
>  {
>    grub_file_t file = 0;
> -  struct grub_arm64_linux_kernel_header lh;
> +  struct grub_linux_kernel_header lh;
>
>    grub_dl_ref (my_mod);
>
> @@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__
> ((unused)),
>    if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
>      return grub_errno;
>
> -  if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE)
> +  if (grub_efi_linux_check_image (&lh) != GRUB_ERR_NONE)
>      goto fail;
>
>    grub_loader_unset();
> diff --git a/grub-core/loader/arm64/xen_boot.c
> b/grub-core/loader/arm64/xen_boot.c
> index d092a53ed..e8720584b 100644
> --- a/grub-core/loader/arm64/xen_boot.c
> +++ b/grub-core/loader/arm64/xen_boot.c
> @@ -67,7 +67,7 @@ typedef enum module_type module_type_t;
>
>  struct xen_hypervisor_header
>  {
> -  struct grub_arm64_linux_kernel_header efi_head;
> +  struct grub_linux_kernel_header efi_head;
>
>    /* This is always PE\0\0.  */
>    grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
> @@ -254,9 +254,9 @@ xen_boot (void)
>    if (err)
>      return err;
>
> -  return grub_arm64_uefi_boot_image (xen_hypervisor->start,
> -                                    xen_hypervisor->size,
> -                                    xen_hypervisor->cmdline);
> +  return grub_efi_linux_boot_image (xen_hypervisor->start,
> +                                   xen_hypervisor->size,
> +                                   xen_hypervisor->cmdline);
>  }
>
>  static void
> @@ -458,8 +458,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd
> __attribute__ ((unused)),
>
>    if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
>      goto fail;
> -  if (grub_arm64_uefi_check_image
> -      ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
> +  if (grub_efi_linux_check_image
> +      ((struct grub_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
>      goto fail;
>    grub_file_seek (file, 0);
>
> diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
> index a981df5d1..e53be83b1 100644
> --- a/include/grub/arm64/linux.h
> +++ b/include/grub/arm64/linux.h
> @@ -19,12 +19,10 @@
>  #ifndef GRUB_LINUX_CPU_HEADER
>  #define GRUB_LINUX_CPU_HEADER 1
>
> -#include <grub/efi/efi.h>
> -
> -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
> +#define GRUB_LINUX_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */
>
This doesn't sound arm64-independent.

>
>  /* From linux/Documentation/arm64/booting.txt */
> -struct grub_arm64_linux_kernel_header
> +struct grub_linux_kernel_header
>  {
>
This makes it confusing with x86 counterpart.

>    grub_uint32_t code0;         /* Executable code */
>    grub_uint32_t code1;         /* Executable code */
> @@ -38,9 +36,4 @@ struct grub_arm64_linux_kernel_header
>    grub_uint32_t hdr_offset;    /* Offset of PE/COFF header */
>  };
>
> -grub_err_t grub_arm64_uefi_check_image (struct
> grub_arm64_linux_kernel_header
> -                                        *lh);
> -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size,
> -                                       char *args);
> -
>  #endif /* ! GRUB_LINUX_CPU_HEADER */
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index a58774efc..149969941 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -92,6 +92,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
>  #endif
>  #if defined(__aarch64__)
>  grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
> +#include <grub/cpu/linux.h>
> +grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header
> *lh);
> +grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size,
> +                                    char *args);
>  #endif
>
>  grub_addr_t grub_efi_modules_addr (void);
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 7683 bytes --]

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

* Re: [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers
  2017-08-03 16:44   ` Vladimir 'phcoder' Serbinenko
@ 2017-08-03 16:46     ` Vladimir 'phcoder' Serbinenko
  2017-09-04 14:29     ` Leif Lindholm
  1 sibling, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-03 16:46 UTC (permalink / raw)
  To: The development of GRUB 2; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 6395 bytes --]

We can use armxx as an infix for names that are for both arm and aarch64

On Thu, Aug 3, 2017, 18:44 Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
wrote:

>
>
> On Thu, Aug 3, 2017, 12:14 Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
>> In preparation for using the linux loader for 32-bit and 64-bit
>> platforms, rename
>> grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*.
>>
>> Move prototypes for now-common functions to efi/efi.h.
>>
>> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
>> ---
>>  grub-core/loader/arm64/linux.c    | 14 +++++++-------
>>  grub-core/loader/arm64/xen_boot.c | 12 ++++++------
>>  include/grub/arm64/linux.h        | 11 ++---------
>>  include/grub/efi/efi.h            |  4 ++++
>>  4 files changed, 19 insertions(+), 22 deletions(-)
>>
>> diff --git a/grub-core/loader/arm64/linux.c
>> b/grub-core/loader/arm64/linux.c
>> index c60469e53..8cd44230d 100644
>> --- a/grub-core/loader/arm64/linux.c
>> +++ b/grub-core/loader/arm64/linux.c
>> @@ -48,9 +48,9 @@ static grub_addr_t initrd_start;
>>  static grub_addr_t initrd_end;
>>
>>  grub_err_t
>> -grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
>> +grub_efi_linux_check_image (struct grub_linux_kernel_header * lh)
>>  {
>> -  if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
>> +  if (lh->magic != GRUB_LINUX_MAGIC_SIGNATURE)
>>      return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
>>
>>    if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
>> @@ -109,7 +109,7 @@ failure:
>>  }
>>
>>  grub_err_t
>> -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char
>> *args)
>> +grub_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char
>> *args)
>>  {
>>    grub_efi_memory_mapped_device_path_t *mempath;
>>    grub_efi_handle_t image_handle;
>> @@ -173,8 +173,8 @@ grub_linux_boot (void)
>>    if (finalize_params_linux () != GRUB_ERR_NONE)
>>      return grub_errno;
>>
>> -  return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr,
>> -                                     kernel_size, linux_args));
>> +  return (grub_efi_linux_boot_image((grub_addr_t)kernel_addr,
>> +                                    kernel_size, linux_args));
>>  }
>>
>>  static grub_err_t
>> @@ -250,7 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__
>> ((unused)),
>>                 int argc, char *argv[])
>>  {
>>    grub_file_t file = 0;
>> -  struct grub_arm64_linux_kernel_header lh;
>> +  struct grub_linux_kernel_header lh;
>>
>>    grub_dl_ref (my_mod);
>>
>> @@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__
>> ((unused)),
>>    if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
>>      return grub_errno;
>>
>> -  if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE)
>> +  if (grub_efi_linux_check_image (&lh) != GRUB_ERR_NONE)
>>      goto fail;
>>
>>    grub_loader_unset();
>> diff --git a/grub-core/loader/arm64/xen_boot.c
>> b/grub-core/loader/arm64/xen_boot.c
>> index d092a53ed..e8720584b 100644
>> --- a/grub-core/loader/arm64/xen_boot.c
>> +++ b/grub-core/loader/arm64/xen_boot.c
>> @@ -67,7 +67,7 @@ typedef enum module_type module_type_t;
>>
>>  struct xen_hypervisor_header
>>  {
>> -  struct grub_arm64_linux_kernel_header efi_head;
>> +  struct grub_linux_kernel_header efi_head;
>>
>>    /* This is always PE\0\0.  */
>>    grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
>> @@ -254,9 +254,9 @@ xen_boot (void)
>>    if (err)
>>      return err;
>>
>> -  return grub_arm64_uefi_boot_image (xen_hypervisor->start,
>> -                                    xen_hypervisor->size,
>> -                                    xen_hypervisor->cmdline);
>> +  return grub_efi_linux_boot_image (xen_hypervisor->start,
>> +                                   xen_hypervisor->size,
>> +                                   xen_hypervisor->cmdline);
>>  }
>>
>>  static void
>> @@ -458,8 +458,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd
>> __attribute__ ((unused)),
>>
>>    if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
>>      goto fail;
>> -  if (grub_arm64_uefi_check_image
>> -      ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
>> +  if (grub_efi_linux_check_image
>> +      ((struct grub_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
>>      goto fail;
>>    grub_file_seek (file, 0);
>>
>> diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
>> index a981df5d1..e53be83b1 100644
>> --- a/include/grub/arm64/linux.h
>> +++ b/include/grub/arm64/linux.h
>> @@ -19,12 +19,10 @@
>>  #ifndef GRUB_LINUX_CPU_HEADER
>>  #define GRUB_LINUX_CPU_HEADER 1
>>
>> -#include <grub/efi/efi.h>
>> -
>> -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
>> +#define GRUB_LINUX_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */
>>
> This doesn't sound arm64-independent.
>
>>
>>  /* From linux/Documentation/arm64/booting.txt */
>> -struct grub_arm64_linux_kernel_header
>> +struct grub_linux_kernel_header
>>  {
>>
> This makes it confusing with x86 counterpart.
>
   grub_uint32_t code0;         /* Executable code */
>>    grub_uint32_t code1;         /* Executable code */
>> @@ -38,9 +36,4 @@ struct grub_arm64_linux_kernel_header
>>    grub_uint32_t hdr_offset;    /* Offset of PE/COFF header */
>>  };
>>
>> -grub_err_t grub_arm64_uefi_check_image (struct
>> grub_arm64_linux_kernel_header
>> -                                        *lh);
>> -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t
>> size,
>> -                                       char *args);
>> -
>>  #endif /* ! GRUB_LINUX_CPU_HEADER */
>> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
>> index a58774efc..149969941 100644
>> --- a/include/grub/efi/efi.h
>> +++ b/include/grub/efi/efi.h
>> @@ -92,6 +92,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
>>  #endif
>>  #if defined(__aarch64__)
>>  grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
>> +#include <grub/cpu/linux.h>
>> +grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header
>> *lh);
>> +grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size,
>> +                                    char *args);
>>  #endif
>>
>>  grub_addr_t grub_efi_modules_addr (void);
>> --
>> 2.11.0
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
>

[-- Attachment #2: Type: text/html, Size: 8232 bytes --]

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

* Re: [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h
  2017-08-03 15:18   ` Vladimir 'phcoder' Serbinenko
@ 2017-08-04  9:11     ` Leif Lindholm
  0 siblings, 0 replies; 39+ messages in thread
From: Leif Lindholm @ 2017-08-04  9:11 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

On Thu, Aug 03, 2017 at 03:18:00PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> This assumes that all CPUs supporting EFI have 4K pages. What if some of
> CPUs have other page sizes?

No, but now you mention it, that used to confuse me too (which is why
I put it in an architecture-specific header originally).

UEFI does not take translation mechanisms into account; a page is
simply an allocation unit - 4kB in size and aligned to 4kB.

I should add a comment explaining this to efi/memory.h.

/
    Leif

> Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a
> écrit :
> 
> > The EFI page definitions and macros are generic and should not be confined
> > to atm64 headers - so move to efi/memory.h.
> > Also add EFI_PAGE_SIZE macro.
> >
> > Update loader sources to reflect new header location.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/loader/arm64/fdt.c      | 1 +
> >  grub-core/loader/arm64/linux.c    | 1 +
> >  grub-core/loader/arm64/xen_boot.c | 1 +
> >  include/grub/arm64/fdtload.h      | 3 ---
> >  include/grub/efi/memory.h         | 4 ++++
> >  5 files changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c
> > index db49cf649..bdc3a0c1f 100644
> > --- a/grub-core/loader/arm64/fdt.c
> > +++ b/grub-core/loader/arm64/fdt.c
> > @@ -24,6 +24,7 @@
> >  #include <grub/command.h>
> >  #include <grub/file.h>
> >  #include <grub/efi/efi.h>
> > +#include <grub/efi/memory.h>
> >
> >  static void *loaded_fdt;
> >  static void *fdt;
> > diff --git a/grub-core/loader/arm64/linux.c
> > b/grub-core/loader/arm64/linux.c
> > index 9519d2e4d..1960d18b5 100644
> > --- a/grub-core/loader/arm64/linux.c
> > +++ b/grub-core/loader/arm64/linux.c
> > @@ -28,6 +28,7 @@
> >  #include <grub/cpu/linux.h>
> >  #include <grub/cpu/fdtload.h>
> >  #include <grub/efi/efi.h>
> > +#include <grub/efi/memory.h>
> >  #include <grub/efi/pe32.h>
> >  #include <grub/i18n.h>
> >  #include <grub/lib/cmdline.h>
> > diff --git a/grub-core/loader/arm64/xen_boot.c
> > b/grub-core/loader/arm64/xen_boot.c
> > index 27ede46ca..b7a5b17c9 100644
> > --- a/grub-core/loader/arm64/xen_boot.c
> > +++ b/grub-core/loader/arm64/xen_boot.c
> > @@ -30,6 +30,7 @@
> >  #include <grub/cpu/fdtload.h>
> >  #include <grub/cpu/linux.h>
> >  #include <grub/efi/efi.h>
> > +#include <grub/efi/memory.h>
> >  #include <grub/efi/pe32.h>     /* required by struct
> > xen_hypervisor_header */
> >  #include <grub/i18n.h>
> >  #include <grub/lib/cmdline.h>
> > diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h
> > index 7b9ddba91..713c9424d 100644
> > --- a/include/grub/arm64/fdtload.h
> > +++ b/include/grub/arm64/fdtload.h
> > @@ -29,7 +29,4 @@ grub_fdt_unload (void);
> >  grub_err_t
> >  grub_fdt_install (void);
> >
> > -#define GRUB_EFI_PAGE_SHIFT    12
> > -#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >>
> > GRUB_EFI_PAGE_SHIFT)
> > -
> >  #endif
> > diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
> > index 20526b146..a113348ca 100644
> > --- a/include/grub/efi/memory.h
> > +++ b/include/grub/efi/memory.h
> > @@ -22,6 +22,10 @@
> >  #include <grub/err.h>
> >  #include <grub/types.h>
> >
> > +#define GRUB_EFI_PAGE_SHIFT             12
> > +#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)
> > +#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >>
> > GRUB_EFI_PAGE_SHIFT)
> > +
> >  #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1
> >
> >  grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t
> > size,
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >

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



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

* Re: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct
  2017-08-03 10:04 ` [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Leif Lindholm
@ 2017-08-07 14:07   ` Vladimir 'phcoder' Serbinenko
  2017-09-04 14:31     ` Leif Lindholm
  0 siblings, 1 reply; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-07 14:07 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 2969 bytes --]

Le Thu, Aug 3, 2017 à 12:15 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> Use kernel header struct and generic magic definition to align with
> arm64/linux loader.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/arm/linux.c | 11 +++++------
>  include/grub/arm/linux.h     | 15 ++++++++++++---
>  2 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
> index e64c79a95..067f69894 100644
> --- a/grub-core/loader/arm/linux.c
> +++ b/grub-core/loader/arm/linux.c
> @@ -46,9 +46,6 @@ static const void *current_fdt;
>
>  typedef void (*kernel_entry_t) (int, unsigned long, void *);
>
> -#define LINUX_ZIMAGE_OFFSET    0x24
> -#define LINUX_ZIMAGE_MAGIC     0x016f2818
> -
>  #define LINUX_PHYS_OFFSET        (0x00008000)
>  #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
>  #define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
> @@ -315,6 +312,7 @@ linux_boot (void)
>  static grub_err_t
>  linux_load (const char *filename, grub_file_t file)
>  {
> +  struct grub_linux_kernel_header *lh;
>    int size;
>
>    size = grub_file_size (file);
> @@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file)
>        return grub_errno;
>      }
>
> -  if (size > LINUX_ZIMAGE_OFFSET + 4
> -      && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
> -      == LINUX_ZIMAGE_MAGIC)
> +  lh = (void *) linux_addr;
> +
> +  if ((grub_size_t) size > sizeof (*lh) &&
> +      lh->magic == GRUB_LINUX_MAGIC_SIGNATURE)
>      ;
>    else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006
>            && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
> diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> index f217f8281..802090239 100644
> --- a/include/grub/arm/linux.h
> +++ b/include/grub/arm/linux.h
> @@ -20,11 +20,20 @@
>  #ifndef GRUB_LINUX_CPU_HEADER
>  #define GRUB_LINUX_CPU_HEADER 1
>
> -#define LINUX_ZIMAGE_OFFSET 0x24
> -#define LINUX_ZIMAGE_MAGIC  0x016f2818
> -
>  #include "system.h"
>
> +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818
> +
> +struct grub_linux_kernel_header {
>
This maz clash with other architectures preventing including several
architecture files in the same file. We need it to create tools like
grub-file .

> +  grub_uint32_t code0;
> +  grub_uint32_t reserved1[8];
> +  grub_uint32_t magic;
> +  grub_uint32_t start; /* _start */
> +  grub_uint32_t end;   /* _edata */
> +  grub_uint32_t reserved2[4];
> +  grub_uint32_t hdr_offset;
> +};
> +
>  #if defined GRUB_MACHINE_UBOOT
>  # include <grub/uboot/uboot.h>
>  # define LINUX_ADDRESS        (start_of_ram + 0x8000)
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 3867 bytes --]

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

* Re: [PATCH v2 11/14] arm/efi: switch to arm64 linux loader
  2017-08-03 10:04 ` [PATCH v2 11/14] arm/efi: switch to arm64 linux loader Leif Lindholm
@ 2017-08-07 14:08   ` Vladimir 'phcoder' Serbinenko
  2017-09-04 14:35     ` Leif Lindholm
  0 siblings, 1 reply; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-07 14:08 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 2645 bytes --]

Le Thu, Aug 3, 2017 à 12:10 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> Switch over to the EFI-stub aware arm64 loader for 32-bit ARM platforms.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/Makefile.core.def | 6 +++---
>  grub-core/kern/efi/mm.c     | 2 +-
>  include/grub/efi/efi.h      | 2 --
>  3 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> index a65c27f7f..87f80d316 100644
> --- a/grub-core/Makefile.core.def
> +++ b/grub-core/Makefile.core.def
> @@ -229,7 +229,6 @@ kernel = {
>    ia64_efi = kern/ia64/cache.c;
>
>    arm_efi = kern/arm/efi/init.c;
> -  arm_efi = kern/arm/efi/misc.c;
>    arm_efi = kern/efi/fdt.c;
>
>    arm64_efi = kern/arm64/efi/init.c;
> @@ -1698,7 +1697,8 @@ module = {
>    powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
>    sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
>    ia64_efi = loader/ia64/efi/linux.c;
> -  arm = loader/arm/linux.c;
> +  arm_uboot = loader/arm/linux.c;
> +  arm_efi = loader/arm64/linux.c;
>
This misses arm-coreboot

>    arm64 = loader/arm64/linux.c;
>    common = loader/linux.c;
>    common = lib/cmdline.c;
> @@ -1707,7 +1707,7 @@ module = {
>
>  module = {
>    name = fdt;
> -  arm64 = loader/efi/fdt.c;
> +  efi = loader/efi/fdt.c;
>    common = lib/fdt.c;
>    enable = fdt;
>  };
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index 1e62eff8f..c8fffe902 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -572,7 +572,7 @@ grub_efi_mm_init (void)
>                        2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
>  }
>
> -#if defined (__aarch64__)
> +#if defined (__aarch64__) || defined (__arm__)
>  grub_err_t
>  grub_efi_get_ram_base(grub_addr_t *base_addr)
>  {
> diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> index 149969941..ec691bd44 100644
> --- a/include/grub/efi/efi.h
> +++ b/include/grub/efi/efi.h
> @@ -89,8 +89,6 @@ extern void (*EXPORT_VAR(grub_efi_net_config))
> (grub_efi_handle_t hnd,
>
>  #if defined(__arm__) || defined(__aarch64__)
>  void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
> -#endif
> -#if defined(__aarch64__)
>  grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
>  #include <grub/cpu/linux.h>
>  grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header
> *lh);
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 3458 bytes --]

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

* Re: [PATCH v2 12/14] arm: delete unused efi support from loader/arm
  2017-08-03 10:04 ` [PATCH v2 12/14] arm: delete unused efi support from loader/arm Leif Lindholm
@ 2017-08-07 14:09   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-07 14:09 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 12655 bytes --]

LGTM

Le Thu, Aug 3, 2017 à 12:11 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> The 32-bit arm efi port now shares the 64-bit linux loader, so delete
> the now unused bits from the 32-bit linux loader.
>
> This in turn leaves the grub-core/kern/arm/efi/misc.c unused, so
> delete that too.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/Makefile.am         |   1 -
>  grub-core/kern/arm/efi/misc.c | 202
> ------------------------------------------
>  grub-core/loader/arm/linux.c  |  28 ------
>  include/grub/arm/efi/loader.h |  26 ------
>  include/grub/arm/linux.h      |  16 ----
>  5 files changed, 273 deletions(-)
>  delete mode 100644 grub-core/kern/arm/efi/misc.c
>  delete mode 100644 include/grub/arm/efi/loader.h
>
> diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
> index 622f946f5..cd3424c07 100644
> --- a/grub-core/Makefile.am
> +++ b/grub-core/Makefile.am
> @@ -256,7 +256,6 @@ KERNEL_HEADER_FILES +=
> $(top_srcdir)/include/grub/fdtbus.h
>  endif
>
>  if COND_arm_efi
> -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
>  KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
>  KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
>  KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
> diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c
> deleted file mode 100644
> index 7cd41842a..000000000
> --- a/grub-core/kern/arm/efi/misc.c
> +++ /dev/null
> @@ -1,202 +0,0 @@
> -/* misc.c - various system functions for an arm-based EFI system */
> -/*
> - *  GRUB  --  GRand Unified Bootloader
> - *  Copyright (C) 2013 Free Software Foundation, Inc.
> - *
> - *  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 <grub/misc.h>
> -#include <grub/mm.h>
> -#include <grub/cpu/linux.h>
> -#include <grub/cpu/system.h>
> -#include <grub/efi/efi.h>
> -#include <grub/machine/loader.h>
> -
> -static inline grub_size_t
> -page_align (grub_size_t size)
> -{
> -  return (size + (1 << 12) - 1) & (~((1 << 12) - 1));
> -}
> -
> -/* Find the optimal number of pages for the memory map. Is it better to
> -   move this code to efi/mm.c?  */
> -static grub_efi_uintn_t
> -find_mmap_size (void)
> -{
> -  static grub_efi_uintn_t mmap_size = 0;
> -
> -  if (mmap_size != 0)
> -    return mmap_size;
> -
> -  mmap_size = (1 << 12);
> -  while (1)
> -    {
> -      int ret;
> -      grub_efi_memory_descriptor_t *mmap;
> -      grub_efi_uintn_t desc_size;
> -
> -      mmap = grub_malloc (mmap_size);
> -      if (! mmap)
> -       return 0;
> -
> -      ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0);
> -      grub_free (mmap);
> -
> -      if (ret < 0)
> -       {
> -         grub_error (GRUB_ERR_IO, "cannot get memory map");
> -         return 0;
> -       }
> -      else if (ret > 0)
> -       break;
> -
> -      mmap_size += (1 << 12);
> -    }
> -
> -  /* Increase the size a bit for safety, because GRUB allocates more on
> -     later, and EFI itself may allocate more.  */
> -  mmap_size += (1 << 12);
> -
> -  return page_align (mmap_size);
> -}
> -
> -#define NEXT_MEMORY_DESCRIPTOR(desc, size)      \
> -  ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
> -#define PAGE_SHIFT 12
> -
> -void *
> -grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t
> size)
> -{
> -  grub_efi_uintn_t desc_size;
> -  grub_efi_memory_descriptor_t *mmap, *mmap_end;
> -  grub_efi_uintn_t mmap_size, tmp_mmap_size;
> -  grub_efi_memory_descriptor_t *desc;
> -  void *mem = NULL;
> -  grub_addr_t min_start = 0;
> -
> -  mmap_size = find_mmap_size();
> -  if (!mmap_size)
> -    return NULL;
> -
> -  mmap = grub_malloc(mmap_size);
> -  if (!mmap)
> -    return NULL;
> -
> -  tmp_mmap_size = mmap_size;
> -  if (grub_efi_get_memory_map (&tmp_mmap_size, mmap, 0, &desc_size, 0) <=
> 0)
> -    {
> -      grub_error (GRUB_ERR_IO, "cannot get memory map");
> -      goto fail;
> -    }
> -
> -  mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size);
> -  /* Find lowest accessible RAM location */
> -  {
> -    int found = 0;
> -    for (desc = mmap ; !found && (desc < mmap_end) ;
> -        desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size))
> -      {
> -       switch (desc->type)
> -         {
> -         case GRUB_EFI_CONVENTIONAL_MEMORY:
> -         case GRUB_EFI_LOADER_CODE:
> -         case GRUB_EFI_LOADER_DATA:
> -           min_start = desc->physical_start + min_offset;
> -           found = 1;
> -           break;
> -         default:
> -           break;
> -         }
> -      }
> -  }
> -
> -  /* First, find free pages for the real mode code
> -     and the memory map buffer.  */
> -  for (desc = mmap ; desc < mmap_end ;
> -       desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size))
> -    {
> -      grub_uint64_t start, end;
> -
> -      grub_dprintf("mm", "%s: 0x%08x bytes @ 0x%08x\n",
> -                  __FUNCTION__,
> -                  (grub_uint32_t) (desc->num_pages << PAGE_SHIFT),
> -                  (grub_uint32_t) (desc->physical_start));
> -
> -      if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY)
> -       continue;
> -
> -      start = desc->physical_start;
> -      end = start + (desc->num_pages << PAGE_SHIFT);
> -      grub_dprintf("mm", "%s: start=0x%016llx, end=0x%016llx\n",
> -                 __FUNCTION__, start, end);
> -      start = start < min_start ? min_start : start;
> -      if (start + size > end)
> -       continue;
> -      grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @
> 0x%08x...\n",
> -                 __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start);
> -      mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1);
> -      grub_dprintf("mm", "%s: retval=0x%08x\n",
> -                  __FUNCTION__, (grub_addr_t) mem);
> -      if (! mem)
> -       {
> -         grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
> -         goto fail;
> -       }
> -      break;
> -    }
> -
> -  if (! mem)
> -    {
> -      grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory");
> -      goto fail;
> -    }
> -
> -  grub_free (mmap);
> -  return mem;
> -
> - fail:
> -  grub_free (mmap);
> -  return NULL;
> -}
> -
> -grub_err_t
> -grub_efi_prepare_platform (void)
> -{
> -  grub_efi_uintn_t mmap_size;
> -  grub_efi_uintn_t map_key;
> -  grub_efi_uintn_t desc_size;
> -  grub_efi_uint32_t desc_version;
> -  grub_efi_memory_descriptor_t *mmap_buf;
> -  grub_err_t err;
> -
> -  /*
> -   * Cloned from IA64
> -   * Must be done after grub_machine_fini because map_key is used by
> -   *exit_boot_services.
> -   */
> -  mmap_size = find_mmap_size ();
> -  if (! mmap_size)
> -    return GRUB_ERR_OUT_OF_MEMORY;
> -  mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12);
> -  if (! mmap_buf)
> -    return GRUB_ERR_OUT_OF_MEMORY;
> -
> -  err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key,
> -                                      &desc_size, &desc_version);
> -  if (err != GRUB_ERR_NONE)
> -    return err;
> -
> -  return GRUB_ERR_NONE;
> -}
> diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
> index 067f69894..e563eca95 100644
> --- a/grub-core/loader/arm/linux.c
> +++ b/grub-core/loader/arm/linux.c
> @@ -290,15 +290,6 @@ linux_boot (void)
>     */
>    linuxmain = (kernel_entry_t) linux_addr;
>
> -#ifdef GRUB_MACHINE_EFI
> -  {
> -    grub_err_t err;
> -    err = grub_efi_prepare_platform();
> -    if (err != GRUB_ERR_NONE)
> -      return err;
> -  }
> -#endif
> -
>    grub_arm_disable_caches_mmu ();
>
>    linuxmain (0, machine_type, target_fdt);
> @@ -317,13 +308,7 @@ linux_load (const char *filename, grub_file_t file)
>
>    size = grub_file_size (file);
>
> -#ifdef GRUB_MACHINE_EFI
> -  linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory
> (LINUX_PHYS_OFFSET, size);
> -  if (!linux_addr)
> -    return grub_errno;
> -#else
>    linux_addr = LINUX_ADDRESS;
> -#endif
>    grub_dprintf ("loader", "Loading Linux to 0x%08x\n",
>                 (grub_addr_t) linux_addr);
>
> @@ -428,20 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__
> ((unused)),
>
>    size = grub_get_initrd_size (&initrd_ctx);
>
> -#ifdef GRUB_MACHINE_EFI
> -  if (initrd_start)
> -    grub_efi_free_pages (initrd_start,
> -                        (initrd_end - initrd_start + 0xfff) >> 12);
> -  initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory
> (LINUX_INITRD_PHYS_OFFSET, size);
> -
> -  if (!initrd_start)
> -    {
> -      grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
> -      goto fail;
> -    }
> -#else
>    initrd_start = LINUX_INITRD_ADDRESS;
> -#endif
>
>    grub_dprintf ("loader", "Loading initrd to 0x%08x\n",
>                 (grub_addr_t) initrd_start);
> diff --git a/include/grub/arm/efi/loader.h b/include/grub/arm/efi/loader.h
> deleted file mode 100644
> index 4bab18e83..000000000
> --- a/include/grub/arm/efi/loader.h
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/*
> - *  GRUB  --  GRand Unified Bootloader
> - *  Copyright (C) 2013  Free Software Foundation, Inc.
> - *
> - *  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/>.
> - */
> -
> -#ifndef GRUB_LOADER_MACHINE_HEADER
> -#define GRUB_LOADER_MACHINE_HEADER     1
> -
> -grub_err_t EXPORT_FUNC (grub_efi_prepare_platform) (void);
> -void * EXPORT_FUNC (grub_efi_allocate_loader_memory) (grub_uint32_t
> min_offset,
> -                                                     grub_uint32_t size);
> -
> -#endif /* ! GRUB_LOADER_MACHINE_HEADER */
> diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> index 802090239..758e97d72 100644
> --- a/include/grub/arm/linux.h
> +++ b/include/grub/arm/linux.h
> @@ -41,20 +41,6 @@ struct grub_linux_kernel_header {
>  # define LINUX_FDT_ADDRESS    (LINUX_INITRD_ADDRESS - 0x10000)
>  # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data
>  # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type
> -#elif defined GRUB_MACHINE_EFI
> -# include <grub/efi/efi.h>
> -# include <grub/machine/loader.h>
> -/* On UEFI platforms - load the images at the lowest available address not
> -   less than *_PHYS_OFFSET from the first available memory location. */
> -# define LINUX_PHYS_OFFSET        (0x00008000)
> -# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
> -# define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
> -# define grub_arm_firmware_get_boot_data
> (grub_addr_t)grub_efi_get_firmware_fdt
> -static inline grub_uint32_t
> -grub_arm_firmware_get_machine_type (void)
> -{
> -  return GRUB_ARM_MACHINE_TYPE_FDT;
> -}
>  #elif defined (GRUB_MACHINE_COREBOOT)
>  #include <grub/fdtbus.h>
>  #include <grub/machine/kernel.h>
> @@ -73,6 +59,4 @@ grub_arm_firmware_get_machine_type (void)
>  }
>  #endif
>
> -#define FDT_ADDITIONAL_ENTRIES_SIZE    0x300
> -
>  #endif /* ! GRUB_LINUX_CPU_HEADER */
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 14952 bytes --]

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

* Re: [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement
  2017-08-03 10:04 ` [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement Leif Lindholm
@ 2017-08-07 14:10   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-07 14:10 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]

LGTM

Le Thu, Aug 3, 2017 à 12:15 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> The 32-bit arm Linux kernel is built as a zImage, which self-decompresses
> down to near start of RAM. In order for an initrd/initramfs to be
> accessible, it needs to be placed within the first ~768MB of RAM.
> The initrd loader built into the kernel EFI stub restricts this down to
> 512MB for simplicity - so enable the same restriction in grub.
>
> For arm64, the requirement is within a 1GB aligned 32GB window also
> covering the (runtime) kernel image. Since the EFI stub loader itself
> will attempt to relocate to near start of RAM, force initrd to be loaded
> completely within the first 32GB of RAM.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/loader/arm64/linux.c | 39
> ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/grub-core/loader/arm64/linux.c
> b/grub-core/loader/arm64/linux.c
> index 8cd44230d..a96019a3b 100644
> --- a/grub-core/loader/arm64/linux.c
> +++ b/grub-core/loader/arm64/linux.c
> @@ -194,6 +194,42 @@ grub_linux_unload (void)
>    return GRUB_ERR_NONE;
>  }
>
> +/*
> + * This function returns a pointer to a legally allocated initrd buffer,
> + * or NULL if unsuccessful
> + */
> +static void *
> +allocate_initrd_mem (int initrd_pages)
> +{
> +  grub_addr_t max_addr;
> +
> +  if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE)
> +    return NULL;
> +
> +  /*
> +   * As per linux/Documentation/arm/Booting
> +   * ARM initrd needs to be covered by kernel linear mapping,
> +   * so place it in the first 512MB of DRAM.
> +   *
> +   * As per linux/Documentation/arm64/booting.txt
> +   * ARM64 initrd needs to be contained entirely within a 1GB aligned
> window
> +   * of up to 32GB of size that covers the kernel image as well.
> +   * Since the EFI stub loader will attempt to load the kernel near start
> of
> +   * RAM, place the buffer in the first 32GB of RAM.
> +   */
> +#ifdef __arm__
> +#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024)
> +#else /* __aarch64__ */
> +#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024)
> +#endif
> +
> +  max_addr += INITRD_MAX_ADDRESS_OFFSET - 1;
> +
> +  return grub_efi_allocate_pages_real (max_addr, initrd_pages,
> +                                      GRUB_EFI_ALLOCATE_MAX_ADDRESS,
> +                                      GRUB_EFI_LOADER_DATA);
> +}
> +
>  static grub_err_t
>  grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
>                  int argc, char *argv[])
> @@ -222,7 +258,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__
> ((unused)),
>    grub_dprintf ("linux", "Loading initrd\n");
>
>    initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size));
> -  initrd_mem = grub_efi_allocate_pages (0, initrd_pages);
> +  initrd_mem = allocate_initrd_mem (initrd_pages);
> +
>    if (!initrd_mem)
>      {
>        grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 4004 bytes --]

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

* Re: [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE
  2017-08-03 10:04 ` [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Leif Lindholm
@ 2017-08-07 14:11   ` Vladimir 'phcoder' Serbinenko
  2017-08-07 16:18     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-07 14:11 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]

LGTM

Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
> not return regions with execute ability. Since modules are loaded onto
> the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
> order to permit execution on systems with this feature enabled.
>
> Closes: 50420
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
>  grub-core/kern/efi/mm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index c8fffe902..f1424f2e4 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -448,7 +448,9 @@ add_memory_regions (grub_efi_memory_descriptor_t
> *memory_map,
>           pages = required_pages;
>         }
>
> -      addr = grub_efi_allocate_pages (start, pages);
> +      addr = grub_efi_allocate_pages_real (start, pages,
> +                                          GRUB_EFI_ALLOCATE_ADDRESS,
> +                                          GRUB_EFI_LOADER_CODE);
>        if (! addr)
>         grub_fatal ("cannot allocate conventional memory %p with %u pages",
>                     (void *) ((grub_addr_t) start),
> --
> 2.11.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 2090 bytes --]

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

* Re: [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE
  2017-08-07 14:11   ` Vladimir 'phcoder' Serbinenko
@ 2017-08-07 16:18     ` Konrad Rzeszutek Wilk
  2017-08-07 16:22       ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 39+ messages in thread
From: Konrad Rzeszutek Wilk @ 2017-08-07 16:18 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

On Mon, Aug 07, 2017 at 02:11:16PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> LGTM

Is LGTM equivalant to Acked-by?

> 
> Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <leif.lindholm@linaro.org> a
> écrit :
> 
> > With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
> > not return regions with execute ability. Since modules are loaded onto
> > the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
> > order to permit execution on systems with this feature enabled.
> >
> > Closes: 50420
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/kern/efi/mm.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> > index c8fffe902..f1424f2e4 100644
> > --- a/grub-core/kern/efi/mm.c
> > +++ b/grub-core/kern/efi/mm.c
> > @@ -448,7 +448,9 @@ add_memory_regions (grub_efi_memory_descriptor_t
> > *memory_map,
> >           pages = required_pages;
> >         }
> >
> > -      addr = grub_efi_allocate_pages (start, pages);
> > +      addr = grub_efi_allocate_pages_real (start, pages,
> > +                                          GRUB_EFI_ALLOCATE_ADDRESS,
> > +                                          GRUB_EFI_LOADER_CODE);
> >        if (! addr)
> >         grub_fatal ("cannot allocate conventional memory %p with %u pages",
> >                     (void *) ((grub_addr_t) start),
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >

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



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

* Re: [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE
  2017-08-07 16:18     ` Konrad Rzeszutek Wilk
@ 2017-08-07 16:22       ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-08-07 16:22 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]

It means that the patch is fine but something else stops it from being
committed. In this case I wanted to go through the whole stack first

Le Mon, Aug 7, 2017 à 6:19 PM, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
a écrit :

> On Mon, Aug 07, 2017 at 02:11:16PM +0000, Vladimir 'phcoder' Serbinenko
> wrote:
> > LGTM
>
> Is LGTM equivalant to Acked-by?
>
> >
> > Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <leif.lindholm@linaro.org>
> a
> > écrit :
> >
> > > With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
> > > not return regions with execute ability. Since modules are loaded onto
> > > the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
> > > order to permit execution on systems with this feature enabled.
> > >
> > > Closes: 50420
> > >
> > > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > > ---
> > >  grub-core/kern/efi/mm.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> > > index c8fffe902..f1424f2e4 100644
> > > --- a/grub-core/kern/efi/mm.c
> > > +++ b/grub-core/kern/efi/mm.c
> > > @@ -448,7 +448,9 @@ add_memory_regions (grub_efi_memory_descriptor_t
> > > *memory_map,
> > >           pages = required_pages;
> > >         }
> > >
> > > -      addr = grub_efi_allocate_pages (start, pages);
> > > +      addr = grub_efi_allocate_pages_real (start, pages,
> > > +                                          GRUB_EFI_ALLOCATE_ADDRESS,
> > > +                                          GRUB_EFI_LOADER_CODE);
> > >        if (! addr)
> > >         grub_fatal ("cannot allocate conventional memory %p with %u
> pages",
> > >                     (void *) ((grub_addr_t) start),
> > > --
> > > 2.11.0
> > >
> > >
> > > _______________________________________________
> > > Grub-devel mailing list
> > > Grub-devel@gnu.org
> > > https://lists.gnu.org/mailman/listinfo/grub-devel
> > >
>
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 3621 bytes --]

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

* Re: [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size
  2017-08-03 15:19   ` Vladimir 'phcoder' Serbinenko
@ 2017-08-08 15:56     ` Leif Lindholm
  0 siblings, 0 replies; 39+ messages in thread
From: Leif Lindholm @ 2017-08-08 15:56 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

On Thu, Aug 03, 2017 at 03:19:25PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> Looks good. But out of context the name is not descriptive enough. Can we
> add a comment near declaration to clarify what this functions is for?

Sure - will do.

/
    Leif

> Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a
> écrit :
> 
> > There are several implementations of this function in the tree.
> > Add a central version in grub-core/efi/mm.c.
> >
> > Taken from grub-core/loader/i386/linux.c, changing some hard-coded
> > constants
> > to use macros from efi/memory.h.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/kern/efi/mm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> >  include/grub/efi/efi.h  |  1 +
> >  2 files changed, 45 insertions(+)
> >
> > diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> > index 20a47aaf5..31ca703ec 100644
> > --- a/grub-core/kern/efi/mm.c
> > +++ b/grub-core/kern/efi/mm.c
> > @@ -217,6 +217,50 @@ grub_efi_finish_boot_services (grub_efi_uintn_t
> > *outbuf_size, void *outbuf,
> >    return GRUB_ERR_NONE;
> >  }
> >
> > +grub_efi_uintn_t
> > +grub_efi_find_mmap_size (void)
> > +{
> > +  static grub_efi_uintn_t mmap_size = 0;
> > +
> > +  if (mmap_size != 0)
> > +    return mmap_size;
> > +
> > +  mmap_size = 1 * GRUB_EFI_PAGE_SIZE;
> > +  while (1)
> > +    {
> > +      int ret;
> > +      grub_efi_memory_descriptor_t *mmap;
> > +      grub_efi_uintn_t desc_size;
> > +      grub_efi_uintn_t cur_mmap_size = mmap_size;
> > +
> > +      mmap = grub_malloc (cur_mmap_size);
> > +      if (! mmap)
> > +       return 0;
> > +
> > +      ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size,
> > 0);
> > +      grub_free (mmap);
> > +
> > +      if (ret < 0)
> > +       {
> > +         grub_error (GRUB_ERR_IO, "cannot get memory map");
> > +         return 0;
> > +       }
> > +      else if (ret > 0)
> > +       break;
> > +
> > +      if (mmap_size < cur_mmap_size)
> > +       mmap_size = cur_mmap_size;
> > +      mmap_size += GRUB_EFI_PAGE_SIZE;
> > +    }
> > +
> > +  /* Increase the size a bit for safety, because GRUB allocates more on
> > +     later, and EFI itself may allocate more.  */
> > +  mmap_size += 3 * GRUB_EFI_PAGE_SIZE;
> > +
> > +  mmap_size = ALIGN_UP (mmap_size, GRUB_EFI_PAGE_SIZE);
> > +  return mmap_size;
> > +}
> > +
> >  /* Get the memory map as defined in the EFI spec. Return 1 if successful,
> >     return 0 if partial, or return -1 if an error occurs.  */
> >  int
> > diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> > index e9c601f34..3984de083 100644
> > --- a/include/grub/efi/efi.h
> > +++ b/include/grub/efi/efi.h
> > @@ -42,6 +42,7 @@ EXPORT_FUNC(grub_efi_allocate_pages)
> > (grub_efi_physical_address_t address,
> >                                       grub_efi_uintn_t pages);
> >  void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t
> > address,
> >                                        grub_efi_uintn_t pages);
> > +grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void);
> >  int
> >  EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
> >                                       grub_efi_memory_descriptor_t
> > *memory_map,
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >

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



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

* Re: [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm*
  2017-08-03 15:30   ` Vladimir 'phcoder' Serbinenko
@ 2017-08-08 16:04     ` Leif Lindholm
  0 siblings, 0 replies; 39+ messages in thread
From: Leif Lindholm @ 2017-08-08 16:04 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

On Thu, Aug 03, 2017 at 03:30:40PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> Any reason to use plain error numbers without grub_error?

Well, no.

In the way I'm using it, it will cascade down to a
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
on failure.

Do we need a specific one for "unable to determine memory start address"?
Or is there an existing error string we could reuse?

/
    Leif

> Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <leif.lindholm@linaro.org> a
> écrit :
> 
> > Since ARM platforms do not have a common memory map, add a helper
> > function that finds the lowest address region with the EFI_MEMORY_WB
> > attribute set in the UEFI memory map.
> >
> > Required for the arm/arm64 linux loader to restrict the initrd
> > location to where it will be accessible by the kernel at runtime.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++
> >  include/grub/efi/efi.h  |  3 +++
> >  2 files changed, 39 insertions(+)
> >
> > diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> > index 31ca703ec..8413c19e5 100644
> > --- a/grub-core/kern/efi/mm.c
> > +++ b/grub-core/kern/efi/mm.c
> > @@ -569,3 +569,39 @@ grub_efi_mm_init (void)
> >    grub_efi_free_pages ((grub_addr_t) memory_map,
> >                        2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
> >  }
> > +
> > +#if defined (__aarch64__)
> > +grub_err_t
> > +grub_efi_get_ram_base(grub_addr_t *base_addr)
> > +{
> > +  grub_efi_memory_descriptor_t *memory_map;
> > +  grub_efi_memory_descriptor_t *desc;
> > +  grub_efi_uintn_t mmap_size;
> > +  grub_efi_uintn_t desc_size;
> > +  int ret;
> > +
> > +  mmap_size = grub_efi_find_mmap_size();
> > +
> > +  memory_map = grub_malloc (mmap_size);
> > +  if (! memory_map)
> > +    return GRUB_ERR_OUT_OF_MEMORY;
> > +  ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL,
> > +                                &desc_size, NULL);
> > +
> > +  if (ret < 1)
> > +    return GRUB_ERR_BUG;
> > +
> > +  for (desc = memory_map, *base_addr = GRUB_UINT_MAX;
> > +       (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size);
> > +       desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
> > +    {
> > +      if (desc->attribute & GRUB_EFI_MEMORY_WB)
> > +       if (desc->physical_start < *base_addr)
> > +         *base_addr = desc->physical_start;
> > +    }
> > +
> > +  grub_free(memory_map);
> > +
> > +  return GRUB_ERR_NONE;
> > +}
> > +#endif
> > diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> > index 3984de083..80ab56795 100644
> > --- a/include/grub/efi/efi.h
> > +++ b/include/grub/efi/efi.h
> > @@ -85,6 +85,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config))
> > (grub_efi_handle_t hnd,
> >  #if defined(__arm__) || defined(__aarch64__)
> >  void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
> >  #endif
> > +#if defined(__aarch64__)
> > +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
> > +#endif
> >
> >  grub_addr_t grub_efi_modules_addr (void);
> >
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >

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



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

* Re: [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers
  2017-08-03 16:44   ` Vladimir 'phcoder' Serbinenko
  2017-08-03 16:46     ` Vladimir 'phcoder' Serbinenko
@ 2017-09-04 14:29     ` Leif Lindholm
  1 sibling, 0 replies; 39+ messages in thread
From: Leif Lindholm @ 2017-09-04 14:29 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: Daniel Kiper, Vladimir 'φ-coder/phcoder' Serbinenko

On Thu, Aug 03, 2017 at 04:44:28PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> On Thu, Aug 3, 2017, 12:14 Leif Lindholm <leif.lindholm@linaro.org> wrote:
> 
> > In preparation for using the linux loader for 32-bit and 64-bit platforms,
> > rename
> > grub_arm64*/GRUB_ARM64* to grub_efi*/GRUB_EFI*.
> >
> > Move prototypes for now-common functions to efi/efi.h.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/loader/arm64/linux.c    | 14 +++++++-------
> >  grub-core/loader/arm64/xen_boot.c | 12 ++++++------
> >  include/grub/arm64/linux.h        | 11 ++---------
> >  include/grub/efi/efi.h            |  4 ++++
> >  4 files changed, 19 insertions(+), 22 deletions(-)
> >
> > diff --git a/grub-core/loader/arm64/linux.c
> > b/grub-core/loader/arm64/linux.c
> > index c60469e53..8cd44230d 100644
> > --- a/grub-core/loader/arm64/linux.c
> > +++ b/grub-core/loader/arm64/linux.c
> > @@ -48,9 +48,9 @@ static grub_addr_t initrd_start;
> >  static grub_addr_t initrd_end;
> >
> >  grub_err_t
> > -grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
> > +grub_efi_linux_check_image (struct grub_linux_kernel_header * lh)
> >  {
> > -  if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
> > +  if (lh->magic != GRUB_LINUX_MAGIC_SIGNATURE)
> >      return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
> >
> >    if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC)
> > @@ -109,7 +109,7 @@ failure:
> >  }
> >
> >  grub_err_t
> > -grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char
> > *args)
> > +grub_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
> >  {
> >    grub_efi_memory_mapped_device_path_t *mempath;
> >    grub_efi_handle_t image_handle;
> > @@ -173,8 +173,8 @@ grub_linux_boot (void)
> >    if (finalize_params_linux () != GRUB_ERR_NONE)
> >      return grub_errno;
> >
> > -  return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr,
> > -                                     kernel_size, linux_args));
> > +  return (grub_efi_linux_boot_image((grub_addr_t)kernel_addr,
> > +                                    kernel_size, linux_args));
> >  }
> >
> >  static grub_err_t
> > @@ -250,7 +250,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__
> > ((unused)),
> >                 int argc, char *argv[])
> >  {
> >    grub_file_t file = 0;
> > -  struct grub_arm64_linux_kernel_header lh;
> > +  struct grub_linux_kernel_header lh;
> >
> >    grub_dl_ref (my_mod);
> >
> > @@ -269,7 +269,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__
> > ((unused)),
> >    if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
> >      return grub_errno;
> >
> > -  if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE)
> > +  if (grub_efi_linux_check_image (&lh) != GRUB_ERR_NONE)
> >      goto fail;
> >
> >    grub_loader_unset();
> > diff --git a/grub-core/loader/arm64/xen_boot.c
> > b/grub-core/loader/arm64/xen_boot.c
> > index d092a53ed..e8720584b 100644
> > --- a/grub-core/loader/arm64/xen_boot.c
> > +++ b/grub-core/loader/arm64/xen_boot.c
> > @@ -67,7 +67,7 @@ typedef enum module_type module_type_t;
> >
> >  struct xen_hypervisor_header
> >  {
> > -  struct grub_arm64_linux_kernel_header efi_head;
> > +  struct grub_linux_kernel_header efi_head;
> >
> >    /* This is always PE\0\0.  */
> >    grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
> > @@ -254,9 +254,9 @@ xen_boot (void)
> >    if (err)
> >      return err;
> >
> > -  return grub_arm64_uefi_boot_image (xen_hypervisor->start,
> > -                                    xen_hypervisor->size,
> > -                                    xen_hypervisor->cmdline);
> > +  return grub_efi_linux_boot_image (xen_hypervisor->start,
> > +                                   xen_hypervisor->size,
> > +                                   xen_hypervisor->cmdline);
> >  }
> >
> >  static void
> > @@ -458,8 +458,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd
> > __attribute__ ((unused)),
> >
> >    if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
> >      goto fail;
> > -  if (grub_arm64_uefi_check_image
> > -      ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
> > +  if (grub_efi_linux_check_image
> > +      ((struct grub_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
> >      goto fail;
> >    grub_file_seek (file, 0);
> >
> > diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
> > index a981df5d1..e53be83b1 100644
> > --- a/include/grub/arm64/linux.h
> > +++ b/include/grub/arm64/linux.h
> > @@ -19,12 +19,10 @@
> >  #ifndef GRUB_LINUX_CPU_HEADER
> >  #define GRUB_LINUX_CPU_HEADER 1
> >
> > -#include <grub/efi/efi.h>
> > -
> > -#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
> > +#define GRUB_LINUX_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */
> >
> This doesn't sound arm64-independent.

No more then the x86 versions are?
The intent was to reuse a common name across architectures, with
architecture-specific content.

That was my interpretation of the i386 definition.
Are you suggesting that that too should be renamed?

> >
> >  /* From linux/Documentation/arm64/booting.txt */
> > -struct grub_arm64_linux_kernel_header
> > +struct grub_linux_kernel_header
> >  {
> >
> This makes it confusing with x86 counterpart.

If it is meant to be an x86-specific struct, why does it have an
architecture-independent sounding name?

/
    Leif

> >    grub_uint32_t code0;         /* Executable code */
> >    grub_uint32_t code1;         /* Executable code */
> > @@ -38,9 +36,4 @@ struct grub_arm64_linux_kernel_header
> >    grub_uint32_t hdr_offset;    /* Offset of PE/COFF header */
> >  };
> >
> > -grub_err_t grub_arm64_uefi_check_image (struct
> > grub_arm64_linux_kernel_header
> > -                                        *lh);
> > -grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size,
> > -                                       char *args);
> > -
> >  #endif /* ! GRUB_LINUX_CPU_HEADER */
> > diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> > index a58774efc..149969941 100644
> > --- a/include/grub/efi/efi.h
> > +++ b/include/grub/efi/efi.h
> > @@ -92,6 +92,10 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
> >  #endif
> >  #if defined(__aarch64__)
> >  grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
> > +#include <grub/cpu/linux.h>
> > +grub_err_t grub_efi_linux_check_image(struct grub_linux_kernel_header
> > *lh);
> > +grub_err_t grub_efi_linux_boot_image(grub_addr_t addr, grub_size_t size,
> > +                                    char *args);
> >  #endif
> >
> >  grub_addr_t grub_efi_modules_addr (void);
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >

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



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

* Re: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct
  2017-08-07 14:07   ` Vladimir 'phcoder' Serbinenko
@ 2017-09-04 14:31     ` Leif Lindholm
  2017-09-04 14:35       ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 39+ messages in thread
From: Leif Lindholm @ 2017-09-04 14:31 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: Daniel Kiper, Vladimir 'φ-coder/phcoder' Serbinenko

On Mon, Aug 07, 2017 at 02:07:19PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> Le Thu, Aug 3, 2017 à 12:15 PM, Leif Lindholm <leif.lindholm@linaro.org> a
> écrit :
> 
> > Use kernel header struct and generic magic definition to align with
> > arm64/linux loader.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/loader/arm/linux.c | 11 +++++------
> >  include/grub/arm/linux.h     | 15 ++++++++++++---
> >  2 files changed, 17 insertions(+), 9 deletions(-)
> >
> > diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
> > index e64c79a95..067f69894 100644
> > --- a/grub-core/loader/arm/linux.c
> > +++ b/grub-core/loader/arm/linux.c
> > @@ -46,9 +46,6 @@ static const void *current_fdt;
> >
> >  typedef void (*kernel_entry_t) (int, unsigned long, void *);
> >
> > -#define LINUX_ZIMAGE_OFFSET    0x24
> > -#define LINUX_ZIMAGE_MAGIC     0x016f2818
> > -
> >  #define LINUX_PHYS_OFFSET        (0x00008000)
> >  #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
> >  #define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
> > @@ -315,6 +312,7 @@ linux_boot (void)
> >  static grub_err_t
> >  linux_load (const char *filename, grub_file_t file)
> >  {
> > +  struct grub_linux_kernel_header *lh;
> >    int size;
> >
> >    size = grub_file_size (file);
> > @@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t file)
> >        return grub_errno;
> >      }
> >
> > -  if (size > LINUX_ZIMAGE_OFFSET + 4
> > -      && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
> > -      == LINUX_ZIMAGE_MAGIC)
> > +  lh = (void *) linux_addr;
> > +
> > +  if ((grub_size_t) size > sizeof (*lh) &&
> > +      lh->magic == GRUB_LINUX_MAGIC_SIGNATURE)
> >      ;
> >    else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006
> >            && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
> > diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> > index f217f8281..802090239 100644
> > --- a/include/grub/arm/linux.h
> > +++ b/include/grub/arm/linux.h
> > @@ -20,11 +20,20 @@
> >  #ifndef GRUB_LINUX_CPU_HEADER
> >  #define GRUB_LINUX_CPU_HEADER 1
> >
> > -#define LINUX_ZIMAGE_OFFSET 0x24
> > -#define LINUX_ZIMAGE_MAGIC  0x016f2818
> > -
> >  #include "system.h"
> >
> > +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818
> > +
> > +struct grub_linux_kernel_header {
> >
> This maz clash with other architectures preventing including several
> architecture files in the same file. We need it to create tools like
> grub-file .

Right, then I do need to inject some patches renaming this struct and
signature on x86 too.

/
    Leif

> > +  grub_uint32_t code0;
> > +  grub_uint32_t reserved1[8];
> > +  grub_uint32_t magic;
> > +  grub_uint32_t start; /* _start */
> > +  grub_uint32_t end;   /* _edata */
> > +  grub_uint32_t reserved2[4];
> > +  grub_uint32_t hdr_offset;
> > +};
> > +
> >  #if defined GRUB_MACHINE_UBOOT
> >  # include <grub/uboot/uboot.h>
> >  # define LINUX_ADDRESS        (start_of_ram + 0x8000)
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >

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



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

* Re: [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct
  2017-09-04 14:31     ` Leif Lindholm
@ 2017-09-04 14:35       ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 39+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-09-04 14:35 UTC (permalink / raw)
  To: Leif Lindholm, The development of GNU GRUB; +Cc: Daniel Kiper

[-- Attachment #1: Type: text/plain, Size: 3809 bytes --]

Great, thanks!

On Mon, Sep 4, 2017, 16:31 Leif Lindholm <leif.lindholm@linaro.org> wrote:

> On Mon, Aug 07, 2017 at 02:07:19PM +0000, Vladimir 'phcoder' Serbinenko
> wrote:
> > Le Thu, Aug 3, 2017 à 12:15 PM, Leif Lindholm <leif.lindholm@linaro.org>
> a
> > écrit :
> >
> > > Use kernel header struct and generic magic definition to align with
> > > arm64/linux loader.
> > >
> > > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > > ---
> > >  grub-core/loader/arm/linux.c | 11 +++++------
> > >  include/grub/arm/linux.h     | 15 ++++++++++++---
> > >  2 files changed, 17 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/grub-core/loader/arm/linux.c
> b/grub-core/loader/arm/linux.c
> > > index e64c79a95..067f69894 100644
> > > --- a/grub-core/loader/arm/linux.c
> > > +++ b/grub-core/loader/arm/linux.c
> > > @@ -46,9 +46,6 @@ static const void *current_fdt;
> > >
> > >  typedef void (*kernel_entry_t) (int, unsigned long, void *);
> > >
> > > -#define LINUX_ZIMAGE_OFFSET    0x24
> > > -#define LINUX_ZIMAGE_MAGIC     0x016f2818
> > > -
> > >  #define LINUX_PHYS_OFFSET        (0x00008000)
> > >  #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
> > >  #define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
> > > @@ -315,6 +312,7 @@ linux_boot (void)
> > >  static grub_err_t
> > >  linux_load (const char *filename, grub_file_t file)
> > >  {
> > > +  struct grub_linux_kernel_header *lh;
> > >    int size;
> > >
> > >    size = grub_file_size (file);
> > > @@ -337,9 +335,10 @@ linux_load (const char *filename, grub_file_t
> file)
> > >        return grub_errno;
> > >      }
> > >
> > > -  if (size > LINUX_ZIMAGE_OFFSET + 4
> > > -      && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
> > > -      == LINUX_ZIMAGE_MAGIC)
> > > +  lh = (void *) linux_addr;
> > > +
> > > +  if ((grub_size_t) size > sizeof (*lh) &&
> > > +      lh->magic == GRUB_LINUX_MAGIC_SIGNATURE)
> > >      ;
> > >    else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) ==
> 0xea000006
> > >            && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
> > > diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> > > index f217f8281..802090239 100644
> > > --- a/include/grub/arm/linux.h
> > > +++ b/include/grub/arm/linux.h
> > > @@ -20,11 +20,20 @@
> > >  #ifndef GRUB_LINUX_CPU_HEADER
> > >  #define GRUB_LINUX_CPU_HEADER 1
> > >
> > > -#define LINUX_ZIMAGE_OFFSET 0x24
> > > -#define LINUX_ZIMAGE_MAGIC  0x016f2818
> > > -
> > >  #include "system.h"
> > >
> > > +#define GRUB_LINUX_MAGIC_SIGNATURE 0x016f2818
> > > +
> > > +struct grub_linux_kernel_header {
> > >
> > This maz clash with other architectures preventing including several
> > architecture files in the same file. We need it to create tools like
> > grub-file .
>
> Right, then I do need to inject some patches renaming this struct and
> signature on x86 too.
>
> /
>     Leif
>
> > > +  grub_uint32_t code0;
> > > +  grub_uint32_t reserved1[8];
> > > +  grub_uint32_t magic;
> > > +  grub_uint32_t start; /* _start */
> > > +  grub_uint32_t end;   /* _edata */
> > > +  grub_uint32_t reserved2[4];
> > > +  grub_uint32_t hdr_offset;
> > > +};
> > > +
> > >  #if defined GRUB_MACHINE_UBOOT
> > >  # include <grub/uboot/uboot.h>
> > >  # define LINUX_ADDRESS        (start_of_ram + 0x8000)
> > > --
> > > 2.11.0
> > >
> > >
> > > _______________________________________________
> > > Grub-devel mailing list
> > > Grub-devel@gnu.org
> > > https://lists.gnu.org/mailman/listinfo/grub-devel
> > >
>
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
>
>

[-- Attachment #2: Type: text/html, Size: 5395 bytes --]

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

* Re: [PATCH v2 11/14] arm/efi: switch to arm64 linux loader
  2017-08-07 14:08   ` Vladimir 'phcoder' Serbinenko
@ 2017-09-04 14:35     ` Leif Lindholm
  0 siblings, 0 replies; 39+ messages in thread
From: Leif Lindholm @ 2017-09-04 14:35 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Daniel Kiper

On Mon, Aug 07, 2017 at 02:08:29PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> Le Thu, Aug 3, 2017 à 12:10 PM, Leif Lindholm <leif.lindholm@linaro.org> a
> écrit :
> 
> > Switch over to the EFI-stub aware arm64 loader for 32-bit ARM platforms.
> >
> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> > ---
> >  grub-core/Makefile.core.def | 6 +++---
> >  grub-core/kern/efi/mm.c     | 2 +-
> >  include/grub/efi/efi.h      | 2 --
> >  3 files changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> > index a65c27f7f..87f80d316 100644
> > --- a/grub-core/Makefile.core.def
> > +++ b/grub-core/Makefile.core.def
> > @@ -229,7 +229,6 @@ kernel = {
> >    ia64_efi = kern/ia64/cache.c;
> >
> >    arm_efi = kern/arm/efi/init.c;
> > -  arm_efi = kern/arm/efi/misc.c;
> >    arm_efi = kern/efi/fdt.c;
> >
> >    arm64_efi = kern/arm64/efi/init.c;
> > @@ -1698,7 +1697,8 @@ module = {
> >    powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
> >    sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
> >    ia64_efi = loader/ia64/efi/linux.c;
> > -  arm = loader/arm/linux.c;
> > +  arm_uboot = loader/arm/linux.c;
> > +  arm_efi = loader/arm64/linux.c;
> >
> This misses arm-coreboot

Ah, apologies, this set predated the coreboot support being merged,
and I did not notice in the rebase.

/
    Leif


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

end of thread, other threads:[~2017-09-04 14:35 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 10:04 [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h Leif Lindholm
2017-08-03 15:18   ` Vladimir 'phcoder' Serbinenko
2017-08-04  9:11     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size Leif Lindholm
2017-08-03 15:19   ` Vladimir 'phcoder' Serbinenko
2017-08-08 15:56     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size Leif Lindholm
2017-08-03 15:20   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* Leif Lindholm
2017-08-03 15:30   ` Vladimir 'phcoder' Serbinenko
2017-08-08 16:04     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages Leif Lindholm
2017-08-03 15:37   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 06/14] efi: move fdt helper library Leif Lindholm
2017-08-03 15:38   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition Leif Lindholm
2017-08-03 16:35   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 08/14] arm64 linux loader: improve type portability Leif Lindholm
2017-08-03 16:41   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 09/14] arm64 linux loader: rename functions and macros and move to common headers Leif Lindholm
2017-08-03 16:44   ` Vladimir 'phcoder' Serbinenko
2017-08-03 16:46     ` Vladimir 'phcoder' Serbinenko
2017-09-04 14:29     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 10/14] loader: switch arm/linux to grub_linux_kernel_header struct Leif Lindholm
2017-08-07 14:07   ` Vladimir 'phcoder' Serbinenko
2017-09-04 14:31     ` Leif Lindholm
2017-09-04 14:35       ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 11/14] arm/efi: switch to arm64 linux loader Leif Lindholm
2017-08-07 14:08   ` Vladimir 'phcoder' Serbinenko
2017-09-04 14:35     ` Leif Lindholm
2017-08-03 10:04 ` [PATCH v2 12/14] arm: delete unused efi support from loader/arm Leif Lindholm
2017-08-07 14:09   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 13/14] efi: restrict arm/arm64 linux loader initrd placement Leif Lindholm
2017-08-07 14:10   ` Vladimir 'phcoder' Serbinenko
2017-08-03 10:04 ` [PATCH v2 14/14] efi: change heap allocation type to GRUB_EFI_LOADER_CODE Leif Lindholm
2017-08-07 14:11   ` Vladimir 'phcoder' Serbinenko
2017-08-07 16:18     ` Konrad Rzeszutek Wilk
2017-08-07 16:22       ` Vladimir 'phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.