|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 08/11] x86/boot: Group trampoline code and data using subsections
The trampoline mixes code, data used only by the trampoline itself and
data also used from outside it (head.S, or C code via bootsym()).
Use subsections of .init.trampoline to lay it out as:
- permanent code;
- permanent data used only by the trampoline;
- data also used from outside the trampoline, the permanent part
followed, from trampoline_perm_end, by the boot-only part;
- boot-only code;
- boot-only data used only by the trampoline.
Data is kept next to the code using it in the sources, and placed in
its group with .pushsection/.popsection. All the data used from
outside is now contiguous.
Move kbd_shift_flags into the padding byte of early_boot_opts, and
mark the byte as reserved in the C view of the structure.
Signed-off-by: Frediano Ziglio <freddy77@xxxxxxxxx>
Co-Authored-By: Claude Opus 5.5 <noreply@xxxxxxxxxxxxx>
---
xen/arch/x86/boot/cmdline.c | 2 +-
xen/arch/x86/boot/edd.S | 2 ++
xen/arch/x86/boot/head.S | 1 +
xen/arch/x86/boot/mem.S | 2 ++
xen/arch/x86/boot/trampoline.S | 44 +++++++++++++++++++++++++++++-----
xen/arch/x86/boot/video.S | 8 +++++++
xen/arch/x86/boot/wakeup.S | 5 ++++
7 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c
index cf9e32b6d9..310acee544 100644
--- a/xen/arch/x86/boot/cmdline.c
+++ b/xen/arch/x86/boot/cmdline.c
@@ -30,7 +30,7 @@ typedef struct __packed {
uint8_t skip_realmode;
uint8_t opt_edd;
uint8_t opt_edid;
- uint8_t padding;
+ uint8_t reserved; /* Used by the trampoline. */
#ifdef CONFIG_VIDEO
uint16_t boot_vid_mode;
uint16_t vesa_width;
diff --git a/xen/arch/x86/boot/edd.S b/xen/arch/x86/boot/edd.S
index 02437511b2..58af7744e4 100644
--- a/xen/arch/x86/boot/edd.S
+++ b/xen/arch/x86/boot/edd.S
@@ -163,6 +163,7 @@ edd_next:
.Ledd_done:
ret
+ .pushsection .init.trampoline, TRAMP_BOOT_EXT_DATA
GLOBAL(boot_edd_info_nr)
.byte 0
GLOBAL(boot_mbr_signature_nr)
@@ -171,3 +172,4 @@ GLOBAL(boot_mbr_signature)
.fill EDD_MBR_SIG_MAX*8,1,0
GLOBAL(boot_edd_info)
.fill EDD_INFO_MAX * (EDDEXTSIZE + EDDPARMSIZE), 1, 0
+ .popsection
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 88c9639f32..0e055ff070 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -725,6 +725,7 @@ trampoline_setup:
.section .init.trampoline, "a", @progbits
ENTRY(trampoline_start)
#include "trampoline.S"
+ .subsection TRAMP_LAST
ENTRY(trampoline_end)
#include "x86_64.S"
diff --git a/xen/arch/x86/boot/mem.S b/xen/arch/x86/boot/mem.S
index 94ffc87d50..96b03a00c8 100644
--- a/xen/arch/x86/boot/mem.S
+++ b/xen/arch/x86/boot/mem.S
@@ -31,8 +31,10 @@ get_memory_map:
.Ldone:
ret
+ .pushsection .init.trampoline, TRAMP_BOOT_EXT_DATA
.align 4
GLOBAL(bios_e820map)
.fill E820_BIOS_MAX*20,1,0
GLOBAL(bios_e820nr)
.long 0
+ .popsection
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index c9c5d6c27e..2898e5da77 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -27,6 +27,27 @@
.word bootsym(111b) - (off); \
.popsection
+/*
+ * The trampoline is assembled in subsections of .init.trampoline, laid out in
+ * this order:
+ * - permanent code;
+ * - permanent data used only by the trampoline;
+ * - data also used from outside the trampoline (head.S, or C code via
+ * bootsym()): first the permanent part, then, starting at
+ * trampoline_perm_end, the boot-only one;
+ * - boot-only code;
+ * - boot-only data used only by the trampoline.
+ * Code is in the current subsection; data is put in its group with
+ * .pushsection/.popsection.
+ */
+#define TRAMP_PERM_CODE 0
+#define TRAMP_PERM_DATA 1
+#define TRAMP_PERM_EXT_DATA 2
+#define TRAMP_BOOT_EXT_DATA 3
+#define TRAMP_BOOT_CODE 4
+#define TRAMP_BOOT_DATA 5
+#define TRAMP_LAST TRAMP_BOOT_DATA
+
/* Start of the permanent trampoline code. */
.code16
@@ -139,6 +160,7 @@ start64:
#include "video.h"
#include "wakeup.S"
+ .pushsection .init.trampoline, TRAMP_PERM_DATA
.balign 8
high_start_address:
.quad abs___high_start + XEN_VIRT_START
@@ -167,7 +189,10 @@ gdt_48:
.word bootsym(trampoline_gdt) + BOOT_DS_TRAMP + 2
.word bootsym(trampoline_gdt) + BOOT_CS32_TRAMP + 2
.popsection
+ .popsection
+ .pushsection .init.trampoline, TRAMP_PERM_EXT_DATA
+ .balign 8
GLOBAL(trampoline_misc_enable_off)
.quad 0
@@ -181,11 +206,16 @@ GLOBAL(trampoline_xen_phys_start)
GLOBAL(trampoline_cpu_started)
.byte 0
-
-LABEL(trampoline_perm_end, 0)
+ .popsection
/* From here on early boot only. */
+ /* Must be the first thing in TRAMP_BOOT_EXT_DATA. */
+ .pushsection .init.trampoline, TRAMP_BOOT_EXT_DATA
+LABEL(trampoline_perm_end, 0)
+ .popsection
+
+ .subsection TRAMP_BOOT_CODE
.code32
trampoline_boot_cpu_entry:
call 1f
@@ -292,6 +322,7 @@ trampoline_boot_cpu_entry:
/* Jump to the common bootstrap entry point. */
jmp trampoline_protmode_entry
+ .pushsection .init.trampoline, TRAMP_BOOT_EXT_DATA
.align 2
/* Keep in sync with cmdline.c:early_boot_opts_t type! */
early_boot_opts:
@@ -301,7 +332,8 @@ opt_edd:
.byte 0 /* edd=on/off/skipmbr */
opt_edid:
.byte 0 /* EDID parsing option
(force/no/default). */
-/* Padding. */
+
+GLOBAL(kbd_shift_flags)
.byte 0
#ifdef CONFIG_VIDEO
@@ -310,11 +342,11 @@ boot_vid_mode:
vesa_size:
.word 0,0,0 /* width x depth x height */
#endif
+ .popsection
-GLOBAL(kbd_shift_flags)
- .byte 0
-
+ .pushsection .init.trampoline, TRAMP_BOOT_DATA
rm_idt: .word 256*4-1, 0, 0
+ .popsection
#include "mem.S"
#include "edd.S"
diff --git a/xen/arch/x86/boot/video.S b/xen/arch/x86/boot/video.S
index f78906878a..57c8e790e8 100644
--- a/xen/arch/x86/boot/video.S
+++ b/xen/arch/x86/boot/video.S
@@ -495,6 +495,7 @@ setvesabysize:
movw %bx,bootsym(boot_vid_mode)
jmp check_vesa
+ .pushsection .init.trampoline, TRAMP_BOOT_DATA
# Table of routines for setting of the special modes.
spec_inits:
.word bootsym(set_80x25)
@@ -505,6 +506,7 @@ spec_inits:
.word bootsym(set_80x30)
.word bootsym(set_80x34)
.word bootsym(set_80x60)
+ .popsection
# Set the 80x25 mode. If already set, do nothing.
set_80x25:
@@ -649,6 +651,7 @@ mode_table:
mtab1: movw $modelist, %si # SI=mode list, DI=list end
ret0: ret
+ .pushsection .init.trampoline, TRAMP_BOOT_DATA
# Modes usable on all standard VGAs
vga_modes:
.word VIDEO_80x25, 0x50,0x19,0 # 80x25
@@ -659,6 +662,7 @@ vga_modes:
.word VIDEO_80x34, 0x50,0x22,0 # 80x34
.word VIDEO_80x60, 0x50,0x3c,0 # 80x60
vga_modes_end:
+ .popsection
# If the current mode is a VESA graphics one, obtain its parameters.
set_current:
@@ -946,6 +950,7 @@ store_edid:
#endif
ret
+ .pushsection .init.trampoline, TRAMP_BOOT_DATA
.p2align 1
mt_end: .word 0 # End of video mode table if built
edit_buf: .space 6 # Line editor buffer
@@ -992,7 +997,9 @@ name_bann: .asciz "Video adapter: "
.p2align 1
force_size: .word 0 # Use this size instead of the one in BIOS vars
+ .popsection
+ .pushsection .init.trampoline, TRAMP_BOOT_EXT_DATA
GLOBAL(boot_vid_info)
.byte 0, 0 /* orig_x, orig_y */
.byte 3 /* text mode 3 */
@@ -1004,3 +1011,4 @@ GLOBAL(boot_edid_info)
.fill 128,1,0x13
GLOBAL(boot_edid_caps)
.word 0x1313
+ .popsection
diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
index ecbf2852d8..f602541972 100644
--- a/xen/arch/x86/boot/wakeup.S
+++ b/xen/arch/x86/boot/wakeup.S
@@ -129,10 +129,15 @@ FUNC_LOCAL(bogus_saved_magic, 0)
jmp bogus_saved_magic
END(bogus_saved_magic)
+ .pushsection .init.trampoline, TRAMP_PERM_DATA
.align 8
s3_start_address:
.quad abs_s3_resume + XEN_VIRT_START
real_magic: .long 0x12345678
video_mode: .word 0
+ .popsection
+
+ .pushsection .init.trampoline, TRAMP_PERM_EXT_DATA
GLOBAL(video_flags)
.byte 0
+ .popsection
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |