From 8c2b28cf21d5e6c35dd8d848ac8507285a006f63 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 12 Jul 2024 10:50:28 +0200 Subject: [PATCH] Enable systemd debug log and all-in-order --- JOURNAL.md | 8 ++++++++ lagarto-ox.nix | 44 ++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/JOURNAL.md b/JOURNAL.md index 47890ca..cb36ee4 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -1427,3 +1427,11 @@ clues by enabling the debug mode. If a trap is being issued, we may be able to modify OpenSBI to print some information to the serial console so we can understand what is going on. + +In the meanwhile, let's try a simple test. We can enable debug output of systemd +with the following boot options: + + systemd.log_level=debug systemd.log_target=console + +We will also need to run `csrtool all-in-order` to arrive to systemd. + diff --git a/lagarto-ox.nix b/lagarto-ox.nix index d03a206..ab0ab8f 100644 --- a/lagarto-ox.nix +++ b/lagarto-ox.nix @@ -81,31 +81,24 @@ kernelModules = [ ]; # Custom init script - extraFiles."/init2".source = pkgs.writeScript "init2" '' - #!${config.system.build.extraUtils}/bin/ash + extraFiles = { + "/shell".source = pkgs.writeScript "shell" '' + #!${config.system.build.extraUtils}/bin/ash - set -x + set -x - export PATH=${config.system.build.extraUtils}/bin + export PATH=${config.system.build.extraUtils}/bin + ash + ''; - #mkdir -p /tracing - #mount -t tracefs nodev /tracing - - #cd /tracing - #echo nop > current_tracer - #echo 100 > max_graph_depth - #echo handle_page_fault > set_graph_function - #echo function_graph > current_tracer - #cd / - - # Open an interactive shell - ash - - memtool fill $((512 * 1024 * 1024)) - - # Unlikely to reach this point - exec /init - ''; + "/preinit".source = pkgs.writeScript "preinit" '' + #!${config.system.build.extraUtils}/bin/ash + set -x + export PATH=${config.system.build.extraUtils}/bin + csrtool all-in-order + exec /init + ''; + }; # Add the csrtool to the initrd so we can change the # in-order/out-of-order, and memtool to stress the memory. @@ -283,7 +276,10 @@ fdt set /memory@80000000 reg <0x0 0x80000000 0x0 0xc0000000> # Set kernel bootcmd options. - # rdinit=/init2 boot custom init script + # rdinit=/preinit boot custom preinit script + # Systemd options + # systemd.log_level=debug + # systemd.log_target=console # NixOS interesting options: # debug1 enable debug shell in stage 1 # boot.trace enable set -x in stage 1 @@ -294,7 +290,7 @@ # tp_printk write ftrace events to console # trace_buf_size=1M set ftrace buffer to 1M # - setenv bootargs "root=/dev/ram0 loglevel=7 debug rw earlycon=sbi console=hvc0 init=${init}" + setenv bootargs "root=/dev/ram0 loglevel=7 debug rw earlycon=sbi console=hvc0 systemd.log_level=debug systemd.log_target=console rdinit=/preinit init=${init}" EOF