blob: 74ebfca2b3ff3b8b73923344d9ef1e47e178840a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# An alternative's replacement code counts towards the checksum of the function
# it belongs to.
#
# checksum_update_insn() walks insn->alts after hashing the instruction itself:
# the alternative's type, and where the replacement forms a group, its feature
# number and every instruction in it. So a patch which edits only the
# replacement -- code that runs on some CPUs and not others -- still has to
# move the function's checksum.
#
# If it does not, klp diff decides the function is unchanged and leaves it out.
# The patch then ships the old replacement, and the bug is fixed only on
# machines whose CPU takes the other arm. Which machines those are depends on
# the feature bit, so the failure looks like a machine-specific bug rather than
# a missing patch.
#
# insn->alts exists only after objtool's check pass, so the pair goes through
# that first -- the compiler emits none of this structure itself.
#
# Covers the same ground as corpus/x86_64/checksum-alt-group,
# checksum-alt-no-group and checksum-alt-recursion-guard in Joe Lawrence's
# klp-build unit test corpus.
. "$(dirname "$0")/../lib.sh"
setup
check()
{
build_pair checksum_alt.c "-D$1"
assert_input_section .altinstructions
run_objtool_check --mcount
run_checksum
assert_checksum_differs target
}
# The replacement instruction itself.
check ALT_REPL
# The feature number, with no instruction anywhere changed.
check ALT_FEATURE
pass "alternative replacement code counts towards the checksum"
|