Skip to content

Commit 80bab43

Browse files
soleenakpm00
authored andcommitted
selftests/liveupdate: add userspace API selftests
Introduce a selftest suite for LUO. These tests validate the core userspace-facing API provided by the /dev/liveupdate device and its associated ioctls. The suite covers fundamental device behavior, session management, and the file preservation mechanism using memfd as a test case. This provides regression testing for the LUO uAPI. The following functionality is verified: Device Access: Basic open and close operations on /dev/liveupdate. Enforcement of exclusive device access (verifying EBUSY on a second open). Session Management: Successful creation of sessions with unique names. Failure to create sessions with duplicate names. File Preservation: Preserving a single memfd and verifying its content remains intact post-preservation. Preserving multiple memfds within a single session, each with unique data. A complex scenario involving multiple sessions, each containing a mix of empty and data-filled memfds. Note: This test suite is limited to verifying the pre-kexec functionality of LUO (e.g., session creation, file preservation). The post-kexec restoration of resources is not covered, as the kselftest framework does not currently support orchestrating a reboot and continuing execution in the new kernel. Link: https://lkml.kernel.org/r/20251125165850.3389713-17-pasha.tatashin@soleen.com Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com> Reviewed-by: Pratyush Yadav <pratyush@kernel.org> Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Tested-by: David Matlack <dmatlack@google.com> Cc: Aleksander Lobakin <aleksander.lobakin@intel.com> Cc: Alexander Graf <graf@amazon.com> Cc: Alice Ryhl <aliceryhl@google.com> Cc: Andriy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: anish kumar <yesanishhere@gmail.com> Cc: Anna Schumaker <anna.schumaker@oracle.com> Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Borislav Betkov <bp@alien8.de> Cc: Chanwoo Choi <cw00.choi@samsung.com> Cc: Chen Ridong <chenridong@huawei.com> Cc: Chris Li <chrisl@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Daniel Wagner <wagi@kernel.org> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: David Jeffery <djeffery@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guixin Liu <kanie@linux.alibaba.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Hugh Dickins <hughd@google.com> Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Jann Horn <jannh@google.com> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Joanthan Cameron <Jonathan.Cameron@huawei.com> Cc: Joel Granados <joel.granados@kernel.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Lennart Poettering <lennart@poettering.net> Cc: Leon Romanovsky <leon@kernel.org> Cc: Leon Romanovsky <leonro@nvidia.com> Cc: Lukas Wunner <lukas@wunner.de> Cc: Marc Rutland <mark.rutland@arm.com> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Matthew Maurer <mmaurer@google.com> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Myugnjoo Ham <myungjoo.ham@samsung.com> Cc: Parav Pandit <parav@nvidia.com> Cc: Pratyush Yadav <ptyadav@amazon.de> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Saeed Mahameed <saeedm@nvidia.com> Cc: Samiullah Khawaja <skhawaja@google.com> Cc: Song Liu <song@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Stuart Hayes <stuart.w.hayes@gmail.com> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleinxer <tglx@linutronix.de> Cc: Thomas Weißschuh <linux@weissschuh.net> Cc: Vincent Guittot <vincent.guittot@linaro.org> Cc: William Tu <witu@nvidia.com> Cc: Yoann Congal <yoann.congal@smile.fr> Cc: Zhu Yanjun <yanjun.zhu@linux.dev> Cc: Zijun Hu <quic_zijuhu@quicinc.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 15fc11b commit 80bab43

6 files changed

Lines changed: 397 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14480,6 +14480,7 @@ F: include/linux/liveupdate/
1448014480
F: include/uapi/linux/liveupdate.h
1448114481
F: kernel/liveupdate/
1448214482
F: mm/memfd_luo.c
14483+
F: tools/testing/selftests/liveupdate/
1448314484

1448414485
LLC (802.2)
1448514486
L: netdev@vger.kernel.org

tools/testing/selftests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ TARGETS += kvm
5454
TARGETS += landlock
5555
TARGETS += lib
5656
TARGETS += livepatch
57+
TARGETS += liveupdate
5758
TARGETS += lkdtm
5859
TARGETS += lsm
5960
TARGETS += membarrier
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
*
3+
!/**/
4+
!*.c
5+
!*.h
6+
!*.sh
7+
!.gitignore
8+
!config
9+
!Makefile
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
TEST_GEN_PROGS += liveupdate
4+
5+
include ../lib.mk
6+
7+
CFLAGS += $(KHDR_INCLUDES)
8+
CFLAGS += -Wall -O2 -Wno-unused-function
9+
CFLAGS += -MD
10+
11+
LIB_O := $(patsubst %.c, $(OUTPUT)/%.o, $(LIB_C))
12+
TEST_O := $(patsubst %, %.o, $(TEST_GEN_PROGS))
13+
TEST_O += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED))
14+
15+
TEST_DEP_FILES := $(patsubst %.o, %.d, $(LIB_O))
16+
TEST_DEP_FILES += $(patsubst %.o, %.d, $(TEST_O))
17+
-include $(TEST_DEP_FILES)
18+
19+
$(LIB_O): $(OUTPUT)/%.o: %.c
20+
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
21+
22+
$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIB_O)
23+
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIB_O) $(LDLIBS) -o $@
24+
25+
EXTRA_CLEAN += $(LIB_O)
26+
EXTRA_CLEAN += $(TEST_O)
27+
EXTRA_CLEAN += $(TEST_DEP_FILES)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CONFIG_BLK_DEV_INITRD=y
2+
CONFIG_KEXEC_FILE=y
3+
CONFIG_KEXEC_HANDOVER=y
4+
CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y
5+
CONFIG_KEXEC_HANDOVER_DEBUGFS=y
6+
CONFIG_KEXEC_HANDOVER_DEBUG=y
7+
CONFIG_LIVEUPDATE=y
8+
CONFIG_LIVEUPDATE_TEST=y
9+
CONFIG_MEMFD_CREATE=y
10+
CONFIG_TMPFS=y
11+
CONFIG_SHMEM=y

0 commit comments

Comments
 (0)