Skip to content

[PW_SID:1071604] Add crashdump support in guest kernel#1665

Closed
linux-riscv-bot wants to merge 4 commits into
workflow__riscv__fixesfrom
pw1071604
Closed

[PW_SID:1071604] Add crashdump support in guest kernel#1665
linux-riscv-bot wants to merge 4 commits into
workflow__riscv__fixesfrom
pw1071604

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1071604 applied to workflow__riscv__fixes

Name: Add crashdump support in guest kernel
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1071604
Version: 1

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>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move riscv_kexec_norelocate out of the generic .text section and into
a dedicated executable trampoline section, .kexec.tramp.text.

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Crash kexec uses riscv_kexec_norelocate as a trampoline to jump into
the crashkernel. Add a small helper to build dedicated 4KB page tables
that map the trampoline page as executable.

Two mappings are installed:
  - VA(__kexec_tramp_text_start) -> PA(__kexec_tramp_text_start)
  - PA(__kexec_tramp_text_start) -> PA(__kexec_tramp_text_start)

This allows the trampoline to run regardless of whether it is entered
via its linked virtual address or its physical address.

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Make riscv_kexec_norelocate a two-pass trampoline so it can
drop the kernel page tables while still executing from a
mapped address.

On the first entry, t3 is initialized to 0 by machine_kexec().
Loads the physical address of riscv_kexec_norelocate and the
trampoline SATP value, switches to the trampoline page table,
and jumps to the trampoline VA(=PA).

On the second entry, t3 contains the physical address of
riscv_kexec_norelocate, so the PC comparison matches and
execution continues under trampoline VA(=PA).

Since the trampoline page table is already active, replace the
previous stvec-based handoff with a direct jump to the target
entry (jr a2).

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 137.03 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1068.48 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1423.58 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 28.75 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.96 seconds
Result: WARNING
Output:

WARNING: Non-declarative macros with multiple statements should be enclosed in a do - while loop
#34: FILE: arch/riscv/kernel/image-vars.h:38:
+#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");

BUT SEE:

   do {} while (0) advice is over-stated in a few situations:

   The more obvious case is macros, like MODULE_PARM_DESC, invoked at
   file-scope, where C disallows code (it must be in functions).  See
   $exceptions if you have one to add by name.

   More troublesome is declarative macros used at top of new scope,
   like DECLARE_PER_CPU.  These might just compile with a do-while-0
   wrapper, but would be incorrect.  Most of these are handled by
   detecting struct,union,etc declaration primitives in $exceptions.

   Theres also macros called inside an if (block), which "return" an
   expression.  These cannot do-while, and need a ({}) wrapper.

   Enjoy this qualification while we work to improve our heuristics.

WARNING: macros should not use a trailing semicolon
#34: FILE: arch/riscv/kernel/image-vars.h:38:
+#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");

CHECK: spaces preferred around that '*' (ctx:VxB)
#38: FILE: arch/riscv/kernel/image-vars.h:42:
+		KEEP(*(.kexec.tramp.text.*))				\
 		                         ^

total: 0 errors, 2 warnings, 1 checks, 24 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 6f4b48a4574b ("riscv: Add kexec trampoline text section to vmlinux.lds.S") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 2 warnings, 1 checks, 24 lines checked
CHECK: spaces preferred around that '*' (ctx:VxB)
WARNING: Non-declarative macros with multiple statements should be enclosed in a do - while loop
WARNING: macros should not use a trailing semicolon


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.93 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
kdoc
Desc: Detects for kdoc errors
Duration: 0.80 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/4] riscv: Add kexec trampoline text section to vmlinux.lds.S"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 138.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1150.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1661.98 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.77 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 28.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.94 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.75 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
kdoc
Desc: Detects for kdoc errors
Duration: 0.87 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/4] riscv: kexec: Place norelocate trampoline into .kexec.tramp.text"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 141.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1114.43 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1627.03 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.41 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 29.81 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.86 seconds
Result: WARNING
Output:

CHECK: Alignment should match open parenthesis
#55: FILE: arch/riscv/kernel/machine_kexec.c:44:
+		set_pgd(pgd, pfn_pgd(PFN_DOWN(__pa_symbol(kexec_tramp_p4d)),
+			PAGE_TABLE));

CHECK: Alignment should match open parenthesis
#58: FILE: arch/riscv/kernel/machine_kexec.c:47:
+		set_pgd(pgd, pfn_pgd(PFN_DOWN(__pa_symbol(kexec_tramp_pud)),
+			PAGE_TABLE));

CHECK: Alignment should match open parenthesis
#65: FILE: arch/riscv/kernel/machine_kexec.c:54:
+			set_p4d(p4d, pfn_p4d(PFN_DOWN(__pa_symbol(kexec_tramp_pud)),
+				PAGE_TABLE));

CHECK: Alignment should match open parenthesis
#68: FILE: arch/riscv/kernel/machine_kexec.c:57:
+			set_p4d(p4d, pfn_p4d(PFN_DOWN(__pa_symbol(kexec_tramp_pmd)),
+				PAGE_TABLE));

CHECK: Alignment should match open parenthesis
#100: FILE: arch/riscv/kernel/machine_kexec.c:89:
+			set_p4d(p4d, pfn_p4d(PFN_DOWN(__pa_symbol(kexec_tramp_pud2)),
+				PAGE_TABLE));

CHECK: Alignment should match open parenthesis
#103: FILE: arch/riscv/kernel/machine_kexec.c:92:
+			set_p4d(p4d, pfn_p4d(PFN_DOWN(__pa_symbol(kexec_tramp_pmd2)),
+				PAGE_TABLE));

CHECK: Unbalanced braces around else statement
#132: FILE: arch/riscv/kernel/machine_kexec.c:259:
+	else {

total: 0 errors, 0 warnings, 7 checks, 116 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit f099aaf7849c ("riscv: kexec: Build trampoline page tables for crash kernel entry") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 7 checks, 116 lines checked
CHECK: Alignment should match open parenthesis
CHECK: Unbalanced braces around else statement


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 82.76 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
kdoc
Desc: Detects for kdoc errors
Duration: 1.00 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[3/4] riscv: kexec: Build trampoline page tables for crash kernel entry"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 138.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1112.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1619.65 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.14 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.96 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 82.82 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
kdoc
Desc: Detects for kdoc errors
Duration: 0.86 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[4/4] riscv: kexec: Switch to trampoline page table before norelocate"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1071604 branch April 1, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants