Makefile.autoconf::do_autoconf_fuzzing sets KCONFIG=fuzzing_defconfig so
appending CONFIG_LKL_FUZZING=y to .config via tools/lkl/kernel.config
shouldn't be necessary.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The existing scripts work for GCC but restrict LLVM builds to
elf64-x86-64 only. The new cc-objdump-file-format.sh helper script works
with both gcc/clang and objdump/llvm-objdump for CC and OBJDUMP
respectively.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Kconfig makes it relatively easy to set kernel config parameters based
on compiler settings, etc. So move some of the logic from
tools/lkl/Makefile.autoconf into arch/lkl/Kconfig .
Moving non-tools specific parameters out of Makefile.autoconf should
make it easier to build LKL as a standalone library.
Signed-off-by: David Disseldorp <ddiss@suse.de>
CONFIG_STACK_HASH_ORDER was removed via mainline kernel commit
f9987921cb ("lib/stackdepot: replace CONFIG_STACK_HASH_ORDER with
automatic sizing") at around the same time as this was added via
downstream LKL commit facd006081 ("lkl: add KASAN support").
The automatic sizing uses a minimum of 12, which matches the obsolete
setting.
Signed-off-by: David Disseldorp <ddiss@suse.de>
windows-2019 is being phased out for GH actions:
This is a scheduled Windows Server 2019 brownout. The Windows Server
2019 image will be removed on 2025-06-30. For more details, see
https://github.com/actions/runner-images/issues/12045
We should be able to migrate to windows-2025, but use 2022 for now to
avoid any major surprises. A list of image differences can be found at:
https://github.com/actions/runner-images/issues/3949
Signed-off-by: David Disseldorp <ddiss@suse.de>
arch/lkl/include/generated/uapi/asm/config.h is generated at build time
with any of:
#define LKL_CONFIG_64BIT 1
#define LKL_CONFIG_CPU_BIG_ENDIAN 1
based on the build environment.
Generation is handled by Makefiles under tools/lkl, where it is then
copied to arch/lkl/include/generated/uapi/asm/config.h prior to kernel
compilation.
This change simplifies header generation by doing it directly in the
arch/lkl parent Makefile. It also improves rebuild times by only
rewriting config.h if its contents would change.
Signed-off-by: David Disseldorp <ddiss@suse.de>
LKL's final kernel config is created by appending the
tools/lkl/Makefile.autoconf generated kernel.config to .config and
then calling "make ARCH=lkl olddefconfig".
With the existing config CPU_BIG_ENDIAN setting of "def_bool n", a
.config with CONFIG_CPU_BIG_ENDIAN=y appended will drop the
CONFIG_CPU_BIG_ENDIAN=y setting when "make ARCH=lkl olddefconfig" is
called.
This issue is resolved by changing config CPU_BIG_ENDIAN to:
bool "Big-endian kernel"
default n
Signed-off-by: David Disseldorp <ddiss@suse.de>
s390x detection is broken in that filters for "elf64-s390" using the '-'
trimmed EXEC_FMT variable.
Additionally, set_kernel_config_h is called with LKL_CONFIG_ENDIAN,
which doesn't match LKL_CONFIG_BIG_ENDIAN checked for in byteorder.h.
Change this to LKL_CONFIG_CPU_BIG_ENDIAN in preparation for removing
the redundant CONFIG_BIG_ENDIAN setting.
Fixes: 0d680a3d58 ("lkl: remove CONFIG_ leaks in uapi headers")
Signed-off-by: David Disseldorp <ddiss@suse.de>
LKL can work without network support. The current Kconfig forces all LKL
builds to enable CONFIG_NET, which is not necessary.
LKL tests may still expect such features to be enabled by default, so
this commit removes the selects in Kconfig, but specifies them as
enabled in defconfigs.
End users using defconfigs should not be affected by this patch, but end
users with their own configs or allnoconfig may benefit from this patch
by having a minified kernel image.
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
host_ops.gettid is not called anywhere except in a boot test. The boot
test just checks to see if gettid returns a non-zero tid, which makes no
sense.
I suspect host_ops.gettid was added for some historical reason, but it
can now be safely removed. This commit removes it as well as the silly
test.
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
The defconfig files should be created with make savedefconfig rather
than edited manually. This command will automatically remove unnecessary
comments in .config, identify the necessary configs that need to be
listed in the defconfig file, and sort the config options properly.
If we don't use it, the contents of the defconfig files can get messy
and hard to maintain.
This commit is created via the following commands:
make ARCH=lkl defconfig
make ARCH=lkl savedefconfig
mv defconfig arch/lkl/configs/defconfig
make ARCH=lkl fuzzing_defconfig
make ARCH=lkl savedefconfig
mv defconfig arch/lkl/configs/fuzzing_defconfig
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
PCI resources can be a mix of I/O and memory resources:
pci 0000:00:00.0: reg 0x10: [mem 0xc1060000-0xc1060fff pref]
pci 0000:00:00.0: reg 0x14: [io 0x6040-0x607f]
pci 0000:00:00.0: reg 0x18: [mem 0xc1040000-0xc105ffff]
pci 0000:00:00.0: reg 0x30: [mem 0xffff0000-0xffffffff pref]
In this case, the remapped_resource variable, which is filled with the
address of the remapped memory resource in the first PCI BAR, should not
be used for the I/O resource in the second PCI BAR.
For the specific PCI device, the current code will cause errors in the
device probe routine. First, the I/O resource is overridden by some
invalid values, then the call to pci_request_regions will think the I/O
resource is illegal and fail immediately because the I/O port is not in
the normal [0, 0xffff] region.
e100 0000:00:00.0: BAR 1: can't reserve [io 0xc1060000-0xc106003f]
0000:00:00.0 (uninitialized): Cannot obtain PCI resources, aborting
e100: probe of 0000:00:00.0 failed with error -16
Fixes: 96de6a9f88 ("lkl: add PCI device interface and a vfio backend driver")
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Currently, LKL cannot be built without selecting CONFIG_PCI. This is
because pci.c is compiled unconditionally even if CONFIG_PCI is not
specified.
arch/lkl/drivers/pci.c: In function ‘lkl_pci_probe’:
arch/lkl/drivers/pci.c:219:15: error: implicit declaration of function ‘pci_scan_bus’ [-Wimplicit-function-declaration]
219 | bus = pci_scan_bus(0, &lkl_pci_root_ops, (void *)dev);
| ^~~~~~~~~~~~
This commit fixes the problem by compiling pci.c conditionally. After
this commit, pci.c will only be compiled if CONFIG_PCI is on.
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
zpoline test has been faced unstable crash on github actions on both
ubuntu 22.04 and 24.04 -based with different situations. As a result,
the CI test with zpoline is unstable (sometimes passed but sometimes
not).
This commit disables the test for a while until the root issue is
resolved. The issue is tracked at #577.
Link: https://github.com/lkl/linux/issues/577
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Now that we have the ability to set kernel config options per host
built we can avoid duplicating the implementation for string functions
that may be provided by the host (e.g. memcpy, memset).
Signed-off-by: Octavian Purdila <tavip@google.com>
CONFIG_HAVE_MEMBLOCK has been removed in upstream by
commit aca52c3983 ("mm: remove CONFIG_HAVE_MEMBLOCK").
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
CONFIG_ARCH_NO_COHERENT_DMA_MMAP has been removed in upstream by
commit 62fcee9a3b ("dma-mapping: remove
CONFIG_ARCH_NO_COHERENT_DMA_MMAP").
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
CONFIG_FLAT_NODE_MEM_MAP has been removed in upstream by
commit 43b02ba93b ("mm: replace CONFIG_FLAT_NODE_MEM_MAP with
CONFIG_FLATMEM").
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
CONFIG_RWSEM_GENERIC_SPINLOCK has been removed in upstream by
commit 390a0c62c2 ("locking/rwsem: Remove rwsem-spinlock.c & use
rwsem-xadd.c for all archs").
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Many distros use a fusermount3 binary for interacting with libfuse3
mounts to distinguish it from old libfuse2 versions.
Fixes: fc0d27b8b3 ("lklfuse: update to libfuse3")
Signed-off-by: David Disseldorp <ddiss@suse.de>
Currently, lkl.o needs the lkl_printf and lkl_bug symbols to work but
does not implement the corresponding functions. These helper functions
are implemented as part of liblkl in tools/lkl/lib/util.c.
This works, but it requires users of lkl.o to implement lkl_printf
manually. However, this does not make much sense, because lkl_printf, by
definition, is just a wrapper to host_ops->print.
In fact, lkl_printf can be implemented correctly using the utilities
from linux/stdarg.h and linux/sprintf.h, as well as the host operations
host_ops->mem_alloc and host_ops->print. See changes in this commit for
more details.
Implementing it internally in arch/lkl makes lkl.o more self-contained
and easier to use in environments without libc support (since in such
environments tool/lkl/lib/util.c may fail to compile due to missing
headers like stdio.h and stdarg.h).
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
The generated lkl.o currently still directly references string utility
symbols (e.g., memcpy and memset). This is because some kernel sources
use things like __builtin_memcpy and the compiler generates a direct
call to the memcpy method.
$ ld -o lkl.bin lkl.o
[ .. ]
lkl.o: in function `virtblk_probe':
drivers/block/virtio_blk.c:1367:(.text+0xa6c6be): undefined reference to `memset'
lkl.o: in function `virtblk_name_format':
drivers/block/virtio_blk.c:1125:(.text+0xa6c97a): undefined reference to `memmove'
drivers/block/virtio_blk.c:1126:(.text+0xa6c99c): undefined reference to `memcpy'
[ .. ]
I suspect this isn't really expected, since LKL shouldn't reference the
memcpy symbol directly, it should try to do so via host_ops first (i.e.,
make a call to lkl_ops->memcpy).
The reason is that we claim __HAVE_ARCH_MEMCPY, but we don't actually
provide the memcpy symbol. We should do that. This commit follows much
the same approach as the x86 architecture, see arch/x86/lib/memcpy_32.c
for the reference.
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
This enables building LKL outside of source tree.
```
mkdir /tmp/lkl_out
OUTPUT=/tmp/lkl_out make -C tools/lkl -j32
```
Signed-off-by: Eugene Rodionov <rodionov@google.com>
dbg_handler exposes a very useful debug shell, but it's currently only
used (within tools/lkl at least) by hijack and zpoline.
Move the functionality into liblkl-hijack, to slightly trim down the
liblkl core library.
This may break external lkl_register_dbg_handler() callers.
Signed-off-by: David Disseldorp <ddiss@suse.de>
We are hijacking `stat`, where the size of the target struct is
dependent on the wordsize. Delegating to `__xstat64` is incorrect, as it
unconditionally uses the stat64 layout and will result in an out-of-bounds
write on 32-bit architectures.
The replacement would be to use `__xstat` as the implementation instead,
but the requirements on the `vers` parameter make it hard to portably
call.
Since the symbol just delegates to the real implementation
unconditionally and therefore does not seem to have a deeper purpose,
just remove it.
Fixes: d4b9b653a1 ("lkl: update dpdk version to 17.02 from 2.2")
Signed-off-by: Tim Schumacher <timschumi@gmx.de>
Without arch implementation of memmove function KASan-enabled builds
result in linker error due to missing __asan_memmove symbol. Providing
arch implementation of memmove resolves the problem.
Signed-off-by: Eugene Rodionov <rodionov@google.com>