@@ -230,7 +230,7 @@ The safe way, is to fist quit QEMU, rebuild the modules, put them in the root fi
230
230
....
231
231
./build-modules
232
232
./build-buildroot
233
- ./run --eval-busybox 'insmod /hello.ko'
233
+ ./run --eval-after 'insmod /hello.ko'
234
234
....
235
235
236
236
`./build-buildroot` is required after `./build-modules` because it generates the root filesystem with the modules that we compiled at `./build-modules`.
@@ -241,7 +241,7 @@ You can see that `./build` does that as well, by running:
241
241
./build --dry-run
242
242
....
243
243
244
- `--eval-busybox ` is optional: you could just type `insmod /hello.ko` in the terminal, but this makes it run automatically at the end of boot, and then drops you into a shell.
244
+ `--eval-after ` is optional: you could just type `insmod /hello.ko` in the terminal, but this makes it run automatically at the end of boot, and then drops you into a shell.
245
245
246
246
If the guest and host are the same arch, typically x86_64, you can speed up boot further with <<kvm>>:
247
247
@@ -275,7 +275,7 @@ then as usual rebuild and re-run:
275
275
276
276
.....
277
277
./build-qemu
278
- ./run --eval-busybox 'grep "model name" /proc/cpuinfo'
278
+ ./run --eval-after 'grep "model name" /proc/cpuinfo'
279
279
.....
280
280
281
281
and once again, there is your message: QEMU communicated it to the Linux kernel, which printed it out.
@@ -1081,7 +1081,7 @@ It is kind of random: if you just `insmod` manually and then immediately `./run-
1081
1081
But this fails most of the time: shell 1:
1082
1082
1083
1083
....
1084
- ./run --arch arm --eval-busybox 'insmod /hello.ko'
1084
+ ./run --arch arm --eval-after 'insmod /hello.ko'
1085
1085
....
1086
1086
1087
1087
shell 2:
@@ -1170,7 +1170,7 @@ So once we find the address the first time, we can just reuse it afterwards, as
1170
1170
Do a fresh boot and get the module:
1171
1171
1172
1172
....
1173
- ./run --eval-busybox '/pr_debug.sh;insmod /fops.ko;/poweroff.out'
1173
+ ./run --eval-after '/pr_debug.sh;insmod /fops.ko;/poweroff.out'
1174
1174
....
1175
1175
1176
1176
The boot must be fresh, because the load address changes every time we insert, even after removing previous modules.
@@ -1606,7 +1606,7 @@ The implementation is described at: https://stackoverflow.com/questions/46415059
1606
1606
We can set and get which cores the Linux kernel allows a program to run on with `sched_getaffinity` and `sched_setaffinity`:
1607
1607
1608
1608
....
1609
- ./run --cpus 2 --eval-busybox '/sched_getaffinity.out'
1609
+ ./run --cpus 2 --eval-after '/sched_getaffinity.out'
1610
1610
....
1611
1611
1612
1612
Source: link:userland/sched_getaffinity.c[]
@@ -1636,7 +1636,7 @@ The number of cores is modified as explained at: <<number-of-cores>>
1636
1636
--config 'BR2_PACKAGE_UTIL_LINUX=y' \
1637
1637
--config 'BR2_PACKAGE_UTIL_LINUX_SCHEDUTILS=y' \
1638
1638
;
1639
- ./run --eval-busybox 'taskset -c 1,1 /sched_getaffinity.out'
1639
+ ./run --eval-after 'taskset -c 1,1 /sched_getaffinity.out'
1640
1640
....
1641
1641
1642
1642
output:
@@ -1658,7 +1658,7 @@ We will run our `/sched_getaffinity.out` infinitely many time, on core 0 and cor
1658
1658
./run \
1659
1659
--cpus 2 \
1660
1660
--wait-gdb \
1661
- --eval-busybox 'i=0; while true; do taskset -c $i,$i /sched_getaffinity.out; i=$((! $i)); done' \
1661
+ --eval-after 'i=0; while true; do taskset -c $i,$i /sched_getaffinity.out; i=$((! $i)); done' \
1662
1662
;
1663
1663
....
1664
1664
@@ -1690,7 +1690,7 @@ We should also try it out with kernel modules: https://stackoverflow.com/questio
1690
1690
TODO we then tried:
1691
1691
1692
1692
....
1693
- ./run --cpus 2 --eval-busybox '/sched_getaffinity_threads.out'
1693
+ ./run --cpus 2 --eval-after '/sched_getaffinity_threads.out'
1694
1694
....
1695
1695
1696
1696
and:
@@ -2217,7 +2217,7 @@ I've tried:
2217
2217
2218
2218
....
2219
2219
./run-toolchain --arch aarch64 gcc -- -static ~/test/hello_world.c -o "$(./getvar p9_dir)/a.out"
2220
- ./run --arch aarch64 --eval-busybox '/mnt/9p/data/a.out'
2220
+ ./run --arch aarch64 --eval-after '/mnt/9p/data/a.out'
2221
2221
....
2222
2222
2223
2223
but it fails with:
@@ -2373,7 +2373,7 @@ This executable is a convenient simple init that does not panic and sleeps inste
2373
2373
Get a reasonable answer to "how long does boot take?":
2374
2374
2375
2375
....
2376
- ./run --eval-busybox '/time_boot.out'
2376
+ ./run --eval-after '/time_boot.out'
2377
2377
....
2378
2378
2379
2379
Dmesg contains a message of type:
@@ -2389,10 +2389,10 @@ Bibliography: https://stackoverflow.com/questions/12683169/measure-time-taken-fo
2389
2389
[[init-busybox]]
2390
2390
=== Run command at the end of BusyBox init
2391
2391
2392
- Use the `--eval-busybox ` option is for you rely on something that BusyBox' init set up for you like `/etc/fstab`:
2392
+ Use the `--eval-after ` option is for you rely on something that BusyBox' init set up for you like `/etc/fstab`:
2393
2393
2394
2394
....
2395
- ./run --eval-busybox 'echo asdf;ls /proc;ls /sys;echo qwer'
2395
+ ./run --eval-after 'echo asdf;ls /proc;ls /sys;echo qwer'
2396
2396
....
2397
2397
2398
2398
After the commands run, you are left on an interactive shell.
@@ -2405,7 +2405,7 @@ The above command is basically equivalent to:
2405
2405
2406
2406
where the `lkmc_eval` option gets evaled by our default link:rootfs_overlay/etc/init.d/S98[S98] startup script.
2407
2407
2408
- Except that `--eval-busybox ` is smarter and uses `base64` encoding.
2408
+ Except that `--eval-after ` is smarter and uses `base64` encoding.
2409
2409
2410
2410
Alternatively, you can also add the comamdns to run to a new `init.d` entry to run at the end o the BusyBox init:
2411
2411
@@ -3059,7 +3059,7 @@ gem5 full system:
3059
3059
time \
3060
3060
./run \
3061
3061
--arch arm \
3062
- --eval-busybox '/gem5.sh' \
3062
+ --eval-after '/gem5.sh' \
3063
3063
--gem5
3064
3064
--gem5-readfile 'dhrystone 100000' \
3065
3065
;
@@ -3077,7 +3077,7 @@ QEMU full system:
3077
3077
time \
3078
3078
./run \
3079
3079
--arch arm \
3080
- --eval-busybox 'time dhrystone 100000000;/poweroff.out' \
3080
+ --eval-after 'time dhrystone 100000000;/poweroff.out' \
3081
3081
;
3082
3082
....
3083
3083
@@ -3095,7 +3095,7 @@ Result on <<p51>> at bad30f513c46c1b0995d3a10c0d9bc2a33dc4fa0:
3095
3095
link:https://git.busybox.net/busybox/tree/modutils/insmod.c?h=1_29_3[Provided by BusyBox]:
3096
3096
3097
3097
....
3098
- ./run --eval-busybox 'insmod /hello.ko'
3098
+ ./run --eval-after 'insmod /hello.ko'
3099
3099
....
3100
3100
3101
3101
=== myinsmod
@@ -4271,8 +4271,8 @@ and so it is Read Only as shown by `ro`.
4271
4271
Disable userland address space randomization. Test it out by running <<rand_check-out>> twice:
4272
4272
4273
4273
....
4274
- ./run --eval-busybox '/rand_check.out;/poweroff.out'
4275
- ./run --eval-busybox '/rand_check.out;/poweroff.out'
4274
+ ./run --eval-after '/rand_check.out;/poweroff.out'
4275
+ ./run --eval-after '/rand_check.out;/poweroff.out'
4276
4276
....
4277
4277
4278
4278
If we remove it from our link:run[] script by hacking it up, the addresses shown by `rand_check.out` vary across boots.
@@ -5027,7 +5027,7 @@ If `CONFIG_KALLSYMS=n`, then addresses are shown on traces instead of symbol plu
5027
5027
In v4.16 it does not seem possible to configure that at runtime. GDB step debugging with:
5028
5028
5029
5029
....
5030
- ./run --eval-busybox 'insmod /dump_stack.ko' --wait-gdb --tmux=dump_stack
5030
+ ./run --eval-after 'insmod /dump_stack.ko' --wait-gdb --tmux=dump_stack
5031
5031
....
5032
5032
5033
5033
shows that traces are printed at `arch/x86/kernel/dumpstack.c`:
@@ -5759,7 +5759,7 @@ Source: link:kernel_modules/work_from_work.c[]
5759
5759
Let's block the entire kernel! Yay:
5760
5760
5761
5761
.....
5762
- ./run --eval-busybox 'dmesg -n 1;insmod /schedule.ko schedule=0'
5762
+ ./run --eval-after 'dmesg -n 1;insmod /schedule.ko schedule=0'
5763
5763
.....
5764
5764
5765
5765
Outcome: the system hangs, the only way out is to kill the VM.
@@ -5773,7 +5773,7 @@ Sleep functions like `usleep_range` also end up calling schedule.
5773
5773
If we allow `schedule()` to be called, then the system becomes responsive:
5774
5774
5775
5775
.....
5776
- ./run --eval-busybox 'dmesg -n 1;insmod /schedule.ko schedule=1'
5776
+ ./run --eval-after 'dmesg -n 1;insmod /schedule.ko schedule=1'
5777
5777
.....
5778
5778
5779
5779
@@ -5786,7 +5786,7 @@ dmesg -w
5786
5786
The system also responds if we <<number-of-cores,add another core>>:
5787
5787
5788
5788
....
5789
- ./run --cpus 2 --eval-busybox 'dmesg -n 1;insmod /schedule.ko schedule=0'
5789
+ ./run --cpus 2 --eval-after 'dmesg -n 1;insmod /schedule.ko schedule=0'
5790
5790
....
5791
5791
5792
5792
==== Wait queues
@@ -5866,7 +5866,7 @@ Bibliography:
5866
5866
Brute force monitor every shared interrupt that will accept us:
5867
5867
5868
5868
....
5869
- ./run --eval-busybox 'insmod /irq.ko' --graphic
5869
+ ./run --eval-after 'insmod /irq.ko' --graphic
5870
5870
....
5871
5871
5872
5872
Source: link:kernel_modules/irq.c[].
@@ -6678,7 +6678,7 @@ Detects buffer overflows for us:
6678
6678
./build-modules --clean
6679
6679
./build-modules
6680
6680
./build-buildroot
6681
- ./run --eval-busybox 'insmod /strlen_overflow.ko' --linux-build-id fortify
6681
+ ./run --eval-after 'insmod /strlen_overflow.ko' --linux-build-id fortify
6682
6682
....
6683
6683
6684
6684
Possible dmesg output:
@@ -7186,7 +7186,7 @@ DRM / DRI is the new interface that supersedes `fbdev`:
7186
7186
....
7187
7187
./build-buildroot --config 'BR2_PACKAGE_LIBDRM=y'
7188
7188
./build-userland --has-package libdrm -- libdrm_modeset
7189
- ./run --eval-busybox '/libdrm_modeset.out' --graphic
7189
+ ./run --eval-after '/libdrm_modeset.out' --graphic
7190
7190
....
7191
7191
7192
7192
Source: link:userland/libdrm_modeset.c[]
@@ -7199,7 +7199,7 @@ TODO not working for `aarch64`, it takes over the screen for a few seconds and t
7199
7199
./build-buildroot --config 'BR2_PACKAGE_LIBDRM=y'
7200
7200
./build-userland --has-package libdrm
7201
7201
./build-buildroot
7202
- ./run --eval-busybox '/libdrm_modeset.out' --graphic
7202
+ ./run --eval-after '/libdrm_modeset.out' --graphic
7203
7203
....
7204
7204
7205
7205
<<kmscube>> however worked, which means that it must be a bug with this demo?
@@ -7224,7 +7224,7 @@ Try creating new displays:
7224
7224
to see multiple `/dev/dri/cardN`, and then use a different display with:
7225
7225
7226
7226
....
7227
- ./run --eval-busybox '/libdrm_modeset.out' --graphic
7227
+ ./run --eval-after '/libdrm_modeset.out' --graphic
7228
7228
....
7229
7229
7230
7230
Bibliography:
@@ -7412,14 +7412,14 @@ For QEMU, this is done by passing the `snapshot` option to `-drive`, and for gem
7412
7412
If you hack up our link:run[] script to remove that option, then:
7413
7413
7414
7414
....
7415
- ./run --eval-busybox 'date >f;poweroff'
7415
+ ./run --eval-after 'date >f;poweroff'
7416
7416
7417
7417
....
7418
7418
7419
7419
followed by:
7420
7420
7421
7421
....
7422
- ./run --eval-busybox 'cat f'
7422
+ ./run --eval-after 'cat f'
7423
7423
....
7424
7424
7425
7425
gives the date, because `poweroff` without `-n` syncs before shutdown.
@@ -7485,7 +7485,7 @@ qcow2 filesystems must be used for that to work.
7485
7485
To test it out, login into the VM with and run:
7486
7486
7487
7487
....
7488
- ./run --eval-busybox 'umount /mnt/9p/*;/count.sh'
7488
+ ./run --eval-after 'umount /mnt/9p/*;/count.sh'
7489
7489
....
7490
7490
7491
7491
On another shell, take a snapshot:
@@ -8279,15 +8279,15 @@ This awesome feature allows you to examine a single run as many times as you wou
8279
8279
8280
8280
....
8281
8281
# Record a run.
8282
- ./run --eval-busybox '/rand_check.out;/poweroff.out;' --record
8282
+ ./run --eval-after '/rand_check.out;/poweroff.out;' --record
8283
8283
# Replay the run.
8284
- ./run --eval-busybox '/rand_check.out;/poweroff.out;' --replay
8284
+ ./run --eval-after '/rand_check.out;/poweroff.out;' --replay
8285
8285
....
8286
8286
8287
8287
A convenient shortcut to do both at once to test the feature is:
8288
8288
8289
8289
....
8290
- ./qemu-rr --eval-busybox '/rand_check.out;/poweroff.out;'
8290
+ ./qemu-rr --eval-after '/rand_check.out;/poweroff.out;'
8291
8291
....
8292
8292
8293
8293
By comparing the terminal output of both runs, we can see that they are the exact same, including things which normally differ across runs:
@@ -8314,7 +8314,7 @@ EXT4-fs (sda): re-mounted. Opts: block_validity,barrier,user_xattr
8314
8314
TODO replay with network gets stuck:
8315
8315
8316
8316
....
8317
- ./qemu-rr --eval-busybox 'ifup -a;wget -S google.com;/poweroff.out;'
8317
+ ./qemu-rr --eval-after 'ifup -a;wget -S google.com;/poweroff.out;'
8318
8318
....
8319
8319
8320
8320
after the message:
@@ -8333,7 +8333,7 @@ Then, when I tried with <<initrd>> and no disk:
8333
8333
8334
8334
....
8335
8335
./build-buildroot --arch aarch64 -i
8336
- ./qemu-rr --arch aarch64 --eval-busybox '/rand_check.out;/poweroff.out;' -i
8336
+ ./qemu-rr --arch aarch64 --eval-after '/rand_check.out;/poweroff.out;' -i
8337
8337
....
8338
8338
8339
8339
QEMU crashes with:
@@ -8353,8 +8353,8 @@ TODO get working.
8353
8353
QEMU replays support checkpointing, and this allows for a simplistic "reverse debugging" implementation proposed at https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg00478.html on the unmerged link:https://github.com/ispras/qemu/tree/rr-180725[]:
8354
8354
8355
8355
....
8356
- ./run --eval-busybox '/rand_check.out;/poweroff.out;' --record
8357
- ./run --eval-busybox '/rand_check.out;/poweroff.out;' --replay --wait-gdb
8356
+ ./run --eval-after '/rand_check.out;/poweroff.out;' --record
8357
+ ./run --eval-after '/rand_check.out;/poweroff.out;' --replay --wait-gdb
8358
8358
....
8359
8359
8360
8360
On another shell:
@@ -8827,7 +8827,7 @@ Usage:
8827
8827
....
8828
8828
./run \
8829
8829
--arch aarch64 \
8830
- --eval-busybox '/gem5.sh' \
8830
+ --eval-after '/gem5.sh' \
8831
8831
--gem5 \
8832
8832
--gem5-readfile '/bst_vs_heap.out' \
8833
8833
;
@@ -8858,7 +8858,7 @@ Buildroot supports it, which makes everything just trivial:
8858
8858
....
8859
8859
./build-buildroot --config 'BR2_PACKAGE_OPENBLAS=y'
8860
8860
./build-userland --has-package openblas -- openblas_hello
8861
- ./run --eval-busybox '/openblas_hello.out; echo $?'
8861
+ ./run --eval-after '/openblas_hello.out; echo $?'
8862
8862
....
8863
8863
8864
8864
Outcome: the test passes:
@@ -8903,7 +8903,7 @@ Header only linear algebra library with a mainline Buildroot package:
8903
8903
Just create an array and print it:
8904
8904
8905
8905
....
8906
- ./run --eval-busybox '/eigen_hello.out'
8906
+ ./run --eval-after '/eigen_hello.out'
8907
8907
....
8908
8908
8909
8909
Output:
@@ -10921,10 +10921,10 @@ It does not work if you just download the `.zip` with the sources for this repos
10921
10921
10922
10922
=== Run command after boot
10923
10923
10924
- If you just want to run a command after boot ends without thinking much about it, just use the `--eval-busybox ` option, e.g.:
10924
+ If you just want to run a command after boot ends without thinking much about it, just use the `--eval-after ` option, e.g.:
10925
10925
10926
10926
....
10927
- ./run --eval-busybox 'echo hello'
10927
+ ./run --eval-after 'echo hello'
10928
10928
....
10929
10929
10930
10930
This option passes the command to our init scripts through <<kernel-command-line-parameters>>, and uses a few clever tricks along the way to make it just work.
@@ -11409,7 +11409,7 @@ Those packages get automatically added to Buildroot's `BR2_EXTERNAL`, so all you
11409
11409
then test it out with:
11410
11410
11411
11411
....
11412
- ./run --eval-busybox '/sample_package.out'
11412
+ ./run --eval-after '/sample_package.out'
11413
11413
....
11414
11414
11415
11415
and you should see:
@@ -11451,7 +11451,7 @@ Usage:
11451
11451
Then test one of the modules with:
11452
11452
11453
11453
....
11454
- ./run --buildroot-linux --eval-busybox 'modprobe buildroot_hello'
11454
+ ./run --buildroot-linux --eval-after 'modprobe buildroot_hello'
11455
11455
....
11456
11456
11457
11457
Source: link:buildroot_packages/kernel_modules/buildroot_hello.c[]
@@ -11686,7 +11686,7 @@ Sources:
11686
11686
Print out several parameters that normally change randomly from boot to boot:
11687
11687
11688
11688
....
11689
- ./run --eval-busybox '/rand_check.out;/poweroff.out'
11689
+ ./run --eval-after '/rand_check.out;/poweroff.out'
11690
11690
....
11691
11691
11692
11692
Source: link:userland/rand_check.c[]
0 commit comments