Commit Graph

1218394 Commits

Author SHA1 Message Date
David Disseldorp
b2009f289c lkl/ci: use windows-2022 instead of windows-2019
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>
2025-06-06 21:28:20 +10:00
Hajime Tazaki
06837c8cde Merge pull request #599 from lrh2000/no-gettid
lkl: Remove gettid from host_ops
2025-05-13 10:45:39 +09:00
Octavian Purdila
9660999714 Merge pull request #598 from lrh2000/min-config
lkl: Drop unnecessary config selects
2025-05-11 08:55:40 -07:00
Ruihan Li
cdd533f541 lkl: Drop unnecessary config selects
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>
2025-05-11 21:15:03 +08:00
Ruihan Li
a819a6a96a lkl: Remove gettid from host_ops
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>
2025-05-11 14:10:29 +08:00
Ruihan Li
b675161b26 lkl: Use make savedefconfig to save defconfigs
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>
2025-05-10 22:12:23 +08:00
Hajime Tazaki
7a3e9893a9 Merge pull request #596 from lrh2000/pci-no
lkl: Fix builds without CONFIG_PCI
2025-04-26 20:18:55 +09:00
Hajime Tazaki
ab543443a5 Merge pull request #597 from lrh2000/pci-io-override
lkl: pci: Never override IORESOURCE_IO
2025-04-26 20:01:56 +09:00
Ruihan Li
8aba5071e1 lkl: pci: Never override IORESOURCE_IO
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>
2025-04-25 20:13:21 +08:00
Ruihan Li
8eee6cfcc4 lkl: Fix builds without CONFIG_PCI
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>
2025-04-25 19:54:46 +08:00
Octavian Purdila
f22c28bc8d Merge pull request #593 from lkl/thehajime-patch-1
lkl: bump up ubuntu image for checkpatch
2025-04-21 14:44:03 -07:00
Hajime Tazaki
cef82e94b8 lkl: bump up ubuntu image for checkpatch
ubuntu 20.04 runner isn't available recently so, update the version.

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
2025-04-21 13:46:35 +09:00
Hajime Tazaki
b6787eab58 Merge pull request #592 from thehajime/disable-zpoline-test
lkl: disable zpoline test on CI
2025-04-21 12:15:29 +09:00
Hajime Tazaki
a3ed157560 lkl: disable zpoline test on CI
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>
2025-04-21 09:11:22 +09:00
Octavian Purdila
967b585364 Merge pull request #591 from lrh2000/clean-config
lkl: Remove some obsolete configs
2025-04-14 14:04:56 -07:00
Octavian Purdila
75133a5d8b Merge pull request #590 from tavip/lkl-rm-str-dup
lkl: remove string functions duplicate implementation
2025-04-12 20:29:17 -07:00
Octavian Purdila
15a7be0d8a lkl: tests: handler lkl_init failures
Check lkl_init for failures. Print the log buffer in case of failures,
to make debugging easier.

Signed-off-by: Octavian Purdila <tavip@google.com>
2025-04-12 18:43:00 -07:00
Octavian Purdila
79fd9f4ec0 lkl: remove string functions duplicate implementation
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>
2025-04-12 18:42:59 -07:00
Ruihan Li
a436a05d87 lkl: Remove use of CONFIG_NO_BOOTMEM
CONFIG_NO_BOOTMEM has been removed in upstream by
commit b4a991ec58 ("mm: remove CONFIG_NO_BOOTMEM").

Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
2025-04-12 15:47:11 +08:00
Ruihan Li
9980eea53e lkl: Remove use of CONFIG_HAVE_MEMBLOCK
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>
2025-04-12 15:47:05 +08:00
Ruihan Li
13e7cee207 lkl: Remove use of CONFIG_ARCH_NO_COHERENT_DMA_MMAP
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>
2025-04-12 15:46:59 +08:00
Ruihan Li
0f808a2aa9 lkl: Remove use of CONFIG_FLAT_NODE_MEM_MAP
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>
2025-04-12 15:46:53 +08:00
Ruihan Li
6f08232061 lkl: Remove use of CONFIG_RWSEM_GENERIC_SPINLOCK
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>
2025-04-12 15:46:47 +08:00
Octavian Purdila
0d9fd6fd2f Merge pull request #589 from ddiss/lklfuse_test_umount
lkl: fix lklfuse.sh umount
2025-04-08 16:11:53 -07:00
David Disseldorp
7c0c1f6767 lkl: fix lklfuse.sh umount
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>
2025-04-09 00:29:29 +10:00
Octavian Purdila
04d872ad05 Merge pull request #588 from lrh2000/undef-print
lkl: Implement lkl_printf and lkl_bug internally
2025-04-07 22:33:55 -07:00
Ruihan Li
486afba4fe lkl: Implement lkl_printf and lkl_bug internally
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>
2025-04-07 13:41:02 +08:00
Octavian Purdila
b5fa7a2e8d Merge pull request #587 from lrh2000/undef-strings
lkl: Define symbols for string utilities
2025-04-06 01:44:14 -07:00
Ruihan Li
b18526a96b lkl: Define symbols for string utilities
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>
2025-04-06 15:42:19 +08:00
Hajime Tazaki
11f5b7eae2 Merge pull request #586 from rodionov/fix_output
Fix OUTPUT environment variable for LKL build.
2025-04-01 07:47:01 +09:00
Eugene Rodionov
eca6448dea Fix OUTPUT environment variable for LKL build.
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>
2025-03-30 04:47:09 +00:00
Hajime Tazaki
cab6e39ff7 Merge pull request #585 from ddiss/lkl_hijack_dbg
lkl: hijack: move dbg_handler out of liblkl
2025-03-27 17:14:12 +09:00
David Disseldorp
db1bf05fcb lkl: hijack: move dbg.c code into dbg_handler.c
dbg_entrance() is only called via the SIGTSTP signal handler setup in
lkl_register_dbg_handler().

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-03-25 10:21:58 +11:00
David Disseldorp
4abf48fdff lkl: hijack: move dbg_handler out of liblkl
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>
2025-03-25 10:09:02 +11:00
Octavian Purdila
fd33ab3d21 Merge pull request #583 from timschumi/hijack-stat-i686
lkl: Remove the stat symbol hijack
2025-03-20 12:36:48 -07:00
Tim Schumacher
5920e09fd9 lkl: Remove the stat symbol hijack
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>
2025-03-18 18:15:02 +01:00
Octavian Purdila
1219089501 Merge pull request #580 from rodionov/memmove
Add LKL arch implementation of memmove.
2025-03-04 02:39:18 -08:00
Eugene Rodionov
1f013226f1 Add LKL arch implementation of memmove.
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>
2025-03-04 00:09:16 +00:00
Octavian Purdila
79948c5e4b Merge pull request #579 from thehajime/fix-zpoline-libgcc
lkl: fix zpoline runtime issue missing libgcc_s.so
2025-03-03 10:52:22 -08:00
Hajime Tazaki
b7889946bf lkl: fix zpoline runtime issue missing libgcc_s.so
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>
2025-03-03 19:25:41 +09:00
Hajime Tazaki
76c7be7721 Merge pull request #578 from tavip/lkl-fix-windows-headers-install
lkl: fix install headers issue on Windows
2025-03-03 19:00:41 +09:00
Octavian Purdila
218748e1d4 lkl: fix install headers issue on Windows
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>
2025-03-02 20:34:44 -08:00
Octavian Purdila
cf50eae651 Merge pull request #576 from ddiss/lklfuse_cfr_lseek
lklfuse: add copy_file_range and lseek hooks
2025-02-28 09:51:09 -08:00
Octavian Purdila
9da40d4848 Merge pull request #564 from rodionov/binder_fuzzer
Android Binder fuzzer
2025-02-28 09:19:13 -08:00
David Disseldorp
727e896158 lklfuse: add lseek hook
This allows for SEEK_HOLE / SEEK_DATA, e.g.
/run/lklfuse-sda# xfs_io -f ./seekme
xfs_io> truncate 1M
xfs_io> statx -m all
  fd.path = "./seekme"
  fd.flags = non-sync,non-direct,read-write
  stat.ino = 136
  stat.type = regular file
  stat.size = 1048576
  stat.blocks = 0
  xfs_io> pwrite 100K 1k
  wrote 1024/1024 bytes at offset 102400
  1 KiB, 1 ops; 0.0002 sec (3.439 MiB/sec and 3521.1268 ops/sec)
  xfs_io> pwrite 512K 1k
  wrote 1024/1024 bytes at offset 524288
  1 KiB, 1 ops; 0.0002 sec (4.585 MiB/sec and 4694.8357 ops/sec)
  xfs_io> seek -d 0
  Whence  Result
  DATA    102400
  xfs_io> seek -h 102400
  Whence  Result
  HOLE    106496
  xfs_io> seek -d 106496
  Whence  Result
  DATA    524288

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-02-28 21:09:50 +11:00
David Disseldorp
88de85c21c lklfuse: add copy_file_range hook
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>
2025-02-28 21:08:11 +11:00
Eugene Rodionov
07b74e7afd Add LKL fuzzers tests to github CI.
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>
2025-02-27 08:07:29 +00:00
Eugene Rodionov
299753ca97 Force including Makefile.conf in tools/lkl/Makefile
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>
2025-02-27 08:07:29 +00:00
Zi Fan Tan
67836d710e Implement Android Binder libprotobuf-mutator-based fuzzer.
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>
2025-02-27 08:07:24 +00:00
Eugene Rodionov
b12183499f Fix enum install_headers.py script.
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>
2025-02-27 06:05:06 +00:00