build: unify QEMU and gem5 kernel configs! The last one!

Split optional and required kernel configs into separate files.

readme: describe how our kernel configs are generated from Buildroot

readme: document QEMU `-no-reboot` and speculate gem5 `panic_on_panic`
in preparation for some more automated bisection with ktest.
This commit is contained in:
Ciro Santilli
2018-04-21 11:39:06 +01:00
parent 4e0d9af81f
commit 2bddcc2891
9 changed files with 99 additions and 3048 deletions

View File

@@ -458,7 +458,7 @@ where `kernel_module` is the name of out Buildroot package that contains the ker
Other important targets are:
....
./build -l -q -G
./build -l -q -g
....
which rebuild the Linux kernel, and QEMU and gem5 respectively. They are essentially aliases for:
@@ -1940,6 +1940,15 @@ shows that interrupts do happen when mouse and keyboard presses are done, so I e
The file `/dev/inputs/mice` does not exist.
Note that our current link:kernel_confi_fragment sets:
....
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
....
for gem5, so you might want to remove those lines to debug this.
=== X11 ARM
On ARM, `startx` hangs at a message:
@@ -2080,7 +2089,7 @@ TODO we were not able to get it working yet: https://stackoverflow.com/questions
By default, we use a `.config` that is a mixture of:
* Buildroot's minimal per machine `.config`, which has the minimal options needed to boot
* our link:kernel_config_fragment[] which enables options we want to play with
* our <<kernel-configs-about,kernel configs>> which enables options we want to play with
If you want to just use your own exact `.config` instead, do:
@@ -2232,7 +2241,7 @@ Make the kernel reboot after n seconds after panic:
echo 1 > /proc/sys/kernel/panic
....
Can also be controlled with the `panic` kernel boot parameter.
Can also be controlled with the `panic=` kernel boot parameter.
`0` to disable: https://unix.stackexchange.com/questions/29567/how-to-configure-the-linux-kernel-to-reboot-on-panic/29569#29569
@@ -2326,6 +2335,18 @@ Related:
Basically just calls `panic("BUG!")` for most archs.
===== Shutdown VM on panic
Useful to automate bisections.
QEMU:
....
./run -E 'insmod /panic.ko' -e 'panic=1' -- -no-reboot
....
gem5: TODO gem5's `config.ini` has a `system.panic_on_panic` param which I bet will work, but it does not seem to be exposed to `fs.py`.
[[oops]]
==== Kernel oops
@@ -2926,6 +2947,31 @@ It just runs forever, so kill it when you get tired:
kill %1
....
[[kernel-configs-about]]
=== About our Linux kernel configs
We have managed to come up with minimalistic kernel configs that work for both QEMU and gem5 (oh, the hours of bisection).
Our configs are all based on Buildroot's configs, which were designed for QEMU, and then on top of those we also add:
* link:kernel_config_fragment/min[]: minimal tweaks required to boot gem5 or for using our slightly different QEMU command line options than Buildroot
* link:kernel_config_fragment/default[]: optional configs that we add by default to our kernel build because they increase visibility, and don't significantly increase build time nor add significant runtime overhead
Changes to those files automatically trigger kernel reconfigures even without using the linux-reconfigure target, since timestamps are used to decide if changes happened or not.
Having the same config working for both QEMU and gem5 means that you can deal with functional matters in QEMU, which runs much faster, and switch to gem5 only for performance issues.
To see Buildroot's base configs, have a look at `buildroot/configs/qemu_x86_64_defconfig`, which our `./build` script uses.
That file contains `BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux-4.11.config"`, which points to the base config file used.
`arm`, on the other hand, uses `buildroot/configs/qemu_arm_vexpress_defconfig`, which contains `BR2_LINUX_KERNEL_DEFCONFIG="vexpress"`, and therefore just does a `make vexpress_defconfig`.
Other configs which we had previously tested at 4e0d9af81fcce2ce4e777cb82a1990d7c2ca7c1e are:
* Jason's magic `x86_64` config: http://web.archive.org/web/20171229121642/http://www.lowepower.com/jason/files/config which is referenced at: link:http://web.archive.org/web/20171229121525/http://www.lowepower.com/jason/setting-up-gem5-full-system.html[]. QEMU boots with that by removing `# CONFIG_VIRTIO_PCI is not set`
* `arm` and `aarch64` configs present in the official ARM gem5 Linux kernel fork: https://gem5.googlesource.com/arm/linux, e.g. for arm v4.9: link:https://gem5.googlesource.com/arm/linux/+/917e007a4150d26a0aa95e4f5353ba72753669c7/arch/arm/configs/gem5_defconfig[]. The patches there are just simple optimizations and instrumentation, but they are not needed to boot.
== QEMU
Some QEMU specific features to play with and limitations to cry over.
@@ -3051,6 +3097,12 @@ devmem 0x101e9000 w 0x12345678
which touches the register from userland through `/dev/mem`.
==== Educational hardware models gem5
TODO
http://gedare-csphd.blogspot.co.uk/2013/02/adding-simple-io-device-to-gem5.html
=== 9P
This protocol allows sharing a mountable filesystem between guest and host.
@@ -3086,7 +3138,7 @@ cat guest
The main ingredients for this are:
* `9P` settings in our link:kernel_config_fragment[]
* `9P` settings in our <<kernel-configs-about,kernel configs>>
* `9p` entry on our link:rootfs_overlay/etc/fstab[]
+
Alternatively, you could also mount your own with:
@@ -3451,8 +3503,6 @@ On another shell:
./gem5-shell
....
A full rebuild is currently needed even if you already have QEMU working unfortunately, see: <<gem5-qemu-config>>
Tested architectures:
* `arm`
@@ -3883,7 +3933,7 @@ Separating input sizes also allows to create smaller images when only running th
This limitation exists because `parsecmgmt` generates the input files just before running via the Bash scripts, but we can't run `parsecmgmt` on gem5 as it is too slow!
One option would be to do that inside the guest with QEMU, but this would required a full rebuild due to <<gem5-qemu-config>>.
One option would be to do that inside the guest with QEMU.
Also, we can't generate all input sizes at once, because many of them have the same name and would overwrite one another...
@@ -4253,162 +4303,18 @@ And a second instance:
TODO Now we just need to network them up to have some more fun! See dist-gem5: http://publish.illinois.edu/icsl-pdgem5/
[[gem5-qemu-config]]
=== gem5 and QEMU with the same kernel configuration
We would like to be able to run both gem5 and QEMU with the same minimal kernel build to:
* do a single Buildroot build for both. Otherwise, we have to create two full `out/.*/buildroot/` directories, which takes up a lot of time.
+
Alternatively, we could try to be brave and switch between two kernel builds inside `out/.*/buildroot/`, but that would be too hackish.
* be able to compare behaviour between QEMU and gem5 when one is doing something weird.
+
Note however that there are also variations which need to be controlled, e.g. kernel command line, DTB and QEMU's non-determinism.
So far, the following build are unified for QEMU and gem5:
* arm
* aarch64
The others use the Buildroot config for QEMU, and magic huge post-olddefconfig config files floating around the web for GEM5.
Subsections of this section document our failed attempts so far.
This is the strategy that we used to make it work for aarch64:
* `make savedefconfig` on the working gem5 kernel tree
* paste the result on `kernel_config_fragment`
* bisect it up
but this strategy failed for the other archs for some reason.
==== gem5 and QEMU with the same kernel configuration x86_64
Boot fails with:
....
--- BEGIN LIBC BACKTRACE ---
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z15print_backtracev+0x29)[0x557f6290bc89]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z12abortHandleri+0x4a)[0x557f6291f88a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7fbb3bd13150]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7fbb3a3450bb]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16d)[0x7fbb3a346f5d]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x4110bf)[0x557f626570bf]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA8PS2Mouse11processDataEh+0x12a)[0x557f6264940a]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA5I80425writeEP6Packet+0xa2c)[0x557f6264bb5c]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN7PioPort10recvAtomicEP6Packet+0x6e)[0x557f6311eace]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15NoncoherentXBar10recvAtomicEP6Packets+0x279)[0x557f62b63969]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6Bridge15BridgeSlavePort10recvAtomicEP6Packet+0x36)[0x557f62b3a7f6]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN12CoherentXBar10recvAtomicEP6Packets+0x57b)[0x557f62b4724b]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU8writeMemEPhjm5FlagsImEPm+0x49d)[0x557f627fd12d]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN17SimpleExecContext8writeMemEPhjm5FlagsImEPm+0x29)[0x557f6280b439]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZNK10X86ISAInst2St7executeEP11ExecContextPN5Trace10InstRecordE+0x29b)[0x557f6301712b]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU4tickEv+0x3b4)[0x557f627fc054]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN10EventQueue10serviceOneEv+0xd9)[0x557f62912f79]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z9doSimLoopP10EventQueue+0x58)[0x557f6292cb88]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z8simulatem+0xc1a)[0x557f6292db7a]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x8a9c7b)[0x557f62aefc7b]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x72d5ab)[0x557f629735ab]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x6e54)[0x7fbb3bfd37e4]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7fbb3c0fdb88]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5bf0)[0x7fbb3bfd2580]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8eaa)[0x7fbb3bfd583a]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8eaa)[0x7fbb3bfd583a]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7fbb3c0fdb88]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCode+0x19)[0x7fbb3bfcc7f9]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x63a3)[0x7fbb3bfd2d33]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7fbb3c0fdb88]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5bf0)[0x7fbb3bfd2580]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7fbb3c0fdb88]
--- END LIBC BACKTRACE ---
./run: line 249: 21991 Aborted (core dumped) M5_PATH='/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/system' '/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt' '/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/configs/example/fs.py' --checkpoint-dir='./m5out/cpts/x86_64' --disk-image='/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/images/rootfs.ext2' --mem-size=256MB --num-cpus='1' --kernel=/linux-kernel-module-cheat//out/x86_64/buildroot/build/linux-custom/vmlinux --command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda nokaslr norandmaps printk.devkmsg=on printk.time=y init=/eval_base64.sh - lkmc_eval="bTUgZXhpdA=="'
....
dmesg stops at:
....
[ 0.420680] ALSA device list:
[ 0.420687] No soundcards found.
....
The following lines of a normal boot would be:
....
[ 0.684720] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[ 0.686057] ata2.00: configured for MWDMA2
[ 0.697741] scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
[ 0.699565] scsi 1:0:0:0: Attached scsi generic sg0 type 5
[ 1.229087] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input3
[ 1.234371] EXT4-fs (vda): couldn't mount as ext3 due to feature incompatibilities
[ 1.243156] EXT4-fs (vda): mounted filesystem without journal. Opts: (null)
[ 1.244443] VFS: Mounted root (ext4 filesystem) readonly on device 254:0.
....
If I append `savedefconfig` to our `kernel_config_fragment`:
....
--- BEGIN LIBC BACKTRACE ---
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z15print_backtracev+0x29)[0x559636f44c89]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z12abortHandleri+0x4a)[0x559636f5888a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7f855f8f3150]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f855df250bb]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16d)[0x7f855df26f5d]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x4110bf)[0x559636c900bf]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA8PS2Mouse11processDataEh+0x12a)[0x559636c8240a]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA5I80425writeEP6Packet+0xa2c)[0x559636c84b5c]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN7PioPort10recvAtomicEP6Packet+0x6e)[0x559637757ace]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15NoncoherentXBar10recvAtomicEP6Packets+0x279)[0x55963719c969]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6Bridge15BridgeSlavePort10recvAtomicEP6Packet+0x36)[0x5596371737f6]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN12CoherentXBar10recvAtomicEP6Packets+0x57b)[0x55963718024b]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU8writeMemEPhjm5FlagsImEPm+0x49d)[0x559636e3612d]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN17SimpleExecContext8writeMemEPhjm5FlagsImEPm+0x29)[0x559636e44439]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZNK10X86ISAInst2St7executeEP11ExecContextPN5Trace10InstRecordE+0x29b)[0x55963765012b]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU4tickEv+0x3b4)[0x559636e35054]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN10EventQueue10serviceOneEv+0xd9)[0x559636f4bf79]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z9doSimLoopP10EventQueue+0x58)[0x559636f65b88]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z8simulatem+0xc1a)[0x559636f66b7a]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x8a9c7b)[0x559637128c7b]
/linux-kernel-module-cheat//out/x86_64-gem5/buildroot/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x72d5ab)[0x559636fac5ab]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x6e54)[0x7f855fbb37e4]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7f855fcddb88]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5bf0)[0x7f855fbb2580]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8eaa)[0x7f855fbb583a]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8eaa)[0x7f855fbb583a]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7f855fcddb88]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCode+0x19)[0x7f855fbac7f9]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x63a3)[0x7f855fbb2d33]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7f855fcddb88]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5bf0)[0x7f855fbb2580]
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7d8)[0x7f855fcddb88]
--- END LIBC BACKTRACE ---
....
and dmesg stops at:
....
[ 2.803252] devtmpfs: mounted
[ 2.803885] Freeing unused kernel memory: 1024K
....
the following lines would be:
....
[ 2.827254] Freeing unused kernel memory: 2016K
[ 2.828949] Freeing unused kernel memory: 836K
[ 2.829561] rodata_test: all tests were successful
[ 2.841871] EXT4-fs (vda): re-mounted. Opts: block_validity,delalloc,barrier,user_xattr,acl
....
which is very close to the end of the boot. Increasing the memory from 256M to 512M didn't help.
=== m5
`m5` is a guest command line utility that is installed and run on the guest.
Its source is present under the gem5 main tree.
It generates magic instructions, which lead gem5 to do magic things, like `dumpstats` or `exit`.
It is however under-documented, so let's document some of its capabilities here.
Part of those explanations could be deduced from the documentation of the magic instructions themselves: http://gem5.org/M5ops
==== m5 exit
Quit gem5 with exit status 0.
@@ -4510,18 +4416,6 @@ Unfortunately-we didn't manage to find an ARM analogue: link:kernel_module/pmccn
* https://stackoverflow.com/questions/31620375/arm-cortex-a7-returning-pmccntr-0-in-kernel-mode-and-illegal-instruction-in-u/31649809#31649809
* https://blog.regehr.org/archives/794
=== gem5 limitations
* networking not working. We currently just disable it from `inittab` by default to prevent waiting at startup
==== gem5 x86_64 limitations
* gets stuck for a long time at:
+
....
[ 0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
....
== Insane action
=== Run on host
@@ -4954,8 +4848,6 @@ Why so long? I had previously documented on README 10 minutes at: 2eff007f7c3458
* update gem5 to master 2a9573f5942b5416fb0570cf5cb6cdecba733392
* larger caches: `--l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB`
One methodology problem is that some gem5 and QEMU were run with different kernel configs, due to <<gem5-qemu-config>>. This could have been improved if we normalized by instruction counts, but to do that we would have to enable tracing which makes QEMU run much slower.
But TODO: on aarch64 both use the same kernel build already, and the gem5 instruction count is much higher, why?
==== Benchmark initial build
@@ -5222,7 +5114,7 @@ ____
Runnable stuff:
* https://lwn.net/Kernel/LDD3/ the best book, but outdated. Updated source: https://github.com/martinezjavier/ldd3 But examples non-minimal and take too much brain power to understand.
* https://github.com/satoru-takeuchi/elkdat manual build process without Buildroot, very few and simple kernel modules
* https://github.com/satoru-takeuchi/elkdat manual build process without Buildroot, very few and simple kernel modules. But it seem ktest + QEMU working, which is awesome. `./test` there patches ktest config dynamically based on CLI! Maybe we should just steal it since GPL licensed.
* https://github.com/tinyclub/linux-lab Buildroot based, no kernel modules?
* https://github.com/agelastic/eudyptula
* https://github.com/linux-kernel-labs Yocto based, source inside a kernel fork subdir: https://github.com/linux-kernel-labs/linux/tree/f08b9e4238dfc612a9d019e3705bd906930057fc/tools/labs which the author would like to upstream https://www.reddit.com/r/programming/comments/79w2q9/linux_device_driver_labs_the_linux_kernel/dp6of43/

21
build
View File

@@ -29,14 +29,11 @@ while getopts 'a:B:b:CGgj:hIiK:klp:qSv' OPT; do
C)
configure=false
;;
G)
g)
extra_make_args="${extra_make_args} gem5-reconfigure \\
"
gem5=true
;;
g)
gem5=true
;;
h)
cat build-usage.adoc 1>&2
exit
@@ -106,10 +103,7 @@ case "$arch" in
defconfig=qemu_mips64r6_malta_defconfig
;;
esac
if ! "$gem5"; then
config_fragments="$config_fragments ${root_dir}/br2_qemu"
fi
config_fragments="${config_fragments} ${br2_cli_file}"
config_fragments="${config_fragments} ${root_dir}/br2_qemu ${br2_cli_file}"
# Configure.
if "$configure"; then
@@ -130,12 +124,6 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
" >> "$config_file"
if "$gem5"; then
printf "BR2_PACKAGE_GEM5=y\n" >> "${config_file}"
if [ -z "$linux_kernel_custom_config_file" ] && [ "$arch" = x86_64 ]; then
f="../kernel_config_${arch_dir}"
if [ -f "$f" ]; then
printf "BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"$f\"\n" >> "$config_file"
fi
fi
fi
if [ -n "$linux_kernel_custom_config_file" ]; then
f="../${linux_kernel_custom_config_file}"
@@ -149,8 +137,9 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
exit 1
fi
else
f=../kernel_config_fragment
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${f}\"\n" >> "$config_file"
d=../kernel_config_fragment
f="${d}/min"
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${f} ${d}/default\"\n" >> "$config_file"
if "${linux_reconfigure}"; then
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
touch "$f"

View File

@@ -4,18 +4,15 @@ set -eux
# Will take forever from a clean repo, this is most useful
# after pulling the repository to do an incremental build
# then quickly test out all the setups.
gem5=true
gem5=-g
while getopts G OPT; do
case "$OPT" in
G)
gem5=false
gem5=
;;
esac
done
shift "$(($OPTIND - 1))"
for arch in x86_64 arm aarch64; do
./build -a "$arch" -klq
if "$gem5"; then
./build -a "$arch" -Gkl
fi
./build -a "$arch" -klq $gem5
done

View File

@@ -18,14 +18,12 @@
Pass multiple times to use multiple fragment files.
|`-C` | |Skip the Buildroot configuration. Saves a few seconds,
but requires you to know what you are doing :-)
|`-g` | |Enable gem5 build and disable QEMU build. You also need
to use `-G` or `-- gem5-reconfigure` to rebuild gem5
after the initial build.
|`-g` | |Enable gem5 build or force its rebuild.
|`-h` | |Show this help message.
|`-I` | |Enable initramfs for the current build.
|`-i` | |Enable initrd for the current build.
|`-K` |`KERNEL_CONFIG_FILE` |Use `KERNEL_CONFIG_FILE` as the exact Linux kernel
configuration. Ignore the default `kernel_config_fragment`.
configuration. Ignore the default kernel config fragments.
|`-p` | |Pass extra arguments to the `rootfs_post_build_script`.
|`-S` | |Don't build QEMU with SDL support.
Graphics such as X11 won't work, only the terminal.
@@ -37,7 +35,7 @@
[options="header"]
|===
|Name |Forces rebuild of |Extra actions
|`-G` |gem5 |Implies `-g`.
|`-g` |gem5 |
|`-k` |Kernel modules |
|`-l` |Linux kernel |Touches kernel configuration files to overcome:
https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi

3
common
View File

@@ -24,9 +24,6 @@ set_common_vars() {
gem5="${2:-false}"
buildroot_dir="${root_dir}/buildroot"
arch_dir="$arch"
if "$gem5" && [ "$arch" = x86_64 ]; then
arch_dir="${arch}-gem5"
fi
out_arch_dir="${out_dir}/${arch_dir}"
buildroot_out_dir="${out_arch_dir}/buildroot"
build_dir="${buildroot_out_dir}/build"

View File

@@ -1,8 +1,3 @@
# Changes to this file are automatically trigger kernel reconfigures
# even without using the linux-reconfigure target.
#
# Timestamps are used to decide if changes happened or not.
CONFIG_BLK_DEV_INITRD=y
CONFIG_DYNAMIC_DEBUG=y
CONFIG_MODULE_SRCVERSION_ALL=y
@@ -200,22 +195,5 @@ CONFIG_DUMMY_IRQ=m
# Like CONFIG_X86_PTDUMP for ARM.
CONFIG_ARM64_PTDUMP=y
## aarch64
# For some reason not selected by the Buildroot kernel config by default as it was for arm,
# and pci modules fail to build. Not that we have PCI working on ARM anyways.
CONFIG_PCI=y
### gem5 aarch64
# Minimal options required to run gem5 aarch64 in addition to QEMU's aarch64 setup.
# Doing such a minimal boot made the gem5 boot 3x faster on the P51, which is awesome.
CONFIG_ATA_PIIX=y
CONFIG_PCI_HOST_GENERIC=y
### qemu aarch64 ext2
# Also requires gem5 aarch64 options.
# Not needed for initrd / initramfs.
CONFIG_VIRTIO_PCI=y
# For record and replay.
CONFIG_8139CP=y

View File

@@ -0,0 +1,25 @@
# This file contains only configs which are required to boot all configurations.
## gem5 x86
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
## qemu aarch64
# For some reason not selected by the Buildroot kernel config by default as it was for arm,
# and pci modules fail to build. Not that we have PCI working on ARM anyways.
CONFIG_PCI=y
## gem5 aarch64
# Minimal options required to run gem5 aarch64 in addition to QEMU's aarch64 setup.
# Doing such a minimal boot made the gem5 boot 3x faster on the P51, which is awesome.
CONFIG_ATA_PIIX=y
CONFIG_PCI_HOST_GENERIC=y
## qemu aarch64 ext2
# Also requires gem5 aarch64 options.
# Not needed for initrd / initramfs.
CONFIG_VIRTIO_PCI=y

File diff suppressed because it is too large Load Diff

2
run
View File

@@ -175,7 +175,7 @@ ${gem5opts} \
fi
cmd="\
${gem5_common} \
--command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda ${extra_append}' \\
--command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/sda ${extra_append}' \\
${extra_flags} \
"
elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then