Commit Graph

1218418 Commits

Author SHA1 Message Date
David Disseldorp
2f1311c005 lkl: tests: minor lkl_test_kasan changes
Grep for the kunit kasan group summary so that we can log the test +
fail count.
Use a common exit path to ensure log is always freed.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-26 16:29:55 +10:00
David Disseldorp
88a4280e01 lkl: define LKL_CONFIG_KASAN_KUNIT_TEST and use for test
CONFIG_KASAN_KUNIT_TEST is a kernel specific build option, so expose it
via the arch config.h instead of the tools-generated lkl_autoconf.h.
Both LKL_HOST_CONFIG_KASAN and LKL_HOST_CONFIG_KASAN_KUNIT_TEST are now
unused so can be removed.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-26 16:29:38 +10:00
David Disseldorp
ed768b65c9 lkl: tests: drop unused lkl_test.fn() parameters
The existing t.fn(t->arg1, t->arg2, t->arg3) call can lead to build
failures:
  tests/test.c: In function ‘lkl_test_run’:
  tests/test.c:93:23: error: too many arguments to function ‘t->fn’;
                             expected 0, have 3

The parameters don't appear to be used, so can be removed.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-26 16:22:28 +10:00
Octavian Purdila
ac5cde6a24 Merge pull request #609 from ddiss/lklfuse_rst_manpage
docs: add lklfuse manpage
2025-06-24 10:36:25 -07:00
David Disseldorp
af20691744 docs: lkl: add basic lklfuse documentation
Can be converted to a man page via rst2man.
The empty lines in the OPTIONS section aren't ideal, but it's the
simplest way to get the rst2man output on separate lines.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-24 19:18:06 +10:00
David Disseldorp
b2c2b66238 docs: lkl: move lkl documentation into subdirectory
In preparation for adding more arch specific documentation.
Add an additional F: Documentation/lkl entry to MAINTAINERS.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-24 19:17:33 +10:00
Octavian Purdila
b89fbb9686 Merge pull request #603 from ddiss/lkl_mv_autoconf_to_kconfig
move some tools/lkl/Makefile.autoconf logic to kconfig
2025-06-16 15:51:28 -07:00
David Disseldorp
c9f0472ec6 lkl: drop explicit CONFIG_SHMEM=n setting
The previous mainline commit 1f737846aa3c4 ("mm/shmem: inline
shmem_is_huge() for disabled transparent hugepages") fixes the described
build failure, so leave the CONFIG_SHMEM setting up to the user (it's
enabled by default with MMU=y).

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-12 19:56:13 +10:00
Sumanth Korikkar
66aa8b6920 mm/shmem: inline shmem_is_huge() for disabled transparent hugepages
In order to  minimize code size (CONFIG_CC_OPTIMIZE_FOR_SIZE=y),
compiler might choose to make a regular function call (out-of-line) for
shmem_is_huge() instead of inlining it. When transparent hugepages are
disabled (CONFIG_TRANSPARENT_HUGEPAGE=n), it can cause compilation
error.

mm/shmem.c: In function `shmem_getattr':
./include/linux/huge_mm.h:383:27: note: in expansion of macro `BUILD_BUG'
  383 | #define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })
      |                           ^~~~~~~~~
mm/shmem.c:1148:33: note: in expansion of macro `HPAGE_PMD_SIZE'
 1148 |                 stat->blksize = HPAGE_PMD_SIZE;

To prevent the possible error, always inline shmem_is_huge() when
transparent hugepages are disabled.

Link: https://lkml.kernel.org/r/20240409155407.2322714-1-sumanthk@linux.ibm.com
Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 1f737846aa3c45f07a06fa0d018b39e1afb8084a)
2025-06-12 19:55:00 +10:00
David Disseldorp
62514fe7a0 lkl: drop LKL_MEMORY_START and LKL_TASK_UNMAPPED_BASE autoconf
The LKL_MEMORY_START=0x50000000 and LKL_TASK_UNMAPPED_BASE=0x100000
kernel config values set in Makefile.autoconf match the arch/lkl/Kconfig
defaults, so avoid explicitly setting them.

The corresponding LKL_HOST_CONFIG_LKL_MEMORY_START/_TASK_UNMAPPED_BASE
lkl_autoconf.h consts appear to be unused, so also drop them for now.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-10 11:45:30 +10:00
David Disseldorp
cb5a9cf01c lkl: move KASAN_SHADOW_OFFSET/_SIZE defaults to Kconfig
OUTPUT_FORMAT is known within Kconfig, so we can use the same
"elf64-x86-64" specific logic when setting the defaults for
CONFIG_KASAN_SHADOW_OFFSET and CONFIG_KASAN_SHADOW_SIZE.

The LKL_HOST_CONFIG_KASAN_SHADOW_OFFSET/_SIZE autoconf variables appear
to be unused, so drop them for now. If necessary we could put them back
in arch/lkl/include/generated/uapi/asm/config.h .

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-10 11:20:03 +10:00
David Disseldorp
ba545e1875 lkl: set host memcpy/set/move defaults in Kconfig
The LKL_HOST_MEMCPY, LKL_HOST_MEMSET and LKL_HOST_MEMMOVE kernel config
parameters are currently set via tools/lkl/Makefile.autoconf based on
whether OUTPUT_FORMAT starts with "elf64" or "elf32".
Use the same logic in arch/lkl/Kconfig to set the parameter defaults and
remove the corresponding Makefile.autoconf set_kernel_config calls.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-10 11:20:03 +10:00
David Disseldorp
ad59b05d54 lkl: set CONFIG_LKL_FUZZING=y in fuzzing_defconfig
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>
2025-06-10 11:20:03 +10:00
David Disseldorp
464dd4bd08 arch/lkl: use a common helper to determine OUTPUT_FORMAT
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>
2025-06-10 11:20:03 +10:00
David Disseldorp
83549bf8e6 arch/lkl: set OUTPUT_FORMAT, 64BIT, CPU_BIG_ENDIAN defaults
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>
2025-06-10 11:20:03 +10:00
David Disseldorp
b0c5c1e6e8 lkl: remove obsolete STACK_HASH_ORDER setting
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>
2025-06-10 11:20:02 +10:00
David Disseldorp
62603ca172 arch/lkl: fix Kconfig whitespace to match rest of kernel
Use tabs instead of spaces.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-10 11:20:02 +10:00
Octavian Purdila
d2df129665 Merge pull request #605 from ddiss/windows_ci
Update Github CI Windows runner
2025-06-09 11:43:50 -07:00
Octavian Purdila
74ef2488b3 Merge pull request #602 from ddiss/lkl_fix_s390x
fix s390x big endian builds
2025-06-06 17:27:21 -07:00
David Disseldorp
5fcf33db22 lkl/ci: bump Windows openvpn version
OpenVPN-2.6.14-I001-amd64.msi is the latest, as per
https://openvpn.net/community-downloads/ .

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-06 21:30:54 +10:00
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
David Disseldorp
407010b7ca arch/lkl: use archprepare rule to generate config.h
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>
2025-06-01 21:24:24 +10:00
David Disseldorp
277a9d2e48 arch/lkl: fix "make olddefconfig" with CONFIG_CPU_BIG_ENDIAN=y
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>
2025-06-01 20:18:47 +10:00
David Disseldorp
8875a7e620 arch/lkl: drop BIG_ENDIAN from kconfig
In contrast to CONFIG_CPU_BIG_ENDIAN, CONFIG_BIG_ENDIAN isn't used
outside of arch/lkl. Remove it.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2025-06-01 20:18:47 +10:00
David Disseldorp
12f0a9f718 tools/lkl: fix s390x and big endian detection
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>
2025-06-01 20:18:47 +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