Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,13 @@ do_steps: &do_steps

## Customize the test machine
jobs:
x86_64:
docker:
- image: lkldocker/circleci-x86_64:v1.4
environment:
CROSS_COMPILE: ""
MKARG: "dpdk=no"
<<: *do_steps

i386:
docker:
- image: lkldocker/circleci-i386:v1.4
environment:
CROSS_COMPILE: ""
<<: *do_steps

mingw32:
docker:
- image: lkldocker/circleci-mingw:v1.4
environment:
CROSS_COMPILE: "i686-w64-mingw32-"
<<: *do_steps

android-arm32:
docker:
- image: lkldocker/circleci-android-arm32:v1.4
Expand Down Expand Up @@ -147,22 +132,10 @@ jobs:
VALGRIND: 1
<<: *do_steps

x86_64_qemu:
docker:
- image: lkldocker/circleci-qemu-x86_64:v1.4
environment:
CROSS_COMPILE: ""
MKARG: "dpdk=no"
LKL_QEMU_TEST: 1
<<: *do_steps

workflows:
version: 2
build:
jobs:
- x86_64
- x86_64_qemu
- mingw32
- android-aarch64
- freebsd11_x86_64
- i386
Expand Down
29 changes: 22 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
include:
- displayTargetName: ubuntu-22.04
- displayTargetName: linux
os: unix
runs_on: ubuntu-22.04
shell: bash
Expand All @@ -38,6 +38,12 @@ jobs:
runs_on: ubuntu-22.04
shell: bash
build_options: "LLVM=1 CROSS_COMPILE=x86_64-linux-gnu"
- displayTargetName: freebsd
os: unix
runs_on: ubuntu-22.04
shell: bash
build_options: "LLVM=1 CROSS_COMPILE=x86_64-unknown-freebsd SYSROOT=~/freebsd-sysroot"
make_sysroot: "./tools/lkl/scripts/freebsd-make-sysroot.sh"
timeout-minutes: 100
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
Expand Down Expand Up @@ -109,12 +115,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt update -y
sudo apt install -y ccache libjsmn-dev libfuse3-dev
- name: Install clang toolchain
if: runner.os == 'Linux'
run: |
sudo apt update -y
sudo apt install -y clang lld llvm
sudo apt install -y ccache libjsmn-dev libfuse3-dev clang lld llvm qemu-system-x86 qemu-utils sshpass cloud-image-utils
- name: Install patched binutils for Windows
if: runner.os == 'Windows'
run: |
Expand Down Expand Up @@ -145,10 +146,24 @@ jobs:
sudo sh -c "echo 0 > /proc/sys/vm/mmap_min_addr"
echo "setting env variable (debug)"
echo "ZPOLINE_DEBUG=0" >> "$GITHUB_ENV"
- name: Start QEMU
if: matrix.displayTargetName == 'linux'
run: |
./tools/lkl/scripts/qemu-x86_64-make-images.sh
sudo chmod a+rw /dev/kvm
. tools/lkl/scripts/qemu-x86_64-start-and-set-env.sh
echo MYHOST="$HOST" >> $GITHUB_ENV
echo MYSSH="$MYSSH" >> $GITHUB_ENV
echo MYSCP="$MYSCP" >> $GITHUB_ENV
echo LKL_QEMU_TEST=1 >> $GITHUB_ENV
- name: Make sysroot
run: |
${{ matrix.make_sysroot }}
- name: Build
run: |
make -j4 -C tools/lkl ${{ matrix.build_options }}
- name: Tests
if: matrix.displayTargetName != 'freebsd'
run: mkdir junit && make -C tools/lkl run-tests tests="--junit-dir ../../junit"
- name: Save test results
uses: actions/upload-artifact@v5
Expand Down
2 changes: 1 addition & 1 deletion arch/lkl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ config PCI
select NO_GENERIC_PCI_IOPORT_MAP
select GENERIC_PCI_IOMAP
select HAS_DMA
select DMA_OPS
select ARCH_HAS_DMA_OPS
default y

config RAID6_PQ_BENCHMARK
Expand Down
9 changes: 9 additions & 0 deletions arch/lkl/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ static inline void __iounmap(void __iomem *addr)
#define iounmap __iounmap
#endif

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnull-pointer-arithmetic"
#endif

#include <asm-generic/io.h>

#ifdef __clang__
#pragma clang diagnostic pop
#endif

#endif /* _ASM_LKL_IO_H */

9 changes: 8 additions & 1 deletion arch/lkl/include/asm/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ static inline void *__memmove(void *dest, const void *src, size_t count)

#else /* __SANITIZE_ADDRESS__ */

#undef memcpy
void *__asan_memset(void *addr, int c, ssize_t len);
void *__asan_memmove(void *dest, const void *src, ssize_t len);
void *__asan_memcpy(void *dest, const void *src, ssize_t len);

#undef memset
#define memset(s, c, n) __asan_memset(s, c, n)
#undef memmove
#define memmove(dst, src, len) __asan_memmove(dst, src, len)
#undef memcpy
#define memcpy(dst, src, len) __asan_memcpy(dst, src, len)

#endif /* __SANITIZE_ADDRESS__ */

Expand Down
16 changes: 12 additions & 4 deletions tools/lkl/Makefile.autoconf
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ $(shell echo "CONFIG_$(1)=$(2)" >> $(OUTPUT)/kernel.config)
endef

define find_include
$(eval include_paths=$(shell $(CC) -E -Wp,-v -xc /dev/null 2>&1 | grep '^ '))
$(foreach f, $(include_paths), $(wildcard $(f)/$(1)))
$(eval include_paths=$(shell $(CC) $(SYSROOT_FLAGS) -E -Wp,-v -xc /dev/null 2>&1 | grep '^ '))
$(foreach f,$(include_paths),$(wildcard $(f)/$(1)))
endef

define is_defined
$(shell $(CC) -dM -E - </dev/null | grep $(1))
$(shell $(CC) $(SYSROOT_FLAGS) -dM -E - </dev/null | grep $(1))
endef

define android_host
Expand Down Expand Up @@ -139,7 +139,13 @@ endef

define llvm_target_to_ld_fmt
$(if $(filter $(CROSS_COMPILE),x86_64-linux-gnu),elf64-x86-64,\
$(error Unsupported LLVM target $(CROSS_COMPILE)))
$(if $(filter $(CROSS_COMPILE),x86_64-unknown-freebsd),elf64-x86-64-freebsd, \
$(error Unsupported LLVM target $(CROSS_COMPILE))))
endef

define llvm_sysroot
CFLAGS += --target=$(CROSS_COMPILE) --sysroot=$(SYSROOT) -I$(SYSROOT)/usr/local/include
LDFLAGS += --target=$(CROSS_COMPILE) --sysroot=$(SYSROOT) -L$(SYSROOT)/usr/local/lib
endef

define do_autoconf_llvm
Expand All @@ -153,6 +159,8 @@ define do_autoconf_llvm
$(eval LD := $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX))
$(eval CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX))
$(eval LD_FMT := $(call llvm_target_to_ld_fmt))
$(if $(SYSROOT),$(eval SYSROOT_FLAGS=--sysroot $(SYSROOT)))
$(if $(SYSROOT),$(call llvm_sysroot))
endef

define define_libprotobuf_mutator
Expand Down
3 changes: 3 additions & 0 deletions tools/lkl/lib/posix-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <sys/mman.h>
#include <poll.h>
#include <limits.h>
#ifdef __FreeBSD__
#include <pthread_np.h>
#endif
#include <lkl_host.h>
#include "iomem.h"
#include "jmp_buf.h"
Expand Down
3 changes: 1 addition & 2 deletions tools/lkl/lib/virtio_net_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#ifdef __FreeBSD__
#include <sys/syslimits.h>
#else
#include <limits.h>
#endif
#include <fcntl.h>
#include <sys/poll.h>
Expand Down
6 changes: 6 additions & 0 deletions tools/lkl/lklfuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ static int lklfuse_truncate(const char *path, off_t off,
return ret;
}

#ifdef __FreeBSD__
#define O_LARGEFILE 0
#define O_NOATIME 0
#define O_TMPFILE 0
#endif

static int lklfuse_open3(const char *path, bool create, mode_t mode,
struct fuse_file_info *fi)
{
Expand Down
24 changes: 24 additions & 0 deletions tools/lkl/scripts/freebsd-make-sysroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

function package_path()
{
grep \"name\":\"$1\" packagesite.yaml | jq -r .repopath
}

mkdir -p ~/freebsd-sysroot
cd ~/freebsd-sysroot
wget -q https://download.freebsd.org/releases/amd64/14.4-RELEASE/base.txz
tar -xf base.txz --exclude='./dev/*' --exclude='./chroot/*'

# Get FreeBSD package index...
wget -q https://pkg.freebsd.org/FreeBSD:14:amd64/latest/packagesite.pkg
tar -xf packagesite.pkg packagesite.yaml

wget -q https://pkg.freebsd.org/FreeBSD:14:amd64/latest/$(package_path argp-standalone)
wget -q https://pkg.freebsd.org/FreeBSD:14:amd64/latest/$(package_path fusefs-libs3)

tar -xf argp-standalone-*.pkg
tar -xf fusefs-libs3-*.pkg

rm fusefs-libs3-*.pkg argp-standalone-*.pkg base.txz packagesite.pkg packagesite.yaml
20 changes: 20 additions & 0 deletions tools/lkl/scripts/qemu-x86_64-make-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0

wget -q https://cloud-images.ubuntu.com/releases/noble/release-20260321/ubuntu-24.04-server-cloudimg-amd64.img
wget -q https://cloud-images.ubuntu.com/releases/noble/release-20260321/unpacked/ubuntu-24.04-server-cloudimg-amd64-vmlinuz-generic
wget -q https://cloud-images.ubuntu.com/releases/noble/release-20260321/unpacked/ubuntu-24.04-server-cloudimg-amd64-initrd-generic

dd if=/dev/zero of=nvme.img bs=1024 count=102400
cat > cloud.txt <<EOF
#cloud-config
user: lkl
password: lkl
sudo: ['ALL=(ALL) NOPASSWD:ALL']
chpasswd: { expire: False }
groups: sudo
ssh_pwauth: True
shell: /bin/bash
EOF
cloud-localds cloud.img cloud.txt
rm cloud.txt
17 changes: 17 additions & 0 deletions tools/lkl/scripts/qemu-x86_64-start-and-set-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0

qemu-system-x86_64 --enable-kvm -m 512 -machine q35,kernel-irqchip=split \
-device intel-iommu,intremap=on \
-net nic,model=e1000 -net user,hostfwd=tcp::2222-:22 \
-drive file=nvme.img,if=none,id=D22 -device nvme,drive=D22,serial=1234 \
-hda ubuntu-24.04-server-cloudimg-amd64.img -hdb cloud.img \
-kernel ubuntu-24.04-server-cloudimg-amd64-vmlinuz-generic \
-initrd ubuntu-24.04-server-cloudimg-amd64-initrd-generic \
-append 'root=LABEL=cloudimg-rootfs ro intel_iommu=on console=tty1 console=ttyS0' \
-display none -serial mon:telnet::5555,server,nowait -daemonize

SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
export MYHOST=lkl@localhost
export MYSSH="sshpass -p lkl ssh $SSH_OPTS -p 2222 $MYHOST"
export MYSCP="sshpass -p lkl scp -O $SSH_OPTS -P 2222"
Loading
Loading