lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ae3dabb001d41b3874c1a3ae9a2d76298806f167.1687706332.git.falcon@tinylab.org>
Date:   Mon, 26 Jun 2023 00:45:12 +0800
From:   Zhangjin Wu <falcon@...ylab.org>
To:     thomas@...ch.de, w@....eu
Cc:     falcon@...ylab.org, arnd@...db.de, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org
Subject: [PATCH v1 22/22] selftests/nolibc: detect bios existing to avoid hang

Without a right -bios option, riscv32 and loongarch will hang during
boot and therefore block the whole testing, this adds necessary
detection.

Before testing, the required bios should be downloaded at first, for a
future working qemu (without a manual -bios), we can simply clear the
QEMU_BIOS_<ARCH> to stop the detection.

By default, the bios should be downloaded and put into
tools/testing/selftests/nolibc/, otherwise, users should specify the
path via QEMU_BIOS_<ARCH>.

Without this patch, it is not possible to directly run tests for all
architectures, otherwise, we should pass our own 'ARCHS' and remove the
unsupported ones explicitly, which is not convenient.

Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 470923dc10e1..b529bb40444a 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -110,6 +110,14 @@ QEMU_ARCH_s390       = s390x
 QEMU_ARCH_loongarch  = loongarch64
 QEMU_ARCH            = $(QEMU_ARCH_$(ARCH))
 
+# QEMU_BIOS: bios used by qemu
+# https://github.com/loongson/Firmware/raw/main/LoongArchVirtMachine/edk2-loongarch64-code.fd
+QEMU_BIOS_loongarch ?= edk2-loongarch64-code.fd
+# https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/opensbi-riscv32-generic-fw_dynamic.bin
+QEMU_BIOS_riscv32   ?= opensbi-riscv32-generic-fw_dynamic.bin
+QEMU_BIOS            = $(QEMU_BIOS_$(ARCH))
+QEMU_ARGS_BIOS       = $(if $(QEMU_BIOS),-bios $(QEMU_BIOS))
+
 # QEMU_ARGS : some arch-specific args to pass to qemu
 QEMU_ARGS_i386       = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_x86_64     = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
@@ -122,7 +130,7 @@ QEMU_ARGS_riscv64    = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_T
 QEMU_ARGS_riscv      = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_s390       = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
 QEMU_ARGS_loongarch  = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
-QEMU_ARGS            = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA)
+QEMU_ARGS            = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)
 
 # OUTPUT is only set when run from the main makefile, otherwise
 # it defaults to this nolibc directory.
@@ -167,9 +175,15 @@ endif
 # allow run tests on all architectures: run-user-all, run-all (=run-default-all), run-tiny-all
 ARCHS   ?= $(shell sed -ne 's/^DEFCONFIG_\([^ ]*\) .*/\1/p' $(CURDIR)/Makefile)
 GOALS   ?= run-user run-tiny run-default
+export $(foreach a, $(ARCHS), QEMU_BIOS_$a)
 RUN_ALL ?= _t=$@; t=$${_t%-all}; [ "$$t" = "run" ] && t=run-default; \
 	   if echo $(GOALS) | grep -wq "$$t"; then \
-		for a in $(ARCHS); do echo "Testing $$t for $${a}:"; make $$t ARCH=$$a; cp $(CURDIR)/run.out $(CURDIR)/run-$$a.out; done; \
+		for a in $(ARCHS); do \
+			echo "Testing $$t for $${a}:"; \
+			eval bios=\$${QEMU_BIOS_$$a}; \
+			if [ -n "$${bios}" -a ! -f "$${bios}" ]; then echo "\nIgnoring $$a test, no bios: $${bios} found."; exit 0; fi; \
+			make $$t ARCH=$$a; cp $(CURDIR)/run.out $(CURDIR)/run-$$a.out; \
+		done; \
 		echo "\n\nTesting summary of $$t:\n"; \
 		for a in $(ARCHS); do echo $${a}:; echo; $(REPORT) $(CURDIR)/run-$$a.out; echo; done; \
 	   else \
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ