mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5: test out panic_on_panic
patches: create patche/manual patch dir, put all patch directories under patches/ subdir
This commit is contained in:
61
README.adoc
61
README.adoc
@@ -3618,6 +3618,8 @@ Basically just calls `panic("BUG!")` for most archs.
|
||||
|
||||
===== Exit emulator on panic
|
||||
|
||||
====== Exit QEMU on panic
|
||||
|
||||
For testing purposes, it is very useful to quit the emulator automatically in case of kernel panic, instead of just hanging forever.
|
||||
|
||||
In QEMU, we enable it by default with:
|
||||
@@ -3631,13 +3633,28 @@ TODO neither method exits with exit status different from 0, so for now we are j
|
||||
|
||||
One possibility that gets close would be to use <<gdb>> to break at the `panic` function, and then send a <<qemu-monitor-from-gdb>> `quit` command if that happens, but I don't see a way to exit with non-zero status to indicate error.
|
||||
|
||||
====== Exit gem5 on panic
|
||||
|
||||
gem5 actually detects panics and outputs:
|
||||
|
||||
....
|
||||
warn: Kernel panic in simulated kernel
|
||||
....
|
||||
|
||||
before hanging. gem5 ff52563a214c71fcd1e21e9f00ad839612032e3b `config.ini` has a `system.panic_on_panic` and `system.panic_on_oops` params which I bet will work, but it does not seem to be exposed to `fs.py`, so we don't enable it by default, although we want to.
|
||||
before hanging forever.
|
||||
|
||||
We can make gem5 ff52563a214c71fcd1e21e9f00ad839612032e3b `fs.py` quit instead of hang with:
|
||||
|
||||
....
|
||||
patch -d gem5/gem5 -p1 < patches/manual/gem5-panic.patch
|
||||
./run -aa -F 'echo c > /proc/sysrq-trigger' -g
|
||||
....
|
||||
|
||||
Source: link:patches/manual/gem5-panic.patch[].
|
||||
|
||||
It does not seem to be exposed to `fs.py`.
|
||||
|
||||
However TODO it still exits with status 0... so we are just parsing the logs for now, like QEMU does.
|
||||
|
||||
Detection seems to be symbol based: it parses the kernel image, and triggers when the PC reaches the address of a symbol: https://github.com/gem5/gem5/blob/1da285dfcc31b904afc27e440544d006aae25b38/src/arch/arm/linux/system.cc#L73
|
||||
|
||||
@@ -8434,21 +8451,7 @@ The `-X-b` option enables the alternative `configs/example/arm/fs_bigLITTLE.py`
|
||||
First apply:
|
||||
|
||||
....
|
||||
echo '
|
||||
diff --git a/configs/example/arm/fs_bigLITTLE.py b/configs/example/arm/fs_bigLITTLE.py
|
||||
index 7d66c03a6..d71e714fe 100644
|
||||
--- a/configs/example/arm/fs_bigLITTLE.py
|
||||
+++ b/configs/example/arm/fs_bigLITTLE.py
|
||||
@@ -194,7 +194,7 @@ def build(options):
|
||||
"norandmaps",
|
||||
"loglevel=8",
|
||||
"mem=%s" % default_mem_size,
|
||||
- "root=/dev/vda1",
|
||||
+ "root=/dev/vda",
|
||||
"rw",
|
||||
"init=%s" % options.kernel_init,
|
||||
"vmalloc=768MB",
|
||||
' | patch -d gem5/gem5 -p1
|
||||
patch -d gem5/gem5 -p1 < patches/manual/gem5-biglittle.patch
|
||||
....
|
||||
|
||||
then:
|
||||
@@ -9320,12 +9323,6 @@ The action seems to be happening at: `hw/arm/virt.c`.
|
||||
***** `out/common/gem5/<gem5-variant>/build/`: main build outputs, including the `gem5.opt` executable and object files
|
||||
***** `out/common/gem5/<gem5-variant>/system/`: `M5_PATH` directory, with DTBs and bootloaders
|
||||
|
||||
==== buildroot_patches
|
||||
|
||||
Every `.patch` file in this directory gets applied to Buildroot before anything else is done.
|
||||
|
||||
This directory has been made kind of useless when we decided to use our own Buildroot fork, but we've kept the functionality just in case we someday go back to upstream Buildroot.
|
||||
|
||||
==== gem5 directory
|
||||
|
||||
We Build the gem5 emulator through Buildroot basically just to reuse its timestamping system to avoid rebuilds.
|
||||
@@ -9334,7 +9331,19 @@ There is also the `m5` tool that we must build through Buildroot ans install on
|
||||
|
||||
This directory has the following structure:
|
||||
|
||||
==== global_patch_dir
|
||||
==== packages directory
|
||||
|
||||
Any directory in that subdirectory is added to `BR2_EXTERNAL` and become available to the build.
|
||||
|
||||
==== patches
|
||||
|
||||
===== patches/buildroot
|
||||
|
||||
Every `.patch` file in this directory gets applied to Buildroot before anything else is done.
|
||||
|
||||
This directory has been made kind of useless when we decided to use our own Buildroot fork, but we've kept the functionality just in case we someday go back to upstream Buildroot.
|
||||
|
||||
===== patches/global
|
||||
|
||||
Has the following structure:
|
||||
|
||||
@@ -9346,9 +9355,11 @@ The patches are then applied to the corresponding packages before build.
|
||||
|
||||
Uses `BR2_GLOBAL_PATCH_DIR`.
|
||||
|
||||
==== packages directory
|
||||
===== patches/manual
|
||||
|
||||
Any directory in that subdirectory is added to `BR2_EXTERNAL` and become available to the build.
|
||||
Patches in this directory are never applied automatically: it is up to users to manually apply them before usage following the instructions in this documentation.
|
||||
|
||||
These are typically patches that don't contain fundamental functionality, so we don't feel like forking the target repos.
|
||||
|
||||
==== rootfs_overlay
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ BR2_CCACHE_USE_BASEDIR=n
|
||||
BR2_GCC_ENABLE_GRAPHITE=y
|
||||
BR2_GCC_ENABLE_LTO=y
|
||||
BR2_GCC_ENABLE_OPENMP=y
|
||||
BR2_GLOBAL_PATCH_DIR="../global_patch_dir"
|
||||
BR2_GLOBAL_PATCH_DIR="../patches/global"
|
||||
BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="../busybox_config_fragment"
|
||||
BR2_PACKAGE_DHRYSTONE=y
|
||||
BR2_PACKAGE_FILE=y
|
||||
|
||||
2
build
2
build
@@ -137,7 +137,7 @@ if "$configure"; then
|
||||
cp "${kernel_config_fragment_cli_file_tmp}" "${kernel_config_fragment_cli_file}"
|
||||
fi
|
||||
cd "${common_buildroot_dir}"
|
||||
for p in $(find "${common_root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do
|
||||
for p in $(find "${common_root_dir}/patches/buildroot/" -maxdepth 1 -name '*.patch' -print); do
|
||||
patch -N -r - -p 1 < "$p" || :
|
||||
done
|
||||
br2_external='../kernel_module:../gem5:../parsec-benchmark'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#buildroot_patches
|
||||
@@ -1 +0,0 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#global_patch_dir
|
||||
1
patches/buildroot/README.adoc
Normal file
1
patches/buildroot/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#patches-buildroot
|
||||
1
patches/global/README.adoc
Normal file
1
patches/global/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#patches-global
|
||||
1
patches/manual/README.adoc
Normal file
1
patches/manual/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#patches-manual
|
||||
13
patches/manual/gem5-biglittle.patch
Normal file
13
patches/manual/gem5-biglittle.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/configs/example/arm/fs_bigLITTLE.py b/configs/example/arm/fs_bigLITTLE.py
|
||||
index 7d66c03a6..d71e714fe 100644
|
||||
--- a/configs/example/arm/fs_bigLITTLE.py
|
||||
+++ b/configs/example/arm/fs_bigLITTLE.py
|
||||
@@ -194,7 +194,7 @@ def build(options):
|
||||
"norandmaps",
|
||||
"loglevel=8",
|
||||
"mem=%s" % default_mem_size,
|
||||
- "root=/dev/vda1",
|
||||
+ "root=/dev/vda",
|
||||
"rw",
|
||||
"init=%s" % options.kernel_init,
|
||||
"vmalloc=768MB",
|
||||
11
patches/manual/gem5-panic.patch
Normal file
11
patches/manual/gem5-panic.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
diff --git a/configs/example/fs.py b/configs/example/fs.py
|
||||
index 4031fd05e..0f502a34a 100644
|
||||
--- a/configs/example/fs.py
|
||||
+++ b/configs/example/fs.py
|
||||
@@ -395,5 +395,6 @@ if buildEnv['TARGET_ISA'] == "arm" and options.generate_dtb:
|
||||
sys = getattr(root, sysname)
|
||||
sys.dtb_filename = create_dtb_for_system(sys, '%s.dtb' % sysname)
|
||||
|
||||
+test_sys.panic_on_panic = True
|
||||
Simulation.setWorkCountOptions(test_sys, options)
|
||||
Simulation.run(options, root, test_sys, FutureClass)
|
||||
8
run
8
run
@@ -389,9 +389,7 @@ ${extra_flags}\
|
||||
"
|
||||
fi
|
||||
"${common_root_dir}/eeval" "$cmd" "${common_run_dir}/run.sh"
|
||||
if ! "$common_gem5"; then
|
||||
if grep 'Kernel panic - not syncing' "$common_termout_file"; then
|
||||
echo 'Kernel panic detected by parsing the terminal output. Exiting with status 1.'
|
||||
exit 1
|
||||
fi
|
||||
if grep 'Kernel panic - not syncing' "$common_termout_file"; then
|
||||
echo 'Kernel panic detected by parsing the terminal output. Exiting with status 1.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user