All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader
@ 2020-04-22  0:44 aiden.park at intel.com
  2020-04-22  0:45 ` [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig aiden.park at intel.com
                   ` (8 more replies)
  0 siblings, 9 replies; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:44 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

This patchset will build 64-bit U-Boot as a Slim Bootloader payload
and introduce a new X86_RUN_64BIT_ONLY to build pure 64-bit U-Boot
binary without SPL. In addition, this supports 64-bit kernel booting
from 64-bit U-Boot.

Aiden Park (8):
  x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  x86: start64: Add a hook at 64-bit entry
  x86: start64: Support HOB in 64-bit U-Boot
  x86: slimbootloader: Support 64-bit operation
  configs: slimbootloader: Add x86_64 slimbootloader config
  x86: Fix 64-bit compile warning
  x86: enable 64-bit kernel boot from 64-bit U-Boot
  doc: slimbootloader: Update 64-bit build instruction

 arch/x86/Kconfig                             |  8 ++++++
 arch/x86/cpu/slimbootloader/Makefile         |  9 ++++--
 arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++
 arch/x86/cpu/slimbootloader/slimbootloader.c | 17 ++++++++++--
 arch/x86/cpu/start64.S                       | 10 +++++++
 arch/x86/cpu/x86_64/Makefile                 |  2 +-
 arch/x86/cpu/x86_64/call64.S                 | 21 ++++++++++++++
 arch/x86/cpu/x86_64/cpu.c                    | 10 +++++++
 arch/x86/include/asm/bootparam.h             | 10 ++++++-
 arch/x86/include/asm/zimage.h                |  2 +-
 arch/x86/lib/bootm.c                         | 10 +++++--
 arch/x86/lib/zimage.c                        | 24 ++++++++++------
 cmd/x86/hob.c                                |  8 +++---
 configs/slimbootloader-x86_64_defconfig      | 24 ++++++++++++++++
 doc/board/intel/slimbootloader.rst           | 29 ++++++++++++++++++++
 15 files changed, 176 insertions(+), 22 deletions(-)
 create mode 100644 arch/x86/cpu/slimbootloader/entry64.S
 create mode 100644 arch/x86/cpu/x86_64/call64.S
 create mode 100644 configs/slimbootloader-x86_64_defconfig

-- 
2.20.1

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

* [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 20:15   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 2/8] x86: start64: Add a hook at 64-bit entry aiden.park at intel.com
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

This will build U-Boot as a pure 64-bit binary with no SPL.
It can be used with a pre-stage boot firmware
which has already done 16-bit, 32-bit and 64-bit init.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 arch/x86/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c8eae24c07..89add17e69 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -40,6 +40,14 @@ config X86_RUN_64BIT
 	  runs through the 16-bit and 32-bit init, then switches to 64-bit
 	  mode and jumps to U-Boot proper.
 
+config X86_RUN_64BIT_ONLY
+	bool "64-bit only"
+	select X86_64
+	help
+	  Build U-Boot as a pure 64-bit binary with no 32-bit SPL. This can
+	  be used with a pre-stage boot firmware which has already done
+	  16-bit, 32-bit and 64-bit init.
+
 endchoice
 
 config X86_64
-- 
2.20.1

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

* [PATCH 2/8] x86: start64: Add a hook at 64-bit entry
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
  2020-04-22  0:45 ` [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 20:15   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot aiden.park at intel.com
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

This will allow a board or cpu to do its specific initialization
at 64-bit entry if U-Boot is a pure 64-bit binary.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 arch/x86/cpu/start64.S | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S
index 7be834788b..b8ac5aab57 100644
--- a/arch/x86/cpu/start64.S
+++ b/arch/x86/cpu/start64.S
@@ -13,6 +13,11 @@
 .globl _start
 .type _start, @function
 _start:
+#if defined(CONFIG_X86_RUN_64BIT_ONLY)
+	jmp	init_64bit_entry
+.globl init_64bit_entry_ret
+init_64bit_entry_ret:
+#endif
 	/* Set up memory using the existing stack */
 	mov	%rsp, %rdi
 	call	board_init_f_alloc_reserve
-- 
2.20.1

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

* [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
  2020-04-22  0:45 ` [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig aiden.park at intel.com
  2020-04-22  0:45 ` [PATCH 2/8] x86: start64: Add a hook at 64-bit entry aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 20:15   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 4/8] x86: slimbootloader: Support 64-bit operation aiden.park at intel.com
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

This will allow 64-bit U-Boot to use HOB.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 arch/x86/cpu/start64.S | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S
index b8ac5aab57..7faf4f6f13 100644
--- a/arch/x86/cpu/start64.S
+++ b/arch/x86/cpu/start64.S
@@ -25,6 +25,11 @@ init_64bit_entry_ret:
 
 	call	board_init_f_init_reserve
 
+#if defined(CONFIG_X86_RUN_64BIT_ONLY) && defined(CONFIG_USE_HOB)
+	mov	%r10, %rdi
+	call	set_hob_list
+#endif
+
 	xor	%rdi, %rdi
 	call	board_init_f
 	call	board_init_f_r
-- 
2.20.1

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

* [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
                   ` (2 preceding siblings ...)
  2020-04-22  0:45 ` [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 20:15   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config aiden.park at intel.com
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

This supports 64-bit U-Boot as a Slim Bootloader payload.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 arch/x86/cpu/slimbootloader/Makefile         |  9 +++++++--
 arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++++++
 arch/x86/cpu/slimbootloader/slimbootloader.c | 17 +++++++++++++++--
 3 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/cpu/slimbootloader/entry64.S

diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile
index aac9fa3db8..79fa699501 100644
--- a/arch/x86/cpu/slimbootloader/Makefile
+++ b/arch/x86/cpu/slimbootloader/Makefile
@@ -1,5 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
-# Copyright (C) 2019 Intel Corporation <www.intel.com>
+# Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
 
-obj-y += car.o slimbootloader.o sdram.o serial.o
+ifeq ($(CONFIG_X86_64),y)
+obj-y += entry64.o
+else
+obj-y += car.o
+endif
+obj-y += slimbootloader.o sdram.o serial.o
diff --git a/arch/x86/cpu/slimbootloader/entry64.S b/arch/x86/cpu/slimbootloader/entry64.S
new file mode 100644
index 0000000000..5e101e18a9
--- /dev/null
+++ b/arch/x86/cpu/slimbootloader/entry64.S
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2020 Intel Corporation <www.intel.com>
+ */
+
+#include <generated/asm-offsets.h>
+
+.section .text
+
+.globl init_64bit_entry
+init_64bit_entry:
+	/* Save hob pointer parameter */
+	mov	%rcx, %r10
+	jmp	init_64bit_entry_ret
diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c b/arch/x86/cpu/slimbootloader/slimbootloader.c
index 21dcfb2142..7857e4cd8b 100644
--- a/arch/x86/cpu/slimbootloader/slimbootloader.c
+++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ * Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
  */
 
 #include <common.h>
@@ -43,11 +43,23 @@ static void tsc_init(void)
 
 int arch_cpu_init(void)
 {
+	int ret = 0;
+
 	tsc_init();
 
-	return x86_cpu_init_f();
+#if !CONFIG_IS_ENABLED(X86_64)
+	ret = x86_cpu_init_f();
+#endif
+	return ret;
 }
 
+#if CONFIG_IS_ENABLED(X86_64)
+int set_hob_list(void *hob_list)
+{
+	gd->arch.hob_list = hob_list;
+	return 0;
+}
+#else
 int checkcpu(void)
 {
 	return 0;
@@ -57,3 +69,4 @@ int print_cpuinfo(void)
 {
 	return default_print_cpuinfo();
 }
+#endif
-- 
2.20.1

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

* [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
                   ` (3 preceding siblings ...)
  2020-04-22  0:45 ` [PATCH 4/8] x86: slimbootloader: Support 64-bit operation aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 20:32   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 6/8] x86: Fix 64-bit compile warning aiden.park at intel.com
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

Add slimbootloader-x86_64_defconfig for 64-bit slimbootloader board.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 configs/slimbootloader-x86_64_defconfig | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 configs/slimbootloader-x86_64_defconfig

diff --git a/configs/slimbootloader-x86_64_defconfig b/configs/slimbootloader-x86_64_defconfig
new file mode 100644
index 0000000000..f046c30179
--- /dev/null
+++ b/configs/slimbootloader-x86_64_defconfig
@@ -0,0 +1,24 @@
+CONFIG_X86=y
+CONFIG_X86_RUN_64BIT_ONLY=y
+CONFIG_ENV_SIZE=0x1000
+CONFIG_VENDOR_INTEL=y
+CONFIG_TARGET_SLIMBOOTLOADER=y
+# CONFIG_USE_CAR is not set
+CONFIG_BOOTSTAGE=y
+CONFIG_BOOTSTAGE_REPORT=y
+CONFIG_BOOTDELAY=10
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_LAST_STAGE_INIT=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_FAT=y
+CONFIG_EFI_PARTITION=y
+CONFIG_DEFAULT_DEVICE_TREE="slimbootloader"
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
+# CONFIG_PCI_PNP is not set
+CONFIG_CONSOLE_SCROLL_LINES=5
-- 
2.20.1

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

* [PATCH 6/8] x86: Fix 64-bit compile warning
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
                   ` (4 preceding siblings ...)
  2020-04-22  0:45 ` [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 19:45   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot aiden.park at intel.com
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

This is to fix pointer type cast warning in hob command.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 cmd/x86/hob.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/x86/hob.c b/cmd/x86/hob.c
index 3967a7ca5a..8c2c1ffc63 100644
--- a/cmd/x86/hob.c
+++ b/cmd/x86/hob.c
@@ -36,14 +36,14 @@ static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	hdr = gd->arch.hob_list;
 
-	printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
+	printf("HOB list address: 0x%p\n\n", hdr);
 
-	printf("#  | Address  | Type      | Len  | ");
+	printf("#  |          Address | Type      | Len  | ");
 	printf("%36s\n", "GUID");
-	printf("---|----------|-----------|------|-");
+	printf("---|------------------|-----------|------|-");
 	printf("------------------------------------\n");
 	while (!end_of_hob(hdr)) {
-		printf("%02x | %08x | ", i, (unsigned int)hdr);
+		printf("%02x | %p | ", i, hdr);
 		type = hdr->type;
 		if (type == HOB_TYPE_UNUSED)
 			desc = "*Unused*";
-- 
2.20.1

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

* [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
                   ` (5 preceding siblings ...)
  2020-04-22  0:45 ` [PATCH 6/8] x86: Fix 64-bit compile warning aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-26 20:15   ` Simon Glass
  2020-04-22  0:45 ` [PATCH 8/8] doc: slimbootloader: Update 64-bit build instruction aiden.park at intel.com
  2020-04-26 20:15 ` [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader Simon Glass
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 arch/x86/cpu/x86_64/Makefile     |  2 +-
 arch/x86/cpu/x86_64/call64.S     | 21 +++++++++++++++++++++
 arch/x86/cpu/x86_64/cpu.c        | 10 ++++++++++
 arch/x86/include/asm/bootparam.h | 10 +++++++++-
 arch/x86/include/asm/zimage.h    |  2 +-
 arch/x86/lib/bootm.c             | 10 +++++++---
 arch/x86/lib/zimage.c            | 24 ++++++++++++++++--------
 7 files changed, 65 insertions(+), 14 deletions(-)
 create mode 100644 arch/x86/cpu/x86_64/call64.S

diff --git a/arch/x86/cpu/x86_64/Makefile b/arch/x86/cpu/x86_64/Makefile
index 400f0ffe39..951e503a1f 100644
--- a/arch/x86/cpu/x86_64/Makefile
+++ b/arch/x86/cpu/x86_64/Makefile
@@ -3,4 +3,4 @@
 # Written by Simon Glass <sjg@chromium.org>
 #
 
-obj-y += cpu.o interrupts.o setjmp.o
+obj-y += cpu.o interrupts.o setjmp.o call64.o
diff --git a/arch/x86/cpu/x86_64/call64.S b/arch/x86/cpu/x86_64/call64.S
new file mode 100644
index 0000000000..e2cfe15080
--- /dev/null
+++ b/arch/x86/cpu/x86_64/call64.S
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2020 Intel Corporation <www.intel.com>
+ */
+
+.code64
+.globl cpu_call64
+cpu_call64:
+	/*
+	 * cpu_call64(ulong pgtable, ulong setup_base, ulong target)
+	 *
+	 * rdi - pgtable (unused - already in 64-bit with paging)
+	 * rsi - setup_base
+	 * rdx - target
+	 *
+	 */
+	cli
+	mov	%rdx, %rcx
+	mov	%rsi, %rdx
+	call	*%rcx
+	ret
diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index 90925e46ea..0730c43f1c 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <debug_uart.h>
+#include <asm/cpu.h>
 
 /*
  * Global declaration of gd.
@@ -67,3 +68,12 @@ int x86_cpu_reinit_f(void)
 {
 	return 0;
 }
+
+int cpu_jump_to_64bit(ulong setup_base, ulong load_address)
+{
+	ulong target = load_address + 0x200;
+
+	cpu_call64(0, setup_base, target);
+
+	return -EFAULT;
+}
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index d961dddc9e..73c94a33ec 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -59,7 +59,15 @@ struct setup_header {
 	__u32	initrd_addr_max;
 	__u32	kernel_alignment;
 	__u8	relocatable_kernel;
-	__u8	_pad2[3];
+	__u8	min_alignment;
+	__u16	xloadflags;
+#define XLF_KERNEL_64			BIT(0)
+#define XLF_CAN_BE_LOADED_ABOVE_4G	BIT(1)
+#define XLF_EFI_HANDOVER_32		BIT(2)
+#define XLF_EFI_HANDOVER_64		BIT(3)
+#define XLF_EFI_KEXEC			BIT(4)
+#define XLF_5LEVEL			BIT(5)
+#define XLF_5LEVEL_ENABLED		BIT(6)
 	__u32	cmdline_size;
 	__u32	hardware_subarch;
 	__u64	hardware_subarch_data;
diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 80e128ccf3..cadeb04168 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -31,7 +31,7 @@
 #define ZIMAGE_LOAD_ADDR   0x10000
 
 struct boot_params *load_zimage(char *image, unsigned long kernel_size,
-				ulong *load_addressp);
+				ulong *load_addressp, bool *image_64bit);
 int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
 		 unsigned long initrd_addr, unsigned long initrd_size);
 void setup_video(struct screen_info *screen_info);
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 07d8f1f279..ebed9e4605 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -74,6 +74,7 @@ static int boot_prep_linux(bootm_headers_t *images)
 	void *data = NULL;
 	size_t len;
 	int ret;
+	bool image_64bit;
 
 #ifdef CONFIG_OF_LIBFDT
 	if (images->ft_len) {
@@ -116,7 +117,8 @@ static int boot_prep_linux(bootm_headers_t *images)
 		ulong load_address;
 		char *base_ptr;
 
-		base_ptr = (char *)load_zimage(data, len, &load_address);
+		base_ptr = (char *)load_zimage(data, len, &load_address,
+					       &image_64bit);
 		if (!base_ptr) {
 			puts("## Kernel loading failed ...\n");
 			goto error;
@@ -124,6 +126,10 @@ static int boot_prep_linux(bootm_headers_t *images)
 		images->os.load = load_address;
 		cmd_line_dest = base_ptr + COMMAND_LINE_OFFSET;
 		images->ep = (ulong)base_ptr;
+#if CONFIG_IS_ENABLED(X86_64)
+		if (image_64bit)
+			images->os.arch = IH_ARCH_X86_64;
+#endif
 	} else if (images->ep) {
 		cmd_line_dest = (void *)images->ep + COMMAND_LINE_OFFSET;
 	} else {
@@ -164,9 +170,7 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
 		 * TODO(sjg at chromium.org): Support booting both 32-bit and
 		 * 64-bit kernels from 64-bit U-Boot.
 		 */
-#if !CONFIG_IS_ENABLED(X86_64)
 		return cpu_jump_to_64bit(setup_base, load_address);
-#endif
 	} else {
 		/*
 		* Set %ebx, %ebp, and %edi to 0, %esi to point to the
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index ffc09630b7..c84e2d39b2 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -129,7 +129,7 @@ static int setup_device_tree(struct setup_header *hdr, const void *fdt_blob)
 }
 
 struct boot_params *load_zimage(char *image, unsigned long kernel_size,
-				ulong *load_addressp)
+				ulong *load_addressp, bool *image_64bit)
 {
 	struct boot_params *setup_base;
 	int setup_size;
@@ -179,6 +179,9 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
 	big_image = (bootproto >= 0x0200) &&
 		    (hdr->loadflags & BIG_KERNEL_FLAG);
 
+	/* Determine 64-bit kernel */
+	*image_64bit = (hdr->xloadflags & XLF_KERNEL_64) ? true : false;
+
 	/* Determine load address */
 	if (big_image)
 		*load_addressp = BZIMAGE_LOAD_ADDR;
@@ -313,12 +316,13 @@ void __setup_pcat_compatibility(void)
 int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
 	struct boot_params *base_ptr;
-	void *bzImage_addr = NULL;
+	void *bzimage_addr = NULL;
 	ulong load_address;
 	char *s;
-	ulong bzImage_size = 0;
+	ulong bzimage_size = 0;
 	ulong initrd_addr = 0;
 	ulong initrd_size = 0;
+	bool image_64bit;
 
 	disable_interrupts();
 
@@ -333,11 +337,11 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	}
 
 	if (s)
-		bzImage_addr = (void *)simple_strtoul(s, NULL, 16);
+		bzimage_addr = (void *)simple_strtoul(s, NULL, 16);
 
 	if (argc >= 3) {
 		/* argv[2] holds the size of the bzImage */
-		bzImage_size = simple_strtoul(argv[2], NULL, 16);
+		bzimage_size = simple_strtoul(argv[2], NULL, 16);
 	}
 
 	if (argc >= 4)
@@ -346,8 +350,13 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		initrd_size = simple_strtoul(argv[4], NULL, 16);
 
 	/* Lets look for */
-	base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address);
+	base_ptr = load_zimage(bzimage_addr, bzimage_size, &load_address,
+			       &image_64bit);
+#if !CONFIG_IS_ENABLED(X86_64)
+	image_64bit = false;
+#endif
 
+	/* we assume that the kernel is in place */
 	if (!base_ptr) {
 		puts("## Kernel loading failed ...\n");
 		return -1;
@@ -358,8 +367,7 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		return -1;
 	}
 
-	/* we assume that the kernel is in place */
-	return boot_linux_kernel((ulong)base_ptr, load_address, false);
+	return boot_linux_kernel((ulong)base_ptr, load_address, image_64bit);
 }
 
 U_BOOT_CMD(
-- 
2.20.1

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

* [PATCH 8/8] doc: slimbootloader: Update 64-bit build instruction
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
                   ` (6 preceding siblings ...)
  2020-04-22  0:45 ` [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot aiden.park at intel.com
@ 2020-04-22  0:45 ` aiden.park at intel.com
  2020-04-30  9:13   ` Bin Meng
  2020-04-26 20:15 ` [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader Simon Glass
  8 siblings, 1 reply; 32+ messages in thread
From: aiden.park at intel.com @ 2020-04-22  0:45 UTC (permalink / raw)
  To: u-boot

From: Aiden Park <aiden.park@intel.com>

Add steps to build 64-bit Slim Bootloader and U-Boot.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 doc/board/intel/slimbootloader.rst | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/doc/board/intel/slimbootloader.rst b/doc/board/intel/slimbootloader.rst
index a8c41b1aa7..779ed78ef1 100644
--- a/doc/board/intel/slimbootloader.rst
+++ b/doc/board/intel/slimbootloader.rst
@@ -145,6 +145,35 @@ Also, the PayloadId needs to be set for APL board.
 
    Use DediProg to flash IFWI. You should reach at U-Boot serial console.
 
+Build Instruction for 64-bit Slim Bootloader & U-Boot on QEMU target
+--------------------------------------------------------------------
+
+1. Build 64-bit U-Boot and obtain u-boot-dtb.bin::
+
+   $ make distclean
+   $ make slimbootloader-x86_64_defconfig
+   $ make all
+
+2. Copy u-boot-dtb.bin to Slim Bootloader::
+
+   $ mkdir -p <Slim Bootloader Dir>/PayloadPkg/PayloadBins/
+   $ cp <U-Boot Dir>/u-boot-dtb.bin <Slim Bootloader Dir>/PayloadPkg/PayloadBins/u-boot-dtb.bin
+
+3. Update PayloadId with 'U-BT'::
+
+    $ vi Platform/QemuBoardPkg/CfgData/CfgDataExt_Brd1.dlt
+    -GEN_CFG_DATA.PayloadId                     | 'AUTO'
+    +GEN_CFG_DATA.PayloadId                     | 'U-BT'
+
+4. Update payload text base::
+
+    $ vi Platform/QemuBoardPkg/BoardConfig.py
+    +               self.PAYLOAD_LOAD_HIGH    = 0
+    +               self.PAYLOAD_EXE_BASE     = 0x00100000
+
+5. Build QEMU target::
+
+   $ python BuildLoader.py build qemu -a x64 -p "OsLoader.efi:LLDR:Lz4;u-boot-dtb.bin:U-BT:Lzma"
 
 Build Instruction to use ELF U-Boot
 -----------------------------------
-- 
2.20.1

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

* [PATCH 6/8] x86: Fix 64-bit compile warning
  2020-04-22  0:45 ` [PATCH 6/8] x86: Fix 64-bit compile warning aiden.park at intel.com
@ 2020-04-26 19:45   ` Simon Glass
  2020-04-29  6:08     ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 19:45 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> This is to fix pointer type cast warning in hob command.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  cmd/x86/hob.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/cmd/x86/hob.c b/cmd/x86/hob.c
> index 3967a7ca5a..8c2c1ffc63 100644
> --- a/cmd/x86/hob.c
> +++ b/cmd/x86/hob.c
> @@ -36,14 +36,14 @@ static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>
>         hdr = gd->arch.hob_list;
>
> -       printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
> +       printf("HOB list address: 0x%p\n\n", hdr);

That 0x should not be there as hex is assumed in U-Boot.

Do we actually need a 64-bit pointer here, or will the HOB be below
4GB? I'm really not a fan of 16-character addresses in a user command.

>
> -       printf("#  | Address  | Type      | Len  | ");
> +       printf("#  |          Address | Type      | Len  | ");
>         printf("%36s\n", "GUID");
> -       printf("---|----------|-----------|------|-");
> +       printf("---|------------------|-----------|------|-");
>         printf("------------------------------------\n");
>         while (!end_of_hob(hdr)) {
> -               printf("%02x | %08x | ", i, (unsigned int)hdr);
> +               printf("%02x | %p | ", i, hdr);
>                 type = hdr->type;
>                 if (type == HOB_TYPE_UNUSED)
>                         desc = "*Unused*";
> --
> 2.20.1
>

Regards,
Simon

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

* [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader
  2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
                   ` (7 preceding siblings ...)
  2020-04-22  0:45 ` [PATCH 8/8] doc: slimbootloader: Update 64-bit build instruction aiden.park at intel.com
@ 2020-04-26 20:15 ` Simon Glass
  2020-04-29  5:41   ` Park, Aiden
  8 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:15 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> This patchset will build 64-bit U-Boot as a Slim Bootloader payload
> and introduce a new X86_RUN_64BIT_ONLY to build pure 64-bit U-Boot
> binary without SPL. In addition, this supports 64-bit kernel booting
> from 64-bit U-Boot.
>
> Aiden Park (8):
>   x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
>   x86: start64: Add a hook at 64-bit entry
>   x86: start64: Support HOB in 64-bit U-Boot
>   x86: slimbootloader: Support 64-bit operation
>   configs: slimbootloader: Add x86_64 slimbootloader config
>   x86: Fix 64-bit compile warning
>   x86: enable 64-bit kernel boot from 64-bit U-Boot
>   doc: slimbootloader: Update 64-bit build instruction
>
>  arch/x86/Kconfig                             |  8 ++++++
>  arch/x86/cpu/slimbootloader/Makefile         |  9 ++++--
>  arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++
>  arch/x86/cpu/slimbootloader/slimbootloader.c | 17 ++++++++++--
>  arch/x86/cpu/start64.S                       | 10 +++++++
>  arch/x86/cpu/x86_64/Makefile                 |  2 +-
>  arch/x86/cpu/x86_64/call64.S                 | 21 ++++++++++++++
>  arch/x86/cpu/x86_64/cpu.c                    | 10 +++++++
>  arch/x86/include/asm/bootparam.h             | 10 ++++++-
>  arch/x86/include/asm/zimage.h                |  2 +-
>  arch/x86/lib/bootm.c                         | 10 +++++--
>  arch/x86/lib/zimage.c                        | 24 ++++++++++------
>  cmd/x86/hob.c                                |  8 +++---
>  configs/slimbootloader-x86_64_defconfig      | 24 ++++++++++++++++
>  doc/board/intel/slimbootloader.rst           | 29 ++++++++++++++++++++
>  15 files changed, 176 insertions(+), 22 deletions(-)
>  create mode 100644 arch/x86/cpu/slimbootloader/entry64.S
>  create mode 100644 arch/x86/cpu/x86_64/call64.S
>  create mode 100644 configs/slimbootloader-x86_64_defconfig
>

For the series:

Tested on qemu:
Tested-by: Simon Glass <sjg@chromium.org>

One little thing that I noticed...your instructions show copying
u-boot-dtb.bin into the slimbootloader directory. This is the same as
u-boot.bin and I suggest you use that name instead. When I tried to, I
got an error.

Regards,
SImon

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

* [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  2020-04-22  0:45 ` [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig aiden.park at intel.com
@ 2020-04-26 20:15   ` Simon Glass
  2020-04-29  5:44     ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:15 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> This will build U-Boot as a pure 64-bit binary with no SPL.
> It can be used with a pre-stage boot firmware
> which has already done 16-bit, 32-bit and 64-bit init.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  arch/x86/Kconfig | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index c8eae24c07..89add17e69 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -40,6 +40,14 @@ config X86_RUN_64BIT
>           runs through the 16-bit and 32-bit init, then switches to 64-bit
>           mode and jumps to U-Boot proper.
>
> +config X86_RUN_64BIT_ONLY

Perhaps X86_RUN_64BIT_NO_SPL? Bin might hav a better idea.

> +       bool "64-bit only"
> +       select X86_64
> +       help
> +         Build U-Boot as a pure 64-bit binary with no 32-bit SPL. This can
> +         be used with a pre-stage boot firmware which has already done
> +         16-bit, 32-bit and 64-bit init.
> +
>  endchoice
>
>  config X86_64
> --
> 2.20.1
>
Regards,
Simon

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

* [PATCH 2/8] x86: start64: Add a hook at 64-bit entry
  2020-04-22  0:45 ` [PATCH 2/8] x86: start64: Add a hook at 64-bit entry aiden.park at intel.com
@ 2020-04-26 20:15   ` Simon Glass
  2020-04-29  5:48     ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:15 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> This will allow a board or cpu to do its specific initialization
> at 64-bit entry if U-Boot is a pure 64-bit binary.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  arch/x86/cpu/start64.S | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S
> index 7be834788b..b8ac5aab57 100644
> --- a/arch/x86/cpu/start64.S
> +++ b/arch/x86/cpu/start64.S
> @@ -13,6 +13,11 @@
>  .globl _start
>  .type _start, @function
>  _start:
> +#if defined(CONFIG_X86_RUN_64BIT_ONLY)
> +       jmp     init_64bit_entry
> +.globl init_64bit_entry_ret
> +init_64bit_entry_ret:
> +#endif

Would it be safe to do this always? Is that a standard register to
have the HOB pointer be in? If so, we could always store it. We could
also make sure that U-Boot passes it on too.

Note that U-Boot has a struct arch_spl_handoff which is how it passes
the HOB through.

>         /* Set up memory using the existing stack */
>         mov     %rsp, %rdi
>         call    board_init_f_alloc_reserve
> --
> 2.20.1
>

Regards,
Simon

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

* [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot
  2020-04-22  0:45 ` [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot aiden.park at intel.com
@ 2020-04-26 20:15   ` Simon Glass
  2020-04-29  5:57     ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:15 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> This will allow 64-bit U-Boot to use HOB.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  arch/x86/cpu/start64.S | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S
> index b8ac5aab57..7faf4f6f13 100644
> --- a/arch/x86/cpu/start64.S
> +++ b/arch/x86/cpu/start64.S
> @@ -25,6 +25,11 @@ init_64bit_entry_ret:
>
>         call    board_init_f_init_reserve
>
> +#if defined(CONFIG_X86_RUN_64BIT_ONLY) && defined(CONFIG_USE_HOB)
> +       mov     %r10, %rdi
> +       call    set_hob_list
> +#endif

Similar question - would it be safe to always do this?

> +
>         xor     %rdi, %rdi
>         call    board_init_f
>         call    board_init_f_r
> --
> 2.20.1
>

Regards,
Simon

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

* [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
  2020-04-22  0:45 ` [PATCH 4/8] x86: slimbootloader: Support 64-bit operation aiden.park at intel.com
@ 2020-04-26 20:15   ` Simon Glass
  2020-04-29  6:01     ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:15 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> This supports 64-bit U-Boot as a Slim Bootloader payload.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  arch/x86/cpu/slimbootloader/Makefile         |  9 +++++++--
>  arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++++++
>  arch/x86/cpu/slimbootloader/slimbootloader.c | 17 +++++++++++++++--
>  3 files changed, 36 insertions(+), 4 deletions(-)
>  create mode 100644 arch/x86/cpu/slimbootloader/entry64.S
>
> diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile
> index aac9fa3db8..79fa699501 100644
> --- a/arch/x86/cpu/slimbootloader/Makefile
> +++ b/arch/x86/cpu/slimbootloader/Makefile
> @@ -1,5 +1,10 @@
>  # SPDX-License-Identifier: GPL-2.0+
>  #
> -# Copyright (C) 2019 Intel Corporation <www.intel.com>
> +# Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
>
> -obj-y += car.o slimbootloader.o sdram.o serial.o
> +ifeq ($(CONFIG_X86_64),y)
> +obj-y += entry64.o
> +else
> +obj-y += car.o
> +endif
> +obj-y += slimbootloader.o sdram.o serial.o
> diff --git a/arch/x86/cpu/slimbootloader/entry64.S b/arch/x86/cpu/slimbootloader/entry64.S
> new file mode 100644
> index 0000000000..5e101e18a9
> --- /dev/null
> +++ b/arch/x86/cpu/slimbootloader/entry64.S
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2020 Intel Corporation <www.intel.com>
> + */
> +
> +#include <generated/asm-offsets.h>
> +
> +.section .text
> +
> +.globl init_64bit_entry
> +init_64bit_entry:
> +       /* Save hob pointer parameter */
> +       mov     %rcx, %r10
> +       jmp     init_64bit_entry_ret
> diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c b/arch/x86/cpu/slimbootloader/slimbootloader.c
> index 21dcfb2142..7857e4cd8b 100644
> --- a/arch/x86/cpu/slimbootloader/slimbootloader.c
> +++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * Copyright (C) 2019 Intel Corporation <www.intel.com>
> + * Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
>   */
>
>  #include <common.h>
> @@ -43,11 +43,23 @@ static void tsc_init(void)
>
>  int arch_cpu_init(void)
>  {
> +       int ret = 0;
> +
>         tsc_init();
>
> -       return x86_cpu_init_f();
> +#if !CONFIG_IS_ENABLED(X86_64)

Can you use if() instead of #if ?

> +       ret = x86_cpu_init_f();
> +#endif
> +       return ret;
>  }
>
> +#if CONFIG_IS_ENABLED(X86_64)

It should be safe to define both of these functions so I don't think
you need the #ifdef

> +int set_hob_list(void *hob_list)
> +{
> +       gd->arch.hob_list = hob_list;
> +       return 0;
> +}
> +#else
>  int checkcpu(void)
>  {
>         return 0;
> @@ -57,3 +69,4 @@ int print_cpuinfo(void)
>  {
>         return default_print_cpuinfo();
>  }
> +#endif
> --
> 2.20.1
>

Regards,
Simon

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

* [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot
  2020-04-22  0:45 ` [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot aiden.park at intel.com
@ 2020-04-26 20:15   ` Simon Glass
  2020-04-29  6:17     ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:15 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  arch/x86/cpu/x86_64/Makefile     |  2 +-
>  arch/x86/cpu/x86_64/call64.S     | 21 +++++++++++++++++++++
>  arch/x86/cpu/x86_64/cpu.c        | 10 ++++++++++
>  arch/x86/include/asm/bootparam.h | 10 +++++++++-
>  arch/x86/include/asm/zimage.h    |  2 +-
>  arch/x86/lib/bootm.c             | 10 +++++++---
>  arch/x86/lib/zimage.c            | 24 ++++++++++++++++--------
>  7 files changed, 65 insertions(+), 14 deletions(-)
>  create mode 100644 arch/x86/cpu/x86_64/call64.S
>
> diff --git a/arch/x86/cpu/x86_64/Makefile b/arch/x86/cpu/x86_64/Makefile
> index 400f0ffe39..951e503a1f 100644
> --- a/arch/x86/cpu/x86_64/Makefile
> +++ b/arch/x86/cpu/x86_64/Makefile
> @@ -3,4 +3,4 @@
>  # Written by Simon Glass <sjg@chromium.org>
>  #
>
> -obj-y += cpu.o interrupts.o setjmp.o
> +obj-y += cpu.o interrupts.o setjmp.o call64.o
> diff --git a/arch/x86/cpu/x86_64/call64.S b/arch/x86/cpu/x86_64/call64.S
> new file mode 100644
> index 0000000000..e2cfe15080
> --- /dev/null
> +++ b/arch/x86/cpu/x86_64/call64.S
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2020 Intel Corporation <www.intel.com>
> + */
> +
> +.code64
> +.globl cpu_call64
> +cpu_call64:
> +       /*
> +        * cpu_call64(ulong pgtable, ulong setup_base, ulong target)
> +        *
> +        * rdi - pgtable (unused - already in 64-bit with paging)
> +        * rsi - setup_base
> +        * rdx - target
> +        *
> +        */
> +       cli
> +       mov     %rdx, %rcx
> +       mov     %rsi, %rdx
> +       call    *%rcx
> +       ret
> diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
> index 90925e46ea..0730c43f1c 100644
> --- a/arch/x86/cpu/x86_64/cpu.c
> +++ b/arch/x86/cpu/x86_64/cpu.c
> @@ -7,6 +7,7 @@
>  #include <common.h>
>  #include <cpu_func.h>
>  #include <debug_uart.h>
> +#include <asm/cpu.h>
>
>  /*
>   * Global declaration of gd.
> @@ -67,3 +68,12 @@ int x86_cpu_reinit_f(void)
>  {
>         return 0;
>  }
> +
> +int cpu_jump_to_64bit(ulong setup_base, ulong load_address)
> +{
> +       ulong target = load_address + 0x200;
> +
> +       cpu_call64(0, setup_base, target);
> +
> +       return -EFAULT;
> +}
> diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
> index d961dddc9e..73c94a33ec 100644
> --- a/arch/x86/include/asm/bootparam.h
> +++ b/arch/x86/include/asm/bootparam.h
> @@ -59,7 +59,15 @@ struct setup_header {
>         __u32   initrd_addr_max;
>         __u32   kernel_alignment;
>         __u8    relocatable_kernel;
> -       __u8    _pad2[3];
> +       __u8    min_alignment;
> +       __u16   xloadflags;
> +#define XLF_KERNEL_64                  BIT(0)
> +#define XLF_CAN_BE_LOADED_ABOVE_4G     BIT(1)
> +#define XLF_EFI_HANDOVER_32            BIT(2)
> +#define XLF_EFI_HANDOVER_64            BIT(3)
> +#define XLF_EFI_KEXEC                  BIT(4)
> +#define XLF_5LEVEL                     BIT(5)
> +#define XLF_5LEVEL_ENABLED             BIT(6)
>         __u32   cmdline_size;
>         __u32   hardware_subarch;
>         __u64   hardware_subarch_data;
> diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
> index 80e128ccf3..cadeb04168 100644
> --- a/arch/x86/include/asm/zimage.h
> +++ b/arch/x86/include/asm/zimage.h
> @@ -31,7 +31,7 @@
>  #define ZIMAGE_LOAD_ADDR   0x10000
>
>  struct boot_params *load_zimage(char *image, unsigned long kernel_size,
> -                               ulong *load_addressp);
> +                               ulong *load_addressp, bool *image_64bit);

Please put a 'p' on the end, so image_64bitp, since it a return value.

>  int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
>                  unsigned long initrd_addr, unsigned long initrd_size);
>  void setup_video(struct screen_info *screen_info);
> diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
> index 07d8f1f279..ebed9e4605 100644
> --- a/arch/x86/lib/bootm.c
> +++ b/arch/x86/lib/bootm.c
> @@ -74,6 +74,7 @@ static int boot_prep_linux(bootm_headers_t *images)
>         void *data = NULL;
>         size_t len;
>         int ret;
> +       bool image_64bit;
>
>  #ifdef CONFIG_OF_LIBFDT
>         if (images->ft_len) {
> @@ -116,7 +117,8 @@ static int boot_prep_linux(bootm_headers_t *images)
>                 ulong load_address;
>                 char *base_ptr;
>
> -               base_ptr = (char *)load_zimage(data, len, &load_address);
> +               base_ptr = (char *)load_zimage(data, len, &load_address,
> +                                              &image_64bit);
>                 if (!base_ptr) {
>                         puts("## Kernel loading failed ...\n");
>                         goto error;
> @@ -124,6 +126,10 @@ static int boot_prep_linux(bootm_headers_t *images)
>                 images->os.load = load_address;
>                 cmd_line_dest = base_ptr + COMMAND_LINE_OFFSET;
>                 images->ep = (ulong)base_ptr;
> +#if CONFIG_IS_ENABLED(X86_64)
> +               if (image_64bit)

if (CONFIG_IS_ENABLED(X86_64) && image_64bit)

> +                       images->os.arch = IH_ARCH_X86_64;
> +#endif
>         } else if (images->ep) {
>                 cmd_line_dest = (void *)images->ep + COMMAND_LINE_OFFSET;
>         } else {
> @@ -164,9 +170,7 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
>                  * TODO(sjg at chromium.org): Support booting both 32-bit and
>                  * 64-bit kernels from 64-bit U-Boot.
>                  */
> -#if !CONFIG_IS_ENABLED(X86_64)

if()

>                 return cpu_jump_to_64bit(setup_base, load_address);
> -#endif
>         } else {
>                 /*
>                 * Set %ebx, %ebp, and %edi to 0, %esi to point to the
> diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
> index ffc09630b7..c84e2d39b2 100644
> --- a/arch/x86/lib/zimage.c
> +++ b/arch/x86/lib/zimage.c
> @@ -129,7 +129,7 @@ static int setup_device_tree(struct setup_header *hdr, const void *fdt_blob)
>  }
>
>  struct boot_params *load_zimage(char *image, unsigned long kernel_size,
> -                               ulong *load_addressp)
> +                               ulong *load_addressp, bool *image_64bit)

image_64bitp

>  {
>         struct boot_params *setup_base;
>         int setup_size;
> @@ -179,6 +179,9 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
>         big_image = (bootproto >= 0x0200) &&
>                     (hdr->loadflags & BIG_KERNEL_FLAG);
>
> +       /* Determine 64-bit kernel */
> +       *image_64bit = (hdr->xloadflags & XLF_KERNEL_64) ? true : false;
> +

Drop ()

In fact I suspect you can do:

*image_64bit = hdr->xloadflags & XLF_KERNEL_64)

>         /* Determine load address */
>         if (big_image)
>                 *load_addressp = BZIMAGE_LOAD_ADDR;
> @@ -313,12 +316,13 @@ void __setup_pcat_compatibility(void)
>  int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>  {
>         struct boot_params *base_ptr;
> -       void *bzImage_addr = NULL;
> +       void *bzimage_addr = NULL;

Good change, but really should be in a separate patch.

>         ulong load_address;
>         char *s;
> -       ulong bzImage_size = 0;
> +       ulong bzimage_size = 0;
>         ulong initrd_addr = 0;
>         ulong initrd_size = 0;
> +       bool image_64bit;
>
>         disable_interrupts();
>
> @@ -333,11 +337,11 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>         }
>
>         if (s)
> -               bzImage_addr = (void *)simple_strtoul(s, NULL, 16);
> +               bzimage_addr = (void *)simple_strtoul(s, NULL, 16);
>
>         if (argc >= 3) {
>                 /* argv[2] holds the size of the bzImage */
> -               bzImage_size = simple_strtoul(argv[2], NULL, 16);
> +               bzimage_size = simple_strtoul(argv[2], NULL, 16);
>         }
>
>         if (argc >= 4)
> @@ -346,8 +350,13 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>                 initrd_size = simple_strtoul(argv[4], NULL, 16);
>
>         /* Lets look for */
> -       base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address);
> +       base_ptr = load_zimage(bzimage_addr, bzimage_size, &load_address,
> +                              &image_64bit);
> +#if !CONFIG_IS_ENABLED(X86_64)

if()

But why not just set it always?

> +       image_64bit = false;
> +#endif
>
> +       /* we assume that the kernel is in place */
>         if (!base_ptr) {
>                 puts("## Kernel loading failed ...\n");
>                 return -1;
> @@ -358,8 +367,7 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>                 return -1;
>         }
>
> -       /* we assume that the kernel is in place */
> -       return boot_linux_kernel((ulong)base_ptr, load_address, false);
> +       return boot_linux_kernel((ulong)base_ptr, load_address, image_64bit);
>  }
>
>  U_BOOT_CMD(
> --
> 2.20.1
>

Regards,
Simon

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

* [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config
  2020-04-22  0:45 ` [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config aiden.park at intel.com
@ 2020-04-26 20:32   ` Simon Glass
  2020-04-29  6:02     ` Park, Aiden
  2020-04-30  9:13     ` Bin Meng
  0 siblings, 2 replies; 32+ messages in thread
From: Simon Glass @ 2020-04-26 20:32 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> Add slimbootloader-x86_64_defconfig for 64-bit slimbootloader board.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  configs/slimbootloader-x86_64_defconfig | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 configs/slimbootloader-x86_64_defconfig

How about slimbootloader64?

We always know it is x86.

Regards,
Simon

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

* [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader
  2020-04-26 20:15 ` [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader Simon Glass
@ 2020-04-29  5:41   ` Park, Aiden
  0 siblings, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  5:41 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:16 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > This patchset will build 64-bit U-Boot as a Slim Bootloader payload
> > and introduce a new X86_RUN_64BIT_ONLY to build pure 64-bit U-Boot
> > binary without SPL. In addition, this supports 64-bit kernel booting
> > from 64-bit U-Boot.
> >
> > Aiden Park (8):
> >   x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
> >   x86: start64: Add a hook at 64-bit entry
> >   x86: start64: Support HOB in 64-bit U-Boot
> >   x86: slimbootloader: Support 64-bit operation
> >   configs: slimbootloader: Add x86_64 slimbootloader config
> >   x86: Fix 64-bit compile warning
> >   x86: enable 64-bit kernel boot from 64-bit U-Boot
> >   doc: slimbootloader: Update 64-bit build instruction
> >
> >  arch/x86/Kconfig                             |  8 ++++++
> >  arch/x86/cpu/slimbootloader/Makefile         |  9 ++++--
> >  arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++
> >  arch/x86/cpu/slimbootloader/slimbootloader.c | 17 ++++++++++--
> >  arch/x86/cpu/start64.S                       | 10 +++++++
> >  arch/x86/cpu/x86_64/Makefile                 |  2 +-
> >  arch/x86/cpu/x86_64/call64.S                 | 21 ++++++++++++++
> >  arch/x86/cpu/x86_64/cpu.c                    | 10 +++++++
> >  arch/x86/include/asm/bootparam.h             | 10 ++++++-
> >  arch/x86/include/asm/zimage.h                |  2 +-
> >  arch/x86/lib/bootm.c                         | 10 +++++--
> >  arch/x86/lib/zimage.c                        | 24 ++++++++++------
> >  cmd/x86/hob.c                                |  8 +++---
> >  configs/slimbootloader-x86_64_defconfig      | 24 ++++++++++++++++
> >  doc/board/intel/slimbootloader.rst           | 29 ++++++++++++++++++++
> >  15 files changed, 176 insertions(+), 22 deletions(-)  create mode
> > 100644 arch/x86/cpu/slimbootloader/entry64.S
> >  create mode 100644 arch/x86/cpu/x86_64/call64.S  create mode 100644
> > configs/slimbootloader-x86_64_defconfig
> >
> 
> For the series:
> 
> Tested on qemu:
> Tested-by: Simon Glass <sjg@chromium.org>
> 
> One little thing that I noticed...your instructions show copying u-boot-dtb.bin
> into the slimbootloader directory. This is the same as u-boot.bin and I suggest
> you use that name instead. When I tried to, I got an error.
> 
Thanks for your testing. Let me update the instruction with u-boot.bin.

> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  2020-04-26 20:15   ` Simon Glass
@ 2020-04-29  5:44     ` Park, Aiden
  2020-04-30  9:13       ` Bin Meng
  0 siblings, 1 reply; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  5:44 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:16 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > This will build U-Boot as a pure 64-bit binary with no SPL.
> > It can be used with a pre-stage boot firmware which has already done
> > 16-bit, 32-bit and 64-bit init.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  arch/x86/Kconfig | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index
> > c8eae24c07..89add17e69 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -40,6 +40,14 @@ config X86_RUN_64BIT
> >           runs through the 16-bit and 32-bit init, then switches to 64-bit
> >           mode and jumps to U-Boot proper.
> >
> > +config X86_RUN_64BIT_ONLY
> 
> Perhaps X86_RUN_64BIT_NO_SPL? Bin might hav a better idea.
> 
I considered X64_RUN_64BIT_NO_SPL, X64_RUN_64BIT_PURE and X64_RUN_64BIT_NATIVE.
Hi Bin, can you recommend better naming?

> > +       bool "64-bit only"
> > +       select X86_64
> > +       help
> > +         Build U-Boot as a pure 64-bit binary with no 32-bit SPL. This can
> > +         be used with a pre-stage boot firmware which has already done
> > +         16-bit, 32-bit and 64-bit init.
> > +
> >  endchoice
> >
> >  config X86_64
> > --
> > 2.20.1
> >
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 2/8] x86: start64: Add a hook at 64-bit entry
  2020-04-26 20:15   ` Simon Glass
@ 2020-04-29  5:48     ` Park, Aiden
  0 siblings, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  5:48 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:16 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 2/8] x86: start64: Add a hook at 64-bit entry
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > This will allow a board or cpu to do its specific initialization at
> > 64-bit entry if U-Boot is a pure 64-bit binary.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  arch/x86/cpu/start64.S | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S index
> > 7be834788b..b8ac5aab57 100644
> > --- a/arch/x86/cpu/start64.S
> > +++ b/arch/x86/cpu/start64.S
> > @@ -13,6 +13,11 @@
> >  .globl _start
> >  .type _start, @function
> >  _start:
> > +#if defined(CONFIG_X86_RUN_64BIT_ONLY)
> > +       jmp     init_64bit_entry
> > +.globl init_64bit_entry_ret
> > +init_64bit_entry_ret:
> > +#endif
> 
> Would it be safe to do this always? Is that a standard register to have the HOB
> pointer be in? If so, we could always store it. We could also make sure that U-
> Boot passes it on too.
Unfortunately, it's not. This is to cover pre-stage firmware's calling convention.
The calling convention of 64-bit Slim Bootloader is that HOB address is in rcx.

> 
> Note that U-Boot has a struct arch_spl_handoff which is how it passes the HOB
> through.
Thanks for your information. Let me try to leverage arch_spl_handoff to pass HOB.

> 
> >         /* Set up memory using the existing stack */
> >         mov     %rsp, %rdi
> >         call    board_init_f_alloc_reserve
> > --
> > 2.20.1
> >
> 
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot
  2020-04-26 20:15   ` Simon Glass
@ 2020-04-29  5:57     ` Park, Aiden
  0 siblings, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  5:57 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:16 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > This will allow 64-bit U-Boot to use HOB.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  arch/x86/cpu/start64.S | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S index
> > b8ac5aab57..7faf4f6f13 100644
> > --- a/arch/x86/cpu/start64.S
> > +++ b/arch/x86/cpu/start64.S
> > @@ -25,6 +25,11 @@ init_64bit_entry_ret:
> >
> >         call    board_init_f_init_reserve
> >
> > +#if defined(CONFIG_X86_RUN_64BIT_ONLY) && defined(CONFIG_USE_HOB)
> > +       mov     %r10, %rdi
> > +       call    set_hob_list
> > +#endif
> 
> Similar question - would it be safe to always do this?
> 
You are right. The r10 is a scratch register. The r12-r15 would be correct choice.
Instead of this, let me try to leverage arch_spl_handoff.

> > +
> >         xor     %rdi, %rdi
> >         call    board_init_f
> >         call    board_init_f_r
> > --
> > 2.20.1
> >
> 
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
  2020-04-26 20:15   ` Simon Glass
@ 2020-04-29  6:01     ` Park, Aiden
  2020-04-29 18:03       ` Simon Glass
  0 siblings, 1 reply; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  6:01 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:16 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > This supports 64-bit U-Boot as a Slim Bootloader payload.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  arch/x86/cpu/slimbootloader/Makefile         |  9 +++++++--
> >  arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++++++
> >  arch/x86/cpu/slimbootloader/slimbootloader.c | 17 +++++++++++++++--
> >  3 files changed, 36 insertions(+), 4 deletions(-)  create mode 100644
> > arch/x86/cpu/slimbootloader/entry64.S
> >
> > diff --git a/arch/x86/cpu/slimbootloader/Makefile
> > b/arch/x86/cpu/slimbootloader/Makefile
> > index aac9fa3db8..79fa699501 100644
> > --- a/arch/x86/cpu/slimbootloader/Makefile
> > +++ b/arch/x86/cpu/slimbootloader/Makefile
> > @@ -1,5 +1,10 @@
> >  # SPDX-License-Identifier: GPL-2.0+
> >  #
> > -# Copyright (C) 2019 Intel Corporation <www.intel.com>
> > +# Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
> >
> > -obj-y += car.o slimbootloader.o sdram.o serial.o
> > +ifeq ($(CONFIG_X86_64),y)
> > +obj-y += entry64.o
> > +else
> > +obj-y += car.o
> > +endif
> > +obj-y += slimbootloader.o sdram.o serial.o
> > diff --git a/arch/x86/cpu/slimbootloader/entry64.S
> > b/arch/x86/cpu/slimbootloader/entry64.S
> > new file mode 100644
> > index 0000000000..5e101e18a9
> > --- /dev/null
> > +++ b/arch/x86/cpu/slimbootloader/entry64.S
> > @@ -0,0 +1,14 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ */
> > +/*
> > + * Copyright (C) 2020 Intel Corporation <www.intel.com>  */
> > +
> > +#include <generated/asm-offsets.h>
> > +
> > +.section .text
> > +
> > +.globl init_64bit_entry
> > +init_64bit_entry:
> > +       /* Save hob pointer parameter */
> > +       mov     %rcx, %r10
> > +       jmp     init_64bit_entry_ret
> > diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c
> > b/arch/x86/cpu/slimbootloader/slimbootloader.c
> > index 21dcfb2142..7857e4cd8b 100644
> > --- a/arch/x86/cpu/slimbootloader/slimbootloader.c
> > +++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
> > @@ -1,6 +1,6 @@
> >  // SPDX-License-Identifier: GPL-2.0+
> >  /*
> > - * Copyright (C) 2019 Intel Corporation <www.intel.com>
> > + * Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
> >   */
> >
> >  #include <common.h>
> > @@ -43,11 +43,23 @@ static void tsc_init(void)
> >
> >  int arch_cpu_init(void)
> >  {
> > +       int ret = 0;
> > +
> >         tsc_init();
> >
> > -       return x86_cpu_init_f();
> > +#if !CONFIG_IS_ENABLED(X86_64)
> 
> Can you use if() instead of #if ?
I will do it.

> 
> > +       ret = x86_cpu_init_f();
> > +#endif
> > +       return ret;
> >  }
> >
> > +#if CONFIG_IS_ENABLED(X86_64)
> 
> It should be safe to define both of these functions so I don't think you need the
> #ifdef
These are defined in arch/x86/cpu/x86_64/cpu.c already.
Is it okay to make them weak reference or can I keep this as it is?

> 
> > +int set_hob_list(void *hob_list)
> > +{
> > +       gd->arch.hob_list = hob_list;
> > +       return 0;
> > +}
> > +#else
> >  int checkcpu(void)
> >  {
> >         return 0;
> > @@ -57,3 +69,4 @@ int print_cpuinfo(void)  {
> >         return default_print_cpuinfo();  }
> > +#endif
> > --
> > 2.20.1
> >
> 
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config
  2020-04-26 20:32   ` Simon Glass
@ 2020-04-29  6:02     ` Park, Aiden
  2020-04-30  9:13     ` Bin Meng
  1 sibling, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  6:02 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:32 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader
> config
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > Add slimbootloader-x86_64_defconfig for 64-bit slimbootloader board.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  configs/slimbootloader-x86_64_defconfig | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >  create mode 100644 configs/slimbootloader-x86_64_defconfig
> 
> How about slimbootloader64?
> 
> We always know it is x86.
> 
Thanks for your suggestion. I will rename it to slimbootloader64.

> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 6/8] x86: Fix 64-bit compile warning
  2020-04-26 19:45   ` Simon Glass
@ 2020-04-29  6:08     ` Park, Aiden
  0 siblings, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  6:08 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 12:46 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 6/8] x86: Fix 64-bit compile warning
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > This is to fix pointer type cast warning in hob command.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  cmd/x86/hob.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/cmd/x86/hob.c b/cmd/x86/hob.c index
> > 3967a7ca5a..8c2c1ffc63 100644
> > --- a/cmd/x86/hob.c
> > +++ b/cmd/x86/hob.c
> > @@ -36,14 +36,14 @@ static int do_hob(cmd_tbl_t *cmdtp, int flag, int
> > argc, char * const argv[])
> >
> >         hdr = gd->arch.hob_list;
> >
> > -       printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
> > +       printf("HOB list address: 0x%p\n\n", hdr);
> 
> That 0x should not be there as hex is assumed in U-Boot.
Thanks. Let me remove the 0x prefix.

> 
> Do we actually need a 64-bit pointer here, or will the HOB be below 4GB? I'm
> really not a fan of 16-character addresses in a user command.
Currently, HOB is always below 4GB. This was just in case for 64-bit address space.
Let me assume HOB < 4GB for now.

> 
> >
> > -       printf("#  | Address  | Type      | Len  | ");
> > +       printf("#  |          Address | Type      | Len  | ");
> >         printf("%36s\n", "GUID");
> > -       printf("---|----------|-----------|------|-");
> > +       printf("---|------------------|-----------|------|-");
> >         printf("------------------------------------\n");
> >         while (!end_of_hob(hdr)) {
> > -               printf("%02x | %08x | ", i, (unsigned int)hdr);
> > +               printf("%02x | %p | ", i, hdr);
> >                 type = hdr->type;
> >                 if (type == HOB_TYPE_UNUSED)
> >                         desc = "*Unused*";
> > --
> > 2.20.1
> >
> 
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot
  2020-04-26 20:15   ` Simon Glass
@ 2020-04-29  6:17     ` Park, Aiden
  0 siblings, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-04-29  6:17 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Sunday, April 26, 2020 1:16 PM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot
> 
> Hi Aiden,
> 
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  arch/x86/cpu/x86_64/Makefile     |  2 +-
> >  arch/x86/cpu/x86_64/call64.S     | 21 +++++++++++++++++++++
> >  arch/x86/cpu/x86_64/cpu.c        | 10 ++++++++++
> >  arch/x86/include/asm/bootparam.h | 10 +++++++++-
> >  arch/x86/include/asm/zimage.h    |  2 +-
> >  arch/x86/lib/bootm.c             | 10 +++++++---
> >  arch/x86/lib/zimage.c            | 24 ++++++++++++++++--------
> >  7 files changed, 65 insertions(+), 14 deletions(-)  create mode
> > 100644 arch/x86/cpu/x86_64/call64.S
> >
> > diff --git a/arch/x86/cpu/x86_64/Makefile
> > b/arch/x86/cpu/x86_64/Makefile index 400f0ffe39..951e503a1f 100644
> > --- a/arch/x86/cpu/x86_64/Makefile
> > +++ b/arch/x86/cpu/x86_64/Makefile
> > @@ -3,4 +3,4 @@
> >  # Written by Simon Glass <sjg@chromium.org>  #
> >
> > -obj-y += cpu.o interrupts.o setjmp.o
> > +obj-y += cpu.o interrupts.o setjmp.o call64.o
> > diff --git a/arch/x86/cpu/x86_64/call64.S
> > b/arch/x86/cpu/x86_64/call64.S new file mode 100644 index
> > 0000000000..e2cfe15080
> > --- /dev/null
> > +++ b/arch/x86/cpu/x86_64/call64.S
> > @@ -0,0 +1,21 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ */
> > +/*
> > + * Copyright (C) 2020 Intel Corporation <www.intel.com>  */
> > +
> > +.code64
> > +.globl cpu_call64
> > +cpu_call64:
> > +       /*
> > +        * cpu_call64(ulong pgtable, ulong setup_base, ulong target)
> > +        *
> > +        * rdi - pgtable (unused - already in 64-bit with paging)
> > +        * rsi - setup_base
> > +        * rdx - target
> > +        *
> > +        */
> > +       cli
> > +       mov     %rdx, %rcx
> > +       mov     %rsi, %rdx
> > +       call    *%rcx
> > +       ret
> > diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
> > index 90925e46ea..0730c43f1c 100644
> > --- a/arch/x86/cpu/x86_64/cpu.c
> > +++ b/arch/x86/cpu/x86_64/cpu.c
> > @@ -7,6 +7,7 @@
> >  #include <common.h>
> >  #include <cpu_func.h>
> >  #include <debug_uart.h>
> > +#include <asm/cpu.h>
> >
> >  /*
> >   * Global declaration of gd.
> > @@ -67,3 +68,12 @@ int x86_cpu_reinit_f(void)  {
> >         return 0;
> >  }
> > +
> > +int cpu_jump_to_64bit(ulong setup_base, ulong load_address) {
> > +       ulong target = load_address + 0x200;
> > +
> > +       cpu_call64(0, setup_base, target);
> > +
> > +       return -EFAULT;
> > +}
> > diff --git a/arch/x86/include/asm/bootparam.h
> > b/arch/x86/include/asm/bootparam.h
> > index d961dddc9e..73c94a33ec 100644
> > --- a/arch/x86/include/asm/bootparam.h
> > +++ b/arch/x86/include/asm/bootparam.h
> > @@ -59,7 +59,15 @@ struct setup_header {
> >         __u32   initrd_addr_max;
> >         __u32   kernel_alignment;
> >         __u8    relocatable_kernel;
> > -       __u8    _pad2[3];
> > +       __u8    min_alignment;
> > +       __u16   xloadflags;
> > +#define XLF_KERNEL_64                  BIT(0)
> > +#define XLF_CAN_BE_LOADED_ABOVE_4G     BIT(1)
> > +#define XLF_EFI_HANDOVER_32            BIT(2)
> > +#define XLF_EFI_HANDOVER_64            BIT(3)
> > +#define XLF_EFI_KEXEC                  BIT(4)
> > +#define XLF_5LEVEL                     BIT(5)
> > +#define XLF_5LEVEL_ENABLED             BIT(6)
> >         __u32   cmdline_size;
> >         __u32   hardware_subarch;
> >         __u64   hardware_subarch_data;
> > diff --git a/arch/x86/include/asm/zimage.h
> > b/arch/x86/include/asm/zimage.h index 80e128ccf3..cadeb04168 100644
> > --- a/arch/x86/include/asm/zimage.h
> > +++ b/arch/x86/include/asm/zimage.h
> > @@ -31,7 +31,7 @@
> >  #define ZIMAGE_LOAD_ADDR   0x10000
> >
> >  struct boot_params *load_zimage(char *image, unsigned long kernel_size,
> > -                               ulong *load_addressp);
> > +                               ulong *load_addressp, bool
> > + *image_64bit);
> 
> Please put a 'p' on the end, so image_64bitp, since it a return value.
Thanks. I will do that.

> 
> >  int setup_zimage(struct boot_params *setup_base, char *cmd_line, int
> auto_boot,
> >                  unsigned long initrd_addr, unsigned long
> > initrd_size);  void setup_video(struct screen_info *screen_info); diff
> > --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index
> > 07d8f1f279..ebed9e4605 100644
> > --- a/arch/x86/lib/bootm.c
> > +++ b/arch/x86/lib/bootm.c
> > @@ -74,6 +74,7 @@ static int boot_prep_linux(bootm_headers_t *images)
> >         void *data = NULL;
> >         size_t len;
> >         int ret;
> > +       bool image_64bit;
> >
> >  #ifdef CONFIG_OF_LIBFDT
> >         if (images->ft_len) {
> > @@ -116,7 +117,8 @@ static int boot_prep_linux(bootm_headers_t *images)
> >                 ulong load_address;
> >                 char *base_ptr;
> >
> > -               base_ptr = (char *)load_zimage(data, len, &load_address);
> > +               base_ptr = (char *)load_zimage(data, len, &load_address,
> > +                                              &image_64bit);
> >                 if (!base_ptr) {
> >                         puts("## Kernel loading failed ...\n");
> >                         goto error;
> > @@ -124,6 +126,10 @@ static int boot_prep_linux(bootm_headers_t
> *images)
> >                 images->os.load = load_address;
> >                 cmd_line_dest = base_ptr + COMMAND_LINE_OFFSET;
> >                 images->ep = (ulong)base_ptr;
> > +#if CONFIG_IS_ENABLED(X86_64)
> > +               if (image_64bit)
> 
> if (CONFIG_IS_ENABLED(X86_64) && image_64bit)
> 
> > +                       images->os.arch = IH_ARCH_X86_64; #endif
> >         } else if (images->ep) {
> >                 cmd_line_dest = (void *)images->ep + COMMAND_LINE_OFFSET;
> >         } else {
> > @@ -164,9 +170,7 @@ int boot_linux_kernel(ulong setup_base, ulong
> load_address, bool image_64bit)
> >                  * TODO(sjg at chromium.org): Support booting both 32-bit and
> >                  * 64-bit kernels from 64-bit U-Boot.
> >                  */
> > -#if !CONFIG_IS_ENABLED(X86_64)
> 
> if()
I will do that.

> 
> >                 return cpu_jump_to_64bit(setup_base, load_address);
> > -#endif
> >         } else {
> >                 /*
> >                 * Set %ebx, %ebp, and %edi to 0, %esi to point to the
> > diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index
> > ffc09630b7..c84e2d39b2 100644
> > --- a/arch/x86/lib/zimage.c
> > +++ b/arch/x86/lib/zimage.c
> > @@ -129,7 +129,7 @@ static int setup_device_tree(struct setup_header
> > *hdr, const void *fdt_blob)  }
> >
> >  struct boot_params *load_zimage(char *image, unsigned long kernel_size,
> > -                               ulong *load_addressp)
> > +                               ulong *load_addressp, bool
> > + *image_64bit)
> 
> image_64bitp
I will do that.

> 
> >  {
> >         struct boot_params *setup_base;
> >         int setup_size;
> > @@ -179,6 +179,9 @@ struct boot_params *load_zimage(char *image,
> unsigned long kernel_size,
> >         big_image = (bootproto >= 0x0200) &&
> >                     (hdr->loadflags & BIG_KERNEL_FLAG);
> >
> > +       /* Determine 64-bit kernel */
> > +       *image_64bit = (hdr->xloadflags & XLF_KERNEL_64) ? true :
> > + false;
> > +
> 
> Drop ()
> 
> In fact I suspect you can do:
> 
> *image_64bit = hdr->xloadflags & XLF_KERNEL_64)
I will do that.

> 
> >         /* Determine load address */
> >         if (big_image)
> >                 *load_addressp = BZIMAGE_LOAD_ADDR; @@ -313,12 +316,13
> > @@ void __setup_pcat_compatibility(void)  int do_zboot(cmd_tbl_t
> > *cmdtp, int flag, int argc, char *const argv[])  {
> >         struct boot_params *base_ptr;
> > -       void *bzImage_addr = NULL;
> > +       void *bzimage_addr = NULL;
> 
> Good change, but really should be in a separate patch.
Let me make a separate patch for this.

> 
> >         ulong load_address;
> >         char *s;
> > -       ulong bzImage_size = 0;
> > +       ulong bzimage_size = 0;
> >         ulong initrd_addr = 0;
> >         ulong initrd_size = 0;
> > +       bool image_64bit;
> >
> >         disable_interrupts();
> >
> > @@ -333,11 +337,11 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc,
> char *const argv[])
> >         }
> >
> >         if (s)
> > -               bzImage_addr = (void *)simple_strtoul(s, NULL, 16);
> > +               bzimage_addr = (void *)simple_strtoul(s, NULL, 16);
> >
> >         if (argc >= 3) {
> >                 /* argv[2] holds the size of the bzImage */
> > -               bzImage_size = simple_strtoul(argv[2], NULL, 16);
> > +               bzimage_size = simple_strtoul(argv[2], NULL, 16);
> >         }
> >
> >         if (argc >= 4)
> > @@ -346,8 +350,13 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc,
> char *const argv[])
> >                 initrd_size = simple_strtoul(argv[4], NULL, 16);
> >
> >         /* Lets look for */
> > -       base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address);
> > +       base_ptr = load_zimage(bzimage_addr, bzimage_size, &load_address,
> > +                              &image_64bit); #if
> > +!CONFIG_IS_ENABLED(X86_64)
> 
> if()
> 
> But why not just set it always?
This was just to keep original boot flow in zboot to boot 32-bit kernel entry from 32-bit U-Boot.
I also agree with you. 32-bit U-Boot is able to boot 64-bit kernel entry with 64-bit paging.
Let me remove this.

> 
> > +       image_64bit = false;
> > +#endif
> >
> > +       /* we assume that the kernel is in place */
> >         if (!base_ptr) {
> >                 puts("## Kernel loading failed ...\n");
> >                 return -1;
> > @@ -358,8 +367,7 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc,
> char *const argv[])
> >                 return -1;
> >         }
> >
> > -       /* we assume that the kernel is in place */
> > -       return boot_linux_kernel((ulong)base_ptr, load_address, false);
> > +       return boot_linux_kernel((ulong)base_ptr, load_address,
> > + image_64bit);
> >  }
> >
> >  U_BOOT_CMD(
> > --
> > 2.20.1
> >
> 
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
  2020-04-29  6:01     ` Park, Aiden
@ 2020-04-29 18:03       ` Simon Glass
  2020-05-01 18:34         ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2020-04-29 18:03 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Wed, 29 Apr 2020 at 00:01, Park, Aiden <aiden.park@intel.com> wrote:
>
> Hi Simon,
>
> > -----Original Message-----
> > From: Simon Glass <sjg@chromium.org>
> > Sent: Sunday, April 26, 2020 1:16 PM
> > To: Park, Aiden <aiden.park@intel.com>
> > Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> > boot at lists.denx.de>
> > Subject: Re: [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
> >
> > Hi Aiden,
> >
> > On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> > >
> > > From: Aiden Park <aiden.park@intel.com>
> > >
> > > This supports 64-bit U-Boot as a Slim Bootloader payload.
> > >
> > > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > > ---
> > >  arch/x86/cpu/slimbootloader/Makefile         |  9 +++++++--
> > >  arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++++++
> > >  arch/x86/cpu/slimbootloader/slimbootloader.c | 17 +++++++++++++++--
> > >  3 files changed, 36 insertions(+), 4 deletions(-)  create mode 100644
> > > arch/x86/cpu/slimbootloader/entry64.S
> > >
> > > diff --git a/arch/x86/cpu/slimbootloader/Makefile
> > > b/arch/x86/cpu/slimbootloader/Makefile
> > > index aac9fa3db8..79fa699501 100644
> > > --- a/arch/x86/cpu/slimbootloader/Makefile
> > > +++ b/arch/x86/cpu/slimbootloader/Makefile
> > > @@ -1,5 +1,10 @@
> > >  # SPDX-License-Identifier: GPL-2.0+
> > >  #
> > > -# Copyright (C) 2019 Intel Corporation <www.intel.com>
> > > +# Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
> > >
> > > -obj-y += car.o slimbootloader.o sdram.o serial.o
> > > +ifeq ($(CONFIG_X86_64),y)
> > > +obj-y += entry64.o
> > > +else
> > > +obj-y += car.o
> > > +endif
> > > +obj-y += slimbootloader.o sdram.o serial.o
> > > diff --git a/arch/x86/cpu/slimbootloader/entry64.S
> > > b/arch/x86/cpu/slimbootloader/entry64.S
> > > new file mode 100644
> > > index 0000000000..5e101e18a9
> > > --- /dev/null
> > > +++ b/arch/x86/cpu/slimbootloader/entry64.S
> > > @@ -0,0 +1,14 @@
> > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > +/*
> > > + * Copyright (C) 2020 Intel Corporation <www.intel.com>  */
> > > +
> > > +#include <generated/asm-offsets.h>
> > > +
> > > +.section .text
> > > +
> > > +.globl init_64bit_entry
> > > +init_64bit_entry:
> > > +       /* Save hob pointer parameter */
> > > +       mov     %rcx, %r10
> > > +       jmp     init_64bit_entry_ret
> > > diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > b/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > index 21dcfb2142..7857e4cd8b 100644
> > > --- a/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > +++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > @@ -1,6 +1,6 @@
> > >  // SPDX-License-Identifier: GPL-2.0+
> > >  /*
> > > - * Copyright (C) 2019 Intel Corporation <www.intel.com>
> > > + * Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
> > >   */
> > >
> > >  #include <common.h>
> > > @@ -43,11 +43,23 @@ static void tsc_init(void)
> > >
> > >  int arch_cpu_init(void)
> > >  {
> > > +       int ret = 0;
> > > +
> > >         tsc_init();
> > >
> > > -       return x86_cpu_init_f();
> > > +#if !CONFIG_IS_ENABLED(X86_64)
> >
> > Can you use if() instead of #if ?
> I will do it.
>
> >
> > > +       ret = x86_cpu_init_f();
> > > +#endif
> > > +       return ret;
> > >  }
> > >
> > > +#if CONFIG_IS_ENABLED(X86_64)
> >
> > It should be safe to define both of these functions so I don't think you need the
> > #ifdef
> These are defined in arch/x86/cpu/x86_64/cpu.c already.
> Is it okay to make them weak reference or can I keep this as it is?

Oh I see. I am not a fan of weak functions so perhaps we should keep them as is.


>
> >
> > > +int set_hob_list(void *hob_list)
> > > +{
> > > +       gd->arch.hob_list = hob_list;
> > > +       return 0;
> > > +}
> > > +#else
> > >  int checkcpu(void)
> > >  {
> > >         return 0;
> > > @@ -57,3 +69,4 @@ int print_cpuinfo(void)  {
> > >         return default_print_cpuinfo();  }
> > > +#endif
> > > --
> > > 2.20.1
> > >
Regards,
Simon

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

* [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  2020-04-29  5:44     ` Park, Aiden
@ 2020-04-30  9:13       ` Bin Meng
  2020-05-01 18:36         ` Park, Aiden
  0 siblings, 1 reply; 32+ messages in thread
From: Bin Meng @ 2020-04-30  9:13 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Wed, Apr 29, 2020 at 1:44 PM Park, Aiden <aiden.park@intel.com> wrote:
>
> Hi Simon,
>
> > -----Original Message-----
> > From: Simon Glass <sjg@chromium.org>
> > Sent: Sunday, April 26, 2020 1:16 PM
> > To: Park, Aiden <aiden.park@intel.com>
> > Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> > boot at lists.denx.de>
> > Subject: Re: [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
> >
> > Hi Aiden,
> >
> > On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> > >
> > > From: Aiden Park <aiden.park@intel.com>
> > >
> > > This will build U-Boot as a pure 64-bit binary with no SPL.
> > > It can be used with a pre-stage boot firmware which has already done
> > > 16-bit, 32-bit and 64-bit init.
> > >
> > > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > > ---
> > >  arch/x86/Kconfig | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > >
> > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index
> > > c8eae24c07..89add17e69 100644
> > > --- a/arch/x86/Kconfig
> > > +++ b/arch/x86/Kconfig
> > > @@ -40,6 +40,14 @@ config X86_RUN_64BIT
> > >           runs through the 16-bit and 32-bit init, then switches to 64-bit
> > >           mode and jumps to U-Boot proper.
> > >
> > > +config X86_RUN_64BIT_ONLY
> >
> > Perhaps X86_RUN_64BIT_NO_SPL? Bin might hav a better idea.
> >
> I considered X64_RUN_64BIT_NO_SPL, X64_RUN_64BIT_PURE and X64_RUN_64BIT_NATIVE.
> Hi Bin, can you recommend better naming?

Cannot figure out a better name :) Let's use it.

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Regards,
Bin

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

* [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config
  2020-04-26 20:32   ` Simon Glass
  2020-04-29  6:02     ` Park, Aiden
@ 2020-04-30  9:13     ` Bin Meng
  1 sibling, 0 replies; 32+ messages in thread
From: Bin Meng @ 2020-04-30  9:13 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 27, 2020 at 4:32 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Aiden,
>
> On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> >
> > From: Aiden Park <aiden.park@intel.com>
> >
> > Add slimbootloader-x86_64_defconfig for 64-bit slimbootloader board.
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> >  configs/slimbootloader-x86_64_defconfig | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >  create mode 100644 configs/slimbootloader-x86_64_defconfig
>
> How about slimbootloader64?
>
> We always know it is x86.

Agreed with Simon,

Aiden, please also make sure the defconfig file is written with all
options in the correct order. You can do it like this:

$ make slimbootloader64_defconfig
$ make savedefconfig
$ cp defconfig configs/slimbootloader64_defconfig

Regards,
Bin

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

* [PATCH 8/8] doc: slimbootloader: Update 64-bit build instruction
  2020-04-22  0:45 ` [PATCH 8/8] doc: slimbootloader: Update 64-bit build instruction aiden.park at intel.com
@ 2020-04-30  9:13   ` Bin Meng
  0 siblings, 0 replies; 32+ messages in thread
From: Bin Meng @ 2020-04-30  9:13 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 22, 2020 at 8:45 AM <aiden.park@intel.com> wrote:
>
> From: Aiden Park <aiden.park@intel.com>
>
> Add steps to build 64-bit Slim Bootloader and U-Boot.
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>  doc/board/intel/slimbootloader.rst | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

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

* [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
  2020-04-29 18:03       ` Simon Glass
@ 2020-05-01 18:34         ` Park, Aiden
  0 siblings, 0 replies; 32+ messages in thread
From: Park, Aiden @ 2020-05-01 18:34 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg@chromium.org>
> Sent: Wednesday, April 29, 2020 11:04 AM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 4/8] x86: slimbootloader: Support 64-bit operation
> 
> Hi Aiden,
> 
> On Wed, 29 Apr 2020 at 00:01, Park, Aiden <aiden.park@intel.com> wrote:
> >
> > Hi Simon,
> >
> > > -----Original Message-----
> > > From: Simon Glass <sjg@chromium.org>
> > > Sent: Sunday, April 26, 2020 1:16 PM
> > > To: Park, Aiden <aiden.park@intel.com>
> > > Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> > > boot at lists.denx.de>
> > > Subject: Re: [PATCH 4/8] x86: slimbootloader: Support 64-bit
> > > operation
> > >
> > > Hi Aiden,
> > >
> > > On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> > > >
> > > > From: Aiden Park <aiden.park@intel.com>
> > > >
> > > > This supports 64-bit U-Boot as a Slim Bootloader payload.
> > > >
> > > > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > > > ---
> > > >  arch/x86/cpu/slimbootloader/Makefile         |  9 +++++++--
> > > >  arch/x86/cpu/slimbootloader/entry64.S        | 14 ++++++++++++++
> > > >  arch/x86/cpu/slimbootloader/slimbootloader.c | 17
> > > > +++++++++++++++--
> > > >  3 files changed, 36 insertions(+), 4 deletions(-)  create mode
> > > > 100644 arch/x86/cpu/slimbootloader/entry64.S
> > > >
> > > > diff --git a/arch/x86/cpu/slimbootloader/Makefile
> > > > b/arch/x86/cpu/slimbootloader/Makefile
> > > > index aac9fa3db8..79fa699501 100644
> > > > --- a/arch/x86/cpu/slimbootloader/Makefile
> > > > +++ b/arch/x86/cpu/slimbootloader/Makefile
> > > > @@ -1,5 +1,10 @@
> > > >  # SPDX-License-Identifier: GPL-2.0+  # -# Copyright (C) 2019
> > > > Intel Corporation <www.intel.com>
> > > > +# Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
> > > >
> > > > -obj-y += car.o slimbootloader.o sdram.o serial.o
> > > > +ifeq ($(CONFIG_X86_64),y)
> > > > +obj-y += entry64.o
> > > > +else
> > > > +obj-y += car.o
> > > > +endif
> > > > +obj-y += slimbootloader.o sdram.o serial.o
> > > > diff --git a/arch/x86/cpu/slimbootloader/entry64.S
> > > > b/arch/x86/cpu/slimbootloader/entry64.S
> > > > new file mode 100644
> > > > index 0000000000..5e101e18a9
> > > > --- /dev/null
> > > > +++ b/arch/x86/cpu/slimbootloader/entry64.S
> > > > @@ -0,0 +1,14 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > > +/*
> > > > + * Copyright (C) 2020 Intel Corporation <www.intel.com>  */
> > > > +
> > > > +#include <generated/asm-offsets.h>
> > > > +
> > > > +.section .text
> > > > +
> > > > +.globl init_64bit_entry
> > > > +init_64bit_entry:
> > > > +       /* Save hob pointer parameter */
> > > > +       mov     %rcx, %r10
> > > > +       jmp     init_64bit_entry_ret
> > > > diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > > b/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > > index 21dcfb2142..7857e4cd8b 100644
> > > > --- a/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > > +++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
> > > > @@ -1,6 +1,6 @@
> > > >  // SPDX-License-Identifier: GPL-2.0+
> > > >  /*
> > > > - * Copyright (C) 2019 Intel Corporation <www.intel.com>
> > > > + * Copyright (C) 2019-2020 Intel Corporation <www.intel.com>
> > > >   */
> > > >
> > > >  #include <common.h>
> > > > @@ -43,11 +43,23 @@ static void tsc_init(void)
> > > >
> > > >  int arch_cpu_init(void)
> > > >  {
> > > > +       int ret = 0;
> > > > +
> > > >         tsc_init();
> > > >
> > > > -       return x86_cpu_init_f();
> > > > +#if !CONFIG_IS_ENABLED(X86_64)
> > >
> > > Can you use if() instead of #if ?
> > I will do it.
> >
> > >
> > > > +       ret = x86_cpu_init_f();
> > > > +#endif
> > > > +       return ret;
> > > >  }
> > > >
> > > > +#if CONFIG_IS_ENABLED(X86_64)
> > >
> > > It should be safe to define both of these functions so I don't think
> > > you need the #ifdef
> > These are defined in arch/x86/cpu/x86_64/cpu.c already.
> > Is it okay to make them weak reference or can I keep this as it is?
> 
> Oh I see. I am not a fan of weak functions so perhaps we should keep them as is.
I agree with you about the weak functions. Let me keep this as is. Thanks.

> 
> 
> >
> > >
> > > > +int set_hob_list(void *hob_list)
> > > > +{
> > > > +       gd->arch.hob_list = hob_list;
> > > > +       return 0;
> > > > +}
> > > > +#else
> > > >  int checkcpu(void)
> > > >  {
> > > >         return 0;
> > > > @@ -57,3 +69,4 @@ int print_cpuinfo(void)  {
> > > >         return default_print_cpuinfo();  }
> > > > +#endif
> > > > --
> > > > 2.20.1
> > > >
> Regards,
> Simon

Best Regards,
Aiden

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

* [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  2020-04-30  9:13       ` Bin Meng
@ 2020-05-01 18:36         ` Park, Aiden
  2020-05-03  2:26           ` Simon Glass
  0 siblings, 1 reply; 32+ messages in thread
From: Park, Aiden @ 2020-05-01 18:36 UTC (permalink / raw)
  To: u-boot

Hi Bin,

> -----Original Message-----
> From: Bin Meng <bmeng.cn@gmail.com>
> Sent: Thursday, April 30, 2020 2:14 AM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: Simon Glass <sjg@chromium.org>; U-Boot Mailing List <u-
> boot at lists.denx.de>
> Subject: Re: [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
> 
> Hi Aiden,
> 
> On Wed, Apr 29, 2020 at 1:44 PM Park, Aiden <aiden.park@intel.com> wrote:
> >
> > Hi Simon,
> >
> > > -----Original Message-----
> > > From: Simon Glass <sjg@chromium.org>
> > > Sent: Sunday, April 26, 2020 1:16 PM
> > > To: Park, Aiden <aiden.park@intel.com>
> > > Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> > > boot at lists.denx.de>
> > > Subject: Re: [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to
> > > Kconfig
> > >
> > > Hi Aiden,
> > >
> > > On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> > > >
> > > > From: Aiden Park <aiden.park@intel.com>
> > > >
> > > > This will build U-Boot as a pure 64-bit binary with no SPL.
> > > > It can be used with a pre-stage boot firmware which has already
> > > > done 16-bit, 32-bit and 64-bit init.
> > > >
> > > > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > > > ---
> > > >  arch/x86/Kconfig | 8 ++++++++
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index
> > > > c8eae24c07..89add17e69 100644
> > > > --- a/arch/x86/Kconfig
> > > > +++ b/arch/x86/Kconfig
> > > > @@ -40,6 +40,14 @@ config X86_RUN_64BIT
> > > >           runs through the 16-bit and 32-bit init, then switches to 64-bit
> > > >           mode and jumps to U-Boot proper.
> > > >
> > > > +config X86_RUN_64BIT_ONLY
> > >
> > > Perhaps X86_RUN_64BIT_NO_SPL? Bin might hav a better idea.
> > >
> > I considered X64_RUN_64BIT_NO_SPL, X64_RUN_64BIT_PURE and
> X64_RUN_64BIT_NATIVE.
> > Hi Bin, can you recommend better naming?
> 
> Cannot figure out a better name :) Let's use it.
Thanks Bin. Let me use X86_RUN_64BIT_ONLY for now.

Hi Simon, is this naming okay for you?
> 
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> 
> Regards,
> Bin

Best Regards,
Aiden

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

* [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
  2020-05-01 18:36         ` Park, Aiden
@ 2020-05-03  2:26           ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2020-05-03  2:26 UTC (permalink / raw)
  To: u-boot

Hi Aiden,

On Fri, 1 May 2020 at 12:36, Park, Aiden <aiden.park@intel.com> wrote:
>
> Hi Bin,
>
> > -----Original Message-----
> > From: Bin Meng <bmeng.cn@gmail.com>
> > Sent: Thursday, April 30, 2020 2:14 AM
> > To: Park, Aiden <aiden.park@intel.com>
> > Cc: Simon Glass <sjg@chromium.org>; U-Boot Mailing List <u-
> > boot at lists.denx.de>
> > Subject: Re: [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig
> >
> > Hi Aiden,
> >
> > On Wed, Apr 29, 2020 at 1:44 PM Park, Aiden <aiden.park@intel.com> wrote:
> > >
> > > Hi Simon,
> > >
> > > > -----Original Message-----
> > > > From: Simon Glass <sjg@chromium.org>
> > > > Sent: Sunday, April 26, 2020 1:16 PM
> > > > To: Park, Aiden <aiden.park@intel.com>
> > > > Cc: Bin Meng <bmeng.cn@gmail.com>; U-Boot Mailing List <u-
> > > > boot at lists.denx.de>
> > > > Subject: Re: [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to
> > > > Kconfig
> > > >
> > > > Hi Aiden,
> > > >
> > > > On Tue, 21 Apr 2020 at 18:45, <aiden.park@intel.com> wrote:
> > > > >
> > > > > From: Aiden Park <aiden.park@intel.com>
> > > > >
> > > > > This will build U-Boot as a pure 64-bit binary with no SPL.
> > > > > It can be used with a pre-stage boot firmware which has already
> > > > > done 16-bit, 32-bit and 64-bit init.
> > > > >
> > > > > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > > > > ---
> > > > >  arch/x86/Kconfig | 8 ++++++++
> > > > >  1 file changed, 8 insertions(+)
> > > > >
> > > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index
> > > > > c8eae24c07..89add17e69 100644
> > > > > --- a/arch/x86/Kconfig
> > > > > +++ b/arch/x86/Kconfig
> > > > > @@ -40,6 +40,14 @@ config X86_RUN_64BIT
> > > > >           runs through the 16-bit and 32-bit init, then switches to 64-bit
> > > > >           mode and jumps to U-Boot proper.
> > > > >
> > > > > +config X86_RUN_64BIT_ONLY
> > > >
> > > > Perhaps X86_RUN_64BIT_NO_SPL? Bin might hav a better idea.
> > > >
> > > I considered X64_RUN_64BIT_NO_SPL, X64_RUN_64BIT_PURE and
> > X64_RUN_64BIT_NATIVE.
> > > Hi Bin, can you recommend better naming?
> >
> > Cannot figure out a better name :) Let's use it.
> Thanks Bin. Let me use X86_RUN_64BIT_ONLY for now.
>
> Hi Simon, is this naming okay for you?

Yes that's fine thanks.

Regards,
Simon

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

end of thread, other threads:[~2020-05-03  2:26 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22  0:44 [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader aiden.park at intel.com
2020-04-22  0:45 ` [PATCH 1/8] x86: Add a new X86_RUN_64BIT_ONLY to Kconfig aiden.park at intel.com
2020-04-26 20:15   ` Simon Glass
2020-04-29  5:44     ` Park, Aiden
2020-04-30  9:13       ` Bin Meng
2020-05-01 18:36         ` Park, Aiden
2020-05-03  2:26           ` Simon Glass
2020-04-22  0:45 ` [PATCH 2/8] x86: start64: Add a hook at 64-bit entry aiden.park at intel.com
2020-04-26 20:15   ` Simon Glass
2020-04-29  5:48     ` Park, Aiden
2020-04-22  0:45 ` [PATCH 3/8] x86: start64: Support HOB in 64-bit U-Boot aiden.park at intel.com
2020-04-26 20:15   ` Simon Glass
2020-04-29  5:57     ` Park, Aiden
2020-04-22  0:45 ` [PATCH 4/8] x86: slimbootloader: Support 64-bit operation aiden.park at intel.com
2020-04-26 20:15   ` Simon Glass
2020-04-29  6:01     ` Park, Aiden
2020-04-29 18:03       ` Simon Glass
2020-05-01 18:34         ` Park, Aiden
2020-04-22  0:45 ` [PATCH 5/8] configs: slimbootloader: Add x86_64 slimbootloader config aiden.park at intel.com
2020-04-26 20:32   ` Simon Glass
2020-04-29  6:02     ` Park, Aiden
2020-04-30  9:13     ` Bin Meng
2020-04-22  0:45 ` [PATCH 6/8] x86: Fix 64-bit compile warning aiden.park at intel.com
2020-04-26 19:45   ` Simon Glass
2020-04-29  6:08     ` Park, Aiden
2020-04-22  0:45 ` [PATCH 7/8] x86: enable 64-bit kernel boot from 64-bit U-Boot aiden.park at intel.com
2020-04-26 20:15   ` Simon Glass
2020-04-29  6:17     ` Park, Aiden
2020-04-22  0:45 ` [PATCH 8/8] doc: slimbootloader: Update 64-bit build instruction aiden.park at intel.com
2020-04-30  9:13   ` Bin Meng
2020-04-26 20:15 ` [PATCH 0/8] Support 64-bit U-Boot for Slim Bootloader Simon Glass
2020-04-29  5:41   ` Park, Aiden

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.