fuse tests are skipped if lklfuse is not found, assuming that fuse was
not enabled. Be more strict and check the host autoconf instead.
Signed-off-by: Octavian Purdila <tavip@google.com>
The previous filter accepted non-usb block devices, which resulted in
unexpected EFI partition mounts. Split the filter and check for
ENV{ID_BUS}!="usb". Tested on systemd-udevd 254 and 257 systems.
Signed-off-by: David Disseldorp <ddiss@suse.de>
lklfuse, fs2tar and cptofs were accidentally dropped from the default
build target via a typo in commit 6d360d164e ("lkl: link tests
against common private library").
The install target was still triggering progs-y builds, which is
probably why this took longer to notice than expected.
Fixes: 6d360d164e ("lkl: link tests against common private library")
Signed-off-by: David Disseldorp <ddiss@suse.de>
This effectively reverts commit 3c97822a40 ("lkl: add tests build
barrier"), replacing the tests .WAIT barrier with a common-object
prerequisite to keep parallel builds working.
Prerequisites are preferable to explicit .WAIT barriers, as they better
allow for build concurrency and also avoid install target breakage
described in the previous commit.
One minor drawback is that some of the test binaries don't use any
cla.o symbols, but get linked nevertheless. E.g. Before:
text data bss dec hex filename
7878818 4851995 885880 13616693 cfc635 tools/lkl/tests/boot
After:
text data bss dec hex filename
7880494 4852094 885856 13618444 cfcd0c tools/lkl/tests/boot
I don't see it as a problem, but if it is then we could split up the
prerequisites.
Signed-off-by: David Disseldorp <ddiss@suse.de>
This is a follow up change for commit 3c97822a40 ("lkl: add tests
build barrier") tracked via https://github.com/lkl/linux/issues/558.
The hijack and zpoline libraries also share object files, so need extra
logic to avoid parallel build failures.
Add a new intermediate libhijack-priv-in.o prerequisite for the hijack
libraries, avoiding the .WAIT target which breaks make libraries_install
on older (e.g. 4.2.1) versions of make.
The existing liblkl$(SOSUF) target is currently unmatched, so fix it and
use it as a linker target which omits libhijack-priv-in.o.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The sleep appears to have been there since the initial tests were added.
It shouldn't be necessary so remove it.
Signed-off-by: David Disseldorp <ddiss@suse.de>
This tests that two lklfuse instances using the same lock file result
in a lock conflict (exit status 2) for the instance started last.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Use an ID_FS_UUID based lock file to avoid duplicate mounts.
If udev doesn't provide an id then use a static noid path, ensuring lock
conflict with any other id-less mount.
Signed-off-by: David Disseldorp <ddiss@suse.de>
This lock-while-mounted behaviour is similar to what QEMU does, and can
help avoid duplicate mounts.
Allowing for an explicit lock path that differs from the filesystem
image / block device path was intentional, to ensure non-flock
supporting filesystems can still be used. Also, there are cases where
a block device and partition (e.g. sda and sda1) can both provide access
to the same filesystem image, in which case an FS-ID based lock would
make sense.
Signed-off-by: David Disseldorp <ddiss@suse.de>
HOST_CALL() uses a (*host_##name)() function pointer while callers
provide regular syscall parameters. With gcc -std=gnu23 this results in:
lib/hijack/hijack.c: In function ‘hijack_setsockopt’:
lib/hijack/hijack.c:176:24: error: too many arguments to function ‘host_setsockopt’; expected 0, have 5
176 | return host_setsockopt(fd, level, optname, optval, optlen);
| ^~~~~~~~~~~~~~~ ~~
Signed-off-by: David Disseldorp <ddiss@suse.de>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This matches the behaviour of Linux mount helper, e.g.
mount("/dev/loop0p1", "/mnt", "iso9660", 0, NULL) = -1 EACCES
mount("/dev/loop0p1", "/mnt", "iso9660", MS_RDONLY, NULL) = 0
WARNING: source write-protected, mounted read-only.
Signed-off-by: David Disseldorp <ddiss@suse.de>
preadv and pwritev have been around for a long time, and should be
usable on BSD and Linux (v2.6.30, glibc 2.10, Bionic API level 24).
Short reads or writes trigger fallback to the old do_rw() handler.
Signed-off-by: David Disseldorp <ddiss@suse.de>
lklfuse-mount@.service:
Mount a block device (specified via @instance) using lklfuse. The
lklfuse binary is run as an unprivileged "lklfuse" user. The
fuse "allow_other" mount option is used to provide access for users
other than "lklfuse", and requires a "user_allow_other" setting in
fuse3.conf
61-lklfuse.rules:
Detect USB block device add/remove events and start/stop the
lklfuse-mount@<dev> service. Block device ownership changed to provide
unprivileged "lklfuse" user access.
Signed-off-by: David Disseldorp <ddiss@suse.de>
This satisfies "gcc -Werror=strict-prototypes" and cleans up error
handling to return either -1 or 0, instead of potentially returning
partial (last iovec) I/O lengths.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The lkl timer IRQ doesn't use its callback parameter, so drop it from
lkl_host_ops altogether. This avoids the extra posix-host alloc/free
while still addressing the compiler warnings fixed with commit
648f7902bc ("lkl: posix: implement wrapper for timer callback").
Signed-off-by: David Disseldorp <ddiss@suse.de>