Skip to content

Commit 15e099b

Browse files
committed
add arm64 config
Copy the CONFIG set by virtme into our own config. Use an approach inspired by merge_config.sh in the kernel source to merge our own config snippets into alldefconfig. Reusing merge_config.sh is not an option since the script is overly simplistic: it doesn't handle trying to set an option which doesn't exist at all in the kernel and prints an error. This is a problem for us since we use a single config across many kernel versions. Some features are only available in new kernels, thus tripping up merge_config.sh. Instead we use a custom script which has the same effect but which uses allyesconfig to verify whether a symbol exists. Signed-off-by: Lorenz Bauer <[email protected]>
1 parent 6ba5097 commit 15e099b

File tree

7 files changed

+191
-20
lines changed

7 files changed

+191
-20
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN --mount=type=cache,target=/tmp/kernel ./download.sh
99

1010
WORKDIR /usr/src/linux-${KERNEL_VERSION}
1111

12-
COPY configure-vmlinux.sh env.sh config .
12+
COPY configure-vmlinux.sh env.sh config config-arm64 config-x86_64 .
1313

1414
ARG KBUILD_BUILD_TIMESTAMP="Thu 6 Jul 01:00:00 UTC 2023"
1515
ARG KBUILD_BUILD_HOST="ci-kernels-builder"

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,25 @@ You can approximate CI by running `buildx.sh`:
1111
$ ./buildx.sh 6.1 amd64 vmlinux --tag foo:vmlinux
1212
```
1313

14-
# Updating the builder
14+
## Updating the configuration
15+
16+
The configuration consists of common options in [config](./config) and platform
17+
specific options in [config-arm64](./config-arm64) and [config-x64_64](./config-x86_64).
18+
19+
To add a new config option:
20+
21+
1. Try adding it to `config` (keep sorted alphabetically)
22+
2. In a checkout of the Linux source code:
23+
```shell
24+
TARGETPLATFORM=linux/arm64 /path/to/configure-vmlinux.sh
25+
```
26+
3. If any symbols are missing you can now run `make menuconfig` and search for
27+
the missing symbols. Figure out which dependencies are missing and add them
28+
to the config as well.
29+
30+
Add the config to the arch specific files if it isn't available in general.
31+
32+
## Updating the builder
1533

1634
The builder image is still built manually.
1735

config

+48-7
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,102 @@
11
# Kernel config common between arches
22

3+
# Settings needed to make the vm work.
4+
CONFIG_9P_FS=y
5+
CONFIG_BINFMT_SCRIPT=y
6+
CONFIG_BLK_DEV_INITRD=y
7+
CONFIG_DEVTMPFS=y
8+
CONFIG_NET_9P_VIRTIO=y
9+
CONFIG_NET_9P=y
10+
CONFIG_NET_CORE=y
11+
CONFIG_PCI=y
12+
CONFIG_SYSFS=y
13+
CONFIG_TMPFS=y
14+
CONFIG_TTY=y
15+
CONFIG_UNIX=y
16+
CONFIG_UNIX98_PTYS=y
17+
CONFIG_VIRTIO_CONSOLE=y
18+
CONFIG_VIRTIO_MMIO=y
19+
CONFIG_VIRTIO_NET=y
20+
CONFIG_VIRTIO_PCI=y
21+
CONFIG_VIRTIO=y
22+
CONFIG_VT=y
23+
324
# Enable BPF related things
425
# Please sort lines by alphabet ascending.
5-
# CONFIG_UPROBE_EVENT renamed to CONFIG_UPROBE_EVENTS in v4.11
26+
CONFIG_BPF_JIT_ALWAYS_ON=y
627
CONFIG_BPF_JIT=y
728
CONFIG_BPF_LIRC_MODE2=y
829
CONFIG_BPF_LSM=y
30+
CONFIG_BPF_PRELOAD=y
931
CONFIG_BPF_STREAM_PARSER=y
1032
CONFIG_BPF_SYSCALL=y
1133
CONFIG_BPF=y
1234
CONFIG_BPFILTER=y
1335
CONFIG_CGROUP_BPF=y
1436
CONFIG_CGROUP_NET_CLASSID=y
37+
CONFIG_CGROUPS=y
1538
CONFIG_DEBUG_INFO_BTF=y
39+
CONFIG_DEBUG_INFO=y
40+
CONFIG_DEBUG_KERNEL=y
41+
CONFIG_DEBUG_INFO_BTF_MODULES=y
1642
# >= 5.18 has a different toggle for debug info
1743
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
18-
CONFIG_DEBUG_INFO=y
1944
CONFIG_DYNAMIC_FTRACE=y
2045
CONFIG_EPOLL=y
2146
CONFIG_EVENTFD=y
22-
CONFIG_FPROBE=y
2347
CONFIG_FTRACE_SYSCALLS=y
48+
CONFIG_FTRACE=y
2449
CONFIG_FUNCTION_ERROR_INJECTION=y
50+
CONFIG_FUNCTION_TRACER=y
51+
CONFIG_HW_RANDOM=y
2552
CONFIG_IKCONFIG_PROC=y
2653
CONFIG_IKCONFIG=y
2754
CONFIG_INET=y
2855
CONFIG_IPV6=y
56+
CONFIG_KPROBES=y
2957
CONFIG_LIRC=y
58+
CONFIG_MEDIA_RC_SUPPORT=y
59+
CONFIG_MEDIA_SUPPORT=y
60+
CONFIG_MODULES=y
61+
CONFIG_MULTIUSER=y
3062
CONFIG_NET=y
3163
CONFIG_NETFILTER_ADVANCED=y
64+
CONFIG_NETFILTER=y
65+
CONFIG_NETWORK_FILESYSTEMS=y
3266
CONFIG_NF_CONNTRACK_MARK=y
67+
CONFIG_NF_CONNTRACK=y
68+
CONFIG_PACKET=y
3369
CONFIG_PERF_EVENTS=y
70+
CONFIG_PROC_FS=y
3471
CONFIG_RC_CORE=y
72+
CONFIG_RC_DECODERS=y
73+
CONFIG_SECURITY=y
3574
CONFIG_SECURITYFS=y
3675
CONFIG_STACK_TRACER=y
3776
CONFIG_UPROBE_EVENT=y
3877
CONFIG_UPROBE_EVENTS=y
3978
CONFIG_XDP_SOCKETS=y
4079

4180
# VirtIO
42-
CONFIG_KVM_GUEST=y
4381
CONFIG_HW_RANDOM_VIRTIO=y
4482
CONFIG_VIRTIO_BALLOON=y
4583

46-
# Get rid of some drivers
47-
CONFIG_AGP=n
84+
# Get rid of some drivers and obsolete features
4885
CONFIG_ATA=n
4986
CONFIG_DRM=n
5087
CONFIG_ETHERNET=n
88+
CONFIG_EXT3_FS=n
5189
CONFIG_EXT4_FS=n
5290
CONFIG_FDDI=n
53-
CONFIG_HID_GENERIC=n
5491
CONFIG_HID=n
92+
CONFIG_INPUT_KEYBOARD=n
93+
CONFIG_INPUT_MOUSE=n
94+
CONFIG_INPUT_MOUSEDEV=n
5595
CONFIG_MD=n
5696
CONFIG_NFS_FS=n
5797
CONFIG_PCCARD=n
5898
CONFIG_SOUND=n
99+
CONFIG_UEVENT_HELPER=n
59100
CONFIG_USB_SUPPORT=n
60101
CONFIG_WIRELESS=n
61102
CONFIG_WLAN=n

config-arm64

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# arm64 specific configuration
2+
3+
CONFIG_PCI_HOST_GENERIC=y
4+
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
5+
CONFIG_SERIAL_AMBA_PL011=y
6+
CONFIG_SERIAL_EARLYCON=y

config-x86_64

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# amd64 specific configuration
2+
3+
CONFIG_DEBUG_INFO_NONE=n
4+
CONFIG_DYNAMIC_FTRACE_WITH_REGS=y
5+
CONFIG_EARLY_PRINTK=y
6+
CONFIG_FPROBE=y
7+
CONFIG_HYPERVISOR_GUEST=y
8+
CONFIG_KVM_GUEST=y
9+
CONFIG_MAXSMP=y
10+
CONFIG_PARAVIRT=y
11+
12+
# Get rid of some drivers and obsolete features
13+
CONFIG_AGP=n

configure-vmlinux.sh

+96-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,104 @@
11
#!/bin/bash
2-
# vmlinux.sh
2+
# configure-vmlinux.sh
33

44
set -eu
55
set -o pipefail
66

7-
source env.sh
7+
dir="$(dirname "$(realpath "$0")")"
88

9-
empty_lsmod="$(mktemp)"
10-
readonly empty_lsmod
9+
source "$dir/env.sh"
1110

12-
make KCONFIG_CONFIG=custom.config defconfig
13-
tee -a < "config" custom.config
14-
make allnoconfig KCONFIG_ALLCONFIG=custom.config
15-
virtme-configkernel --update
16-
make localmodconfig LSMOD="${empty_lsmod}"
11+
# read_config array file
12+
# read a file in Kconfig format into an associative array.
13+
#
14+
# Valid values are "y", "n", "m". Unset options are turned into "n".
15+
read_config() {
16+
local -n arr=$1
17+
local file=$2
18+
19+
while IFS='=' read -r cfg value
20+
do
21+
if [[ -v arr[$cfg] ]]; then
22+
echo "Error: $cfg is redefined by $file."
23+
exit 1
24+
fi
25+
26+
arr[$cfg]=$value
27+
done < <(sed -E 's/^# (CONFIG_.+) is not set$/\1=n/; /^\#/d; /^$/d' "$file")
28+
}
29+
30+
# Figure out all valid options
31+
# allconfig doesn't contain all config, since Kconfig seems to omit
32+
# some implicit options like CONFIG_DEBUG_INFO. This is the best I can come
33+
# up with.
34+
declare -A allconfig
35+
make allyesconfig > /dev/null
36+
read_config allconfig .config
37+
38+
# Use defconfig as the base
39+
declare -A config
40+
make defconfig
41+
read_config config .config
42+
43+
# Remove all modules
44+
for cfg in "${!config[@]}"; do
45+
if [[ "${config[$cfg]}" == "m" ]]; then
46+
unset config[$cfg]
47+
fi
48+
done
49+
50+
# Merge configuration snippets
51+
declare -A overrides
52+
for file in "$dir/config" "$dir/config-$ARCH"; do
53+
echo "Merging $file"
54+
read_config overrides "$file"
55+
done
56+
57+
for cfg in "${!overrides[@]}"; do
58+
echo "$cfg=${overrides[$cfg]}"
59+
config[$cfg]="${overrides[$cfg]}"
60+
done
61+
62+
rm .config
63+
for cfg in "${!config[@]}"; do
64+
echo "$cfg=${config[$cfg]}" >> .config
65+
done
66+
67+
# Add missing configuration options.
1768
make olddefconfig
69+
70+
# Validate that all the options have the value we want.
71+
declare -A effective
72+
read_config effective .config
73+
74+
status=0
75+
for cfg in "${!overrides[@]}"; do
76+
if [[ ! -v effective[$cfg] ]]; then
77+
if [[ ! -v allconfig[$cfg] ]]; then
78+
echo "Ignoring unrecognised option $cfg"
79+
continue
80+
fi
81+
82+
echo "Option $cfg: not present in config"
83+
status=1
84+
continue
85+
fi
86+
87+
want="${overrides[$cfg]}"
88+
have="${effective[$cfg]}"
89+
case "$want" in
90+
y|n|m)
91+
if [[ "$have" != "$want" ]]; then
92+
echo "Option $cfg: expected '$want', found '$have'"
93+
status=1
94+
fi
95+
;;
96+
97+
*)
98+
echo "Option $cfg: don't know how to handle '$want'"
99+
status=1
100+
;;
101+
esac
102+
done
103+
104+
exit $status

env.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
44
ARCH=x86_64
5-
CROSS_COMPILE="ccache x86_64-linux-gnu-"
5+
CROSS_COMPILE="x86_64-linux-gnu-"
66
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
7-
ARCH=arm64 CROSS_COMPILE="ccache aarch64-linux-gnu-"
7+
ARCH=arm64
8+
CROSS_COMPILE="aarch64-linux-gnu-"
89
else
910
echo "Unsupported target platform"; exit 1;
1011
fi
12+
13+
if command -v ccache > /dev/null; then
14+
CROSS_COMPILE="ccache $CROSS_COMPILE"
15+
fi
16+
1117
export ARCH CROSS_COMPILE

0 commit comments

Comments
 (0)