All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
@ 2023-11-19 16:54 Shantur Rathore
  2023-11-19 16:54 ` [PATCH v4 1/4] bootflow: bootmeth_efi: Set bootp_arch as hex Shantur Rathore
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Shantur Rathore @ 2023-11-19 16:54 UTC (permalink / raw
  To: u-boot; +Cc: Shantur Rathore, Simon Glass


Currently bootmeth_efi crashes while doing a network (dhcp) boot.
This patch series fixes issues and both network and disk boot works.

Shantur Rathore (4):
  bootflow: bootmeth_efi: Set bootp_arch as hex
  bootflow: bootmeth_efi: set bflow->fname from bootfile name
  bootflow: bootmeth_efi: Handle fdt not available.
  bootflow: bootmeth_efi: don't free buffer

 boot/bootmeth_efi.c | 36 +++++++++++++++++++++++++++---------
 include/bootflow.h  |  2 ++
 2 files changed, 29 insertions(+), 9 deletions(-)

-- 
2.40.1


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

* [PATCH v4 1/4] bootflow: bootmeth_efi: Set bootp_arch as hex
  2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
@ 2023-11-19 16:54 ` Shantur Rathore
  2023-11-19 16:54 ` [PATCH v4 2/4] bootflow: bootmeth_efi: set bflow->fname from bootfile name Shantur Rathore
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Shantur Rathore @ 2023-11-19 16:54 UTC (permalink / raw
  To: u-boot; +Cc: Shantur Rathore, Simon Glass

bootmeth_efi sets up bootp_arch which is read later in bootp.c
Currently bootp_arch is being set as integer string and being
read in bootp.c as hex, this sends incorrect arch value to dhcp server
which in return sends wrong file for network boot.

For ARM64 UEFI Arch value is 0xb (11), here we set environment as 11
and later is read as 0x11 and 17 is sent to dhcp server.

Setting it as hex string fixes the problem.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Shantur Rathore <i@shantur.com>
---

(no changes since v1)

 boot/bootmeth_efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 9ba7734911..682cf5b23b 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -339,7 +339,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
 	ret = env_set("bootp_vci", str);
 	if (ret)
 		return log_msg_ret("vcs", ret);
-	ret = env_set_ulong("bootp_arch", arch);
+	ret = env_set_hex("bootp_arch", arch);
 	if (ret)
 		return log_msg_ret("ars", ret);
 
-- 
2.40.1


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

* [PATCH v4 2/4] bootflow: bootmeth_efi: set bflow->fname from bootfile name
  2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
  2023-11-19 16:54 ` [PATCH v4 1/4] bootflow: bootmeth_efi: Set bootp_arch as hex Shantur Rathore
@ 2023-11-19 16:54 ` Shantur Rathore
  2023-11-19 16:55 ` [PATCH v4 3/4] bootflow: bootmeth_efi: Handle fdt not available Shantur Rathore
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Shantur Rathore @ 2023-11-19 16:54 UTC (permalink / raw
  To: u-boot; +Cc: Shantur Rathore, Simon Glass

We need to set boot->fname before calling efi_set_bootdev
otherwise this crashes as bflow->fname is null.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Shantur Rathore <i@shantur.com>
---

(no changes since v1)

 boot/bootmeth_efi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 682cf5b23b..fd224f7c91 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -323,7 +323,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
 	char file_addr[17], fname[256];
 	char *tftp_argv[] = {"tftp", file_addr, fname, NULL};
 	struct cmd_tbl cmdtp = {};	/* dummy */
-	const char *addr_str, *fdt_addr_str;
+	const char *addr_str, *fdt_addr_str, *bootfile_name;
 	int ret, arch, size;
 	ulong addr, fdt_addr;
 	char str[36];
@@ -360,6 +360,12 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
 		return log_msg_ret("sz", -EINVAL);
 	bflow->size = size;
 
+    /* bootfile should be setup by dhcp*/
+	bootfile_name = env_get("bootfile");
+	if (!bootfile_name)
+		return log_msg_ret("bootfile_name", ret);
+	bflow->fname = strdup(bootfile_name);
+
 	/* do the hideous EFI hack */
 	efi_set_bootdev("Net", "", bflow->fname, map_sysmem(addr, 0),
 			bflow->size);
-- 
2.40.1


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

* [PATCH v4 3/4] bootflow: bootmeth_efi: Handle fdt not available.
  2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
  2023-11-19 16:54 ` [PATCH v4 1/4] bootflow: bootmeth_efi: Set bootp_arch as hex Shantur Rathore
  2023-11-19 16:54 ` [PATCH v4 2/4] bootflow: bootmeth_efi: set bflow->fname from bootfile name Shantur Rathore
@ 2023-11-19 16:55 ` Shantur Rathore
  2023-11-19 16:55 ` [PATCH v4 4/4] bootflow: bootmeth_efi: don't free buffer Shantur Rathore
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Shantur Rathore @ 2023-11-19 16:55 UTC (permalink / raw
  To: u-boot; +Cc: Shantur Rathore, Simon Glass

While booting with efi, if fdt isn't available externally,
just use the built-in one.

Reviewed-by: Simon Glass <sjg@chromium.org>

Signed-off-by: Shantur Rathore <i@shantur.com>
---

Changes in v4:
- Update code to use BUILT_IN_FDT flag as suggested

 boot/bootmeth_efi.c | 19 +++++++++++++------
 include/bootflow.h  |  2 ++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index fd224f7c91..e884dc6293 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -313,6 +313,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
 		 */
 	} else {
 		log_debug("No device tree available\n");
+		bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
 	}
 
 	return 0;
@@ -391,6 +392,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
 		bflow->fdt_addr = fdt_addr;
 	} else {
 		log_debug("No device tree available\n");
+		bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
 	}
 
 	bflow->state = BOOTFLOWST_READY;
@@ -429,13 +431,11 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
 			return log_msg_ret("read", ret);
 
 		/*
-		 * use the provided device tree if available, else fall back to
-		 * the control FDT
+		 * use the provided device tree if not using the built-in fdt
 		 */
-		if (bflow->fdt_fname)
+		if (bflow->flags & ~BOOTFLOWF_USE_BUILTIN_FDT)
 			fdt = bflow->fdt_addr;
-		else
-			fdt = (ulong)map_to_sysmem(gd->fdt_blob);
+
 	} else {
 		/*
 		 * This doesn't actually work for network devices:
@@ -452,7 +452,14 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
 	 * At some point we can add a real interface to bootefi so we can call
 	 * this directly. For now, go through the CLI, like distro boot.
 	 */
-	snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
+	if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
+		log_debug("Booting with built-in fdt\n");
+		snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
+	} else {
+		log_debug("Booting with external fdt\n");
+		snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
+	}
+
 	if (run_command(cmd, 0))
 		return log_msg_ret("run", -EINVAL);
 
diff --git a/include/bootflow.h b/include/bootflow.h
index fede8f22a2..42112874f6 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -45,10 +45,12 @@ enum bootflow_state_t {
  *	CONFIG_OF_HAS_PRIOR_STAGE is enabled
  * @BOOTFLOWF_STATIC_BUF: Indicates that @bflow->buf is statically set, rather
  *	than being allocated by malloc().
+ * @BOOTFLOWF_USE_BUILTIN_FDT : Indicates that current bootflow uses built-in FDT
  */
 enum bootflow_flags_t {
 	BOOTFLOWF_USE_PRIOR_FDT	= 1 << 0,
 	BOOTFLOWF_STATIC_BUF	= 1 << 1,
+	BOOTFLOWF_USE_BUILTIN_FDT	= 1 << 2,
 };
 
 /**
-- 
2.40.1


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

* [PATCH v4 4/4] bootflow: bootmeth_efi: don't free buffer
  2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
                   ` (2 preceding siblings ...)
  2023-11-19 16:55 ` [PATCH v4 3/4] bootflow: bootmeth_efi: Handle fdt not available Shantur Rathore
@ 2023-11-19 16:55 ` Shantur Rathore
  2023-12-04 12:38 ` [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
  2023-12-09 18:16 ` Tom Rini
  5 siblings, 0 replies; 11+ messages in thread
From: Shantur Rathore @ 2023-11-19 16:55 UTC (permalink / raw
  To: u-boot; +Cc: Shantur Rathore, Simon Glass

bootmeth_efi doesn't allocate any buffer to load efi in any case.
enable static buffer flag for all cases.

Reviewed-by: Simon Glass <sjg@chromium.org>

Signed-off-by: Shantur Rathore <i@shantur.com>
---

(no changes since v1)

 boot/bootmeth_efi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index e884dc6293..446cb73140 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -160,7 +160,6 @@ static int efiload_read_file(struct bootflow *bflow, ulong addr)
 	if (ret)
 		return log_msg_ret("read", ret);
 	bflow->buf = map_sysmem(addr, bflow->size);
-	bflow->flags |= BOOTFLOWF_STATIC_BUF;
 
 	set_efi_bootdev(desc, bflow);
 
@@ -404,6 +403,12 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
 	int ret;
 
+	/*
+	 * bootmeth_efi doesn't allocate any buffer neither for blk nor net device
+	 * set flag to avoid freeing static buffer.
+	 */
+	bflow->flags |= BOOTFLOWF_STATIC_BUF;
+
 	if (bootmeth_uses_network(bflow)) {
 		/* we only support reading from one device, so ignore 'dev' */
 		ret = distro_efi_read_bootflow_net(bflow);
-- 
2.40.1


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

* Re: [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
  2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
                   ` (3 preceding siblings ...)
  2023-11-19 16:55 ` [PATCH v4 4/4] bootflow: bootmeth_efi: don't free buffer Shantur Rathore
@ 2023-12-04 12:38 ` Shantur Rathore
  2023-12-05  0:51   ` Simon Glass
  2023-12-09 18:16 ` Tom Rini
  5 siblings, 1 reply; 11+ messages in thread
From: Shantur Rathore @ 2023-12-04 12:38 UTC (permalink / raw
  To: u-boot; +Cc: Simon Glass

Hi Simon,

On Sun, Nov 19, 2023 at 4:56 PM Shantur Rathore <i@shantur.com> wrote:
>
>
> Currently bootmeth_efi crashes while doing a network (dhcp) boot.
> This patch series fixes issues and both network and disk boot works.
>
How can I help to get this patch series merged in?

Kind Regards
Shantur

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

* Re: [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
  2023-12-04 12:38 ` [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
@ 2023-12-05  0:51   ` Simon Glass
  2023-12-05 11:13     ` Shantur Rathore
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Glass @ 2023-12-05  0:51 UTC (permalink / raw
  To: Shantur Rathore; +Cc: u-boot

Hi Shantur,

On Mon, 4 Dec 2023 at 05:38, Shantur Rathore <i@shantur.com> wrote:
>
> Hi Simon,
>
> On Sun, Nov 19, 2023 at 4:56 PM Shantur Rathore <i@shantur.com> wrote:
> >
> >
> > Currently bootmeth_efi crashes while doing a network (dhcp) boot.
> > This patch series fixes issues and both network and disk boot works.
> >
> How can I help to get this patch series merged in?

You can check patchwork [1] to see who it is assigned to. I don't see
it in my queue though.

Regards,
Simon

[1]

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

* Re: [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
  2023-12-05  0:51   ` Simon Glass
@ 2023-12-05 11:13     ` Shantur Rathore
  2023-12-06  3:54       ` Simon Glass
  0 siblings, 1 reply; 11+ messages in thread
From: Shantur Rathore @ 2023-12-05 11:13 UTC (permalink / raw
  To: Simon Glass; +Cc: u-boot

Hi Simon,

On Tue, Dec 5, 2023 at 12:52 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Shantur,
>
> On Mon, 4 Dec 2023 at 05:38, Shantur Rathore <i@shantur.com> wrote:
> >
> > Hi Simon,
> >
> > On Sun, Nov 19, 2023 at 4:56 PM Shantur Rathore <i@shantur.com> wrote:
> > >
> > >
> > > Currently bootmeth_efi crashes while doing a network (dhcp) boot.
> > > This patch series fixes issues and both network and disk boot works.
> > >
> > How can I help to get this patch series merged in?
>
> You can check patchwork [1] to see who it is assigned to. I don't see
> it in my queue though.
>
It's with Tom Rini I believe but with status Needs Review / ACK.

https://patchwork.ozlabs.org/project/uboot/list/?series=382855

Kind Regards,
Shantur

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

* Re: [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
  2023-12-05 11:13     ` Shantur Rathore
@ 2023-12-06  3:54       ` Simon Glass
  2023-12-09 18:15         ` Tom Rini
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Glass @ 2023-12-06  3:54 UTC (permalink / raw
  To: Shantur Rathore, Tom Rini; +Cc: u-boot

Hi Shantur,

On Tue, 5 Dec 2023 at 04:13, Shantur Rathore <i@shantur.com> wrote:
>
> Hi Simon,
>
> On Tue, Dec 5, 2023 at 12:52 AM Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Shantur,
> >
> > On Mon, 4 Dec 2023 at 05:38, Shantur Rathore <i@shantur.com> wrote:
> > >
> > > Hi Simon,
> > >
> > > On Sun, Nov 19, 2023 at 4:56 PM Shantur Rathore <i@shantur.com> wrote:
> > > >
> > > >
> > > > Currently bootmeth_efi crashes while doing a network (dhcp) boot.
> > > > This patch series fixes issues and both network and disk boot works.
> > > >
> > > How can I help to get this patch series merged in?
> >
> > You can check patchwork [1] to see who it is assigned to. I don't see
> > it in my queue though.
> >
> It's with Tom Rini I believe but with status Needs Review / ACK.
>
> https://patchwork.ozlabs.org/project/uboot/list/?series=382855

OK, well it has a review so that tag may be out-of-date.

+Tom Rini

Regards,
SImon

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

* Re: [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
  2023-12-06  3:54       ` Simon Glass
@ 2023-12-09 18:15         ` Tom Rini
  0 siblings, 0 replies; 11+ messages in thread
From: Tom Rini @ 2023-12-09 18:15 UTC (permalink / raw
  To: Simon Glass; +Cc: Shantur Rathore, u-boot

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

On Tue, Dec 05, 2023 at 08:54:51PM -0700, Simon Glass wrote:
> Hi Shantur,
> 
> On Tue, 5 Dec 2023 at 04:13, Shantur Rathore <i@shantur.com> wrote:
> >
> > Hi Simon,
> >
> > On Tue, Dec 5, 2023 at 12:52 AM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Hi Shantur,
> > >
> > > On Mon, 4 Dec 2023 at 05:38, Shantur Rathore <i@shantur.com> wrote:
> > > >
> > > > Hi Simon,
> > > >
> > > > On Sun, Nov 19, 2023 at 4:56 PM Shantur Rathore <i@shantur.com> wrote:
> > > > >
> > > > >
> > > > > Currently bootmeth_efi crashes while doing a network (dhcp) boot.
> > > > > This patch series fixes issues and both network and disk boot works.
> > > > >
> > > > How can I help to get this patch series merged in?
> > >
> > > You can check patchwork [1] to see who it is assigned to. I don't see
> > > it in my queue though.
> > >
> > It's with Tom Rini I believe but with status Needs Review / ACK.
> >
> > https://patchwork.ozlabs.org/project/uboot/list/?series=382855
> 
> OK, well it has a review so that tag may be out-of-date.

OK, so you're happy with it Simon, so I'll grab it for master shortly.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot.
  2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
                   ` (4 preceding siblings ...)
  2023-12-04 12:38 ` [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
@ 2023-12-09 18:16 ` Tom Rini
  5 siblings, 0 replies; 11+ messages in thread
From: Tom Rini @ 2023-12-09 18:16 UTC (permalink / raw
  To: u-boot, Shantur Rathore; +Cc: Simon Glass

On Sun, 19 Nov 2023 16:54:57 +0000, Shantur Rathore wrote:

> Currently bootmeth_efi crashes while doing a network (dhcp) boot.
> This patch series fixes issues and both network and disk boot works.
> 
> Shantur Rathore (4):
>   bootflow: bootmeth_efi: Set bootp_arch as hex
>   bootflow: bootmeth_efi: set bflow->fname from bootfile name
>   bootflow: bootmeth_efi: Handle fdt not available.
>   bootflow: bootmeth_efi: don't free buffer
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom



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

end of thread, other threads:[~2023-12-09 18:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-19 16:54 [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
2023-11-19 16:54 ` [PATCH v4 1/4] bootflow: bootmeth_efi: Set bootp_arch as hex Shantur Rathore
2023-11-19 16:54 ` [PATCH v4 2/4] bootflow: bootmeth_efi: set bflow->fname from bootfile name Shantur Rathore
2023-11-19 16:55 ` [PATCH v4 3/4] bootflow: bootmeth_efi: Handle fdt not available Shantur Rathore
2023-11-19 16:55 ` [PATCH v4 4/4] bootflow: bootmeth_efi: don't free buffer Shantur Rathore
2023-12-04 12:38 ` [PATCH v4 0/4] bootflow: bootmeth_efi: Fix network efi boot Shantur Rathore
2023-12-05  0:51   ` Simon Glass
2023-12-05 11:13     ` Shantur Rathore
2023-12-06  3:54       ` Simon Glass
2023-12-09 18:15         ` Tom Rini
2023-12-09 18:16 ` Tom Rini

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.