Skip to contentSkip to conversation

x86/boot: Introduce boot-helpers.h

PATCH In review Andrew Cooper 3 participants 4 messages Nov 18, 2024 – Nov 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: Introduce boot-helpers.h

Eclair complains that neither reloc_trampoline{32,64}() can see their declarations.

reloc_trampoline32() needs to become asmlinkage, while reloc_trampoline64() needs declaring properly in a way that both efi-boot.h and reloc-trampoline.c can see.

Introduce boot-helpers.h for the purpose.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Frediano Ziglio <[email protected]>
CC: Stefano Stabellini <[email protected]>

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1549438881

---
 xen/arch/x86/boot/reloc-trampoline.c    |  4 +++-
 xen/arch/x86/efi/efi-boot.h             |  4 ++--
 xen/arch/x86/include/asm/boot-helpers.h | 13 +++++++++++++
 3 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 xen/arch/x86/include/asm/boot-helpers.h
xen/arch/x86/boot/reloc-trampoline.c +3 -1
index d5548eb08f85..e35e7c78aa86 100644
@@ -2,13 +2,15 @@
 
 #include <xen/compiler.h>
 #include <xen/stdint.h>
+
+#include <asm/boot-helpers.h>
 #include <asm/trampoline.h>
 
 extern const int32_t __trampoline_rel_start[], __trampoline_rel_stop[];
 extern const int32_t __trampoline_seg_start[], __trampoline_seg_stop[];
 
 #if defined(__i386__)
-void reloc_trampoline32(void)
+void asmlinkage reloc_trampoline32(void)
 #elif defined (__x86_64__)
 void reloc_trampoline64(void)
 #else
xen/arch/x86/efi/efi-boot.h +2 -2
index 9d3f2b71447e..1d8902a9a724 100644
@@ -4,6 +4,8 @@
  * therefore can define arch specific global variables.
  */
 #include <xen/vga.h>
+
+#include <asm/boot-helpers.h>
 #include <asm/e820.h>
 #include <asm/edd.h>
 #include <asm/microcode.h>
@@ -103,8 +105,6 @@ static void __init efi_arch_relocate_image(unsigned long delta)
     }
 }
 
-void reloc_trampoline64(void);
-
 static void __init relocate_trampoline(unsigned long phys)
 {
     trampoline_phys = phys;
xen/arch/x86/include/asm/boot-helpers.h new file +13 -0
new file mode 100644
index 000000000000..166f49b4da01
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Declarations for helper functions compiled for both 32bit and 64bit.
+ *
+ * The 32bit forms are called only from assembly, so no declaration is provide
+ * here.
+ */
+#ifndef X86_BOOT_HELPERS_H
+#define X86_BOOT_HELPERS_H
+
+void reloc_trampoline64(void);
+
+#endif /* X86_BOOT_HELPERS_H */
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andrew Cooper

Eclair complains that neither reloc_trampoline{32,64}() can see their declarations.

reloc_trampoline32() needs to become asmlinkage, while reloc_trampoline64() needs declaring properly in a way that both efi-boot.h and reloc-trampoline.c can see.

Introduce boot-helpers.h for the purpose.

xen/arch/x86/include/asm/boot-helpers.h line 7

Quoted 10 lines
xen/arch/x86/include/asm/boot-helpers.h new file +7 -0
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Declarations for helper functions compiled for both 32bit and 64bit.
+ *
+ * The 32bit forms are called only from assembly, so no declaration is provide
+ * here.
+ */

How certain are you/we that what is said in the 2nd paragraph will remain as a pattern?

Also, nit: s/provide/provided/?

Jan

#2 lore raw
Quoted 4 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

Eclair complains that neither reloc_trampoline{32,64}() can see their declarations.

Quoted 8 lines
Quoted 7 lines

reloc_trampoline32() needs to become asmlinkage, while reloc_trampoline64() needs declaring properly in a way that both efi-boot.h and reloc-trampoline.c can see.

Introduce boot-helpers.h for the purpose.

Thanks.

Quoted 4 lines
Quoted 4 lines
xen/arch/x86/include/asm/boot-helpers.h new file +1 -0
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
Quoted 8 lines

xen/arch/x86/include/asm/boot-helpers.h line 7

Quoted 6 lines
xen/arch/x86/include/asm/boot-helpers.h new file +6 -0
+/*
+ * Declarations for helper functions compiled for both 32bit and 64bit.
+ *
+ * The 32bit forms are called only from assembly, so no declaration is provide
+ * here.
+ */

How certain are you/we that what is said in the 2nd paragraph will remain as a pattern?

Unsure, but there needs to be an explanation of why reloc_trampoline32() isn't here.

It's not clear how we'd even safely get 32bit declarations here.  They would really want to be nocall, so the rest of Xen can't use them accidentally.

The comment is easy enough to change if the circumstances change.

Quoted 1 line

Also, nit: s/provide/provided/?

Oops yes, will fix.

~Andrew

#3 lore raw
In reply to Andrew Cooper
Quoted 74 lines · Andrew Cooper

Eclair complains that neither reloc_trampoline{32,64}() can see their declarations.

reloc_trampoline32() needs to become asmlinkage, while reloc_trampoline64() needs declaring properly in a way that both efi-boot.h and reloc-trampoline.c can see.

Introduce boot-helpers.h for the purpose.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Frediano Ziglio <[email protected]>
CC: Stefano Stabellini <[email protected]>

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1549438881

---
 xen/arch/x86/boot/reloc-trampoline.c    |  4 +++-
 xen/arch/x86/efi/efi-boot.h             |  4 ++--
 xen/arch/x86/include/asm/boot-helpers.h | 13 +++++++++++++
 3 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 xen/arch/x86/include/asm/boot-helpers.h
xen/arch/x86/boot/reloc-trampoline.c +3 -1
index d5548eb08f85..e35e7c78aa86 100644
@@ -2,13 +2,15 @@
 
 #include <xen/compiler.h>
 #include <xen/stdint.h>
+
+#include <asm/boot-helpers.h>
 #include <asm/trampoline.h>
 
 extern const int32_t __trampoline_rel_start[], __trampoline_rel_stop[];
 extern const int32_t __trampoline_seg_start[], __trampoline_seg_stop[];
 
 #if defined(__i386__)
-void reloc_trampoline32(void)
+void asmlinkage reloc_trampoline32(void)
 #elif defined (__x86_64__)
 void reloc_trampoline64(void)
 #else
xen/arch/x86/efi/efi-boot.h +2 -2
index 9d3f2b71447e..1d8902a9a724 100644
@@ -4,6 +4,8 @@
  * therefore can define arch specific global variables.
  */
 #include <xen/vga.h>
+
+#include <asm/boot-helpers.h>
 #include <asm/e820.h>
 #include <asm/edd.h>
 #include <asm/microcode.h>
@@ -103,8 +105,6 @@ static void __init efi_arch_relocate_image(unsigned long delta)
     }
 }
 
-void reloc_trampoline64(void);
-
 static void __init relocate_trampoline(unsigned long phys)
 {
     trampoline_phys = phys;
xen/arch/x86/include/asm/boot-helpers.h new file +0 -0
new file mode 100644
index 000000000000..166f49b4da01

xen/arch/x86/include/asm/boot-helpers.h line 9

Quoted 9 lines
xen/arch/x86/include/asm/boot-helpers.h new file +9 -0
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Declarations for helper functions compiled for both 32bit and 64bit.
+ *
+ * The 32bit forms are called only from assembly, so no declaration is provide
+ * here.
+ */
+#ifndef X86_BOOT_HELPERS_H
+#define X86_BOOT_HELPERS_H

Why not follow the coding style ? IMHO if we don't agree on coding style we should update it, otherwise we should follow coding style.

Maybe considering this
https://lists.xenproject.org/archives/html/xen-devel/2024-11/msg00658.html
move the file into the boot include directory instead?

xen/arch/x86/include/asm/boot-helpers.h line 13

Quoted 4 lines
xen/arch/x86/include/asm/boot-helpers.h new file +4 -0
+
+void reloc_trampoline64(void);
+
+#endif /* X86_BOOT_HELPERS_H */

Frediano