All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support
@ 2018-06-15 12:42 Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 01/17] efi: sandbox: Add distroboot support Alexander Graf
                   ` (17 more replies)
  0 siblings, 18 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

This patch set augments Simon's patch set for efi_loader support
in sandbox[1], but follows a different memory allocation scheme.

Instead of keeping U-Boot addresses in the EFI memory map, this
patch set makes the EFI memory map contain host virtual addresses.
That way most logic "just works" and all EFI interfaces automatically
gain sandbox awareness.

We also change the memory map of sandbox to hard code RAM to always
live at address 0x80000000. This patch is completely optional.

With this patch set in place, I can successfully run the selftest suite
as well as an aarch64 grub.efi binary. X86_64 grub.efi doesn't work
because that one requires inl instructions to work.

Alex

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=49832

v1 -> v2:

  - only compile efi_add_known_memory if efi_loader is enabled
  - clarify address vs pointer in fs_read patch
  - include mapmem.h

v2 -> v3:

  - removed: efi_loader: Pass address to fs_read()
  - new: fs: Convert fs_read/write to take buffer instead of address
  - new: efi_loader: Introduce ms abi vararg helpers
  - new: sandbox: Enable 1:1 map
  - new: distro: Move to compiler based target architecture determination
  - new: efi_loader: Move to compiler based target architecture determination
  - new: sandbox: Allow to execute from RAM
  - new: sandbox: Fix setjmp/longjmp

Alexander Graf (13):
  efi_loader: Use compiler constants for image loader
  efi_loader: Use map_sysmem() in bootefi command
  efi.h: Do not use config options
  efi_loader: Allow SMBIOS tables in highmem
  sandbox: Map host memory for efi_loader
  efi_loader: Disable miniapps on sandbox
  fs: Convert fs_read/write to take buffer instead of address
  efi_loader: Introduce ms abi vararg helpers
  sandbox: Enable 1:1 map
  distro: Move to compiler based target architecture determination
  efi_loader: Move to compiler based target architecture determination
  sandbox: Allow to execute from RAM
  sandbox: Fix setjmp/longjmp

Heinrich Schuchardt (1):
  efi_loader: efi_allocate_pages is too restrictive

Simon Glass (3):
  efi: sandbox: Add distroboot support
  efi: sandbox: Add relocation constants
  efi: sandbox: Enable EFI loader for sandbox

 Makefile                              |  2 +-
 arch/sandbox/cpu/cpu.c                | 30 ++++++++----------------
 arch/sandbox/cpu/os.c                 | 43 ++++++++++++++++++++---------------
 arch/sandbox/cpu/state.c              |  4 ++--
 arch/sandbox/cpu/u-boot.lds           |  9 ++++++++
 arch/sandbox/include/asm/io.h         | 17 ++++----------
 arch/sandbox/include/asm/setjmp.h     |  4 +++-
 board/BuR/common/common.c             |  2 +-
 board/gdsys/p1022/controlcenterd-id.c | 10 ++++----
 cmd/bootefi.c                         | 13 +++++++----
 cmd/mvebu/bubt.c                      |  4 ++--
 common/board_f.c                      |  4 +++-
 common/splash_source.c                |  4 +++-
 configs/sandbox64_defconfig           |  6 ++---
 configs/sandbox_defconfig             |  6 ++---
 configs/sandbox_flattree_defconfig    |  4 ++--
 configs/sandbox_noblk_defconfig       |  4 ++--
 configs/sandbox_spl_defconfig         |  4 ++--
 drivers/bootcount/bootcount_ext.c     | 12 +++++-----
 drivers/fpga/zynqpl.c                 |  8 ++++---
 fs/fs.c                               | 20 ++++++++--------
 include/config_distro_bootcmd.h       | 14 +++++++-----
 include/configs/sandbox.h             | 32 +++++++++++++-------------
 include/efi.h                         | 25 ++++++++++----------
 include/fs.h                          | 12 +++++-----
 include/os.h                          | 19 ++++++++++++++++
 lib/efi/Makefile                      |  4 ++--
 lib/efi_loader/Kconfig                |  2 +-
 lib/efi_loader/efi_boottime.c         | 36 ++++++++++++++---------------
 lib/efi_loader/efi_file.c             |  6 ++---
 lib/efi_loader/efi_image_loader.c     | 12 +++++-----
 lib/efi_loader/efi_memory.c           |  2 +-
 lib/efi_loader/efi_runtime.c          | 14 +++++++-----
 lib/efi_loader/efi_smbios.c           | 11 +++++++--
 lib/efi_selftest/Makefile             |  2 +-
 35 files changed, 219 insertions(+), 182 deletions(-)

-- 
2.12.3

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

* [U-Boot] [PATCH v3 01/17] efi: sandbox: Add distroboot support
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 02/17] efi: sandbox: Add relocation constants Alexander Graf
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

From: Simon Glass <sjg@chromium.org>

With sandbox these values depend on the host system. Let's assume that it
is x86_64 for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 include/config_distro_bootcmd.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index d672e8ebe6..1bd79ae3b8 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -251,6 +251,8 @@
 #elif defined(CONFIG_ARM)
 #define BOOTENV_EFI_PXE_ARCH "0xa"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000"
+
+/* For sandbox we only support 64-bit x86 at present */
 #elif defined(CONFIG_X86)
 /* Always assume we're running 64bit */
 #define BOOTENV_EFI_PXE_ARCH "0x7"
@@ -261,6 +263,17 @@
 #elif defined(CONFIG_CPU_RISCV_64)
 #define BOOTENV_EFI_PXE_ARCH "0x1b"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000"
+#elif defined(CONFIG_SANDBOX)
+/*
+ * TODO(sjg at chromium.org): Consider providing a way to enable sandbox features
+ * based on the host architecture
+ */
+# ifndef __x86_64__
+#  warning "sandbox EFI support is only tested on 64-bit x86"
+# endif
+/* To support other *host* architectures this should be changed */
+#define BOOTENV_EFI_PXE_ARCH "0x7"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
 #else
 #error Please specify an EFI client identifier
 #endif
-- 
2.12.3

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

* [U-Boot] [PATCH v3 02/17] efi: sandbox: Add relocation constants
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 01/17] efi: sandbox: Add distroboot support Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 03/17] efi_loader: Use compiler constants for image loader Alexander Graf
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

From: Simon Glass <sjg@chromium.org>

Add these so that we can build the EFI loader for sandbox. The values are
for x86_64 so potentially bogus. But we don't support relocation within
sandbox anyway.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_runtime.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 4874eb602f..388dfb9840 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -62,6 +62,18 @@ struct dyn_sym {
 #define R_ABSOLUTE	R_RISCV_64
 #define SYM_INDEX	32
 #endif
+
+/* For sandbox we only support 64-bit x86 at present */
+#elif defined(CONFIG_SANDBOX)
+/*
+ * TODO(sjg at chromium.org): Consider providing a way to enable sandbox features
+ * based on the host architecture
+ */
+# ifndef __x86_64__
+#  warning "sandbox EFI support is only tested on 64-bit x86"
+# endif
+#define R_RELATIVE	8
+#define R_MASK		0xffffffffULL
 #else
 #error Need to add relocation awareness
 #endif
-- 
2.12.3

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

* [U-Boot] [PATCH v3 03/17] efi_loader: Use compiler constants for image loader
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 01/17] efi: sandbox: Add distroboot support Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 02/17] efi: sandbox: Add relocation constants Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 04/17] efi_loader: Use map_sysmem() in bootefi command Alexander Graf
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

The EFI image loader tries to determine which target architecture we're
working with to only load PE binaries that match.

So far this has worked based on CONFIG defines, because the target CPU
was always indicated by a config define. With sandbox however, this is
not longer true as all sandbox targets only encompass a single CONFIG
option and so we need to use compiler defines to determine the CPU
architecture.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_image_loader.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index ecdb77e5b6..fdf40a62c8 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -19,25 +19,25 @@ const efi_guid_t efi_simple_file_system_protocol_guid =
 const efi_guid_t efi_file_info_guid = EFI_FILE_INFO_GUID;
 
 static int machines[] = {
-#if defined(CONFIG_ARM64)
+#if defined(__aarch64__)
 	IMAGE_FILE_MACHINE_ARM64,
-#elif defined(CONFIG_ARM)
+#elif defined(__arm__)
 	IMAGE_FILE_MACHINE_ARM,
 	IMAGE_FILE_MACHINE_THUMB,
 	IMAGE_FILE_MACHINE_ARMNT,
 #endif
 
-#if defined(CONFIG_X86_64)
+#if defined(__x86_64__)
 	IMAGE_FILE_MACHINE_AMD64,
-#elif defined(CONFIG_X86)
+#elif defined(__i386__)
 	IMAGE_FILE_MACHINE_I386,
 #endif
 
-#if defined(CONFIG_CPU_RISCV_32)
+#if defined(__riscv) && (__riscv_xlen == 32)
 	IMAGE_FILE_MACHINE_RISCV32,
 #endif
 
-#if defined(CONFIG_CPU_RISCV_64)
+#if defined(__riscv) && (__riscv_xlen == 64)
 	IMAGE_FILE_MACHINE_RISCV64,
 #endif
 	0 };
-- 
2.12.3

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

* [U-Boot] [PATCH v3 04/17] efi_loader: Use map_sysmem() in bootefi command
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (2 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 03/17] efi_loader: Use compiler constants for image loader Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 05/17] efi.h: Do not use config options Alexander Graf
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

The bootefi command gets a few addresses as values passed in. In sandbox,
these values are in U-Boot address space, so we need to make sure we
explicitly call map_sysmem() on them to be able to access them.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 cmd/bootefi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index f55a40dc84..a86a2bd4a9 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -14,6 +14,7 @@
 #include <errno.h>
 #include <linux/libfdt.h>
 #include <linux/libfdt_env.h>
+#include <mapmem.h>
 #include <memalign.h>
 #include <asm/global_data.h>
 #include <asm-generic/sections.h>
@@ -389,7 +390,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	unsigned long addr;
 	char *saddr;
 	efi_status_t r;
-	void *fdt_addr;
+	unsigned long fdt_addr;
+	void *fdt;
 
 	/* Allow unaligned memory access */
 	allow_unaligned();
@@ -406,11 +408,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return CMD_RET_USAGE;
 
 	if (argc > 2) {
-		fdt_addr = (void *)simple_strtoul(argv[2], NULL, 16);
+		fdt_addr = simple_strtoul(argv[2], NULL, 16);
 		if (!fdt_addr && *argv[2] != '0')
 			return CMD_RET_USAGE;
 		/* Install device tree */
-		r = efi_install_fdt(fdt_addr);
+		fdt = map_sysmem(fdt_addr, 0);
+		r = efi_install_fdt(fdt);
 		if (r != EFI_SUCCESS) {
 			printf("ERROR: failed to install device tree\n");
 			return CMD_RET_FAILURE;
@@ -429,7 +432,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			addr = simple_strtoul(saddr, NULL, 16);
 		else
 			addr = CONFIG_SYS_LOAD_ADDR;
-		memcpy((char *)addr, __efi_helloworld_begin, size);
+		memcpy(map_sysmem(addr, size), __efi_helloworld_begin, size);
 	} else
 #endif
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
@@ -475,7 +478,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	printf("## Starting EFI application at %08lx ...\n", addr);
-	r = do_bootefi_exec((void *)addr, bootefi_device_path,
+	r = do_bootefi_exec(map_sysmem(addr, 0), bootefi_device_path,
 			    bootefi_image_path);
 	printf("## Application terminated, r = %lu\n",
 	       r & ~EFI_ERROR_MASK);
-- 
2.12.3

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

* [U-Boot] [PATCH v3 05/17] efi.h: Do not use config options
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (3 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 04/17] efi_loader: Use map_sysmem() in bootefi command Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 06/17] efi_loader: Allow SMBIOS tables in highmem Alexander Graf
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

Currently efi.h determines a few bits of its environment according to
config options. This falls apart with the efi stub support which may
result in efi.h getting pulled into the stub as well as real U-Boot
code. In that case, one may be 32bit while the other one is 64bit.

This patch changes the conditionals to use compiler provided defines
instead. That way we always adhere to the build environment we're in
and the definitions adjust automatically.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
 include/efi.h    | 17 ++++-------------
 lib/efi/Makefile |  4 ++--
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index e30a3c51c6..826d484977 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -19,12 +19,12 @@
 #include <linux/string.h>
 #include <linux/types.h>
 
-#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__))
-/* EFI uses the Microsoft ABI which is not the default for GCC */
+/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */
+#ifdef __x86_64__
 #define EFIAPI __attribute__((ms_abi))
 #else
 #define EFIAPI asmlinkage
-#endif
+#endif /* __x86_64__ */
 
 struct efi_device_path;
 
@@ -32,16 +32,7 @@ typedef struct {
 	u8 b[16];
 } efi_guid_t;
 
-#define EFI_BITS_PER_LONG	BITS_PER_LONG
-
-/*
- * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
- * in lib/efi/Makefile, when building the stub.
- */
-#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)
-#undef EFI_BITS_PER_LONG
-#define EFI_BITS_PER_LONG	64
-#endif
+#define EFI_BITS_PER_LONG	(sizeof(long) * 8)
 
 /* Bit mask for EFI status code with error */
 #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1))
diff --git a/lib/efi/Makefile b/lib/efi/Makefile
index 18d081ac46..ece7907227 100644
--- a/lib/efi/Makefile
+++ b/lib/efi/Makefile
@@ -7,9 +7,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB
+CFLAGS_efi_stub.o := -fpic -fshort-wchar
 CFLAGS_REMOVE_efi.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB
+CFLAGS_efi.o := -fpic -fshort-wchar
 
 extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
-- 
2.12.3

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

* [U-Boot] [PATCH v3 06/17] efi_loader: Allow SMBIOS tables in highmem
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (4 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 05/17] efi.h: Do not use config options Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 07/17] sandbox: Map host memory for efi_loader Alexander Graf
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

We try hard to make sure that SMBIOS tables live in the lower 32bit.
However, when we can not find any space at all there, we should not
error out but instead just fall back to map them in the full address
space instead.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_smbios.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 7c3fc8af0b..932f7582ec 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -26,8 +26,15 @@ efi_status_t efi_smbios_register(void)
 	/* Reserve 4kiB page for SMBIOS */
 	ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
 				 EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
-	if (ret != EFI_SUCCESS)
-		return ret;
+
+	if (ret != EFI_SUCCESS) {
+		/* Could not find space in lowmem, use highmem instead */
+		ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+					 EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
+
+		if (ret != EFI_SUCCESS)
+			return ret;
+	}
 
 	/*
 	 * Generate SMBIOS tables - we know that efi_allocate_pages() returns
-- 
2.12.3

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

* [U-Boot] [PATCH v3 07/17] sandbox: Map host memory for efi_loader
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (5 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 06/17] efi_loader: Allow SMBIOS tables in highmem Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 08/17] efi_loader: efi_allocate_pages is too restrictive Alexander Graf
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

With efi_loader we do not control payload applications, so we can not
teach them about the difference between virtual and physical addresses.

Instead, let's just always map host virtual addresses in the efi memory
map. That way we can be sure that all memory allocation functions always
return consumable pointers.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - only compile efi_add_known_memory if efi_loader is enabled
---
 arch/sandbox/cpu/cpu.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index cde0b055a6..23d8b70648 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -5,6 +5,7 @@
 #define DEBUG
 #include <common.h>
 #include <dm.h>
+#include <efi_loader.h>
 #include <errno.h>
 #include <linux/libfdt.h>
 #include <os.h>
@@ -177,3 +178,22 @@ void longjmp(jmp_buf jmp, int ret)
 	while (1)
 		;
 }
+
+#ifdef CONFIG_EFI_LOADER
+
+/*
+ * In sandbox, we don't have a 1:1 map, so we need to expose
+ * process addresses instead of U-Boot addresses
+ */
+void efi_add_known_memory(void)
+{
+	u64 ram_start = (uintptr_t)map_sysmem(0, gd->ram_size);
+	u64 ram_size = gd->ram_size;
+	u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
+	u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+
+	efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY,
+			   false);
+}
+
+#endif
-- 
2.12.3

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

* [U-Boot] [PATCH v3 08/17] efi_loader: efi_allocate_pages is too restrictive
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (6 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 07/17] sandbox: Map host memory for efi_loader Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 09/17] efi_loader: Disable miniapps on sandbox Alexander Graf
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

From: Heinrich Schuchardt <xypron.glpk@gmx.de>

When running on the sandbox the stack is not necessarily at a higher memory
address than the highest free memory.

There is no reason why the checking of the highest memory address should be
more restrictive for EFI_ALLOCATE_ANY_PAGES than for
EFI_ALLOCATE_MAX_ADDRESS.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[agraf: use -1ULL instead]
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index ec66af98ea..ce29bcc6a3 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -295,7 +295,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
 	switch (type) {
 	case EFI_ALLOCATE_ANY_PAGES:
 		/* Any page */
-		addr = efi_find_free_memory(len, gd->start_addr_sp);
+		addr = efi_find_free_memory(len, -1ULL);
 		if (!addr) {
 			r = EFI_NOT_FOUND;
 			break;
-- 
2.12.3

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

* [U-Boot] [PATCH v3 09/17] efi_loader: Disable miniapps on sandbox
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (7 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 08/17] efi_loader: efi_allocate_pages is too restrictive Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address Alexander Graf
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

In the sandbox environment we can not easily build efi stub binaries
right now, so let's disable the respective test cases for the efi
selftest suite.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 lib/efi_selftest/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 4fe404d88d..bf5c8199cb 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -41,7 +41,7 @@ endif
 
 # TODO: As of v2018.01 the relocation code for the EFI application cannot
 # be built on x86_64.
-ifeq ($(CONFIG_X86_64),)
+ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),)
 
 ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),)
 
-- 
2.12.3

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

* [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (8 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 09/17] efi_loader: Disable miniapps on sandbox Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 14:24   ` Simon Glass
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 11/17] efi_loader: Introduce ms abi vararg helpers Alexander Graf
                   ` (7 subsequent siblings)
  17 siblings, 1 reply; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

The fs_read() and fs_write() functions are internal interfaces that
naturally want to get pointers as arguments. Most users so far even
have pointers and explicitly cast them into integers just to be able
to pass them into the function.

Convert them over to instead take a pointer argument for the buffer.
That way any sandbox mapping gets greatly simplified and users of
the API intuitively know what to do.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 board/BuR/common/common.c             |  2 +-
 board/gdsys/p1022/controlcenterd-id.c | 10 +++++-----
 cmd/mvebu/bubt.c                      |  4 ++--
 common/splash_source.c                |  4 +++-
 drivers/bootcount/bootcount_ext.c     | 12 ++++++------
 drivers/fpga/zynqpl.c                 |  8 +++++---
 fs/fs.c                               | 20 ++++++++++----------
 include/fs.h                          | 12 ++++++------
 lib/efi_loader/efi_file.c             |  6 ++----
 9 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 9df19791c2..ab9d9c51cf 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -269,7 +269,7 @@ static int load_devicetree(void)
 		puts("load_devicetree: set_blk_dev failed.\n");
 		return -1;
 	}
-	rc = fs_read(dtbname, (u32)dtbaddr, 0, 0, &dtbsize);
+	rc = fs_read(dtbname, (u_char *)dtbaddr, 0, 0, &dtbsize);
 #endif
 	if (rc == 0) {
 		gd->fdt_blob = (void *)dtbaddr;
diff --git a/board/gdsys/p1022/controlcenterd-id.c b/board/gdsys/p1022/controlcenterd-id.c
index 7e082dff05..2f01f7b7eb 100644
--- a/board/gdsys/p1022/controlcenterd-id.c
+++ b/board/gdsys/p1022/controlcenterd-id.c
@@ -874,7 +874,7 @@ static struct key_program *load_key_chunk(const char *ifname,
 
 	if (fs_set_blk_dev(ifname, dev_part_str, fs_type))
 		goto failure;
-	if (fs_read(path, (ulong)buf, 0, 12, &i) < 0)
+	if (fs_read(path, buf, 0, 12, &i) < 0)
 		goto failure;
 	if (i < 12)
 		goto failure;
@@ -890,7 +890,7 @@ static struct key_program *load_key_chunk(const char *ifname,
 		goto failure;
 	if (fs_set_blk_dev(ifname, dev_part_str, fs_type))
 		goto failure;
-	if (fs_read(path, (ulong)result, 0,
+	if (fs_read(path, result, 0,
 		    sizeof(struct key_program) + header.code_size, &i) < 0)
 		goto failure;
 	if (i <= 0)
@@ -1019,7 +1019,7 @@ static int second_stage_init(void)
 	struct key_program *hmac_blob = NULL;
 	const char *image_path = "/ccdm.itb";
 	char *mac_path = NULL;
-	ulong image_addr;
+	u8 *image_addr;
 	loff_t image_size;
 	uint32_t err;
 
@@ -1059,7 +1059,7 @@ static int second_stage_init(void)
 	strcat(mac_path, mac_suffix);
 
 	/* read image from mmcdev (ccdm.itb) */
-	image_addr = (ulong)get_image_location();
+	image_addr = get_image_location();
 	if (fs_set_blk_dev("mmc", mmcdev, FS_TYPE_EXT))
 		goto failure;
 	if (fs_read(image_path, image_addr, 0, 0, &image_size) < 0)
@@ -1077,7 +1077,7 @@ static int second_stage_init(void)
 		puts("corrupted mac file\n");
 		goto failure;
 	}
-	if (check_hmac(hmac_blob, (u8 *)image_addr, image_size)) {
+	if (check_hmac(hmac_blob, image_addr, image_size)) {
 		puts("image integrity could not be verified\n");
 		goto failure;
 	}
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index b4d371f305..29fff898fa 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -209,7 +209,7 @@ static size_t mmc_read_file(const char *file_name)
 	}
 
 	/* Perfrom file read */
-	rc = fs_read(file_name, get_load_addr(), 0, 0, &act_read);
+	rc = fs_read(file_name, (void *)get_load_addr(), 0, 0, &act_read);
 	if (rc)
 		return 0;
 
@@ -392,7 +392,7 @@ static size_t usb_read_file(const char *file_name)
 	}
 
 	/* Perfrom file read */
-	rc = fs_read(file_name, get_load_addr(), 0, 0, &act_read);
+	rc = fs_read(file_name, (void *)get_load_addr(), 0, 0, &act_read);
 	if (rc)
 		return 0;
 
diff --git a/common/splash_source.c b/common/splash_source.c
index 62763b9ebd..79dbea12fc 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -11,6 +11,7 @@
 #include <fs.h>
 #include <fdt_support.h>
 #include <image.h>
+#include <mapmem.h>
 #include <nand.h>
 #include <sata.h>
 #include <spi.h>
@@ -252,7 +253,8 @@ static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
 	}
 
 	splash_select_fs_dev(location);
-	res = fs_read(splash_file, bmp_load_addr, 0, 0, &actread);
+	res = fs_read(splash_file, map_sysmem(bmp_load_addr, bmp_size),
+		      0, 0, &actread);
 
 out:
 	if (location->ubivol != NULL)
diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c
index 075e590896..4a46f17c15 100644
--- a/drivers/bootcount/bootcount_ext.c
+++ b/drivers/bootcount/bootcount_ext.c
@@ -24,10 +24,10 @@ void bootcount_store(ulong a)
 	buf = map_sysmem(CONFIG_SYS_BOOTCOUNT_ADDR, 2);
 	buf[0] = BC_MAGIC;
 	buf[1] = (a & 0xff);
-	unmap_sysmem(buf);
 
-	ret = fs_write(CONFIG_SYS_BOOTCOUNT_EXT_NAME,
-		       CONFIG_SYS_BOOTCOUNT_ADDR, 0, 2, &len);
+	ret = fs_write(CONFIG_SYS_BOOTCOUNT_EXT_NAME, buf, 0, 2, &len);
+
+	unmap_sysmem(buf);
 	if (ret != 0)
 		puts("Error storing bootcount\n");
 }
@@ -44,14 +44,14 @@ ulong bootcount_load(void)
 		return 0;
 	}
 
-	ret = fs_read(CONFIG_SYS_BOOTCOUNT_EXT_NAME, CONFIG_SYS_BOOTCOUNT_ADDR,
-		      0, 2, &len_read);
+	buf = map_sysmem(CONFIG_SYS_BOOTCOUNT_ADDR, 2);
+
+	ret = fs_read(CONFIG_SYS_BOOTCOUNT_EXT_NAME, buf, 0, 2, &len_read);
 	if (ret != 0 || len_read != 2) {
 		puts("Error loading bootcount\n");
 		return 0;
 	}
 
-	buf = map_sysmem(CONFIG_SYS_BOOTCOUNT_ADDR, 2);
 	if (buf[0] == BC_MAGIC)
 		ret = buf[1];
 
diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c
index fd37d18c7f..2fba77d45f 100644
--- a/drivers/fpga/zynqpl.c
+++ b/drivers/fpga/zynqpl.c
@@ -431,7 +431,7 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize,
 	if (fs_set_blk_dev(interface, dev_part, fstype))
 		return FPGA_FAIL;
 
-	if (fs_read(filename, (u32) buf, pos, blocksize, &actread) < 0)
+	if (fs_read(filename, (void *)buf, pos, blocksize, &actread) < 0)
 		return FPGA_FAIL;
 
 	if (zynq_validate_bitstream(desc, buf, bsize, blocksize, &swap,
@@ -454,10 +454,12 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize,
 			return FPGA_FAIL;
 
 		if (bsize > blocksize) {
-			if (fs_read(filename, (u32) buf, pos, blocksize, &actread) < 0)
+			if (fs_read(filename, (void *)buf, pos, blocksize,
+				    &actread) < 0)
 				return FPGA_FAIL;
 		} else {
-			if (fs_read(filename, (u32) buf, pos, bsize, &actread) < 0)
+			if (fs_read(filename, (void *)buf, pos, bsize,
+				    &actread) < 0)
 				return FPGA_FAIL;
 		}
 	} while (bsize > blocksize);
diff --git a/fs/fs.c b/fs/fs.c
index 33808d549e..27ce9259d2 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -402,20 +402,17 @@ int fs_size(const char *filename, loff_t *size)
 	return ret;
 }
 
-int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
+int fs_read(const char *filename, void *buf, loff_t offset, loff_t len,
 	    loff_t *actread)
 {
 	struct fstype_info *info = fs_get_info(fs_type);
-	void *buf;
 	int ret;
 
 	/*
 	 * We don't actually know how many bytes are being read, since len==0
 	 * means read the whole file.
 	 */
-	buf = map_sysmem(addr, len);
 	ret = info->read(filename, buf, offset, len, actread);
-	unmap_sysmem(buf);
 
 	/* If we requested a specific number of bytes, check we got it */
 	if (ret == 0 && len && *actread != len)
@@ -425,16 +422,13 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
 	return ret;
 }
 
-int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,
+int fs_write(const char *filename, void *buf, loff_t offset, loff_t len,
 	     loff_t *actwrite)
 {
 	struct fstype_info *info = fs_get_info(fs_type);
-	void *buf;
 	int ret;
 
-	buf = map_sysmem(addr, len);
 	ret = info->write(filename, buf, offset, len, actwrite);
-	unmap_sysmem(buf);
 
 	if (ret < 0 && len != *actwrite) {
 		printf("** Unable to write file %s **\n", filename);
@@ -529,6 +523,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 	int ret;
 	unsigned long time;
 	char *ep;
+	void *buf;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -567,9 +562,11 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 	else
 		pos = 0;
 
+	buf = map_sysmem(addr, bytes);
 	time = get_timer(0);
-	ret = fs_read(filename, addr, pos, bytes, &len_read);
+	ret = fs_read(filename, buf, pos, bytes, &len_read);
 	time = get_timer(time);
+	unmap_sysmem(buf);
 	if (ret < 0)
 		return 1;
 
@@ -623,6 +620,7 @@ int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 	loff_t len;
 	int ret;
 	unsigned long time;
+	void *buf;
 
 	if (argc < 6 || argc > 7)
 		return CMD_RET_USAGE;
@@ -638,9 +636,11 @@ int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 	else
 		pos = 0;
 
+	buf = map_sysmem(addr, bytes);
 	time = get_timer(0);
-	ret = fs_write(filename, addr, pos, bytes, &len);
+	ret = fs_write(filename, buf, pos, bytes, &len);
 	time = get_timer(time);
+	unmap_sysmem(buf);
 	if (ret < 0)
 		return 1;
 
diff --git a/include/fs.h b/include/fs.h
index 163da103b4..647b0c2ed2 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -76,27 +76,27 @@ int fs_size(const char *filename, loff_t *size);
  * Note that not all filesystem types support either/both offset!=0 or len!=0.
  *
  * @filename: Name of file to read from
- * @addr: The address to read into
+ * @buf: The buffer to read into
  * @offset: The offset in file to read from
  * @len: The number of bytes to read. Maybe 0 to read entire file
  * @actread: Returns the actual number of bytes read
  * @return 0 if ok with valid *actread, -1 on error conditions
  */
-int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
+int fs_read(const char *filename, void *buf, loff_t offset, loff_t len,
 	    loff_t *actread);
 
 /*
  * fs_write - Write file to the partition previously set by fs_set_blk_dev()
  * Note that not all filesystem types support offset!=0.
  *
- * @filename: Name of file to read from
- * @addr: The address to read into
- * @offset: The offset in file to read from. Maybe 0 to write to start of file
+ * @filename: Name of file to write to
+ * @buf: The buffer to read from
+ * @offset: The offset in file to write to. Maybe 0 to write to start of file
  * @len: The number of bytes to write
  * @actwrite: Returns the actual number of bytes written
  * @return 0 if ok with valid *actwrite, -1 on error conditions
  */
-int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,
+int fs_write(const char *filename, void *buf, loff_t offset, loff_t len,
 	     loff_t *actwrite);
 
 /*
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index e6a15bcb52..7bd061f395 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -233,8 +233,7 @@ static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size,
 {
 	loff_t actread;
 
-	if (fs_read(fh->path, (ulong)buffer, fh->offset,
-		    *buffer_size, &actread))
+	if (fs_read(fh->path, buffer, fh->offset, *buffer_size, &actread))
 		return EFI_DEVICE_ERROR;
 
 	*buffer_size = actread;
@@ -363,8 +362,7 @@ static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file,
 		goto error;
 	}
 
-	if (fs_write(fh->path, (ulong)buffer, fh->offset, *buffer_size,
-		     &actwrite)) {
+	if (fs_write(fh->path, buffer, fh->offset, *buffer_size, &actwrite)) {
 		ret = EFI_DEVICE_ERROR;
 		goto error;
 	}
-- 
2.12.3

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

* [U-Boot] [PATCH v3 11/17] efi_loader: Introduce ms abi vararg helpers
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (9 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 12/17] efi: sandbox: Enable EFI loader for sandbox Alexander Graf
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

Varargs differ between sysv and ms abi. On x86_64 we have to follow the ms
abi though, so we also need to make sure we use x86_64 varargs helpers.

This patch introduces generic efi vararg helpers that adhere to the
respective EFI ABI. That way we can deal with them properly from efi
loader code and properly interpret variable arguments.

This fixes the InstallMultipleProtocolInterfaces tests in the efi selftests
on x86_64 for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 include/efi.h                 |  8 ++++++++
 lib/efi_loader/efi_boottime.c | 36 ++++++++++++++++++------------------
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index 826d484977..7be7798d8d 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -22,8 +22,16 @@
 /* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */
 #ifdef __x86_64__
 #define EFIAPI __attribute__((ms_abi))
+#define efi_va_list __builtin_ms_va_list
+#define efi_va_start __builtin_ms_va_start
+#define efi_va_arg __builtin_va_arg
+#define efi_va_end __builtin_ms_va_end
 #else
 #define EFIAPI asmlinkage
+#define efi_va_list va_list
+#define efi_va_start va_start
+#define efi_va_arg va_arg
+#define efi_va_end va_end
 #endif /* __x86_64__ */
 
 struct efi_device_path;
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 50d311548e..404743fe01 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2273,7 +2273,7 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
 {
 	EFI_ENTRY("%p", handle);
 
-	va_list argptr;
+	efi_va_list argptr;
 	const efi_guid_t *protocol;
 	void *protocol_interface;
 	efi_status_t r = EFI_SUCCESS;
@@ -2282,12 +2282,12 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
 	if (!handle)
 		return EFI_EXIT(EFI_INVALID_PARAMETER);
 
-	va_start(argptr, handle);
+	efi_va_start(argptr, handle);
 	for (;;) {
-		protocol = va_arg(argptr, efi_guid_t*);
+		protocol = efi_va_arg(argptr, efi_guid_t*);
 		if (!protocol)
 			break;
-		protocol_interface = va_arg(argptr, void*);
+		protocol_interface = efi_va_arg(argptr, void*);
 		r = EFI_CALL(efi_install_protocol_interface(
 						handle, protocol,
 						EFI_NATIVE_INTERFACE,
@@ -2296,19 +2296,19 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
 			break;
 		i++;
 	}
-	va_end(argptr);
+	efi_va_end(argptr);
 	if (r == EFI_SUCCESS)
 		return EFI_EXIT(r);
 
 	/* If an error occurred undo all changes. */
-	va_start(argptr, handle);
+	efi_va_start(argptr, handle);
 	for (; i; --i) {
-		protocol = va_arg(argptr, efi_guid_t*);
-		protocol_interface = va_arg(argptr, void*);
+		protocol = efi_va_arg(argptr, efi_guid_t*);
+		protocol_interface = efi_va_arg(argptr, void*);
 		EFI_CALL(efi_uninstall_protocol_interface(handle, protocol,
 							  protocol_interface));
 	}
-	va_end(argptr);
+	efi_va_end(argptr);
 
 	return EFI_EXIT(r);
 }
@@ -2332,7 +2332,7 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
 {
 	EFI_ENTRY("%p", handle);
 
-	va_list argptr;
+	efi_va_list argptr;
 	const efi_guid_t *protocol;
 	void *protocol_interface;
 	efi_status_t r = EFI_SUCCESS;
@@ -2341,12 +2341,12 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
 	if (!handle)
 		return EFI_EXIT(EFI_INVALID_PARAMETER);
 
-	va_start(argptr, handle);
+	efi_va_start(argptr, handle);
 	for (;;) {
-		protocol = va_arg(argptr, efi_guid_t*);
+		protocol = efi_va_arg(argptr, efi_guid_t*);
 		if (!protocol)
 			break;
-		protocol_interface = va_arg(argptr, void*);
+		protocol_interface = efi_va_arg(argptr, void*);
 		r = EFI_CALL(efi_uninstall_protocol_interface(
 						handle, protocol,
 						protocol_interface));
@@ -2354,20 +2354,20 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
 			break;
 		i++;
 	}
-	va_end(argptr);
+	efi_va_end(argptr);
 	if (r == EFI_SUCCESS)
 		return EFI_EXIT(r);
 
 	/* If an error occurred undo all changes. */
-	va_start(argptr, handle);
+	efi_va_start(argptr, handle);
 	for (; i; --i) {
-		protocol = va_arg(argptr, efi_guid_t*);
-		protocol_interface = va_arg(argptr, void*);
+		protocol = efi_va_arg(argptr, efi_guid_t*);
+		protocol_interface = efi_va_arg(argptr, void*);
 		EFI_CALL(efi_install_protocol_interface(&handle, protocol,
 							EFI_NATIVE_INTERFACE,
 							protocol_interface));
 	}
-	va_end(argptr);
+	efi_va_end(argptr);
 
 	return EFI_EXIT(r);
 }
-- 
2.12.3

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

* [U-Boot] [PATCH v3 12/17] efi: sandbox: Enable EFI loader for sandbox
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (10 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 11/17] efi_loader: Introduce ms abi vararg helpers Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 13/17] sandbox: Enable 1:1 map Alexander Graf
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

From: Simon Glass <sjg@chromium.org>

This allows this feature to build within sandbox. This is for testing
purposes only since it is not possible for sandbox to load native code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index df58e633d1..d471e6f4a4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -1,6 +1,6 @@
 config EFI_LOADER
 	bool "Support running EFI Applications in U-Boot"
-	depends on (ARM || X86 || RISCV) && OF_LIBFDT
+	depends on (ARM || X86 || RISCV || SANDBOX) && OF_LIBFDT
 	# We do not support bootefi booting ARMv7 in non-secure mode
 	depends on !ARMV7_NONSEC
 	# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
-- 
2.12.3

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

* [U-Boot] [PATCH v3 13/17] sandbox: Enable 1:1 map
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (11 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 12/17] efi: sandbox: Enable EFI loader for sandbox Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 14/17] distro: Move to compiler based target architecture determination Alexander Graf
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

So far we've always had a split address space situation with
"U-Boot addresses" (a number space starting from 0) and "host
virtual addresses" (128MB mapped randomly in address space).

This meant that we had to make sure all code is properly aware that
addresses and pointers are not the same thing, so they must not cast
between the two.

However, most real boards do actually have a 1:1 map. So it's
much easier to just expose the same in sandbox.

So this patch maps sandbox RAM from 0x8000000-0x10000000. This
address range fits just fine on both 32bit and 64bit systems.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

I don't know if this really is the best path forward, but at least
it's one that gets rid of the one awkward target that does not
have a 1:1 map ;)
---
 Makefile                           |  2 +-
 arch/sandbox/cpu/cpu.c             | 35 -----------------------------------
 arch/sandbox/cpu/state.c           |  4 ++--
 arch/sandbox/cpu/u-boot.lds        |  9 +++++++++
 arch/sandbox/include/asm/io.h      | 17 +++++------------
 common/board_f.c                   |  4 +++-
 configs/sandbox64_defconfig        |  6 +++---
 configs/sandbox_defconfig          |  6 +++---
 configs/sandbox_flattree_defconfig |  4 ++--
 configs/sandbox_noblk_defconfig    |  4 ++--
 configs/sandbox_spl_defconfig      |  4 ++--
 include/configs/sandbox.h          | 32 ++++++++++++++++----------------
 12 files changed, 48 insertions(+), 79 deletions(-)

diff --git a/Makefile b/Makefile
index 6a190e7a89..705c5b632f 100644
--- a/Makefile
+++ b/Makefile
@@ -867,7 +867,7 @@ endif
 
 # Normally we fill empty space with 0xff
 quiet_cmd_objcopy = OBJCOPY $@
-cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \
+cmd_objcopy = $(OBJCOPY) --gap-fill=0xff -R .ram $(OBJCOPYFLAGS) \
 	$(OBJCOPYFLAGS_$(@F)) $< $@
 
 # Provide a version which does not do this, for use by EFI
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 23d8b70648..b20894b806 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -5,7 +5,6 @@
 #define DEBUG
 #include <common.h>
 #include <dm.h>
-#include <efi_loader.h>
 #include <errno.h>
 #include <linux/libfdt.h>
 #include <os.h>
@@ -58,16 +57,6 @@ int cleanup_before_linux_select(int flags)
 	return 0;
 }
 
-void *phys_to_virt(phys_addr_t paddr)
-{
-	return (void *)(gd->arch.ram_buf + paddr);
-}
-
-phys_addr_t virt_to_phys(void *vaddr)
-{
-	return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf);
-}
-
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
 #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD)
@@ -103,11 +92,6 @@ void sandbox_set_enable_pci_map(int enable)
 	enable_pci_map = enable;
 }
 
-phys_addr_t map_to_sysmem(const void *ptr)
-{
-	return (u8 *)ptr - gd->arch.ram_buf;
-}
-
 void flush_dcache_range(unsigned long start, unsigned long stop)
 {
 }
@@ -178,22 +162,3 @@ void longjmp(jmp_buf jmp, int ret)
 	while (1)
 		;
 }
-
-#ifdef CONFIG_EFI_LOADER
-
-/*
- * In sandbox, we don't have a 1:1 map, so we need to expose
- * process addresses instead of U-Boot addresses
- */
-void efi_add_known_memory(void)
-{
-	u64 ram_start = (uintptr_t)map_sysmem(0, gd->ram_size);
-	u64 ram_size = gd->ram_size;
-	u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
-	u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
-
-	efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY,
-			   false);
-}
-
-#endif
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index cc50819ab9..75ad564274 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -12,6 +12,7 @@
 /* Main state record for the sandbox */
 static struct sandbox_state main_state;
 static struct sandbox_state *state;	/* Pointer to current state record */
+static __attribute__ ((section (".ram"))) u8 sandbox_ram[CONFIG_SYS_SDRAM_SIZE];
 
 static int state_ensure_space(int extra_size)
 {
@@ -366,8 +367,7 @@ int state_init(void)
 	state = &main_state;
 
 	state->ram_size = CONFIG_SYS_SDRAM_SIZE;
-	state->ram_buf = os_malloc(state->ram_size);
-	assert(state->ram_buf);
+	state->ram_buf = sandbox_ram;
 
 	state_reset_for_test(state);
 	/*
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index 3a6cf55eb9..dd649df1f8 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -50,3 +50,12 @@ SECTIONS
 }
 
 INSERT BEFORE .data;
+
+SECTIONS
+{
+	.ram 0x8000000 : {
+		*(.ram)
+	}
+}
+
+INSERT BEFORE .bss;
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 81b7750628..fe792200a7 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -6,12 +6,6 @@
 #ifndef __SANDBOX_ASM_IO_H
 #define __SANDBOX_ASM_IO_H
 
-void *phys_to_virt(phys_addr_t paddr);
-#define phys_to_virt phys_to_virt
-
-phys_addr_t virt_to_phys(void *vaddr);
-#define virt_to_phys virt_to_phys
-
 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
 #define map_physmem map_physmem
 
@@ -23,20 +17,19 @@ void unmap_physmem(const void *vaddr, unsigned long flags);
 
 #include <asm-generic/io.h>
 
-/* For sandbox, we want addresses to point into our RAM buffer */
 static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
 {
-	return map_physmem(paddr, len, MAP_WRBACK);
+	return (void *)(unsigned long)paddr;
 }
 
-/* Remove a previous mapping */
 static inline void unmap_sysmem(const void *vaddr)
 {
-	unmap_physmem(vaddr, MAP_WRBACK);
 }
 
-/* Map from a pointer to our RAM buffer */
-phys_addr_t map_to_sysmem(const void *ptr);
+static inline phys_addr_t map_to_sysmem(const void *ptr)
+{
+	return (phys_addr_t)(unsigned long)ptr;
+}
 
 /* Define nops for sandbox I/O access */
 #define readb(addr) ((void)addr, 0)
diff --git a/common/board_f.c b/common/board_f.c
index e943347ce3..b06f9d30ad 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -219,7 +219,9 @@ static int setup_mon_len(void)
 {
 #if defined(__ARM__) || defined(__MICROBLAZE__)
 	gd->mon_len = (ulong)&__bss_end - (ulong)_start;
-#elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
+#elif defined(CONFIG_SANDBOX)
+	gd->mon_len = 0;
+#elif defined(CONFIG_EFI_APP)
 	gd->mon_len = (ulong)&_end - (ulong)_init;
 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
 	gd->mon_len = CONFIG_SYS_MONITOR_LEN;
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 20a2ab3ffb..5c47b651d4 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -1,4 +1,4 @@
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SANDBOX64=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox64"
@@ -11,13 +11,13 @@ CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_PRE_CON_BUF_ADDR=0x100000
+CONFIG_PRE_CON_BUF_ADDR=0x8100000
 CONFIG_LOG_MAX_LEVEL=6
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_CMD_CPU=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 2fc84a16c9..84828c972c 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,4 +1,4 @@
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_DISTRO_DEFAULTS=y
@@ -10,13 +10,13 @@ CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_PRE_CON_BUF_ADDR=0x100000
+CONFIG_PRE_CON_BUF_ADDR=0x8100000
 CONFIG_LOG_MAX_LEVEL=6
 CONFIG_LOG_ERROR_RETURN=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index e922c4b38f..567ec15c22 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -1,4 +1,4 @@
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_DISTRO_DEFAULTS=y
@@ -10,7 +10,7 @@ CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig
index 8bdd4edcda..c46b0bc06c 100644
--- a/configs/sandbox_noblk_defconfig
+++ b/configs/sandbox_noblk_defconfig
@@ -1,4 +1,4 @@
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_DISTRO_DEFAULTS=y
@@ -10,7 +10,7 @@ CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_CONSOLE_RECORD=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index fb6bb4baa2..4327e3f8b6 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -1,4 +1,4 @@
-CONFIG_SYS_TEXT_BASE=0
+CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
@@ -17,7 +17,7 @@ CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
 CONFIG_BOOTSTAGE_STASH=y
-CONFIG_BOOTSTAGE_STASH_ADDR=0x0
+CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 1a49d1dab5..d0e5a5d6bf 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -6,12 +6,18 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+/* Size of our emulated memory */
+#define CONFIG_SYS_SDRAM_BASE		0x8000000
+#define CONFIG_SYS_SDRAM_SIZE		(128 << 20)
+#define CONFIG_SYS_MONITOR_BASE	0
+#define CONFIG_NR_DRAM_BANKS		1
+
 #ifdef FTRACE
 #define CONFIG_TRACE
 #define CONFIG_TRACE_BUFFER_SIZE	(16 << 20)
 #define CONFIG_TRACE_EARLY_SIZE		(8 << 20)
 #define CONFIG_TRACE_EARLY
-#define CONFIG_TRACE_EARLY_ADDR		0x00100000
+#define CONFIG_TRACE_EARLY_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x100000)
 
 #endif
 
@@ -30,7 +36,7 @@
 /*
  * Size of malloc() pool, before and after relocation
  */
-#define CONFIG_MALLOC_F_ADDR		0x0010000
+#define CONFIG_MALLOC_F_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x10000)
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)	/* 32MB  */
 
 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
@@ -44,19 +50,13 @@
 #define CONFIG_I2C_EDID
 
 /* Memory things - we don't really want a memory test */
-#define CONFIG_SYS_LOAD_ADDR		0x00000000
-#define CONFIG_SYS_MEMTEST_START	0x00100000
+#define CONFIG_SYS_LOAD_ADDR		CONFIG_SYS_SDRAM_BASE
+#define CONFIG_SYS_MEMTEST_START	(CONFIG_SYS_SDRAM_BASE + 0x100000)
 #define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_MEMTEST_START + 0x1000)
-#define CONFIG_SYS_FDT_LOAD_ADDR	        0x100
+#define CONFIG_SYS_FDT_LOAD_ADDR	(CONFIG_SYS_SDRAM_BASE + 0x100)
 
 #define CONFIG_PHYSMEM
 
-/* Size of our emulated memory */
-#define CONFIG_SYS_SDRAM_BASE		0
-#define CONFIG_SYS_SDRAM_SIZE		(128 << 20)
-#define CONFIG_SYS_MONITOR_BASE	0
-#define CONFIG_NR_DRAM_BANKS		1
-
 #define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
 					115200}
 
@@ -104,11 +104,11 @@
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x10000000\0" \
-	"kernel_addr_r=0x1000000\0" \
-	"fdt_addr_r=0xc00000\0" \
-	"ramdisk_addr_r=0x2000000\0" \
-	"scriptaddr=0x1000\0" \
-	"pxefile_addr_r=0x2000\0"
+	"kernel_addr_r=0x9000000\0" \
+	"fdt_addr_r=0x8c00000\0" \
+	"ramdisk_addr_r=0xa000000\0" \
+	"scriptaddr=0x8001000\0" \
+	"pxefile_addr_r=0x8002000\0"
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	SANDBOX_SERIAL_SETTINGS \
-- 
2.12.3

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

* [U-Boot] [PATCH v3 14/17] distro: Move to compiler based target architecture determination
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (12 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 13/17] sandbox: Enable 1:1 map Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 15/17] efi_loader: " Alexander Graf
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

Thanks to CONFIG_SANDBOX, we can not rely on config options to tell us
what CPU architecture we're running on.

The compiler however does know that, so let's just move the ifdefs over
to compiler based defines rather than kconfig based options.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 include/config_distro_bootcmd.h | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 1bd79ae3b8..ca6c57edbf 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -245,35 +245,24 @@
 #if defined(CONFIG_CMD_DHCP)
 #if defined(CONFIG_EFI_LOADER)
 /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
-#if defined(CONFIG_ARM64)
+#if defined(__aarch64__)
 #define BOOTENV_EFI_PXE_ARCH "0xb"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000"
-#elif defined(CONFIG_ARM)
+#elif defined(__arm__)
 #define BOOTENV_EFI_PXE_ARCH "0xa"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000"
-
-/* For sandbox we only support 64-bit x86 at present */
-#elif defined(CONFIG_X86)
-/* Always assume we're running 64bit */
+#elif defined(__x86_64__)
 #define BOOTENV_EFI_PXE_ARCH "0x7"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
-#elif defined(CONFIG_CPU_RISCV_32)
+#elif defined(__i386__)
+#define BOOTENV_EFI_PXE_ARCH "0x0"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00000:UNDI:003000"
+#elif defined(__riscv) && (__riscv_xlen == 32)
 #define BOOTENV_EFI_PXE_ARCH "0x19"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000"
-#elif defined(CONFIG_CPU_RISCV_64)
+#elif defined(__riscv) && (__riscv_xlen == 64)
 #define BOOTENV_EFI_PXE_ARCH "0x1b"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000"
-#elif defined(CONFIG_SANDBOX)
-/*
- * TODO(sjg at chromium.org): Consider providing a way to enable sandbox features
- * based on the host architecture
- */
-# ifndef __x86_64__
-#  warning "sandbox EFI support is only tested on 64-bit x86"
-# endif
-/* To support other *host* architectures this should be changed */
-#define BOOTENV_EFI_PXE_ARCH "0x7"
-#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
 #else
 #error Please specify an EFI client identifier
 #endif
-- 
2.12.3

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

* [U-Boot] [PATCH v3 15/17] efi_loader: Move to compiler based target architecture determination
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (13 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 14/17] distro: Move to compiler based target architecture determination Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 16/17] sandbox: Allow to execute from RAM Alexander Graf
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

Thanks to CONFIG_SANDBOX, we can not rely on config options to tell us
what CPU architecture we're running on.

The compiler however does know that, so let's just move the ifdefs over
to compiler based defines rather than kconfig based options.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_runtime.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 388dfb9840..bc44e43745 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -32,18 +32,18 @@ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
  * TODO(sjg at chromium.org): These defines and structs should come from the elf
  * header for each arch (or a generic header) rather than being repeated here.
  */
-#if defined(CONFIG_ARM64)
+#if defined(__aarch64__)
 #define R_RELATIVE	1027
 #define R_MASK		0xffffffffULL
 #define IS_RELA		1
-#elif defined(CONFIG_ARM)
+#elif defined(__arm__)
 #define R_RELATIVE	23
 #define R_MASK		0xffULL
-#elif defined(CONFIG_X86)
+#elif defined(__x86_64__) || defined(__i386__)
 #include <asm/elf.h>
 #define R_RELATIVE	R_386_RELATIVE
 #define R_MASK		0xffULL
-#elif defined(CONFIG_RISCV)
+#elif defined(__riscv)
 #include <elf.h>
 #define R_RELATIVE	R_RISCV_RELATIVE
 #define R_MASK		0xffULL
@@ -55,25 +55,15 @@ struct dyn_sym {
 	u32 foo2;
 	u32 foo3;
 };
-#ifdef CONFIG_CPU_RISCV_32
+#if (__riscv_xlen == 32)
 #define R_ABSOLUTE	R_RISCV_32
 #define SYM_INDEX	8
-#else
+#elif (__riscv_xlen == 64)
 #define R_ABSOLUTE	R_RISCV_64
 #define SYM_INDEX	32
+#else
+#error unknown riscv target
 #endif
-
-/* For sandbox we only support 64-bit x86 at present */
-#elif defined(CONFIG_SANDBOX)
-/*
- * TODO(sjg at chromium.org): Consider providing a way to enable sandbox features
- * based on the host architecture
- */
-# ifndef __x86_64__
-#  warning "sandbox EFI support is only tested on 64-bit x86"
-# endif
-#define R_RELATIVE	8
-#define R_MASK		0xffffffffULL
 #else
 #error Need to add relocation awareness
 #endif
-- 
2.12.3

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

* [U-Boot] [PATCH v3 16/17] sandbox: Allow to execute from RAM
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (14 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 15/17] efi_loader: " Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 17/17] sandbox: Fix setjmp/longjmp Alexander Graf
  2018-06-15 15:18 ` [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Simon Glass
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

With efi_loader, we may want to execute payload from RAM. By default,
permissions on the RAM region don't allow us to execute from there though.

So whenever we get into the efi_loader case, let's mark RAM as executable.
That way we still protect normal cases, but allow for efi binaries to
directly get executed from within RAM.

For this, we hook into the already existing allow_unaligned() call which
also transitions the system over into semantics required by the UEFI
specification.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/sandbox/cpu/cpu.c | 10 ++++++++++
 arch/sandbox/cpu/os.c  | 23 +++++++++++++++++++++++
 include/os.h           | 19 +++++++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index b20894b806..944f104899 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -162,3 +162,13 @@ void longjmp(jmp_buf jmp, int ret)
 	while (1)
 		;
 }
+
+void allow_unaligned(void)
+{
+	int r;
+
+	r = os_mprotect(gd->arch.ram_buf, gd->ram_size,
+			OS_PROT_READ | OS_PROT_WRITE | OS_PROT_EXEC);
+
+	assert(!r);
+}
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 5839932b00..81206ba0d2 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -183,6 +183,29 @@ void *os_realloc(void *ptr, size_t length)
 	return buf;
 }
 
+int os_mprotect(void *ptr, size_t length, int prot)
+{
+	struct os_mem_hdr *hdr = ptr;
+	int p = 0;
+
+	if ((uintptr_t)ptr & sizeof(*hdr)) {
+		/*
+		 * We got an unaligned pointer, probably a return value
+		 * from os_malloc()
+		 */
+		ptr = &hdr[-1];
+	}
+
+	if (prot & OS_PROT_READ)
+		p |= PROT_READ;
+	if (prot & OS_PROT_WRITE)
+		p |= PROT_WRITE;
+	if (prot & OS_PROT_EXEC)
+		p |= PROT_EXEC;
+
+	return mprotect(ptr, length, p);
+}
+
 void os_usleep(unsigned long usec)
 {
 	usleep(usec);
diff --git a/include/os.h b/include/os.h
index c8e0f52d30..d451e12064 100644
--- a/include/os.h
+++ b/include/os.h
@@ -157,6 +157,25 @@ void os_free(void *ptr);
 void *os_realloc(void *ptr, size_t length);
 
 /**
+ * Modify protection of a memory region
+ *
+ * This function changes the memory protection scheme of a given memory
+ * region. Using it you can for example allow execution of memory that
+ * would otherwise prohibit it.
+ *
+ * \param ptr		Pointer to memory region to modify
+ * \param length	New length for memory block
+ * \param prot		New protection scheme (ORed OS_PROT_ values)
+ * \return 0 on success, -1 otherwise.
+ */
+int os_mprotect(void *ptr, size_t length, int prot);
+
+/* Defines for "prot" in os_mprotect() */
+#define OS_PROT_READ	0x1
+#define OS_PROT_WRITE	0x2
+#define OS_PROT_EXEC	0x4
+
+/**
  * Access to the usleep function of the os
  *
  * \param usec Time to sleep in micro seconds
-- 
2.12.3

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

* [U-Boot] [PATCH v3 17/17] sandbox: Fix setjmp/longjmp
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (15 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 16/17] sandbox: Allow to execute from RAM Alexander Graf
@ 2018-06-15 12:42 ` Alexander Graf
  2018-06-15 15:18 ` [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Simon Glass
  17 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 12:42 UTC (permalink / raw)
  To: u-boot

In sandbox, longjmp returns to itself in an endless loop. Cut this through
by calling the real OS function.

Setjmp on the other hand must not return. So here we have to call the OS
setjmp function straight from the code where the setjmp call happens.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/sandbox/cpu/cpu.c            |  5 -----
 arch/sandbox/cpu/os.c             | 20 ++------------------
 arch/sandbox/include/asm/setjmp.h |  4 +++-
 3 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 944f104899..1d9f10df98 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -151,11 +151,6 @@ ulong timer_get_boot_us(void)
 	return (count - base_count) / 1000;
 }
 
-int setjmp(jmp_buf jmp)
-{
-	return os_setjmp((ulong *)jmp, sizeof(*jmp));
-}
-
 void longjmp(jmp_buf jmp, int ret)
 {
 	os_longjmp((ulong *)jmp, ret);
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 81206ba0d2..4ef4040103 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -653,24 +653,8 @@ void os_localtime(struct rtc_time *rt)
 	rt->tm_isdst = tm->tm_isdst;
 }
 
-int os_setjmp(ulong *jmp, int size)
-{
-	jmp_buf dummy;
-
-	/*
-	 * We cannot rely on the struct name that jmp_buf uses, so use a
-	 * local variable here
-	 */
-	if (size < sizeof(dummy)) {
-		printf("setjmp: jmpbuf is too small (%d bytes, need %d)\n",
-		       size, sizeof(jmp_buf));
-		return -ENOSPC;
-	}
-
-	return setjmp((struct __jmp_buf_tag *)jmp);
-}
-
 void os_longjmp(ulong *jmp, int ret)
 {
-	longjmp((struct __jmp_buf_tag *)jmp, ret);
+	/* Call the OS longjmp function directly */
+	_longjmp((struct __jmp_buf_tag *)jmp, ret);
 }
diff --git a/arch/sandbox/include/asm/setjmp.h b/arch/sandbox/include/asm/setjmp.h
index 1fe37c91cc..e103d170e0 100644
--- a/arch/sandbox/include/asm/setjmp.h
+++ b/arch/sandbox/include/asm/setjmp.h
@@ -24,7 +24,9 @@ struct jmp_buf_data {
 
 typedef struct jmp_buf_data jmp_buf[1];
 
-int setjmp(jmp_buf jmp);
+/* Call the OS setjmp function directly, so that we don't introduce returns */
+#define setjmp _setjmp
+int _setjmp(jmp_buf jmp);
 __noreturn void longjmp(jmp_buf jmp, int ret);
 
 #endif /* _SETJMP_H_ */
-- 
2.12.3

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

* [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address Alexander Graf
@ 2018-06-15 14:24   ` Simon Glass
  2018-06-15 14:30     ` Alexander Graf
  0 siblings, 1 reply; 21+ messages in thread
From: Simon Glass @ 2018-06-15 14:24 UTC (permalink / raw)
  To: u-boot

Hi Alex,

On 15 June 2018 at 06:42, Alexander Graf <agraf@suse.de> wrote:
> The fs_read() and fs_write() functions are internal interfaces that
> naturally want to get pointers as arguments. Most users so far even
> have pointers and explicitly cast them into integers just to be able
> to pass them into the function.
>
> Convert them over to instead take a pointer argument for the buffer.
> That way any sandbox mapping gets greatly simplified and users of
> the API intuitively know what to do.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  board/BuR/common/common.c             |  2 +-
>  board/gdsys/p1022/controlcenterd-id.c | 10 +++++-----
>  cmd/mvebu/bubt.c                      |  4 ++--
>  common/splash_source.c                |  4 +++-
>  drivers/bootcount/bootcount_ext.c     | 12 ++++++------
>  drivers/fpga/zynqpl.c                 |  8 +++++---
>  fs/fs.c                               | 20 ++++++++++----------
>  include/fs.h                          | 12 ++++++------
>  lib/efi_loader/efi_file.c             |  6 ++----
>  9 files changed, 40 insertions(+), 38 deletions(-)

U-Boot uses addresses for loading and managing images. I don't see a
good reason to change that. We expect all logging to emit an address
rather than a pointer, for example. See for example all the FIT and
legacy image stuff, bootm, all the commands, etc.

Regards,
Simon

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

* [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address
  2018-06-15 14:24   ` Simon Glass
@ 2018-06-15 14:30     ` Alexander Graf
  0 siblings, 0 replies; 21+ messages in thread
From: Alexander Graf @ 2018-06-15 14:30 UTC (permalink / raw)
  To: u-boot



On 15.06.18 16:24, Simon Glass wrote:
> Hi Alex,
> 
> On 15 June 2018 at 06:42, Alexander Graf <agraf@suse.de> wrote:
>> The fs_read() and fs_write() functions are internal interfaces that
>> naturally want to get pointers as arguments. Most users so far even
>> have pointers and explicitly cast them into integers just to be able
>> to pass them into the function.
>>
>> Convert them over to instead take a pointer argument for the buffer.
>> That way any sandbox mapping gets greatly simplified and users of
>> the API intuitively know what to do.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>  board/BuR/common/common.c             |  2 +-
>>  board/gdsys/p1022/controlcenterd-id.c | 10 +++++-----
>>  cmd/mvebu/bubt.c                      |  4 ++--
>>  common/splash_source.c                |  4 +++-
>>  drivers/bootcount/bootcount_ext.c     | 12 ++++++------
>>  drivers/fpga/zynqpl.c                 |  8 +++++---
>>  fs/fs.c                               | 20 ++++++++++----------
>>  include/fs.h                          | 12 ++++++------
>>  lib/efi_loader/efi_file.c             |  6 ++----
>>  9 files changed, 40 insertions(+), 38 deletions(-)
> 
> U-Boot uses addresses for loading and managing images. I don't see a
> good reason to change that. We expect all logging to emit an address
> rather than a pointer, for example. See for example all the FIT and
> legacy image stuff, bootm, all the commands, etc.

Yes, usually the point of transition from address is when you go from
command line to internal infrastructure.

If you for example take a look at struct fstype_info in fs.c, you can
see that the read and write callbacks already use pointers.

The block equivalent of fs_read() is blk_dread() which also takes a buffer.

fs_read()/fs_write() really are the odd ones out in the API. And if you
take a look at all users of the API, I'd say 90% of them already get it
"wrong" (read: they assume a 1:1 map and just randomly cast pointers to
addresses).

So IMHO this patch really is just streamlining the API to adjust it to
the rest of the U-Boot infrastructure.


Alex

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

* [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support
  2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
                   ` (16 preceding siblings ...)
  2018-06-15 12:42 ` [U-Boot] [PATCH v3 17/17] sandbox: Fix setjmp/longjmp Alexander Graf
@ 2018-06-15 15:18 ` Simon Glass
  17 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2018-06-15 15:18 UTC (permalink / raw)
  To: u-boot

Hi Alex,

On 15 June 2018 at 06:42, Alexander Graf <agraf@suse.de> wrote:
>
> This patch set augments Simon's patch set for efi_loader support
> in sandbox[1], but follows a different memory allocation scheme.
>
> Instead of keeping U-Boot addresses in the EFI memory map, this
> patch set makes the EFI memory map contain host virtual addresses.
> That way most logic "just works" and all EFI interfaces automatically
> gain sandbox awareness.
>
> We also change the memory map of sandbox to hard code RAM to always
> live at address 0x80000000. This patch is completely optional.
>
> With this patch set in place, I can successfully run the selftest suite
> as well as an aarch64 grub.efi binary. X86_64 grub.efi doesn't work
> because that one requires inl instructions to work.
>
> Alex
>
> [1] https://patchwork.ozlabs.org/project/uboot/list/?series=49832
>
> v1 -> v2:
>
>   - only compile efi_add_known_memory if efi_loader is enabled
>   - clarify address vs pointer in fs_read patch
>   - include mapmem.h
>
> v2 -> v3:
>
>   - removed: efi_loader: Pass address to fs_read()
>   - new: fs: Convert fs_read/write to take buffer instead of address
>   - new: efi_loader: Introduce ms abi vararg helpers
>   - new: sandbox: Enable 1:1 map
>   - new: distro: Move to compiler based target architecture determination
>   - new: efi_loader: Move to compiler based target architecture determination
>   - new: sandbox: Allow to execute from RAM
>   - new: sandbox: Fix setjmp/longjmp
>
> Alexander Graf (13):
>   efi_loader: Use compiler constants for image loader
>   efi_loader: Use map_sysmem() in bootefi command
>   efi.h: Do not use config options
>   efi_loader: Allow SMBIOS tables in highmem
>   sandbox: Map host memory for efi_loader
>   efi_loader: Disable miniapps on sandbox
>   fs: Convert fs_read/write to take buffer instead of address
>   efi_loader: Introduce ms abi vararg helpers
>   sandbox: Enable 1:1 map
>   distro: Move to compiler based target architecture determination
>   efi_loader: Move to compiler based target architecture determination
>   sandbox: Allow to execute from RAM
>   sandbox: Fix setjmp/longjmp
>
> Heinrich Schuchardt (1):
>   efi_loader: efi_allocate_pages is too restrictive
>
> Simon Glass (3):
>   efi: sandbox: Add distroboot support
>   efi: sandbox: Add relocation constants
>   efi: sandbox: Enable EFI loader for sandbox
>
>  Makefile                              |  2 +-
>  arch/sandbox/cpu/cpu.c                | 30 ++++++++----------------
>  arch/sandbox/cpu/os.c                 | 43 ++++++++++++++++++++---------------
>  arch/sandbox/cpu/state.c              |  4 ++--
>  arch/sandbox/cpu/u-boot.lds           |  9 ++++++++
>  arch/sandbox/include/asm/io.h         | 17 ++++----------
>  arch/sandbox/include/asm/setjmp.h     |  4 +++-
>  board/BuR/common/common.c             |  2 +-
>  board/gdsys/p1022/controlcenterd-id.c | 10 ++++----
>  cmd/bootefi.c                         | 13 +++++++----
>  cmd/mvebu/bubt.c                      |  4 ++--
>  common/board_f.c                      |  4 +++-
>  common/splash_source.c                |  4 +++-
>  configs/sandbox64_defconfig           |  6 ++---
>  configs/sandbox_defconfig             |  6 ++---
>  configs/sandbox_flattree_defconfig    |  4 ++--
>  configs/sandbox_noblk_defconfig       |  4 ++--
>  configs/sandbox_spl_defconfig         |  4 ++--
>  drivers/bootcount/bootcount_ext.c     | 12 +++++-----
>  drivers/fpga/zynqpl.c                 |  8 ++++---
>  fs/fs.c                               | 20 ++++++++--------
>  include/config_distro_bootcmd.h       | 14 +++++++-----
>  include/configs/sandbox.h             | 32 +++++++++++++-------------
>  include/efi.h                         | 25 ++++++++++----------
>  include/fs.h                          | 12 +++++-----
>  include/os.h                          | 19 ++++++++++++++++
>  lib/efi/Makefile                      |  4 ++--
>  lib/efi_loader/Kconfig                |  2 +-
>  lib/efi_loader/efi_boottime.c         | 36 ++++++++++++++---------------
>  lib/efi_loader/efi_file.c             |  6 ++---
>  lib/efi_loader/efi_image_loader.c     | 12 +++++-----
>  lib/efi_loader/efi_memory.c           |  2 +-
>  lib/efi_loader/efi_runtime.c          | 14 +++++++-----
>  lib/efi_loader/efi_smbios.c           | 11 +++++++--
>  lib/efi_selftest/Makefile             |  2 +-
>  35 files changed, 219 insertions(+), 182 deletions(-)
>
> --
> 2.12.3
>

General comment on this series. I don't see the need to change how
sandbox works just to avoid a few map_sysmem() calls in the EFI code.
I don't think it is very hard to press on from 'sandbox runs hello
world' to 'sandbox runs grub', particularly as you have solved some of
the other problems. I'll take a look.

Regards,
Simon

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

end of thread, other threads:[~2018-06-15 15:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 12:42 [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 01/17] efi: sandbox: Add distroboot support Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 02/17] efi: sandbox: Add relocation constants Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 03/17] efi_loader: Use compiler constants for image loader Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 04/17] efi_loader: Use map_sysmem() in bootefi command Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 05/17] efi.h: Do not use config options Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 06/17] efi_loader: Allow SMBIOS tables in highmem Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 07/17] sandbox: Map host memory for efi_loader Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 08/17] efi_loader: efi_allocate_pages is too restrictive Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 09/17] efi_loader: Disable miniapps on sandbox Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 10/17] fs: Convert fs_read/write to take buffer instead of address Alexander Graf
2018-06-15 14:24   ` Simon Glass
2018-06-15 14:30     ` Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 11/17] efi_loader: Introduce ms abi vararg helpers Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 12/17] efi: sandbox: Enable EFI loader for sandbox Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 13/17] sandbox: Enable 1:1 map Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 14/17] distro: Move to compiler based target architecture determination Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 15/17] efi_loader: " Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 16/17] sandbox: Allow to execute from RAM Alexander Graf
2018-06-15 12:42 ` [U-Boot] [PATCH v3 17/17] sandbox: Fix setjmp/longjmp Alexander Graf
2018-06-15 15:18 ` [U-Boot] [PATCH v3 00/17] sandbox: efi_loader support Simon Glass

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.