From: fangyu.yu@linux.alibaba.com
To: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, songshuaishuai@tinylab.org, bjorn@rivosinc.com,
ardb@kernel.org, arnd@arndb.de, bhelgaas@google.com,
richard.lyu@suse.com, tzimmermann@suse.de, nathan@kernel.org
Cc: guoren@kernel.org, kvm-riscv@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Fangyu Yu <fangyu.yu@linux.alibaba.com>
Subject: [PATCH 1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S
Date: Tue, 24 Mar 2026 19:45:24 +0800 [thread overview]
Message-ID: <20260324114527.91494-2-fangyu.yu@linux.alibaba.com> (raw)
In-Reply-To: <20260324114527.91494-1-fangyu.yu@linux.alibaba.com>
From: Fangyu Yu <fangyu.yu@linux.alibaba.com>
When CONFIG_KEXEC_CORE is enabled, add a dedicated .kexec.tramp.text
area to the RISC-V kernel linker script.
This introduces a KEXEC_TRAMP_TEXT linker snippet in image-vars.h and
uses it from vmlinux.lds.S to:
- align to PAGE_SIZE
- define __kexec_tramp_text_start/__kexec_tramp_text_end
- KEEP all .kexec.tramp.text* input sections
- ASSERT the trampoline text fits within one page
When kexec is disabled, KEXEC_TRAMP_TEXT expands to nothing.
Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
---
arch/riscv/kernel/image-vars.h | 13 +++++++++++++
arch/riscv/kernel/vmlinux.lds.S | 1 +
2 files changed, 14 insertions(+)
diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h
index 3bd9d06a8b8f..5419609ff89c 100644
--- a/arch/riscv/kernel/image-vars.h
+++ b/arch/riscv/kernel/image-vars.h
@@ -34,4 +34,17 @@ __efistub_sysfb_primary_display = sysfb_primary_display;
#endif
+#ifdef CONFIG_KEXEC_CORE
+#define KEXEC_TRAMP_TEXT \
+ . = ALIGN(PAGE_SIZE); \
+ __kexec_tramp_text_start = .; \
+ KEEP(*(.kexec.tramp.text)) \
+ KEEP(*(.kexec.tramp.text.*)) \
+ __kexec_tramp_text_end = .; \
+ ASSERT((__kexec_tramp_text_end - __kexec_tramp_text_start) <= PAGE_SIZE, \
+ ".kexec.tramp.text exceeds 4K");
+#else
+#define KEXEC_TRAMP_TEXT /* nothing */
+#endif
+
#endif /* __RISCV_KERNEL_IMAGE_VARS_H */
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 997f9eb3b22b..c55316912c1d 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -45,6 +45,7 @@ SECTIONS
ENTRY_TEXT
IRQENTRY_TEXT
SOFTIRQENTRY_TEXT
+ KEXEC_TRAMP_TEXT
_etext = .;
}
--
2.50.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-03-24 11:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 11:45 [PATCH 0/4] Add crashdump support in guest kernel fangyu.yu
2026-03-24 11:45 ` fangyu.yu [this message]
2026-03-24 11:45 ` [PATCH 2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text fangyu.yu
2026-03-24 11:45 ` [PATCH 3/4] riscv: kexec: Build trampoline page tables for crash kernel entry fangyu.yu
2026-03-24 11:45 ` [PATCH 4/4] riscv: kexec: Switch to trampoline page table before norelocate fangyu.yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260324114527.91494-2-fangyu.yu@linux.alibaba.com \
--to=fangyu.yu@linux.alibaba.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=bjorn@rivosinc.com \
--cc=guoren@kernel.org \
--cc=kvm-riscv@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=nathan@kernel.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=richard.lyu@suse.com \
--cc=songshuaishuai@tinylab.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox