Skip to contentSkip to conversation

efi_loader: Clean up usage of structure jmp_buf_data

PATCH In review Yao Zi 2 participants 6 messages Feb 15, 2025 – Feb 28, 2025

lore
Share & tools
lore

Yao Zi

author
#0 lore raw

PATCH 1/1 efi_loader: Clean up usage of structure jmp_buf_data

Structure jmp_buf_data provides the underlying format of jmp_buf, which we actually don't care about. Clean up existing code to use the standard jmp_buf type. This introduces no functional change.

---
 include/efi_loader.h          | 4 ++--
 lib/efi_loader/efi_boottime.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
include/efi_loader.h +2 -2
index dcae6a731a0..4afe8b9c859 100644
@@ -15,13 +15,13 @@
 #include <efi_api.h>
 #include <image.h>
 #include <pe.h>
+#include <asm/setjmp.h>
 #include <linux/list.h>
 #include <linux/sizes.h>
 #include <linux/oid_registry.h>
 
 struct blk_desc;
 struct bootflow;
-struct jmp_buf_data;
 
 #if CONFIG_IS_ENABLED(EFI_LOADER)
 
@@ -485,7 +485,7 @@ struct efi_loaded_image_obj {
 	efi_status_t *exit_status;
 	efi_uintn_t *exit_data_size;
 	u16 **exit_data;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 	EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
 				     struct efi_system_table *st);
 	u16 image_type;
lib/efi_loader/efi_boottime.c +4 -4
index 5164cb15986..80c56b1ee46 100644
@@ -3199,7 +3199,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
 	void *info;
 	efi_handle_t parent_image = current_image;
 	efi_status_t exit_status;
-	struct jmp_buf_data exit_jmp;
+	jmp_buf exit_jmp;
 
 	EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
@@ -3238,7 +3238,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
 	}
 
 	/* call the image! */
-	if (setjmp(&exit_jmp)) {
+	if (setjmp(exit_jmp)) {
 		/*
 		 * We called the entry point of the child image with EFI_CALL
 		 * in the lines below. The child image called the Exit() boot
@@ -3444,7 +3444,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
 	struct efi_loaded_image *loaded_image_protocol;
 	struct efi_loaded_image_obj *image_obj =
 		(struct efi_loaded_image_obj *)image_handle;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 
 	EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
 		  exit_data_size, exit_data);
@@ -3511,7 +3511,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
 	 */
 	efi_restore_gd();
 
-	longjmp(exit_jmp, 1);
+	longjmp(*exit_jmp, 1);
 
 	panic("EFI application exited");
 out:
Signature · 1 line
2.48.1
#1 lore raw
Quoted 15 lines · Yao Zi

Structure jmp_buf_data provides the underlying format of jmp_buf, which we actually don't care about. Clean up existing code to use the standard jmp_buf type. This introduces no functional change.

---
  include/efi_loader.h          | 4 ++--
  lib/efi_loader/efi_boottime.c | 8 ++++----
  2 files changed, 6 insertions(+), 6 deletions(-)
include/efi_loader.h +0 -0
index dcae6a731a0..4afe8b9c859 100644

include/efi_loader.h line 18

Quoted 4 lines
include/efi_loader.h +1 -0
@@ -15,13 +15,13 @@
  #include <efi_api.h>
  #include <image.h>
  #include <pe.h>
+#include <asm/setjmp.h>

Thanks for this suggestion.

lib/efi_loader/efi_boottime.c already has this include. We don't need to include it globally.

The rest looks fine.

Best regards

Heinrich

Quoted 59 lines
include/efi_loader.h +1 -2
  #include <linux/list.h>
  #include <linux/sizes.h>
  #include <linux/oid_registry.h>
 
  struct blk_desc;
  struct bootflow;
-struct jmp_buf_data;
 
  #if CONFIG_IS_ENABLED(EFI_LOADER)
 
@@ -485,7 +485,7 @@ struct efi_loaded_image_obj {
  	efi_status_t *exit_status;
  	efi_uintn_t *exit_data_size;
  	u16 **exit_data;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
  	EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
  				     struct efi_system_table *st);
  	u16 image_type;
lib/efi_loader/efi_boottime.c +4 -4
index 5164cb15986..80c56b1ee46 100644
@@ -3199,7 +3199,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	void *info;
  	efi_handle_t parent_image = current_image;
  	efi_status_t exit_status;
-	struct jmp_buf_data exit_jmp;
+	jmp_buf exit_jmp;
 
  	EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
@@ -3238,7 +3238,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	}
 
  	/* call the image! */
-	if (setjmp(&exit_jmp)) {
+	if (setjmp(exit_jmp)) {
  		/*
  		 * We called the entry point of the child image with EFI_CALL
  		 * in the lines below. The child image called the Exit() boot
@@ -3444,7 +3444,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	struct efi_loaded_image *loaded_image_protocol;
  	struct efi_loaded_image_obj *image_obj =
  		(struct efi_loaded_image_obj *)image_handle;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 
  	EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
  		  exit_data_size, exit_data);
@@ -3511,7 +3511,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	 */
  	efi_restore_gd();
 
-	longjmp(exit_jmp, 1);
+	longjmp(*exit_jmp, 1);
 
  	panic("EFI application exited");
  out:
author
#2 lore raw
Quoted 23 lines · Heinrich Schuchardt
Quoted 15 lines · Yao Zi

Structure jmp_buf_data provides the underlying format of jmp_buf, which we actually don't care about. Clean up existing code to use the standard jmp_buf type. This introduces no functional change.

---
  include/efi_loader.h          | 4 ++--
  lib/efi_loader/efi_boottime.c | 8 ++++----
  2 files changed, 6 insertions(+), 6 deletions(-)
include/efi_loader.h +0 -0
index dcae6a731a0..4afe8b9c859 100644

include/efi_loader.h line 18

Quoted 4 lines
include/efi_loader.h +1 -0
@@ -15,13 +15,13 @@
  #include <efi_api.h>
  #include <image.h>
  #include <pe.h>
+#include <asm/setjmp.h>

Thanks for this suggestion.

Quoted 2 lines

lib/efi_loader/efi_boottime.c already has this include. We don't need to include it globally.

We need to include it, or in files that doesn't include asm/setjmp.h directly, type jmp_buf is unknown, failing the compilation.

Quoted 5 lines

The rest looks fine.

Best regards

Heinrich

Thanks,
Yao Zi

Quoted 61 lines
Quoted 60 lines
include/efi_loader.h +1 -2
  #include <linux/list.h>
  #include <linux/sizes.h>
  #include <linux/oid_registry.h>
 
  struct blk_desc;
  struct bootflow;
-struct jmp_buf_data;
 
  #if CONFIG_IS_ENABLED(EFI_LOADER)
 
@@ -485,7 +485,7 @@ struct efi_loaded_image_obj {
  	efi_status_t *exit_status;
  	efi_uintn_t *exit_data_size;
  	u16 **exit_data;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
  	EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
  				     struct efi_system_table *st);
  	u16 image_type;
lib/efi_loader/efi_boottime.c +4 -4
index 5164cb15986..80c56b1ee46 100644
@@ -3199,7 +3199,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	void *info;
  	efi_handle_t parent_image = current_image;
  	efi_status_t exit_status;
-	struct jmp_buf_data exit_jmp;
+	jmp_buf exit_jmp;
 
  	EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
@@ -3238,7 +3238,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	}
 
  	/* call the image! */
-	if (setjmp(&exit_jmp)) {
+	if (setjmp(exit_jmp)) {
  		/*
  		 * We called the entry point of the child image with EFI_CALL
  		 * in the lines below. The child image called the Exit() boot
@@ -3444,7 +3444,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	struct efi_loaded_image *loaded_image_protocol;
  	struct efi_loaded_image_obj *image_obj =
  		(struct efi_loaded_image_obj *)image_handle;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 
  	EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
  		  exit_data_size, exit_data);
@@ -3511,7 +3511,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	 */
  	efi_restore_gd();
 
-	longjmp(exit_jmp, 1);
+	longjmp(*exit_jmp, 1);
 
  	panic("EFI application exited");
  out:
#3 lore raw

Am 16. Februar 2025 15:26:31 MEZ schrieb Yao Zi <[email protected]>:

Quoted 24 lines · Heinrich Schuchardt
Quoted 23 lines · Yao Zi
Quoted 15 lines

Structure jmp_buf_data provides the underlying format of jmp_buf, which we actually don't care about. Clean up existing code to use the standard jmp_buf type. This introduces no functional change.

---
  include/efi_loader.h          | 4 ++--
  lib/efi_loader/efi_boottime.c | 8 ++++----
  2 files changed, 6 insertions(+), 6 deletions(-)
include/efi_loader.h +0 -0
index dcae6a731a0..4afe8b9c859 100644

include/efi_loader.h line 18

Quoted 4 lines
include/efi_loader.h +1 -0
@@ -15,13 +15,13 @@
  #include <efi_api.h>
  #include <image.h>
  #include <pe.h>
+#include <asm/setjmp.h>

Thanks for this suggestion.

Quoted 5 lines
Quoted 2 lines

lib/efi_loader/efi_boottime.c already has this include. We don't need to include it globally.

We need to include it, or in files that doesn't include asm/setjmp.h directly, type jmp_buf is unknown, failing the compilation.

There is no such file.

Quoted 71 lines
Quoted 6 lines

The rest looks fine.

Best regards

Heinrich

Thanks,
Yao Zi

Quoted 61 lines
Quoted 60 lines
include/efi_loader.h +1 -2
  #include <linux/list.h>
  #include <linux/sizes.h>
  #include <linux/oid_registry.h>
 
  struct blk_desc;
  struct bootflow;
-struct jmp_buf_data;
 
  #if CONFIG_IS_ENABLED(EFI_LOADER)
 
@@ -485,7 +485,7 @@ struct efi_loaded_image_obj {
  	efi_status_t *exit_status;
  	efi_uintn_t *exit_data_size;
  	u16 **exit_data;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
  	EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
  				     struct efi_system_table *st);
  	u16 image_type;
lib/efi_loader/efi_boottime.c +4 -4
index 5164cb15986..80c56b1ee46 100644
@@ -3199,7 +3199,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	void *info;
  	efi_handle_t parent_image = current_image;
  	efi_status_t exit_status;
-	struct jmp_buf_data exit_jmp;
+	jmp_buf exit_jmp;
 
  	EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
@@ -3238,7 +3238,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	}
 
  	/* call the image! */
-	if (setjmp(&exit_jmp)) {
+	if (setjmp(exit_jmp)) {
  		/*
  		 * We called the entry point of the child image with EFI_CALL
  		 * in the lines below. The child image called the Exit() boot
@@ -3444,7 +3444,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	struct efi_loaded_image *loaded_image_protocol;
  	struct efi_loaded_image_obj *image_obj =
  		(struct efi_loaded_image_obj *)image_handle;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 
  	EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
  		  exit_data_size, exit_data);
@@ -3511,7 +3511,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	 */
  	efi_restore_gd();
 
-	longjmp(exit_jmp, 1);
+	longjmp(*exit_jmp, 1);
 
  	panic("EFI application exited");
  out:
author
#4 lore raw
Quoted 31 lines · Heinrich Schuchardt

Am 16. Februar 2025 15:26:31 MEZ schrieb Yao Zi <[email protected]>:

Quoted 29 lines · Heinrich Schuchardt
Quoted 23 lines · Yao Zi
Quoted 15 lines

Structure jmp_buf_data provides the underlying format of jmp_buf, which we actually don't care about. Clean up existing code to use the standard jmp_buf type. This introduces no functional change.

---
  include/efi_loader.h          | 4 ++--
  lib/efi_loader/efi_boottime.c | 8 ++++----
  2 files changed, 6 insertions(+), 6 deletions(-)
include/efi_loader.h +0 -0
index dcae6a731a0..4afe8b9c859 100644

include/efi_loader.h line 18

Quoted 4 lines
include/efi_loader.h +1 -0
@@ -15,13 +15,13 @@
  #include <efi_api.h>
  #include <image.h>
  #include <pe.h>
+#include <asm/setjmp.h>

Thanks for this suggestion.

Quoted 2 lines

lib/efi_loader/efi_boottime.c already has this include. We don't need to include it globally.

We need to include it, or in files that doesn't include asm/setjmp.h directly, type jmp_buf is unknown, failing the compilation.

After removing the include, I get bunches of compilation errors like

	In file included from lib/efi_loader/efi_file.c:11:
	include/efi_loader.h:487:9: error: unknown type name 'jmp_buf'
	  487 |         jmp_buf *exit_jmp;
	      |         ^~~~~~~
	In file included from lib/efi_loader/efi_load_options.c:13:
	include/efi_loader.h:487:9: error: unknown type name 'jmp_buf'
	  487 |         jmp_buf *exit_jmp;
	      |         ^~~~~~~
Quoted 1 line

There is no such file.

So I don't think it's true. By "files that doesn't include asm/setjmp.h directly", I mean those which include efi_loader.h but don't include asm/setjmp.h.

Quoted 72 lines
Quoted 71 lines
Quoted 6 lines

The rest looks fine.

Best regards

Heinrich

Thanks,
Yao Zi

Quoted 61 lines
Quoted 60 lines
include/efi_loader.h +1 -2
  #include <linux/list.h>
  #include <linux/sizes.h>
  #include <linux/oid_registry.h>
 
  struct blk_desc;
  struct bootflow;
-struct jmp_buf_data;
 
  #if CONFIG_IS_ENABLED(EFI_LOADER)
 
@@ -485,7 +485,7 @@ struct efi_loaded_image_obj {
  	efi_status_t *exit_status;
  	efi_uintn_t *exit_data_size;
  	u16 **exit_data;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
  	EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
  				     struct efi_system_table *st);
  	u16 image_type;
lib/efi_loader/efi_boottime.c +4 -4
index 5164cb15986..80c56b1ee46 100644
@@ -3199,7 +3199,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	void *info;
  	efi_handle_t parent_image = current_image;
  	efi_status_t exit_status;
-	struct jmp_buf_data exit_jmp;
+	jmp_buf exit_jmp;
 
  	EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
@@ -3238,7 +3238,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  	}
 
  	/* call the image! */
-	if (setjmp(&exit_jmp)) {
+	if (setjmp(exit_jmp)) {
  		/*
  		 * We called the entry point of the child image with EFI_CALL
  		 * in the lines below. The child image called the Exit() boot
@@ -3444,7 +3444,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	struct efi_loaded_image *loaded_image_protocol;
  	struct efi_loaded_image_obj *image_obj =
  		(struct efi_loaded_image_obj *)image_handle;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 
  	EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
  		  exit_data_size, exit_data);
@@ -3511,7 +3511,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  	 */
  	efi_restore_gd();
 
-	longjmp(exit_jmp, 1);
+	longjmp(*exit_jmp, 1);
 
  	panic("EFI application exited");
  out:
#5 lore raw
Quoted 44 lines · Yao Zi
Quoted 31 lines · Heinrich Schuchardt

Am 16. Februar 2025 15:26:31 MEZ schrieb Yao Zi <[email protected]>:

Quoted 29 lines · Heinrich Schuchardt
Quoted 23 lines · Yao Zi
Quoted 15 lines

Structure jmp_buf_data provides the underlying format of jmp_buf, which we actually don't care about. Clean up existing code to use the standard jmp_buf type. This introduces no functional change.

---
   include/efi_loader.h          | 4 ++--
   lib/efi_loader/efi_boottime.c | 8 ++++----
   2 files changed, 6 insertions(+), 6 deletions(-)
include/efi_loader.h +0 -0
index dcae6a731a0..4afe8b9c859 100644

include/efi_loader.h line 18

Quoted 4 lines
include/efi_loader.h +1 -0
@@ -15,13 +15,13 @@
   #include <efi_api.h>
   #include <image.h>
   #include <pe.h>
+#include <asm/setjmp.h>

Thanks for this suggestion.

Quoted 2 lines

lib/efi_loader/efi_boottime.c already has this include. We don't need to include it globally.

We need to include it, or in files that doesn't include asm/setjmp.h directly, type jmp_buf is unknown, failing the compilation.

After removing the include, I get bunches of compilation errors like

	In file included from lib/efi_loader/efi_file.c:11:
	include/efi_loader.h:487:9: error: unknown type name 'jmp_buf'
	  487 |         jmp_buf *exit_jmp;
	      |         ^~~~~~~
	In file included from lib/efi_loader/efi_load_options.c:13:
	include/efi_loader.h:487:9: error: unknown type name 'jmp_buf'
	  487 |         jmp_buf *exit_jmp;
	      |         ^~~~~~~
Quoted 5 lines
Quoted 1 line

There is no such file.

So I don't think it's true. By "files that doesn't include asm/setjmp.h directly", I mean those which include efi_loader.h but don't include asm/setjmp.h.

Building with your patch fails on architectures that don't implement setjmp because asm/setjmp.h does not exist on these.

Best regards

Heinrich

Quoted 73 lines
Quoted 73 lines
Quoted 72 lines
Quoted 7 lines

The rest looks fine.

Best regards

Heinrich

Thanks,
Yao Zi

Quoted 61 lines
Quoted 60 lines
include/efi_loader.h +1 -2
   #include <linux/list.h>
   #include <linux/sizes.h>
   #include <linux/oid_registry.h>
 
   struct blk_desc;
   struct bootflow;
-struct jmp_buf_data;
 
   #if CONFIG_IS_ENABLED(EFI_LOADER)
 
@@ -485,7 +485,7 @@ struct efi_loaded_image_obj {
   	efi_status_t *exit_status;
   	efi_uintn_t *exit_data_size;
   	u16 **exit_data;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
   	EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
   				     struct efi_system_table *st);
   	u16 image_type;
lib/efi_loader/efi_boottime.c +4 -4
index 5164cb15986..80c56b1ee46 100644
@@ -3199,7 +3199,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
   	void *info;
   	efi_handle_t parent_image = current_image;
   	efi_status_t exit_status;
-	struct jmp_buf_data exit_jmp;
+	jmp_buf exit_jmp;
 
   	EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
@@ -3238,7 +3238,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
   	}
 
   	/* call the image! */
-	if (setjmp(&exit_jmp)) {
+	if (setjmp(exit_jmp)) {
   		/*
   		 * We called the entry point of the child image with EFI_CALL
   		 * in the lines below. The child image called the Exit() boot
@@ -3444,7 +3444,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
   	struct efi_loaded_image *loaded_image_protocol;
   	struct efi_loaded_image_obj *image_obj =
   		(struct efi_loaded_image_obj *)image_handle;
-	struct jmp_buf_data *exit_jmp;
+	jmp_buf *exit_jmp;
 
   	EFI_ENTRY("%p, %ld, %zu, %p", image_handle, exit_status,
   		  exit_data_size, exit_data);
@@ -3511,7 +3511,7 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
   	 */
   	efi_restore_gd();
 
-	longjmp(exit_jmp, 1);
+	longjmp(*exit_jmp, 1);
 
   	panic("EFI application exited");
   out: