Skip to content

[LTS 8.8] selftests: breakpoints: Fix a typo of function name #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: ciqlts8_8
Choose a base branch
from

Conversation

pvts-mat
Copy link
Contributor

[LTS 8.8]

About

This commit fixes the problem with the compilation of breakpoints:breakpoint_test_arm64 test on aarch64 architecture.

Before

Compilation attempt:

$ make -C tools/testing/selftests/breakpoints

make[1]: Entering directory '/mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints'
gcc     step_after_suspend_test.c /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest_harness.h /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest.h  -o /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints/step_after_suspend_test
gcc     breakpoint_test_arm64.c /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest_harness.h /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest.h  -o /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints/breakpoint_test_arm64
breakpoint_test_arm64.c: In function ‘main’:
breakpoint_test_arm64.c:226:14: warning: implicit declaration of function ‘run_test’; did you mean ‘arun_test’? [-Wimplicit-function-declaration]
     result = run_test(size, MIN(size, 8), wr, wp);
              ^~~~~~~~
              arun_test
/tmp/cc5dMu7r.o: In function `main':
breakpoint_test_arm64.c:(.text+0xb08): undefined reference to `run_test'
breakpoint_test_arm64.c:(.text+0xc10): undefined reference to `run_test'
collect2: error: ld returned 1 exit status
make[1]: *** [../lib.mk:143: /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints/breakpoint_test_arm64] Error 1
make[1]: Leaving directory '/mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints'

Test run attempt:

TAP version 13
1..1
# selftests: breakpoints: breakpoint_test_arm64
# Warning: file breakpoint_test_arm64 is missing!
not ok 1 selftests: breakpoints: breakpoint_test_arm64

After

Compilation

$ make -C tools/testing/selftests/breakpoints

make[1]: Entering directory '/mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints'
gcc     step_after_suspend_test.c /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest_harness.h /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest.h  -o /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints/step_after_suspend_test
gcc     breakpoint_test_arm64.c /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest_harness.h /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/kselftest.h  -o /mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints/breakpoint_test_arm64
make[1]: Leaving directory '/mnt/build_files/kernel-src-tree-kselftests-ciqlts8_8/tools/testing/selftests/breakpoints'

Test run:

TAP version 13
1..1
# selftests: breakpoints: breakpoint_test_arm64
# TAP version 13
# 1..213
# # child did not single-step
# ok 1 Test size = 1 write offset = 0 watchpoint offset = -1
# ok 2 Test size = 1 write offset = 0 watchpoint offset = 0
# # child did not single-step
# ok 3 Test size = 1 write offset = 0 watchpoint offset = 1
…
# ok 203 Test size = 32 write offset = 0 watchpoint offset = 0
# # child did not single-step
# ok 204 Test size = 32 write offset = 0 watchpoint offset = 32
# # child did not single-step
# ok 205 Test size = 32 write offset = 32 watchpoint offset = 0
# ok 206 Test size = 32 write offset = 32 watchpoint offset = 32
# # child did not single-step
# ok 207 Test size = 32 write offset = 32 watchpoint offset = 64
# ok 208 Test size = 1 write offset = -1 watchpoint offset = -8
# ok 209 Test size = 2 write offset = -2 watchpoint offset = -8
# ok 210 Test size = 4 write offset = -4 watchpoint offset = -8
# ok 211 Test size = 8 write offset = -8 watchpoint offset = -8
# ok 212 Test size = 16 write offset = -16 watchpoint offset = -8
# ok 213 Test size = 32 write offset = -32 watchpoint offset = -8
# # Totals: pass:213 fail:0 xfail:0 xpass:0 skip:0 error:0
ok 1 selftests: breakpoints: breakpoint_test_arm64

Note

To successfully compile the breakpoints:breakpoint_test_arm64 test on the base cloud init image an additional step must be made, although it relates to the system image and the packages available in Mountain, not the kernel.

Compiling breakpoints:breakpoint_test_arm64 on aarch may raise the following error:

breakpoint_test_arm64.c: In function ‘run_test’:
breakpoint_test_arm64.c:188:25: error: ‘TRAP_HWBKPT’ undeclared (first use in this function); did you mean ‘TRAP_BRKPT’?
  if (siginfo.si_code != TRAP_HWBKPT) {
                         ^~~~~~~~~~~
                         TRAP_BRKPT
breakpoint_test_arm64.c:188:25: note: each undeclared identifier is reported only once for each function it appears in

This occurs on versions ciqlts8_6 and ciqlts8_8 but not on ciqlts9_2 or ciqlts9_4. The TRAP_BRKPT constant is searched for in the /usr/include/bits/siginfo-consts.h file, which in versions ≥ 9.2 contains

/* `si_code' values for SIGTRAP signal.  */
enum
{
  TRAP_BRKPT = 1,		/* Process breakpoint.  */
#  define TRAP_BRKPT	TRAP_BRKPT
  TRAP_TRACE,			/* Process trace trap.  */
#  define TRAP_TRACE	TRAP_TRACE
  TRAP_BRANCH,			/* Process taken branch trap.  */
#  define TRAP_BRANCH	TRAP_BRANCH
  TRAP_HWBKPT,			/* Hardware breakpoint/watchpoint.  */
#  define TRAP_HWBKPT	TRAP_HWBKPT
  TRAP_UNK			/* Undiagnosed trap.  */
#  define TRAP_UNK	TRAP_UNK
};
# endif

while in versions < 9.2 contains

/* `si_code' values for SIGTRAP signal.  */
enum
{
  TRAP_BRKPT = 1,		/* Process breakpoint.  */
#  define TRAP_BRKPT	TRAP_BRKPT
  TRAP_TRACE			/* Process trace trap.  */
#  define TRAP_TRACE	TRAP_TRACE
};
# endif

In ≥ 9.2 the /usr/include/bits/siginfo-consts.h file is part of the glibc-devel package, while in the 8.8 version it's managed by glibc-headers. Having this package updated to the most recent version glibc-headers-2.28-236.el8_8.88ciq_lts.13.aarch64 doesn't help. The following hacky sed is used during machine preparation phase to simply expand the set of known TRAP_* codes in the system to match those on ≥ 9.2:

sudo sed -e '144 d' -e 's/#  define TRAP_TRACE\tTRAP_TRACE/  TRAP_TRACE,\n#  define TRAP_TRACE\tTRAP_TRACE\n  TRAP_BRANCH,\n#  define TRAP_BRANCH\tTRAP_BRANCH\n  TRAP_HWBKPT,\n#  define TRAP_HWBKPT\tTRAP_HWBKPT\n  TRAP_UNK\n#  define TRAP_UNK\tTRAP_UNK/g' -i /usr/include/bits/siginfo-consts.h

commit-author Masami Hiramatsu <mhiramat@kernel.org>
commit 5b06eea

Since commit 5821ba9 ("selftests: Add test plan API to kselftest.h
and adjust callers") accidentally introduced 'a' typo in the front of
run_test() function, breakpoint_test_arm64.c became not able to be
compiled.

Remove the 'a' from arun_test().

Fixes: 5821ba9 ("selftests: Add test plan API to kselftest.h and adjust callers")
        Reported-by: Jun Takahashi <takahashi.jun_s@aa.socionext.com>
        Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
        Cc: Kees Cook <keescook@chromium.org>
        Reviewed-by: Kees Cook <keescook@chromium.org>
        Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
(cherry picked from commit 5b06eea)
        Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants