diff options
author | Martin Jansa <Martin.Jansa@gmail.com> | 2022-07-28 13:40:44 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-02 11:29:59 +0100 |
commit | ad32aab27006b5df7cd9f4a5ef550ff4ab58f84d (patch) | |
tree | f24a3b89952ed59c228246c7112ba2bc7c8db31c /meta/recipes-extended/ltp | |
parent | 848d57ebe52375f9d7ac70baa842894b7b5134c3 (diff) | |
download | poky-ad32aab27006b5df7cd9f4a5ef550ff4ab58f84d.tar.gz |
ltp: fix build with ld-is-gold in DISTRO_FEATURES
* backport one more commit for LD call which conflicts with the
0001-kvm-use-LD-instead-of-hardcoding-ld.patch we already had
and replace this 2nd patch with the rebased version which is
now merged upstream
* then backport additional patch which introduces KVM_LD variable
which we can set to use .bfd suffix in LD when ld-is-gold is
in DISTRO_FEATURES to work around gold incompatibility reported:
https://github.com/linux-test-project/ltp/pull/948#issuecomment-1193138866
https://lists.openembedded.org/g/openembedded-core/message/168193
http://errors.yoctoproject.org/Errors/Details/663094/
x86_64-oe-linux-ld --sysroot=/OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/ltp/20220527-r0/recipe-sysroot -z noexecstack -r -T /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/ltp/20220527-r0/git/testcases/kernel/kvm/linker/payload.lds --oformat=elf64-x86-64 -o kvm_pagefault01-payload.o kvm_pagefault01-payload.bin
x86_64-oe-linux-ld: error: kvm_pagefault01-payload.bin:1:1: invalid character
make: *** [Makefile:53: kvm_pagefault01-payload.o] Error 1
(From OE-Core rev: ace41f64c7d617852bdfca736cefa0a470598af7)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended/ltp')
-rw-r--r-- | meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch | 40 | ||||
-rw-r--r-- | meta/recipes-extended/ltp/ltp/0002-kvm-use-LD-instead-of-hardcoding-ld.patch (renamed from meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch) | 26 | ||||
-rw-r--r-- | meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch | 63 | ||||
-rw-r--r-- | meta/recipes-extended/ltp/ltp_20220527.bb | 13 |
4 files changed, 128 insertions, 14 deletions
diff --git a/meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch b/meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch new file mode 100644 index 0000000000..764e9c0d9f --- /dev/null +++ b/meta/recipes-extended/ltp/ltp/0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From 608fc7bcda43e60536ae1f19842f7affba8f0aea Mon Sep 17 00:00:00 2001 | ||
2 | From: Martin Doucha <mdoucha@suse.cz> | ||
3 | Date: Wed, 1 Jun 2022 16:16:34 +0200 | ||
4 | Subject: [PATCH] kvm: Fix stack access mode in KVM test ELF headers | ||
5 | |||
6 | When the linker converts guest payload binary into a linkable resource | ||
7 | object file, it somehow defaults to requesting executable stack section | ||
8 | for the final test binary. This trips some build-time security checks | ||
9 | on newer systems. Add explicit linker option to make the stack | ||
10 | non-executable. | ||
11 | |||
12 | Suggested-by: Fabian Vogt <fvogt@suse.com> | ||
13 | Signed-off-by: Martin Doucha <mdoucha@suse.cz> | ||
14 | Reviewed-by: Petr Vorel <pvorel@suse.cz> | ||
15 | Reviewed-by: Cyril Hrubis <chrubis@suse.cz> | ||
16 | |||
17 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
18 | Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/f9715d7c2e78713e26533c6e0846aaabf5c4095b] | ||
19 | --- | ||
20 | testcases/kernel/kvm/Makefile | 4 ++-- | ||
21 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
22 | |||
23 | diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile | ||
24 | index 69a9946fe..adab56952 100644 | ||
25 | --- a/testcases/kernel/kvm/Makefile | ||
26 | +++ b/testcases/kernel/kvm/Makefile | ||
27 | @@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk | ||
28 | ifdef VERBOSE | ||
29 | $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) | ||
30 | objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin | ||
31 | - ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
32 | + ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
33 | else | ||
34 | @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) | ||
35 | @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin | ||
36 | - @ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
37 | + @ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
38 | @echo KVM_CC $(target_rel_dir)$@ | ||
39 | endif | ||
40 | @rm $*-payload.elf $*-payload.bin | ||
diff --git a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch b/meta/recipes-extended/ltp/ltp/0002-kvm-use-LD-instead-of-hardcoding-ld.patch index 23634d0c86..060ba05835 100644 --- a/meta/recipes-extended/ltp/ltp/0001-kvm-use-LD-instead-of-hardcoding-ld.patch +++ b/meta/recipes-extended/ltp/ltp/0002-kvm-use-LD-instead-of-hardcoding-ld.patch | |||
@@ -1,7 +1,4 @@ | |||
1 | Upstream-Status: Submitted [https://github.com/linux-test-project/ltp/pull/948] | 1 | From 1cea308a647c2a2f9790b0bac7c523de7aa83270 Mon Sep 17 00:00:00 2001 |
2 | Signed-off-by: Ross Burton <ross.burton@arm.com> | ||
3 | |||
4 | From 7670233e43df2aed6d44b96c51b034f8e2d28a19 Mon Sep 17 00:00:00 2001 | ||
5 | From: Ross Burton <ross.burton@arm.com> | 2 | From: Ross Burton <ross.burton@arm.com> |
6 | Date: Tue, 12 Jul 2022 15:03:54 +0100 | 3 | Date: Tue, 12 Jul 2022 15:03:54 +0100 |
7 | Subject: [PATCH] kvm: use $(LD) instead of hardcoding ld | 4 | Subject: [PATCH] kvm: use $(LD) instead of hardcoding ld |
@@ -9,29 +6,34 @@ Subject: [PATCH] kvm: use $(LD) instead of hardcoding ld | |||
9 | In cross-compiled builds the host ld may not know the required ELF format, | 6 | In cross-compiled builds the host ld may not know the required ELF format, |
10 | so ensure we use $(LD) which will be the cross-capable ld binary. | 7 | so ensure we use $(LD) which will be the cross-capable ld binary. |
11 | 8 | ||
9 | Closes: https://github.com/linux-test-project/ltp/pull/948 | ||
10 | |||
11 | Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/f94e0ef3b7280f886384703ef9019aaf2f2dfebb] | ||
12 | Signed-off-by: Ross Burton <ross.burton@arm.com> | 12 | Signed-off-by: Ross Burton <ross.burton@arm.com> |
13 | |||
14 | Reviewed-by: Petr Vorel <pvorel@suse.cz> | ||
15 | Reviewed-by: Martin Doucha <mdoucha@suse.cz> | ||
16 | Signed-off-by: Ross Burton <ross.burton@arm.com> | ||
17 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
13 | --- | 18 | --- |
14 | testcases/kernel/kvm/Makefile | 4 ++-- | 19 | testcases/kernel/kvm/Makefile | 4 ++-- |
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | 20 | 1 file changed, 2 insertions(+), 2 deletions(-) |
16 | 21 | ||
17 | diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile | 22 | diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile |
18 | index 69a9946fe..4ddef9f95 100644 | 23 | index adab56952..d67230735 100644 |
19 | --- a/testcases/kernel/kvm/Makefile | 24 | --- a/testcases/kernel/kvm/Makefile |
20 | +++ b/testcases/kernel/kvm/Makefile | 25 | +++ b/testcases/kernel/kvm/Makefile |
21 | @@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk | 26 | @@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk |
22 | ifdef VERBOSE | 27 | ifdef VERBOSE |
23 | $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) | 28 | $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) |
24 | objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin | 29 | objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin |
25 | - ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | 30 | - ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
26 | + $(LD) -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | 31 | + $(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
27 | else | 32 | else |
28 | @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) | 33 | @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) |
29 | @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin | 34 | @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin |
30 | - @ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | 35 | - @ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
31 | + @$(LD) -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | 36 | + @$(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin |
32 | @echo KVM_CC $(target_rel_dir)$@ | 37 | @echo KVM_CC $(target_rel_dir)$@ |
33 | endif | 38 | endif |
34 | @rm $*-payload.elf $*-payload.bin | 39 | @rm $*-payload.elf $*-payload.bin |
35 | -- | ||
36 | 2.34.1 | ||
37 | |||
diff --git a/meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch b/meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch new file mode 100644 index 0000000000..974ca5eebe --- /dev/null +++ b/meta/recipes-extended/ltp/ltp/0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch | |||
@@ -0,0 +1,63 @@ | |||
1 | From a8d41b7937a34904611011ca357f8db880d42270 Mon Sep 17 00:00:00 2001 | ||
2 | From: Martin Doucha <mdoucha@suse.cz> | ||
3 | Date: Mon, 25 Jul 2022 17:37:27 +0200 | ||
4 | Subject: [PATCH] Add KVM_LD Makefile variable for building KVM payload | ||
5 | binaries | ||
6 | |||
7 | KVM linker needs to be configurable for cross-compiling but some | ||
8 | linkers don't support the linker script for wrapping arbitrary files | ||
9 | into linkable resource files. Allow KVM linker to be changed | ||
10 | independently of $LD via $KVM_LD. | ||
11 | |||
12 | Signed-off-by: Martin Doucha <mdoucha@suse.cz> | ||
13 | Acked-by: Richard Palethorpe <rpalethorpe@suse.com> | ||
14 | |||
15 | Upstream-Status: Backport [https://github.com/linux-test-project/ltp/commit/5ef0b7892a17b64040e55e9ad62d36ebb75d33fd] | ||
16 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
17 | --- | ||
18 | doc/build-system-guide.txt | 5 +++++ | ||
19 | testcases/kernel/kvm/Makefile | 5 +++-- | ||
20 | 2 files changed, 8 insertions(+), 2 deletions(-) | ||
21 | |||
22 | diff --git a/doc/build-system-guide.txt b/doc/build-system-guide.txt | ||
23 | index 166f7fb92..b8d267b4b 100644 | ||
24 | --- a/doc/build-system-guide.txt | ||
25 | +++ b/doc/build-system-guide.txt | ||
26 | @@ -145,6 +145,11 @@ $(CPPFLAGS) : Preprocessor flags, e.g. -I arguments. | ||
27 | |||
28 | $(DEBUG_CFLAGS) : Debug flags to pass to $(CC), -g, etc. | ||
29 | |||
30 | +$(KVM_LD) : Special linker for wrapping KVM payload binaries | ||
31 | + into linkable object files. Defaults to $(LD). | ||
32 | + Change this variable if the KVM Makefile fails | ||
33 | + to build files named *-payload.o. | ||
34 | + | ||
35 | $(LD) : The system linker (typically $(CC), but not | ||
36 | necessarily). | ||
37 | |||
38 | diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile | ||
39 | index d67230735..31f144c26 100644 | ||
40 | --- a/testcases/kernel/kvm/Makefile | ||
41 | +++ b/testcases/kernel/kvm/Makefile | ||
42 | @@ -11,6 +11,7 @@ GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD | ||
43 | GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse | ||
44 | GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none | ||
45 | GUEST_LDLIBS = | ||
46 | +KVM_LD ?= $(LD) | ||
47 | |||
48 | FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86 | ||
49 | |||
50 | @@ -50,11 +51,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk | ||
51 | ifdef VERBOSE | ||
52 | $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) | ||
53 | objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin | ||
54 | - $(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
55 | + $(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
56 | else | ||
57 | @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) | ||
58 | @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin | ||
59 | - @$(LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
60 | + @$(KVM_LD) -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin | ||
61 | @echo KVM_CC $(target_rel_dir)$@ | ||
62 | endif | ||
63 | @rm $*-payload.elf $*-payload.bin | ||
diff --git a/meta/recipes-extended/ltp/ltp_20220527.bb b/meta/recipes-extended/ltp/ltp_20220527.bb index d07563c4e1..b0f4ea6021 100644 --- a/meta/recipes-extended/ltp/ltp_20220527.bb +++ b/meta/recipes-extended/ltp/ltp_20220527.bb | |||
@@ -28,7 +28,9 @@ SRCREV = "6f88e0f6f1d6eb12c48c902f50f47ecbd3b0f18a" | |||
28 | SRC_URI = "git://github.com/linux-test-project/ltp.git;branch=master;protocol=https \ | 28 | SRC_URI = "git://github.com/linux-test-project/ltp.git;branch=master;protocol=https \ |
29 | file://0001-Remove-OOM-tests-from-runtest-mm.patch \ | 29 | file://0001-Remove-OOM-tests-from-runtest-mm.patch \ |
30 | file://disable_hanging_tests.patch \ | 30 | file://disable_hanging_tests.patch \ |
31 | file://0001-kvm-use-LD-instead-of-hardcoding-ld.patch \ | 31 | file://0001-kvm-Fix-stack-access-mode-in-KVM-test-ELF-headers.patch \ |
32 | file://0002-kvm-use-LD-instead-of-hardcoding-ld.patch \ | ||
33 | file://0003-Add-KVM_LD-Makefile-variable-for-building-KVM-payloa.patch \ | ||
32 | file://0001-nfs05_make_tree-Restore-5-min-timeout.patch \ | 34 | file://0001-nfs05_make_tree-Restore-5-min-timeout.patch \ |
33 | file://0001-syscalls-migrate_pages03-restore-runtime-to-5m.patch \ | 35 | file://0001-syscalls-migrate_pages03-restore-runtime-to-5m.patch \ |
34 | file://0001-mountns0-1-3-wait-for-umount-completed-in-thread_b.patch \ | 36 | file://0001-mountns0-1-3-wait-for-umount-completed-in-thread_b.patch \ |
@@ -47,6 +49,13 @@ inherit autotools-brokensep pkgconfig | |||
47 | # https://github.com/linux-test-project/ltp/commit/3fce2064b54843218d085aae326c8f7ecf3a8c41#diff-39268f0855c634ca48c8993fcd2c95b12a65b79e8d9fa5ccd6b0f5a8785c0dd6R36 | 49 | # https://github.com/linux-test-project/ltp/commit/3fce2064b54843218d085aae326c8f7ecf3a8c41#diff-39268f0855c634ca48c8993fcd2c95b12a65b79e8d9fa5ccd6b0f5a8785c0dd6R36 |
48 | LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" | 50 | LDFLAGS:append = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd', '', d)}" |
49 | 51 | ||
52 | # After 0002-kvm-use-LD-instead-of-hardcoding-ld.patch | ||
53 | # https://github.com/linux-test-project/ltp/commit/f94e0ef3b7280f886384703ef9019aaf2f2dfebb | ||
54 | # it fails with gold also a bit later when trying to use *-payload.bin | ||
55 | # http://errors.yoctoproject.org/Errors/Details/663094/ | ||
56 | # work around this by forcing .bfd linked in LD when ld-is-gold is in DISTRO_FEATURES | ||
57 | KVM_LD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '${HOST_PREFIX}ld.bfd${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}', '${LD}', d)}" | ||
58 | |||
50 | TARGET_CC_ARCH += "${LDFLAGS}" | 59 | TARGET_CC_ARCH += "${LDFLAGS}" |
51 | 60 | ||
52 | export prefix = "/opt/${PN}" | 61 | export prefix = "/opt/${PN}" |
@@ -59,7 +68,7 @@ EXTRA_OECONF = " --with-realtime-testsuite --with-open-posix-testsuite " | |||
59 | EXTRA_OECONF += " --without-tirpc " | 68 | EXTRA_OECONF += " --without-tirpc " |
60 | 69 | ||
61 | do_compile() { | 70 | do_compile() { |
62 | oe_runmake HOSTCC="${CC_FOR_BUILD}" HOST_CFLAGS="${CFLAGS_FOR_BUILD}" HOST_LDFLAGS="${LDFLAGS_FOR_BUILD}" | 71 | oe_runmake HOSTCC="${CC_FOR_BUILD}" HOST_CFLAGS="${CFLAGS_FOR_BUILD}" HOST_LDFLAGS="${LDFLAGS_FOR_BUILD}" KVM_LD="${KVM_LD}" |
63 | } | 72 | } |
64 | 73 | ||
65 | do_install(){ | 74 | do_install(){ |