mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
Introduce a kexec-based selftest, luo_kexec_simple, to validate the end-to-end lifecycle of a Live Update Orchestrator session across a reboot. While existing tests verify the uAPI in a pre-reboot context, this test ensures that the core functionality—preserving state via Kexec Handover and restoring it in a new kernel—works as expected. The test operates in two stages, managing its state across the reboot by preserving a dedicated "state session" containing a memfd. This mechanism dogfoods the LUO feature itself for state tracking, making the test self-contained. The test validates the following sequence: Stage 1 (Pre-kexec): - Creates a test session (test-session). - Creates and preserves a memfd with a known data pattern into the test session. - Creates the state-tracking session to signal progression to Stage 2. - Executes a kexec reboot via a helper script. Stage 2 (Post-kexec): - Retrieves the state-tracking session to confirm it is in the post-reboot stage. - Retrieves the preserved test session. - Restores the memfd from the test session and verifies its contents match the original data pattern written in Stage 1. - Finalizes both the test and state sessions to ensure a clean teardown. The test relies on a helper script (do_kexec.sh) to perform the reboot and a shared utility library (luo_test_utils.c) for common LUO operations, keeping the main test logic clean and focused. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Pasha Tatashin <[email protected]> Reviewed-by: Zhu Yanjun <[email protected]> Reviewed-by: Mike Rapoport (Microsoft) <[email protected]> Tested-by: David Matlack <[email protected]> Cc: Aleksander Lobakin <[email protected]> Cc: Alexander Graf <[email protected]> Cc: Alice Ryhl <[email protected]> Cc: Andriy Shevchenko <[email protected]> Cc: anish kumar <[email protected]> Cc: Anna Schumaker <[email protected]> Cc: Bartosz Golaszewski <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Borislav Betkov <[email protected]> Cc: Chanwoo Choi <[email protected]> Cc: Chen Ridong <[email protected]> Cc: Chris Li <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Daniel Wagner <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Dan Williams <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: David Jeffery <[email protected]> Cc: David Rientjes <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Guixin Liu <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Ilpo Järvinen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Jann Horn <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Joanthan Cameron <[email protected]> Cc: Joel Granados <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Lennart Poettering <[email protected]> Cc: Leon Romanovsky <[email protected]> Cc: Leon Romanovsky <[email protected]> Cc: Lukas Wunner <[email protected]> Cc: Marc Rutland <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Matthew Maurer <[email protected]> Cc: Miguel Ojeda <[email protected]> Cc: Myugnjoo Ham <[email protected]> Cc: Parav Pandit <[email protected]> Cc: Pratyush Yadav <[email protected]> Cc: Pratyush Yadav <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Saeed Mahameed <[email protected]> Cc: Samiullah Khawaja <[email protected]> Cc: Song Liu <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Stuart Hayes <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Thomas Gleinxer <[email protected]> Cc: Thomas Weißschuh <[email protected]> Cc: Vincent Guittot <[email protected]> Cc: William Tu <[email protected]> Cc: Yoann Congal <[email protected]> Cc: Zijun Hu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
45 lines
1.3 KiB
C
45 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
* Copyright (c) 2025, Google LLC.
|
|
* Pasha Tatashin <[email protected]>
|
|
*
|
|
* Utility functions for LUO kselftests.
|
|
*/
|
|
|
|
#ifndef LUO_TEST_UTILS_H
|
|
#define LUO_TEST_UTILS_H
|
|
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <linux/liveupdate.h>
|
|
#include "../kselftest.h"
|
|
|
|
#define LUO_DEVICE "/dev/liveupdate"
|
|
|
|
#define fail_exit(fmt, ...) \
|
|
ksft_exit_fail_msg("[%s:%d] " fmt " (errno: %s)\n", \
|
|
__func__, __LINE__, ##__VA_ARGS__, strerror(errno))
|
|
|
|
int luo_open_device(void);
|
|
int luo_create_session(int luo_fd, const char *name);
|
|
int luo_retrieve_session(int luo_fd, const char *name);
|
|
int luo_session_finish(int session_fd);
|
|
|
|
int create_and_preserve_memfd(int session_fd, int token, const char *data);
|
|
int restore_and_verify_memfd(int session_fd, int token, const char *expected_data);
|
|
|
|
void create_state_file(int luo_fd, const char *session_name, int token,
|
|
int next_stage);
|
|
void restore_and_read_stage(int state_session_fd, int token, int *stage);
|
|
|
|
void daemonize_and_wait(void);
|
|
|
|
typedef void (*luo_test_stage1_fn)(int luo_fd);
|
|
typedef void (*luo_test_stage2_fn)(int luo_fd, int state_session_fd);
|
|
|
|
int luo_test(int argc, char *argv[], const char *state_session_name,
|
|
luo_test_stage1_fn stage1, luo_test_stage2_fn stage2);
|
|
|
|
#endif /* LUO_TEST_UTILS_H */
|