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>
Some of tests failed on zpoline build with random places, which are not
always reproducible. All of them we found shows the message below,
which this commit adds the package to silence them.
libgcc_s.so.1 must be installed for pthread_exit to work
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Windows multiprocessing support in Python has restrictions around the
use of global variables. Create an Installer class and keep the state
there instead of in global variables.
Signed-off-by: Octavian Purdila <tavip@google.com>
The copy_file_range() syscall allows filesystems to optimize a copy
workload by using reflinks or server-side offload. It can be triggered
via e.g.
xfs_io -f -c "copy_range copysrc" copydest
Without this hook, (kernel) fuse currently falls back to manual
read/write via splice_copy_file_range().
Signed-off-by: David Disseldorp <ddiss@suse.de>
Move lkl-fuzzing test from tests group into a dedicated entry. Building
fuzzers target generates fuzzer bineries and produces no test binaries
(e.g. boot, disk, etc).
Enable MMU and libprotobuf-mutator for testing LKL fuzzers in CI.
Signed-off-by: Eugene Rodionov <rodionov@google.com>
Currently Makefile.conf is included in tools/lkl/Makefile using
`-include` construct which won't generate an error if Makefile.conf is
not present which might happen due to an error while executing
Makefile.autoconf.
As Makefile.conf contains important LKL configuration options `make`
should not proceed with building targets.
Do the same for inclusion of Target and ../scripts/Makefile.include
files.
Signed-off-by: Eugene Rodionov <rodionov@google.com>
The instructions on how to build the fuzzer are provided in
tools/lkl/fuzzers/binder/README.md
Signed-off-by: Zi Fan Tan <zifantan@google.com>
Signed-off-by: Eugene Rodionov <rodionov@google.com>
Current implementation of install_headers.py doesn't handle enums which
contain complex expressions such as macro invocations. For example, in
include/uapi/linux/android/binder.h the following enums are incorrectly
parsed due to commas inside macro _IOW('c', 0, ...) in:
```
enum binder_driver_command_protocol {
BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
...
}
```
This CL implements a workaround which detect presence of macros with
brackets and ignores commas in it.
As a limitation the proposed solution isn't generic engough to handle
nested macro invocations (i.e. MACRO1(MACRO2(...))) with unlimited depth
of brackets. However it offers an improvement over existing approach.
Signed-off-by: Zi Fan Tan <zifantan@google.com>
Signed-off-by: Eugene Rodionov <rodionov@google.com>
This commit fixes an issue not to be able to configure network
interfaces via environmental variable at all. On refactoring of json
config interface, variables such as LKL_HIJACK_NET_IFTYPE was completely
ignored thus, cannot create any network interfaces.
Fixes: 254fbe1374 ("lkl-upstream: refactors json config implementation")
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>