add riscv64 kernels to kernel/Makefile and kernel/Dockerfile.*, riscv64 kernel config, bump alpine version for kernel builds

Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
Avi Deitcher 2025-01-09 17:06:37 +02:00
parent efb139697e
commit b63c7eb131
10 changed files with 13298 additions and 3146 deletions

View File

@ -274,7 +274,7 @@ your local Docker setup.
The process of modifying the kernel configuration is as follows: The process of modifying the kernel configuration is as follows:
1. Create a `linuxkit/kconfig` container image: `make kconfig`. This is not pushed out. 1. Create a `linuxkit/kconfig` container image: `make kconfig`. This is not pushed out. By default, this will be for your local architecture, but you can override it with `make kconfig ARCH=${ARCH}`, e.g. `make kconfig ARCH=arm64`. The image is tagged with the architecture, e.g. `linuxkit/kconfig:arm64`.
1. Run a container based on `linuxkit/kconfig`. 1. Run a container based on `linuxkit/kconfig`.
1. In the container, modify the config to suit your needs using normal kernel tools like `make defconfig` or `make menuconfig`. 1. In the container, modify the config to suit your needs using normal kernel tools like `make defconfig` or `make menuconfig`.
1. Save the config from the image. 1. Save the config from the image.
@ -287,7 +287,11 @@ so that `make menuconfig` and `make defconfig` work correctly.
Run the container as follows: Run the container as follows:
```sh ```sh
docker run --rm -ti -v $(pwd):/src linuxkit/kconfig docker run --rm -ti -v $(pwd):/src linuxkit/kconfig:aarch64
# or
docker run --rm -ti -v $(pwd):/src linuxkit/kconfig:x86_64
# or
docker run --rm -ti -v $(pwd):/src linuxkit/kconfig:riscv64
``` ```
This will give you a interactive shell where you can modify the kernel This will give you a interactive shell where you can modify the kernel
@ -321,6 +325,11 @@ make ARCH=arm64 defconfig
make ARCH=arm64 oldconfig # or menuconfig make ARCH=arm64 oldconfig # or menuconfig
``` ```
It is important to note that sometimes the configuration can be subtly different
when running `make defconfig` across architectures. Of note is that `make ARCH=riscv` on
x86_64 or aarch64 comes out slightly differently than when run natively on riscv64.
Feel free to try it cross, but do not be surprised if it generates outputs that are not the same.
Note that the generated file **must** be final. When you actually build the kernel, Note that the generated file **must** be final. When you actually build the kernel,
it will check that running `make defconfig` will have no changes. If there are changes, it will check that running `make defconfig` will have no changes. If there are changes,
the build will fail. the build will fail.

View File

@ -1,3 +1,3 @@
KERNEL_VERSION=6.6.13 KERNEL_VERSION=6.6.71
KERNEL_SERIES=6.6.x KERNEL_SERIES=6.6.x
BUILD_IMAGE=linuxkit/alpine:146f540f25cd92ec8ff0c5b0c98342a9a95e479e BUILD_IMAGE=linuxkit/alpine:8c02670fd2e5c28d03fd39db0bddc1379b3af6b2

File diff suppressed because it is too large Load Diff

5038
kernel/6.6.x/config-riscv64 Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -115,6 +115,9 @@ RUN case $(uname -m) in \
aarch64) \ aarch64) \
KERNEL_DEF_CONF=/linux/arch/arm64/configs/defconfig; \ KERNEL_DEF_CONF=/linux/arch/arm64/configs/defconfig; \
;; \ ;; \
riscv64) \
KERNEL_DEF_CONF=/linux/arch/riscv/configs/defconfig; \
;; \
esac && \ esac && \
cp /src/${KERNEL_SERIES}/config-$(uname -m) ${KERNEL_DEF_CONF}; \ cp /src/${KERNEL_SERIES}/config-$(uname -m) ${KERNEL_DEF_CONF}; \
if [ -n "${EXTRA}" ] && [ -f "/src/${KERNEL_SERIES}-${EXTRA}/config-$(uname -m)" ]; then \ if [ -n "${EXTRA}" ] && [ -f "/src/${KERNEL_SERIES}-${EXTRA}/config-$(uname -m)" ]; then \
@ -139,6 +142,9 @@ RUN make -j "$(getconf _NPROCESSORS_ONLN)" KCFLAGS="-fno-pie" && \
aarch64) \ aarch64) \
cp arch/arm64/boot/Image.gz /out/kernel; \ cp arch/arm64/boot/Image.gz /out/kernel; \
;; \ ;; \
riscv64) \
cp arch/riscv64/boot/Image.gz /out/kernel; \
;; \
esac && \ esac && \
cp System.map /out && \ cp System.map /out && \
([ -n "${DEBUG}" ] && cp vmlinux /out || true) ([ -n "${DEBUG}" ] && cp vmlinux /out || true)

View File

@ -24,6 +24,7 @@ RUN apk update && apk upgrade -a && \
iperf3 \ iperf3 \
libedit-dev \ libedit-dev \
libtool \ libtool \
libxml2 \
llvm \ llvm \
llvm-dev \ llvm-dev \
llvm-static \ llvm-static \

View File

@ -43,8 +43,9 @@ RUN set -e && \
patch -t -F0 -N -u -p1 < "$patch"; \ patch -t -F0 -N -u -p1 < "$patch"; \
done; \ done; \
fi && \ fi && \
[ ! -f /config-${SERIES}-x86_64 ] || mv /config-${SERIES}-x86_64 arch/x86/configs/x86_64_defconfig && \ [ ! -f /config-${SERIES}-x86_64 ] || mv /config-${SERIES}-x86_64 arch/x86/configs/x86_64_defconfig ; \
[ ! -f /config-${SERIES}-aarch64 ] || mv /config-${SERIES}-aarch64 arch/arm64/configs/defconfig ; \ [ ! -f /config-${SERIES}-aarch64 ] || mv /config-${SERIES}-aarch64 arch/arm64/configs/defconfig ; \
[ ! -f /config-${SERIES}-riscv64 ] || mv /config-${SERIES}-riscv64 arch/riscv64/configs/riscv64_defconfig ; \
done done
ENTRYPOINT ["/bin/sh"] ENTRYPOINT ["/bin/sh"]

View File

@ -58,6 +58,9 @@ for VERSION in ${KERNEL_VERSIONS}; do
elif [ ${TARGETARCH} = "arm64" ] ; then elif [ ${TARGETARCH} = "arm64" ] ; then
cp /config-${SERIES}-aarch64 .config cp /config-${SERIES}-aarch64 .config
ARCH=arm64 make oldconfig ARCH=arm64 make oldconfig
elif [ ${TARGETARCH} = "riscv64" ] ; then
cp /config-${SERIES}-riscv64 .config
ARCH=riscv64 make oldconfig
fi fi
done done
EOF EOF

View File

@ -16,7 +16,7 @@ RM = rm -f
# Name and Org on Hub # Name and Org on Hub
ORG?=linuxkit ORG?=linuxkit
IMAGE?=kernel IMAGE?=kernel
IMAGE_BUILDER=linuxkit/alpine:146f540f25cd92ec8ff0c5b0c98342a9a95e479e IMAGE_BUILDER=linuxkit/alpine:8c02670fd2e5c28d03fd39db0bddc1379b3af6b2
# You can specify an extra options for the Makefile. This will: # You can specify an extra options for the Makefile. This will:
# - append a config$(EXTRA) to the kernel config for your kernel/arch # - append a config$(EXTRA) to the kernel config for your kernel/arch
@ -37,21 +37,23 @@ endif
REPO_ROOT:=$(shell git rev-parse --show-toplevel) REPO_ROOT:=$(shell git rev-parse --show-toplevel)
# determine our architecture # determine our architecture
BUILDERARCH= ARCH?=$(shell uname -m)
BUILDERARCH=$(ARCH)
ifneq ($(ARCH),) ifneq ($(ARCH),)
ifeq ($(ARCH),$(filter $(ARCH),x86_64 amd64)) ifeq ($(ARCH),$(filter $(ARCH),x86_64 amd64))
override ARCH=x86_64 override ARCH=x86_64
BUILDERARCH=amd64 override BUILDERARCH=amd64
endif endif
ifeq ($(ARCH),$(filter $(ARCH),aarch64 arm64)) ifeq ($(ARCH),$(filter $(ARCH),aarch64 arm64))
override ARCH=aarch64 override ARCH=aarch64
BUILDERARCH=arm64 override BUILDERARCH=arm64
endif
ifeq ($(ARCH),riscv64)
override BUILDERARCH=riscv64
endif endif
endif endif
ifneq ($(BUILDERARCH),) BUILD_PLATFORM=linux/$(BUILDERARCH)
PLATFORMS=--platforms linux/$(BUILDERARCH)
endif
HASHTAG=$(HASH)$(DIRTY) HASHTAG=$(HASH)$(DIRTY)
@ -124,11 +126,11 @@ buildkerneldeps-%: Dockerfile Makefile $(wildcard patches-$(call series,$*)/*) $
buildplainkernel-%: buildkerneldeps-% buildplainkernel-%: buildkerneldeps-%
$(eval KERNEL_SERIES=$(call series,$*)) $(eval KERNEL_SERIES=$(call series,$*))
linuxkit pkg build . $(FORCE) $(PLATFORMS) --build-yml ./build-kernel.yml --tag "$*-{{.Hash}}" --build-arg-file $(KERNEL_SERIES)/build-args linuxkit pkg build . $(FORCE) --platforms $(BUILD_PLATFORM) --build-yml ./build-kernel.yml --tag "$*-{{.Hash}}" --build-arg-file $(KERNEL_SERIES)/build-args
builddebugkernel-%: buildkerneldeps-% builddebugkernel-%: buildkerneldeps-%
$(eval KERNEL_SERIES=$(call series,$*)) $(eval KERNEL_SERIES=$(call series,$*))
linuxkit pkg build . $(FORCE) $(PLATFORMS) --build-yml ./build-kernel.yml --tag "$*-dbg-{{.Hash}}" --build-arg-file $(KERNEL_SERIES)/build-args --build-arg-file build-args-debug linuxkit pkg build . $(FORCE) --platforms $(BUILD_PLATFORM) --build-yml ./build-kernel.yml --tag "$*-dbg-{{.Hash}}" --build-arg-file $(KERNEL_SERIES)/build-args --build-arg-file build-args-debug
push-%: notdirty build-% pushkernel-% tagbuilder-% pushtools-%; push-%: notdirty build-% pushkernel-% tagbuilder-% pushtools-%;
@ -163,7 +165,7 @@ buildtool-%:
$(eval TOOL=$(call toolname,$*)) $(eval TOOL=$(call toolname,$*))
$(eval KERNEL_VERSION=$(call toolkernel,$*)) $(eval KERNEL_VERSION=$(call toolkernel,$*))
$(eval KERNEL_SERIES=$(call series,$(KERNEL_VERSION))) $(eval KERNEL_SERIES=$(call series,$(KERNEL_VERSION)))
linuxkit pkg build . $(FORCE) $(PLATFORMS) --build-yml ./build-$(TOOL).yml --tag "$(KERNEL_VERSION)-{{.Hash}}" --build-arg-file $(KERNEL_SERIES)/build-args linuxkit pkg build . $(FORCE) --platforms $(BUILD_PLATFORM) --build-yml ./build-$(TOOL).yml --tag "$(KERNEL_VERSION)-{{.Hash}}" --build-arg-file $(KERNEL_SERIES)/build-args
pushtools-%: $(addprefix pushtool-%$(RELEASESEP),$(TOOLS)); pushtools-%: $(addprefix pushtool-%$(RELEASESEP),$(TOOLS));
@ -206,34 +208,34 @@ update-kernel-semver-yaml-%:
update-kernel-yamls: $(addprefix update-kernel-hash-yaml-,$(KERNELS)) update-kernel-semver-yaml-$(KERNEL_HIGHEST); update-kernel-yamls: $(addprefix update-kernel-hash-yaml-,$(KERNELS)) update-kernel-semver-yaml-$(KERNEL_HIGHEST);
# Target for kernel config # Target for kernel config
kconfig: KCONFIG_TAG_EXTENSION=
ifeq (${KCONFIG_TAG},) ifneq (${KCONFIG_TAG},)
docker build --no-cache -f Dockerfile.kconfig \ KCONFIG_TAG_EXTENSION=-${KCONFIG_TAG}
--build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \
--build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \
-t linuxkit/kconfig .
else
docker build --no-cache -f Dockerfile.kconfig \
--build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \
--build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \
-t linuxkit/kconfig:${KCONFIG_TAG} .
endif endif
kconfig:
docker build --no-cache -f Dockerfile.kconfig \
--build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \
--build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \
--platform $(BUILD_PLATFORM) \
-t linuxkit/kconfig:$(ARCH)${KCONFIG_TAG_EXTENSION} .
kconfigx: kconfigx:
ifeq (${KCONFIG_TAG},) ifeq (${KCONFIG_TAG},)
docker buildx build --no-cache -f Dockerfile.kconfigx \ docker buildx build --no-cache -f Dockerfile.kconfigx \
--platform=$(PLATFORMS) \ --platform $(BUILD_PLATFORM) \
--output . \ --output . \
--build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \ --build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \
--build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \ --build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \
-t linuxkit/kconfigx . -t linuxkit/kconfigx:$(ARCH) .
cp linux_arm64/config-${KERNEL_VERSIONS}-arm64 config-${KERNEL_SERIES}-aarch64 cp linux_arm64/config-${KERNEL_VERSIONS}-arm64 config-${KERNEL_SERIES}-aarch64
cp linux_amd64/config-${KERNEL_VERSIONS}-amd64 config-${KERNEL_SERIES}-x86_64 cp linux_amd64/config-${KERNEL_VERSIONS}-amd64 config-${KERNEL_SERIES}-x86_64
cp linux_amd64/config-${KERNEL_VERSIONS}-riscv64 config-${KERNEL_SERIES}-riscv64
else else
docker buildx build --no-cache -f Dockerfile.kconfigx \ docker buildx build --no-cache -f Dockerfile.kconfigx \
--platform=$(PLATFORMS) --push \ --platform $(BUILD_PLATFORM) --push \
--output . \ --output . \
--build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \ --build-arg KERNEL_VERSIONS="$(KERNEL_VERSIONS)" \
--build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \ --build-arg BUILD_IMAGE=$(IMAGE_BUILDER) \
-t linuxkit/kconfigx:${KCONFIG_TAG} . -t linuxkit/kconfigx:$(ARCH)${KCONFIG_TAG_EXTENSION} .
endif endif