From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED890606A322 for ; Fri, 4 Dec 2026 20:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xCPa5HmH Received: from list by lists.xenproject.org with outflank-mailman.1514953.1705690 (Exim 4.92) (envelope-from ) id 1xZaFC-00059u-Fw; Fri, 04 Dec 2026 20:51:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1514953.1705690; Fri, 04 Dec 2026 20:51:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xZaFC-00058R-5P; Fri, 04 Dec 2026 20:51:02 +0000 Received: by outflank-mailman (input) for mailman id 1514953; Fri, 04 Dec 2026 20:51:01 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xZaFA-0004j0-V5 for xen-devel@lists.xenproject.org; Fri, 04 Dec 2026 20:51:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xZaFA-001bMw-Bq for xen-devel@lists.xenproject.org; Fri, 04 Dec 2026 21:51:00 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6b132796-8faa-0a2a0a5109dd-0a2a4501ca56-16 for ; Fri, 04 Dec 2026 21:51:00 +0100 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6b1327b4-5bcc-0a2a45010019-d155dd33e1ac-3 for ; Fri, 04 Dec 2026 21:51:00 +0100 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-48dee593f18so1394051f8f.3 for ; Fri, 04 Dec 2026 12:51:00 -0800 (PST) Received: from localhost.localdomain (89.246.200.146.dyn.plus.net. [146.200.246.89]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17426821asm6895228f8f.45.2026.12.04.12.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:50:59 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Post: List-Help: List-Subscribe: , Precedence: list Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796417460; x=1797022260; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to:content-type; bh=98s1Q5aNBXi3ukX7VkEccBtfON0GV/KDnU1Va6A4Gz8=; b=xCPa5HmH8tpMjvXBx0YmbmLc5aTQGMqmOPsxQ1QImNTDEKS5sBl2R3d9S2ucsDRSUf VtoklFsKvs58JtIhu4h2DKGa5qZQSTE1eRjQwidQldpqEQwuYpiATYsrL6aNMSu0ibar J4abYG5KeMMud1YUDUGZi9hkKok+/x4mho/bNLjGV2oNtWCVQPbu75i1+lMV/psDycAb KEAZ3gCVZbmI6x0iMWydp0YtBY/l++bu13yZoUhNfuGo0ZwoJ11nGCrumBXlhTs+V8JX b6Q6yTgesPA8PmkJxcqqnk3njNrC/+E8S58B5r2u041bMT4zN9lKnQ6oN+VoUeewYv/E r9NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796417460; x=1797022260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=98s1Q5aNBXi3ukX7VkEccBtfON0GV/KDnU1Va6A4Gz8=; b=hlZEI+CifSGmWDEnAnHSZe1gp1V2gD+9KUNiROjdX4djUBDVAN4Hp1WRukMVhxar3A EuVtQ0dkaotMQOI2phsCe6ZMQy4m0hFLgTIEGwtaKtRZdYhFfm0iwRheG2aU5EcdnNqc 7lrpUfRgYtNuDull7uZvrfo9yig6tNGJatoWY8f4qyU/eA9y3aVFSOVBI46Wm81Oe7zm UwBP3T5+3aTQd0LszUJTgWZZP5CQ0PtnaXe19N/LnrUm3AVkHVjJyojnVTud6T4G2WFX mrrd3fKR2bAesLapd0R9z/nyqqC13Y8ERrX5BwA9ziNFHDcYXTlFKMEI3qV6jEQ9VKCv Dtrg== X-Gm-Message-State: AB4q+uGvVKmS2sr2RU4nBXmcFk0AKcjN6ZmEjNd68CZ4AaTMa/MtHtcc Z+v3fYJBJY/+dofzVpwXvHja/6QNpz0F/A00/YNerY/mUeQqutx7N01mp3+h/30M X-Gm-Gg: AZFdTZdJE+GHlYUCrnx3FLJ/zzZKB0vhm9bB7w28YJKbYSNsSrjyJB0SPyoP7myy7hl vDk/fiD4Ch10SRBDkA2Rd7dQVWKgESaheaq9ByjfvWMXgzJvIOeSe5dzl+DFevB4y3QSVDMbr1I FprlJp2TDNTvjRGmfOFDSJ8P9vwaNTLO3ulhV5vuyqQpaICCeX83T7RGAeY0wPf37TyOCtDnpO1 VlGD7H+GjqRzFcmvs6CBmqsXyOAa3CM7CgNC8rdvwk9wi4DiuT/ZPa3aw/2/2yd2rSBChSTHUR/ Oh4Lvq4dUdzo3QhylxVJKIynilchuk1byyvwSoJ7Ia+p0K55ztv7FqjViybiqkxjNDyOo8xNhMt aq+PARCALyDsQbelrmR4YmwAN15xIHxcCPcx2uUctcV145nfbJxr7Ty1rv2hyhAOpcA4ctVOkHp //gGAR2MsqL0pUxm38DDPxN2qj4Xvd3UR/mIvivX02XwwiQGEky0iICqviKz7azkYPkEmM6Gz0i bVS2GTpbXI1mj7QELjpZWES6ra+eDh84ao70ZU4aFvFwf0bEB8U76ZXhXM7bjjlNc777Vf/sfYh AT7xXFSsxL5npV4VStm5d+x/f5L3UCltA/9XdfbW3DrNUDmVzqwMAYAcori+JccBQvQQPY8NUgw 4JrOiUf2Pn16v/+cwqcL8toA= X-Received: by 2002:adf:e001:0:20b0:48d:fd4d:7fbf with SMTP id ffacd0b85a97d-4d1e291e15emr4644522f8f.4.1796417459669; Fri, 04 Dec 2026 12:50:59 -0800 (PST) Sender: Frediano Ziglio From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie , "Claude Opus 5 . 5" Subject: [PATCH 08/11] x86/boot: Group trampoline code and data using subsections Date: Fri, 4 Dec 2026 20:50:41 +0000 Message-ID: <20261204205045.596093-9-freddy77@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261204205045.596093-1-freddy77@gmail.com> References: <20261204205045.596093-1-freddy77@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-d62444/1796417460-BEED25FD-774CDE3C/0/0 X-purgate-type: clean X-purgate-size: 9004 X-Spam-Status: No, score=-15.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 Co-Authored-By: Claude Opus 5.5 --- 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