From f58f117dc589efea14763066f09c62bdcc42f30d Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Thu, 15 Feb 2024 13:25:07 +0000 Subject: [PATCH] Fix missing kern.module_path for run --test Currently run-riscv64- --run/kernel-abi=purecap as run by Jenkins fails to load modules due to not having kern.module_path set like the non-test code path (and thus trying to load from the default hybrid path). Extend --alternate-kernel-rootfs-path to also convey this for direct booting. --- pycheribuild/boot_cheribsd/__init__.py | 17 ++++++++++------- pycheribuild/config/compilation_targets.py | 2 +- pycheribuild/projects/run_qemu.py | 4 +--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pycheribuild/boot_cheribsd/__init__.py b/pycheribuild/boot_cheribsd/__init__.py index 3c12fb200..32955ca9d 100755 --- a/pycheribuild/boot_cheribsd/__init__.py +++ b/pycheribuild/boot_cheribsd/__init__.py @@ -778,8 +778,6 @@ def boot_cheribsd(qemu_options: QemuOptions, qemu_command: Optional[Path], kerne if not qemu_options.can_boot_kernel_directly: if not disk_image: failure("Cannot boot kernel directly and no disk image passed!", exit=True) - else: - assert boot_alternate_kernel_dir is None, "Unexpected alternate kernel parameter for loader(8)" if bios_path is not None: bios_args = ["-bios", str(bios_path)] elif qemu_options.xtarget.is_riscv(include_purecap=True): @@ -795,6 +793,11 @@ def boot_cheribsd(qemu_options: QemuOptions, qemu_command: Optional[Path], kerne ) qemu_args.extend(smp_args) kernel_commandline = [] + if qemu_options.can_boot_kernel_directly and kernel_image and boot_alternate_kernel_dir: + kernel_commandline.append(f"kern.module_path={boot_alternate_kernel_dir}") + loader_kernel_dir = None + else: + loader_kernel_dir = boot_alternate_kernel_dir if kernel_init_only: kernel_commandline.append("init_path=/sbin/startup-benchmark.sh") if skip_ssh_setup: @@ -834,14 +837,14 @@ def boot_cheribsd(qemu_options: QemuOptions, qemu_command: Optional[Path], kerne kernel_init_only=kernel_init_only, network_iface=qemu_options.network_interface_name(), expected_kernel_abi_msg=expected_kernel_abi_arg_to_regex[expected_kernel_abi], - boot_alternate_kernel_dir=boot_alternate_kernel_dir, + loader_kernel_dir=loader_kernel_dir, ) return child def boot_and_login(child: CheriBSDSpawnMixin, *, starttime, kernel_init_only=False, network_iface: Optional[str], expected_kernel_abi_msg: Optional[str] = None, - boot_alternate_kernel_dir: "Optional[Path]" = None) -> None: + loader_kernel_dir: "Optional[Path]" = None) -> None: have_dhclient = False # ignore SIGINT for the python code, the child should still receive it # signal.signal(signal.SIGINT, signal.SIG_IGN) @@ -876,7 +879,7 @@ def boot_and_login(child: CheriBSDSpawnMixin, *, starttime, kernel_init_only=Fal # Skip 10s wait from loader(8) if we see the autoboot message if i == loader_boot_messages.index(AUTOBOOT_PROMPT): # Hit Enter success("===> loader(8) autoboot") - if boot_alternate_kernel_dir: + if loader_kernel_dir: # Stop autoboot and enter console child.send("\x1b") i = child.expect(loader_boot_prompt_messages, timeout=60, @@ -889,10 +892,10 @@ def boot_and_login(child: CheriBSDSpawnMixin, *, starttime, kernel_init_only=Fal if i == loader_boot_messages.index(BOOT_LOADER_PROMPT): # loader(8) prompt success("===> loader(8) waiting boot commands") # Just boot the default kernel if no alternate kernel directory is given - child.sendline("boot {}".format(boot_alternate_kernel_dir or "")) + child.sendline("boot {}".format(loader_kernel_dir or "")) ran_manual_boot = True i = child.expect(boot_messages, timeout=20 * 60, timeout_msg="timeout before kernel") - if boot_alternate_kernel_dir and not ran_manual_boot: + if loader_kernel_dir and not ran_manual_boot: failure("failed to enter boot loader prompt", exit=True) # Check that we are booting the expected kind of CheriBSD kernel (hybrid/purecap) diff --git a/pycheribuild/config/compilation_targets.py b/pycheribuild/config/compilation_targets.py index 6533e76bd..fb283e3c6 100644 --- a/pycheribuild/config/compilation_targets.py +++ b/pycheribuild/config/compilation_targets.py @@ -614,7 +614,7 @@ def has_test_extra_arg_override(arg: str): cmd.append("--test-ld-preload-variable=LD_64_PRELOAD") else: cmd.append("--test-ld-preload-variable=LD_PRELOAD") - if rootfs_alternate_kernel_dir and not qemu_options.can_boot_kernel_directly: + if rootfs_alternate_kernel_dir: cmd.extend(["--alternate-kernel-rootfs-path", rootfs_alternate_kernel_dir]) cmd.extend(map(str, script_args)) diff --git a/pycheribuild/projects/run_qemu.py b/pycheribuild/projects/run_qemu.py index 35b353a3a..f701429d6 100644 --- a/pycheribuild/projects/run_qemu.py +++ b/pycheribuild/projects/run_qemu.py @@ -727,9 +727,7 @@ def _extra_test_args(self) -> "list[str]": return [] def run_tests(self): - rootfs_kernel_bootdir = None - if not self.qemu_options.can_boot_kernel_directly: - rootfs_kernel_bootdir = self.kernel_project.get_kern_module_path(self.kernel_config) + rootfs_kernel_bootdir = self.kernel_project.get_kern_module_path(self.kernel_config) extra_args = self._extra_test_args if self.kyua_test_files and "--kyua-tests-files" not in self.config.test_extra_args: extra_args.extend("--kyua-tests-files=" + x for x in self.kyua_test_files)