Skip to contentSkip to conversation

efi/libstub/x86: fix mixed mode boot issue after macro refactor

PATCH New Ard Biesheuvel 3 participants 11 messages May 3, 2020 – May 5, 2020

Subsystems (2)
lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH 1/1 efi/libstub/x86: fix mixed mode boot issue after macro refactor

Commit

22090f84bc3f8081 ("efi/libstub: Unify EFI call wrappers for non-x86")

refactored some macros that are used to wrap EFI service calls, and allow us to boot the 64-bit x86 kernel from 32-bit firmware. Sadly, due to an oversight, this caused a boot issue on mixed mode, due to the fact that efi_is_native() is not a macro on x86, and so #ifndef will not detect that it is already defined.

Fix this by defining the macro as well.

---
 arch/x86/include/asm/efi.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/efi.h +1 -0
index cd0c3fbf6156..42b2fd123a2f 100644
@@ -240,6 +240,7 @@ static inline bool efi_is_native(void)
 		return true;
 	return efi_is_64bit();
 }
+#define efi_is_native efi_is_native
 
 #define efi_mixed_mode_cast(attr)					\
 	__builtin_choose_expr(						\
Signature · 1 line
2.26.2
#1 lore raw

cover efi/libstub: Fix mixed mode boot on efi/next

How about this instead -- just get rid of the macros on x86 as well if mixed mode isn't enabled, and condition the generic definition on CONFIG_EFI_MIXED?

Arvind Sankar (1):
efi/libstub: Fix mixed mode boot issue after macro refactor

 arch/x86/include/asm/efi.h             | 17 +++++++++++++----
 drivers/firmware/efi/libstub/efistub.h | 14 ++++----------
 2 files changed, 17 insertions(+), 14 deletions(-)
Signature · 1 line
2.26.2
#2 lore raw

PATCH 1/1 efi/libstub: Fix mixed mode boot issue after macro refactor

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Fix this by conditioning the generic macro definitions on CONFIG_EFI_MIXED, and removing the wrapper definitions on x86 if CONFIG_EFI_MIXED is not enabled.

---
 arch/x86/include/asm/efi.h             | 17 +++++++++++++----
 drivers/firmware/efi/libstub/efistub.h | 14 ++++----------
 2 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/include/asm/efi.h +13 -4
index cd0c3fbf6156..88f29f84a4d0 100644
@@ -225,13 +225,13 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
 
 /* arch specific definitions used by the stub code */
 
-extern const bool efi_is64;
+#ifdef CONFIG_EFI_MIXED
 
 static inline bool efi_is_64bit(void)
 {
-	if (IS_ENABLED(CONFIG_EFI_MIXED))
-		return efi_is64;
-	return IS_ENABLED(CONFIG_X86_64);
+	extern const bool efi_is64;
+
+	return efi_is64;
 }
 
 static inline bool efi_is_native(void)
@@ -356,6 +356,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
 						   runtime),		\
 				    func, __VA_ARGS__))
 
+#else /* CONFIG_EFI_MIXED */
+
+static inline bool efi_is_64bit(void)
+{
+	return IS_ENABLED(CONFIG_X86_64);
+}
+
+#endif /* CONFIG_EFI_MIXED */
+
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
 
drivers/firmware/efi/libstub/efistub.h +4 -10
index 874233cf8820..37ca286a40c6 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef CONFIG_EFI_MIXED
+
+#define efi_is_native()		(true)
 #define efi_bs_call(func, ...)	efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...)	efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()		(true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)	(inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)		do {			\
Signature · 1 line
2.26.2
author maintainer
#3 lore raw

Re: [PATCH 1/1] efi/libstub: Fix mixed mode boot issue after macro refactor

Quoted 10 lines · Arvind Sankar

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Quoted 6 lines

Fix this by conditioning the generic macro definitions on CONFIG_EFI_MIXED, and removing the wrapper definitions on x86 if CONFIG_EFI_MIXED is not enabled.

Thanks Arvind.

Currently, CONFIG_EFI_MIXED is never referenced outside of arch/x86, and I prefer to keep it that way.

Also, I fail to see where the definition of efi_is_native() comes from after applying this patch.

Quoted 75 lines
---
 arch/x86/include/asm/efi.h             | 17 +++++++++++++----
 drivers/firmware/efi/libstub/efistub.h | 14 ++++----------
 2 files changed, 17 insertions(+), 14 deletions(-)
arch/x86/include/asm/efi.h +13 -4
index cd0c3fbf6156..88f29f84a4d0 100644
@@ -225,13 +225,13 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
 
 /* arch specific definitions used by the stub code */
 
-extern const bool efi_is64;
+#ifdef CONFIG_EFI_MIXED
 
 static inline bool efi_is_64bit(void)
 {
-       if (IS_ENABLED(CONFIG_EFI_MIXED))
-               return efi_is64;
-       return IS_ENABLED(CONFIG_X86_64);
+       extern const bool efi_is64;
+
+       return efi_is64;
 }
 
 static inline bool efi_is_native(void)
@@ -356,6 +356,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
                                                   runtime),            \
                                    func, __VA_ARGS__))
 
+#else /* CONFIG_EFI_MIXED */
+
+static inline bool efi_is_64bit(void)
+{
+       return IS_ENABLED(CONFIG_X86_64);
+}
+
+#endif /* CONFIG_EFI_MIXED */
+
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
 
drivers/firmware/efi/libstub/efistub.h +4 -11
index 874233cf8820..37ca286a40c6 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef CONFIG_EFI_MIXED
+
+#define efi_is_native()                (true)
 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()                (true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)     (inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)          do {                    \
--

2.26.2

#4 lore raw

Re: [PATCH 1/1] efi/libstub: Fix mixed mode boot issue after macro refactor

Quoted 15 lines · Ard Biesheuvel
Quoted 14 lines · Arvind Sankar

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Fix this by conditioning the generic macro definitions on CONFIG_EFI_MIXED, and removing the wrapper definitions on x86 if CONFIG_EFI_MIXED is not enabled.

Quoted 7 lines
Quoted 2 lines

Thanks Arvind.

Currently, CONFIG_EFI_MIXED is never referenced outside of arch/x86, and I prefer to keep it that way.

All these macros go together though -- they should either all be defined or none, so it makes sense to put them under a single #if. If you think it's possible that a future architecture might need the wrappers but not be mixed, we could maybe add an ARCH_NEEDS_EFISTUB_WRAPPERS?

Quoted 3 lines

Also, I fail to see where the definition of efi_is_native() comes from after applying this patch.

The generic definition is in the same place -- I just moved it to the top as it's a predicate rather than a wrapper, and kept all the actual wrappers together.

Quoted 32 lines
Quoted 32 lines
drivers/firmware/efi/libstub/efistub.h +4 -11
index 874233cf8820..37ca286a40c6 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef CONFIG_EFI_MIXED
+
+#define efi_is_native()                (true)
 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()                (true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)     (inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)          do {                    \
--

2.26.2

author maintainer
#5 lore raw

Re: [PATCH 1/1] efi/libstub: Fix mixed mode boot issue after macro refactor

Quoted 20 lines · Arvind Sankar
Quoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Arvind Sankar

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Fix this by conditioning the generic macro definitions on CONFIG_EFI_MIXED, and removing the wrapper definitions on x86 if CONFIG_EFI_MIXED is not enabled.

Quoted 7 lines
Quoted 4 lines

Thanks Arvind.

Currently, CONFIG_EFI_MIXED is never referenced outside of arch/x86, and I prefer to keep it that way.

All these macros go together though -- they should either all be defined or none, so it makes sense to put them under a single #if.

True.

Quoted 4 lines

If you think
it's possible that a future architecture might need the wrappers but not be mixed, we could maybe add an ARCH_NEEDS_EFISTUB_WRAPPERS?

Well, remember that x86 used wrappers for native invocations only two releases ago, but that was mainly because of the SysV vs MS ABI issue, so the issue could emerge again, but it is unlikely.

Quoted 8 lines
Quoted 3 lines

Also, I fail to see where the definition of efi_is_native() comes from after applying this patch.

The generic definition is in the same place -- I just moved it to the top as it's a predicate rather than a wrapper, and kept all the actual wrappers together.

Ah yes, I see it now.

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
drivers/firmware/efi/libstub/efistub.h +4 -11
index 874233cf8820..37ca286a40c6 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef CONFIG_EFI_MIXED
+
+#define efi_is_native()                (true)
 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()                (true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)     (inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)          do {                    \
--

2.26.2

#6 lore raw

Re: [PATCH 1/1] efi/libstub: Fix mixed mode boot issue after macro refactor

Quoted 31 lines · Ard Biesheuvel
Quoted 20 lines · Arvind Sankar
Quoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Arvind Sankar

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Fix this by conditioning the generic macro definitions on CONFIG_EFI_MIXED, and removing the wrapper definitions on x86 if CONFIG_EFI_MIXED is not enabled.

Quoted 7 lines
Quoted 4 lines

Thanks Arvind.

Currently, CONFIG_EFI_MIXED is never referenced outside of arch/x86, and I prefer to keep it that way.

All these macros go together though -- they should either all be defined or none, so it makes sense to put them under a single #if.

True.

Quoted 9 lines
Quoted 4 lines

If you think
it's possible that a future architecture might need the wrappers but not be mixed, we could maybe add an ARCH_NEEDS_EFISTUB_WRAPPERS?

Well, remember that x86 used wrappers for native invocations only two releases ago, but that was mainly because of the SysV vs MS ABI issue, so the issue could emerge again, but it is unlikely.

Yep.

Would the below be more palatable?

arch/x86/include/asm/efi.h +15 -4
index cd0c3fbf6156..6b9ab0d8b2a7 100644
@@ -225,13 +225,15 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
 
 /* arch specific definitions used by the stub code */
 
-extern const bool efi_is64;
+#ifdef CONFIG_EFI_MIXED
+
+#define ARCH_HAS_EFISTUB_WRAPPERS
 
 static inline bool efi_is_64bit(void)
 {
-	if (IS_ENABLED(CONFIG_EFI_MIXED))
-		return efi_is64;
-	return IS_ENABLED(CONFIG_X86_64);
+	extern const bool efi_is64;
+
+	return efi_is64;
 }
 
 static inline bool efi_is_native(void)
@@ -356,6 +358,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
 						   runtime),		\
 				    func, __VA_ARGS__))
 
+#else /* CONFIG_EFI_MIXED */
+
+static inline bool efi_is_64bit(void)
+{
+	return IS_ENABLED(CONFIG_X86_64);
+}
+
+#endif /* CONFIG_EFI_MIXED */
+
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
 
drivers/firmware/efi/libstub/efistub.h +4 -10
index 874233cf8820..4f10a09563f3 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef ARCH_HAS_EFISTUB_WRAPPERS
+
+#define efi_is_native()		(true)
 #define efi_bs_call(func, ...)	efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...)	efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()		(true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)	(inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)		do {			\
author maintainer
#7 lore raw

Re: [PATCH 1/1] efi/libstub: Fix mixed mode boot issue after macro refactor

Quoted 38 lines · Arvind Sankar
Quoted 36 lines · Ard Biesheuvel
Quoted 20 lines · Arvind Sankar
Quoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Arvind Sankar

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Fix this by conditioning the generic macro definitions on CONFIG_EFI_MIXED, and removing the wrapper definitions on x86 if CONFIG_EFI_MIXED is not enabled.

Quoted 7 lines
Quoted 4 lines

Thanks Arvind.

Currently, CONFIG_EFI_MIXED is never referenced outside of arch/x86, and I prefer to keep it that way.

All these macros go together though -- they should either all be defined or none, so it makes sense to put them under a single #if.

True.

Quoted 4 lines

If you think
it's possible that a future architecture might need the wrappers but not be mixed, we could maybe add an ARCH_NEEDS_EFISTUB_WRAPPERS?

Quoted 9 lines
Quoted 4 lines

Well, remember that x86 used wrappers for native invocations only two releases ago, but that was mainly because of the SysV vs MS ABI issue, so the issue could emerge again, but it is unlikely.

Yep.

Would the below be more palatable?

Yes that looks better. Could you please spin it as a proper patch?

Quoted 69 lines
arch/x86/include/asm/efi.h +15 -4
index cd0c3fbf6156..6b9ab0d8b2a7 100644
@@ -225,13 +225,15 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
 
 /* arch specific definitions used by the stub code */
 
-extern const bool efi_is64;
+#ifdef CONFIG_EFI_MIXED
+
+#define ARCH_HAS_EFISTUB_WRAPPERS
 
 static inline bool efi_is_64bit(void)
 {
-       if (IS_ENABLED(CONFIG_EFI_MIXED))
-               return efi_is64;
-       return IS_ENABLED(CONFIG_X86_64);
+       extern const bool efi_is64;
+
+       return efi_is64;
 }
 
 static inline bool efi_is_native(void)
@@ -356,6 +358,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
                                                   runtime),            \
                                    func, __VA_ARGS__))
 
+#else /* CONFIG_EFI_MIXED */
+
+static inline bool efi_is_64bit(void)
+{
+       return IS_ENABLED(CONFIG_X86_64);
+}
+
+#endif /* CONFIG_EFI_MIXED */
+
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
 
drivers/firmware/efi/libstub/efistub.h +4 -10
index 874233cf8820..4f10a09563f3 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef ARCH_HAS_EFISTUB_WRAPPERS
+
+#define efi_is_native()                (true)
 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()                (true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)     (inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)          do {                    \
#8 lore raw

PATCH v2 1/1 efi/libstub: Fix mixed mode boot issue after macro refactor

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

All of these macros should go together, so rather than testing each one to see if it is defined, condition the generic macro definitions on a new ARCH_HAS_EFISTUB_WRAPPERS, and remove the wrapper definitions on x86 as well if CONFIG_EFI_MIXED is not enabled.

Fixes 22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")
---
 arch/x86/include/asm/efi.h             | 19 +++++++++++++++----
 drivers/firmware/efi/libstub/efistub.h | 14 ++++----------
 2 files changed, 19 insertions(+), 14 deletions(-)
arch/x86/include/asm/efi.h +15 -4
index cd0c3fbf6156..6b9ab0d8b2a7 100644
@@ -225,13 +225,15 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
 
 /* arch specific definitions used by the stub code */
 
-extern const bool efi_is64;
+#ifdef CONFIG_EFI_MIXED
+
+#define ARCH_HAS_EFISTUB_WRAPPERS
 
 static inline bool efi_is_64bit(void)
 {
-	if (IS_ENABLED(CONFIG_EFI_MIXED))
-		return efi_is64;
-	return IS_ENABLED(CONFIG_X86_64);
+	extern const bool efi_is64;
+
+	return efi_is64;
 }
 
 static inline bool efi_is_native(void)
@@ -356,6 +358,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
 						   runtime),		\
 				    func, __VA_ARGS__))
 
+#else /* CONFIG_EFI_MIXED */
+
+static inline bool efi_is_64bit(void)
+{
+	return IS_ENABLED(CONFIG_X86_64);
+}
+
+#endif /* CONFIG_EFI_MIXED */
+
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
 
drivers/firmware/efi/libstub/efistub.h +4 -10
index 874233cf8820..4f10a09563f3 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef ARCH_HAS_EFISTUB_WRAPPERS
+
+#define efi_is_native()		(true)
 #define efi_bs_call(func, ...)	efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...)	efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()		(true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)	(inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)		do {			\
Signature · 1 line
2.26.2
author maintainer
#9 lore raw

Re: [PATCH v2] efi/libstub: Fix mixed mode boot issue after macro refactor

Quoted 10 lines · Arvind Sankar

Commit
22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

refactored the macros that are used to provide wrappers for mixed-mode calls on x86, allowing us to boot a 64-bit kernel on 32-bit firmware.

Unfortunately, this broke mixed mode boot due to the fact that efi_is_native() is not a macro on x86.

Quoted 8 lines

All of these macros should go together, so rather than testing each one to see if it is defined, condition the generic macro definitions on a new ARCH_HAS_EFISTUB_WRAPPERS, and remove the wrapper definitions on x86 as well if CONFIG_EFI_MIXED is not enabled.

Fixes 22090f84bc3f ("efi/libstub: unify EFI call wrappers for non-x86")

Thanks Arvind, I've queued this up now.

Quoted 77 lines
---
 arch/x86/include/asm/efi.h             | 19 +++++++++++++++----
 drivers/firmware/efi/libstub/efistub.h | 14 ++++----------
 2 files changed, 19 insertions(+), 14 deletions(-)
arch/x86/include/asm/efi.h +15 -4
index cd0c3fbf6156..6b9ab0d8b2a7 100644
@@ -225,13 +225,15 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
 
 /* arch specific definitions used by the stub code */
 
-extern const bool efi_is64;
+#ifdef CONFIG_EFI_MIXED
+
+#define ARCH_HAS_EFISTUB_WRAPPERS
 
 static inline bool efi_is_64bit(void)
 {
-       if (IS_ENABLED(CONFIG_EFI_MIXED))
-               return efi_is64;
-       return IS_ENABLED(CONFIG_X86_64);
+       extern const bool efi_is64;
+
+       return efi_is64;
 }
 
 static inline bool efi_is_native(void)
@@ -356,6 +358,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
                                                   runtime),            \
                                    func, __VA_ARGS__))
 
+#else /* CONFIG_EFI_MIXED */
+
+static inline bool efi_is_64bit(void)
+{
+       return IS_ENABLED(CONFIG_X86_64);
+}
+
+#endif /* CONFIG_EFI_MIXED */
+
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
 
drivers/firmware/efi/libstub/efistub.h +4 -11
index 874233cf8820..4f10a09563f3 100644
@@ -33,20 +33,14 @@ extern bool efi_novamap;
 
 extern const efi_system_table_t *efi_system_table;
 
-#ifndef efi_bs_call
+#ifndef ARCH_HAS_EFISTUB_WRAPPERS
+
+#define efi_is_native()                (true)
 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
-#endif
-#ifndef efi_rt_call
 #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
-#endif
-#ifndef efi_is_native
-#define efi_is_native()                (true)
-#endif
-#ifndef efi_table_attr
 #define efi_table_attr(inst, attr)     (inst->attr)
-#endif
-#ifndef efi_call_proto
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
+
 #endif
 
 #define efi_info(msg)          do {                    \
--

2.26.2

#10 lore raw

Re: [PATCH 0/1] efi/libstub: Fix mixed mode boot on efi/next

In reply to Arvind Sankar
Quoted 4 lines · Arvind Sankar

How about this instead -- just get rid of the macros on x86 as well if mixed mode isn't enabled, and condition the generic definition on CONFIG_EFI_MIXED?

Not my call to make, but I prefer simple solutions. So for me the other patch is a clear winner.

Guenter

Quoted 7 lines

Arvind Sankar (1):
efi/libstub: Fix mixed mode boot issue after macro refactor

 arch/x86/include/asm/efi.h             | 17 +++++++++++++----
 drivers/firmware/efi/libstub/efistub.h | 14 ++++----------
 2 files changed, 17 insertions(+), 14 deletions(-)