mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Use a single build for aarch64 qemu and gem5!
Document the minimal aarch64 boot. Rename -c to -B for uniformity with -b. Add help for ./run and ./build options.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
# Extensions and prefixes.
|
||||
*.html
|
||||
*.log
|
||||
*.tmp
|
||||
*~
|
||||
|
||||
195
README.adoc
195
README.adoc
@@ -127,7 +127,7 @@ Only nuke one one package:
|
||||
|
||||
....
|
||||
rm -rf buildroot/output.x86_64~/build/host-qemu-custom
|
||||
./build -q
|
||||
./build
|
||||
....
|
||||
|
||||
This is sometimes necessary when changing the version of the submodules, and then builds fail. We should try to understand why and report bugs.
|
||||
@@ -221,6 +221,7 @@ Limitations:
|
||||
--
|
||||
+
|
||||
It is also hard to enter the monitor for the same reason:
|
||||
+
|
||||
--
|
||||
* http://stackoverflow.com/questions/14165158/how-to-switch-to-qemu-monitor-console-when-running-with-curses
|
||||
* https://superuser.com/questions/488263/how-to-switch-to-the-qemu-control-panel-with-nographics
|
||||
@@ -1848,7 +1849,11 @@ We us this exact procedure to connect to <<gdbserver>>.
|
||||
|
||||
https://unix.stackexchange.com/questions/124681/how-to-ssh-from-host-to-guest-using-qemu/307557#307557
|
||||
|
||||
Uses OpenSSH's `sshd`.
|
||||
Uses OpenSSH's `sshd`, enable with the option:
|
||||
|
||||
....
|
||||
BR2_PACKAGE_OPENSSH=y
|
||||
....
|
||||
|
||||
Not enabled by default due to the build / runtime overhead, but it was tested and worked at the time of this commit.
|
||||
|
||||
@@ -1971,7 +1976,7 @@ gem5 is a system simulator, much <<gem5-vs-qemu,like QEMU>>: http://gem5.org/
|
||||
For the most part, just add the `-g` option to the QEMU commands and everything should magically work:
|
||||
|
||||
....
|
||||
./configure -gq && ./build -a arm -g
|
||||
./configure -g && ./build -a arm -g
|
||||
./run -a arm -g
|
||||
....
|
||||
|
||||
@@ -2046,15 +2051,17 @@ and the results were:
|
||||
|===
|
||||
|Emulator |Time |N times slower than QEMU
|
||||
|QEMU ARM |6 seconds |1
|
||||
|gem5 ARM AtomicSimpleCPU |1 minute 40 seconds| 17
|
||||
|gem5 ARM AtomicSimpleCPU |1 minute 40 seconds |17
|
||||
|gem5 ARM HPI |10 minutes |100
|
||||
|QEMU X86_64 |4 seconds |1
|
||||
|QEMU X86_64 KVM |2 seconds |0.5
|
||||
|gem5 X86_64 |5 minutes 30 seconds| 82
|
||||
|gem5 X86_64 |5 minutes 30 seconds |82
|
||||
|===
|
||||
|
||||
tested on the <<p51>>.
|
||||
|
||||
One methodology problem is that 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 we didn't think of that previously.
|
||||
|
||||
=== gem5 run benchmark
|
||||
|
||||
OK, this is why we used gem5 in the first place, performance measurements!
|
||||
@@ -2348,8 +2355,7 @@ There are two ways to run PARSEC with this repo:
|
||||
====== PARSEC benchmark without parsecmgmt
|
||||
|
||||
....
|
||||
configure -gpq && ./build -a arm -g -b br2_parsec
|
||||
./run -a arm -g
|
||||
configure -gpq && ./build -a arm -b br2_parsec -g && ./run -a arm -g
|
||||
....
|
||||
|
||||
Once inside the guest, launch one of the `test` input sized benchmarks manually as in:
|
||||
@@ -2403,7 +2409,7 @@ Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_EXT2_SIZE)
|
||||
The solution is to simply add:
|
||||
|
||||
....
|
||||
./build -c BR2_TARGET_ROOTFS_EXT2_SIZE="500M"
|
||||
./build -B 'BR2_TARGET_ROOTFS_EXT2_SIZE="500M"'
|
||||
....
|
||||
|
||||
where 500M is "large enough".
|
||||
@@ -2736,15 +2742,35 @@ 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 kernel build to avoid duplication, but TODO we haven't been able to get that working yet.
|
||||
We would like to be able to run both gem5 and QEMU with the same minimal kernel build to:
|
||||
|
||||
This documents our failed attempts so far.
|
||||
* do a single Buildroot build for both. Otherwise, we have to create two full `buildroot/output*` directories, which takes up a lot of time.
|
||||
+
|
||||
Alternatively, we could try to be brave and switch between two kernel builds inside `buildroot/output.*/`, 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.
|
||||
|
||||
As a result, we currently have to create two full `buildroot/output*` directories, which means two full GCC builds.
|
||||
Unfortunately, we have only managed to find a working config for aarch64, which just works transparently.
|
||||
|
||||
==== QEMU with gem5 kernel configuration
|
||||
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 ARM
|
||||
|
||||
===== QEMU with gem5 kernel configuration ARM
|
||||
|
||||
To test this, hack up `run` to use the `buildroot/output.arm-gem5~` directory, and then run:
|
||||
|
||||
@@ -2764,7 +2790,7 @@ and the display shows:
|
||||
Guest has not initialized the display (yet).
|
||||
....
|
||||
|
||||
==== gem5 with QEMU kernel configuration
|
||||
==== gem5 with QEMU kernel configuration ARM
|
||||
|
||||
Test it out with:
|
||||
|
||||
@@ -2781,7 +2807,7 @@ info: Entering event queue @ 0. Starting simulation...
|
||||
1614868500: system.terminal: attach terminal 0
|
||||
....
|
||||
|
||||
and the `telnet` at:
|
||||
and the `telnet` remains empty even after 20 minutes:
|
||||
|
||||
....
|
||||
$ ./gem5-shell
|
||||
@@ -2791,7 +2817,136 @@ Escape character is '^]'.
|
||||
==== m5 slave terminal: Terminal 0 ====
|
||||
....
|
||||
|
||||
I have also tried to copy the exact same kernel command line options used by QEMU, but nothing changed.
|
||||
Finally, it is not just an output problem, since running:
|
||||
|
||||
....
|
||||
./run -a arm -g -E 'm5 exit'
|
||||
....
|
||||
|
||||
never finishes, so boot never really finished.
|
||||
|
||||
I have also tried to do `make savedefconfig` on the gem5 kernel, and then paste that on `kernel_config_fragment`, but the boot still fails... so the only option I see left is to bisect the huge unclean `kernel_config_arm-gem5` itself...
|
||||
|
||||
==== gem5 and QEMU with the same kernel configuration x86_64
|
||||
|
||||
==== gem5 with QEMU kernel configuration x86
|
||||
|
||||
Boot fails with:
|
||||
|
||||
....
|
||||
--- BEGIN LIBC BACKTRACE ---
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z15print_backtracev+0x29)[0x557f6290bc89]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/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]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x4110bf)[0x557f626570bf]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA8PS2Mouse11processDataEh+0x12a)[0x557f6264940a]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA5I80425writeEP6Packet+0xa2c)[0x557f6264bb5c]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN7PioPort10recvAtomicEP6Packet+0x6e)[0x557f6311eace]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15NoncoherentXBar10recvAtomicEP6Packets+0x279)[0x557f62b63969]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6Bridge15BridgeSlavePort10recvAtomicEP6Packet+0x36)[0x557f62b3a7f6]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN12CoherentXBar10recvAtomicEP6Packets+0x57b)[0x557f62b4724b]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU8writeMemEPhjm5FlagsImEPm+0x49d)[0x557f627fd12d]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN17SimpleExecContext8writeMemEPhjm5FlagsImEPm+0x29)[0x557f6280b439]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZNK10X86ISAInst2St7executeEP11ExecContextPN5Trace10InstRecordE+0x29b)[0x557f6301712b]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU4tickEv+0x3b4)[0x557f627fc054]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN10EventQueue10serviceOneEv+0xd9)[0x557f62912f79]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z9doSimLoopP10EventQueue+0x58)[0x557f6292cb88]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z8simulatem+0xc1a)[0x557f6292db7a]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x8a9c7b)[0x557f62aefc7b]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/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='/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/system' '/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt' '/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/configs/example/fs.py' --checkpoint-dir='./m5out/cpts/x86_64' --disk-image='/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/images/rootfs.ext2' --mem-size=256MB --num-cpus='1' --kernel=/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64~/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 ---
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z15print_backtracev+0x29)[0x559636f44c89]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/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]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x4110bf)[0x559636c900bf]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA8PS2Mouse11processDataEh+0x12a)[0x559636c8240a]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6X86ISA5I80425writeEP6Packet+0xa2c)[0x559636c84b5c]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN7PioPort10recvAtomicEP6Packet+0x6e)[0x559637757ace]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15NoncoherentXBar10recvAtomicEP6Packets+0x279)[0x55963719c969]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN6Bridge15BridgeSlavePort10recvAtomicEP6Packet+0x36)[0x5596371737f6]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN12CoherentXBar10recvAtomicEP6Packets+0x57b)[0x55963718024b]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU8writeMemEPhjm5FlagsImEPm+0x49d)[0x559636e3612d]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN17SimpleExecContext8writeMemEPhjm5FlagsImEPm+0x29)[0x559636e44439]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZNK10X86ISAInst2St7executeEP11ExecContextPN5Trace10InstRecordE+0x29b)[0x55963765012b]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN15AtomicSimpleCPU4tickEv+0x3b4)[0x559636e35054]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_ZN10EventQueue10serviceOneEv+0xd9)[0x559636f4bf79]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z9doSimLoopP10EventQueue+0x58)[0x559636f65b88]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(_Z8simulatem+0xc1a)[0x559636f66b7a]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/build/gem5-1.0/gem5/build/X86/gem5.opt(+0x8a9c7b)[0x559637128c7b]
|
||||
/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.x86_64-gem5~/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.
|
||||
|
||||
=== gem5 limitations
|
||||
|
||||
@@ -2801,6 +2956,12 @@ I have also tried to copy the exact same kernel command line options used by QEM
|
||||
==== gem5 x86_64 limitations
|
||||
|
||||
* `gdb` debugging not working. First we need to remove the initial `set arch i386:x86-64:intel` required for QEMU. Then it cannot find the symbols.
|
||||
* gets stuck for a long time at:
|
||||
+
|
||||
....
|
||||
[ 0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
|
||||
....
|
||||
|
||||
|
||||
== Insane action
|
||||
|
||||
@@ -2880,13 +3041,13 @@ dmesg
|
||||
|
||||
We provide the following mechanisms:
|
||||
|
||||
* `./build -b br2.gitignore`: append the file `br2.gitignore` to a single build. Must be passed every time you run `./build`.
|
||||
* `./build -b br2.gitignore`: append the file `br2.gitignore` to a single build. Must be passed every time you run `./build`. A good template is provided by:
|
||||
+
|
||||
....
|
||||
cp br2.gitignore.example br2.gitignore
|
||||
....
|
||||
+
|
||||
* `./build -c 'BR2_SOM_OPTION="myval"'`: append a single option to a single build.
|
||||
* `./build -B 'BR2_SOM_OPTION="myval"'`: append a single option to a single build.
|
||||
|
||||
=== Find Buildroot options with make menuconfig
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Rename this file to just br2_local
|
||||
# If is then gitignored, and you can add your own buildroot configs here to quickly test new buildroot features.
|
||||
# Often used for new packages.
|
||||
#BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
|
||||
|
||||
#BR2_PACKAGE_OPENSSH=y
|
||||
|
||||
#BR2_PACKAGE_OPENBLAS=y
|
||||
#BR2_PACKAGE_OPENBLAS_TARGET="NEHALEM"
|
||||
|
||||
#BR2_PACKAGE_PARSEC_BENCHMARK=y
|
||||
#BR2_PACKAGE_PARSEC_BENCHMARK_BUILD_LIST="all"
|
||||
#BR2_PACKAGE_PARSEC_BENCHMARK_INPUT_SIZE="test"
|
||||
|
||||
34
build
34
build
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
help_text='
|
||||
'
|
||||
. common
|
||||
arch=x86_64
|
||||
rm -f br2_cli.gitignore
|
||||
touch br2_cli.gitignore
|
||||
@@ -14,7 +13,7 @@ linux_kernel_custom_config_file=''
|
||||
post_script_args=''
|
||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||
v=0
|
||||
while getopts 'a:b:c:Cgj:IiK:klp:qSv' OPT; do
|
||||
while getopts 'a:b:c:Cgj:hIiK:klp:qSv' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
@@ -22,7 +21,7 @@ while getopts 'a:b:c:Cgj:IiK:klp:qSv' OPT; do
|
||||
b)
|
||||
config_fragments="$config_fragments $OPTARG"
|
||||
;;
|
||||
c)
|
||||
B)
|
||||
echo "$OPTARG" >> br2_cli.gitignore
|
||||
;;
|
||||
C)
|
||||
@@ -31,6 +30,10 @@ while getopts 'a:b:c:Cgj:IiK:klp:qSv' OPT; do
|
||||
g)
|
||||
gem5=true
|
||||
;;
|
||||
h)
|
||||
cat build-usage.adoc 1>&2
|
||||
exit
|
||||
;;
|
||||
I)
|
||||
echo "
|
||||
BR2_TARGET_ROOTFS_CPIO=n
|
||||
@@ -48,12 +51,12 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
||||
j)
|
||||
echo "$OPTARG" >> br2_cli.gitignore
|
||||
;;
|
||||
k)
|
||||
extra_make_args="$extra_make_args kernel_module-reconfigure"
|
||||
;;
|
||||
K)
|
||||
linux_kernel_custom_config_file="$OPTARG"
|
||||
;;
|
||||
k)
|
||||
extra_make_args="$extra_make_args kernel_module-reconfigure"
|
||||
;;
|
||||
l)
|
||||
extra_make_args="$extra_make_args linux-reconfigure"
|
||||
;;
|
||||
@@ -73,6 +76,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
extra_make_args="$extra_make_args $@"
|
||||
set_common_vars "$arch"
|
||||
case "$arch" in
|
||||
x86_64)
|
||||
defconfig=qemu_x86_64_defconfig
|
||||
@@ -87,20 +91,14 @@ case "$arch" in
|
||||
defconfig=qemu_mips64r6_malta_defconfig
|
||||
;;
|
||||
esac
|
||||
arch_dir="$arch"
|
||||
if "$gem5"; then
|
||||
arch_dir="${arch}-gem5"
|
||||
# Networking was not working, so disable it to speed things up.
|
||||
post_script_args="$post_script_args -n"
|
||||
else
|
||||
config_fragments="$config_fragments br2_qemu"
|
||||
fi
|
||||
root_dir="$(pwd)"
|
||||
buildroot_dir="${root_dir}/buildroot"
|
||||
out_dir="${buildroot_dir}/output.${arch_dir}~"
|
||||
config_file="${out_dir}/.config"
|
||||
config_fragments="$config_fragments br2_cli.gitignore"
|
||||
|
||||
# Configure.
|
||||
if "$configure"; then
|
||||
cd "${buildroot_dir}"
|
||||
for p in $(find "${root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do
|
||||
@@ -118,8 +116,11 @@ 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" ]; then
|
||||
printf "BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"../kernel_config_${arch_dir}\"\n" >> "${config_file}"
|
||||
if [ -z "$linux_kernel_custom_config_file" ] && [ ! "$arch" = aarch64 ]; 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 [ -z "$linux_kernel_custom_config_file" ]; then
|
||||
@@ -136,6 +137,7 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"$post_script_args\"
|
||||
make O="$out_dir" olddefconfig
|
||||
fi
|
||||
|
||||
# Build.
|
||||
mkdir -p "${root_dir}/9p"
|
||||
cd "${buildroot_dir}"
|
||||
# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
|
||||
|
||||
38
build-usage.adoc
Normal file
38
build-usage.adoc
Normal file
@@ -0,0 +1,38 @@
|
||||
= build usage
|
||||
|
||||
....
|
||||
./build [OPTIONS] [-- EXTRA_MAKE_ARGS]
|
||||
....
|
||||
|
||||
[options="header"]
|
||||
|===
|
||||
|Name |Argument name | Description
|
||||
|`-a` |`ARCH` | Build for architecture `ARCH`.
|
||||
|`-b` |`BR2_FILE` | Also use the given Buildroot configuration fragment file.
|
||||
Pass multiple times to use multiple fragment files.
|
||||
|`-B` |`BR2_CONFIG` | Add a single Buildroot option to the current build.
|
||||
Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="500M"'`
|
||||
|`-c` |`BR2_FILE` | Also use the given Buildroot configuration fragment file.
|
||||
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. You also need to use `-- gem5-reconfigure`
|
||||
to rebuild gem5 after the initial build.
|
||||
|`-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`.
|
||||
You also need to `touch KERNEL_CONFIG_FILE` if that file is
|
||||
older than the latest build.
|
||||
|`-k` | | Reconfigure and rebuild the kernel module package.
|
||||
Shortcut for `-- kernel_module-reconfigure`.
|
||||
|`-l` | | Reconfigure and rebuild the linux kernel.
|
||||
Shortcut for `-- linux-reconfigure`.
|
||||
|`-p` | | Pass extra arguments to the `rootfs_post_build_script`.
|
||||
|`-q` | | Reconfigure and rebuild QEMU.
|
||||
Shortcut for `-- host-qemu-reconfigure`.
|
||||
|`-S` | | Don't build QEMU with SDL support.
|
||||
Graphics such as X11 won't work, only the terminal.
|
||||
|`-v` | | Do a verbose build.
|
||||
|===
|
||||
13
common
Normal file
13
common
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set_common_vars() {
|
||||
arch="$1"
|
||||
root_dir="$(pwd)"
|
||||
buildroot_dir="${root_dir}/buildroot"
|
||||
arch_dir="$arch"
|
||||
if "$gem5" && [ ! "$arch" = aarch64 ]; then
|
||||
arch_dir="${arch}-gem5"
|
||||
fi
|
||||
out_dir="${buildroot_dir}/output.${arch_dir}~"
|
||||
config_file="${out_dir}/.config"
|
||||
images_dir="${out_dir}/images"
|
||||
}
|
||||
7
count-boot-instructions
Executable file
7
count-boot-instructions
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
time ./run -n -e 'init=/poweroff.out' -- -trace exec_tb,file=trace
|
||||
time ./qemu/scripts/simpletrace.py buildroot/output.x86_64~/build/host-qemu-custom/trace-events-all trace >trace.txt
|
||||
wc -l trace.txt
|
||||
sed '/0x1000000/q' trace.txt >trace-boot.txt
|
||||
wc -l trace-boot.txt
|
||||
File diff suppressed because it is too large
Load Diff
@@ -93,6 +93,34 @@ CONFIG_E1000=y
|
||||
# cat /sys/kernel/debug/kernel_page_tables
|
||||
CONFIG_X86_PTDUMP=y
|
||||
|
||||
## UIO
|
||||
|
||||
# Userspace drivers: allow you to handle IRQs and do memory IO from userland through a /dev file.
|
||||
#
|
||||
# Superseded by the more featureful VFIO.
|
||||
#
|
||||
# Documentation/DocBook/uio-howto.tmpl contains actual userland examples
|
||||
# for the generic examples under drivers/uio
|
||||
#
|
||||
# UIO interface in a nutshell:
|
||||
#
|
||||
# - blocking read / poll: waits until interrupts
|
||||
# - write: call irqcontrol callback. Default: 0 or 1 to enable / disable interrupts.
|
||||
# - mmap: access device memory
|
||||
|
||||
# All other UIO depend on this module.
|
||||
CONFIG_UIO=m
|
||||
|
||||
# Generic platform devices.
|
||||
# https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
|
||||
CONFIG_UIO_DMEM_GENIRQ=m
|
||||
CONFIG_UIO_PDRV_GENIRQ=m
|
||||
|
||||
# https://github.com/rumpkernel/wiki/wiki/Howto:-Accessing-PCI-devices-from-userspace
|
||||
# /sys/class/uio/
|
||||
# /sys/class/uio/uio0
|
||||
CONFIG_UIO_PCI_GENERIC=m
|
||||
|
||||
## ARM
|
||||
|
||||
# LEDs:
|
||||
@@ -140,7 +168,7 @@ CONFIG_LEDS_TRIGGER_ONESHOT=y
|
||||
CONFIG_LEDS_TRIGGER_TIMER=y
|
||||
CONFIG_NEW_LEDS=y
|
||||
|
||||
# GPIO.
|
||||
# GPIO
|
||||
CONFIG_ARM_AMBA=y
|
||||
CONFIG_GPIOLIB=y
|
||||
CONFIG_GPIO_SYSFS=y
|
||||
@@ -161,39 +189,22 @@ CONFIG_GPIO_PL061=y
|
||||
# The IRQ number 34 was found by via dmesg on a previous "insmod /platform_device.ko".
|
||||
CONFIG_DUMMY_IRQ=m
|
||||
|
||||
## aarch64
|
||||
|
||||
# For some reason not selected 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
|
||||
|
||||
# Like CONFIG_X86_PTDUMP for ARM.
|
||||
CONFIG_ARM64_PTDUMP=y
|
||||
|
||||
## UIO
|
||||
## aarch64
|
||||
|
||||
# Userspace drivers: allow you to handle IRQs and do memory IO from userland through a /dev file.
|
||||
#
|
||||
# Superseded by the more featureful VFIO.
|
||||
#
|
||||
# Documentation/DocBook/uio-howto.tmpl contains actual userland examples
|
||||
# for the generic examples under drivers/uio
|
||||
#
|
||||
# UIO interface in a nutshell:
|
||||
#
|
||||
# - blocking read / poll: waits until interrupts
|
||||
# - write: call irqcontrol callback. Default: 0 or 1 to enable / disable interrupts.
|
||||
# - mmap: access device memory
|
||||
# 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
|
||||
|
||||
# All other UIO depend on this module.
|
||||
CONFIG_UIO=m
|
||||
### 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
|
||||
|
||||
# Generic platform devices.
|
||||
# https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt/
|
||||
CONFIG_UIO_DMEM_GENIRQ=m
|
||||
CONFIG_UIO_PDRV_GENIRQ=m
|
||||
|
||||
# https://github.com/rumpkernel/wiki/wiki/Howto:-Accessing-PCI-devices-from-userspace
|
||||
# /sys/class/uio/
|
||||
# /sys/class/uio/uio0
|
||||
CONFIG_UIO_PCI_GENERIC=m
|
||||
### qemu aarch64 ext2
|
||||
# Also requires gem5 aarch64 options.
|
||||
# Not needed for initrd / initramfs.
|
||||
CONFIG_VIRTIO_PCI=y
|
||||
|
||||
30
run
30
run
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
. common
|
||||
|
||||
# CLI handling.
|
||||
arch=x86_64
|
||||
@@ -20,7 +20,7 @@ gem5opts=''
|
||||
lkmc_eval=''
|
||||
initrd=false
|
||||
initramfs=false
|
||||
memory=128M
|
||||
memory=256M
|
||||
nographic=false
|
||||
root=''
|
||||
while getopts a:c:DdE:e:G:gIiKkm:nt:x OPT; do
|
||||
@@ -31,12 +31,12 @@ while getopts a:c:DdE:e:G:gIiKkm:nt:x OPT; do
|
||||
c)
|
||||
cpus="$OPTARG"
|
||||
;;
|
||||
d)
|
||||
extra_flags_qemu="$extra_flags_qemu -S -s"
|
||||
;;
|
||||
D)
|
||||
debug_vm='gdb -q -ex start --args'
|
||||
;;
|
||||
d)
|
||||
extra_flags_qemu="$extra_flags_qemu -S -s"
|
||||
;;
|
||||
E)
|
||||
lkmc_eval="$OPTARG"
|
||||
;;
|
||||
@@ -53,12 +53,16 @@ while getopts a:c:DdE:e:G:gIiKkm:nt:x OPT; do
|
||||
extra_flags_qemu="$extra_flags_qemu -serial tcp::1234,server,nowait"
|
||||
kgdb=true
|
||||
;;
|
||||
g)
|
||||
gem5=true
|
||||
;;
|
||||
G)
|
||||
gem5opts="$OPTARG"
|
||||
;;
|
||||
g)
|
||||
gem5=true
|
||||
;;
|
||||
h)
|
||||
cat build-usage.adoc 1>&2
|
||||
exit
|
||||
;;
|
||||
I)
|
||||
initramfs=true
|
||||
;;
|
||||
@@ -75,14 +79,7 @@ while getopts a:c:DdE:e:G:gIiKkm:nt:x OPT; do
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
extra_flags="$extra_flags $@"
|
||||
arch_dir="$arch"
|
||||
if "$gem5"; then
|
||||
arch_dir="${arch}-gem5"
|
||||
fi
|
||||
root_dir="$(pwd)"
|
||||
buildroot_dir="${root_dir}/buildroot"
|
||||
out_dir="${root_dir}/buildroot/output.${arch_dir}~"
|
||||
images_dir="${out_dir}/images"
|
||||
set_common_vars "$arch"
|
||||
if "$initrd" || "$initramfs"; then
|
||||
ramfs=true
|
||||
else
|
||||
@@ -147,7 +144,6 @@ else
|
||||
extra_flags="${extra_flags} -enable-kvm"
|
||||
fi
|
||||
extra_flags="${extra_flags_qemu} ${extra_flags}"
|
||||
images_dir="${out_dir}/images"
|
||||
qemu_common="\
|
||||
${debug_vm} \
|
||||
'${out_dir}/host/usr/bin/qemu-system-${arch}' \
|
||||
|
||||
30
run-usage.adoc
Normal file
30
run-usage.adoc
Normal file
@@ -0,0 +1,30 @@
|
||||
= run usage
|
||||
|
||||
....
|
||||
./run [OPTIONS] [-- EXTRA_RUN_ARGS]`
|
||||
....
|
||||
|
||||
[options="header"]
|
||||
|===
|
||||
|Name |Argument name | Description
|
||||
|`-a` |`ARCH` | Run architecture `ARCH`.
|
||||
|`-c` |`NCPUS` | Emulate `NCPUS` guest CPUs.
|
||||
|`-D` | | Run GDB on the emulator itself.
|
||||
|`-d` | | Run in debug mode, expect a GDB connection to guest.
|
||||
|`-E` |`CMDSTR` | Replace the normal init with a minimal init that just evals
|
||||
with given `CMDSTR` bash command string. Example:
|
||||
`-E 'insmod /hello.ko;'`
|
||||
|`-e` |`CLI_OPTIONS` | Pass an extra Linux kernel command line options.
|
||||
Example: `./run -a arm -e 'init=/poweroff.out'`
|
||||
|`-K` | | Use KVM. Only works if guest arch == host arch.
|
||||
|`-k` | | Enable KGDB.
|
||||
|`-G` | | Pass extra options to the gem5 executable.
|
||||
Only useful if `-g` is given.
|
||||
Do not confuse with the arguments passed to the config scripts,
|
||||
e.g. `fs.py`
|
||||
|`-h` | | Show this help message.
|
||||
|`-I` | | Run with initramfs.
|
||||
|`-i` | | Run with initrd.
|
||||
|`-m` | | Set the memory size of the guest. E.g.: `-m 512M`. Default: `256M`.
|
||||
|`-n` | | Run in nographic mode.
|
||||
|===
|
||||
Reference in New Issue
Block a user