Skip to content

Commit 5fd8fea

Browse files
brenns10akpm00
authored andcommitted
vmcoreinfo: include kallsyms symbols
The internal kallsyms tables contain information which could be quite useful to a debugging tool in the absence of other debuginfo. If kallsyms is enabled, then a debugging tool could parse it and use it as a fallback symbol table. Combined with BTF data, live & post-mortem debuggers can support basic operations without needing a large DWARF debuginfo file available. As many as five symbols are necessary to properly parse kallsyms names and addresses. Add these to the vmcoreinfo note. CONFIG_KALLSYMS_ABSOLUTE_PERCPU does impact the computation of symbol addresses. However, a debugger can infer this configuration value by comparing the address of _stext in the vmcoreinfo with the address computed via kallsyms. So there's no need to include information about this config value in the vmcoreinfo note. To verify that we're still well below the maximum of 4096 bytes, I created a script[1] to compute a rough upper bound on the possible size of vmcoreinfo. On v5.18-rc7, the script reports 3106 bytes, and with this patch, the maximum become 3370 bytes. [1]: https://github.com/brenns10/kernel_stuff/blob/master/vmcoreinfosize/ Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Brennan <[email protected]> Acked-by: Baoquan He <[email protected]> Cc: Bixuan Cui <[email protected]> Cc: Dave Young <[email protected]> Cc: David Vernet <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kees Cook <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Sami Tolvanen <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Vivek Goyal <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 71f8c15 commit 5fd8fea

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

kernel/crash_core.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include <crypto/sha1.h>
1717

18+
#include "kallsyms_internal.h"
19+
1820
/* vmcoreinfo stuff */
1921
unsigned char *vmcoreinfo_data;
2022
size_t vmcoreinfo_size;
@@ -480,6 +482,18 @@ static int __init crash_save_vmcoreinfo_init(void)
480482
VMCOREINFO_NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE);
481483
#endif
482484

485+
#ifdef CONFIG_KALLSYMS
486+
VMCOREINFO_SYMBOL(kallsyms_names);
487+
VMCOREINFO_SYMBOL(kallsyms_token_table);
488+
VMCOREINFO_SYMBOL(kallsyms_token_index);
489+
#ifdef CONFIG_KALLSYMS_BASE_RELATIVE
490+
VMCOREINFO_SYMBOL(kallsyms_offsets);
491+
VMCOREINFO_SYMBOL(kallsyms_relative_base);
492+
#else
493+
VMCOREINFO_SYMBOL(kallsyms_addresses);
494+
#endif /* CONFIG_KALLSYMS_BASE_RELATIVE */
495+
#endif /* CONFIG_KALLSYMS */
496+
483497
arch_crash_save_vmcoreinfo();
484498
update_vmcoreinfo_note();
485499

0 commit comments

Comments
 (0)