Pull objtool fix from Borislav Petkov: - Add a ORC format hash to vmlinux and modules in order for other tools which use it, to detect changes to it and adapt accordingly * tag 'objtool_urgent_for_v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/unwind/orc: Add ELF section with ORC version identifier
Unified · Split
| @@ -305,6 +305,18 @@ ifeq ($(RETPOLINE_CFLAGS),) · 304 unmodified lines | ||
| 305 | 305 | endif |
| 306 | 306 | endif |
| 307 | 307 | |
| 308 | +ifdef CONFIG_UNWINDER_ORC | |
| 309 | +orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h | |
| 310 | +orc_hash_sh := $(srctree)/scripts/orc_hash.sh | |
| 311 | +targets += $(orc_hash_h) | |
| 312 | +quiet_cmd_orc_hash = GEN $@ | |
| 313 | + cmd_orc_hash = mkdir -p $(dir $@); \ | |
| 314 | + $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@ | |
| 315 | +$(orc_hash_h): $(srctree)/arch/x86/include/asm/orc_types.h $(orc_hash_sh) FORCE | |
| 316 | + $(call if_changed,orc_hash) | |
| 317 | +archprepare: $(orc_hash_h) | |
| 318 | +endif | |
| 319 | + | |
| 308 | 320 | archclean: |
| 309 | 321 | $(Q)rm -rf $(objtree)/arch/i386 |
| 310 | 322 | $(Q)rm -rf $(objtree)/arch/x86_64 |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +generated-y += orc_hash.h | |
| 4 | 5 | generated-y += syscalls_32.h |
| 5 | 6 | generated-y += syscalls_64.h |
| 6 | 7 | generated-y += syscalls_x32.h |
| @@ -0,0 +1,19 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | |
| 2 | +/* Copyright (c) Meta Platforms, Inc. and affiliates. */ | |
| 3 | + | |
| 4 | +#ifndef _ORC_HEADER_H | |
| 5 | +#define _ORC_HEADER_H | |
| 6 | + | |
| 7 | +#include <linux/types.h> | |
| 8 | +#include <linux/compiler.h> | |
| 9 | +#include <asm/orc_hash.h> | |
| 10 | + | |
| 11 | +/* | |
| 12 | + * The header is currently a 20-byte hash of the ORC entry definition; see | |
| 13 | + * scripts/orc_hash.sh. | |
| 14 | + */ | |
| 15 | +#define ORC_HEADER \ | |
| 16 | + __used __section(".orc_header") __aligned(4) \ | |
| 17 | + static const u8 orc_header[] = { ORC_HASH } | |
| 18 | + | |
| 19 | +#endif /* _ORC_HEADER_H */ | |
| @@ -7,6 +7,9 @@ · 6 unmodified lines | ||
| 7 | 7 | #include <asm/unwind.h> |
| 8 | 8 | #include <asm/orc_types.h> |
| 9 | 9 | #include <asm/orc_lookup.h> |
| 10 | +#include <asm/orc_header.h> | |
| 11 | + | |
| 12 | +ORC_HEADER; | |
| 10 | 13 | |
| 11 | 14 | #define orc_warn(fmt, ...) \ |
| 12 | 15 | printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__) |
| @@ -839,6 +839,9 @@ · 838 unmodified lines | ||
| 839 | 839 | |
| 840 | 840 | #ifdef CONFIG_UNWINDER_ORC |
| 841 | 841 | #define ORC_UNWIND_TABLE \ |
| 842 | + .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \ | |
| 843 | + BOUNDED_SECTION_BY(.orc_header, _orc_header) \ | |
| 844 | + } \ | |
| 842 | 845 | . = ALIGN(4); \ |
| 843 | 846 | .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \ |
| 844 | 847 | BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \ |
| @@ -1979,6 +1979,11 @@ static void add_header(struct buffer *b, struct module *mod) · 1978 unmodified lines | ||
| 1979 | 1979 | buf_printf(b, "#include <linux/vermagic.h>\n"); |
| 1980 | 1980 | buf_printf(b, "#include <linux/compiler.h>\n"); |
| 1981 | 1981 | buf_printf(b, "\n"); |
| 1982 | + buf_printf(b, "#ifdef CONFIG_UNWINDER_ORC\n"); | |
| 1983 | + buf_printf(b, "#include <asm/orc_header.h>\n"); | |
| 1984 | + buf_printf(b, "ORC_HEADER;\n"); | |
| 1985 | + buf_printf(b, "#endif\n"); | |
| 1986 | + buf_printf(b, "\n"); | |
| 1982 | 1987 | buf_printf(b, "BUILD_SALT;\n"); |
| 1983 | 1988 | buf_printf(b, "BUILD_LTO_INFO;\n"); |
| 1984 | 1989 | buf_printf(b, "\n"); |
| @@ -0,0 +1,16 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +# SPDX-License-Identifier: GPL-2.0-or-later | |
| 3 | +# Copyright (c) Meta Platforms, Inc. and affiliates. | |
| 4 | + | |
| 5 | +set -e | |
| 6 | + | |
| 7 | +printf '%s' '#define ORC_HASH ' | |
| 8 | + | |
| 9 | +awk ' | |
| 10 | +/^#define ORC_(REG|TYPE)_/ { print } | |
| 11 | +/^struct orc_entry {$/ { p=1 } | |
| 12 | +p { print } | |
| 13 | +/^}/ { p=0 }' | | |
| 14 | + sha1sum | | |
| 15 | + cut -d " " -f 1 | | |
| 16 | + sed 's/\([0-9a-f]\{2\}\)/0x\1,/g' | |