forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86/unwind/orc: Add ELF section with ORC version identifier
Commits ffb1b4a ("x86/unwind/orc: Add 'signal' field to ORC metadata") and fb79944 ("x86,objtool: Split UNWIND_HINT_EMPTY in two") changed the ORC format. Although ORC is internal to the kernel, it's the only way for external tools to get reliable kernel stack traces on x86-64. In particular, the drgn debugger [1] uses ORC for stack unwinding, and these format changes broke it [2]. As the drgn maintainer, I don't care how often or how much the kernel changes the ORC format as long as I have a way to detect the change. It suffices to store a version identifier in the vmlinux and kernel module ELF files (to use when parsing ORC sections from ELF), and in kernel memory (to use when parsing ORC from a core dump+symbol table). Rather than hard-coding a version number that needs to be manually bumped, Peterz suggested hashing the definitions from orc_types.h. If there is a format change that isn't caught by this, the hashing script can be updated. This patch adds an .orc_header allocated ELF section containing the 20-byte hash to vmlinux and kernel modules, along with the corresponding __start_orc_header and __stop_orc_header symbols in vmlinux. 1: https://github.com/osandov/drgn 2: osandov/drgn#303 Fixes: ffb1b4a ("x86/unwind/orc: Add 'signal' field to ORC metadata") Fixes: fb79944 ("x86,objtool: Split UNWIND_HINT_EMPTY in two") Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://lkml.kernel.org/r/aef9c8dc43915b886a8c48509a12ec1b006ca1ca.1686690801.git.osandov@osandov.com
- Loading branch information
Showing
7 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
/* Copyright (c) Meta Platforms, Inc. and affiliates. */ | ||
|
||
#ifndef _ORC_HEADER_H | ||
#define _ORC_HEADER_H | ||
|
||
#include <linux/types.h> | ||
#include <linux/compiler.h> | ||
#include <asm/orc_hash.h> | ||
|
||
/* | ||
* The header is currently a 20-byte hash of the ORC entry definition; see | ||
* scripts/orc_hash.sh. | ||
*/ | ||
#define ORC_HEADER \ | ||
__used __section(".orc_header") __aligned(4) \ | ||
static const u8 orc_header[] = { ORC_HASH } | ||
|
||
#endif /* _ORC_HEADER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
||
set -e | ||
|
||
printf '%s' '#define ORC_HASH ' | ||
|
||
awk ' | ||
/^#define ORC_(REG|TYPE)_/ { print } | ||
/^struct orc_entry {$/ { p=1 } | ||
p { print } | ||
/^}/ { p=0 }' | | ||
sha1sum | | ||
cut -d " " -f 1 | | ||
sed 's/\([0-9a-f]\{2\}\)/0x\1,/g' |