mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5: aarch64 graphic mode works
build: allow passing extra kernel config fragment with -c. Old -c was renamed to -C, and old -C to -f.
This commit is contained in:
52
README.adoc
52
README.adoc
@@ -297,6 +297,7 @@ More concretely:
|
|||||||
....
|
....
|
||||||
git checkout gem5-arm
|
git checkout gem5-arm
|
||||||
./build -aa -lg -K linux/arch/arm/configs/gem5_defconfig
|
./build -aa -lg -K linux/arch/arm/configs/gem5_defconfig
|
||||||
|
./run -aa -gu
|
||||||
....
|
....
|
||||||
|
|
||||||
and then on another shell:
|
and then on another shell:
|
||||||
@@ -305,15 +306,30 @@ and then on another shell:
|
|||||||
vinagre localhost:5900
|
vinagre localhost:5900
|
||||||
....
|
....
|
||||||
|
|
||||||
TODO: without the `-K` it fails even though we have added to link:kernel_config_fragment/default[] on the branch:
|
The port `5900` is incremented by one if you already have something running on that port: `gem5` stdout tells us the right port on stdout as:
|
||||||
|
|
||||||
....
|
....
|
||||||
CONFIG_DRM=y
|
system.vncserver: Listening for connections on port 5900
|
||||||
CONFIG_DRM_HDLCD=y
|
|
||||||
CONFIG_DRM_VIRT_ENCODER=y
|
|
||||||
....
|
....
|
||||||
|
|
||||||
so what other options are missing from `gem5_defconfig`? The failing dmesg is:
|
aarch64:
|
||||||
|
|
||||||
|
....
|
||||||
|
./build -aA -lg -K linux/arch/arm64/configs/gem5_defconfig -c kernel_config_fragment/gem5-aarch64-hdlcd
|
||||||
|
./run -aA -gu
|
||||||
|
....
|
||||||
|
|
||||||
|
We need the extra config fragment because the gem5 aarch64 defconfig does not enable HDLCD like the 32 bit one for some reason.
|
||||||
|
|
||||||
|
TODO: without the `-K`:
|
||||||
|
|
||||||
|
....
|
||||||
|
git checkout gem5-arm
|
||||||
|
./build -aa -lg -c kernel_config_fragment/gem5-aarch64-hdlcd
|
||||||
|
./run -aa -gu
|
||||||
|
....
|
||||||
|
|
||||||
|
it does not work with a failing dmesg:
|
||||||
|
|
||||||
....
|
....
|
||||||
[ 0.121078] [drm] found ARM HDLCD version r0p0
|
[ 0.121078] [drm] found ARM HDLCD version r0p0
|
||||||
@@ -325,6 +341,8 @@ so what other options are missing from `gem5_defconfig`? The failing dmesg is:
|
|||||||
[ 0.121197] hdlcd: probe of 2b000000.hdlcd failed with error -12
|
[ 0.121197] hdlcd: probe of 2b000000.hdlcd failed with error -12
|
||||||
....
|
....
|
||||||
|
|
||||||
|
So what other options are missing from `gem5_defconfig`? It would be cool to minimize it out to better understand the options.
|
||||||
|
|
||||||
=== Automatic startup commands
|
=== Automatic startup commands
|
||||||
|
|
||||||
When debugging a module, it becomes tedious to wait for build and re-type:
|
When debugging a module, it becomes tedious to wait for build and re-type:
|
||||||
@@ -2222,7 +2240,7 @@ TODO we were not able to get it working yet: https://stackoverflow.com/questions
|
|||||||
|
|
||||||
=== Linux kernel configuration
|
=== Linux kernel configuration
|
||||||
|
|
||||||
==== Use your own kernel config
|
==== Modify kernel config options
|
||||||
|
|
||||||
By default, we use a `.config` that is a mixture of:
|
By default, we use a `.config` that is a mixture of:
|
||||||
|
|
||||||
@@ -2237,14 +2255,24 @@ If you want to just use your own exact `.config` instead, do:
|
|||||||
|
|
||||||
Beware that Buildroot can `sed` override some of the configurations we make no matter what, e.g. it forces `CONFIG_BLK_DEV_INITRD=y` when `BR2_TARGET_ROOTFS_CPIO` is on, so you might want to double check as explained at <<find-the-kernel-config>>. TODO check if there is a way to prevent that patching and maybe patch Buildroot for it, it is too fuzzy. People should be able to just build with whatever `.config` they want.
|
Beware that Buildroot can `sed` override some of the configurations we make no matter what, e.g. it forces `CONFIG_BLK_DEV_INITRD=y` when `BR2_TARGET_ROOTFS_CPIO` is on, so you might want to double check as explained at <<find-the-kernel-config>>. TODO check if there is a way to prevent that patching and maybe patch Buildroot for it, it is too fuzzy. People should be able to just build with whatever `.config` they want.
|
||||||
|
|
||||||
==== Modify a config option
|
Modify a single option:
|
||||||
|
|
||||||
Only effective for the current build:
|
|
||||||
|
|
||||||
....
|
....
|
||||||
./build -c 'CONFIG_FORTIFY_SOURCE=y' -l
|
./build -C 'CONFIG_FORTIFY_SOURCE=y' -l
|
||||||
....
|
....
|
||||||
|
|
||||||
|
Use an extra kernel config fragment file:
|
||||||
|
|
||||||
|
....
|
||||||
|
printf '
|
||||||
|
CONFIG_IKCONFIG=y
|
||||||
|
CONFIG_IKCONFIG_PROC=y
|
||||||
|
' > myconfig
|
||||||
|
./build -c 'myconfig' -l
|
||||||
|
....
|
||||||
|
|
||||||
|
`-K`, `-c`, `-C` can all be used at the same time. Options passed via `-C` take precedence over `-c`, which takes precedence over `-K`.
|
||||||
|
|
||||||
==== Find the kernel config
|
==== Find the kernel config
|
||||||
|
|
||||||
Ge the build config in guest:
|
Ge the build config in guest:
|
||||||
@@ -3003,7 +3031,7 @@ TODO: can you get function arguments? https://stackoverflow.com/questions/276087
|
|||||||
==== Kprobes
|
==== Kprobes
|
||||||
|
|
||||||
....
|
....
|
||||||
./build -c 'CONFIG_KPROBES=y'
|
./build -C 'CONFIG_KPROBES=y'
|
||||||
./run -F 'insmod /kprobe_example.ko && sleep 4 & sleep 4 &'
|
./run -F 'insmod /kprobe_example.ko && sleep 4 & sleep 4 &'
|
||||||
....
|
....
|
||||||
|
|
||||||
@@ -3282,7 +3310,7 @@ Make it harder to get hacked and easier to notice that you were, at the cost of
|
|||||||
Enable:
|
Enable:
|
||||||
|
|
||||||
....
|
....
|
||||||
./build -c 'CONFIG_FORTIFY_SOURCE=y'
|
./build -C 'CONFIG_FORTIFY_SOURCE=y'
|
||||||
....
|
....
|
||||||
|
|
||||||
Test it out:
|
Test it out:
|
||||||
|
|||||||
31
build
31
build
@@ -15,11 +15,12 @@ extra_make_args=
|
|||||||
j="$(nproc)"
|
j="$(nproc)"
|
||||||
linux_reconfigure=false
|
linux_reconfigure=false
|
||||||
linux_kernel_custom_config_file=
|
linux_kernel_custom_config_file=
|
||||||
|
kernel_config_fragments=
|
||||||
post_script_args=
|
post_script_args=
|
||||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||||
suffix=
|
suffix=
|
||||||
v=0
|
v=0
|
||||||
while getopts 'a:B:b:Cc:Ggj:hIiK:klp:qSs:v' OPT; do
|
while getopts 'a:B:b:C:c:fGgj:hIiK:klp:qSs:v' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
arch="$OPTARG"
|
||||||
@@ -31,10 +32,13 @@ while getopts 'a:B:b:Cc:Ggj:hIiK:klp:qSs:v' OPT; do
|
|||||||
config_fragments="${config_fragments} $(common_abspath "${OPTARG}")"
|
config_fragments="${config_fragments} $(common_abspath "${OPTARG}")"
|
||||||
;;
|
;;
|
||||||
C)
|
C)
|
||||||
configure=false
|
echo "$OPTARG" >> "$kernel_config_fragment_cli_file"
|
||||||
;;
|
;;
|
||||||
c)
|
c)
|
||||||
echo "$OPTARG" >> "$kernel_config_fragment_cli_file"
|
kernel_config_fragments="${kernel_config_fragments} $(common_abspath "${OPTARG}")"
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
configure=false
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
extra_make_args="${extra_make_args} gem5-reconfigure \\
|
extra_make_args="${extra_make_args} gem5-reconfigure \\
|
||||||
@@ -145,15 +149,22 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
|
|||||||
echo "error: -K: file does not exist: ${linux_kernel_custom_config_file}" 1>&2
|
echo "error: -K: file does not exist: ${linux_kernel_custom_config_file}" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
default_config_fragments=
|
||||||
else
|
else
|
||||||
d=../kernel_config_fragment
|
default_config_fragments="${d}/min ${d}/default"
|
||||||
f="${d}/min"
|
|
||||||
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${f} ${d}/default ${kernel_config_fragment_cli_file}\"\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"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
d=../kernel_config_fragment
|
||||||
|
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${default_config_fragments} ${kernel_config_fragments} ${kernel_config_fragment_cli_file}\"\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 "${d}/min"
|
||||||
|
fi
|
||||||
|
if [ "$arch" = 'mips64' ]; then
|
||||||
|
# Workaround for:
|
||||||
|
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
|
||||||
|
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file"
|
||||||
|
fi
|
||||||
|
make O="$buildroot_out_dir" olddefconfig
|
||||||
if [ "$arch" = 'mips64' ]; then
|
if [ "$arch" = 'mips64' ]; then
|
||||||
# Workaround for:
|
# Workaround for:
|
||||||
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
|
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
|
||||||
|
|||||||
@@ -12,13 +12,18 @@
|
|||||||
|`-a` |`ARCH` |Build for architecture `ARCH`.
|
|`-a` |`ARCH` |Build for architecture `ARCH`.
|
||||||
|`-B` |`BR2_CONFIG` |Add a single Buildroot option to the current build.
|
|`-B` |`BR2_CONFIG` |Add a single Buildroot option to the current build.
|
||||||
Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="512M"'`
|
Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="512M"'`
|
||||||
|`-b` |`BR2_FILE` |Also use the given Buildroot configuration fragment file.
|
|`-b` |`BR2_CONFIG_FILE` |Also use the given Buildroot configuration fragment file.
|
||||||
Pass multiple times to use multiple fragment files.
|
Pass multiple times to use multiple fragment files.
|
||||||
|`-C` | |Skip the Buildroot configuration. Saves a few seconds,
|
|`-C` |`CONFIG_SOMETHING` |Also use the given Linux kernel configuration, example:
|
||||||
but requires you to know what you are doing :-)
|
|
||||||
|`-c` |`CONFIG_SOMETHING` |Also use the given Linux kernel configuration, example:
|
|
||||||
`./build -c 'CONFIG_FORTIFY_SOURCE=y'`
|
`./build -c 'CONFIG_FORTIFY_SOURCE=y'`
|
||||||
Can be used multiple times for multiple configs.
|
Can be used multiple times for multiple configs.
|
||||||
|
These options take precedence over `-c`.
|
||||||
|
|`-c` |`KERNEL_CONFIG_FILE` |Also use the given kernel configuration fragment file.
|
||||||
|
Pass multiple times to use multiple fragment files.
|
||||||
|
These options take precedence over `-K`.
|
||||||
|
|`-f` | |Skip the Buildroot configuration. Saves a few seconds,
|
||||||
|
but requires you to know what you are doing :-)
|
||||||
|
Mnemonic: `fast`.
|
||||||
|`-g` | |Enable gem5 build or force its rebuild.
|
|`-g` | |Enable gem5 build or force its rebuild.
|
||||||
|`-h` | |Show this help message.
|
|`-h` | |Show this help message.
|
||||||
|`-I` | |Enable initramfs for the current build.
|
|`-I` | |Enable initramfs for the current build.
|
||||||
|
|||||||
3
kernel_config_fragment/gem5-aarch64-hdlcd
Normal file
3
kernel_config_fragment/gem5-aarch64-hdlcd
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_DRM=y
|
||||||
|
CONFIG_DRM_HDLCD=y
|
||||||
|
CONFIG_DRM_VIRT_ENCODER=y
|
||||||
Reference in New Issue
Block a user